Package org.surfnet.oaaas.auth.principal

Examples of org.surfnet.oaaas.auth.principal.AuthenticatedPrincipal


  public void testSerialization() throws IOException {
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("key", "value");
    String identityProvider = "http://universiteit-hardewijk";
    String displayName = "gebruiker.pi";
    AuthenticatedPrincipal principal = new SAMLAuthenticatedPrincipal("ud.id.name.pi", Arrays.asList(new String[]{"USER", "ADMIN"}), attributes, Arrays.asList(new String[]{"id.group.1", "id.group.2", "id.group.3"}), identityProvider, displayName, true);
    String json = principal.serialize();
    SAMLAuthenticatedPrincipal samlPrincipal = (SAMLAuthenticatedPrincipal) AuthenticatedPrincipal.deserialize(json);
    assertTrue(samlPrincipal.isGroupAware());
    assertEquals(identityProvider, samlPrincipal.getIdentityProvider());
    assertEquals(displayName, samlPrincipal.getDisplayName());
    assertTrue(samlPrincipal.isAdminPrincipal());
View Full Code Here


    save(authReq, repo);
    authReq.setPrincipal(getPrincipal());
    repo.save(authReq);

    AuthorizationRequest authReqSaved = repo.findByAuthState(authState);
    AuthenticatedPrincipal principal = authReqSaved.getPrincipal();
    assertEquals("foo-university", principal.getAttributes().get("organization"));

  }
View Full Code Here

  private AuthenticatedPrincipal getPrincipal() {
    List<String> roles = Arrays.asList(new String[] { "user", "admin" });
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("organization", "foo-university");
    return new AuthenticatedPrincipal("john.doe", roles, attributes);
  }
View Full Code Here

  public void principal() {
    final ClientResponse response = webResource.path("principal").header("Authorization", authorizationBearer(ACCESS_TOKEN))
            .get(ClientResponse.class);
    assertEquals(200, response.getStatus());

    AuthenticatedPrincipal principal = response.getEntity(AuthenticatedPrincipal.class);
    assertEquals("admin-enduser",principal.getName());
  }
View Full Code Here

  @Before
  public void before() throws Exception {
    MockitoAnnotations.initMocks(this);
    VerifyTokenResponse verifyTokenResponse = new VerifyTokenResponse();
    verifyTokenResponse.setPrincipal(new AuthenticatedPrincipal("user"));
    verifyTokenResponse.setScopes(Arrays.asList("read"));
    when(request.getAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE)).thenReturn(verifyTokenResponse);
  }
View Full Code Here

  @Test
  public void scopesShouldBeSubsetOfResourceServerScopes() {

    Client client = new Client();
    request.setAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE, new VerifyTokenResponse("",
        new ArrayList<String>(), new AuthenticatedPrincipal("user"), 0L));
    client.setScopes(Arrays.asList("Some", "arbitrary", "set"));
    client.setName("clientname");
    ResourceServer resourceServer = new ResourceServer();
    resourceServer.setScopes(Arrays.asList("read", "update", "delete"));
    when(resourceServerRepository.findByIdAndOwner(1L, "user")).thenReturn(resourceServer);
View Full Code Here

  @Before
  public void before() {
    MockitoAnnotations.initMocks(this);
    VerifyTokenResponse verifyTokenResponse = new VerifyTokenResponse();
    verifyTokenResponse.setPrincipal(new AuthenticatedPrincipal("user"));
    verifyTokenResponse.setScopes(Arrays.asList("read"));
    when(request.getAttribute(AuthorizationServerFilter.VERIFY_TOKEN_RESPONSE)).thenReturn(verifyTokenResponse);
  }
View Full Code Here

  @Test
  public void testDoFilterHappyFlow() throws IOException, ServletException {
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("key", "value");
    VerifyTokenResponse recorderdResponse = new VerifyTokenResponse("org.surfnet.oaaas.conext.mock-client", Collections.singletonList("read"),
        new AuthenticatedPrincipal("john.doe", Arrays.asList("user", "admin"), attributes), 0L);
    MockFilterChain chain = doCallFilter(recorderdResponse);
    /*
     * Verify that the FilterChain#doFilter is called and the
     * VerifyTokenResponse is set on the Request
     */
 
View Full Code Here

   
    // Validate password
    if (!user.checkPassword(password)) {
      return null;
    }
    return new AuthenticatedPrincipal(username);
  }
View Full Code Here

    return authorizationRequestRepository.findByAuthState(authState);
  }

  private void storePrincipal(HttpServletRequest request, HttpServletResponse response,
      AuthorizationRequest authorizationRequest) throws IOException {
    AuthenticatedPrincipal principal = (AuthenticatedPrincipal) request.getAttribute(AbstractAuthenticator.PRINCIPAL);
    if (principal == null) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, "No valid AbstractAuthenticator.PRINCIPAL on the Request");
    }
    authorizationRequest.setPrincipal(principal);
    authorizationRequestRepository.save(authorizationRequest);
View Full Code Here

TOP

Related Classes of org.surfnet.oaaas.auth.principal.AuthenticatedPrincipal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.