Package org.apache.cxf.rs.security.oauth2.jwt

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtClaims


            return createErrorResponse(params, redirectUri, OAuthConstants.INVALID_SCOPE);
        }
       
       
        // Create a UserSubject representing the end user
        UserSubject userSubject = createUserSubject(sc);
       
        // Request a new grant only if no pre-authorized token is available
        ServerAccessToken preauthorizedToken = getDataProvider().getPreauthorizedToken(
            client, requestedScope, userSubject, supportedGrantType);
        if (preauthorizedToken != null) {
View Full Code Here


        if (!requestedScope.containsAll(approvedScope)
            || !OAuthUtils.validateScopes(requestedScope, client.getRegisteredScopes(),
                                         partialMatchScopeValidation)) {
            return createErrorResponse(params, redirectUri, OAuthConstants.INVALID_SCOPE);
        }
        UserSubject userSubject = createUserSubject(securityContext);
       
        // Request a new grant
        return createGrant(params,
                           client,
                           redirectUri,
View Full Code Here

    public void setSubjectCreator(SubjectCreator creator) {
        this.subjectCreator = creator;
    }
   
    protected UserSubject createUserSubject(SecurityContext securityContext) {
        UserSubject subject = null;
        if (subjectCreator != null) {
            subject = subjectCreator.createUserSubject(getMessageContext());
            if (subject != null) {
                return subject;
            }
View Full Code Here

        return accessToken;
    }
   
    protected SecurityContext createSecurityContext(HttpServletRequest request,
                                                    ServerAccessToken token) {
        UserSubject endUserSubject = token.getSubject();
        UserSubject clientSubject = token.getClient().getSubject();

        final UserSubject theSubject =
            OAuthRequestFilter.this.useUserSubject ? endUserSubject : clientSubject;
                   
        return new SecurityContext() {

            public Principal getUserPrincipal() {
                return theSubject != null ? new SimplePrincipal(theSubject.getLogin()) : null;
            }

            public boolean isUserInRole(String role) {
                if (theSubject == null) {
                    return false;
                }
                return theSubject.getRoles().contains(role);
            }
        };
    }
View Full Code Here

                    return handler;
                }
            }
            // Lets try the default grant handler
            if (grantHandlers.size() == 0) {
                AuthorizationCodeGrantHandler handler = new AuthorizationCodeGrantHandler();
                if (handler.getSupportedGrantTypes().contains(grantType)) {
                    handler.setDataProvider(
                            (AuthorizationCodeDataProvider)super.getDataProvider());
                    return handler;
                }
            }
        }
View Full Code Here

                    return handler;
                }
            }
            // Lets try the default grant handler
            if (grantHandlers.size() == 0) {
                AuthorizationCodeGrantHandler handler = new AuthorizationCodeGrantHandler();
                if (handler.getSupportedGrantTypes().contains(grantType)) {
                    handler.setDataProvider(
                            (AuthorizationCodeDataProvider)super.getDataProvider());
                    return handler;
                }
            }
        }
View Full Code Here

        Crypto crypto = new CryptoLoader().loadCrypto(CRYPTO_RESOURCE_PROPERTIES);
        SelfSignInfo signInfo = new SelfSignInfo(crypto, "alice", "password");
       
        String assertion =  SAMLUtils.createAssertion(new SamlCallbackHandler(),
                                                      signInfo).assertionToString();
        Saml2BearerGrant grant = new Saml2BearerGrant(assertion);
        ClientAccessToken at = OAuthClientUtils.getAccessToken(wc,
                                        new OAuthClientUtils.Consumer("alice", "alice"),
                                        grant,
                                        false);
        assertNotNull(at.getTokenKey());
View Full Code Here

   
    @Test
    public void testWriteReadJwsUnsigned() throws Exception {
        JwtHeaders headers = new JwtHeaders(JwtConstants.PLAIN_TEXT_ALGO);
       
        JwtClaims claims = new JwtClaims();
        claims.setIssuer("https://jwt-idp.example.com");
        claims.setSubject("mailto:mike@example.com");
        claims.setAudience("https://jwt-rp.example.net");
        claims.setNotBefore(1300815780);
        claims.setExpiryTime(1300819380);
        claims.setClaim("http://claims.example.com/member", true);
       
        JwsCompactProducer writer = new JwsJwtCompactProducer(headers, claims);
        String signed = writer.getSignedEncodedJws();
       
        JwsJwtCompactConsumer reader = new JwsJwtCompactConsumer(signed);
View Full Code Here

    private void doTestWriteJwsWithJwkSignedByMac(Object jsonWebKey) throws Exception {
        JwtHeaders headers = new JwtHeaders(Algorithm.HmacSHA256.getJwtName());
       
        headers.setHeader(JwtConstants.HEADER_JSON_WEB_KEY, jsonWebKey);
       
        JwtClaims claims = new JwtClaims();
        claims.setIssuer("joe");
        claims.setExpiryTime(1300819380);
        claims.setClaim("http://example.com/is_root", Boolean.TRUE);
       
        JwtToken token = new JwtToken(headers, claims);
        JwsCompactProducer jws = new JwsJwtCompactProducer(token, getWriter());
        jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY));
       
View Full Code Here

        validateSpecClaim(token.getClaims());
    }
   
    private JwsCompactProducer initSpecJwtTokenWriter(JwtHeaders headers) throws Exception {
       
        JwtClaims claims = new JwtClaims();
        claims.setIssuer("joe");
        claims.setExpiryTime(1300819380);
        claims.setClaim("http://example.com/is_root", Boolean.TRUE);
       
        JwtToken token = new JwtToken(headers, claims);
        return new JwsJwtCompactProducer(token, getWriter());
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.rs.security.oauth2.jwt.JwtClaims

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.