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);
}
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;
}
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;
}
Aggregations