use of org.springframework.ldap.core.support.LdapContextSource in project av-service by dvoraka.
the class LdapUserConfig method contextSource.
@Bean
public ContextSource contextSource() {
LdapContextSource ldapContextSource = new LdapContextSource();
ldapContextSource.setUrl("");
return ldapContextSource;
}
use of org.springframework.ldap.core.support.LdapContextSource in project spring-boot by spring-projects.
the class LdapAutoConfiguration method ldapContextSource.
@Bean
@ConditionalOnMissingBean
public ContextSource ldapContextSource() {
LdapContextSource source = new LdapContextSource();
source.setUserDn(this.properties.getUsername());
source.setPassword(this.properties.getPassword());
source.setBase(this.properties.getBase());
source.setUrls(this.properties.determineUrls(this.environment));
source.setBaseEnvironmentProperties(Collections.<String, Object>unmodifiableMap(this.properties.getBaseEnvironment()));
return source;
}
use of org.springframework.ldap.core.support.LdapContextSource in project jBPM5-Developer-Guide by Salaboy.
the class ProcessAndHumanTasksTest method setUp.
@Before
public void setUp() throws Exception {
container = new ApacheDSContainer("o=mojo", "classpath:identity-repository.ldif");
container.setPort(9898);
container.afterPropertiesSet();
LdapContextSource cs = new LdapContextSource();
cs.setUrl("ldap://localhost:9898/");
cs.setBase("o=mojo");
cs.setUserDn("uid=admin,ou=system");
cs.setPassword("secret");
cs.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(cs);
ldapTemplate.afterPropertiesSet();
ldapQuery = new LdapQueryHelper(ldapTemplate);
// By Setting the jbpm.usergroup.callback property with the call
// back class full name, task service will use this to validate the
// user/group exists and its permissions are ok.
System.setProperty("jbpm.usergroup.callback", "org.jbpm.task.identity.LDAPUserGroupCallbackImpl");
// LdapUserGroupCallback callback = (LdapUserGroupCallback) UserGroupCallbackManager.getInstance().getCallback();
// callback.setQuery(ldapQuery);
}
use of org.springframework.ldap.core.support.LdapContextSource in project incubator-atlas by apache.
the class AtlasLdapAuthenticationProvider method getLdapBindAuthentication.
private Authentication getLdapBindAuthentication(Authentication authentication) {
try {
if (isDebugEnabled) {
LOG.debug("==> AtlasLdapAuthenticationProvider getLdapBindAuthentication");
}
String userName = authentication.getName();
String userPassword = "";
if (authentication.getCredentials() != null) {
userPassword = authentication.getCredentials().toString();
}
LdapContextSource ldapContextSource = getLdapContextSource();
DefaultLdapAuthoritiesPopulator defaultLdapAuthoritiesPopulator = getDefaultLdapAuthoritiesPopulator(ldapContextSource);
if (ldapUserSearchFilter == null || ldapUserSearchFilter.trim().isEmpty()) {
ldapUserSearchFilter = "(uid={0})";
}
FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch(ldapBase, ldapUserSearchFilter, ldapContextSource);
userSearch.setSearchSubtree(true);
BindAuthenticator bindAuthenticator = getBindAuthenticator(userSearch, ldapContextSource);
LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(bindAuthenticator, defaultLdapAuthoritiesPopulator);
if (userName != null && userPassword != null && !userName.trim().isEmpty() && !userPassword.trim().isEmpty()) {
final List<GrantedAuthority> grantedAuths = getAuthorities(userName);
final UserDetails principal = new User(userName, userPassword, grantedAuths);
final Authentication finalAuthentication = new UsernamePasswordAuthenticationToken(principal, userPassword, grantedAuths);
authentication = ldapAuthenticationProvider.authenticate(finalAuthentication);
if (groupsFromUGI) {
authentication = getAuthenticationWithGrantedAuthorityFromUGI(authentication);
}
return authentication;
} else {
LOG.error("LDAP Authentication::userName or userPassword is null or empty for userName " + userName);
}
} catch (Exception e) {
LOG.error(" getLdapBindAuthentication LDAP Authentication Failed:", e);
}
if (isDebugEnabled) {
LOG.debug("<== AtlasLdapAuthenticationProvider getLdapBindAuthentication");
}
return authentication;
}
Aggregations