Java Code Examples for org.keycloak.representations.idm.ProtocolMapperRepresentation#getConfig()

The following examples show how to use org.keycloak.representations.idm.ProtocolMapperRepresentation#getConfig() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testUserSessionNote() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user session note");
    createClientMappersPage.form().setMapperType(USER_SESSION_NOTE);
    createClientMappersPage.form().setUserSessionNote("session note");
    createClientMappersPage.form().setTokenClaimName("claim name");
    createClientMappersPage.form().setClaimJSONType("int");
    createClientMappersPage.form().setAddToIDToken(false);
    createClientMappersPage.form().setAddToAccessToken(false);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user session note");
    assertNotNull(found);

    assertEquals("oidc-usersessionmodel-note-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("claim name", config.get("claim.name"));
    assertEquals("session note", config.get("user.session.note"));
    assertEquals("int", config.get("jsonType.label"));
}
 
Example 2
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testRoleName() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("role name");
    createClientMappersPage.form().setMapperType(ROLE_NAME_MAPPER);
    createClientMappersPage.form().setRole("offline_access");
    createClientMappersPage.form().setNewRole("new role");
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "role name");
    assertEquals("oidc-role-name-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("offline_access", config.get("role"));
    assertEquals("new role", config.get("new.role.name"));
}
 
Example 3
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testUserAttribute() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user attribute");
    createClientMappersPage.form().setMapperType(USER_ATTRIBUTE);
    createClientMappersPage.form().setUserAttribute("user attribute");
    createClientMappersPage.form().setMultivalued(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user attribute");
    assertEquals("oidc-usermodel-attribute-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("multivalued"));
    assertEquals("user attribute", config.get("user.attribute"));
}
 
Example 4
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testUserProperty() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("user property");
    createClientMappersPage.form().setMapperType(USER_PROPERTY);
    createClientMappersPage.form().setProperty("property");
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "user property");
    assertEquals("oidc-usermodel-property-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("property", config.get("user.attribute"));
}
 
Example 5
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testGroupMembership() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("group membership");
    createClientMappersPage.form().setMapperType(GROUP_MEMBERSHIP);
    createClientMappersPage.form().setFullGroupPath(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "group membership");
    assertEquals("oidc-group-membership-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("full.path"));
}
 
Example 6
Source File: ClientMappersSAMLTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testRoleName() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("role name");
    createClientMappersPage.form().setMapperType(ROLE_NAME_MAPPER);
    createClientMappersPage.form().setRole("offline_access");
    createClientMappersPage.form().setNewRole("new role");
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "role name");
    assertEquals("saml-role-name-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("offline_access", config.get("role"));
    assertEquals("new role", config.get("new.role.name"));
}
 
Example 7
Source File: ClientMappersSAMLTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testRoleList() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("new role list");
    createClientMappersPage.form().setMapperType(ROLE_LIST);
    createClientMappersPage.form().setRoleAttributeName("role attribute name");
    createClientMappersPage.form().setFriendlyName("friendly name");
    createClientMappersPage.form().setSamlAttributeNameFormat("URI Reference");
    createClientMappersPage.form().setSingleRoleAttribute(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "new role list");
    assertNotNull(found);

    assertEquals("saml-role-list-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("role attribute name", config.get("attribute.name"));
    assertEquals("URI Reference", config.get("attribute.nameformat"));
    assertEquals("friendly name", config.get("friendly.name"));
    assertEquals("true", config.get("single"));
}
 
Example 8
Source File: ClientMappersSAMLTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testHardcodedAttribute() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("hardcoded attribute");
    createClientMappersPage.form().setMapperType(HARDCODED_ATTRIBUTE);
    createClientMappersPage.form().setAttributeValue("attribute value");
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded attribute");
    assertNotNull(found);

    assertEquals("saml-hardcode-attribute-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("attribute value", config.get("attribute.value"));
}
 
Example 9
Source File: ClientMappersSAMLTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testGroupList() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("group list");
    createClientMappersPage.form().setMapperType(GROUP_LIST);
    createClientMappersPage.form().setGroupAttributeName("group attribute name");
    createClientMappersPage.form().setSingleGroupAttribute(true);
    createClientMappersPage.form().setFullGroupPath(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "group list");
    assertEquals("saml-group-membership-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("full.path"));
    assertEquals("true", config.get("single"));
    assertEquals("group attribute name", config.get("attribute.name"));
}
 
Example 10
Source File: ClientMappersSAMLTest.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Test
public void testHardcodedRole() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("hardcoded role");
    createClientMappersPage.form().setMapperType(HARDCODED_ROLE_SAML);
    createClientMappersPage.form().selectRole(REALM_ROLE, "offline_access", null);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded role");
    assertNotNull(found);
    
    assertEquals("saml-hardcode-role-mapper", found.getProtocolMapper());

    Map<String, String> config = found.getConfig();
    assertEquals(1, config.size());
    assertEquals("offline_access", config.get("role"));
}
 
Example 11
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testHardcodedRole() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("hardcoded role");
    createClientMappersPage.form().setMapperType(HARDCODED_ROLE);
    createClientMappersPage.form().selectRole(REALM_ROLE, "offline_access", null);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded role");
    assertNotNull(found);

    assertEquals("oidc-hardcoded-role-mapper", found.getProtocolMapper());
    Map<String, String> config = found.getConfig();
    
    assertEquals("offline_access", config.get("role"));
    
    //edit
    createClientMappersPage.form().selectRole(CLIENT_ROLE, "view-profile", "account");
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    config = findClientMapperByName(id, "hardcoded role").getConfig();
    assertEquals("account.view-profile", config.get("role"));
    
    //delete
    clientMapperPage.setMapperId(found.getId());
    clientMapperPage.delete();
    assertAlertSuccess();
    
    //check
    assertNull(findClientMapperByName(id, "hardcoded role"));
}
 
Example 12
Source File: ClientMappersOIDCTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Test
public void testHardcodedClaim() {
    //create
    clientMappersPage.mapperTable().createMapper();
    setInitialValues("hardcoded claim");
    createClientMappersPage.form().setMapperType(HARDCODED_CLAIM);
    createClientMappersPage.form().setTokenClaimName("claim name");
    createClientMappersPage.form().setTokenClaimValue("claim value");
    createClientMappersPage.form().setClaimJSONType("long");
    createClientMappersPage.form().setAddToIDToken(true);
    createClientMappersPage.form().setAddToAccessToken(true);
    createClientMappersPage.form().save();
    assertAlertSuccess();
    
    //check
    ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded claim");
    assertNotNull(found);

    assertEquals("oidc-hardcoded-claim-mapper", found.getProtocolMapper());
    
    Map<String, String> config = found.getConfig();
    assertEquals("true", config.get("id.token.claim"));
    assertEquals("true", config.get("access.token.claim"));
    assertEquals("claim name", config.get("claim.name"));
    assertEquals("claim value", config.get("claim.value"));
    assertEquals("long", config.get("jsonType.label"));
}
 
Example 13
Source File: KcOidcBrokerConfiguration.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public List<ClientRepresentation> createProviderClients() {
    ClientRepresentation client = new ClientRepresentation();
    client.setId(CLIENT_ID);
    client.setClientId(getIDPClientIdInProviderRealm());
    client.setName(CLIENT_ID);
    client.setSecret(CLIENT_SECRET);
    client.setEnabled(true);

    client.setRedirectUris(Collections.singletonList(getConsumerRoot() +
            "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_OIDC_ALIAS + "/endpoint/*"));

    client.setAdminUrl(getConsumerRoot() +
            "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_OIDC_ALIAS + "/endpoint");

    ProtocolMapperRepresentation emailMapper = new ProtocolMapperRepresentation();
    emailMapper.setName("email");
    emailMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    emailMapper.setProtocolMapper(UserPropertyMapper.PROVIDER_ID);

    Map<String, String> emailMapperConfig = emailMapper.getConfig();
    emailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "email");
    emailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "email");
    emailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    emailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation nestedAttrMapper = new ProtocolMapperRepresentation();
    nestedAttrMapper.setName("attribute - nested claim");
    nestedAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    nestedAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> nestedEmailMapperConfig = nestedAttrMapper.getConfig();
    nestedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "nested.email");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "nested.email");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    nestedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation dottedAttrMapper = new ProtocolMapperRepresentation();
    dottedAttrMapper.setName("attribute - claim with dot in name");
    dottedAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    dottedAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> dottedEmailMapperConfig = dottedAttrMapper.getConfig();
    dottedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "dotted.email");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, "dotted\\.email");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    dottedEmailMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");

    ProtocolMapperRepresentation userAttrMapper = new ProtocolMapperRepresentation();
    userAttrMapper.setName("attribute - name");
    userAttrMapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    userAttrMapper.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> userAttrMapperConfig = userAttrMapper.getConfig();
    userAttrMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    userAttrMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");
    userAttrMapperConfig.put(ProtocolMapperUtils.MULTIVALUED, "true");

    ProtocolMapperRepresentation userAttrMapper2 = new ProtocolMapperRepresentation();
    userAttrMapper2.setName("attribute - name - 2");
    userAttrMapper2.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    userAttrMapper2.setProtocolMapper(UserAttributeMapper.PROVIDER_ID);

    Map<String, String> userAttrMapperConfig2 = userAttrMapper2.getConfig();
    userAttrMapperConfig2.put(ProtocolMapperUtils.USER_ATTRIBUTE, ATTRIBUTE_TO_MAP_NAME_2);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, ATTRIBUTE_TO_MAP_NAME_2);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.JSON_TYPE, ProviderConfigProperty.STRING_TYPE);
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    userAttrMapperConfig2.put(OIDCAttributeMapperHelper.INCLUDE_IN_USERINFO, "true");
    userAttrMapperConfig2.put(ProtocolMapperUtils.MULTIVALUED, "true");

    ProtocolMapperRepresentation hardcodedJsonClaim = new ProtocolMapperRepresentation();
    hardcodedJsonClaim.setName("json-mapper");
    hardcodedJsonClaim.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    hardcodedJsonClaim.setProtocolMapper(HardcodedClaim.PROVIDER_ID);

    Map<String, String> hardcodedJsonClaimMapperConfig = hardcodedJsonClaim.getConfig();
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, KcOidcBrokerConfiguration.USER_INFO_CLAIM);
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.JSON_TYPE, "JSON");
    hardcodedJsonClaimMapperConfig.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    hardcodedJsonClaimMapperConfig.put(HardcodedClaim.CLAIM_VALUE, "{\"" + HARDOCDED_CLAIM + "\": \"" + HARDOCDED_VALUE + "\"}");

    client.setProtocolMappers(Arrays.asList(emailMapper, userAttrMapper, userAttrMapper2, nestedAttrMapper, dottedAttrMapper, hardcodedJsonClaim));

    return Collections.singletonList(client);
}
 
Example 14
Source File: KcSamlBrokerConfiguration.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private ClientRepresentation createProviderClient(String clientId) {
    ClientRepresentation client = new ClientRepresentation();

    client.setClientId(clientId);
    client.setEnabled(true);
    client.setProtocol(IDP_SAML_PROVIDER_ID);
    client.setRedirectUris(Collections.singletonList(
            getConsumerRoot() + "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_SAML_ALIAS + "/endpoint"
    ));

    Map<String, String> attributes = new HashMap<>();

    attributes.put(SamlConfigAttributes.SAML_AUTHNSTATEMENT, "true");
    attributes.put(SamlProtocol.SAML_SINGLE_LOGOUT_SERVICE_URL_POST_ATTRIBUTE,
            getConsumerRoot() + "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_SAML_ALIAS + "/endpoint");
    attributes.put(SAML_ASSERTION_CONSUMER_URL_POST_ATTRIBUTE,
            getConsumerRoot() + "/auth/realms/" + REALM_CONS_NAME + "/broker/" + IDP_SAML_ALIAS + "/endpoint");
    attributes.put(SamlConfigAttributes.SAML_FORCE_NAME_ID_FORMAT_ATTRIBUTE, "true");
    attributes.put(SamlConfigAttributes.SAML_NAME_ID_FORMAT_ATTRIBUTE, "username");
    attributes.put(SamlConfigAttributes.SAML_ASSERTION_SIGNATURE, "false");
    attributes.put(SamlConfigAttributes.SAML_SERVER_SIGNATURE, "false");
    attributes.put(SamlConfigAttributes.SAML_CLIENT_SIGNATURE_ATTRIBUTE, "false");
    attributes.put(SamlConfigAttributes.SAML_ENCRYPT, "false");

    client.setAttributes(attributes);

    ProtocolMapperRepresentation emailMapper = new ProtocolMapperRepresentation();
    emailMapper.setName("email");
    emailMapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    emailMapper.setProtocolMapper(UserPropertyAttributeStatementMapper.PROVIDER_ID);

    Map<String, String> emailMapperConfig = emailMapper.getConfig();
    emailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "email");
    emailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, "urn:oid:1.2.840.113549.1.9.1");
    emailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, "urn:oasis:names:tc:SAML:2.0:attrname-format:uri");
    emailMapperConfig.put(AttributeStatementHelper.FRIENDLY_NAME, "email");

    ProtocolMapperRepresentation dottedAttrMapper = new ProtocolMapperRepresentation();
    dottedAttrMapper.setName("email - dotted");
    dottedAttrMapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    dottedAttrMapper.setProtocolMapper(UserAttributeStatementMapper.PROVIDER_ID);

    Map<String, String> dottedEmailMapperConfig = dottedAttrMapper.getConfig();
    dottedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "dotted.email");
    dottedEmailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, "dotted.email");
    dottedEmailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, "urn:oasis:names:tc:SAML:2.0:attrname-format:uri");

    ProtocolMapperRepresentation nestedAttrMapper = new ProtocolMapperRepresentation();
    nestedAttrMapper.setName("email - nested");
    nestedAttrMapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    nestedAttrMapper.setProtocolMapper(UserAttributeStatementMapper.PROVIDER_ID);

    Map<String, String> nestedEmailMapperConfig = nestedAttrMapper.getConfig();
    nestedEmailMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, "nested.email");
    nestedEmailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, "nested.email");
    nestedEmailMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, "urn:oasis:names:tc:SAML:2.0:attrname-format:uri");

    ProtocolMapperRepresentation userAttrMapper = new ProtocolMapperRepresentation();
    userAttrMapper.setName("attribute - name");
    userAttrMapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    userAttrMapper.setProtocolMapper(UserAttributeStatementMapper.PROVIDER_ID);

    Map<String, String> userAttrMapperConfig = userAttrMapper.getConfig();
    userAttrMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, KcOidcBrokerConfiguration.ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, KcOidcBrokerConfiguration.ATTRIBUTE_TO_MAP_NAME);
    userAttrMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, AttributeStatementHelper.BASIC);
    userAttrMapperConfig.put(AttributeStatementHelper.FRIENDLY_NAME, "");

    ProtocolMapperRepresentation userFriendlyAttrMapper = new ProtocolMapperRepresentation();
    userFriendlyAttrMapper.setName("attribute - friendly name");
    userFriendlyAttrMapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    userFriendlyAttrMapper.setProtocolMapper(UserAttributeStatementMapper.PROVIDER_ID);

    Map<String, String> userFriendlyAttrMapperConfig = userFriendlyAttrMapper.getConfig();
    userFriendlyAttrMapperConfig.put(ProtocolMapperUtils.USER_ATTRIBUTE, AbstractUserAttributeMapperTest.ATTRIBUTE_TO_MAP_FRIENDLY_NAME);
    userFriendlyAttrMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, "urn:oid:1.2.3.4.5.6.7");
    userFriendlyAttrMapperConfig.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, AttributeStatementHelper.BASIC);
    userFriendlyAttrMapperConfig.put(AttributeStatementHelper.FRIENDLY_NAME, AbstractUserAttributeMapperTest.ATTRIBUTE_TO_MAP_FRIENDLY_NAME);

    client.setProtocolMappers(Arrays.asList(emailMapper, dottedAttrMapper, nestedAttrMapper, userAttrMapper, userFriendlyAttrMapper));

    return client;
}