use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class UserService method getUsersByAttribute.
public List<User> getUsersByAttribute(String attributeName, Object attributeValue, Boolean multiValued, int limit) {
log.debug("Getting user information from LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
if (StringHelper.isEmpty(attributeName) || (attributeValue == null)) {
return null;
}
Filter filter = Filter.createEqualityFilter(attributeName, attributeValue);
if (multiValued != null) {
filter.multiValued(multiValued);
}
List<User> entries = persistenceEntryManager.findEntries(getPeopleBaseDn(), User.class, filter, limit);
log.debug("Found '{}' entries", entries.size());
return entries;
}
use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class UserService method getUsersWithPersistentJwts.
//
// // this method must be called only if app mode = MEMORY, in ldap case it's anyway persisted in ldap.
// public boolean saveLongLivedToken(String userId, PersistentJwt longLivedToken) {
// log.debug("Saving long-lived access token: userId = {}", userId);
// boolean succeed = false;
//
// User user = getUser(userId);
// if (user != null) {
// int nTokens = 0;
// if (user.getOxAuthPersistentJwt() != null) {
// nTokens = user.getOxAuthPersistentJwt().length;
// }
// nTokens++;
// String[] persistentJwts = new String[nTokens];
// if (user.getOxAuthPersistentJwt() != null) {
// for (int i = 0; i < user.getOxAuthPersistentJwt().length; i++) {
// persistentJwts[i] = user.getOxAuthPersistentJwt()[i];
// }
// }
// persistentJwts[nTokens - 1] = longLivedToken.toString();
//
// user.setOxAuthPersistentJwt(persistentJwts);
// ldapEntryManager.merge(user);
// succeed = true;
// }
//
// return succeed;
// }
public List<User> getUsersWithPersistentJwts() {
String baseDN = getPeopleBaseDn();
Filter filter = Filter.createPresenceFilter("oxAuthPersistentJWT");
return persistenceEntryManager.findEntries(baseDN, User.class, filter);
}
use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class RegistrationService method getRegisterRequestMessageByRequestId.
public RegisterRequestMessageLdap getRegisterRequestMessageByRequestId(String requestId) {
String baseDn = getDnForRegisterRequestMessage(null);
Filter requestIdFilter = Filter.createEqualityFilter("oxRequestId", requestId);
List<RegisterRequestMessageLdap> registerRequestMessagesLdap = ldapEntryManager.findEntries(baseDn, RegisterRequestMessageLdap.class, requestIdFilter);
if ((registerRequestMessagesLdap == null) || registerRequestMessagesLdap.isEmpty()) {
return null;
}
return registerRequestMessagesLdap.get(0);
}
use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class UmaScopeService method createAnyFilterByIds.
private Filter createAnyFilterByIds(List<String> scopeIds) {
if (scopeIds != null && !scopeIds.isEmpty()) {
List<Filter> filters = new ArrayList<Filter>();
for (String url : scopeIds) {
Filter filter = Filter.createEqualityFilter("oxId", url);
filters.add(filter);
}
Filter filter = Filter.createORFilter(filters.toArray(new Filter[0]));
log.trace("Uma scope ids: " + scopeIds + ", ldapFilter: " + filter);
return filter;
}
return null;
}
use of org.gluu.search.filter.Filter in project oxAuth by GluuFederation.
the class UmaPctService method getByCode.
public UmaPCT getByCode(String pctCode) {
try {
final Filter filter = Filter.createEqualityFilter("tknCde", pctCode);
final List<UmaPCT> entries = ldapEntryManager.findEntries(branchBaseDn(), UmaPCT.class, filter);
if (entries != null && !entries.isEmpty()) {
return entries.get(0);
} else {
log.error("Failed to find PCT by code: " + pctCode);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
Aggregations