本文整理汇总了Java中org.gluu.persist.model.SearchScope类的典型用法代码示例。如果您正苦于以下问题:Java SearchScope类的具体用法?Java SearchScope怎么用?Java SearchScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SearchScope类属于org.gluu.persist.model包,在下文中一共展示了SearchScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLDIF
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
@Override
public List<String[]> getLDIF(String dn, String[] attributes) {
SearchResult searchResult;
try {
searchResult = this.ldapOperationService.search(dn, toLdapFilter(Filter.create("objectclass=*")), toLdapSearchScope(SearchScope.BASE), -1, 0, null, attributes);
if (!ResultCode.SUCCESS.equals(searchResult.getResultCode())) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s", dn));
}
} catch (Exception ex) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s, filter: %s", dn, null), ex);
}
List<String[]> result = new ArrayList<String[]>();
if (searchResult.getEntryCount() == 0) {
return result;
}
for (SearchResultEntry searchResultEntry : searchResult.getSearchEntries()) {
result.add(searchResultEntry.toLDIF());
}
return result;
}
示例2: updateTargetEntriesViaVDS
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
private List<String> updateTargetEntriesViaVDS(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection targetServerConnection, Set<String> changedInums) {
List<String> result = new ArrayList<String>();
LdapEntryManager targetLdapEntryManager = targetServerConnection.getLdapEntryManager();
Filter filter = cacheRefreshService.createObjectClassPresenceFilter();
for (String changedInum : changedInums) {
String baseDn = "action=synchronizecache," + personService.getDnForPerson(changedInum);
try {
targetLdapEntryManager.findEntries(baseDn, GluuDummyEntry.class, filter, SearchScope.SUB, null, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
result.add(changedInum);
log.debug("Updated entry with inum {}", changedInum);
} catch (BaseMappingException ex) {
log.error("Failed to update entry with inum '{}' using baseDN {}", changedInum, baseDn, ex);
}
}
return result;
}
示例3: findEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> List<T> findEntries(Object entry, int sizeLimit) {
if (entry == null) {
throw new MappingException("Entry to find is null");
}
// Check entry class
Class<T> entryClass = (Class<T>) entry.getClass();
checkEntryClass(entryClass, false);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Object dnValue = getDNValue(entry, entryClass);
List<AttributeData> attributes = getAttributesListForPersist(entry, propertiesAnnotations);
Filter searchFilter = createFilterByEntry(entry, entryClass, attributes);
return findEntries(dnValue.toString(), entryClass, searchFilter, SearchScope.SUB, null, sizeLimit, DEFAULT_PAGINATION_SIZE);
}
示例4: cleanup
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public void cleanup(final Date now) {
LdapBatchOperation<UmaPermission> batchService = new LdapBatchOperation<UmaPermission>(ldapEntryManager) {
@Override
public List<UmaPermission> getChunkOrNull(int chunkSize) {
return ldapEntryManager.findEntries(staticConfiguration.getBaseDn().getClients(), UmaPermission.class, getFilter(), SearchScope.SUB, null, this, 0, chunkSize, chunkSize);
}
@Override
public void performAction(List<UmaPermission> entries) {
for (UmaPermission p : entries) {
try {
ldapEntryManager.remove(p);
} catch (Exception e) {
log.error("Failed to remove entry", e);
}
}
}
private Filter getFilter() {
return Filter.createLessOrEqualFilter("oxAuthExpiration", StaticUtils.encodeGeneralizedTime(now));
}
};
batchService.iterateAllByChunks(CleanerTimer.BATCH_SIZE);
}
示例5: cleanup
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public void cleanup(final Date now) {
prepareBranch();
LdapBatchOperation<UmaPCT> batchService = new LdapBatchOperation<UmaPCT>(ldapEntryManager) {
@Override
public List<UmaPCT> getChunkOrNull(int chunkSize) {
return ldapEntryManager.findEntries(branchBaseDn(), UmaPCT.class, getFilter(), SearchScope.SUB, null, this, 0, chunkSize, chunkSize);
}
@Override
public void performAction(List<UmaPCT> entries) {
for (UmaPCT p : entries) {
try {
remove(p);
} catch (Exception e) {
log.error("Failed to remove entry", e);
}
}
}
private Filter getFilter() {
return Filter.createLessOrEqualFilter("oxAuthExpiration", StaticUtils.encodeGeneralizedTime(now));
}
};
batchService.iterateAllByChunks(CleanerTimer.BATCH_SIZE);
}
示例6: cleanup
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public void cleanup(final Date now) {
LdapBatchOperation<UmaRPT> rptBatchService = new LdapBatchOperation<UmaRPT>(ldapEntryManager) {
@Override
public List<UmaRPT> getChunkOrNull(int chunkSize) {
return ldapEntryManager.findEntries(staticConfiguration.getBaseDn().getClients(), UmaRPT.class, getFilter(), SearchScope.SUB, null, this, 0, chunkSize, chunkSize);
}
@Override
public void performAction(List<UmaRPT> entries) {
for (UmaRPT p : entries) {
try {
ldapEntryManager.remove(p);
} catch (Exception e) {
log.error("Failed to remove entry", e);
}
}
}
private Filter getFilter() {
return Filter.createLessOrEqualFilter("oxAuthExpiration", StaticUtils.encodeGeneralizedTime(now));
}
};
rptBatchService.iterateAllByChunks(CleanerTimer.BATCH_SIZE);
}
示例7: loadInumServerEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
private List<GluuInumMap> loadInumServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection inumDbServerConnection) {
LdapEntryManager inumDbldapEntryManager = inumDbServerConnection.getLdapEntryManager();
String inumbaseDn = inumDbServerConnection.getBaseDns()[0];
Filter filterObjectClass = Filter.createEqualityFilter(OxTrustConstants.objectClass, OxTrustConstants.objectClassInumMap);
Filter filterStatus = Filter.createNOTFilter(Filter.createEqualityFilter(OxTrustConstants.gluuStatus, GluuStatus.INACTIVE.getValue()));
Filter filter = Filter.createANDFilter(filterObjectClass, filterStatus);
return inumDbldapEntryManager.findEntries(inumbaseDn, GluuInumMap.class, filter, SearchScope.SUB, null, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
}
示例8: convertToLdapSearchScope
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public com.unboundid.ldap.sdk.SearchScope convertToLdapSearchScope(SearchScope searchScope) throws SearchScopeException {
if (SearchScope.BASE == searchScope) {
return com.unboundid.ldap.sdk.SearchScope.BASE;
} if (SearchScope.ONE == searchScope) {
return com.unboundid.ldap.sdk.SearchScope.ONE;
} if (SearchScope.SUB == searchScope) {
return com.unboundid.ldap.sdk.SearchScope.SUB;
}
throw new SearchScopeException(String.format("Unknown search scope '%s'", searchScope));
}
示例9: countEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
@Override
public <T> int countEntries(String baseDN, Class<T> entryClass, Filter filter) {
if (StringHelper.isEmptyString(baseDN)) {
throw new MappingException("Base DN to find entries is null");
}
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
String[] ldapReturnAttributes = new String[] { "" }; // Don't load attributes
// Find entries
Filter searchFilter;
if (objectClasses.length > 0) {
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
searchFilter = filter;
}
CountBatchOperation<T> batchOperation = new CountBatchOperation<T>(this);
try {
ldapOperationService.search(baseDN, toLdapFilter(searchFilter), toLdapSearchScope(SearchScope.SUB), batchOperation, 0, 100, 0, null, ldapReturnAttributes);
} catch (Exception ex) {
throw new EntryPersistenceException(String.format("Failed to calucalte count of entries with baseDN: %s, filter: %s", baseDN, searchFilter), ex);
}
return batchOperation.getCountEntries();
}
示例10: getExpiredRequestMessages
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public List<RequestMessageLdap> getExpiredRequestMessages(LdapBatchOperation<RequestMessageLdap> batchOperation, Date expirationDate) {
final String u2fBaseDn = staticConfiguration.getBaseDn().getU2fBase(); // ou=u2f,[email protected]!1111,o=gluu
Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeGeneralizedTime(expirationDate));
List<RequestMessageLdap> requestMessageLdap = ldapEntryManager.findEntries(u2fBaseDn, RequestMessageLdap.class, expirationFilter, SearchScope.SUB, null, batchOperation, 0, CleanerTimer.BATCH_SIZE, CleanerTimer.BATCH_SIZE);
return requestMessageLdap;
}
示例11: getExpiredDeviceRegistrations
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
public List<DeviceRegistration> getExpiredDeviceRegistrations(LdapBatchOperation<DeviceRegistration> batchOperation, Date expirationDate) {
final String u2fBaseDn = getDnForOneStepU2fDevice(null);
Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeGeneralizedTime(expirationDate));
List<DeviceRegistration> deviceRegistrations = ldapEntryManager.findEntries(u2fBaseDn, DeviceRegistration.class, expirationFilter, SearchScope.SUB, null, batchOperation, 0, CleanerTimer.BATCH_SIZE, CleanerTimer.BATCH_SIZE);
return deviceRegistrations;
}
示例12: loadSourceServerEntriesWithoutLimits
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
private List<GluuSimplePerson> loadSourceServerEntriesWithoutLimits(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) {
Filter customFilter = cacheRefreshService.createFilter(cacheRefreshConfiguration.getCustomLdapFilter());
String[] keyAttributes = getCompoundKeyAttributes(cacheRefreshConfiguration);
String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
String[] keyObjectClasses = getCompoundKeyObjectClasses(cacheRefreshConfiguration);
String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
String[] returnAttributes = ArrayHelper.arrayMerge(keyAttributesWithoutValues, sourceAttributes);
Set<String> addedDns = new HashSet<String>();
List<GluuSimplePerson> sourcePersons = new ArrayList<GluuSimplePerson>();
for (LdapServerConnection sourceServerConnection : sourceServerConnections) {
String sourceServerName = sourceServerConnection.getSourceServerName();
LdapEntryManager sourceLdapEntryManager = sourceServerConnection.getLdapEntryManager();
String[] baseDns = sourceServerConnection.getBaseDns();
Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, "", customFilter);
if (log.isTraceEnabled()) {
log.trace("Using next filter to load entris from source server: {}", filter);
}
for (String baseDn : baseDns) {
List<GluuSimplePerson> currentSourcePersons = sourceLdapEntryManager.findEntries(baseDn, GluuSimplePerson.class,
filter, SearchScope.SUB, returnAttributes, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
// Add to result and ignore root entry if needed
for (GluuSimplePerson currentSourcePerson : currentSourcePersons) {
currentSourcePerson.setSourceServerName(sourceServerName);
// if (!StringHelper.equalsIgnoreCase(baseDn,
// currentSourcePerson.getDn())) {
String currentSourcePersonDn = currentSourcePerson.getDn().toLowerCase();
if (!addedDns.contains(currentSourcePersonDn)) {
sourcePersons.add(currentSourcePerson);
addedDns.add(currentSourcePersonDn);
}
// }
}
}
}
return sourcePersons;
}
示例13: loadSourceServerEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
private List<GluuSimplePerson> loadSourceServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) {
Filter customFilter = cacheRefreshService.createFilter(cacheRefreshConfiguration.getCustomLdapFilter());
String[] keyAttributes = getCompoundKeyAttributes(cacheRefreshConfiguration);
String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
String[] keyObjectClasses = getCompoundKeyObjectClasses(cacheRefreshConfiguration);
String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
String[] twoLettersArray = createTwoLettersArray();
String[] returnAttributes = ArrayHelper.arrayMerge(keyAttributesWithoutValues, sourceAttributes);
Set<String> addedDns = new HashSet<String>();
List<GluuSimplePerson> sourcePersons = new ArrayList<GluuSimplePerson>();
for (LdapServerConnection sourceServerConnection : sourceServerConnections) {
String sourceServerName = sourceServerConnection.getSourceServerName();
LdapEntryManager sourceLdapEntryManager = sourceServerConnection.getLdapEntryManager();
String[] baseDns = sourceServerConnection.getBaseDns();
for (String keyAttributeStart : twoLettersArray) {
Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, keyAttributeStart, customFilter);
if (log.isDebugEnabled()) {
log.trace("Using next filter to load entris from source server: {}", filter);
}
for (String baseDn : baseDns) {
List<GluuSimplePerson> currentSourcePersons = sourceLdapEntryManager.findEntries(baseDn, GluuSimplePerson.class,
filter, SearchScope.SUB, returnAttributes, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
// Add to result and ignore root entry if needed
for (GluuSimplePerson currentSourcePerson : currentSourcePersons) {
currentSourcePerson.setSourceServerName(sourceServerName);
// if (!StringHelper.equalsIgnoreCase(baseDn,
// currentSourcePerson.getDn())) {
String currentSourcePersonDn = currentSourcePerson.getDn().toLowerCase();
if (!addedDns.contains(currentSourcePersonDn)) {
sourcePersons.add(currentSourcePerson);
addedDns.add(currentSourcePersonDn);
}
// }
}
}
}
}
return sourcePersons;
}
示例14: loadTargetServerEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
private List<GluuSimplePerson> loadTargetServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapEntryManager targetLdapEntryManager) {
Filter filter = Filter.createEqualityFilter(OxTrustConstants.objectClass, OxTrustConstants.objectClassPerson);
return targetLdapEntryManager.findEntries(personService.getDnForPerson(null), GluuSimplePerson.class, filter, SearchScope.SUB,
TARGET_PERSON_RETURN_ATTRIBUTES, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
}
示例15: findEntries
import org.gluu.persist.model.SearchScope; //导入依赖的package包/类
@Override
public <T> List<T> findEntries(String baseDN, Class<T> entryClass, Filter filter, SearchScope scope, String[] ldapReturnAttributes, BatchOperation<T> batchOperation, int startIndex, int sizeLimit, int chunkSize) {
if (StringHelper.isEmptyString(baseDN)) {
throw new MappingException("Base DN to find entries is null");
}
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
String[] currentLdapReturnAttributes = ldapReturnAttributes;
if (ArrayHelper.isEmpty(currentLdapReturnAttributes)) {
currentLdapReturnAttributes = getLdapAttributes(null, propertiesAnnotations, false);
}
// Find entries
Filter searchFilter;
if (objectClasses.length > 0) {
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
searchFilter = filter;
}
SearchResult searchResult = null;
try {
searchResult = this.ldapOperationService.search(baseDN, toLdapFilter(searchFilter), toLdapSearchScope(scope), batchOperation, startIndex, chunkSize, sizeLimit, null, currentLdapReturnAttributes);
if (!ResultCode.SUCCESS.equals(searchResult.getResultCode())) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s, filter: %s", baseDN, searchFilter));
}
} catch (Exception ex) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s, filter: %s", baseDN, searchFilter),
ex);
}
if (searchResult.getEntryCount() == 0) {
return new ArrayList<T>(0);
}
List<T> entries = createEntities(entryClass, propertiesAnnotations,
searchResult.getSearchEntries().toArray(new SearchResultEntry[searchResult.getSearchEntries().size()]));
// Default sort if needed
sortEntriesIfNeeded(entryClass, entries);
return entries;
}