Skip to content

Commit

Permalink
Corrected test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Garry committed Jun 3, 2016
1 parent 2a5c910 commit e664c34
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions pac4j-jwt/src/main/java/org/pac4j/jwt/profile/JwtGenerator.java
Expand Up @@ -75,16 +75,7 @@ public JwtGenerator(final String signingSecret, final String encryptionSecret) {
* @return the created JWT
*/
public String generate(final U profile) {
try {
// Create HMAC signer
JWSSigner signer = null;
if (CommonHelper.isNotBlank(this.signingSecret)) {
signer = new MACSigner(this.signingSecret);
}
return generate(profile, signer, this.jwsAlgorithm);
} catch (JOSEException e) {
throw new RuntimeException(e);
}
return generate(profile, null, this.jwsAlgorithm);
}

/**
Expand Down Expand Up @@ -135,16 +126,15 @@ protected String encryptJwt(final SignedJWT signedJWT) throws Exception {
}

protected SignedJWT signJwt(final JWTClaimsSet claims) throws JOSEException {
// Create HMAC signer
JWSSigner signer = null;
if (CommonHelper.isNotBlank(this.signingSecret)) {
signer = new MACSigner(this.signingSecret);
}
return signJwt(claims, signer, this.jwsAlgorithm);
return signJwt(claims, null, this.jwsAlgorithm);
}

protected SignedJWT signJwt(final JWTClaimsSet claims, JWSSigner signer, JWSAlgorithm jwsAlgorithm) throws JOSEException {
final SignedJWT signedJWT = new SignedJWT(new JWSHeader(jwsAlgorithm), claims);
if (signer == null) {
// Create HMAC signer
signer = new MACSigner(this.signingSecret);
}
final SignedJWT signedJWT = new SignedJWT(new JWSHeader(jwsAlgorithm), claims);
// Apply the HMAC
signedJWT.sign(signer);
return signedJWT;
Expand Down

0 comments on commit e664c34

Please sign in to comment.