use of org.keycloak.jose.jws.JWSBuilder in project keycloak by keycloak.
the class RSAVerifierTest method testExpirationBad.
@Test
public void testExpirationBad() {
token.expiration(Time.currentTime() - 100);
String encoded = new JWSBuilder().jsonContent(token).rsa256(idpPair.getPrivate());
AccessToken v = null;
try {
v = verifySkeletonKeyToken(encoded);
Assert.fail();
} catch (VerificationException ignored) {
}
}
use of org.keycloak.jose.jws.JWSBuilder in project keycloak by keycloak.
the class RSAVerifierTest method testNotBeforeBad.
@Test
public void testNotBeforeBad() {
token.notBefore(Time.currentTime() + 100);
String encoded = new JWSBuilder().jsonContent(token).rsa256(idpPair.getPrivate());
AccessToken v = null;
try {
v = verifySkeletonKeyToken(encoded);
Assert.fail();
} catch (VerificationException ignored) {
System.out.println(ignored.getMessage());
}
}
use of org.keycloak.jose.jws.JWSBuilder in project keycloak by keycloak.
the class RSAVerifierTest method testExpirationGood.
@Test
public void testExpirationGood() throws Exception {
token.expiration(Time.currentTime() + 100);
String encoded = new JWSBuilder().jsonContent(token).rsa256(idpPair.getPrivate());
AccessToken v = null;
try {
v = verifySkeletonKeyToken(encoded);
} catch (VerificationException ignored) {
throw ignored;
}
}
use of org.keycloak.jose.jws.JWSBuilder in project keycloak by keycloak.
the class RSAVerifierTest method testTokenAuth.
@Test
public void testTokenAuth() {
token = new AccessToken();
token.subject("CN=Client").issuer("http://localhost:8080/auth/realms/demo").addAccess("service").addRole("admin").verifyCaller(true);
token.setEmail("bill@jboss.org");
String encoded = new JWSBuilder().jsonContent(token).rsa256(idpPair.getPrivate());
System.out.println("token size: " + encoded.length());
AccessToken v = null;
try {
v = verifySkeletonKeyToken(encoded);
Assert.fail();
} catch (VerificationException ignored) {
}
}
use of org.keycloak.jose.jws.JWSBuilder in project keycloak by keycloak.
the class RSAVerifierTest method testSimpleVerification.
@Test
public void testSimpleVerification() throws Exception {
String encoded = new JWSBuilder().jsonContent(token).rsa256(idpPair.getPrivate());
System.out.print("encoded size: " + encoded.length());
AccessToken token = verifySkeletonKeyToken(encoded);
Assert.assertTrue(token.getResourceAccess("service").getRoles().contains("admin"));
Assert.assertEquals("CN=Client", token.getSubject());
}
Aggregations