本文整理汇总了Java中org.ldaptive.SearchResult类的典型用法代码示例。如果您正苦于以下问题:Java SearchResult类的具体用法?Java SearchResult怎么用?Java SearchResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchResult类属于org.ldaptive包,在下文中一共展示了SearchResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: submit
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public boolean submit(final RequestContext requestContext, final Credential credential) {
String currentDn = null;
try (Connection searchConnection = LdapUtils.createConnection(this.connectionFactory)) {
final Response<SearchResult> response = searchForId(searchConnection, credential.getId());
if (LdapUtils.containsResultEntry(response)) {
currentDn = response.getResult().getEntry().getDn();
}
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
if (StringUtils.isNotBlank(currentDn)) {
logger.debug("Updating {}", currentDn);
return LdapUtils.executeModifyOperation(currentDn, this.connectionFactory,
Collections.singletonMap(this.aupAttributeName,
Collections.singleton(Boolean.TRUE.toString())));
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapAcceptableUsagePolicyRepository.java
示例2: update
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Update the ldap entry with the given registered service.
*
* @param rs the rs
* @return the registered service
*/
private RegisteredService update(final RegisteredService rs) {
String currentDn = null;
if (ldapServiceMapper == null) {
return null;
}
try {
final Response<SearchResult> response = searchForServiceById(rs.getId());
if (LdapUtils.containsResultEntry(response)) {
currentDn = response.getResult().getEntry().getDn();
}
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
if (StringUtils.isNotBlank(currentDn)) {
logger.debug("Updating registered service at {}", currentDn);
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
LdapUtils.executeModifyOperation(currentDn, this.connectionFactory, entry);
}
return rs;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:31,代码来源:LdapServiceRegistryDao.java
示例3: load
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
final List<RegisteredService> list = new LinkedList<>();
if (ldapServiceMapper == null) {
return list;
}
try {
final Response<SearchResult> response = LdapUtils.executeSearchOperation(this.connectionFactory,
this.baseDn, new SearchFilter(this.loadFilter));
if (LdapUtils.containsResultEntry(response)) {
for (final LdapEntry entry : response.getResult().getEntries()) {
final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
list.add(svc);
}
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
}
return list;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapServiceRegistryDao.java
示例4: fetchCRLFromLdap
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Downloads a CRL from given LDAP url.
*
* @param r the resource that is the ldap url.
* @return the x 509 cRL
* @throws Exception if connection to ldap fails, or attribute to get the revocation list is unavailable
*/
protected X509CRL fetchCRLFromLdap(final Object r) throws Exception {
try {
final String ldapURL = r.toString();
logger.debug("Fetching CRL from ldap {}", ldapURL);
final Response<SearchResult> result = performLdapSearch(ldapURL);
if (result.getResultCode() == ResultCode.SUCCESS) {
final LdapEntry entry = result.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute();
logger.debug("Located entry [{}]. Retrieving first attribute [{}]",
entry, attribute);
return fetchX509CRLFromAttribute(attribute);
} else {
logger.debug("Failed to execute the search [{}]", result);
}
throw new CertificateException("Failed to establish a connection ldap and search.");
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
throw new CertificateException(e);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:32,代码来源:LdaptiveResourceCRLFetcher.java
示例5: load
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
Connection connection = null;
final List<RegisteredService> list = new LinkedList<>();
try {
connection = getConnection();
final Response<SearchResult> response =
executeSearchOperation(connection, new SearchFilter(this.loadFilter));
if (hasResults(response)) {
for (final LdapEntry entry : response.getResult().getEntries()) {
final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
list.add(svc);
}
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return list;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:LdapServiceRegistryDao.java
示例6: findServiceById
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
Connection connection = null;
try {
connection = getConnection();
final Response<SearchResult> response = searchForServiceById(connection, id);
if (hasResults(response)) {
return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return null;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:LdapServiceRegistryDao.java
示例7: submit
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public boolean submit(final RequestContext requestContext, final Credential credential) {
String currentDn = null;
try {
final Response<SearchResult> response = searchForId(credential.getId());
if (LdapUtils.containsResultEntry(response)) {
currentDn = response.getResult().getEntry().getDn();
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
if (StringUtils.isNotBlank(currentDn)) {
LOGGER.debug("Updating [{}]", currentDn);
return LdapUtils.executeModifyOperation(currentDn, this.connectionFactory,
Collections.singletonMap(this.aupAttributeName,
Collections.singleton(Boolean.TRUE.toString())));
}
return false;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:LdapAcceptableUsagePolicyRepository.java
示例8: generateAuthorizationForLdapEntry
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
protected CommonProfile generateAuthorizationForLdapEntry(final CommonProfile profile, final LdapEntry userEntry) {
try {
LOGGER.debug("Attempting to get roles for user [{}].", userEntry.getDn());
final Response<SearchResult> response = this.groupSearchExecutor.search(
this.connectionFactory,
Beans.newLdaptiveSearchFilter(this.groupSearchExecutor.getSearchFilter().getFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, Arrays.asList(userEntry.getDn())));
LOGGER.debug("LDAP role search response: [{}]", response);
final SearchResult groupResult = response.getResult();
for (final LdapEntry entry : groupResult.getEntries()) {
final LdapAttribute groupAttribute = entry.getAttribute(this.groupAttributeName);
if (groupAttribute == null) {
LOGGER.warn("Role attribute not found on entry [{}]", entry);
continue;
}
addProfileRolesFromAttributes(profile, groupAttribute, this.groupPrefix);
}
} catch (final LdapException e) {
throw new RuntimeException("LDAP error fetching roles for user.", e);
}
return profile;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:LdapUserGroupsToRolesAuthorizationGenerator.java
示例9: update
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Update the ldap entry with the given registered service.
*
* @param rs the rs
* @return the registered service
*/
private RegisteredService update(final RegisteredService rs) {
String currentDn = null;
try {
final Response<SearchResult> response = searchForServiceById(rs.getId());
if (LdapUtils.containsResultEntry(response)) {
currentDn = response.getResult().getEntry().getDn();
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
if (StringUtils.isNotBlank(currentDn)) {
LOGGER.debug("Updating registered service at [{}]", currentDn);
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
LdapUtils.executeModifyOperation(currentDn, this.connectionFactory, entry);
}
return rs;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:27,代码来源:LdapServiceRegistryDao.java
示例10: load
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
final List<RegisteredService> list = new LinkedList<>();
try {
final Response<SearchResult> response = getSearchResultResponse();
if (LdapUtils.containsResultEntry(response)) {
response.getResult().getEntries()
.stream()
.map(this.ldapServiceMapper::mapToRegisteredService)
.forEach(s -> {
publishEvent(new CasRegisteredServiceLoadedEvent(this, s));
list.add(s);
});
}
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return list;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:LdapServiceRegistryDao.java
示例11: getGraphics
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public ByteSource getGraphics(final String username) {
try {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final Response<SearchResult> response = searchForId(username);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(gua.getLdap().getImageAttribute());
if (attribute != null && attribute.isBinary()) {
return ByteSource.wrap(attribute.getBinaryValue());
}
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return ByteSource.empty();
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:LdapUserGraphicalAuthenticationRepository.java
示例12: canAuthenticateAs
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public boolean canAuthenticateAs(final String username, final Principal surrogate) {
try {
if (username.equalsIgnoreCase(surrogate.getId())) {
return true;
}
final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldapProperties.getSurrogateSearchFilter(), Arrays.asList(username));
LOGGER.debug("Using search filter: [{}]", filter);
final Response<SearchResult> response = LdapUtils.executeSearchOperation(this.connectionFactory,
ldapProperties.getBaseDn(), filter);
LOGGER.debug("LDAP response: [{}]", response);
return LdapUtils.containsResultEntry(response);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:LdapSurrogateUsernamePasswordService.java
示例13: fetchCRLFromLdap
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Downloads a CRL from given LDAP url.
*
* @param r the resource that is the ldap url.
* @return the x 509 cRL
* @throws IOException the exception thrown if resources cant be fetched
* @throws CRLException the exception thrown if resources cant be fetched
* @throws CertificateException if connection to ldap fails, or attribute to get the revocation list is unavailable
*/
protected X509CRL fetchCRLFromLdap(final Object r) throws CertificateException, IOException, CRLException {
try {
final String ldapURL = r.toString();
LOGGER.debug("Fetching CRL from ldap [{}]", ldapURL);
final Response<SearchResult> result = performLdapSearch(ldapURL);
if (result.getResultCode() == ResultCode.SUCCESS) {
final LdapEntry entry = result.getResult().getEntry();
final LdapAttribute attribute = entry.getAttribute(this.certificateAttribute);
if (attribute.isBinary()) {
LOGGER.debug("Located entry [{}]. Retrieving first attribute [{}]", entry, attribute);
return fetchX509CRLFromAttribute(attribute);
}
LOGGER.warn("Found certificate attribute [{}] but it is not marked as a binary attribute", this.certificateAttribute);
}
LOGGER.debug("Failed to execute the search [{}]", result);
throw new CertificateException("Failed to establish a connection ldap and search.");
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
throw new CertificateException(e.getMessage());
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:LdaptiveResourceCRLFetcher.java
示例14: load
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
Connection connection = null;
final List<RegisteredService> list = new LinkedList<RegisteredService>();
try {
connection = this.connectionFactory.getConnection();
final Response<SearchResult> response =
executeSearchOperation(connection, new SearchFilter(this.loadFilter));
if (hasResults(response)) {
for (final LdapEntry entry : response.getResult().getEntries()) {
final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
list.add(svc);
}
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return list;
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:22,代码来源:LdapServiceRegistryDao.java
示例15: findServiceById
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
Connection connection = null;
try {
connection = this.connectionFactory.getConnection();
final Response<SearchResult> response = searchForServiceById(connection, id);
if (hasResults(response)) {
return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return null;
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:19,代码来源:LdapServiceRegistryDao.java
示例16: load
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public List<RegisteredService> load() {
final List<RegisteredService> list = new LinkedList<>();
if (ldapServiceMapper == null) {
return list;
}
try (final Connection connection = getConnection()) {
final Response<SearchResult> response =
executeSearchOperation(connection, new SearchFilter(this.loadFilter));
if (hasResults(response)) {
for (final LdapEntry entry : response.getResult().getEntries()) {
final RegisteredService svc = this.ldapServiceMapper.mapToRegisteredService(entry);
list.add(svc);
}
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
}
return list;
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:22,代码来源:LdapServiceRegistryDao.java
示例17: findServiceById
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public RegisteredService findServiceById(final long id) {
if (ldapServiceMapper == null) {
return null;
}
try (final Connection connection = getConnection()) {
final Response<SearchResult> response = searchForServiceById(connection, id);
if (hasResults(response)) {
return this.ldapServiceMapper.mapToRegisteredService(response.getResult().getEntry());
}
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
}
return null;
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:17,代码来源:LdapServiceRegistryDao.java
示例18: next
import org.ldaptive.SearchResult; //导入依赖的package包/类
@Override
public LdapEntry next() {
final String dn = dnsIterator.next();
final SearchRequest request = new SearchRequest();
request.setBaseDn(dn);
request.setSearchFilter(usersFilter);
request.setSearchScope(OBJECT);
request.setReturnAttributes(returnAttrs);
request.setSearchEntryHandlers(new ObjectGuidHandler());
try {
final Response<SearchResult> response = searchOp.execute(request);
if (response.getResultCode() != SUCCESS) {
throw new SyncException(
format(
"Couldn't get entry dn '%s', result code is '%s'", dn, response.getResultCode()));
}
return response.getResult().getEntry();
} catch (LdapException x) {
throw new SyncException(x.getLocalizedMessage(), x);
}
}
开发者ID:codenvy,项目名称:codenvy,代码行数:22,代码来源:MembershipSelector.java
示例19: executeSearchOperation
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Execute search operation.
*
* @param connectionFactory the connection factory
* @param baseDn the base dn
* @param filter the filter
* @return the response
* @throws LdapException the ldap exception
*/
public static Response<SearchResult> executeSearchOperation(final ConnectionFactory connectionFactory,
final String baseDn,
final SearchFilter filter)
throws LdapException {
try (Connection connection = createConnection(connectionFactory)) {
final SearchOperation searchOperation = new SearchOperation(connection);
final SearchRequest request = createSearchRequest(baseDn, filter);
request.setReferralHandler(new SearchReferralHandler());
return searchOperation.execute(request);
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:LdapUtils.java
示例20: containsResultEntry
import org.ldaptive.SearchResult; //导入依赖的package包/类
/**
* Checks to see if response has a result.
*
* @param response the response
* @return true, if successful
*/
public static boolean containsResultEntry(final Response<SearchResult> response) {
final SearchResult result = response.getResult();
if (result != null && result.getEntry() != null) {
return true;
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:LdapUtils.java
注:本文中的org.ldaptive.SearchResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论