keycloak-service
公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 静的関数 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.broker.saml.mappers.AttributeToRoleMapper クラス
org.keycloak.broker.saml.mappers.AttributeToRoleMapper の継承関係図
Inheritance graph
org.keycloak.broker.saml.mappers.AttributeToRoleMapper 連携図
Collaboration graph

公開メンバ関数

List< ProviderConfigProperty > getConfigProperties ()
 
String getId ()
 
String [] getCompatibleProviders ()
 
String getDisplayCategory ()
 
String getDisplayType ()
 
void importNewUser (KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 
void updateBrokeredUser (KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 
String getHelpText ()
 

静的公開変数類

static final String [] COMPATIBLE_PROVIDERS = {SAMLIdentityProviderFactory.PROVIDER_ID}
 
static final String ATTRIBUTE_NAME = "attribute.name"
 
static final String ATTRIBUTE_FRIENDLY_NAME = "attribute.friendly.name"
 
static final String ATTRIBUTE_VALUE = "attribute.value"
 
static final String PROVIDER_ID = "saml-role-idp-mapper"
 

限定公開メンバ関数

boolean isAttributePresent (IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
 

静的関数

 [static initializer]
 

静的非公開変数類

static final List< ProviderConfigProperty > configProperties = new ArrayList<ProviderConfigProperty>()
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ [static initializer]()

org.keycloak.broker.saml.mappers.AttributeToRoleMapper.[static initializer] ( )
inlinestaticpackage

◆ getCompatibleProviders()

String [] org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getCompatibleProviders ( )
inline
95  {
96  return COMPATIBLE_PROVIDERS;
97  }
static final String [] COMPATIBLE_PROVIDERS
Definition: AttributeToRoleMapper.java:46

◆ getConfigProperties()

List<ProviderConfigProperty> org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getConfigProperties ( )
inline
85  {
86  return configProperties;
87  }
static final List< ProviderConfigProperty > configProperties
Definition: AttributeToRoleMapper.java:48

◆ getDisplayCategory()

String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getDisplayCategory ( )
inline
100  {
101  return "Role Mapper";
102  }

◆ getDisplayType()

String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getDisplayType ( )
inline
105  {
106  return "SAML Attribute to Role";
107  }

◆ getHelpText()

String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getHelpText ( )
inline
153  {
154  return "If a claim exists, grant the user the specified realm or application role.";
155  }

◆ getId()

String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.getId ( )
inline
90  {
91  return PROVIDER_ID;
92  }
static final String PROVIDER_ID
Definition: AttributeToRoleMapper.java:82

◆ importNewUser()

void org.keycloak.broker.saml.mappers.AttributeToRoleMapper.importNewUser ( KeycloakSession  session,
RealmModel  realm,
UserModel  user,
IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inline
110  {
111  String roleName = mapperModel.getConfig().get(ConfigConstants.ROLE);
112  if (isAttributePresent(mapperModel, context)) {
113  RoleModel role = KeycloakModelUtils.getRoleFromString(realm, roleName);
114  if (role == null) throw new IdentityBrokerException("Unable to find role: " + roleName);
115  user.grantRole(role);
116  }
117  }
boolean isAttributePresent(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AttributeToRoleMapper.java:119

◆ isAttributePresent()

boolean org.keycloak.broker.saml.mappers.AttributeToRoleMapper.isAttributePresent ( IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inlineprotected
119  {
120  String name = mapperModel.getConfig().get(ATTRIBUTE_NAME);
121  if (name != null && name.trim().equals("")) name = null;
122  String friendly = mapperModel.getConfig().get(ATTRIBUTE_FRIENDLY_NAME);
123  if (friendly != null && friendly.trim().equals("")) friendly = null;
124  String desiredValue = mapperModel.getConfig().get(ATTRIBUTE_VALUE);
125  AssertionType assertion = (AssertionType)context.getContextData().get(SAMLEndpoint.SAML_ASSERTION);
126  for (AttributeStatementType statement : assertion.getAttributeStatements()) {
127  for (AttributeStatementType.ASTChoiceType choice : statement.getAttributes()) {
128  AttributeType attr = choice.getAttribute();
129  if (name != null && !name.equals(attr.getName())) continue;
130  if (friendly != null && !friendly.equals(attr.getFriendlyName())) continue;
131  for (Object val : attr.getAttributeValue()) {
132  if (val.equals(desiredValue)) return true;
133  }
134  }
135  }
136  return false;
137  }
static final String ATTRIBUTE_VALUE
Definition: AttributeToRoleMapper.java:52
static final String ATTRIBUTE_NAME
Definition: AttributeToRoleMapper.java:50
static final String ATTRIBUTE_FRIENDLY_NAME
Definition: AttributeToRoleMapper.java:51

◆ updateBrokeredUser()

void org.keycloak.broker.saml.mappers.AttributeToRoleMapper.updateBrokeredUser ( KeycloakSession  session,
RealmModel  realm,
UserModel  user,
IdentityProviderMapperModel  mapperModel,
BrokeredIdentityContext  context 
)
inline
140  {
141  String roleName = mapperModel.getConfig().get(ConfigConstants.ROLE);
142  RoleModel role = KeycloakModelUtils.getRoleFromString(realm, roleName);
143  if (role == null) throw new IdentityBrokerException("Unable to find role: " + roleName);
144  if (!isAttributePresent(mapperModel, context)) {
145  user.deleteRoleMapping(role);
146  }else{
147  user.grantRole(role);
148  }
149 
150  }
boolean isAttributePresent(IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context)
Definition: AttributeToRoleMapper.java:119

メンバ詳解

◆ ATTRIBUTE_FRIENDLY_NAME

final String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.ATTRIBUTE_FRIENDLY_NAME = "attribute.friendly.name"
static

◆ ATTRIBUTE_NAME

final String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.ATTRIBUTE_NAME = "attribute.name"
static

◆ ATTRIBUTE_VALUE

final String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.ATTRIBUTE_VALUE = "attribute.value"
static

◆ COMPATIBLE_PROVIDERS

final String [] org.keycloak.broker.saml.mappers.AttributeToRoleMapper.COMPATIBLE_PROVIDERS = {SAMLIdentityProviderFactory.PROVIDER_ID}
static

◆ configProperties

final List<ProviderConfigProperty> org.keycloak.broker.saml.mappers.AttributeToRoleMapper.configProperties = new ArrayList<ProviderConfigProperty>()
staticprivate

◆ PROVIDER_ID

final String org.keycloak.broker.saml.mappers.AttributeToRoleMapper.PROVIDER_ID = "saml-role-idp-mapper"
static

このクラス詳解は次のファイルから抽出されました: