예제 #1
0
  @Test
  public void testAppLoad() throws Exception {
    clearCache();
    startDeployment();
    init();
    stopDeployment();
    startDeployment();
    ResteasyClient client = new ResteasyClientBuilder().build();
    WebTarget target = client.target(generateBaseUrl());
    SkeletonKeyAdminClient admin =
        new SkeletonKeyClientBuilder().username("wburke").password("geheim").idp(target).admin();

    StoredUser newUser = new StoredUser();
    newUser.setName("John Smith");
    newUser.setUsername("jsmith");
    newUser.setEnabled(true);
    Map creds = new HashMap();
    creds.put("password", "foobar");
    newUser.setCredentials(creds);
    Response response = admin.users().create(newUser);
    User user = response.readEntity(User.class);
    response = admin.roles().create("user");
    Role role = response.readEntity(Role.class);
    Projects projects = admin.projects().query("Skeleton Key");
    Project project = projects.getList().get(0);
    admin.projects().addUserRole(project.getId(), user.getId(), role.getId());

    admin =
        new SkeletonKeyClientBuilder().username("jsmith").password("foobar").idp(target).admin();
    response = admin.roles().create("error");
    Assert.assertEquals(403, response.getStatus());
    stopDeployment();
  }
예제 #2
0
  @Test
  public void testSignedAuth() throws Exception {
    // Use our own providerFactory to test json context provider
    ResteasyProviderFactory providerFactory = new ResteasyProviderFactory();
    RegisterBuiltin.register(providerFactory);
    ResteasyClient client = new ResteasyClient(providerFactory);
    WebTarget target = client.target(generateBaseUrl());
    SkeletonKeyAdminClient admin =
        new SkeletonKeyClientBuilder().username("wburke").password("geheim").idp(target).admin();

    StoredUser newUser = new StoredUser();
    newUser.setName("John Smith");
    newUser.setUsername("jsmith");
    newUser.setEnabled(true);
    Map creds = new HashMap();
    creds.put("password", "foobar");
    newUser.setCredentials(creds);
    Response response = admin.users().create(newUser);
    User user = response.readEntity(User.class);
    response = admin.roles().create("user");
    Role role = response.readEntity(Role.class);
    Projects projects = admin.projects().query("Skeleton Key");
    Project project = projects.getList().get(0);
    admin.projects().addUserRole(project.getId(), user.getId(), role.getId());

    String signed =
        new SkeletonKeyClientBuilder()
            .username("jsmith")
            .password("foobar")
            .idp(target)
            .obtainSignedToken("Skeleton Key");
    System.out.println(signed);
    PKCS7SignatureInput input = new PKCS7SignatureInput(signed);
    input.setCertificate(certificate);
    Assert.assertTrue(input.verify());
  }