Search in sources :

Example 1 with IUsernameAttributeProvider

use of org.jasig.services.persondir.support.IUsernameAttributeProvider in project uPortal by Jasig.

the class ImpersonationStatusPersonAttributeDao method getPeopleWithMultivaluedAttributes.

@Override
public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(Map<String, List<Object>> query) {
    // default (per spec?)
    Set<IPersonAttributes> rslt = null;
    if (this.logger.isDebugEnabled()) {
        this.logger.debug("invoking getPeopleWithMultivaluedAttributes(" + query + ")");
    }
    final IUsernameAttributeProvider usernameAttributeProvider = super.getUsernameAttributeProvider();
    final String queryUid = usernameAttributeProvider.getUsernameFromQuery(query);
    if (queryUid == null) {
        this.logger.debug("No username attribute found in query, returning null");
    } else {
        final HttpServletRequest req = portalRequestUtils.getCurrentPortalRequest();
        final IPerson person = personManager.getPerson(req);
        final String currentUid = person.getUserName();
        if (currentUid.equals(queryUid)) {
            final String value = identitySwapperManager.isImpersonating(req) ? "true" : "false";
            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Gathering attributes for the current user [" + currentUid + "];  impersonating=" + value);
            }
            final List<Object> values = Collections.singletonList((Object) value);
            final Map<String, List<Object>> attrs = Collections.singletonMap(IMPERSONATING_ATTRIBUTE_NAME, values);
            final IPersonAttributes ipa = new CaseInsensitiveNamedPersonImpl(currentUid, attrs);
            rslt = Collections.singleton(ipa);
        }
    }
    return rslt;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IUsernameAttributeProvider(org.jasig.services.persondir.support.IUsernameAttributeProvider) IPersonAttributes(org.jasig.services.persondir.IPersonAttributes) List(java.util.List) CaseInsensitiveNamedPersonImpl(org.jasig.services.persondir.support.CaseInsensitiveNamedPersonImpl)

Example 2 with IUsernameAttributeProvider

use of org.jasig.services.persondir.support.IUsernameAttributeProvider in project uPortal by Jasig.

the class LocalAccountPersonAttributeDao method getPeopleWithMultivaluedAttributes.

/* (non-Javadoc)
     * @see org.jasig.services.persondir.IPersonAttributeDao#getPeopleWithMultivaluedAttributes(java.util.Map)
     */
public final Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(Map<String, List<Object>> query) {
    Validate.notNull(query, "query may not be null.");
    //Generate the query to pass to the subclass
    final LocalAccountQuery queryBuilder = this.generateQuery(query);
    if (queryBuilder == null) {
        this.logger.debug("No queryBuilder was generated for query " + query + ", null will be returned");
        return null;
    }
    //Get the username from the query, if specified
    final IUsernameAttributeProvider usernameAttributeProvider = this.getUsernameAttributeProvider();
    //Execute the query in the subclass
    final List<ILocalAccountPerson> unmappedPeople = localAccountDao.getPeople(queryBuilder);
    if (unmappedPeople == null) {
        return null;
    }
    //Map the attributes of the found people according to resultAttributeMapping if it is set
    final Set<IPersonAttributes> mappedPeople = new LinkedHashSet<IPersonAttributes>();
    for (final ILocalAccountPerson unmappedPerson : unmappedPeople) {
        final IPersonAttributes mappedPerson = this.mapPersonAttributes(unmappedPerson);
        mappedPeople.add(mappedPerson);
    }
    return Collections.unmodifiableSet(mappedPeople);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IUsernameAttributeProvider(org.jasig.services.persondir.support.IUsernameAttributeProvider) IPersonAttributes(org.jasig.services.persondir.IPersonAttributes)

Aggregations

IPersonAttributes (org.jasig.services.persondir.IPersonAttributes)2 IUsernameAttributeProvider (org.jasig.services.persondir.support.IUsernameAttributeProvider)2 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 IPerson (org.apereo.portal.security.IPerson)1 CaseInsensitiveNamedPersonImpl (org.jasig.services.persondir.support.CaseInsensitiveNamedPersonImpl)1