Package org.surfnet.oaaas.auth.principal

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


  @GET
  public Response verifyToken(@HeaderParam(HttpHeaders.AUTHORIZATION)
                              String authorization, @QueryParam("access_token")
                              String accessToken) throws IOException {

    BasicAuthCredentials credentials =
        BasicAuthCredentials.createCredentialsFromHeader(authorization);

    if (LOG.isDebugEnabled()) {
      LOG.debug("Incoming verify-token request, access token: {}, credentials from authorization header: {}", accessToken, credentials);
    }

    ResourceServer resourceServer = getResourceServer(credentials);
    if (resourceServer == null || !resourceServer.getSecret().equals(credentials.getPassword())) {
      LOG.warn("For access token {}: Resource server not found for credentials {}. Responding with 401 in VerifyResource#verifyToken.", accessToken, credentials);
      return unauthorized();
    }

    AccessToken token = accessTokenRepository.findByToken(accessToken);
View Full Code Here


  public Response revokeAccessToken(@HeaderParam("Authorization") String authorization,
                                    final MultivaluedMap<String, String> formParameters) {
    String accessToken;
    Client client;
    AccessTokenRequest accessTokenRequest = AccessTokenRequest.fromMultiValuedFormParameters(formParameters);
    BasicAuthCredentials credentials = getClientCredentials(authorization, accessTokenRequest);
    try {
      client = validateClient(credentials);
      List<String> params = formParameters.get("token");
      accessToken = CollectionUtils.isEmpty(params) ? null : params.get(0);
    } catch (ValidationResponseException e) {
View Full Code Here

    return client;
  }

  private BasicAuthCredentials getClientCredentials(String authorization, AccessTokenRequest accessTokenRequest) {
    return StringUtils.isBlank(authorization) ?
        new BasicAuthCredentials(accessTokenRequest.getClientId(),
                                 accessTokenRequest.getClientSecret())
        : BasicAuthCredentials.createCredentialsFromHeader(authorization);
  }
View Full Code Here

  public Response token(@HeaderParam("Authorization") String authorization,
          final MultivaluedMap<String, String> formParameters) {
    // Convert incoming parameters into internal form and validate them
    AccessTokenRequest accessTokenRequest =
            AccessTokenRequest.fromMultiValuedFormParameters(formParameters);
    BasicAuthCredentials credentials =
        BasicAuthCredentials.createCredentialsFromHeader(authorization);

    ValidationResponse vr = oAuth2Validator.validate(accessTokenRequest, credentials);
    if (!vr.valid()) {
      return sendErrorResponse(vr);
View Full Code Here

TOP

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

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.