Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed JAXB dependency #4471

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
Expand All @@ -42,7 +43,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpSession;
import javax.xml.bind.DatatypeConverter;

/**
* <p>This utility class is to provide both encryption and
Expand Down Expand Up @@ -203,7 +203,7 @@ private void setupKeyAndMac() {
try {
InitialContext context = new InitialContext();
String encodedKeyArray = (String) context.lookup("java:comp/env/jsf/ClientSideSecretKey");
byte[] keyArray = DatatypeConverter.parseBase64Binary(encodedKeyArray);
byte[] keyArray = Base64.getDecoder().decode(encodedKeyArray);
sk = new SecretKeySpec(keyArray, KEY_ALGORITHM);
}
catch(NamingException exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.crypto.spec.IvParameterSpec;
import javax.faces.FacesException;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.SortedMap;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -35,7 +36,6 @@
import javax.crypto.spec.SecretKeySpec;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.bind.DatatypeConverter;

/**
* <p>This utility class is to provide both encryption and
Expand Down Expand Up @@ -104,7 +104,7 @@ public String encrypt(String value) {
// encrypt the plaintext
byte[] encdata = encryptCipher.doFinal(bytes);
// Base64 encode the encrypted bytes
securedata = DatatypeConverter.printBase64Binary(encdata);
securedata = Base64.getEncoder().encodeToString(encdata);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException e) {
if (LOGGER.isLoggable(Level.SEVERE)) {
LOGGER.log(Level.SEVERE,
Expand All @@ -119,7 +119,7 @@ public String encrypt(String value) {

public String decrypt(String value) throws InvalidKeyException {

byte[] bytes = DatatypeConverter.parseBase64Binary(value);;
byte[] bytes = Base64.getDecoder().decode(value);

try {
Cipher decryptCipher = Cipher.getInstance(CIPHER_CODE);
Expand All @@ -146,7 +146,7 @@ private void setupKeyAndCharset() {
InitialContext context = new InitialContext();
String encodedKeyArray = (String) context.lookup("java:comp/env/jsf/FlashSecretKey");
if (null != encodedKeyArray) {
byte[] keyArray = DatatypeConverter.parseBase64Binary(encodedKeyArray);
byte[] keyArray = Base64.getDecoder().decode(encodedKeyArray);
if (keyArray.length < 16) {
throw new FacesException("key must be at least 16 bytes long.");
}
Expand Down