Search in sources :

Example 1 with AMIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity in project gravitee-management-rest-api by gravitee-io.

the class IdentityProviderMapperTest method testGraviteeIoAMProvider.

@Test
public void testGraviteeIoAMProvider() {
    AMIdentityProviderEntity providerEntity = new AMIdentityProviderEntity(serverUrl);
    providerEntity.setClientId(IDP_CLIENT_ID);
    providerEntity.setClientSecret(IDP_CLIENT_SECRET);
    providerEntity.setColor(IDP_COLOR);
    providerEntity.setDescription(IDP_DESCRIPTION);
    providerEntity.setDiscoveryEndpoint(IDP_DISCOVERY_ENDPOINT);
    providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED);
    providerEntity.setGroupMappings(new ArrayList<>());
    providerEntity.setId(IDP_ID);
    providerEntity.setName(IDP_NAME);
    providerEntity.setRoleMappings(new ArrayList<>());
    providerEntity.setScopes(Arrays.asList(IDP_SCOPE));
    providerEntity.setUserProfileMapping(new HashMap<>());
    IdentityProvider idp = identityProviderMapper.convert(providerEntity);
    checkIdp(idp, IdentityProviderType.GRAVITEEIO_AM);
}
Also used : AMIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity) IdentityProvider(io.gravitee.rest.api.portal.rest.model.IdentityProvider) Test(org.junit.Test)

Example 2 with AMIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity in project gravitee-management-rest-api by gravitee-io.

the class ConfigurationIdentitiesResourceTest method mockAMIdentityProviderEntity.

private Object mockAMIdentityProviderEntity() {
    AMIdentityProviderEntity providerEntity = new AMIdentityProviderEntity(serverUrl);
    providerEntity.setClientId(IDP_CLIENT_ID);
    providerEntity.setClientSecret(IDP_CLIENT_SECRET);
    providerEntity.setColor(IDP_COLOR);
    providerEntity.setDescription(IDP_DESCRIPTION);
    providerEntity.setDiscoveryEndpoint(IDP_DISCOVERY_ENDPOINT);
    providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED);
    providerEntity.setGroupMappings(new ArrayList<>());
    providerEntity.setId(IDP_ID);
    providerEntity.setName(IDP_NAME);
    providerEntity.setRoleMappings(new ArrayList<>());
    providerEntity.setScopes(Arrays.asList(IDP_SCOPE));
    providerEntity.setUserProfileMapping(new HashMap<>());
    return providerEntity;
}
Also used : AMIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity)

Example 3 with AMIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity in project gravitee-management-rest-api by gravitee-io.

the class SocialIdentityProviderImpl method convert.

private SocialIdentityProviderEntity convert(IdentityProviderEntity identityProvider) {
    SocialIdentityProviderEntity provider = null;
    if (identityProvider.getType() == IdentityProviderType.GOOGLE) {
        provider = new GoogleIdentityProviderEntity();
    } else if (identityProvider.getType() == IdentityProviderType.GITHUB) {
        provider = new GitHubIdentityProviderEntity();
    } else if (identityProvider.getType() == IdentityProviderType.OIDC) {
        provider = new OIDCIdentityProviderEntity();
        ((OIDCIdentityProviderEntity) provider).setColor((String) identityProvider.getConfiguration().get("color"));
        ((OIDCIdentityProviderEntity) provider).setDiscoveryEndpoint((String) identityProvider.getConfiguration().get("discoveryEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setTokenEndpoint((String) identityProvider.getConfiguration().get("tokenEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setAuthorizationEndpoint((String) identityProvider.getConfiguration().get("authorizeEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setTokenIntrospectionEndpoint((String) identityProvider.getConfiguration().get("tokenIntrospectionEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setUserInfoEndpoint((String) identityProvider.getConfiguration().get("userInfoEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setUserLogoutEndpoint((String) identityProvider.getConfiguration().get("userLogoutEndpoint"));
        ((OIDCIdentityProviderEntity) provider).setScopes((List<String>) identityProvider.getConfiguration().get("scopes"));
        ((OIDCIdentityProviderEntity) provider).setUserProfileMapping(identityProvider.getUserProfileMapping());
    } else if (identityProvider.getType() == IdentityProviderType.GRAVITEEIO_AM) {
        String serverBaseUrl = (String) identityProvider.getConfiguration().get("serverURL");
        String domain = (String) identityProvider.getConfiguration().get("domain");
        // Remove duplicate slash
        String serverUrl = DUPLICATE_SLASH_REMOVER.matcher(serverBaseUrl + '/' + domain).replaceAll(URI_PATH_SEPARATOR);
        if (serverUrl.lastIndexOf(URI_PATH_SEPARATOR) == serverUrl.length() - 1) {
            serverUrl = serverUrl.substring(0, serverUrl.length() - 1);
        }
        provider = new AMIdentityProviderEntity(serverUrl);
        ((AMIdentityProviderEntity) provider).setColor((String) identityProvider.getConfiguration().get("color"));
        ((AMIdentityProviderEntity) provider).setDiscoveryEndpoint((String) identityProvider.getConfiguration().get("discoveryEndpoint"));
        ((AMIdentityProviderEntity) provider).setScopes((List<String>) identityProvider.getConfiguration().get("scopes"));
        ((AMIdentityProviderEntity) provider).setUserProfileMapping(identityProvider.getUserProfileMapping());
    }
    if (provider != null) {
        provider.setId(identityProvider.getId());
        provider.setName(identityProvider.getName());
        provider.setDescription(identityProvider.getDescription());
        provider.setClientId((String) identityProvider.getConfiguration().get(CLIENT_ID));
        provider.setClientSecret((String) identityProvider.getConfiguration().get(CLIENT_SECRET));
        provider.setGroupMappings(identityProvider.getGroupMappings());
        provider.setRoleMappings(identityProvider.getRoleMappings());
        provider.setRoleMappings(identityProvider.getRoleMappings());
        provider.setEmailRequired(identityProvider.isEmailRequired());
        provider.setSyncMappings(identityProvider.isSyncMappings());
        return provider;
    }
    return null;
}
Also used : GitHubIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.github.GitHubIdentityProviderEntity) AMIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity) GoogleIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity) List(java.util.List) OIDCIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.oidc.OIDCIdentityProviderEntity)

Aggregations

AMIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity)3 GitHubIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.github.GitHubIdentityProviderEntity)1 GoogleIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity)1 OIDCIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.oidc.OIDCIdentityProviderEntity)1 IdentityProvider (io.gravitee.rest.api.portal.rest.model.IdentityProvider)1 List (java.util.List)1 Test (org.junit.Test)1