Search in sources :

Example 6 with JSONWebKey

use of org.gluu.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(SignatureAlgorithm.fromString(JSONWebKey.getAlg().getParamName()), JSONWebKey.getX(), JSONWebKey.getY());
                break;
            default:
                break;
        }
    }
    return publicKey;
}
Also used : JSONWebKey(org.gluu.oxauth.model.jwk.JSONWebKey) RSAPublicKey(org.gluu.oxauth.model.crypto.signature.RSAPublicKey) PublicKey(org.gluu.oxauth.model.crypto.PublicKey) ECDSAPublicKey(org.gluu.oxauth.model.crypto.signature.ECDSAPublicKey) RSAPublicKey(org.gluu.oxauth.model.crypto.signature.RSAPublicKey) ECDSAPublicKey(org.gluu.oxauth.model.crypto.signature.ECDSAPublicKey)

Aggregations

JSONWebKey (org.gluu.oxauth.model.jwk.JSONWebKey)6 Test (org.testng.annotations.Test)3 ArrayList (java.util.ArrayList)2 BaseTest (org.gluu.oxauth.BaseTest)2 JwkClient (org.gluu.oxauth.client.JwkClient)2 JwkResponse (org.gluu.oxauth.client.JwkResponse)2 JSONWebKeySet (org.gluu.oxauth.model.jwk.JSONWebKeySet)2 JSONObject (org.json.JSONObject)2 RSAKey (com.nimbusds.jose.jwk.RSAKey)1 IOException (java.io.IOException)1 PrivateKey (java.security.PrivateKey)1 PublicKey (java.security.PublicKey)1 Signature (java.security.Signature)1 X509Certificate (java.security.cert.X509Certificate)1 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)1 ParseException (java.text.ParseException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 AppConfiguration (org.gluu.oxauth.model.configuration.AppConfiguration)1 AbstractCryptoProvider (org.gluu.oxauth.model.crypto.AbstractCryptoProvider)1 PublicKey (org.gluu.oxauth.model.crypto.PublicKey)1