Search in sources :

Example 1 with CaseInsensitiveNamedPersonImpl

use of org.jasig.services.persondir.support.CaseInsensitiveNamedPersonImpl 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)

Aggregations

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