List of usage examples for org.springframework.security.jwt.crypto.sign RsaVerifier verify
public void verify(byte[] content, byte[] sig)
From source file:org.cloudfoundry.identity.uaa.oauth.JwtTokenEnhancer.java
@Override public void afterPropertiesSet() throws Exception { // Check the signing and verification keys match if (signer instanceof RsaSigner) { RsaVerifier verifier;//from w w w .ja va2 s . c o m try { verifier = new RsaVerifier(verifierKey); } catch (Exception e) { logger.warn("Unable to create an RSA verifier from verifierKey"); return; } byte[] test = "test".getBytes(); try { verifier.verify(test, signer.sign(test)); logger.info("Signing and verification RSA keys match"); } catch (InvalidSignatureException e) { logger.error("Signing and verification RSA keys do not match"); } } else { // Avoid a race condition where Assert.state(this.signingKey == this.verifierKey, "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key"); } }
From source file:org.cloudfoundry.identity.uaa.oauth.token.SignerProvider.java
@Override public void afterPropertiesSet() throws Exception { if (signer instanceof RsaSigner) { type = "RSA"; RsaVerifier verifier; try {/*from w w w . j av a2 s .co m*/ verifier = new RsaVerifier(verifierKey); } catch (Exception e) { throw new RuntimeException("Unable to create an RSA verifier from verifierKey", e); } byte[] test = "test".getBytes(); try { verifier.verify(test, signer.sign(test)); logger.debug("Signing and verification RSA keys match"); } catch (InvalidSignatureException e) { throw new RuntimeException("Signing and verification RSA keys do not match", e); } } else { Assert.state(this.signingKey == this.verifierKey, "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key"); } }
From source file:org.springframework.security.oauth2.provider.token.JwtTokenEnhancer.java
public void afterPropertiesSet() throws Exception { // Check the signing and verification keys match if (signer instanceof RsaSigner) { RsaVerifier verifier; try {/*from www.j av a2 s. c o m*/ verifier = new RsaVerifier(verifierKey); } catch (Exception e) { logger.warn("Unable to create an RSA verifier from verifierKey"); return; } byte[] test = "test".getBytes(); try { verifier.verify(test, signer.sign(test)); logger.info("Signing and verification RSA keys match"); } catch (InvalidSignatureException e) { logger.error("Signing and verification RSA keys do not match"); } } else { // Avoid a race condition where Assert.state(this.signingKey == this.verifierKey, "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key"); } SignatureVerifier verifier = new MacSigner(verifierKey); try { verifier = new RsaVerifier(verifierKey); } catch (Exception e) { logger.warn("Unable to create an RSA verifier from verifierKey"); } this.verifier = verifier; }
From source file:org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter.java
public void afterPropertiesSet() throws Exception { // Check the signing and verification keys match if (signer instanceof RsaSigner) { RsaVerifier verifier; try {//w w w . ja v a 2 s . co m verifier = new RsaVerifier(verifierKey); } catch (Exception e) { logger.warn("Unable to create an RSA verifier from verifierKey"); return; } byte[] test = "test".getBytes(); try { verifier.verify(test, signer.sign(test)); logger.info("Signing and verification RSA keys match"); } catch (InvalidSignatureException e) { logger.error("Signing and verification RSA keys do not match"); } } else { // Avoid a race condition where setters are called in the wrong order. Use of == is intentional. Assert.state(this.signingKey == this.verifierKey, "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key"); } SignatureVerifier verifier = new MacSigner(verifierKey); try { verifier = new RsaVerifier(verifierKey); } catch (Exception e) { logger.warn("Unable to create an RSA verifier from verifierKey"); } this.verifier = verifier; }