Java Code Examples for org.apache.cxf.rs.security.oauth2.common.Client#setRedirectUris()

The following examples show how to use org.apache.cxf.rs.security.oauth2.common.Client#setRedirectUris() . 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: ModelEncryptionSupport.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static Client recreateClientInternal(String sequence) {
    String[] parts = getParts(sequence);
    Client c = new Client(parts[0],
                          parts[1],
                          Boolean.parseBoolean(parts[2]),
                          getStringPart(parts[3]), getStringPart(parts[4]));
    c.setApplicationDescription(getStringPart(parts[5]));
    c.setApplicationLogoUri(getStringPart(parts[6]));
    c.setApplicationCertificates(parseSimpleList(parts[7]));
    c.setAllowedGrantTypes(parseSimpleList(parts[8]));
    c.setRedirectUris(parseSimpleList(parts[9]));
    c.setRegisteredScopes(parseSimpleList(parts[10]));
    c.setRegisteredAudiences(parseSimpleList(parts[11]));
    c.setProperties(parseSimpleMap(parts[12]));
    c.setSubject(recreateUserSubject(parts[13]));
    return c;
}
 
Example 2
Source File: JCacheCodeDataProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Client addClient(String clientId, String userLogin) {
    Client c = new Client();
    c.setRedirectUris(Collections.singletonList("http://client/redirect"));
    c.setClientId(clientId);
    c.setResourceOwnerSubject(new UserSubject(userLogin));
    provider.setClient(c);
    return c;
}
 
Example 3
Source File: JPACodeDataProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Client addClient(String clientId, String userLogin) {
    Client c = new Client();
    c.setRedirectUris(Collections.singletonList("http://client/redirect"));
    c.setClientId(clientId);
    c.setResourceOwnerSubject(new UserSubject(userLogin));
    getProvider().setClient(c);
    return c;
}
 
Example 4
Source File: AbstractOAuthDataProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Client addClient(String clientId, String userLogin) {
    Client c = new Client();
    c.setRedirectUris(Collections.singletonList("http://client/redirect"));
    c.setClientId(clientId);
    c.setClientSecret("123");
    c.setResourceOwnerSubject(new UserSubject(userLogin));
    getProvider().setClient(c);
    return c;
}
 
Example 5
Source File: JPAOidcUserSubjectTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Client addClient(String clientId, String userLogin) {
    Client c = new Client();
    c.setRedirectUris(Collections.singletonList("http://client/redirect"));
    c.setClientId(clientId);
    c.setResourceOwnerSubject(new OidcUserSubject(userLogin));
    getProvider().setClient(c);
    return c;
}
 
Example 6
Source File: DynamicRegistrationService.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void fromClientRegistrationToClient(ClientRegistration request, Client client) {
    final List<String> grantTypes = client.getAllowedGrantTypes();

    // Client Redirect URIs
    List<String> redirectUris = request.getRedirectUris();
    if (redirectUris != null) {
        String appType = request.getApplicationType();
        if (appType == null) {
            appType = DEFAULT_APPLICATION_TYPE;
        }
        for (String uri : redirectUris) {
            validateRequestUri(uri, appType, grantTypes);
        }
        client.setRedirectUris(redirectUris);
    }

    if (client.getRedirectUris().isEmpty()
        && (grantTypes.contains(OAuthConstants.AUTHORIZATION_CODE_GRANT)
            || grantTypes.contains(OAuthConstants.IMPLICIT_GRANT))) {
        // Throw an error as we need a redirect URI for these grants.
        OAuthError error =
            new OAuthError(OAuthConstants.INVALID_REQUEST, "A Redirection URI is required");
        reportInvalidRequestError(error);
    }

    // Client Resource Audience URIs
    List<String> resourceUris = request.getResourceUris();
    if (resourceUris != null) {
        client.setRegisteredAudiences(resourceUris);
    }

    // Client Scopes
    String scope = request.getScope();
    if (!StringUtils.isEmpty(scope)) {
        client.setRegisteredScopes(OAuthUtils.parseScope(scope));
    }
    // Client Application URI
    String clientUri = request.getClientUri();
    if (clientUri != null) {
        client.setApplicationWebUri(clientUri);
    }
    // Client Logo URI
    String clientLogoUri = request.getLogoUri();
    if (clientLogoUri != null) {
        client.setApplicationLogoUri(clientLogoUri);
    }

    //TODO: check other properties
    // Add more typed properties like tosUri, policyUri, etc to Client
    // or set them as Client extra properties
}