Search in sources :

Example 1 with GoogleIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity in project gravitee-management-rest-api by gravitee-io.

the class IdentityProviderMapperTest method testGoogleProvider.

@Test
public void testGoogleProvider() {
    GoogleIdentityProviderEntity providerEntity = new GoogleIdentityProviderEntity();
    providerEntity.setClientId(IDP_CLIENT_ID);
    providerEntity.setClientSecret(IDP_CLIENT_SECRET);
    providerEntity.setDescription(IDP_DESCRIPTION);
    providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED);
    providerEntity.setGroupMappings(new ArrayList<>());
    providerEntity.setId(IDP_ID);
    providerEntity.setName(IDP_NAME);
    providerEntity.setRoleMappings(new ArrayList<>());
    IdentityProvider idp = identityProviderMapper.convert(providerEntity);
    checkIdp(idp, IdentityProviderType.GOOGLE);
}
Also used : GoogleIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity) IdentityProvider(io.gravitee.rest.api.portal.rest.model.IdentityProvider) Test(org.junit.Test)

Example 2 with GoogleIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity in project gravitee-management-rest-api by gravitee-io.

the class ConfigurationIdentitiesResourceTest method mockGoogleIdentityProviderEntity.

private Object mockGoogleIdentityProviderEntity() {
    GoogleIdentityProviderEntity providerEntity = new GoogleIdentityProviderEntity();
    providerEntity.setClientId(IDP_CLIENT_ID);
    providerEntity.setClientSecret(IDP_CLIENT_SECRET);
    providerEntity.setDescription(IDP_DESCRIPTION);
    providerEntity.setEmailRequired(IDP_EMAIL_REQUIRED);
    providerEntity.setGroupMappings(new ArrayList<>());
    providerEntity.setId(IDP_ID);
    providerEntity.setName(IDP_NAME);
    providerEntity.setRoleMappings(new ArrayList<>());
    return providerEntity;
}
Also used : GoogleIdentityProviderEntity(io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity)

Example 3 with GoogleIdentityProviderEntity

use of io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity 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

GoogleIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.google.GoogleIdentityProviderEntity)3 AMIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.am.AMIdentityProviderEntity)1 GitHubIdentityProviderEntity (io.gravitee.rest.api.model.configuration.identity.github.GitHubIdentityProviderEntity)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