Search in sources :

Example 1 with LdapUserDetailsImpl

use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.

the class UserHelperTest method shouldGetNameFromLdapUserDetailsIfCannotGetFullName.

@Test
public void shouldGetNameFromLdapUserDetailsIfCannotGetFullName() {
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(new LdapUserDetailsImpl() {

        public String getUsername() {
            return "test1";
        }

        public String getDn() {
            return "n=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
        }
    }, null, null);
    assertThat(UserHelper.getUserName(authentication).getDisplayName(), is("test1"));
}
Also used : LdapUserDetailsImpl(org.springframework.security.userdetails.ldap.LdapUserDetailsImpl) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) TestingAuthenticationToken(org.springframework.security.providers.TestingAuthenticationToken) Test(org.junit.Test)

Example 2 with LdapUserDetailsImpl

use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.

the class GoVelocityViewTest method shouldRetriveLdapCompleteNameFromSessionWhenAuthenticated.

@Test
public void shouldRetriveLdapCompleteNameFromSessionWhenAuthenticated() throws Exception {
    securityContext.setAuthentication(new TestingAuthenticationToken(new LdapUserDetailsImpl() {

        public String getUsername() {
            return "test1";
        }

        public String getDn() {
            return "cn=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
        }
    }, null, null));
    request.getSession().setAttribute(SPRING_SECURITY_CONTEXT_KEY, securityContext);
    view.exposeHelpers(velocityContext, request);
    assertThat(velocityContext.get(GoVelocityView.PRINCIPAL), is("Test User"));
}
Also used : LdapUserDetailsImpl(org.springframework.security.userdetails.ldap.LdapUserDetailsImpl) TestingAuthenticationToken(org.springframework.security.providers.TestingAuthenticationToken) Test(org.junit.Test)

Example 3 with LdapUserDetailsImpl

use of org.springframework.security.userdetails.ldap.LdapUserDetailsImpl in project gocd by gocd.

the class UserHelperTest method shouldGetFullNameFromLdapUserDetails.

@Test
public void shouldGetFullNameFromLdapUserDetails() {
    TestingAuthenticationToken authentication = new TestingAuthenticationToken(new LdapUserDetailsImpl() {

        public String getUsername() {
            return "test1";
        }

        public String getDn() {
            return "cn=Test User, ou=Beijing, ou=Employees, ou=Enterprise, ou=Principal";
        }
    }, null, null);
    assertThat(UserHelper.getUserName(authentication).getDisplayName(), is("Test User"));
}
Also used : LdapUserDetailsImpl(org.springframework.security.userdetails.ldap.LdapUserDetailsImpl) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) TestingAuthenticationToken(org.springframework.security.providers.TestingAuthenticationToken) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 TestingAuthenticationToken (org.springframework.security.providers.TestingAuthenticationToken)3 LdapUserDetailsImpl (org.springframework.security.userdetails.ldap.LdapUserDetailsImpl)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2