本文整理汇总了Java中org.jose4j.jws.AlgorithmIdentifiers.RSA_USING_SHA256属性的典型用法代码示例。如果您正苦于以下问题:Java AlgorithmIdentifiers.RSA_USING_SHA256属性的具体用法?Java AlgorithmIdentifiers.RSA_USING_SHA256怎么用?Java AlgorithmIdentifiers.RSA_USING_SHA256使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jose4j.jws.AlgorithmIdentifiers
的用法示例。
在下文中一共展示了AlgorithmIdentifiers.RSA_USING_SHA256属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
/**
* Initialize this component by building up the consumer for JWT using the
* pre-configured secret
*
* @param rsaPublicKey the RSA public key to be used for verification.
*
* @return Fluent interface.
*/
SSOFacade initialize(final RSAPublicKey rsaPublicKey) {
if (logger.isDebugEnabled()) {
logger.debug("Initializing single-sign-on manager SSOFacade. ");
}
Objects.requireNonNull(rsaPublicKey);
// Build up the algorithm constraints by only accepting RSA_USING_SHA256.
final AlgorithmConstraints algorithmConstraints = new AlgorithmConstraints(
AlgorithmConstraints.ConstraintType.WHITELIST, AlgorithmIdentifiers.RSA_USING_SHA256);
this.jwtConsumer = new JwtConsumerBuilder()
.setJwsAlgorithmConstraints(algorithmConstraints)
.setSkipDefaultAudienceValidation()
.setVerificationKey(rsaPublicKey)
.setRequireExpirationTime()
.setRequireNotBefore()
.setRequireIssuedAt()
.build();
return this;
}
示例2: generateAccessTokenHash
private String generateAccessTokenHash(final AccessToken accessTokenId,
final OidcRegisteredService service) {
final byte[] tokenBytes = accessTokenId.getId().getBytes();
final String hashAlg;
switch (signingService.getJsonWebKeySigningAlgorithm()) {
case AlgorithmIdentifiers.RSA_USING_SHA512:
hashAlg = MessageDigestAlgorithms.SHA_512;
break;
case AlgorithmIdentifiers.RSA_USING_SHA256:
default:
hashAlg = MessageDigestAlgorithms.SHA_256;
}
LOGGER.debug("Digesting access token hash via algorithm [{}]", hashAlg);
final byte[] digested = DigestUtils.rawDigest(hashAlg, tokenBytes);
final byte[] hashBytesLeftHalf = Arrays.copyOf(digested, digested.length / 2);
return EncodingUtils.encodeBase64(hashBytesLeftHalf);
}
示例3: getAlgorithmIdentifier
private String getAlgorithmIdentifier() {
String algorithmId = AlgorithmIdentifiers.RSA_USING_SHA256;
switch (this.encryptionAlgorithm) {
case RSA_SHA_384:
algorithmId = AlgorithmIdentifiers.RSA_USING_SHA384;
break;
case RSA_SHA_512:
algorithmId = AlgorithmIdentifiers.RSA_USING_SHA512;
break;
case RSA_SHA_256:
default:
break;
}
return algorithmId;
}
示例4: keyAlgorithm
/**
* Analyzes the key used in the {@link JsonWebKey}, and returns the key algorithm
* identifier for {@link JsonWebSignature}.
*
* @param jwk
* {@link JsonWebKey} to analyze
* @return algorithm identifier
* @throws IllegalArgumentException
* there is no corresponding algorithm identifier for the key
*/
public static String keyAlgorithm(JsonWebKey jwk) {
if (jwk instanceof EllipticCurveJsonWebKey) {
EllipticCurveJsonWebKey ecjwk = (EllipticCurveJsonWebKey) jwk;
switch (ecjwk.getCurveName()) {
case "P-256":
return AlgorithmIdentifiers.ECDSA_USING_P256_CURVE_AND_SHA256;
case "P-384":
return AlgorithmIdentifiers.ECDSA_USING_P384_CURVE_AND_SHA384;
case "P-521":
return AlgorithmIdentifiers.ECDSA_USING_P521_CURVE_AND_SHA512;
default:
throw new IllegalArgumentException("Unknown EC name "
+ ecjwk.getCurveName());
}
} else if (jwk instanceof RsaJsonWebKey) {
return AlgorithmIdentifiers.RSA_USING_SHA256;
} else {
throw new IllegalArgumentException("Unknown algorithm " + jwk.getAlgorithm());
}
}
示例5: getJsonWebKeySigningAlgorithm
public String getJsonWebKeySigningAlgorithm() {
return AlgorithmIdentifiers.RSA_USING_SHA256;
}
示例6: JwtTokenIssuer
JwtTokenIssuer(String issuer, PrivateKey privateKey, Certificate cert)
{
this(issuer, 0, AlgorithmIdentifiers.RSA_USING_SHA256, privateKey, cert, null);
}