Example usage for org.springframework.security.authentication TestingAuthenticationToken getPrincipal

List of usage examples for org.springframework.security.authentication TestingAuthenticationToken getPrincipal

Introduction

In this page you can find the example usage for org.springframework.security.authentication TestingAuthenticationToken getPrincipal.

Prototype

public Object getPrincipal() 

Source Link

Usage

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 .  ja va  2s.  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()));
}