Java Code Examples for org.apache.cxf.rs.security.jose.jws.JwsUtils#getSignatureAlgorithm()
The following examples show how to use
org.apache.cxf.rs.security.jose.jws.JwsUtils#getSignatureAlgorithm() .
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: OidcImplicitService.java From cxf with Apache License 2.0 | 6 votes |
protected String processIdToken(OAuthRedirectionState state, IdToken idToken) { OAuthJoseJwtProducer processor = idTokenHandler == null ? new OAuthJoseJwtProducer() : idTokenHandler; String code = (String)JAXRSUtils.getCurrentMessage().getExchange().get(OAuthConstants.AUTHORIZATION_CODE_VALUE); if (code != null) { // this service is invoked as part of the hybrid flow Properties props = JwsUtils.loadSignatureOutProperties(false); SignatureAlgorithm sigAlgo = null; if (processor.isSignWithClientSecret()) { sigAlgo = OAuthUtils.getClientSecretSignatureAlgorithm(props); } else { sigAlgo = JwsUtils.getSignatureAlgorithm(props, SignatureAlgorithm.RS256); } idToken.setAuthorizationCodeHash(OidcUtils.calculateAuthorizationCodeHash(code, sigAlgo)); } idToken.setNonce(state.getNonce()); return processor.processJwt(new JwtToken(idToken)); }
Example 2
Source File: IdTokenResponseFilter.java From cxf with Apache License 2.0 | 4 votes |
private void setAtHashAndNonce(IdToken idToken, ServerAccessToken st) { String rType = st.getResponseType(); boolean atHashRequired = idToken.getAccessTokenHash() == null && (rType == null || !rType.equals(OidcUtils.ID_TOKEN_RESPONSE_TYPE)); boolean cHashRequired = idToken.getAuthorizationCodeHash() == null && rType != null && (rType.equals(OidcUtils.CODE_ID_TOKEN_AT_RESPONSE_TYPE) || rType.equals(OidcUtils.CODE_ID_TOKEN_RESPONSE_TYPE)); Message m = JAXRSUtils.getCurrentMessage(); if (atHashRequired || cHashRequired) { Properties props = JwsUtils.loadSignatureOutProperties(false); final SignatureAlgorithm sigAlgo; if (super.isSignWithClientSecret()) { sigAlgo = OAuthUtils.getClientSecretSignatureAlgorithm(props); } else { sigAlgo = JwsUtils.getSignatureAlgorithm(props, SignatureAlgorithm.RS256); } if (sigAlgo != SignatureAlgorithm.NONE) { if (atHashRequired) { String tokenKey = st.getEncodedToken() != null ? st.getEncodedToken() : st.getTokenKey(); String atHash = OidcUtils.calculateAccessTokenHash(tokenKey, sigAlgo); idToken.setAccessTokenHash(atHash); } if (cHashRequired) { // c_hash can be returned from either Authorization or Token endpoints String code; if (st.getGrantCode() != null) { // This is a token endpoint, the code has been exchanged for a token code = st.getGrantCode(); } else { // Authorization endpoint: hybrid flow, implicit part code = (String)m.getExchange().get(OAuthConstants.AUTHORIZATION_CODE_VALUE); } if (code != null) { idToken.setAuthorizationCodeHash(OidcUtils.calculateAuthorizationCodeHash(code, sigAlgo)); } } } } if (m != null && m.getExchange().containsKey(OAuthConstants.NONCE)) { idToken.setNonce((String)m.getExchange().get(OAuthConstants.NONCE)); } else if (st.getNonce() != null) { idToken.setNonce(st.getNonce()); } }