Package org.surfnet.oaaas.model

Examples of org.surfnet.oaaas.model.Client


  }

  @Test
  public void scopesShouldBeSubsetOfResourceServerScopes() {

    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);
View Full Code Here


  }


  @Test
  public void get() {
    Client c = putSomeClient();

    final Client returnedFromGet = webResource
        .path(String.valueOf(c.getId()))
        .header("Authorization", authorizationBearer(ACCESS_TOKEN))
        .get(Client.class);

    assertEquals(c.getId(), returnedFromGet.getId());
    assertEquals(c.getAttributes(), returnedFromGet.getAttributes());
  }
View Full Code Here

    Endpoint endpoint = endpointGenerator.generateEndpoint(
            SingleSignOnService.DEFAULT_ELEMENT_NAME, target, openSAMLContext.assertionConsumerUri());

    AuthnRequest authnRequest = authnRequestGenerator.generateAuthnRequest(target, openSAMLContext.assertionConsumerUri());

    Client client = getClientByRequest(authState);
    String spEntityIdBy = client.getAttributes().get(CLIENT_SAML_ENTITY_NAME);

    if (StringUtils.isNotEmpty(spEntityIdBy)) {
      Scoping scoping = scopingBuilder.buildObject();
      scoping.getRequesterIDs().add(createRequesterID(spEntityIdBy));
      authnRequest.setScoping(scoping);
    } else {
      LOG.warn("For Client {} there is no key CLIENT_SAML_ENTITY_NAME configured to identify the SP entity name. NO SCOPING IS APPLIED", client.getClientId());
    }

    CriteriaSet criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIDCriteria(openSAMLContext.entityId()));
    criteriaSet.add(new UsageCriteria(UsageType.SIGNING));
View Full Code Here

    assertEquals(c.getAttributes(), returnedFromGet.getAttributes());
  }

  @Test
  public void put() {
    Client c = buildClient();
    Client putResult = webResource
        .header("Authorization", authorizationBearer(ACCESS_TOKEN))
        .put(Client.class, c);
    assertThat("Server should override provided secret with a generated one",
        putResult.getSecret(),not(equalTo(c.getSecret())));

    assertNotNull(putResult.getId());

    assertEquals(c.getAttributes(), putResult.getAttributes());
  }
View Full Code Here

  public void test() {
    ResourceServerRepository repo = getRepository(ResourceServerRepository.class);
    ClientRepository clientRepo = getRepository(ClientRepository.class);

    ResourceServer rs = repo.findByKey("authorization-server-admin");
    Client client = null;
    assertFalse(rs.containsClient(client));

    client = clientRepo.findByClientId("authorization-server-admin-js-client");
    assertTrue(rs.containsClient(client));
    Set<Client> clients = rs.getClients();
View Full Code Here

    resourceServer.setContactName("contact");
    resourceServer.setScopes(Arrays.asList("read"));
    resourceServer = repo.save(resourceServer);

    // Create and save a client, associated with the resourceServer
    Client c = new Client();
    c.setName("name");
    c.setClientId("clientid");
    c.setSecret(UUID.randomUUID().toString());
    c.setResourceServer(resourceServer);
    resourceServer.setClients(new HashSet(Arrays.asList(c)));
    c = clientRepo.save(c);
    getEntityManager().getTransaction().commit();

    // See that the client can be found
    assertNotNull(clientRepo.findOne(c.getId()));

    long resourceServerId = resourceServer.getId();
    // Remove the resourceServer
    getEntityManager().getTransaction().begin();
    repo.delete(resourceServer);
    getEntityManager().getTransaction().commit();

    // Expect the resource server to be deleted
    assertNull(repo.findOne(resourceServerId));

    // Expect the client to be deleted as well.
    final Client foundClient = clientRepo.findOne(c.getId());
    assertNull(foundClient);
  }
View Full Code Here

    assertEquals(c.getAttributes(), putResult.getAttributes());
  }

  @Test
  public void putInvalidScopes() {
    Client c = buildClient();
    c.setScopes(Arrays.asList("invalidScope", "read", "write"));
    ClientResponse clientResponse = webResource
        .header("Authorization", authorizationBearer(ACCESS_TOKEN))
        .put(ClientResponse.class, c);
    assertThat("Server should not accept a client with scopes that are not a subset of the resourceServers scope",
        clientResponse.getStatus(), equalTo(400));
View Full Code Here

  }

  @Test
  public void testValidateImplicitGrant() {
    reset(clientRepository);
    Client client = createClient("client-app");
    client.setAllowedImplicitGrant(true);
    when(clientRepository.findByClientId(client.getClientId())).thenReturn(client);

    request.setResponseType(OAuth2ValidatorImpl.IMPLICIT_GRANT_RESPONSE_TYPE);
    request.setRedirectUri(" ");
    validate(ValidationResponse.IMPLICIT_GRANT_REDIRECT_URI);
  }
View Full Code Here

  }

  @Test
  public void implicitGrantNoRedirectGivenShouldUseDefault() {
    Client client = createClient("any");
    final String uri = "http://implicit-grant-uri/";
    request.setRedirectUri("");
    client.setRedirectUris(Arrays.asList(uri));
    try {
      final String determinedUri = validator.determineRedirectUri(request,
          OAuth2ValidatorImpl.IMPLICIT_GRANT_RESPONSE_TYPE, client);
      fail();
    } catch (ValidationResponseException e) {
View Full Code Here

    }
  }

  @Test
  public void determineUrlValidImplicitGrant() {
    Client client = createClient("any");
    final String uri = "http://implicit-grant-uri/";
    request.setRedirectUri(uri);
    client.setRedirectUris(Arrays.asList(uri));
    final String determinedUri = validator.determineRedirectUri(request,
        OAuth2ValidatorImpl.IMPLICIT_GRANT_RESPONSE_TYPE, client);
    assertEquals(uri, determinedUri);
  }
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.