本文整理汇总了Java中com.nimbusds.jose.jwk.RSAKey.parse方法的典型用法代码示例。如果您正苦于以下问题:Java RSAKey.parse方法的具体用法?Java RSAKey.parse怎么用?Java RSAKey.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nimbusds.jose.jwk.RSAKey
的用法示例。
在下文中一共展示了RSAKey.parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveUsernamePasswordFromLoginToken
import com.nimbusds.jose.jwk.RSAKey; //导入方法依赖的package包/类
/**
* retrieves username and password from JSON web tocken
*
* @param token - the serialized JSON web token from login
* @return username and password (combined by ":")
*/
public static String retrieveUsernamePasswordFromLoginToken(String token) {
JWEObject jweObject;
try {
jweObject = JWEObject.parse(token);
// Decrypt with shared key
jweObject.decrypt(new RSADecrypter(RSA_KEYS.getPrivate()));
// Extract payload
SignedJWT signedJWT = jweObject.getPayload().toSignedJWT();
RSAKey serverPublicKey = RSAKey.parse(signedJWT.getHeader().getJWK().toJSONObject());
if (signedJWT.verify(new RSASSAVerifier(serverPublicKey))) {
//Token is valid
String username = signedJWT.getJWTClaimsSet().getSubject();
String password = signedJWT.getJWTClaimsSet().getStringClaim("password");
return username + ":" + password;
}
} catch (ParseException | JOSEException e) {
LOGGER.error(e);
}
return null;
}
示例2: retrievePublicKeyFromLoginToken
import com.nimbusds.jose.jwk.RSAKey; //导入方法依赖的package包/类
/**
* retrieves the client public key from Login Token
*
* @param token - the serialized JSON Web Token from login
* @return the public key as JWK object
*/
public static JWK retrievePublicKeyFromLoginToken(String token) {
JWK result = null;
JWEObject jweObject;
try {
jweObject = JWEObject.parse(token);
// Decrypt with shared key
jweObject.decrypt(new RSADecrypter(RSA_KEYS.getPrivate()));
// Extract payload
SignedJWT signedJWT = jweObject.getPayload().toSignedJWT();
result = signedJWT.getHeader().getJWK();
RSAKey publicKey = RSAKey.parse(result.toJSONObject());
if (signedJWT.verify(new RSASSAVerifier(publicKey))) {
return result;
}
} catch (ParseException | JOSEException e) {
LOGGER.error(e);
}
return null;
}
示例3: buildRSAKeyPairFromJwk
import com.nimbusds.jose.jwk.RSAKey; //导入方法依赖的package包/类
/**
* Build the RSA key pair from the JWK JSON.
*
* @param json the json
* @return the key pair
*/
public static KeyPair buildRSAKeyPairFromJwk(final String json) {
CommonHelper.assertNotBlank("json", json);
try {
final RSAKey rsaKey = RSAKey.parse(json);
return rsaKey.toKeyPair();
} catch (final JOSEException | ParseException e) {
throw new TechnicalException(e);
}
}
示例4: retrieveUsernameFromAuthenticationToken
import com.nimbusds.jose.jwk.RSAKey; //导入方法依赖的package包/类
/**
* retrieves the username from Authentication Token
*
* @param signedJWT - the authentication token
* @return the user name
*/
public static String retrieveUsernameFromAuthenticationToken(SignedJWT signedJWT) {
try {
// Extract payload
RSAKey serverPublicKey = RSAKey.parse(signedJWT.getHeader().getJWK().toJSONObject());
if (signedJWT.verify(new RSASSAVerifier(serverPublicKey))) {
//Token is valid
return signedJWT.getJWTClaimsSet().getSubject();
}
} catch (ParseException | JOSEException e) {
LOGGER.error(e);
}
return MCRSystemUserInformation.getGuestInstance().getUserID();
}
示例5: newJwtToken
import com.nimbusds.jose.jwk.RSAKey; //导入方法依赖的package包/类
private JWSObject newJwtToken(String kid,String role) throws Exception {
RSAKey rsaKey = RSAKey.parse(jsonFile("jwk/private_key.json"));
JWSSigner signer = new RSASSASigner(rsaKey);
JWSObject jwsObject = new JWSObject(
new JWSHeader.Builder(JWSAlgorithm.RS256).keyID(kid).build(),
new Payload(jsonFile("jwk/payload-" + role + ".json")));
jwsObject.sign(signer);
return jwsObject;
}
开发者ID:IxorTalk,项目名称:ixortalk.aws.cognito.jwt.security.filter,代码行数:15,代码来源:AwsCognitoIdTokenProcessorTest.java