use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class ScopeService method handleInternalScopes.
private List<String> handleInternalScopes(List<String> p_scopeUrls, List<String> result) {
List<String> notProcessedScopeUrls = new ArrayList<String>(p_scopeUrls);
try {
final Filter filter = Filter.create(String.format("&(oxType=%s)", InternalExternal.INTERNAL.getValue()));
final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
if (entries != null && !entries.isEmpty()) {
for (String scopeUrl : p_scopeUrls) {
for (ScopeDescription scopeDescription : entries) {
final String internalScopeUrl = getInternalScopeUrl(scopeDescription);
if (internalScopeUrl.equals(scopeUrl) && !result.contains(internalScopeUrl)) {
result.add(scopeDescription.getDn());
notProcessedScopeUrls.remove(scopeUrl);
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return notProcessedScopeUrls;
}
use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class ScopeService method getScopesByUrls.
public List<ScopeDescription> getScopesByUrls(List<String> p_scopeUrls) {
List<ScopeDescription> scopes = new ArrayList<ScopeDescription>();
try {
// external scopes
Filter filter = createAnyFilterByUrls(p_scopeUrls);
if (filter != null) {
final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
if (entries != null) {
scopes.addAll(entries);
}
}
// internal scopes
filter = Filter.create(String.format("&(oxType=%s)", InternalExternal.INTERNAL.getValue()));
final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
if (entries != null && !entries.isEmpty()) {
for (String scopeUrl : p_scopeUrls) {
for (ScopeDescription scopeDescription : entries) {
final String internalScopeUrl = getInternalScopeUrl(scopeDescription);
if (internalScopeUrl.equals(scopeUrl) && !scopes.contains(internalScopeUrl)) {
scopes.add(scopeDescription);
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return scopes;
}
use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class UserService method getUser.
public User getUser(String userId, String... returnAttributes) {
log.debug("Getting user information from LDAP: userId = {}", userId);
if (StringHelper.isEmpty(userId)) {
return null;
}
Filter userUidFilter = Filter.createEqualityFilter("uid", userId);
List<User> entries = ldapEntryManager.findEntries(staticConfiguration.getBaseDn().getPeople(), User.class, returnAttributes, userUidFilter);
log.debug("Found {} entries for user id = {}", entries.size(), userId);
if (entries.size() > 0) {
return entries.get(0);
} else {
return null;
}
}
use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class UserService method getUsersWithPersistentJwts.
public List<User> getUsersWithPersistentJwts() {
String baseDN = staticConfiguration.getBaseDn().getPeople();
Filter filter = Filter.createPresenceFilter("oxAuthPersistentJWT");
return ldapEntryManager.findEntries(baseDN, User.class, filter);
}
use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class ResourceSetPermissionManager method getResourceSetPermissionByTicket.
@Override
public ResourceSetPermission getResourceSetPermissionByTicket(String p_ticket) {
try {
final String baseDn = staticConfiguration.getBaseDn().getClients();
final Filter filter = Filter.create(String.format("&(oxTicket=%s)", p_ticket));
final List<ResourceSetPermission> entries = ldapEntryManager.findEntries(baseDn, ResourceSetPermission.class, filter);
if (entries != null && !entries.isEmpty()) {
return entries.get(0);
}
} catch (Exception e) {
log.trace(e.getMessage(), e);
}
return null;
}
Aggregations