use of org.springframework.security.authentication.UsernamePasswordAuthenticationToken in project opennms by OpenNMS.
the class RadiusAuthenticationProviderTest method testRetrieveUserChap.
@Test
@Ignore("Need to have a RADIUS server running on localhost")
public void testRetrieveUserChap() throws IOException {
RadiusAuthenticationProvider provider = new RadiusAuthenticationProvider(m_radiusServer, m_sharedSecret);
RadiusAuthenticator authTypeClass = new CHAPAuthenticator();
provider.setAuthTypeClass(authTypeClass);
provider.setRolesAttribute("Unknown-VSAttribute(5813:1)");
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(m_principal, m_credentials);
provider.retrieveUser(m_username, token);
}
use of org.springframework.security.authentication.UsernamePasswordAuthenticationToken in project opennms by OpenNMS.
the class RadiusAuthenticationProviderTest method testRetrieveUserPap.
@Test
@Ignore("Need to have a RADIUS server running on localhost")
public void testRetrieveUserPap() throws IOException {
RadiusAuthenticationProvider provider = new RadiusAuthenticationProvider(m_radiusServer, m_sharedSecret);
RadiusAuthenticator authTypeClass = new PAPAuthenticator();
provider.setAuthTypeClass(authTypeClass);
provider.setRolesAttribute("Unknown-VSAttribute(5813:1)");
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(m_principal, m_credentials);
provider.retrieveUser(m_username, token);
}
use of org.springframework.security.authentication.UsernamePasswordAuthenticationToken in project opennms by OpenNMS.
the class RadiusAuthenticationProviderTest method doTestRetrieveUserMultipleTimes.
public void doTestRetrieveUserMultipleTimes(RadiusAuthenticator authenticator) {
RadiusAuthenticationProvider provider = new RadiusAuthenticationProvider(m_radiusServer, m_sharedSecret);
RadiusAuthenticator authTypeClass = authenticator;
provider.setAuthTypeClass(authTypeClass);
provider.setRolesAttribute("Unknown-VSAttribute(5813:1)");
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(m_principal, m_credentials);
provider.retrieveUser(m_username, token);
provider.retrieveUser(m_username, token);
provider.retrieveUser(m_username, token);
provider.retrieveUser(m_username, token);
provider.retrieveUser(m_username, token);
provider.retrieveUser(m_username, token);
}
use of org.springframework.security.authentication.UsernamePasswordAuthenticationToken in project opennms by OpenNMS.
the class SimpleBackEndTest method testBackendWithBasicAuth.
@Test
@JUnitHttpServer(port = 9162, basicAuth = true, webapps = @Webapp(context = "/", path = "src/test/resources/simple-test-webapp"))
public void testBackendWithBasicAuth() throws Exception {
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken("testuser", "testpassword"));
assertNotNull(m_authBackEnd);
assertEquals("first get should be 0", 0, m_authBackEnd.getCount());
assertEquals("second should be 1", 1, m_authBackEnd.getCount());
}
use of org.springframework.security.authentication.UsernamePasswordAuthenticationToken in project opennms by OpenNMS.
the class AuthenticationIT method testAuthenticateTempUser.
@Test
public void testAuthenticateTempUser() throws Exception {
OnmsUser user = new OnmsUser("tempuser");
user.setFullName("Temporary User");
user.setPassword("18126E7BD3F84B3F3E4DF094DEF5B7DE");
user.setDutySchedule(Arrays.asList("MoTuWeThFrSaSu800-2300"));
m_userManager.save(user);
org.springframework.security.core.Authentication authentication = new UsernamePasswordAuthenticationToken("tempuser", "mike");
org.springframework.security.core.Authentication authenticated = m_provider.authenticate(authentication);
assertNotNull("authenticated Authentication object not null", authenticated);
Collection<? extends GrantedAuthority> authorities = authenticated.getAuthorities();
assertNotNull("GrantedAuthorities should not be null", authorities);
assertEquals("GrantedAuthorities size", 1, authorities.size());
assertContainsAuthority(Authentication.ROLE_USER, authorities);
}
Aggregations