本文整理汇总了Java中org.apereo.cas.configuration.support.Beans.newLdaptiveSearchFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Beans.newLdaptiveSearchFilter方法的具体用法?Java Beans.newLdaptiveSearchFilter怎么用?Java Beans.newLdaptiveSearchFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apereo.cas.configuration.support.Beans
的用法示例。
在下文中一共展示了Beans.newLdaptiveSearchFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ldapSpnegoClientAction
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
@Lazy
@Bean
@RefreshScope
public Action ldapSpnegoClientAction() {
final SpnegoProperties spnegoProperties = casProperties.getAuthn().getSpnego();
final ConnectionFactory connectionFactory = Beans.newLdaptivePooledConnectionFactory(spnegoProperties.getLdap());
final SearchFilter filter = Beans.newLdaptiveSearchFilter(spnegoProperties.getLdap().getSearchFilter(),
"host", Collections.emptyList());
final SearchRequest searchRequest = Beans.newLdaptiveSearchRequest(spnegoProperties.getLdap().getBaseDn(), filter);
return new LdapSpnegoKnownClientSystemsFilterAction(spnegoProperties.getIpsToCheckPattern(),
spnegoProperties.getAlternativeRemoteHostAttribute(),
spnegoProperties.getDnsTimeout(),
connectionFactory,
searchRequest,
spnegoProperties.getSpnegoAttributeName());
}
示例2: canAuthenticateAs
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的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;
}
示例3: searchForId
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
/**
* Search for service by id.
*
* @param id the id
* @return the response
* @throws LdapException the ldap exception
*/
private Response<SearchResult> searchForId(final String id) throws LdapException {
final SearchFilter filter = Beans.newLdaptiveSearchFilter(this.searchFilter,
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(id));
return LdapUtils.executeSearchOperation(this.connectionFactory, this.baseDn, filter);
}
示例4: findEmail
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
@Override
public String findEmail(final String username) {
try {
final PasswordManagementProperties.Ldap ldap = passwordManagementProperties.getLdap();
final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldap.getUserFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(username));
LOGGER.debug("Constructed LDAP filter [{}] to locate account email", filter);
final ConnectionFactory factory = Beans.newLdaptivePooledConnectionFactory(ldap);
final Response<SearchResult> response = LdapUtils.executeSearchOperation(factory, ldap.getBaseDn(), filter);
LOGGER.debug("LDAP response to locate account email is [{}]", response);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
LOGGER.debug("Found LDAP entry [{}] to use for the account email", entry);
final String attributeName = passwordManagementProperties.getReset().getEmailAttribute();
final LdapAttribute attr = entry.getAttribute(attributeName);
if (attr != null) {
final String email = attr.getStringValue();
LOGGER.debug("Found email address [{}] for user [{}]. Validating...", email, username);
if (EmailValidator.getInstance().isValid(email)) {
LOGGER.debug("Email address [{}] matches a valid email address", email);
return email;
}
LOGGER.error("Email [{}] is not a valid address", email);
} else {
LOGGER.error("Could not locate an LDAP attribute [{}] for [{}] and base DN [{}]",
attributeName, filter.format(), ldap.getBaseDn());
}
return null;
}
LOGGER.error("Could not locate an LDAP entry for [{}] and base DN [{}]", filter.format(), ldap.getBaseDn());
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
示例5: change
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
@Audit(action = "CHANGE_PASSWORD",
actionResolverName = "CHANGE_PASSWORD_ACTION_RESOLVER",
resourceResolverName = "CHANGE_PASSWORD_RESOURCE_RESOLVER")
@Override
public boolean change(final Credential credential, final PasswordChangeBean bean) {
Assert.notNull(credential, "Credential cannot be null");
Assert.notNull(bean, "PasswordChangeBean cannot be null");
try {
final PasswordManagementProperties.Ldap ldap = passwordManagementProperties.getLdap();
final UsernamePasswordCredential c = (UsernamePasswordCredential) credential;
final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldap.getUserFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(c.getId()));
LOGGER.debug("Constructed LDAP filter [{}] to update account password", filter);
final ConnectionFactory factory = Beans.newLdaptivePooledConnectionFactory(ldap);
final Response<SearchResult> response = LdapUtils.executeSearchOperation(factory, ldap.getBaseDn(), filter);
LOGGER.debug("LDAP response to update password is [{}]", response);
if (LdapUtils.containsResultEntry(response)) {
final String dn = response.getResult().getEntry().getDn();
LOGGER.debug("Updating account password for [{}]", dn);
if (LdapUtils.executePasswordModifyOperation(dn, factory, c.getPassword(), bean.getPassword(),
passwordManagementProperties.getLdap().getType())) {
LOGGER.debug("Successfully updated the account password for [{}]", dn);
return true;
}
LOGGER.error("Could not update the LDAP entry's password for [{}] and base DN [{}]", filter.format(), ldap.getBaseDn());
} else {
LOGGER.error("Could not locate an LDAP entry for [{}] and base DN [{}]", filter.format(), ldap.getBaseDn());
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return false;
}
示例6: getSecurityQuestions
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
@Override
public Map<String, String> getSecurityQuestions(final String username) {
final Map<String, String> set = new LinkedHashMap<>();
try {
final PasswordManagementProperties.Ldap ldap = passwordManagementProperties.getLdap();
final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldap.getUserFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(username));
LOGGER.debug("Constructed LDAP filter [{}] to locate security questions", filter);
final ConnectionFactory factory = Beans.newLdaptivePooledConnectionFactory(ldap);
final Response<SearchResult> response = LdapUtils.executeSearchOperation(factory, ldap.getBaseDn(), filter);
LOGGER.debug("LDAP response for security questions [{}]", response);
if (LdapUtils.containsResultEntry(response)) {
final LdapEntry entry = response.getResult().getEntry();
LOGGER.debug("Located LDAP entry [{}] in the response", entry);
final Map<String, String> qs = passwordManagementProperties.getLdap().getSecurityQuestionsAttributes();
LOGGER.debug("Security question attributes are defined to be [{}]", qs);
qs.forEach((k, v) -> {
final LdapAttribute q = entry.getAttribute(k);
final LdapAttribute a = entry.getAttribute(v);
if (q != null && a != null && StringUtils.isNotBlank(q.getStringValue())
&& StringUtils.isNotBlank(a.getStringValue())) {
LOGGER.debug("Added security question [{}]", q.getStringValue());
set.put(q.getStringValue(), a.getStringValue());
}
});
} else {
LOGGER.debug("LDAP response did not contain a result for security questions");
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return set;
}
示例7: searchForId
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
private Response<SearchResult> searchForId(final String id) throws LdapException {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
final SearchFilter filter = Beans.newLdaptiveSearchFilter(gua.getLdap().getUserFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(id));
return LdapUtils.executeSearchOperation(
Beans.newLdaptiveConnectionFactory(gua.getLdap()),
gua.getLdap().getBaseDn(), filter,
new String[]{gua.getLdap().getImageAttribute()},
ReturnAttributes.NONE.value());
}
示例8: getEligibleAccountsForSurrogateToProxy
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
@Override
public Collection<String> getEligibleAccountsForSurrogateToProxy(final String username) {
final Collection<String> eligible = new LinkedHashSet<>();
try {
final SearchFilter filter = Beans.newLdaptiveSearchFilter(ldapProperties.getSearchFilter(), 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);
if (!LdapUtils.containsResultEntry(response)) {
return eligible;
}
final LdapEntry ldapEntry = response.getResult().getEntry();
final LdapAttribute attribute = ldapEntry.getAttribute(ldapProperties.getMemberAttributeName());
if (attribute == null || attribute.getStringValues().isEmpty()) {
return eligible;
}
final Pattern pattern = RegexUtils.createPattern(ldapProperties.getMemberAttributeValueRegex());
eligible.addAll(
attribute.getStringValues()
.stream()
.map(pattern::matcher)
.filter(Matcher::matches)
.map(p -> p.group(1))
.collect(Collectors.toList()));
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return eligible;
}
示例9: searchForServiceById
import org.apereo.cas.configuration.support.Beans; //导入方法依赖的package包/类
/**
* Search for service by id.
*
* @param id the id
* @return the response
* @throws LdapException the ldap exception
*/
private Response<SearchResult> searchForServiceById(final Long id) throws LdapException {
final SearchFilter filter = Beans.newLdaptiveSearchFilter(this.searchFilter,
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
Arrays.asList(id.toString()));
return LdapUtils.executeSearchOperation(this.connectionFactory, this.baseDn, filter);
}