use of org.apereo.services.persondir.support.CaseInsensitiveNamedPersonImpl in project cas by apereo.
the class CouchbasePersonAttributeDao method getPerson.
@Override
@SneakyThrows
public IPersonAttributes getPerson(final String uid, final IPersonAttributeDaoFilter filter) {
val query = String.format("%s = '%s'", couchbaseProperties.getUsernameAttribute(), uid);
val result = couchbase.select(query);
if (result.rowsAsObject().isEmpty()) {
LOGGER.debug("Couchbase query did not return any results/rows.");
return null;
}
val rows = result.rowsAsObject();
val attributes = new LinkedHashMap<String, Object>(rows.stream().filter(row -> row.containsKey(couchbase.getBucket())).map(row -> {
val document = row.getObject(couchbase.getBucket());
val results = CouchbaseClientFactory.collectAttributesFromEntity(document, s -> true);
return results.entrySet();
}).flatMap(Collection::stream).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
return new CaseInsensitiveNamedPersonImpl(uid, stuffAttributesIntoList(attributes));
}
use of org.apereo.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;
}
use of org.apereo.services.persondir.support.CaseInsensitiveNamedPersonImpl in project cas by apereo.
the class CouchbasePersonAttributeDao method getPerson.
@Override
@SneakyThrows
public IPersonAttributes getPerson(final String uid) {
final N1qlQueryResult result = couchbase.query(couchbaseProperties.getUsernameAttribute(), uid);
final Map<String, ?> attributes;
if (result.allRows().isEmpty()) {
LOGGER.debug("Couchbase query did not return any results/rows.");
attributes = new LinkedHashMap<>();
} else {
attributes = result.allRows().stream().filter(row -> row.value().containsKey(couchbase.getBucket().name())).filter(row -> {
final JsonObject value = (JsonObject) row.value().get(couchbase.getBucket().name());
return value.containsKey(couchbaseProperties.getUsernameAttribute());
}).map(row -> (JsonObject) row.value().get(couchbase.getBucket().name())).map(entity -> couchbase.collectAttributesFromEntity(entity, s -> !s.equals(couchbaseProperties.getUsernameAttribute())).entrySet()).flatMap(Collection::stream).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
return new CaseInsensitiveNamedPersonImpl(uid, stuffAttributesIntoList(attributes));
}
use of org.apereo.services.persondir.support.CaseInsensitiveNamedPersonImpl in project cas by apereo.
the class OktaPersonAttributeDao method getPerson.
@Override
@SuppressWarnings("JavaUtilDate")
public IPersonAttributes getPerson(final String uid, final IPersonAttributeDaoFilter filter) {
val attributes = new HashMap<String, Object>();
val user = oktaClient.getUser(uid);
FunctionUtils.doIfNotNull(user.getActivated(), attribute -> attributes.put("oktaUserActivatedDate", user.getActivated().getTime()));
FunctionUtils.doIfNotNull(user.getCreated(), attribute -> attributes.put("oktaUserCreatedDate", user.getCreated().getTime()));
FunctionUtils.doIfNotNull(user.getLastLogin(), attribute -> attributes.put("oktaUserLastLoginDate", user.getLastLogin().getTime()));
FunctionUtils.doIfNotNull(user.getLastUpdated(), attribute -> attributes.put("oktaUserLastUpdatedDate", user.getLastUpdated().getTime()));
FunctionUtils.doIfNotNull(user.getPasswordChanged(), attribute -> attributes.put("oktaUserPasswordChangedDate", user.getPasswordChanged().getTime()));
FunctionUtils.doIfNotNull(user.getId(), attribute -> attributes.put("oktaUserId", attribute));
FunctionUtils.doIfNotNull(user.getStatus(), attribute -> attributes.put("oktaUserStatus", attribute.toString()));
FunctionUtils.doIfNotNull(user.getType(), attribute -> attributes.put("oktaUserType", attribute));
val profile = user.getProfile();
FunctionUtils.doIfNotNull(profile.getCity(), attribute -> attributes.put("oktaCity", attribute));
FunctionUtils.doIfNotNull(profile.getCostCenter(), attribute -> attributes.put("oktaCostCenter", attribute));
FunctionUtils.doIfNotNull(profile.getCountryCode(), attribute -> attributes.put("oktaCountryCode", attribute));
FunctionUtils.doIfNotNull(profile.getDepartment(), attribute -> attributes.put("oktaDepartment", attribute));
FunctionUtils.doIfNotNull(profile.getDisplayName(), attribute -> attributes.put("oktaDisplayName", attribute));
FunctionUtils.doIfNotNull(profile.getDivision(), attribute -> attributes.put("oktaDivision", attribute));
FunctionUtils.doIfNotNull(profile.getEmail(), attribute -> attributes.put("oktaEmail", attribute));
FunctionUtils.doIfNotNull(profile.getEmployeeNumber(), attribute -> attributes.put("oktaEmployeeNumber", attribute));
FunctionUtils.doIfNotNull(profile.getFirstName(), attribute -> attributes.put("oktaFirstName", attribute));
FunctionUtils.doIfNotNull(profile.getHonorificPrefix(), attribute -> attributes.put("oktaPrefix", attribute));
FunctionUtils.doIfNotNull(profile.getHonorificSuffix(), attribute -> attributes.put("oktaSuffix", attribute));
FunctionUtils.doIfNotNull(profile.getLastName(), attribute -> attributes.put("oktaLastName", attribute));
FunctionUtils.doIfNotNull(profile.getLocale(), attribute -> attributes.put("oktaLocale", attribute));
FunctionUtils.doIfNotNull(profile.getManager(), attribute -> attributes.put("oktaManager", attribute));
FunctionUtils.doIfNotNull(profile.getManagerId(), attribute -> attributes.put("oktaManagerId", attribute));
FunctionUtils.doIfNotNull(profile.getMiddleName(), attribute -> attributes.put("oktaMiddleName", attribute));
FunctionUtils.doIfNotNull(profile.getMobilePhone(), attribute -> attributes.put("oktaMobilePhone", attribute));
FunctionUtils.doIfNotNull(profile.getNickName(), attribute -> attributes.put("oktaNickName", attribute));
FunctionUtils.doIfNotNull(profile.getOrganization(), attribute -> attributes.put("oktaOrganization", attribute));
FunctionUtils.doIfNotNull(profile.getPostalAddress(), attribute -> attributes.put("oktaPostalAddress", attribute));
FunctionUtils.doIfNotNull(profile.getPreferredLanguage(), attribute -> attributes.put("oktaPreferredLanguage", attribute));
FunctionUtils.doIfNotNull(profile.getPrimaryPhone(), attribute -> attributes.put("oktaPrimaryPhone", attribute));
FunctionUtils.doIfNotNull(profile.getSecondEmail(), attribute -> attributes.put("oktaSecondEmail", attribute));
FunctionUtils.doIfNotNull(profile.getState(), attribute -> attributes.put("oktaState", attribute));
FunctionUtils.doIfNotNull(profile.getStreetAddress(), attribute -> attributes.put("oktaStreetAddress", attribute));
FunctionUtils.doIfNotNull(profile.getTimezone(), attribute -> attributes.put("oktaTimezone", attribute));
FunctionUtils.doIfNotNull(profile.getTitle(), attribute -> attributes.put("oktaTitle", attribute));
FunctionUtils.doIfNotNull(profile.getLogin(), attribute -> attributes.put("oktaLogin", attribute));
return new CaseInsensitiveNamedPersonImpl(uid, stuffAttributesIntoList(attributes));
}
Aggregations