Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.Client


    assertEquals(ValidationResponse.VALID, response);
    assertEquals(client, accessTokenRequest.getClient());
  }

  private Client createClient(String clientId) {
    Client client = new Client();
    client.setName("Client App");
    client.setClientId(clientId);
    client.setRedirectUris(Arrays.asList("http://gothere.nl", "http://gohere.nl"));
    client.setScopes(Arrays.asList("read","update"));
    return client;
  }
View Full Code Here


                          @PathParam("clientId") Long id) {
    Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_READ));
    if (validateScopeResponse != null) {
      return validateScopeResponse;
    }
    Client client = getClientByResourceServer(request, id, resourceServerId);
    return response(client);
  }
View Full Code Here

    client.setResourceServer(resourceServer);
    client.setClientId(generateClientId(client));
    client.setSecret(client.isAllowedImplicitGrant() ? null : generateSecret());

    Client clientSaved;

    try {
      clientSaved = clientRepository.save(client);
    } catch (RuntimeException e) {
      return buildErrorResponse(e);
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("Saved client: {}", clientSaved);
    }
    final URI uri = UriBuilder.fromPath("{clientId}.json").build(clientSaved.getId());
    return Response.created(uri).entity(clientSaved).build();
  }
View Full Code Here

    Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_WRITE));
    if (validateScopeResponse != null) {
      return validateScopeResponse;
    }

    Client client = getClientByResourceServer(request, id, resourceServerId);

    if (client == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }
    if (LOG.isDebugEnabled()) {
View Full Code Here

      return validateScopeResponse;
    }

    ResourceServer resourceServer = getResourceServer(request, resourceServerId);

    final Client clientFromStore = clientRepository.findByIdAndResourceServer(id, resourceServer);
    if (clientFromStore == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    // Copy over read-only fields
    newOne.setResourceServer(resourceServer);
    newOne.setClientId(clientFromStore.getClientId());
    newOne.setSecret(newOne.isAllowedImplicitGrant() ? null : clientFromStore.getSecret());

    Client savedInstance;
    try {
      savedInstance = clientRepository.save(newOne);
    } catch (RuntimeException e) {
      return buildErrorResponse(e);
    }
View Full Code Here

    try {
      validateAuthorizationRequest(authorizationRequest);

      String responseType = validateResponseType(authorizationRequest);

      Client client = validateClient(authorizationRequest);
      authorizationRequest.setClient(client);

      String redirectUri = determineRedirectUri(authorizationRequest, responseType, client);
      authorizationRequest.setRedirectUri(redirectUri);
View Full Code Here

  @POST
  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) {
      ValidationResponse validationResponse = e.v;
      return Response.status(Status.BAD_REQUEST).entity(new ErrorResponse(validationResponse.getValue(), validationResponse.getDescription())).build();
    }
    AccessToken token = accessTokenRepository.findByTokenAndClient(accessToken, client);
    if (token == null) {
      LOG.info("Access token {} not found for client '{}'. Will return OK however.", accessToken, client.getClientId());
      return Response.ok().build();
    }
    accessTokenRepository.delete(token);
    return Response.ok().build();
  }
View Full Code Here

    return redirectUri;
  }

  protected Client validateClient(AuthorizationRequest authorizationRequest) {
    String clientId = authorizationRequest.getClientId();
    Client client = StringUtils.isBlank(clientId) ? null : clientRepository.findByClientId(clientId);
    if (client == null) {
      throw new ValidationResponseException(UNKNOWN_CLIENT_ID);
    }
    if (!client.isAllowedImplicitGrant()
        && authorizationRequest.getResponseType().equals(IMPLICIT_GRANT_RESPONSE_TYPE)) {
      throw new ValidationResponseException(IMPLICIT_GRANT_NOT_PERMITTED);
    }
    return client;
  }
View Full Code Here

    return Response.ok().build();
  }

  protected Client validateClient(BasicAuthCredentials credentials) {
    String clientId = credentials.getUsername();
    Client client = StringUtils.isBlank(clientId) ? null : clientRepository.findByClientId(clientId);
    if (client == null) {
      throw new ValidationResponseException(UNKNOWN_CLIENT_ID);
    } else if (!client.verifySecret(credentials.getPassword())) {
      throw new ValidationResponseException(UNAUTHORIZED_CLIENT);
    }
    return client;
  }
View Full Code Here

    }
  }
 
  protected void validateClient(AccessTokenRequest accessTokenRequest,
      BasicAuthCredentials clientCredentials) {
    Client client = null;
   
    // Were we given client credentials via basic auth?
    if (!clientCredentials.isNull()) {
      // Confirm that the credentials are valid and use them to get the client
      if (!clientCredentials.isValid()) {
View Full Code Here

TOP

Related Classes of org.surfnet.oaaas.model.Client

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.