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

公開メンバ関数

String getDisplayCategory ()
 
String getDisplayType ()
 
String getHelpText ()
 
List< ProviderConfigProperty > getConfigProperties ()
 
String getId ()
 
void mapRoles (AttributeStatementType roleAttributeStatement, ProtocolMapperModel mappingModel, KeycloakSession session, UserSessionModel userSession, ClientSessionContext clientSessionCtx)
 
String getProtocol ()
 
void close ()
 
final ProtocolMapper create (KeycloakSession session)
 
void init (Config.Scope config)
 
void postInit (KeycloakSessionFactory factory)
 

静的公開メンバ関数

static ProtocolMapperModel create (String name, String samlAttributeName, String nameFormat, String friendlyName, boolean singleAttribute)
 

静的公開変数類

static final String PROVIDER_ID = "saml-role-list-mapper"
 
static final String SINGLE_ROLE_ATTRIBUTE = "single"
 

静的関数

 [static initializer]
 

静的非公開変数類

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

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ [static initializer]()

org.keycloak.protocol.saml.mappers.RoleListMapper.[static initializer] ( )
inlinestaticpackage

◆ close()

void org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper.close ( )
inlineinherited
39  {
40 
41  }

◆ create() [1/2]

final ProtocolMapper org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper.create ( KeycloakSession  session)
inlineinherited
44  {
45  throw new RuntimeException("UNSUPPORTED METHOD");
46  }

◆ create() [2/2]

static ProtocolMapperModel org.keycloak.protocol.saml.mappers.RoleListMapper.create ( String  name,
String  samlAttributeName,
String  nameFormat,
String  friendlyName,
boolean  singleAttribute 
)
inlinestatic
174  {
175  ProtocolMapperModel mapper = new ProtocolMapperModel();
176  mapper.setName(name);
177  mapper.setProtocolMapper(PROVIDER_ID);
178  mapper.setProtocol(SamlProtocol.LOGIN_PROTOCOL);
179  Map<String, String> config = new HashMap<>();
180  config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAME, samlAttributeName);
181  if (friendlyName != null) {
182  config.put(AttributeStatementHelper.FRIENDLY_NAME, friendlyName);
183  }
184  if (nameFormat != null) {
185  config.put(AttributeStatementHelper.SAML_ATTRIBUTE_NAMEFORMAT, nameFormat);
186  }
187  config.put(SINGLE_ROLE_ATTRIBUTE, Boolean.toString(singleAttribute));
188  mapper.setConfig(config);
189 
190  return mapper;
191  }
static final String SINGLE_ROLE_ATTRIBUTE
Definition: RoleListMapper.java:47
static final String PROVIDER_ID
Definition: RoleListMapper.java:46

◆ getConfigProperties()

List<ProviderConfigProperty> org.keycloak.protocol.saml.mappers.RoleListMapper.getConfigProperties ( )
inline
102  {
103  return configProperties;
104  }
static final List< ProviderConfigProperty > configProperties
Definition: RoleListMapper.java:49

◆ getDisplayCategory()

String org.keycloak.protocol.saml.mappers.RoleListMapper.getDisplayCategory ( )
inline
87  {
88  return "Role Mapper";
89  }

◆ getDisplayType()

String org.keycloak.protocol.saml.mappers.RoleListMapper.getDisplayType ( )
inline
92  {
93  return "Role list";
94  }

◆ getHelpText()

String org.keycloak.protocol.saml.mappers.RoleListMapper.getHelpText ( )
inline
97  {
98  return "Role names are stored in an attribute value. There is either one attribute with multiple attribute values, or an attribute per role name depending on how you configure it. You can also specify the attribute name i.e. 'Role' or 'memberOf' being examples.";
99  }

◆ getId()

String org.keycloak.protocol.saml.mappers.RoleListMapper.getId ( )
inline
107  {
108  return PROVIDER_ID;
109  }
static final String PROVIDER_ID
Definition: RoleListMapper.java:46

◆ getProtocol()

String org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper.getProtocol ( )
inlineinherited
34  {
35  return SamlProtocol.LOGIN_PROTOCOL;
36  }

◆ init()

void org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper.init ( Config.Scope  config)
inlineinherited
49  {
50  }

◆ mapRoles()

void org.keycloak.protocol.saml.mappers.RoleListMapper.mapRoles ( AttributeStatementType  roleAttributeStatement,
ProtocolMapperModel  mappingModel,
KeycloakSession  session,
UserSessionModel  userSession,
ClientSessionContext  clientSessionCtx 
)
inline

org.keycloak.protocol.saml.mappers.SAMLRoleListMapperを実装しています。

112  {
113  String single = mappingModel.getConfig().get(SINGLE_ROLE_ATTRIBUTE);
114  boolean singleAttribute = Boolean.parseBoolean(single);
115 
116  List<SamlProtocol.ProtocolMapperProcessor<SAMLRoleNameMapper>> roleNameMappers = new LinkedList<>();
117  KeycloakSessionFactory sessionFactory = session.getKeycloakSessionFactory();
118  AttributeType singleAttributeType = null;
119  Set<ProtocolMapperModel> requestedProtocolMappers = clientSessionCtx.getProtocolMappers();
120  for (ProtocolMapperModel mapping : requestedProtocolMappers) {
121 
122  ProtocolMapper mapper = (ProtocolMapper)sessionFactory.getProviderFactory(ProtocolMapper.class, mapping.getProtocolMapper());
123  if (mapper == null) continue;
124 
125  if (mapper instanceof SAMLRoleNameMapper) {
126  roleNameMappers.add(new SamlProtocol.ProtocolMapperProcessor<>((SAMLRoleNameMapper) mapper,mapping));
127  }
128 
129  if (mapper instanceof HardcodedRole) {
130  AttributeType attributeType;
131  if (singleAttribute) {
132  if (singleAttributeType == null) {
133  singleAttributeType = AttributeStatementHelper.createAttributeType(mappingModel);
134  roleAttributeStatement.addAttribute(new AttributeStatementType.ASTChoiceType(singleAttributeType));
135  }
136  attributeType = singleAttributeType;
137  } else {
138  attributeType = AttributeStatementHelper.createAttributeType(mappingModel);
139  roleAttributeStatement.addAttribute(new AttributeStatementType.ASTChoiceType(attributeType));
140  }
141 
142  attributeType.addAttributeValue(mapping.getConfig().get(HardcodedRole.ROLE_ATTRIBUTE));
143  }
144  }
145 
146  List<String> allRoleNames = clientSessionCtx.getRoles().stream()
147  // todo need a role mapping
148  .flatMap(RoleUtils::expandCompositeRolesStream)
149  .map(roleModel -> roleNameMappers.stream()
150  .map(entry -> entry.mapper.mapName(entry.model, roleModel))
151  .filter(Objects::nonNull)
152  .findFirst()
153  .orElse(roleModel.getName())
154  ).collect(Collectors.toList());
155 
156  for (String roleName : allRoleNames) {
157  AttributeType attributeType;
158  if (singleAttribute) {
159  if (singleAttributeType == null) {
160  singleAttributeType = AttributeStatementHelper.createAttributeType(mappingModel);
161  roleAttributeStatement.addAttribute(new AttributeStatementType.ASTChoiceType(singleAttributeType));
162  }
163  attributeType = singleAttributeType;
164  } else {
165  attributeType = AttributeStatementHelper.createAttributeType(mappingModel);
166  roleAttributeStatement.addAttribute(new AttributeStatementType.ASTChoiceType(attributeType));
167  }
168 
169  attributeType.addAttributeValue(roleName);
170  }
171 
172  }
static final String SINGLE_ROLE_ATTRIBUTE
Definition: RoleListMapper.java:47

◆ postInit()

void org.keycloak.protocol.saml.mappers.AbstractSAMLProtocolMapper.postInit ( KeycloakSessionFactory  factory)
inlineinherited
53  {
54 
55  }

メンバ詳解

◆ configProperties

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

◆ PROVIDER_ID

final String org.keycloak.protocol.saml.mappers.RoleListMapper.PROVIDER_ID = "saml-role-list-mapper"
static

◆ SINGLE_ROLE_ATTRIBUTE

final String org.keycloak.protocol.saml.mappers.RoleListMapper.SINGLE_ROLE_ATTRIBUTE = "single"
static

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