本文整理汇总了Java中org.ldaptive.LdapException类的典型用法代码示例。如果您正苦于以下问题:Java LdapException类的具体用法?Java LdapException怎么用?Java LdapException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LdapException类属于org.ldaptive包,在下文中一共展示了LdapException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: executeModifyOperation
import org.ldaptive.LdapException; //导入依赖的package包/类
/**
* Execute modify operation boolean.
*
* @param currentDn the current dn
* @param connectionFactory the connection factory
* @param attributes the attributes
* @return the boolean
*/
public static boolean executeModifyOperation(final String currentDn,
final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (Connection modifyConnection = createConnection(connectionFactory)) {
final ModifyOperation operation = new ModifyOperation(modifyConnection);
final List<AttributeModification> mods = new ArrayList<>();
for (final Map.Entry<String, Set<String>> entry : attributes.entrySet()) {
mods.add(new AttributeModification(AttributeModificationType.REPLACE,
new LdapAttribute(entry.getKey(), entry.getValue().toArray(new String[]{}))));
}
final ModifyRequest request = new ModifyRequest(currentDn,
mods.toArray(new AttributeModification[]{}));
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:LdapUtils.java
示例2: save
import org.ldaptive.LdapException; //导入依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
if (this.ldapServiceMapper != null) {
if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
return update(rs);
}
try {
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
LdapUtils.executeAddOperation(this.connectionFactory, entry);
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
}
return rs;
}
return null;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:LdapServiceRegistryDao.java
示例3: load
import org.ldaptive.LdapException; //导入依赖的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.LdapException; //导入依赖的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: observe
import org.ldaptive.LdapException; //导入依赖的package包/类
/**
* Gets a connection from the underlying connection factory and attempts to validate it.
*
* @return Status with code {@link StatusCode#OK} on success otherwise {@link StatusCode#ERROR}.
*/
@Override
public Status observe() {
Connection conn = null;
try {
conn = this.connectionFactory.getConnection();
if (!conn.isOpen()) {
conn.open();
}
return this.validator.validate(conn) ? OK : ERROR;
} catch (final LdapException e) {
logger.warn("Validation failed with error.", e);
} finally {
LdapUtils.closeConnection(conn);
}
return ERROR;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:ConnectionFactoryMonitor.java
示例6: save
import org.ldaptive.LdapException; //导入依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
return update(rs);
}
Connection connection = null;
try {
connection = getConnection();
final AddOperation operation = new AddOperation(connection);
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
operation.execute(new AddRequest(entry.getDn(), entry.getAttributes()));
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return rs;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:LdapServiceRegistryDao.java
示例7: load
import org.ldaptive.LdapException; //导入依赖的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
示例8: findServiceById
import org.ldaptive.LdapException; //导入依赖的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
示例9: generateAuthorizationForLdapEntry
import org.ldaptive.LdapException; //导入依赖的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
示例10: executeModifyOperation
import org.ldaptive.LdapException; //导入依赖的package包/类
/**
* Execute modify operation boolean.
*
* @param currentDn the current dn
* @param connectionFactory the connection factory
* @param attributes the attributes
* @return true/false
*/
public static boolean executeModifyOperation(final String currentDn, final ConnectionFactory connectionFactory,
final Map<String, Set<String>> attributes) {
try (Connection modifyConnection = createConnection(connectionFactory)) {
final ModifyOperation operation = new ModifyOperation(modifyConnection);
final List<AttributeModification> mods = attributes.entrySet()
.stream().map(entry -> new AttributeModification(AttributeModificationType.REPLACE,
new LdapAttribute(entry.getKey(), entry.getValue().toArray(new String[]{})))).collect(Collectors.toList());
final ModifyRequest request = new ModifyRequest(currentDn,
mods.toArray(new AttributeModification[]{}));
request.setReferralHandler(new ModifyReferralHandler());
operation.execute(request);
return true;
} catch (final LdapException e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:LdapUtils.java
示例11: load
import org.ldaptive.LdapException; //导入依赖的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
示例12: fetchCRLFromLdap
import org.ldaptive.LdapException; //导入依赖的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
示例13: save
import org.ldaptive.LdapException; //导入依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
return update(rs);
}
Connection connection = null;
try {
connection = this.connectionFactory.getConnection();
final AddOperation operation = new AddOperation(connection);
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
operation.execute(new AddRequest(entry.getDn(), entry.getAttributes()));
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
} finally {
LdapUtils.closeConnection(connection);
}
return rs;
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:LdapServiceRegistryDao.java
示例14: load
import org.ldaptive.LdapException; //导入依赖的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.LdapException; //导入依赖的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: save
import org.ldaptive.LdapException; //导入依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
if (this.ldapServiceMapper != null && this.searchRequest != null) {
if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
return update(rs);
}
try (final Connection connection = getConnection()) {
final AddOperation operation = new AddOperation(connection);
final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.searchRequest.getBaseDn(), rs);
operation.execute(new AddRequest(entry.getDn(), entry.getAttributes()));
} catch (final LdapException e) {
logger.error(e.getMessage(), e);
}
return rs;
}
return null;
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:21,代码来源:LdapServiceRegistryDao.java
示例17: load
import org.ldaptive.LdapException; //导入依赖的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
示例18: findServiceById
import org.ldaptive.LdapException; //导入依赖的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
示例19: authenticate
import org.ldaptive.LdapException; //导入依赖的package包/类
/**
* Performs authentication.
*
* @param auth UsernamePasswordAuthenticationToken.
* @return authenticated object.
* @throws AuthenticationException if authentication fails.
*/
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
Assert.notNull(auth, "No authentication data provided.");
String userName = (String) auth.getPrincipal();
String password = (String) auth.getCredentials();
String domain = (String) auth.getDetails();
OneOpsUser user = null;
try {
user = ldapUserService.authenticate(userName, password.toCharArray(), domain);
} catch (LdapException ex) {
log.debug("Ldap Authentication failed for user: " + userName, ex);
}
if (user == null) {
throw new BadCredentialsException("Invalid Username/Password.");
}
// Check for user privileges.
if (user.getAuthorities().isEmpty()) {
throw new InsufficientAuthenticationException(user.getUsername() + " user has no roles assigned.");
}
return new LoginAuthToken(user, null, user.getAuthorities());
}
开发者ID:oneops,项目名称:secrets-proxy,代码行数:33,代码来源:LoginAuthProvider.java
示例20: authenticate
import org.ldaptive.LdapException; //导入依赖的package包/类
@Override
public String authenticate(String login, String password) throws AuthenticationException {
final AuthenticationResponse response;
try {
LOG.debug("Attempting LDAP authentication for: {}", login);
final AuthenticationRequest request =
new AuthenticationRequest(login, new Credential(password));
request.setReturnAttributes(returnAttributes);
response = this.ldapAuthenticator.authenticate(request);
} catch (final LdapException e) {
throw new AuthenticationException(401, "Unexpected LDAP error");
}
LOG.debug("LDAP response: {}", response);
if (!response.getResult()) {
throw new AuthenticationException(
401, "Authentication failed. Please check username and password.");
}
if (AuthenticationResultCode.DN_RESOLUTION_FAILURE == response.getAuthenticationResultCode()) {
throw new AuthenticationException(login + " is not found");
}
LOG.debug("Account state {}", response.getAccountState());
return idNormalizer.retrieveAndNormalize(response.getLdapEntry());
}
开发者ID:codenvy,项目名称:codenvy,代码行数:27,代码来源:LdapAuthenticationHandler.java
注:本文中的org.ldaptive.LdapException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论