Search in sources :

Example 11 with InetOrgPerson

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);
}
Also used : InetOrgPerson(org.springframework.security.ldap.userdetails.InetOrgPerson) OrganizacaoDTO(com.tomasio.projects.trainning.dto.OrganizacaoDTO)

Example 12 with InetOrgPerson

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();
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) InetOrgPerson(org.springframework.security.ldap.userdetails.InetOrgPerson) UserDetailsService(org.springframework.security.core.userdetails.UserDetailsService) LdapUserDetailsService(org.springframework.security.ldap.userdetails.LdapUserDetailsService) InetOrgPersonContextMapper(org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper) Test(org.junit.jupiter.api.Test)

Example 13 with InetOrgPerson

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);
}
Also used : InetOrgPerson(org.springframework.security.ldap.userdetails.InetOrgPerson) InetOrgPersonContextMapper(org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper) Test(org.junit.jupiter.api.Test)

Example 14 with InetOrgPerson

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());
}
Also used : InetOrgPerson(org.springframework.security.ldap.userdetails.InetOrgPerson) InetOrgPersonContextMapper(org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper) Test(org.junit.jupiter.api.Test)

Aggregations

InetOrgPerson (org.springframework.security.ldap.userdetails.InetOrgPerson)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ArrayList (java.util.ArrayList)5 Test (org.junit.jupiter.api.Test)5 InetOrgPersonContextMapper (org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper)4 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)2 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)2 NetworkGroupDTO (com.tomasio.projects.trainning.dto.NetworkGroupDTO)2 NetworkUserDTO (com.tomasio.projects.trainning.dto.NetworkUserDTO)2 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)2 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)2 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)2 CoreException (com.tomasio.projects.trainning.exeption.CoreException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 UserDetails (org.springframework.security.core.userdetails.UserDetails)2 UserDetailsService (org.springframework.security.core.userdetails.UserDetailsService)2 LdapUserDetailsService (org.springframework.security.ldap.userdetails.LdapUserDetailsService)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 AnotacaoDTO (com.tomasio.projects.trainning.dto.AnotacaoDTO)1