本文整理汇总了Java中org.jboss.security.identity.RoleGroup.getRoles方法的典型用法代码示例。如果您正苦于以下问题:Java RoleGroup.getRoles方法的具体用法?Java RoleGroup.getRoles怎么用?Java RoleGroup.getRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.security.identity.RoleGroup
的用法示例。
在下文中一共展示了RoleGroup.getRoles方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrincipalSetFromRole
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
private Set<Principal> getPrincipalSetFromRole(Role role)
{
Set<Principal> principalsSet = new HashSet<Principal>();
if(role instanceof RoleGroup)
{
RoleGroup rg = (RoleGroup) role;
Collection<Role> rolesList = rg.getRoles();
for(Role r: rolesList)
{
principalsSet.add(new SimplePrincipal(r.getRoleName()));
}
}
else
principalsSet.add(new SimplePrincipal(role.getRoleName()));
return principalsSet;
}
示例2: getSubjectType
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
private SubjectType getSubjectType( Principal principal, RoleGroup callerRoles )
{
String subjectID_NS = XACMLConstants.ATTRIBUTEID_SUBJECT_ID;
String roleID_NS = XACMLConstants.ATTRIBUTEID_ROLE;
String principalName = principal.getName();
//Create a subject type
SubjectType subject = new SubjectType();
AttributeType attribute = RequestAttributeFactory.createStringAttributeType( subjectID_NS, "jboss.org", principalName );
subject.getAttribute().add( attribute );
Collection<Role> rolesList = callerRoles.getRoles();
if(rolesList != null)
{
for(Role role:rolesList)
{
String roleName = role.getRoleName();
AttributeType attSubjectID = RequestAttributeFactory.createStringAttributeType( roleID_NS , "jboss.org", roleName );
subject.getAttribute().add(attSubjectID);
}
}
return subject;
}
示例3: testRoleRecursion
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
public void testRoleRecursion() throws Exception {
StaxBasedConfigParser parser = new StaxBasedConfigParser();
parser.parse(Thread.currentThread().getContextClassLoader().getResourceAsStream("ldap/ldap-role-mapping-config.xml"));
SecurityContext sc = SecurityContextFactory.createSecurityContext("test");
MappingManager mm = sc.getMappingManager();
assertNotNull("MappingManager == null", mm);
MappingContext<RoleGroup> mc = mm.getMappingContext(MappingType.ROLE.name());
assertNotNull("MappingContext == null", mc);
assertTrue(mc.hasModules());
HashMap<String, Object> map = new HashMap<>();
map.put(SecurityConstants.PRINCIPAL_IDENTIFIER, new SimplePrincipal("jduke"));
MappingProvider<RoleGroup> provider = mc.getModules().get(0);
RoleGroup roleGroup = new SimpleRoleGroup("roles");
provider.performMapping(map, roleGroup);
Collection<Role> roles = roleGroup.getRoles();
assertEquals(roles.size(), 4);
List<Role> correctRoles = new ArrayList<>();
for (int i = 1; i < 5; i++)
correctRoles.add(new SimpleRole("R"+i));
assertTrue(roles.containsAll(correctRoles));
}
示例4: getAllRoles
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
/**
* <p>
* This method traverses the role tree that has the specified root role and puts all simple (i.e. not an instance of
* RoleGroup) roles into the specified roles list.
* </p>
*
* @param role the root of the role tree.
* @param roles the {@code List<Role>} that contains the simple roles of the tree.
*/
protected void getAllRoles(Role role, List<Role> roles)
{
if (role instanceof RoleGroup)
{
RoleGroup group = (RoleGroup) role;
for (Role nestedRole : group.getRoles())
getAllRoles(nestedRole, roles);
}
else
roles.add(role);
}
示例5: getRolesAsSet
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
private HashSet<Principal> getRolesAsSet(RoleGroup roles)
{
HashSet<Principal> userRoles = null;
if( roles != null )
{
userRoles = new HashSet<Principal>();
Collection<Role> rolesList = roles.getRoles();
for(Role r: rolesList)
{
userRoles.add(new SimplePrincipal(r.getRoleName()));
}
}
return userRoles;
}
示例6: containsAtleastOneRole
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
public boolean containsAtleastOneRole(RoleGroup anotherRole)
{
if (anotherRole == null)
throw PicketBoxMessages.MESSAGES.invalidNullArgument("anotherRole");
CopyOnWriteArrayList<Role> roleList = new CopyOnWriteArrayList<Role>(anotherRole.getRoles());
for (Role r : roleList)
{
if (this.containsAll(r))
return true;
}
return false;
}
示例7: populate
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void populate(ServiceSecurity serviceSecurity, SecurityContext securityContext) {
String sy_securityDomain = serviceSecurity.getSecurityDomain();
Subject sy_subject = securityContext.getSubject(sy_securityDomain);
org.jboss.security.SecurityContext jb_securityContext = SecurityContextAssociation.getSecurityContext();
if (jb_securityContext != null) {
// populate from pre-authenticated container context
String jb_securityDomain = jb_securityContext.getSecurityDomain();
if (!sy_securityDomain.equals(jb_securityDomain)) {
pushSubjectContext(sy_securityDomain);
}
Subject jb_subject = jb_securityContext.getUtil().getSubject();
transfer(jb_subject, sy_subject);
} else {
// populate from pre-verified federated assertion
Set<AssertionCredential> assertionCredentials = securityContext.getCredentials(AssertionCredential.class);
for (AssertionCredential assertionCredential : assertionCredentials) {
Element assertionElement = assertionCredential.getAssertion();
if (assertionElement != null) {
Subject sts_subject = new Subject();
boolean sts_mapped = false;
Map<String, Object> contextMap = new HashMap<String, Object>();
contextMap.put(AbstractSTSLoginModule.SHARED_TOKEN, assertionElement);
STSPrincipalMappingProvider principalMapper = new STSPrincipalMappingProvider();
principalMapper.init(contextMap);
MappingResult<Principal> principalResult = new MappingResult<Principal>();
principalMapper.setMappingResult(principalResult);
principalMapper.performMapping(contextMap, null);
Principal principal = principalResult.getMappedObject();
if (principal != null) {
sts_subject.getPrincipals().add(new UserPrincipal(principal.getName()));
sts_mapped = true;
}
STSGroupMappingProvider rolesMapper = new STSGroupMappingProvider();
rolesMapper.init(contextMap);
MappingResult<RoleGroup> rolesResult = new MappingResult<RoleGroup>();
rolesMapper.setMappingResult(rolesResult);
rolesMapper.performMapping(contextMap, null);
RoleGroup roleGroup = rolesResult.getMappedObject();
if (roleGroup != null) {
GroupPrincipal roles = null;
for (Role role : roleGroup.getRoles()) {
if (roles == null) {
roles = new GroupPrincipal(GroupPrincipal.ROLES);
}
roles.addMember(new RolePrincipal(role.getRoleName()));
}
if (roles != null) {
sts_subject.getPrincipals().add(roles);
sts_mapped = true;
}
}
if (sts_mapped) {
transfer(sts_subject, sy_subject);
}
}
}
}
super.populate(serviceSecurity, securityContext);
}
示例8: performMapping
import org.jboss.security.identity.RoleGroup; //导入方法依赖的package包/类
/**
* Obtains the deployment roles via the context map and applies it
* on the mappedObject
* @see MappingProvider#performMapping(Map, Object)
*/
@SuppressWarnings("unchecked")
public void performMapping(Map<String,Object> contextMap, RoleGroup mappedObject)
{
if(contextMap == null || contextMap.isEmpty())
throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextMap");
//Obtain the principal to roles mapping
Principal principal = (Principal) contextMap.get(SecurityConstants.PRINCIPAL_IDENTIFIER);
Map<String,Set<String>> roleToRolesMap = (Map<String,Set<String>>)contextMap.get(SecurityConstants.DEPLOYMENT_PRINCIPAL_ROLES_MAP);
Set<Principal> subjectPrincipals = (Set<Principal>) contextMap.get(SecurityConstants.PRINCIPALS_SET_IDENTIFIER);
PicketBoxLogger.LOGGER.debugMappingProviderOptions(principal, roleToRolesMap, subjectPrincipals);
if(roleToRolesMap == null || roleToRolesMap.isEmpty())
{
result.setMappedObject(mappedObject);
return ; // No Mapping
}
RoleGroup newRoles = new SimpleRoleGroup(SecurityConstants.ROLES_IDENTIFIER);
RoleGroup assignedRoles = (SimpleRoleGroup)contextMap.get(SecurityConstants.ROLES_IDENTIFIER);
if(assignedRoles != null){
for (Role r: assignedRoles.getRoles()) {
boolean mappedRoleIncluded = false;
for (String mappedRole: roleToRolesMap.keySet()) {
if (roleToRolesMap.get(mappedRole).contains(r.getRoleName())) {
newRoles.addRole(new SimpleRole(mappedRole));
mappedRoleIncluded = true;
}
}
if (!mappedRoleIncluded) {
newRoles.addRole(r);
}
}
}
if(assignedRoles != null){
mappedObject.clearRoles();
mappedObject.addAll(newRoles.getRoles());
}
result.setMappedObject(mappedObject);
}