Package org.surfnet.oaaas.auth.principal

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


  @Override
  public void authenticate(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
      String authStateValue, String returnUri) throws IOException, ServletException {
    HttpSession session = request.getSession(false);
    AuthenticatedPrincipal principal = (AuthenticatedPrincipal) (session != null ? session
        .getAttribute(SESSION_IDENTIFIER) : null);
    if (request.getMethod().equals("POST")) {
      processForm(request);
      chain.doFilter(request, response);
    } else if (principal != null) {
View Full Code Here


   * @param request
   *          the {@link HttpServletRequest}
   */
  protected void processForm(final HttpServletRequest request) {
    setAuthStateValue(request, request.getParameter(AUTH_STATE));
    AuthenticatedPrincipal principal = new AuthenticatedPrincipal(request.getParameter("j_username"));
    request.getSession().setAttribute(SESSION_IDENTIFIER, principal);
    setPrincipal(request, principal);
  }
View Full Code Here

    return request.getMethod().equals(HttpMethod.POST.toString()) && StringUtils.isNotBlank(oauthApproval);
  }

  private void processInitial(HttpServletRequest request, ServletResponse response, FilterChain chain,
      String returnUri, String authStateValue, Client client) throws IOException, ServletException {
    AuthenticatedPrincipal principal = (AuthenticatedPrincipal) request.getAttribute(AbstractAuthenticator.PRINCIPAL);
    List<AccessToken> tokens = accessTokenRepository.findByResourceOwnerIdAndClient(principal.getName(), client);
    if (!CollectionUtils.isEmpty(tokens)) {
      // If another token is already present for this resource owner and client, no new consent should be requested
      List<String> grantedScopes = tokens.get(0).getScopes(); // take the scopes of the first access token found.
      setGrantedScopes(request, grantedScopes.toArray(new String[grantedScopes.size()]));
      chain.doFilter(request, response);
View Full Code Here

    client = repo.save(client);


    // Create an access token
    AccessToken at = new AccessToken("mytoken", new AuthenticatedPrincipal("username"), client, 0, null);
    at = accessTokenRepository.save(at);
    assertEquals(at, accessTokenRepository.findOne(at.getId()));

    // Create an authorization request
    AuthorizationRequest ar = new AuthorizationRequest("foo", "faa", "boo", null, "boo", "boo");
View Full Code Here

*/
public class AccessTokenTest {

  @Test
  public void marshallToJsonShouldHideSomeMembers() throws JAXBException {
    AccessToken token = getToken(new AuthenticatedPrincipal("Truus"));
    token.setClient(createClient("my-client-id", "my-client-secret"));

    String json = marshallToJson(token);

    assertTrue(json.contains("my-client-id"));
View Full Code Here

    client.setSecret(secret);
    return client;
  }

  private String generateEncodedPrincipal(String name, Collection<String> roles) {
    AuthenticatedPrincipal principal = new AuthenticatedPrincipal(name, roles);
    AccessToken token = getToken(principal);
    token.encodePrincipal();
    return token.getEncodedPrincipal();
  }
View Full Code Here

    when(resourceOwnerRepository.findByUsername(this.resourceOwner.getUsername())).thenReturn(resourceOwner);
  }

  @Test
  public void testAuthenticate() {
    AuthenticatedPrincipal principal =
        this.authenticator.authenticate(this.resourceOwner.getUsername(), PASSWORD);
    assertNotNull(principal);
    assertEquals("Principal does not have expected name", this.resourceOwner.getUsername(),
        principal.getName());
  }
View Full Code Here

        principal.getName());
  }

  @Test
  public void testAuthenticateBadUser() {
    AuthenticatedPrincipal principal = this.authenticator.authenticate("foo", PASSWORD);
    assertNull(principal);
  }
View Full Code Here

    assertNull(principal);
  }

  @Test
  public void testAuthenticateBadPassword() {
    AuthenticatedPrincipal principal =
        this.authenticator.authenticate(this.resourceOwner.getUsername(), "bad");
    assertNull(principal);
  }
View Full Code Here

  private AuthorizationRequest createAuthRequest(String implicitGrantResponseType) {
    AuthorizationRequest authRequest = new AuthorizationRequest();
    Client client = new Client();
    authRequest.setClient(client);
    authRequest.setResponseType(implicitGrantResponseType);
    authRequest.setPrincipal(new AuthenticatedPrincipal("sammy sammy"));
    authRequest.setRedirectUri("http://localhost:8080");
    authRequest.setState("important");
    return authRequest;
  }
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.