Search in sources :

Example 11 with ProtocolMapperModel

use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.

the class UserSessionNoteMapper method createClaimMapper.

public static ProtocolMapperModel createClaimMapper(String name, String userSessionNote, String tokenClaimName, String jsonType, boolean accessToken, boolean idToken) {
    ProtocolMapperModel mapper = new ProtocolMapperModel();
    mapper.setName(name);
    mapper.setProtocolMapper(PROVIDER_ID);
    mapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    Map<String, String> config = new HashMap<>();
    config.put(ProtocolMapperUtils.USER_SESSION_NOTE, userSessionNote);
    config.put(OIDCAttributeMapperHelper.TOKEN_CLAIM_NAME, tokenClaimName);
    config.put(OIDCAttributeMapperHelper.JSON_TYPE, jsonType);
    if (accessToken)
        config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN, "true");
    if (idToken)
        config.put(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN, "true");
    mapper.setConfig(config);
    return mapper;
}
Also used : HashMap(java.util.HashMap) ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel)

Example 12 with ProtocolMapperModel

use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.

the class HardcodedAttributeMapper method create.

public static ProtocolMapperModel create(String name, String samlAttributeName, String nameFormat, String friendlyName, String value) {
    String mapperId = PROVIDER_ID;
    ProtocolMapperModel model = AttributeStatementHelper.createAttributeMapper(name, null, samlAttributeName, nameFormat, friendlyName, mapperId);
    model.getConfig().put(ATTRIBUTE_VALUE, value);
    return model;
}
Also used : ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel)

Example 13 with ProtocolMapperModel

use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.

the class GroupMembershipMapper method create.

public static ProtocolMapperModel create(String name, String samlAttributeName, String nameFormat, String friendlyName, boolean singleAttribute) {
    ProtocolMapperModel mapper = new ProtocolMapperModel();
    mapper.setName(name);
    mapper.setProtocolMapper(PROVIDER_ID);
    mapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    Map<String, String> config = new HashMap<String, String>();
    config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, samlAttributeName);
    if (friendlyName != null) {
        config.put(AttributeStatementHelper.FRIENDLY_NAME, friendlyName);
    }
    if (nameFormat != null) {
        config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, nameFormat);
    }
    config.put(SINGLE_GROUP_ATTRIBUTE, Boolean.toString(singleAttribute));
    mapper.setConfig(config);
    return mapper;
}
Also used : HashMap(java.util.HashMap) ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel)

Example 14 with ProtocolMapperModel

use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.

the class RoleListMapper method create.

public static ProtocolMapperModel create(String name, String samlAttributeName, String nameFormat, String friendlyName, boolean singleAttribute) {
    ProtocolMapperModel mapper = new ProtocolMapperModel();
    mapper.setName(name);
    mapper.setProtocolMapper(PROVIDER_ID);
    mapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
    Map<String, String> config = new HashMap<>();
    config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, samlAttributeName);
    if (friendlyName != null) {
        config.put(AttributeStatementHelper.FRIENDLY_NAME, friendlyName);
    }
    if (nameFormat != null) {
        config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, nameFormat);
    }
    config.put(SINGLE_ROLE_ATTRIBUTE, Boolean.toString(singleAttribute));
    mapper.setConfig(config);
    return mapper;
}
Also used : HashMap(java.util.HashMap) ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel)

Example 15 with ProtocolMapperModel

use of org.keycloak.models.ProtocolMapperModel in project keycloak by keycloak.

the class RoleNameMapper method create.

public static ProtocolMapperModel create(String name, String role, String newName) {
    String mapperId = PROVIDER_ID;
    ProtocolMapperModel mapper = new ProtocolMapperModel();
    mapper.setName(name);
    mapper.setProtocolMapper(mapperId);
    mapper.setProtocol(OIDCLoginProtocol.LOGIN_PROTOCOL);
    Map<String, String> config = new HashMap<>();
    config.put(ROLE_CONFIG, role);
    config.put(NEW_ROLE_NAME, newName);
    mapper.setConfig(config);
    return mapper;
}
Also used : HashMap(java.util.HashMap) ProtocolMapperModel(org.keycloak.models.ProtocolMapperModel)

Aggregations

ProtocolMapperModel (org.keycloak.models.ProtocolMapperModel)51 HashMap (java.util.HashMap)22 ClientModel (org.keycloak.models.ClientModel)7 Path (javax.ws.rs.Path)6 NoCache (org.jboss.resteasy.annotations.cache.NoCache)6 LinkedList (java.util.LinkedList)5 List (java.util.List)5 ProviderConfigProperty (org.keycloak.provider.ProviderConfigProperty)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 NotFoundException (javax.ws.rs.NotFoundException)4 ClientScopeModel (org.keycloak.models.ClientScopeModel)4 KeycloakSession (org.keycloak.models.KeycloakSession)4 RealmModel (org.keycloak.models.RealmModel)4 RoleModel (org.keycloak.models.RoleModel)4 UserModel (org.keycloak.models.UserModel)4 IDToken (org.keycloak.representations.IDToken)4 ProtocolMapperRepresentation (org.keycloak.representations.idm.ProtocolMapperRepresentation)4 IOException (java.io.IOException)3 MigrationProvider (org.keycloak.migration.MigrationProvider)3