List of usage examples for org.springframework.security.authentication TestingAuthenticationToken setDetails
public void setDetails(Object details)
From source file:at.ac.univie.isc.asio.security.AuthToolsTest.java
@Test public void should_find_identity_in_authentication_details() throws Exception { final TestingAuthenticationToken authentication = new TestingAuthenticationToken("test", "password"); authentication.setDetails(new DelegatedCredentialsDetails(Identity.from("user", "password"))); context.setAuthentication(authentication); assertThat(AuthTools.findIdentity(context), equalTo(Identity.from("user", "password"))); }
From source file:at.ac.univie.isc.asio.security.AuthToolsTest.java
@Test public void should_yield_undefined_if_unexpected_details_type_found() throws Exception { final TestingAuthenticationToken authentication = new TestingAuthenticationToken("test", "password"); authentication.setDetails("no delegated credentials"); context.setAuthentication(authentication); assertThat(AuthTools.findIdentity(context), equalTo(Identity.undefined())); }
From source file:at.ac.univie.isc.asio.security.WhoamiResourceTest.java
@Test public void should_omit_delegated_credentials_if_not_instance_of_identity() throws Exception { final TestingAuthenticationToken auth = new TestingAuthenticationToken("name", "password"); auth.setDetails("not delegated credentials"); when(security.getAuthentication()).thenReturn(auth); final AuthInfo response = subject.getAuthInfo(); assertThat(response.getName(), nullValue()); assertThat(response.getSecret(), nullValue()); }
From source file:at.ac.univie.isc.asio.security.WhoamiResourceTest.java
@Test public void should_include_identity_if_present() throws Exception { final TestingAuthenticationToken auth = new TestingAuthenticationToken("name", "password"); auth.setDetails(new DelegatedCredentialsDetails(Identity.from("test-login", "test-secret"))); when(security.getAuthentication()).thenReturn(auth); final AuthInfo response = subject.getAuthInfo(); assertThat(response.getName(), equalTo("test-login")); assertThat(response.getSecret(), equalTo("test-secret")); }
From source file:at.ac.univie.isc.asio.security.HttpMethodRestrictionFilterTest.java
@Test public void should_keep_other_token_properties() throws Exception { final TestingAuthenticationToken token = new TestingAuthenticationToken("user", "secret", Collections.<GrantedAuthority>singletonList(Permission.INVOKE_UPDATE)); token.setDetails("details"); setAuthentication(token);/*from w ww. java2 s . com*/ request.setMethod(HttpMethod.GET.name()); subject.doFilter(request, response, chain); final Authentication filtered = getAuthentication(); assertThat(filtered.getPrincipal(), equalTo(token.getPrincipal())); assertThat(filtered.getCredentials(), equalTo(token.getCredentials())); assertThat(filtered.getDetails(), equalTo(token.getDetails())); }
From source file:at.ac.univie.isc.asio.engine.DatasetResourceTest.java
@Test public void forward_request_principal() throws Exception { final TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password"); authentication.setDetails(new DelegatedCredentialsDetails(Identity.from("test", "password"))); securityContext.setAuthentication(authentication); subject.acceptForm(requestParameters, async, request); verify(connector).accept(params.capture()); assertThat(params.getValue().owner().get(), Matchers.<Principal>is(Identity.from("test", "password"))); }