Java Code Examples for org.apache.cxf.rs.security.oauth2.utils.OAuthUtils#createSubject()

The following examples show how to use org.apache.cxf.rs.security.oauth2.utils.OAuthUtils#createSubject() . 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: SubjectCreatorImpl.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public OidcUserSubject createUserSubject(MessageContext mc, MultivaluedMap<String, String> params) {
    OidcUserSubject oidcSub = new OidcUserSubject(OAuthUtils.createSubject(mc,
        (SecurityContext)mc.get(SecurityContext.class.getName())));

    final List<String> scopes;
    String requestedScope = params.getFirst(OAuthConstants.SCOPE);
    if (requestedScope != null && !requestedScope.isEmpty()) {
        scopes = OidcUtils.getScopeClaims(requestedScope.split(" "));
    } else {
        scopes = Collections.emptyList();
    }

    oidcSub.setIdToken(ID_TOKEN_PROVIDER.getIdToken(null, oidcSub, scopes));

    return oidcSub;
}
 
Example 2
Source File: DirectAuthorizationService.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected UserSubject createUserSubject(SecurityContext securityContext,
                                        MultivaluedMap<String, String> params) {
    UserSubject subject = null;
    if (subjectCreator != null) {
        subject = subjectCreator.createUserSubject(getMessageContext(), params);
        if (subject != null) {
            return subject;
        }
    }

    subject = getMessageContext().getContent(UserSubject.class);
    if (subject != null) {
        return subject;
    }
    return OAuthUtils.createSubject(securityContext);
}
 
Example 3
Source File: RedirectionBasedGrantService.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected UserSubject createUserSubject(SecurityContext securityContext,
                                        MultivaluedMap<String, String> params) {
    if (subjectCreator != null) {
        UserSubject subject = subjectCreator.createUserSubject(getMessageContext(),
                                                   params);
        if (subject != null) {
            return subject;
        }
    }
    return OAuthUtils.createSubject(getMessageContext(), securityContext);
}
 
Example 4
Source File: JAASResourceOwnerLoginHandler.java    From cxf with Apache License 2.0 4 votes vote down vote up
public UserSubject createSubject(Client client, String name, String password) {
    Message message = setupMessage(name, password);
    jaasInterceptor.handleMessage(message);

    return OAuthUtils.createSubject(message.get(SecurityContext.class));
}
 
Example 5
Source File: DefaultSubjectCreator.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
public UserSubject createUserSubject(MessageContext mc,
                                     MultivaluedMap<String, String> params) throws OAuthServiceException {
    return OAuthUtils.createSubject(mc,
                                    (SecurityContext)mc.get(SecurityContext.class.getName()));
}