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

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

Introduction

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

Prototype

@Override
    public Object getPrincipal() 

Source Link

Usage

From source file:at.ac.univie.isc.asio.security.HttpMethodRestrictionFilterTest.java

@Test
public void should_keep_anonymous_type() throws Exception {
    final AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("key", "principal",
            Collections.<GrantedAuthority>singletonList(Permission.INVOKE_UPDATE));
    token.setDetails("details");
    setAuthentication(token);//from   w  w w .j ava  2s .  c  om
    request.setMethod(HttpMethod.GET.name());
    subject.doFilter(request, response, chain);
    final Authentication filtered = getAuthentication();
    assertThat(filtered, instanceOf(AnonymousAuthenticationToken.class));
    assertThat(filtered.getPrincipal(), equalTo(token.getPrincipal()));
    assertThat(filtered.getDetails(), equalTo(token.getDetails()));
}