use of org.xdi.oxauth.model.jwk.JSONWebKey in project oxAuth by GluuFederation.
the class JwkRestWebServiceHttpTest method requestClientJwks.
@Parameters({ "clientJwksUri" })
@Test
public void requestClientJwks(final String clientJwksUri) throws Exception {
showTitle("requestJwks");
JwkClient jwkClient = new JwkClient(clientJwksUri);
JwkResponse response = jwkClient.exec();
showClient(jwkClient);
assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity());
assertNotNull(response.getEntity(), "Unexpected result: entity is null");
assertNotNull(response.getJwks(), "Unexpected result: jwks is null");
assertNotNull(response.getJwks().getKeys(), "Unexpected result: keys is null");
assertTrue(response.getJwks().getKeys().size() > 0, "Unexpected result: keys is empty");
for (JSONWebKey JSONWebKey : response.getJwks().getKeys()) {
assertNotNull(JSONWebKey.getKid(), "Unexpected result: kid is null");
assertNotNull(JSONWebKey.getUse(), "Unexpected result: use is null");
}
}
use of org.xdi.oxauth.model.jwk.JSONWebKey in project oxAuth by GluuFederation.
the class JwkResponse method getPublicKey.
@Deprecated
public PublicKey getPublicKey(String keyId) {
PublicKey publicKey = null;
JSONWebKey JSONWebKey = getKeyValue(keyId);
if (JSONWebKey != null) {
switch(JSONWebKey.getKty()) {
case RSA:
publicKey = new RSAPublicKey(JSONWebKey.getN(), JSONWebKey.getE());
break;
case EC:
publicKey = new ECDSAPublicKey(JSONWebKey.getAlg(), JSONWebKey.getX(), JSONWebKey.getY());
break;
default:
break;
}
}
return publicKey;
}
use of org.xdi.oxauth.model.jwk.JSONWebKey in project oxAuth by GluuFederation.
the class JwkResponse method getKeys.
public List<JSONWebKey> getKeys(SignatureAlgorithm algorithm) {
List<JSONWebKey> jsonWebKeys = new ArrayList<JSONWebKey>();
if (SignatureAlgorithmFamily.RSA.equals(algorithm.getFamily())) {
for (JSONWebKey jsonWebKey : jwks.getKeys()) {
if (jsonWebKey.getAlg().equals(algorithm)) {
jsonWebKeys.add(jsonWebKey);
}
}
} else if (SignatureAlgorithmFamily.EC.equals(algorithm.getFamily())) {
for (JSONWebKey jsonWebKey : jwks.getKeys()) {
if (jsonWebKey.getAlg().equals(algorithm)) {
jsonWebKeys.add(jsonWebKey);
}
}
}
Collections.sort(jsonWebKeys);
return jsonWebKeys;
}
use of org.xdi.oxauth.model.jwk.JSONWebKey in project oxAuth by GluuFederation.
the class JwkRestWebServiceHttpTest method requestJwks.
@Test
public void requestJwks() throws Exception {
showTitle("requestJwks");
JwkClient jwkClient = new JwkClient(jwksUri);
JwkResponse response = jwkClient.exec();
showClient(jwkClient);
assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity());
assertNotNull(response.getEntity(), "Unexpected result: entity is null");
assertNotNull(response.getJwks(), "Unexpected result: jwks is null");
assertNotNull(response.getJwks().getKeys(), "Unexpected result: keys is null");
assertTrue(response.getJwks().getKeys().size() > 0, "Unexpected result: keys is empty");
for (JSONWebKey JSONWebKey : response.getJwks().getKeys()) {
assertNotNull(JSONWebKey.getKid(), "Unexpected result: kid is null");
assertNotNull(JSONWebKey.getUse(), "Unexpected result: use is null");
}
}
Aggregations