use of org.springframework.security.ldap.userdetails.InetOrgPerson in project trainning by fernandotomasio.
the class AuthenticationSuccessHandlerImpl method onAuthenticationSuccess.
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication auth) throws IOException, ServletException {
final InetOrgPerson user = (InetOrgPerson) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String userLogin = user.getUid();
// OrganizacaoDTO[] organizacoesGestoras = atividadesEnsinoService.findAllOrganizacoesGestoras();
// selecionar todas as ORGANIZAÇÕES que possuem PLANO DE ENSINO
OrganizacaoDTO[] organizacoesGestoras = atividadesEnsinoService.findAllOrganizacoesHasPlano();
OrganizacaoDTO organizacao = organizationalService.findOrganizacaoBySigla(user.getO());
request.getSession().setAttribute("userOrganization", organizacao);
request.getSession().setAttribute("organizacoesGestoras", organizacoesGestoras);
request.getSession().setAttribute("topOrganization", organizacao.getTopOrganizacao());
request.getSession().setAttribute("userLogin", userLogin);
request.getSession().setAttribute("permissionsManager", businessPermissionManager);
request.getRequestDispatcher("/").forward(request, response);
}
use of org.springframework.security.ldap.userdetails.InetOrgPerson 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) this.appCtx.getBean("ldapUDS");
UserDetails ben = uds.loadUserByUsername("ben");
assertThat(ben instanceof InetOrgPerson).isTrue();
}
use of org.springframework.security.ldap.userdetails.InetOrgPerson in project spring-security by spring-projects.
the class InetOrgPersonMixinTests method serializeWhenMixinRegisteredThenSerializes.
@Test
public void serializeWhenMixinRegisteredThenSerializes() throws Exception {
InetOrgPersonContextMapper mapper = new InetOrgPersonContextMapper();
InetOrgPerson p = (InetOrgPerson) mapper.mapUserFromContext(createUserContext(), "ghengis", AuthorityUtils.NO_AUTHORITIES);
String json = this.mapper.writeValueAsString(p);
JSONAssert.assertEquals(INET_ORG_PERSON_JSON, json, true);
}
use of org.springframework.security.ldap.userdetails.InetOrgPerson in project spring-security by spring-projects.
the class InetOrgPersonMixinTests method deserializeWhenMixinRegisteredThenDeserializes.
@Test
public void deserializeWhenMixinRegisteredThenDeserializes() throws Exception {
InetOrgPersonContextMapper mapper = new InetOrgPersonContextMapper();
InetOrgPerson expectedAuthentication = (InetOrgPerson) mapper.mapUserFromContext(createUserContext(), "ghengis", AuthorityUtils.NO_AUTHORITIES);
InetOrgPerson authentication = this.mapper.readValue(INET_ORG_PERSON_JSON, InetOrgPerson.class);
assertThat(authentication.getAuthorities()).containsExactlyElementsOf(expectedAuthentication.getAuthorities());
assertThat(authentication.getCarLicense()).isEqualTo(expectedAuthentication.getCarLicense());
assertThat(authentication.getDepartmentNumber()).isEqualTo(expectedAuthentication.getDepartmentNumber());
assertThat(authentication.getDestinationIndicator()).isEqualTo(expectedAuthentication.getDestinationIndicator());
assertThat(authentication.getDn()).isEqualTo(expectedAuthentication.getDn());
assertThat(authentication.getDescription()).isEqualTo(expectedAuthentication.getDescription());
assertThat(authentication.getDisplayName()).isEqualTo(expectedAuthentication.getDisplayName());
assertThat(authentication.getUid()).isEqualTo(expectedAuthentication.getUid());
assertThat(authentication.getUsername()).isEqualTo(expectedAuthentication.getUsername());
assertThat(authentication.getPassword()).isEqualTo(expectedAuthentication.getPassword());
assertThat(authentication.getHomePhone()).isEqualTo(expectedAuthentication.getHomePhone());
assertThat(authentication.getEmployeeNumber()).isEqualTo(expectedAuthentication.getEmployeeNumber());
assertThat(authentication.getHomePostalAddress()).isEqualTo(expectedAuthentication.getHomePostalAddress());
assertThat(authentication.getInitials()).isEqualTo(expectedAuthentication.getInitials());
assertThat(authentication.getMail()).isEqualTo(expectedAuthentication.getMail());
assertThat(authentication.getMobile()).isEqualTo(expectedAuthentication.getMobile());
assertThat(authentication.getO()).isEqualTo(expectedAuthentication.getO());
assertThat(authentication.getOu()).isEqualTo(expectedAuthentication.getOu());
assertThat(authentication.getPostalAddress()).isEqualTo(expectedAuthentication.getPostalAddress());
assertThat(authentication.getPostalCode()).isEqualTo(expectedAuthentication.getPostalCode());
assertThat(authentication.getRoomNumber()).isEqualTo(expectedAuthentication.getRoomNumber());
assertThat(authentication.getStreet()).isEqualTo(expectedAuthentication.getStreet());
assertThat(authentication.getSn()).isEqualTo(expectedAuthentication.getSn());
assertThat(authentication.getTitle()).isEqualTo(expectedAuthentication.getTitle());
assertThat(authentication.getGivenName()).isEqualTo(expectedAuthentication.getGivenName());
assertThat(authentication.getTelephoneNumber()).isEqualTo(expectedAuthentication.getTelephoneNumber());
assertThat(authentication.getGraceLoginsRemaining()).isEqualTo(expectedAuthentication.getGraceLoginsRemaining());
assertThat(authentication.getTimeBeforeExpiration()).isEqualTo(expectedAuthentication.getTimeBeforeExpiration());
assertThat(authentication.isAccountNonExpired()).isEqualTo(expectedAuthentication.isAccountNonExpired());
assertThat(authentication.isAccountNonLocked()).isEqualTo(expectedAuthentication.isAccountNonLocked());
assertThat(authentication.isEnabled()).isEqualTo(expectedAuthentication.isEnabled());
assertThat(authentication.isCredentialsNonExpired()).isEqualTo(expectedAuthentication.isCredentialsNonExpired());
}
Aggregations