Examples of AuthenticatedPrincipal


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

  @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

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

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

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

    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

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

            request.getSession().setAttribute(PostCasAuthenticationFilter.REDIRECT_URL, uri + "?" + queryString);
            response.sendRedirect("/cas");
            return;
        }
        else {
            AuthenticatedPrincipal principal = new AuthenticatedPrincipal(casUser.getUid());
            principal.setAdminPrincipal(casUser.isAdmin);
            super.setPrincipal(request, principal);
            super.setAuthStateValue(request, authStateValue);
            chain.doFilter(request, response);
        }
    }
View Full Code Here

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

   
    // Is this our bad user?
    if (BAD_USER.equals(username)) {
      return null;
    }
    return new AuthenticatedPrincipal(username);
  }
View Full Code Here

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 {
    super.setAuthStateValue(request, authStateValue);
    AuthenticatedPrincipal principal = getAuthenticatedPrincipal();
    super.setPrincipal(request, principal);
    chain.doFilter(request, response);
  }
View Full Code Here

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

    super.setPrincipal(request, principal);
    chain.doFilter(request, response);
  }

  protected AuthenticatedPrincipal getAuthenticatedPrincipal() {
    return new AuthenticatedPrincipal("noop");
  }
View Full Code Here

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

*/
public class NoopAdminAuthenticator extends NoopAuthenticator {

  @Override
  protected AuthenticatedPrincipal getAuthenticatedPrincipal() {
    AuthenticatedPrincipal principal = super.getAuthenticatedPrincipal();
    principal.setAdminPrincipal(true);
    return principal;
  }
View Full Code Here

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

  private AccessToken createAccessToken(AuthorizationRequest request, boolean isImplicitGrant) {
    Client client = request.getClient();
    long expireDuration = client.getExpireDuration();
    long expires = (expireDuration == 0L ? 0L : (System.currentTimeMillis() + (1000 * expireDuration)));
    String refreshToken = (client.isUseRefreshTokens() && !isImplicitGrant) ? getTokenValue(true) : null;
    AuthenticatedPrincipal principal = request.getPrincipal();
    AccessToken token = new AccessToken(getTokenValue(false), principal, client, expires, request.getGrantedScopes(), refreshToken);
    return accessTokenRepository.save(token);
  }
View Full Code Here

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

 
  private AuthorizationRequest clientCredentialToken(AccessTokenRequest accessTokenRequest) {
    AuthorizationRequest request =  new AuthorizationRequest();
    request.setClient(accessTokenRequest.getClient());
    // We have to construct a AuthenticatedPrincipal on-the-fly as there is only key-secret authentication
    request.setPrincipal(new AuthenticatedPrincipal(request.getClient().getClientId()));
    // Get scopes (either from request or the client's default set)
    request.setGrantedScopes(accessTokenRequest.getScopeList());
    return request;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.