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

The following examples show how to use org.apache.cxf.rs.security.oauth2.utils.OAuthUtils#validateAudiences() . 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: AbstractGrantHandler.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected ServerAccessToken getPreAuthorizedToken(Client client,
                                                  UserSubject subject,
                                                  String requestedGrant,
                                                  List<String> requestedScopes,
                                                  List<String> audiences) {
    if (!OAuthUtils.validateScopes(requestedScopes, client.getRegisteredScopes(),
                                   partialMatchScopeValidation)) {
        throw new OAuthServiceException(new OAuthError(OAuthConstants.INVALID_SCOPE));
    }
    if (!OAuthUtils.validateAudiences(audiences, client.getRegisteredAudiences())) {
        throw new OAuthServiceException(new OAuthError(OAuthConstants.INVALID_GRANT));
    }

    // Get a pre-authorized token if available
    return dataProvider.getPreauthorizedToken(
                                 client, requestedScopes, subject, requestedGrant);

}
 
Example 2
Source File: AbstractGrantHandler.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected List<String> getAudiences(Client client, String clientAudience) {
    if (client.getRegisteredAudiences().isEmpty() && clientAudience == null) {
        return Collections.emptyList();
    }
    if (clientAudience != null) {
        List<String> audiences = Collections.singletonList(clientAudience);
        if (!OAuthUtils.validateAudiences(audiences, client.getRegisteredAudiences())) {
            throw new OAuthServiceException(OAuthConstants.INVALID_GRANT);
        }
        return audiences;
    }
    return client.getRegisteredAudiences();
}