Skip to content

Commit

Permalink
Replace "javax.xml.bind.DatatypeConverter" with "org.apache.commons.c…
Browse files Browse the repository at this point in the history
…odec.binary.Base64", which is used for Base64 encoding/decoding.

"DatatypeConverter" caused a serious problem in "WildFly 9". The problem is that the session stored in the cookie can not be restored properly.
  • Loading branch information
visavis2k committed Jan 9, 2018
1 parent 746dbd3 commit ec96556
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.chequer.axboot.admin.domain.user.SessionUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
Expand Down Expand Up @@ -80,11 +80,11 @@ private byte[] toJSON(SessionUser user) {
}

private String toBase64(byte[] content) {
return DatatypeConverter.printBase64Binary(content);
return Base64.encodeBase64URLSafeString(content);
}

private byte[] fromBase64(String content) {
return DatatypeConverter.parseBase64Binary(content);
return Base64.decodeBase64(content);
}

private synchronized byte[] createHmac(byte[] content) {
Expand Down

0 comments on commit ec96556

Please sign in to comment.