OAuth2SecurityContext implements SecurityContext { @Override public Principal getUserPrincipal() { return principal; } OAuth2SecurityContext(final OAuthToken token,
                                 final Boolean isSecure); @Override Principal getUserPrincipal(); @Override boolean isUserInRole(final String roleName); @Override boolean isSecure(); @Override String getAuthenticationScheme();  }
@Test public void getUserPrincipal() throws Exception { ApplicationContext context = TEST_DATA_RESOURCE.getAdminApplication(); OAuthToken token = context.getBuilder() .scope("principal-1") .scope("principal-2") .bearerToken("principal-1", "principal-2") .build() .getToken(); OAuth2SecurityContext securityContext = new OAuth2SecurityContext( token, false); assertEquals(false, securityContext.isSecure()); assertEquals("OAuth2", securityContext.getAuthenticationScheme()); assertSame(token, securityContext.getUserPrincipal()); assertTrue(securityContext.isUserInRole("principal-1")); assertTrue(securityContext.isUserInRole("principal-2")); assertFalse(securityContext.isUserInRole("principal-3")); }