use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.
the class AttributeToRoleMapperTest method createMapperInIdp.
@Override
protected void createMapperInIdp(IdentityProviderRepresentation idp, IdentityProviderMapperSyncMode syncMode) {
IdentityProviderMapperRepresentation samlAttributeToRoleMapper = new IdentityProviderMapperRepresentation();
samlAttributeToRoleMapper.setName("user-role-mapper");
samlAttributeToRoleMapper.setIdentityProviderMapper(AttributeToRoleMapper.PROVIDER_ID);
samlAttributeToRoleMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_NAME, "Role").put(ATTRIBUTE_VALUE, ROLE_USER).put("role", CLIENT_ROLE_MAPPER_REPRESENTATION).build());
IdentityProviderResource idpResource = realm.identityProviders().get(idp.getAlias());
samlAttributeToRoleMapper.setIdentityProviderAlias(bc.getIDPAlias());
idpResource.addMapper(samlAttributeToRoleMapper).close();
}
use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.
the class LDAPSamlIdPInitiatedVaryingLetterCaseTest method setupIdentityProvider.
@Before
public void setupIdentityProvider() {
// Configure autolink flow
AuthenticationFlowRepresentation newFlow = new AuthenticationFlowRepresentation();
newFlow.setAlias(FLOW_AUTO_LINK);
newFlow.setDescription("Auto-link flow");
newFlow.setProviderId("basic-flow");
newFlow.setBuiltIn(false);
newFlow.setTopLevel(true);
Creator.Flow amr = Creator.create(testRealm(), newFlow);
AuthenticationExecutionInfoRepresentation exCreateUser = amr.addExecution(IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID);
exCreateUser.setRequirement(Requirement.ALTERNATIVE.name());
testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exCreateUser);
AuthenticationExecutionInfoRepresentation exAutoLink = amr.addExecution(IdpAutoLinkAuthenticatorFactory.PROVIDER_ID);
exAutoLink.setRequirement(Requirement.ALTERNATIVE.name());
testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exAutoLink);
getCleanup().addCleanup(amr);
// Configure identity provider
IdentityProviderRepresentation idp = KcSamlBrokerConfiguration.INSTANCE.setUpIdentityProvider();
idp.getConfig().put(SAMLIdentityProviderConfig.NAME_ID_POLICY_FORMAT, JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get());
idp.setFirstBrokerLoginFlowAlias(FLOW_AUTO_LINK);
final Creator<IdentityProviderResource> idpCreator = Creator.create(testRealm(), idp);
IdentityProviderMapperRepresentation samlNameIdMapper = new IdentityProviderMapperRepresentation();
samlNameIdMapper.setName("username-nameid-mapper");
idpAlias = idp.getAlias();
samlNameIdMapper.setIdentityProviderAlias(idpAlias);
samlNameIdMapper.setIdentityProviderMapper(UsernameTemplateMapper.PROVIDER_ID);
samlNameIdMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, "IMPORT").put(UsernameTemplateMapper.TEMPLATE, "${NAMEID | lowercase}").put(UsernameTemplateMapper.TARGET, Target.BROKER_ID.name()).build());
idpCreator.resource().addMapper(samlNameIdMapper);
getCleanup().addCleanup(idpCreator);
}
use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.
the class AbstractAdvancedBrokerTest method createRoleMappersForConsumerRealm.
protected void createRoleMappersForConsumerRealm(IdentityProviderMapperSyncMode syncMode) {
log.debug("adding mappers to identity provider in realm " + bc.consumerRealmName());
RealmResource realm = adminClient.realm(bc.consumerRealmName());
IdentityProviderResource idpResource = realm.identityProviders().get(bc.getIDPAlias());
for (IdentityProviderMapperRepresentation mapper : createIdentityProviderMappers(syncMode)) {
mapper.setIdentityProviderAlias(bc.getIDPAlias());
Response resp = idpResource.addMapper(mapper);
resp.close();
}
}
use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.
the class KcSamlAdvancedAttributeToRoleMapperTest method createMapperInIdp.
@Override
protected void createMapperInIdp(IdentityProviderRepresentation idp, String claimsOrAttributeRepresentation, boolean areClaimsOrAttributeValuesRegexes, IdentityProviderMapperSyncMode syncMode) {
IdentityProviderMapperRepresentation advancedAttributeToRoleMapper = new IdentityProviderMapperRepresentation();
advancedAttributeToRoleMapper.setName("advanced-attribute-to-role-mapper");
advancedAttributeToRoleMapper.setIdentityProviderMapper(AdvancedAttributeToRoleMapper.PROVIDER_ID);
advancedAttributeToRoleMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(AdvancedAttributeToRoleMapper.ATTRIBUTE_PROPERTY_NAME, claimsOrAttributeRepresentation).put(AdvancedAttributeToRoleMapper.ARE_ATTRIBUTE_VALUES_REGEX_PROPERTY_NAME, areClaimsOrAttributeValuesRegexes ? "true" : "false").put(ConfigConstants.ROLE, CLIENT_ROLE_MAPPER_REPRESENTATION).build());
IdentityProviderResource idpResource = realm.identityProviders().get(idp.getAlias());
advancedAttributeToRoleMapper.setIdentityProviderAlias(bc.getIDPAlias());
idpResource.addMapper(advancedAttributeToRoleMapper).close();
}
use of org.keycloak.representations.idm.IdentityProviderMapperRepresentation in project keycloak by keycloak.
the class KcSamlBrokerTest method createAdditionalMapperWithCustomSyncMode.
protected void createAdditionalMapperWithCustomSyncMode(IdentityProviderMapperSyncMode syncMode) {
IdentityProviderMapperRepresentation friendlyManagerMapper = new IdentityProviderMapperRepresentation();
friendlyManagerMapper.setName("friendly-manager-role-mapper");
friendlyManagerMapper.setIdentityProviderMapper(AttributeToRoleMapper.PROVIDER_ID);
friendlyManagerMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, syncMode.toString()).put(UserAttributeMapper.ATTRIBUTE_NAME, "Role").put(ATTRIBUTE_VALUE, ROLE_FRIENDLY_MANAGER).put("role", ROLE_FRIENDLY_MANAGER).build());
friendlyManagerMapper.setIdentityProviderAlias(bc.getIDPAlias());
RealmResource realm = adminClient.realm(bc.consumerRealmName());
IdentityProviderResource idpResource = realm.identityProviders().get(bc.getIDPAlias());
idpResource.addMapper(friendlyManagerMapper).close();
}
Aggregations