本文整理了Java中com.nimbusds.jose.Algorithm
类的一些代码示例,展示了Algorithm
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algorithm
类的具体详情如下:
包路径:com.nimbusds.jose.Algorithm
类名称:Algorithm
[英]The base class for algorithm names, with optional implementation requirement. This class is immutable.
Includes constants for the following standard algorithm names:
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Override
public String apply(Algorithm alg) {
if (alg == null) {
return null;
} else {
return alg.getName();
}
}
};
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
if (!clientAlg.equals(tokenAlg)) {
throw new AuthenticationServiceException("Token algorithm " + tokenAlg + " does not match expected algorithm " + clientAlg);
if (tokenAlg != null && !tokenAlg.equals(Algorithm.NONE)) {
throw new AuthenticationServiceException("Unsigned token received, expected signature with " + tokenAlg);
if (tokenAlg.equals(JWSAlgorithm.HS256)
|| tokenAlg.equals(JWSAlgorithm.HS384)
|| tokenAlg.equals(JWSAlgorithm.HS512)) {
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.hostobjects.oidc
Algorithm clientAlg = new Algorithm(clientAlgorithm);
if (!clientAlg.equals(tokenAlg)) {
isValid = false;
log.error("Token algorithm " + tokenAlg + " does not match expected algorithm " + clientAlg);
代码示例来源:origin: stackoverflow.com
public class Test2 extends Application {
@Override
public void start(Stage primaryStage) {
Algorithm alg = new Algorithm();
alg.solve();
GUI gui = new GUI();
gui.displaySolution(alg.getSolution());
}
// included for the benefit of IDEs that do not support
// launching an Application without a main method:
public static void main(String[] args) { launch(args); }
}
代码示例来源:origin: stackoverflow.com
Algorithm algorithm = new Algorithm(new BigInteger(jtfX.getText()));
jlSolution.setText(algorithm.check());
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
/**
* Parses the optional algorithm.
*
* @param o The JSON object to parse. Must not be {@code null}.
*
* @return The intended JOSE algorithm, {@code null} if not specified.
*
* @throws ParseException If parsing failed.
*/
static Algorithm parseAlgorithm(final JSONObject o)
throws ParseException {
if (o.containsKey("alg")) {
return new Algorithm(JSONObjectUtils.getString(o, "alg"));
} else {
return null;
}
}
代码示例来源:origin: stackoverflow.com
final Button button3 = new Button("Button 3");
Algorithm algo = new Algorithm() {
代码示例来源:origin: spring-projects/spring-security
@Test
public void getWhenMatchThenCreatesKeys() {
when(this.matcher.matches(any())).thenReturn(true);
List<JWK> keys = this.source.get(this.selector).block();
assertThat(keys).hasSize(2);
JWK key1 = keys.get(0);
assertThat(key1.getKeyID()).isEqualTo("1923397381d9574bb873202a90c32b7ceeaed027");
assertThat(key1.getAlgorithm().getName()).isEqualTo("RS256");
assertThat(key1.getKeyType()).isEqualTo(KeyType.RSA);
assertThat(key1.getKeyUse()).isEqualTo(KeyUse.SIGNATURE);
JWK key2 = keys.get(1);
assertThat(key2.getKeyID()).isEqualTo("7ddf54d3032d1f0d48c3618892ca74c1ac30ad77");
assertThat(key2.getAlgorithm().getName()).isEqualTo("RS256");
assertThat(key2.getKeyType()).isEqualTo(KeyType.RSA);
assertThat(key2.getKeyUse()).isEqualTo(KeyUse.SIGNATURE);
}
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
if (alg.equals(Algorithm.NONE)) {
return PlainJWT.parse(s);
} else if (alg instanceof JWSAlgorithm) {
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
private ECPublicKey getKey(String kid, String alg) throws Exception {
JWK jwk = keyCache.get(kid);
if (jwk == null) {
// update cache loading jwk public key data from url
JWKSet jwkSet = JWKSet.load(new URL(PUBLIC_KEY_VERIFICATION_URL));
for (JWK key : jwkSet.getKeys()) {
keyCache.put(key.getKeyID(), key);
}
jwk = keyCache.get(kid);
}
// confirm that algorithm matches
if (jwk != null && jwk.getAlgorithm().getName().equals(alg)) {
return ECKey.parse(jwk.toJSONString()).toECPublicKey();
}
return null;
}
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
/**
* Parses a {@link PlainHeader}, {@link JWSHeader} or {@link JWEHeader}
* from the specified JSON object.
*
* @param jsonObject The JSON object to parse. Must not be
* {@code null}.
* @param parsedBase64URL The original parsed Base64URL, {@code null}
* if not applicable.
*
* @return The header.
*
* @throws ParseException If the specified JSON object doesn't
* represent a valid header.
*/
public static Header parse(final JSONObject jsonObject,
final Base64URL parsedBase64URL)
throws ParseException {
Algorithm alg = parseAlgorithm(jsonObject);
if (alg.equals(Algorithm.NONE)) {
return PlainHeader.parse(jsonObject, parsedBase64URL);
} else if (alg instanceof JWSAlgorithm) {
return JWSHeader.parse(jsonObject, parsedBase64URL);
} else if (alg instanceof JWEAlgorithm) {
return JWEHeader.parse(jsonObject, parsedBase64URL);
} else {
throw new AssertionError("Unexpected algorithm type: " + alg);
}
}
代码示例来源:origin: org.mitre/openid-connect-server
@Override
public String apply(Algorithm alg) {
if (alg == null) {
return null;
} else {
return alg.getName();
}
}
};
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
if (alg.equals(Algorithm.NONE)) {
return PlainObject.parse(s);
} else if (alg instanceof JWSAlgorithm) {
代码示例来源:origin: org.apereo.cas/cas-server-support-token
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();
}
代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.oauth2/org.wso2.carbon.identity.oauth
private void setRequestObjectValues(String requestObjectString, RequestObject requestObjectInstance) throws
RequestObjectException {
try {
JOSEObject jwt = JOSEObject.parse(requestObjectString);
if (jwt.getHeader().getAlgorithm() == null || jwt.getHeader().getAlgorithm().equals(JWSAlgorithm.NONE)) {
requestObjectInstance.setPlainJWT(PlainJWT.parse(requestObjectString));
} else {
requestObjectInstance.setSignedJWT(SignedJWT.parse(requestObjectString));
}
} catch (ParseException e) {
String errorMessage = "No Valid JWT is found for the Request Object.";
if (log.isDebugEnabled()) {
log.debug(errorMessage + "Received Request Object: " + requestObjectString, e);
}
throw new RequestObjectException(OAuth2ErrorCodes.INVALID_REQUEST, errorMessage);
}
}
代码示例来源:origin: com.nimbusds/nimbus-jose-jwt
/**
* Creates a new JWS header builder.
*
* @param alg The JWS algorithm ({@code alg}) parameter. Must
* not be "none" or {@code null}.
*/
public Builder(final JWSAlgorithm alg) {
if (alg.getName().equals(Algorithm.NONE.getName())) {
throw new IllegalArgumentException("The JWS algorithm \"alg\" cannot be \"none\"");
}
this.alg = alg;
}
代码示例来源:origin: com.moomanow/moomanow-oauth2
if (!clientAlg.equals(tokenAlg)) {
throw new AuthenticationServiceException("Token algorithm " + tokenAlg + " does not match expected algorithm " + clientAlg);
if (tokenAlg != null && !tokenAlg.equals(Algorithm.NONE)) {
throw new AuthenticationServiceException("Unsigned token received, expected signature with " + tokenAlg);
if (tokenAlg.equals(JWSAlgorithm.HS256)
|| tokenAlg.equals(JWSAlgorithm.HS384)
|| tokenAlg.equals(JWSAlgorithm.HS512)) {
代码示例来源:origin: org.apereo.cas/cas-server-support-token-authentication
private static <T extends Algorithm> T findAlgorithmFamily(final Set<Algorithm> family,
final String alg, final Class<T> clazz) {
val result = family
.stream()
.filter(l -> l.getName().equalsIgnoreCase(alg))
.findFirst()
.get();
if (!clazz.isAssignableFrom(result.getClass())) {
throw new ClassCastException("Result [" + result
+ " is of type " + result.getClass()
+ " when we were expecting " + clazz);
}
return (T) result;
}
代码示例来源:origin: org.mitre/openid-connect-client
if (!clientAlg.equals(tokenAlg)) {
throw new AuthenticationServiceException("Token algorithm " + tokenAlg + " does not match expected algorithm " + clientAlg);
if (tokenAlg != null && !tokenAlg.equals(Algorithm.NONE)) {
throw new AuthenticationServiceException("Unsigned token received, expected signature with " + tokenAlg);
if (tokenAlg.equals(JWSAlgorithm.HS256)
|| tokenAlg.equals(JWSAlgorithm.HS384)
|| tokenAlg.equals(JWSAlgorithm.HS512)) {
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.oauth
public JWTTokenGenerator(boolean includeClaims, boolean enableSigning) {
this.includeClaims = includeClaims;
this.enableSigning = enableSigning;
signatureAlgorithm = new JWSAlgorithm(JWSAlgorithm.NONE.getName());
}
内容来源于网络,如有侵权,请联系作者删除!