public void testSignedAuth() throws Exception
{
// Use our own providerFactory to test json context provider
ResteasyProviderFactory providerFactory = new ResteasyProviderFactory();
RegisterBuiltin.register(providerFactory);
ResteasyClient client = new ResteasyClientBuilder().providerFactory(providerFactory).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());
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());
client.close();
}