use of org.springframework.security.core.userdetails.UserDetails in project head by mifos.
the class AuthenticationAuthorizationServiceFacadeImpl method reloadUserDetailsForSecurityContext.
@Override
public void reloadUserDetailsForSecurityContext(String username) {
UserDetails userSecurityDetails = loadUserByUsername(username);
MifosUser reloadedUserDetails = (MifosUser) userSecurityDetails;
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext == null) {
securityContext = new SecurityContextImpl();
SecurityContextHolder.setContext(securityContext);
}
Authentication authentication = new UsernamePasswordAuthenticationToken(reloadedUserDetails, reloadedUserDetails, reloadedUserDetails.getAuthorities());
securityContext.setAuthentication(authentication);
}
use of org.springframework.security.core.userdetails.UserDetails in project spring-security by spring-projects.
the class LdapUserServiceBeanDefinitionParserTests method externalContextMapperIsSupported.
@Test
public void externalContextMapperIsSupported() {
setContext("<ldap-server id='someServer' ldif='classpath:test-server.ldif'/>" + "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-context-mapper-ref='mapper'/>" + "<b:bean id='mapper' class='" + InetOrgPersonContextMapper.class.getName() + "'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
UserDetails ben = uds.loadUserByUsername("ben");
assertThat(ben instanceof InetOrgPerson).isTrue();
}
use of org.springframework.security.core.userdetails.UserDetails in project spring-security by spring-projects.
the class LdapUserServiceBeanDefinitionParserTests method userServiceReturnsExpectedData.
@Test
public void userServiceReturnsExpectedData() throws Exception {
setContext("<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' group-search-filter='member={0}' /><ldap-server ldif='classpath:test-server.ldif'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
UserDetails ben = uds.loadUserByUsername("ben");
Set<String> authorities = AuthorityUtils.authorityListToSet(ben.getAuthorities());
assertThat(authorities).hasSize(3);
assertThat(authorities.contains("ROLE_DEVELOPERS")).isTrue();
}
use of org.springframework.security.core.userdetails.UserDetails in project spring-security by spring-projects.
the class LdapUserServiceBeanDefinitionParserTests method personContextMapperIsSupported.
@Test
public void personContextMapperIsSupported() {
setContext("<ldap-server ldif='classpath:test-server.ldif'/>" + "<ldap-user-service id='ldapUDS' user-search-filter='(uid={0})' user-details-class='person'/>");
UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS");
UserDetails ben = uds.loadUserByUsername("ben");
assertThat(ben instanceof Person).isTrue();
}
use of org.springframework.security.core.userdetails.UserDetails in project spring-security by spring-projects.
the class CasAuthenticationTokenMixinTests method deserializeCasAuthenticationTestAfterEraseCredentialInvoked.
@Test
public void deserializeCasAuthenticationTestAfterEraseCredentialInvoked() throws Exception {
CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_CLEARED_JSON, CasAuthenticationToken.class);
assertThat(((UserDetails) token.getPrincipal()).getPassword()).isNull();
}
Aggregations