Examples of RoleGroup


Examples of org.jboss.security.identity.RoleGroup

    @return The Set<Principal> for the application domain roles that the
    principal has been assigned.
    */
   public Set<Principal> getUserRoles(Principal principal)
   {
      RoleGroup userRoles = getCurrentRoles(principal);
      return this.getRolesAsSet(userRoles);
  
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

      if(callerRunAs != null)
      {
         callerPrincipal = new SimplePrincipal(callerRunAs.getName());
      }
     
      RoleGroup roles = this.getCurrentRoles(callerPrincipal, authenticatedSubject, sc);
      if(roles == null)
         roles = new SimpleRoleGroup(SecurityConstants.ROLES_IDENTIFIER);
      return roles;
  
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

     
      Group subjectRoles = getGroupFromSubject(subject);
     
      boolean emptyContextRoles = false;
     
      RoleGroup userRoles = sc.getUtil().getRoles();
      //Group userRoles = (Group)sc.getData().get(ROLES_IDENTIFIER);
      if(userRoles == null || "true".equalsIgnoreCase(SubjectActions.getRefreshSecurityContextRoles()))
         emptyContextRoles = true;
      userRoles = copyGroups(userRoles, subjectRoles);
     
      /**
       * Update the roles in the SecurityContext and
       * allow mapping rules be applied only if the SC roles
       * and the subject roles are not the same
       */
      if(subjectRoles != userRoles || emptyContextRoles)
      {
         MappingManager mm = sc.getMappingManager();
         MappingContext<RoleGroup> mc = mm.getMappingContext(RoleGroup.class);
       
         RoleGroup mappedUserRoles = userRoles;
         if(mc != null && mc.hasModules())
         {
            Map<String,Object> contextMap = new HashMap<String,Object>();
            contextMap.put(SecurityConstants.ROLES_IDENTIFIER, userRoles);
            if(principal != null)
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

                MappingContext<RoleGroup> mc = mappingManager.getMappingContext(MappingType.ROLE.name());
                if (mc != null && mc.hasModules()) {
                    SecurityRolesAssociation.setSecurityRoles(principalVersusRolesMap);
                }
            }
            RoleGroup roles = authorizationManager.getSubjectRoles(subject, scb);
            List<Role> rolesAsList = roles.getRoles();
            List<String> rolesAsStringList = new ArrayList<String>();
            for (Role role : rolesAsList) {
                rolesAsStringList.add(role.getRoleName());
            }
            if (mappingManager != null) {
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

                    MappingContext<RoleGroup> mc = mappingManager.getMappingContext(MappingType.ROLE.name());
                    if (mc != null && mc.hasModules()) {
                        SecurityRolesAssociation.setSecurityRoles(principalVersusRolesMap);
                    }
                }
                RoleGroup roles = authorizationManager.getSubjectRoles(subject, scb);
                List<Role> rolesAsList = roles.getRoles();
                List<String> rolesAsStringList = new ArrayList<String>();
                for (Role role : rolesAsList) {
                    rolesAsStringList.add(role.getRoleName());
                }
                if (mappingManager != null) {
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

                    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()));
                        }
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

            Set<Object> credentials = subject.getPrivateCredentials();
            Object credential = !credentials.isEmpty() ? credentials.iterator().next() : null;
            org.jboss.security.SecurityContext new_jb_securityContext = SecurityContextFactory.createSecurityContext(securityDomain);
            SecurityContextAssociation.setSecurityContext(new_jb_securityContext);
            if (rolesGroup != null) {
                RoleGroup roleGroup = new SimpleRoleGroup(rolesGroup);
                Identity identity = CredentialIdentityFactory.createIdentity(principal, credential, roleGroup);
                new_jb_securityContext.getUtil().createSubjectInfo(identity, subject);
                new_jb_securityContext.getSubjectInfo().setRoles(roleGroup);
            } else {
                Identity identity = CredentialIdentityFactory.createIdentity(principal, credential);
                new_jb_securityContext.getUtil().createSubjectInfo(identity, subject);
            }
            if (new_jb_runAs != null) {
                new_jb_securityContext.setOutgoingRunAs(new_jb_runAs);
            }
            return new JBossContainerContext(null, null, null);
        } else {
            RoleGroup old_jb_roleGroup = old_jb_securityContext.getSubjectInfo().getRoles();
            if (rolesGroup != null) {
                old_jb_securityContext.getSubjectInfo().setRoles(new SimpleRoleGroup(rolesGroup));
            }
            RunAs old_jb_runAs = old_jb_securityContext.getOutgoingRunAs();
            if (new_jb_runAs != null) {
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

         }
      }
      else
      {
         //Dealing with another roleGroup
         RoleGroup anotherRG = (RoleGroup) anotherRole;
         List<Role> anotherRoles = anotherRG.getRoles();
         for(Role r: anotherRoles)
         {
            //if any of the roles are not there, no point checking further
            if(!this.containsAll(r))
               return false;
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

        final SecurityContext securityContext = doPrivileged(securityContext());
        if (securityContext == null) {
            return false;
        }

        RoleGroup roleGroup = null;

        RunAs runAs = securityContext.getIncomingRunAs();
        if (runAs != null && runAs instanceof RunAsIdentity) {
            RunAsIdentity runAsIdentity = (RunAsIdentity) runAs;
            roleGroup = runAsIdentity.getRunAsRolesAsRoleGroup();
        } else {
            AuthorizationManager am = securityContext.getAuthorizationManager();
            SecurityContextCallbackHandler scb = new SecurityContextCallbackHandler(securityContext);

            roleGroup = am.getSubjectRoles(securityContext.getSubjectInfo().getAuthenticatedSubject(), scb);
        }

        List<Role> roles = roleGroup.getRoles();

        // TODO - Review most performant way.
        Set<String> requiredRoles = new HashSet<String>();
        for (String current : roleNames) {
            requiredRoles.add(current);
View Full Code Here

Examples of org.jboss.security.identity.RoleGroup

        if (isValid) {
            SecurityContext sc = SecurityActions.createSecurityContext(authenticationManager.getSecurityDomain());
            sc.getUtil().createSubjectInfo(userPrincipal, credentials, subject);
            SecurityActions.setSecurityContextOnAssociation(sc);
            SecurityContextCallbackHandler scb = new SecurityContextCallbackHandler(sc);
            RoleGroup roles = authorizationManager.getSubjectRoles(subject, scb);
            List<Role> rolesAsList = roles.getRoles();
            List<String> rolesAsStringList = new ArrayList<String>();
            for (Role role : rolesAsList) {
                rolesAsStringList.add(role.getRoleName());
            }
            return new GenericPrincipal(this, username, credentials, rolesAsStringList);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.