Search in sources :

Example 1 with JwtClaims

use of org.gluu.oxauth.model.jwt.JwtClaims in project oxAuth by GluuFederation.

the class JwkRestWebServiceEmbeddedTest method setClaimTestInt.

@Test
public void setClaimTestInt() {
    try {
        JwtClaims claims = new JwtClaims();
        claims.setClaim("test_claim", 123);
        assertEquals("{\"test_claim\":123}", claims.toJsonObject().toString());
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : JwtClaims(org.gluu.oxauth.model.jwt.JwtClaims) JSONException(org.json.JSONException) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 2 with JwtClaims

use of org.gluu.oxauth.model.jwt.JwtClaims in project oxAuth by GluuFederation.

the class JwkRestWebServiceEmbeddedTest method setClaimTestStringList.

@Test
public void setClaimTestStringList() {
    try {
        JwtClaims claims = new JwtClaims();
        claims.setClaim("test_claim", Arrays.asList("qwe", "asd", "zxc"));
        assertEquals("{\"test_claim\":[\"qwe\",\"asd\",\"zxc\"]}", claims.toJsonObject().toString());
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : JwtClaims(org.gluu.oxauth.model.jwt.JwtClaims) JSONException(org.json.JSONException) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 3 with JwtClaims

use of org.gluu.oxauth.model.jwt.JwtClaims in project oxAuth by GluuFederation.

the class AudienceTest method addAudience_callItTwiceWithSameValue_shouldResultInSingleAudValue.

@Test
public void addAudience_callItTwiceWithSameValue_shouldResultInSingleAudValue() {
    JwtClaims claims = new JwtClaims();
    claims.addAudience("aud1");
    claims.addAudience("aud1");
    assertEquals(claims.getClaimAsString("aud"), "aud1");
}
Also used : JwtClaims(org.gluu.oxauth.model.jwt.JwtClaims) Test(org.testng.annotations.Test)

Example 4 with JwtClaims

use of org.gluu.oxauth.model.jwt.JwtClaims in project oxAuth by GluuFederation.

the class AudienceTest method addAudience_callItTwiceWithDifferentValues_shouldResultInSingleAudValue.

@Test
public void addAudience_callItTwiceWithDifferentValues_shouldResultInSingleAudValue() {
    JwtClaims claims = new JwtClaims();
    claims.addAudience("aud1");
    claims.addAudience("aud2");
    assertEquals(claims.getClaim("aud"), Lists.newArrayList("aud1", "aud2"));
}
Also used : JwtClaims(org.gluu.oxauth.model.jwt.JwtClaims) Test(org.testng.annotations.Test)

Example 5 with JwtClaims

use of org.gluu.oxauth.model.jwt.JwtClaims in project oxAuth by GluuFederation.

the class AudienceTest method setAudience_withAdditionalClaims_shouldResultInAdditionalClaimsPresentinAud.

@Test
public void setAudience_withAdditionalClaims_shouldResultInAdditionalClaimsPresentinAud() {
    JwtClaims claims = new JwtClaims();
    Client client = new Client();
    client.setClientId("clientId");
    client.getAttributes().setAdditionalAudience(Lists.newArrayList("aud1", "aud2"));
    Audience.setAudience(claims, client);
    assertEquals(claims.getClaim("aud"), Lists.newArrayList("clientId", "aud1", "aud2"));
}
Also used : JwtClaims(org.gluu.oxauth.model.jwt.JwtClaims) Client(org.gluu.oxauth.model.registration.Client) Test(org.testng.annotations.Test)

Aggregations

JwtClaims (org.gluu.oxauth.model.jwt.JwtClaims)14 Test (org.testng.annotations.Test)8 JSONException (org.json.JSONException)6 JSONObject (org.json.JSONObject)5 BaseTest (org.gluu.oxauth.BaseTest)4 InvalidJwtException (org.gluu.oxauth.model.exception.InvalidJwtException)3 JwtHeader (org.gluu.oxauth.model.jwt.JwtHeader)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 PublicKey (java.security.PublicKey)2 Jwe (org.gluu.oxauth.model.jwe.Jwe)2 JweEncrypterImpl (org.gluu.oxauth.model.jwe.JweEncrypterImpl)2 Jwt (org.gluu.oxauth.model.jwt.Jwt)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JWEDecrypter (com.nimbusds.jose.JWEDecrypter)1 EncryptedJWT (com.nimbusds.jwt.EncryptedJWT)1 SignedJWT (com.nimbusds.jwt.SignedJWT)1 Key (java.security.Key)1 MessageDigest (java.security.MessageDigest)1 PrivateKey (java.security.PrivateKey)1 SecretKeySpec (javax.crypto.spec.SecretKeySpec)1