corb2 icon indicating copy to clipboard operation
corb2 copied to clipboard

Adjustments for Java 11+ and deprecated JAXB javax.xml.bind package

Open hansenmc opened this issue 2 years ago • 0 comments

javax.xml.bind.DatatypeConverter is deprecated and removed in Java 11. Will need to either add the necessary JAXB dependency or modules, or look to use the java.util.Base64 class instead.

Build issues observed building with a more recent version of Java:

/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/PrivateKeyDecrypter.java:50: error: package javax.xml.bind does not exist
import javax.xml.bind.DatatypeConverter;
                     ^
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/HostKeyDecrypter.java:53: error: package javax.xml.bind does not exist
import javax.xml.bind.DatatypeConverter;
                     ^
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/PrivateKeyDecrypter.java:120: error: cannot find symbol
                    privateKey = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(DatatypeConverter.parseBase64Binary(keyAsString)));
                                                                                    ^
  symbol:   variable DatatypeConverter
  location: class PrivateKeyDecrypter
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/PrivateKeyDecrypter.java:154: error: cannot find symbol
                dValue = new String(cipher.doFinal(DatatypeConverter.parseBase64Binary(value)));
                                                   ^
  symbol:   variable DatatypeConverter
  location: class PrivateKeyDecrypter
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/PrivateKeyDecrypter.java:224: error: cannot find symbol
            String encryptedText = DatatypeConverter.printBase64Binary(cipher.doFinal(clearText.getBytes("UTF-8")));
                                   ^
  symbol:   variable DatatypeConverter
  location: class PrivateKeyDecrypter
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/HostKeyDecrypter.java:332: error: cannot find symbol
        return DatatypeConverter.printHexBinary(encryptedVal);
               ^
  symbol:   variable DatatypeConverter
  location: class HostKeyDecrypter
/Users/mhansen/code/corb2/src/main/java/com/marklogic/developer/corb/HostKeyDecrypter.java:346: error: cannot find symbol
        byte[] encryptedTextBytes = DatatypeConverter.parseHexBinary(encryptedText);

hansenmc avatar Oct 15 '22 21:10 hansenmc