Java Code Examples for org.apache.cxf.rs.security.jose.jws.JwsUtils#getSignatureProvider()

The following examples show how to use org.apache.cxf.rs.security.jose.jws.JwsUtils#getSignatureProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestJwts.java    From deprecated-security-advanced-modules with Apache License 2.0 5 votes vote down vote up
static String createSignedWithPeculiarEscaping(JwtToken baseJwt, JsonWebKey jwk) {
	JwsSignatureProvider signatureProvider = JwsUtils.getSignatureProvider(jwk);
	JwsHeaders jwsHeaders = new JwsHeaders();
	JwtToken signedToken = new JwtToken(jwsHeaders, baseJwt.getClaims());

	// Depends on CXF not escaping the input string. This may fail for other frameworks or versions.
	jwsHeaders.setKeyId(jwk.getKeyId().replace("/", "\\/"));

	return new JoseJwtProducer().processJwt(signedToken, null, signatureProvider);
}
 
Example 2
Source File: DefaultJoseImpl.java    From thorntail with Apache License 2.0 5 votes vote down vote up
private JwsSignatureProvider getSignatureProvider(Properties props, JwsHeaders headers) {
    if (isInlinedJwkSetAvailable()) {
        return JwsUtils.getSignatureProvider(loadJsonWebKey(signatureKeyAlias()));
    } else {
        return JwsUtils.loadSignatureProvider(props, headers);
    }
}
 
Example 3
Source File: ApacheCXFProducer.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void produceJsonJWS(String plainText, JsonWebKey key, JwsHeaders jwsHeaders, boolean flattened) {
    JwsJsonProducer jwsProducer = new JwsJsonProducer(plainText, flattened);
    JwsSignatureProvider jwsSignatureProvider = JwsUtils.getSignatureProvider(key,
        jwsHeaders.getSignatureAlgorithm());
    jwsProducer.signWith(jwsSignatureProvider, null, jwsHeaders);
}