Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.ResourceServer


   * Create a resourceServer that's ready to be persisted.
   *
   * @return a ResourceServer
   */
  private ResourceServer buildResourceServer() {
    ResourceServer resourceServer = new ResourceServer();
    resourceServer.setContactName("myContactName");
    resourceServer.setDescription("The description");
    resourceServer.setName("the name" + System.currentTimeMillis());
    resourceServer.setKey("the-key-" + System.currentTimeMillis());
    resourceServer.setThumbNailUrl("http://example.com/thumbnail");
    return resourceServer;
  }
View Full Code Here


    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);

    final ConstraintViolation<Client> violation = (ConstraintViolation<Client>) mock(ConstraintViolation.class);
    Set<ConstraintViolation<Client>> violations = Collections.singleton(violation);
    when(validator.validate(client)).thenReturn(violations);
View Full Code Here

    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);
    if (token == null || !resourceServer.containsClient(token.getClient())) {
      LOG.warn("Access token {} not found for resource server '{}'. Responding with 404 in VerifyResource#verifyToken for user {}", accessToken, resourceServer.getName(), credentials);
      return Response.status(Status.NOT_FOUND).entity(new VerifyTokenResponse("not_found")).build();
    }
    if (tokenExpired(token)) {
      LOG.warn("Token {} is expired. Responding with 410 in VerifyResource#verifyToken for user {}", accessToken, credentials);
      return Response.status(Status.GONE).entity(new VerifyTokenResponse("token_expired")).build();
View Full Code Here

    // Read only fields
    newOne.setKey(generateKey());
    newOne.setSecret(generateSecret());
    newOne.setOwner(owner);

    ResourceServer resourceServerSaved;
    try {
      //we run transactional modus, so any constraint violations only occur after the commit of the transaction (to late...)
      validate(newOne);
      resourceServerSaved = resourceServerRepository.save(newOne);
    } catch (Exception e) {
      return buildErrorResponse(e);
    }

    LOG.debug("New resourceServer has been saved: {}. ", resourceServerSaved);

    final URI uri = UriBuilder.fromPath("{resourceServerId}.json").build(resourceServerSaved.getId());
    return Response.created(uri).entity(resourceServerSaved).build();
  }
View Full Code Here

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

    if (resourceServer == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }
    LOG.debug("About to delete resourceServer {}", id);
View Full Code Here

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

    ResourceServer persistedResourceServer = getResourceServer(request, id);
    if (persistedResourceServer == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    // Copy over read-only fields
    resourceServer.setSecret(persistedResourceServer.getSecret());
    resourceServer.setKey(persistedResourceServer.getKey());
    resourceServer.setOwner(getUserId(request));

    pruneClientScopes(resourceServer.getScopes(), persistedResourceServer.getScopes(),
            persistedResourceServer.getClients());
    LOG.debug("About to update existing resourceServer {} with new properties: {}", persistedResourceServer,
            resourceServer);

    ResourceServer savedInstance;
    try {
      //we run transactional modus, so any constraint violations only occur after the commit of the transaction (to late...)
      validate(resourceServer);
      savedInstance = resourceServerRepository.save(resourceServer);
    } catch (Exception e) {
View Full Code Here

  protected String generateSecret() {
    return super.generateRandom();
  }

  private ResourceServer getResourceServer(HttpServletRequest request, Long id) {
    ResourceServer resourceServer;
    if (isAdminPrincipal(request)) {
      resourceServer = resourceServerRepository.findOne(id);
    } else {
      String owner = getUserId(request);
      resourceServer = resourceServerRepository.findByIdAndOwner(id, owner);
View Full Code Here

                         @PathParam("resourceServerId") Long resourceServerId) {
    Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_READ));
    if (validateScopeResponse != null) {
      return validateScopeResponse;
    }
    ResourceServer resourceServer = getResourceServer(request, resourceServerId);
    Iterable<Client> clients = clientRepository.findByResourceServer(resourceServer);
    return response(addAll(clients.iterator()));
  }
View Full Code Here

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

    client.setResourceServer(resourceServer);
    client.setClientId(generateClientId(client));
    client.setSecret(client.isAllowedImplicitGrant() ? null : generateSecret());
View Full Code Here

    Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_WRITE));
    if (validateScopeResponse != null) {
      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();
    }
View Full Code Here

TOP

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

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.