Get the set of all user attribute names defined in the portal for which the specified
principal has the attribute viewing permission.

@param principal
@return
501982
protected Set<String> getPermittedAttributes(final IAuthorizationPrincipal principal) {
        final Set<String> attributeNames = personAttributeDao.getPossibleUserAttributeNames();
        return getPermittedAttributes(principal, attributeNames);
    }
960748
public List<UserAttributeType<PortletAppType<T>>> getAllUserAttribute()
   {
      List<UserAttributeType<PortletAppType<T>>> list = new ArrayList<UserAttributeType<PortletAppType<T>>>();
      List<Node> nodeList = childNode.get("user-attribute");
      for(Node node: nodeList)
      {
         UserAttributeType<PortletAppType<T>>  type = new UserAttributeTypeImpl<PortletAppType<T>>(this, "user-attribute", childNode, node);
         list.add(type);
      }
      return list;
   }
578324
public Principal principal() {
        if (_subject == null)
            return null;
        Set<Principal> princs = _subject.getPrincipals();
        if (princs.size() == 0)
            return null;
        return (Principal) (princs.toArray()[0]);
    }
68687
private Map getUsers() throws NamingException {

        String filter = "(" + roleNameRDN + "=*)";

        HashMap users = new HashMap();

        NamingEnumeration results = this.search(roleBase, filter, new String[]{roleMemberRDN});
        while (results != null && results.hasMore()) {

            SearchResult roleResult = (SearchResult) results.next();

            String roleResultName = roleResult.getName();
            if ("".equals(roleResultName)) {
                continue;
            }

            String roleResultValue = (roleResultName.split("="))[1];

            Attributes roleAttrs = roleResult.getAttributes();

            Attribute roleAttr = roleAttrs.get(roleMemberRDN);
            NamingEnumeration valueEnum = roleAttr.getAll();
            while (valueEnum != null && valueEnum.hasMore()) {
                String value = (String) valueEnum.next();

                String name;
                if (value.endsWith("," + userBase)) {
                    name = value.substring(0, value.length() - userBase.length() - 1);
                    name = name.split("=")[1];
                } else {
                    log.debug("found unrecognized DN: " + value);
                    continue;
                }

                if (users.containsKey(name)) {
                    HashSet roles = (HashSet) users.get(name);
                    roles.add(roleResultValue);
                } else {
                    HashSet roles = new HashSet();
                    roles.add(roleResultValue);
                    users.put(name, roles);
                }
            }
        }
        return users;

    }
1199949
@ReadOperation
    public Collection<Map<String, Object>> consentDecisions(@Selector final String principal) {
        val result = new HashSet<Map<String, Object>>();
        LOGGER.debug("Fetching consent decisions for principal [{}]", principal);
        val consentDecisions = this.consentRepository.findConsentDecisions(principal);
        LOGGER.debug("Resolved consent decisions for principal [{}]: [{}]", principal, consentDecisions);

        consentDecisions.forEach(d -> {
            val map = new HashMap<String, Object>();
            map.put("decision", d);
            map.put("attributes", this.consentEngine.resolveConsentableAttributesFrom(d));
            result.add(map);
        });
        return result;
    }
958769
@Override
    public IAuthorizationPrincipal getPrincipal(IPermission permission)
            throws AuthorizationException {
        String principalString = permission.getPrincipal();
        int idx = principalString.indexOf(PRINCIPAL_SEPARATOR);
        Integer typeId = Integer.valueOf(principalString.substring(0, idx));
        Class type = EntityTypesLocator.getEntityTypes().getEntityTypeFromID(typeId);
        String key = principalString.substring(idx + 1);
        return newPrincipal(key, type);
    }
685666
private void initPermissionsForPrincipal(JsonEntityBean principal) {
        permissions.add(
                principal.getTypeAndIdHash()
                        + "_"
                        + PortletAdministrationHelper.PortletPermissionsOnForm.BROWSE
                                .getActivity());
        permissions.add(
                principal.getTypeAndIdHash()
                        + "_"
                        + PortletAdministrationHelper.PortletPermissionsOnForm.SUBSCRIBE
                                .getActivity());
    }
655607
public boolean hasPrivileges( SecurityContext sc,
                                  Privilege[] privileges ) {
        for (AccessControlEntryImpl ace : principals.values()) {
            // check access list for everyone
            if (ace.getPrincipal().getName().equals(SimplePrincipal.EVERYONE.getName())) {
                if (ace.hasPrivileges(privileges)) {
                    return true;
                }
            }

            // check user principal
            if (ace.getPrincipal().getName().equals(username(sc.getUserName()))) {
                if (ace.hasPrivileges(privileges)) {
                    return true;
                }
            }

            // check group/role principal
            if (sc.hasRole(ace.getPrincipal().getName())) {
                if (ace.hasPrivileges(privileges)) {
                    return true;
                }
            }
        }
        return false;
    }
321614
public java.security.Principal getUserPrincipal()
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        IWebAppSecurityCollaborator webAppSec=null;
        if (getDispatchContext()!=null && getDispatchContext().getWebApp() != null) {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator(getDispatchContext().getWebApp());
        } else {
            webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator();           
        } 
            
        if (webAppSec != null) {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "calling getUserPrincipal on " + webAppSec.getClass().getName());
            }
            return webAppSec.getUserPrincipal();
        } else {
            if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)){  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"getUserPrincipal", "returning null");
            }
            // No IWebAppSecurityCollaborator means no security, so no Principal 
            return null;
        }
    }
488593
@Override
    public Set<String> getDisplayAttributes(ExternalContext externalContext) {
        final PortletRequest portletRequest = (PortletRequest) externalContext.getNativeRequest();
        final PortletPreferences preferences = portletRequest.getPreferences();

        final Set<String> displayAttributes;
        final String[] configuredAttributes =
                preferences.getValues(PERSON_LOOKUP_PERSON_DETAILS_DETAILS_ATTRIBUTES, null);
        final String[] excludedAttributes =
                preferences.getValues(
                        PERSON_LOOKUP_PERSON_DETAILS_DETAILS_ATTRIBUTES_EXCLUDES, null);

        // If attributes are configured in portlet prefs use those the user has
        if (configuredAttributes != null) {
            displayAttributes = new LinkedHashSet<>();
            displayAttributes.addAll(Arrays.asList(configuredAttributes));
        }
        // Otherwise provide all available attributes from the IPersonAttributes
        else {
            displayAttributes = new TreeSet<>(personAttributeDao.getPossibleUserAttributeNames());
        }

        // Remove any excluded attributes
        if (excludedAttributes != null) {
            for (final String excludedAttribute : excludedAttributes) {
                displayAttributes.remove(excludedAttribute);
            }
        }

        return displayAttributes;
    }
1326576
@Override
    public Node getPrincipal() {
        if (principal == null) {
            principal = new LdapUser();
            LdapUser p = (LdapUser) principal;
            p.setDn(Configuration.getProperty(instanceName + ".principal").trim());
            p.setUid(getUidForDN(p.getDn()));
        }
        return principal;
    }
112471
private IPermission[] primGetPermissionsForPrincipal(IAuthorizationPrincipal principal)
            throws AuthorizationException {
        if (!this.cachePermissions) {
            return getUncachedPermissionsForPrincipal(principal, null, null, null);
        }

        IPermissionSet ps = null;
        // Check the caching service for the Permissions first.
        ps = cacheGet(principal);

        if (ps == null)
            synchronized (principal) {
                ps = cacheGet(principal);
                if (ps == null) {
                    IPermission[] permissions =
                            getUncachedPermissionsForPrincipal(principal, null, null, null);
                    ps = new PermissionSetImpl(permissions, principal);
                    cacheAdd(ps);
                }
            } // end synchronized
        return ps.getPermissions();
    }
1131350
protected boolean enoughAttributesAvailableToProcess(final String principal, final Map<String, Object> principalAttributes) {
        if (!enoughRequiredAttributesAvailableToProcess(principalAttributes, this.requiredAttributes)) {
            return false;
        }
        if (principalAttributes.size() < this.rejectedAttributes.size()) {
            LOGGER.debug("The size of the principal attributes that are [{}] does not match defined rejected attributes, "
                + "which means the principal is not carrying enough data to grant authorization", principalAttributes);
            return false;
        }
        return true;
    }
653697
@JsonIgnore
    @Override
    public Set<String> getPossibleUserAttributeNames(final IPersonAttributeDaoFilter filter) {
        return targetPersonAttributeDao.getPossibleUserAttributeNames(filter);
    }
277339
public static SimplePrincipalProvider getSimplePrincipalByName(Collection<PrincipalProvider<?>> principalProviders,
            String principalName) {
        for (SimplePrincipalProvider principal : getSimplePrincipals(principalProviders)) {
            if (principal.getName().equals(principalName)) {
                return principal;
            }
        }
        return null;
    }
988149
@Override
    public Set<Principal> getPrincipals(final HttpServletRequest request) {
        LOGGER.debug("Checking for principals using {}", ContainerRolesPrincipalProvider.class.getSimpleName());

        if (request == null) {
            LOGGER.debug("Servlet request was null");

            return emptySet();
        }

        if (roleNames == null) {
            LOGGER.debug("Role names Set was never initialized");

            return emptySet();
        }

        final Iterator<String> iterator = roleNames.iterator();
        final Set<Principal> principals = new HashSet<>();

        while (iterator.hasNext()) {
            final String role = iterator.next().trim();

            if (request.isUserInRole(role)) {
                LOGGER.debug("Adding container role as principal: {}", role);

                principals.add(new ContainerRolesPrincipal(role));
            }
        }

        return principals;
    }
1237623
public AccessLevel getAccessForPrincipal(String user) {
        AccessLevel result = AccessLevel.NOTHING;
        for (Access item : getAccessList()) {
            if (item.isNegativeRule()) {
                if (!item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            } else {
                if (item.getPrincipal().contains(user)) {
                    result = item.getLevel();
                }
            }
        }
        return result;
    }