Skip to content

Commit

Permalink
Merge pull request #15 from madurangasiriwardena/base64
Browse files Browse the repository at this point in the history
Removing java.util.Base64
  • Loading branch information
godwinamila committed Mar 16, 2016
2 parents c16f4cc + c25cc9e commit 5d87fb1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import org.apache.commons.codec.binary.Base64;

/**
* Implements the AuthorizationGrantHandler for the Grant Type : authorization_code.
Expand Down Expand Up @@ -192,7 +192,7 @@ public boolean validateGrant(OAuthTokenReqMessageContext tokReqMsgCtx) throws Id
String PKCECodeChallenge = authzCodeDO.getPkceCodeChallenge();
String PKCECodeChallengeMethod = authzCodeDO.getPkceCodeChallengeMethod();
String codeVerifier = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getPkceCodeVerifier();
if(!doPKCEValidation(PKCECodeChallenge,codeVerifier,PKCECodeChallengeMethod,oAuthAppDO)) {
if (!doPKCEValidation(PKCECodeChallenge, codeVerifier, PKCECodeChallengeMethod, oAuthAppDO)) {
//possible malicious oAuthRequest
log.warn("Failed PKCE Verification for oAuth 2.0 request");
return false;
Expand Down Expand Up @@ -318,7 +318,7 @@ private boolean doPKCEValidation(String referenceCodeChallenge, String codeVerif
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");

byte[] hash = messageDigest.digest(codeVerifier.getBytes(StandardCharsets.US_ASCII));
String referencePKCECodeChallenge = new String(Base64.getEncoder().encode(hash));
String referencePKCECodeChallenge = new String(new Base64().encode(hash));
if (!referencePKCECodeChallenge.equals(referenceCodeChallenge)) {
return false;
}
Expand Down

0 comments on commit 5d87fb1

Please sign in to comment.