Search in sources :

Example 11 with IdentityProviderMapperRepresentation

use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.

the class OidcUserAttributeMapperTest method createIdentityProviderMappers.

@Override
protected Iterable<IdentityProviderMapperRepresentation> createIdentityProviderMappers(IdentityProviderMapperSyncMode syncMode) {
    IdentityProviderMapperRepresentation attrMapper1 = new IdentityProviderMapperRepresentation();
    attrMapper1.setName("attribute-mapper");
    attrMapper1.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapper1.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.CLAIM, KcOidcBrokerConfiguration.ATTRIBUTE_TO_MAP_NAME).put(UserAttributeMapper.USER_ATTRIBUTE, MAPPED_ATTRIBUTE_NAME).build());
    IdentityProviderMapperRepresentation emailAttrMapper = new IdentityProviderMapperRepresentation();
    emailAttrMapper.setName("attribute-mapper-email");
    emailAttrMapper.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    emailAttrMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.CLAIM, "email").put(UserAttributeMapper.USER_ATTRIBUTE, "email").build());
    IdentityProviderMapperRepresentation nestedEmailAttrMapper = new IdentityProviderMapperRepresentation();
    nestedEmailAttrMapper.setName("nested-attribute-mapper-email");
    nestedEmailAttrMapper.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    nestedEmailAttrMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.CLAIM, "nested.email").put(UserAttributeMapper.USER_ATTRIBUTE, "nested.email").build());
    IdentityProviderMapperRepresentation dottedEmailAttrMapper = new IdentityProviderMapperRepresentation();
    dottedEmailAttrMapper.setName("dotted-attribute-mapper-email");
    dottedEmailAttrMapper.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    dottedEmailAttrMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.CLAIM, "dotted\\.email").put(UserAttributeMapper.USER_ATTRIBUTE, "dotted.email").build());
    return Lists.newArrayList(attrMapper1, emailAttrMapper, nestedEmailAttrMapper, dottedEmailAttrMapper);
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation)

Example 12 with IdentityProviderMapperRepresentation

use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.

the class SamlUserAttributeMapperTest method createIdentityProviderMappers.

@Override
protected Iterable<IdentityProviderMapperRepresentation> createIdentityProviderMappers(IdentityProviderMapperSyncMode syncMode) {
    IdentityProviderMapperRepresentation attrMapperEmail = new IdentityProviderMapperRepresentation();
    attrMapperEmail.setName("attribute-mapper-email");
    attrMapperEmail.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapperEmail.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_FRIENDLY_NAME, "email").put(UserAttributeMapper.USER_ATTRIBUTE, "email").build());
    IdentityProviderMapperRepresentation attrMapperNestedEmail = new IdentityProviderMapperRepresentation();
    attrMapperNestedEmail.setName("nested-attribute-mapper-email");
    attrMapperNestedEmail.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapperNestedEmail.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_NAME, "nested.email").put(UserAttributeMapper.USER_ATTRIBUTE, "nested.email").build());
    IdentityProviderMapperRepresentation attrMapperDottedEmail = new IdentityProviderMapperRepresentation();
    attrMapperDottedEmail.setName("dotted-attribute-mapper-email");
    attrMapperDottedEmail.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapperDottedEmail.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_NAME, "dotted.email").put(UserAttributeMapper.USER_ATTRIBUTE, "dotted.email").build());
    IdentityProviderMapperRepresentation attrMapper1 = new IdentityProviderMapperRepresentation();
    attrMapper1.setName("attribute-mapper");
    attrMapper1.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapper1.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_NAME, KcOidcBrokerConfiguration.ATTRIBUTE_TO_MAP_NAME).put(UserAttributeMapper.USER_ATTRIBUTE, MAPPED_ATTRIBUTE_NAME).build());
    IdentityProviderMapperRepresentation attrMapper2 = new IdentityProviderMapperRepresentation();
    attrMapper2.setName("attribute-mapper-friendly");
    attrMapper2.setIdentityProviderMapper(UserAttributeMapper.PROVIDER_ID);
    attrMapper2.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_FRIENDLY_NAME, ATTRIBUTE_TO_MAP_FRIENDLY_NAME).put(UserAttributeMapper.USER_ATTRIBUTE, MAPPED_ATTRIBUTE_FRIENDLY_NAME).build());
    return Lists.newArrayList(attrMapperEmail, attrMapper1, attrMapper2, attrMapperDottedEmail, attrMapperNestedEmail);
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation)

Example 13 with IdentityProviderMapperRepresentation

use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.

the class ExternalKeycloakRoleToRoleMapperTest method createMapperInIdp.

@Override
protected void createMapperInIdp(IdentityProviderRepresentation idp, IdentityProviderMapperSyncMode syncMode) {
    IdentityProviderMapperRepresentation externalRoleToRoleMapper = new IdentityProviderMapperRepresentation();
    externalRoleToRoleMapper.setName("external-keycloak-role-mapper");
    externalRoleToRoleMapper.setIdentityProviderMapper(ExternalKeycloakRoleToRoleMapper.PROVIDER_ID);
    externalRoleToRoleMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put("external.role", ROLE_USER).put("role", CLIENT_ROLE_MAPPER_REPRESENTATION).build());
    IdentityProviderResource idpResource = realm.identityProviders().get(idp.getAlias());
    externalRoleToRoleMapper.setIdentityProviderAlias(bc.getIDPAlias());
    idpResource.addMapper(externalRoleToRoleMapper).close();
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) IdentityProviderResource(org.keycloak.admin.client.resource.IdentityProviderResource)

Example 14 with IdentityProviderMapperRepresentation

use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.

the class JsonUserAttributeMapperTest method createGithubProviderMapper.

private void createGithubProviderMapper(IdentityProviderRepresentation idp, IdentityProviderMapperSyncMode syncMode) {
    IdentityProviderMapperRepresentation githubProvider = new IdentityProviderMapperRepresentation();
    githubProvider.setName("json-attribute-mapper");
    githubProvider.setIdentityProviderMapper(GitHubUserAttributeMapper.PROVIDER_ID);
    githubProvider.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(AbstractJsonUserAttributeMapper.CONF_JSON_FIELD, USER_INFO_CLAIM + "." + HARDOCDED_CLAIM).put(AbstractJsonUserAttributeMapper.CONF_USER_ATTRIBUTE, USER_ATTRIBUTE).build());
    IdentityProviderResource idpResource = realm.identityProviders().get(idp.getAlias());
    githubProvider.setIdentityProviderAlias(bc.getIDPAlias());
    idpResource.addMapper(githubProvider).close();
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) IdentityProviderResource(org.keycloak.admin.client.resource.IdentityProviderResource)

Example 15 with IdentityProviderMapperRepresentation

use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.

the class AbstractUserAttributeMapperTest method addIdentityProviderToConsumerRealm.

public void addIdentityProviderToConsumerRealm(IdentityProviderMapperSyncMode syncMode) {
    IdentityProviderRepresentation idp = setupIdentityProvider();
    IdentityProviderResource idpResource = realm.identityProviders().get(idp.getAlias());
    for (IdentityProviderMapperRepresentation mapper : createIdentityProviderMappers(syncMode)) {
        mapper.setIdentityProviderAlias(bc.getIDPAlias());
        idpResource.addMapper(mapper).close();
    }
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) IdentityProviderResource(org.keycloak.admin.client.resource.IdentityProviderResource) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation)

Aggregations

IdentityProviderMapperRepresentation (org.keycloak.representations.idm.IdentityProviderMapperRepresentation)34 IdentityProviderResource (org.keycloak.admin.client.resource.IdentityProviderResource)25 Test (org.junit.Test)9 RealmResource (org.keycloak.admin.client.resource.RealmResource)7 Response (javax.ws.rs.core.Response)6 IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)5 Closeable (java.io.Closeable)3 HashMap (java.util.HashMap)3 StringInputStream (org.apache.tools.ant.filters.StringInputStream)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 EntityDescriptorType (org.keycloak.dom.saml.v2.metadata.EntityDescriptorType)3 SPSSODescriptorType (org.keycloak.dom.saml.v2.metadata.SPSSODescriptorType)3 SAMLParser (org.keycloak.saml.processing.core.parsers.saml.SAMLParser)3 IdentityProviderAttributeUpdater (org.keycloak.testsuite.updaters.IdentityProviderAttributeUpdater)3 Before (org.junit.Before)2 NotFoundException (javax.ws.rs.NotFoundException)1 MultipartFormDataOutput (org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataOutput)1 ClientsResource (org.keycloak.admin.client.resource.ClientsResource)1 AuthenticationExecutionInfoRepresentation (org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation)1 AuthenticationFlowRepresentation (org.keycloak.representations.idm.AuthenticationFlowRepresentation)1