@Test public void expectedCredentialsAreReturned() { AuthenticationSource source = new SpringSecurityAuthenticationSource(); SecurityContextHolder.getContext().setAuthentication( new TestingAuthenticationToken(new Object(), "password")); assertThat(source.getCredentials()).isEqualTo("password"); }
@Test public void principalAndCredentialsAreEmptyWithNoAuthentication() { AuthenticationSource source = new SpringSecurityAuthenticationSource(); assertThat(source.getPrincipal()).isEqualTo(""); assertThat(source.getCredentials()).isEqualTo(""); }
/** * Checks if the target's principal is not empty; if not, the credentials * from the target is returned - otherwise return the * <code>defaultPassword</code>. * * @return the target's password if the target's principal is not empty, the * <code>defaultPassword</code> otherwise. */ public String getCredentials() { if (StringUtils.hasText(target.getPrincipal())) { return target.getCredentials(); } else { return defaultPassword; } }
/** * Checks if the target's principal is not empty; if not, the credentials * from the target is returned - otherwise return the * <code>defaultPassword</code>. * * @return the target's password if the target's principal is not empty, the * <code>defaultPassword</code> otherwise. */ public String getCredentials() { if (StringUtils.hasText(target.getPrincipal())) { return target.getCredentials(); } else { return defaultPassword; } }
/** * Checks if the target's principal is not empty; if not, the credentials * from the target is returned - otherwise return the * <code>defaultPassword</code>. * * @return the target's password if the target's principal is not empty, the * <code>defaultPassword</code> otherwise. */ public String getCredentials() { if (StringUtils.hasText(target.getPrincipal())) { return target.getCredentials(); } else { return defaultPassword; } }
/** * Checks if the target's principal is not empty; if not, the credentials * from the target is returned - otherwise return the * <code>defaultPassword</code>. * * @return the target's password if the target's principal is not empty, the * <code>defaultPassword</code> otherwise. */ public String getCredentials() { if (StringUtils.hasText(target.getPrincipal())) { return target.getCredentials(); } else { return defaultPassword; } }
public DirContext getReadWriteContext() { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); }
public DirContext getReadWriteContext() { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); }
public DirContext getReadWriteContext() { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); }
public DirContext getReadWriteContext() { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); }
public DirContext getReadOnlyContext() { if (!anonymousReadOnly) { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } else { return createContext(getAnonymousEnv()); } }
@Test public void testGetCredentials_TargetHasPrincipal() { when(authenticationSourceMock.getPrincipal()).thenReturn("cn=someUser"); when(authenticationSourceMock.getCredentials()).thenReturn("somepassword"); String credentials = tested.getCredentials(); assertThat(credentials).isEqualTo("somepassword"); }
@Test public void testGetCredentials_TargetHasNoPrincipal() { when(authenticationSourceMock.getPrincipal()).thenReturn(""); when(authenticationSourceMock.getCredentials()).thenReturn("somepassword"); String credentials = tested.getCredentials(); assertThat(credentials).isEqualTo(DEFAULT_PASSWORD); }
public DirContext getReadOnlyContext() { if (!anonymousReadOnly) { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } else { return createContext(getAnonymousEnv()); } }
public DirContext getReadOnlyContext() { if (!anonymousReadOnly) { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } else { return createContext(getAnonymousEnv()); } }
public DirContext getReadOnlyContext() { if (!anonymousReadOnly) { return doGetContext( authenticationSource.getPrincipal(), authenticationSource.getCredentials(), DONT_DISABLE_POOLING); } else { return createContext(getAnonymousEnv()); } }