本文整理汇总了Java中com.nimbusds.jose.Algorithm类的典型用法代码示例。如果您正苦于以下问题:Java Algorithm类的具体用法?Java Algorithm怎么用?Java Algorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Algorithm类属于com.nimbusds.jose包,在下文中一共展示了Algorithm类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeRSA
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
public RSAKey makeRSA(Integer keySize, KeyUse keyUse, Algorithm keyAlg, String kid) {
try {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(keySize);
KeyPair kp = generator.generateKeyPair();
RSAPublicKey pub = (RSAPublicKey) kp.getPublic();
RSAPrivateKey priv = (RSAPrivateKey) kp.getPrivate();
return new RSAKey.Builder(pub)
.privateKey(priv)
.keyUse(keyUse)
.algorithm(keyAlg)
.keyID(kid)
.build();
} catch (NoSuchAlgorithmException e) {
// FIXME Auto-generated catch block
e.printStackTrace();
return null;
}
}
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:23,代码来源:RSAKeyFactory.java
示例2: make
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
private static RSAKey make(Integer keySize, KeyUse keyUse, Algorithm keyAlg, String kid) {
try {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(keySize);
KeyPair kp = generator.generateKeyPair();
RSAPublicKey pub = (RSAPublicKey) kp.getPublic();
RSAPrivateKey priv = (RSAPrivateKey) kp.getPrivate();
return new RSAKey.Builder(pub)
.privateKey(priv)
.keyUse(keyUse)
.algorithm(keyAlg)
.keyID(kid)
.build();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
开发者ID:atbashEE,项目名称:jsr375-extensions,代码行数:22,代码来源:RSAKeysGenerator.java
示例3: make
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
private static RSAKey make(Integer keySize, KeyUse keyUse, Algorithm keyAlg, String kid) {
try {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(keySize);
KeyPair kp = generator.generateKeyPair();
RSAPublicKey pub = (RSAPublicKey) kp.getPublic();
RSAPrivateKey priv = (RSAPrivateKey) kp.getPrivate();
RSAKey rsaKey = new RSAKey.Builder(pub)
.privateKey(priv)
.keyUse(keyUse)
.algorithm(keyAlg)
.keyID(kid)
.build();
return rsaKey;
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
开发者ID:rdebusscher,项目名称:soteria-jwt,代码行数:25,代码来源:JWKManager.java
示例4: getSigner
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
/**
* Returns correct implementation of signer based on algorithm type.
*
* @param jwsAlgorithm
* JWS algorithm
* @return signer for algorithm and private key
* @throws JOSEException
* if algorithm cannot be supported
*/
private JWSSigner getSigner(Algorithm jwsAlgorithm) throws JOSEException {
if (JWSAlgorithm.Family.EC.contains(jwsAlgorithm)) {
return new ECDSASigner((ECPrivateKey) credential.getPrivateKey());
}
if (JWSAlgorithm.Family.RSA.contains(jwsAlgorithm)) {
return new RSASSASigner(credential.getPrivateKey());
}
if (JWSAlgorithm.Family.HMAC_SHA.contains(jwsAlgorithm)) {
return new MACSigner(credential.getSecretKey());
}
throw new JOSEException("Unsupported algorithm " + jwsAlgorithm.getName());
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:SignRegistrationResponse.java
示例5: testSetters
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
@Test
public void testSetters() {
jwk.setKid("kid");
jwk.setAlgorithm(algo);
Assert.assertEquals(jwk.getKid(), "kid");
Assert.assertEquals(jwk.getAlgorithm(), new Algorithm("RS256"));
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:8,代码来源:BasicJWKCredentialTest.java
示例6: HMACSecret
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
public HMACSecret(byte[] secret, String id) {
super(KeyType.OCT, KeyUse.SIGNATURE, null, new Algorithm("HMAC"), id, null, null, null, null, null);
if (!StringUtils.hasText(id)) {
throw new IllegalArgumentException("Parameter id should have a value");
}
this.secret = Objects.requireNonNull(secret, "Parameter secret should not be null");
}
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:8,代码来源:HMACSecret.java
示例7: createKey
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
private void createKey() {
RSAKeyFactory keyFactory = new RSAKeyFactory();
// FIXME Not only RSA and Signature
RSAKey rsaKey = keyFactory.makeRSA(Integer.valueOf(keySize.getValue()), KeyUse.SIGNATURE, new Algorithm("PS512"), id.getValue());
jwkSetData.add(rsaKey);
new JWKView(primaryStage, rootPane, jwkSetData).initialize();
}
开发者ID:atbashEE,项目名称:atbash-octopus,代码行数:9,代码来源:NewJWKView.java
示例8: main
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
public static void main(String[] args) {
List<JWK> jwks = new ArrayList<>();
// First key
String xApiKey = UUID.randomUUID().toString();
JWK jwk = make(2048, KeyUse.SIGNATURE, new Algorithm("PS512"), xApiKey);
jwks.add(jwk);
// Second key
xApiKey = UUID.randomUUID().toString();
jwk = make(2048, KeyUse.SIGNATURE, new Algorithm("PS512"), xApiKey);
jwks.add(jwk);
// Third key
xApiKey = UUID.randomUUID().toString();
jwk = make(2048, KeyUse.SIGNATURE, new Algorithm("PS512"), xApiKey);
jwks.add(jwk);
JWKSet jwkSet = new JWKSet(jwks);
System.out.println(jwkSet.toJSONObject(false));
}
开发者ID:atbashEE,项目名称:jsr375-extensions,代码行数:25,代码来源:RSAKeysGenerator.java
示例9: main
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
public static void main(String[] args) {
String xApiKey = UUID.randomUUID().toString();
JWK jwk = make(2048, KeyUse.SIGNATURE, new Algorithm("PS512"), xApiKey);
System.out.println("x-api-key");
System.out.println(xApiKey);
System.out.println("Private");
System.out.println(jwk.toJSONString());
System.out.println("Public");
System.out.println(jwk.toPublicJWK().toJSONString());
}
开发者ID:rdebusscher,项目名称:soteria-jwt,代码行数:14,代码来源:JWKManager.java
示例10: mapDigestAlgorithm
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
/**
* This method maps signature algorithm define in identity.xml to digest algorithms to generate the at_hash
*
* @param signatureAlgorithm
* @return
* @throws IdentityOAuth2Exception
*/
protected String mapDigestAlgorithm(Algorithm signatureAlgorithm) throws IdentityOAuth2Exception {
if (JWSAlgorithm.RS256.equals(signatureAlgorithm) || JWSAlgorithm.HS256.equals(signatureAlgorithm) ||
JWSAlgorithm.ES256.equals(signatureAlgorithm)) {
return SHA256;
} else if (JWSAlgorithm.RS384.equals(signatureAlgorithm) || JWSAlgorithm.HS384.equals(signatureAlgorithm) ||
JWSAlgorithm.ES384.equals(signatureAlgorithm)) {
return SHA384;
} else if (JWSAlgorithm.RS512.equals(signatureAlgorithm) || JWSAlgorithm.HS512.equals(signatureAlgorithm) ||
JWSAlgorithm.ES512.equals(signatureAlgorithm)) {
return SHA512;
}
throw new RuntimeException("Cannot map Signature Algorithm in identity.xml to hashing algorithm");
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:22,代码来源:DefaultIDTokenBuilder.java
示例11: getAlgorithm
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Algorithm getAlgorithm() {
return jwkAlgorithm;
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:6,代码来源:BasicJWKCredential.java
示例12: setUp
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
@BeforeMethod
protected void setUp() throws Exception {
jwk = new BasicJWKCredential();
algo = new Algorithm("RS256");
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:6,代码来源:BasicJWKCredentialTest.java
示例13: getAuthenticator
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
@Override
protected Authenticator<TokenCredentials> getAuthenticator(final Credential credential) {
final TokenCredential tokenCredential = (TokenCredential) credential;
LOGGER.debug("Locating token secret for service [{}]", tokenCredential.getService());
final RegisteredService service = this.servicesManager.findServiceBy(tokenCredential.getService());
final String signingSecret = getRegisteredServiceJwtSigningSecret(service);
final String encryptionSecret = getRegisteredServiceJwtEncryptionSecret(service);
final String signingSecretAlg =
StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_SIGNING_ALG),
JWSAlgorithm.HS256.getName());
final String encryptionSecretAlg =
StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_ENCRYPTION_ALG),
JWEAlgorithm.DIR.getName());
final String encryptionSecretMethod =
StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_ENCRYPTION_METHOD),
EncryptionMethod.A192CBC_HS384.getName());
if (StringUtils.isNotBlank(signingSecret)) {
Set<Algorithm> sets = new HashSet<>();
sets.addAll(JWSAlgorithm.Family.EC);
sets.addAll(JWSAlgorithm.Family.HMAC_SHA);
sets.addAll(JWSAlgorithm.Family.RSA);
sets.addAll(JWSAlgorithm.Family.SIGNATURE);
final JWSAlgorithm signingAlg = findAlgorithmFamily(sets, signingSecretAlg);
final JwtAuthenticator a = new JwtAuthenticator();
a.setSignatureConfiguration(new SecretSignatureConfiguration(signingSecret, signingAlg));
if (StringUtils.isNotBlank(encryptionSecret)) {
sets = new HashSet<>();
sets.addAll(JWEAlgorithm.Family.AES_GCM_KW);
sets.addAll(JWEAlgorithm.Family.AES_KW);
sets.addAll(JWEAlgorithm.Family.ASYMMETRIC);
sets.addAll(JWEAlgorithm.Family.ECDH_ES);
sets.addAll(JWEAlgorithm.Family.PBES2);
sets.addAll(JWEAlgorithm.Family.RSA);
sets.addAll(JWEAlgorithm.Family.SYMMETRIC);
final JWEAlgorithm encAlg = findAlgorithmFamily(sets, encryptionSecretAlg);
sets = new HashSet<>();
sets.addAll(EncryptionMethod.Family.AES_CBC_HMAC_SHA);
sets.addAll(EncryptionMethod.Family.AES_GCM);
final EncryptionMethod encMethod = findAlgorithmFamily(sets, encryptionSecretMethod);
a.setEncryptionConfiguration(new SecretEncryptionConfiguration(encryptionSecret, encAlg, encMethod));
} else {
LOGGER.warn("JWT authentication is configured to share a single key for both signing/encryption");
}
return a;
}
LOGGER.warn("No token signing secret is defined for service [{}]. Ensure [{}] property is defined for service",
service.getServiceId(), TokenConstants.PROPERTY_NAME_TOKEN_SECRET_SIGNING);
return null;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:61,代码来源:TokenAuthenticationHandler.java
示例14: findAlgorithmFamily
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
private static <T extends Algorithm> T findAlgorithmFamily(final Set<Algorithm> family, final String alg) {
return (T) family.stream().filter(l -> l.getName().equalsIgnoreCase(alg)).findFirst().get();
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:4,代码来源:TokenAuthenticationHandler.java
示例15: createIdToken
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
@Override
public JWT createIdToken(final ClientDetailsEntity client, final OAuth2Request request,
final Date issueTime, final String sub,
final OAuth2AccessTokenEntity accessToken) {
JWSAlgorithm signingAlg = jwtService.getDefaultSigningAlgorithm();
if (client.getIdTokenSignedResponseAlg() != null) {
signingAlg = client.getIdTokenSignedResponseAlg();
}
final JWTClaimsSet.Builder idClaims = new JWTClaimsSet.Builder();
log.debug("Request {} extension {}", ConnectRequestParameters.MAX_AGE, request.getExtensions().get(ConnectRequestParameters.MAX_AGE));
log.debug("Request {} extension {}", OIDCConstants.ID_TOKEN, request.getExtensions().get(OIDCConstants.ID_TOKEN));
log.debug("Client require authN time {}", client.getRequireAuthTime());
calculateAuthTimeClaim(request, idClaims);
idClaims.issueTime(issueTime);
calculateAmrAndAcrClaims(accessToken, idClaims);
calculateExpirationClaim(client, idClaims);
idClaims.issuer(configBean.getIssuer());
log.debug("issuer is set to {}", configBean.getIssuer());
idClaims.subject(sub);
log.debug("sub is set to {}", sub);
idClaims.audience(Lists.newArrayList(client.getClientId()));
log.debug("audience is set to {}", client.getClientId());
final String jwtId = UUID.randomUUID().toString();
idClaims.jwtID(jwtId);
log.debug("JWT id is set to {}", jwtId);
calculateNonceClaim(request, idClaims);
final Set<String> responseTypes = request.getResponseTypes();
calculateAtHashClaim(accessToken, signingAlg, idClaims, responseTypes);
JWT idToken = null;
if (client.getIdTokenEncryptedResponseAlg() != null
&& !client.getIdTokenEncryptedResponseAlg().equals(Algorithm.NONE)
&& client.getIdTokenEncryptedResponseEnc() != null
&& !client.getIdTokenEncryptedResponseEnc().equals(Algorithm.NONE)
&& (!Strings.isNullOrEmpty(client.getJwksUri()) || client.getJwks() != null)) {
idToken = encryptIdToken(client, idClaims);
} else {
idToken = signIdToken(client, signingAlg, idClaims);
}
log.debug("Mapping the idToken to the authentication of client {}",
accessToken.getAuthenticationHolder().getClientId());
return idToken;
// idTokenEntity.setAuthenticationHolder(accessToken.getAuthenticationHolder());
//
// // create a scope set with just the special "id-token" scope
// final Set<String> idScopes = Sets.newHashSet(SystemScopeService.ID_TOKEN_SCOPE);
// idTokenEntity.setScope(idScopes);
// log.debug("Configured scopes for the idToken scope {} are {}",
// SystemScopeService.ID_TOKEN_SCOPE, idScopes);
//
// idTokenEntity.setClient(accessToken.getClient());
//
// return idTokenEntity;
}
开发者ID:uchicago,项目名称:shibboleth-oidc,代码行数:72,代码来源:ShibbolethAcrAwareTokenService.java
示例16: setAlgorithm
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
/**
* Set the algorithm of jwk.
*
* @param algorithm algorithm of jwk.
*/
public void setAlgorithm(Algorithm algorithm) {
jwkAlgorithm = algorithm;
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:9,代码来源:BasicJWKCredential.java
示例17: getAlgorithm
import com.nimbusds.jose.Algorithm; //导入依赖的package包/类
/**
* Get algorithm of JWK.
*
* @return algorithm of JWK.
*/
@Nonnull
public Algorithm getAlgorithm();
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:8,代码来源:JWKCredential.java
注:本文中的com.nimbusds.jose.Algorithm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论