Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.ResourceOwner


        this.authenticator.authenticate(this.resourceOwner.getUsername(), "bad");
    assertNull(principal);
  }

  private ResourceOwner createResourceOwner(String username) {
    ResourceOwner resourceOwner = new ResourceOwner();
    resourceOwner.setUsername(username);
    resourceOwner.setPassword(PASSWORD);
    return resourceOwner;
  }
View Full Code Here


  @Test
  public void test() {
    ResourceOwnerRepository repo = getRepository(ResourceOwnerRepository.class);

    ResourceOwner ro = repo.findByUsername("emma.blunt");
    assertNotNull("Did not find expected resource owner", ro);
   
    ro = repo.findByUsername("not.here");
    assertNull("Found user that shouldn't be there", ro);
  }
View Full Code Here

  @Inject
  private ResourceOwnerRepository resourceOwnerRepository;

  @Override
  public AuthenticatedPrincipal authenticate(String username, String password) {
    ResourceOwner user = resourceOwnerRepository.findByUsername(username);
    if (user == null) {
      return null;
    }
   
    // Validate password
    if (!user.checkPassword(password)) {
      return null;
    }
    return new AuthenticatedPrincipal(username);
  }
View Full Code Here

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

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

    LOG.debug("New resourceOwner has been saved: {}. ", resourceOwnerSaved);

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

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

    if (resourceOwner == 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;
    }

    ResourceOwner persistedResourceOwner = getResourceOwner(request, id);
    if (persistedResourceOwner == null) {
      return Response.status(Response.Status.NOT_FOUND).build();
    }

    LOG.debug("About to update existing resourceOwner {} with new properties: {}", persistedResourceOwner,
            resourceOwner);

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

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

  private ResourceOwner getResourceOwner(HttpServletRequest request, Long id) {
    ResourceOwner resourceOwner;
    if (isAdminPrincipal(request)) {
      resourceOwner = resourceOwnerRepository.findOne(id);
    } else {
      String owner = getUserId(request);
      resourceOwner = resourceOwnerRepository.findByUsername(owner);
      if (resourceOwner != null && resourceOwner.getId() != id) {
        resourceOwner = null;
      }
    }
    LOG.debug("About to return one resourceServer with id {}: {}", id, resourceOwner);
    return resourceOwner;
View Full Code Here

    if (isAdminPrincipal(request)) {
      resourceOwners = addAll(resourceOwnerRepository.findAll().iterator());
      LOG.debug("About to return all resource owners ({}) for adminPrincipal", resourceOwners.size());
    } else {
      String owner = getUserId(request);
      ResourceOwner resourceOwner = resourceOwnerRepository.findByUsername(owner);
      if (resourceOwner == null) {
        resourceOwners = Collections.emptyList();
      } else {
        resourceOwners = Collections.singletonList(resourceOwner);
      }
View Full Code Here

TOP

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

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.