Package org.jose4j.keys

Examples of org.jose4j.keys.RsaKeyUtil


*/
public class RsaJwkGenerator
{
    public static RsaJsonWebKey generateJwk(int bits) throws JoseException
    {
        RsaKeyUtil keyUtil = new RsaKeyUtil();
        KeyPair keyPair = keyUtil.generateKeyPair(bits);
        RsaJsonWebKey rsaJwk = (RsaJsonWebKey) PublicJsonWebKey.Factory.newPublicJwk(keyPair.getPublic());
        rsaJwk.setPrivateKey(keyPair.getPrivate());
        return rsaJwk;
    }
View Full Code Here


        BigInteger modulus = getBigIntFromBase64UrlEncodedParam(params, MODULUS_MEMBER_NAME);

        BigInteger publicExponent = getBigIntFromBase64UrlEncodedParam(params, EXPONENT_MEMBER_NAME);

        RsaKeyUtil rsaKeyUtil = new RsaKeyUtil();
        key = rsaKeyUtil.publicKey(modulus, publicExponent);
        checkForBareKeyCertMismatch();

        if (params.containsKey(PRIVATE_EXPONENT_MEMBER_NAME))
        {
            BigInteger d = getBigIntFromBase64UrlEncodedParam(params, PRIVATE_EXPONENT_MEMBER_NAME);

            if (params.containsKey(FIRST_PRIME_FACTOR_MEMBER_NAME))
            {
                BigInteger p = getBigIntFromBase64UrlEncodedParam(params, FIRST_PRIME_FACTOR_MEMBER_NAME);
                BigInteger q = getBigIntFromBase64UrlEncodedParam(params, SECOND_PRIME_FACTOR_MEMBER_NAME);
                BigInteger dp = getBigIntFromBase64UrlEncodedParam(params, FIRST_FACTOR_CRT_EXPONENT_MEMBER_NAME);
                BigInteger dq = getBigIntFromBase64UrlEncodedParam(params, SECOND_FACTOR_CRT_EXPONENT_MEMBER_NAME);
                BigInteger qi = getBigIntFromBase64UrlEncodedParam(params, FIRST_CRT_COEFFICIENT_MEMBER_NAME);
                privateKey = rsaKeyUtil.privateKey(modulus, publicExponent, d, p, q, dp, dq, qi);
            }
            else
            {
                privateKey = rsaKeyUtil.privateKey(modulus, d);
            }
        }
    }
View Full Code Here

*/
public class RsaUsingShaTest extends TestCase
{
    public void testRoundTrips() throws JoseException
    {
        RsaKeyUtil keyUtil = new RsaKeyUtil();
        KeyPair pair = keyUtil.generateKeyPair(KeyValidationSupport.MIN_RSA_KEY_LENGTH);

        PrivateKey priv1 = pair.getPrivate();
        PublicKey pub1 = pair.getPublic();
        PrivateKey priv2 = ExampleRsaKeyFromJws.PRIVATE_KEY;
        PublicKey pub2 = ExampleRsaKeyFromJws.PUBLIC_KEY;
View Full Code Here

        JwsTestSupport.testBasicRoundTrip("PAYLOAD!", AlgorithmIdentifiers.RSA_USING_SHA512, priv1, pub1, priv2, pub2);
    }

    public void testBadKeys() throws JoseException
    {
        RsaKeyUtil keyUtil = new RsaKeyUtil();

        KeyPair pair = keyUtil.generateKeyPair(1024);
        PublicKey pub = pair.getPublic();
        PrivateKey priv = pair.getPrivate();

        String cs256 = "eyJhbGciOiJSUzI1NiJ9.UEFZTE9BRCEhIQ.ln8y7TlxyR0jLemqdVybaWYmcS2nIseDEqKNJ1J-mM6TXRWjfFKsJr1kzBgh1nKHbVT6q_cgSoPLsb-9WGvpUMkt7N0NxqT2Vffcz_2HMwKvWDJZSjbuj6_XHSJye7gqySHiI2gOggSaYyIqnua-_kOmVGmgncrzwm2YRPgwLXAl9zB0GNul7lNGDvs193WbgOJ-rKGj515NBfqb7cV2VjQg7vsrnzIWT8FKcrQ5TYNXMrybzK5Q_1BNIxOVlrTsdh_pcUNiJvKKgC3_5PBHkhaJrJlxfwmi77YW8ezwXpFKdzbh8cKKzO0ZhamOOJns99HPPot4jr26JCERzBVF3g";
        String cs384 = "eyJhbGciOiJSUzM4NCJ9.UEFZTE9BRCEhIQ.E27QWhxodHU2vB-C3eKr4SQR8YF1jptmDrw7LRtQF1105bUk_WQqI8dCZcJDBsHdJ11O7JEmnRPJLiZd50eFnzcvZsAN5gh7q2eNnxCPuXjH2MoyRlIt6-8aSs-Es0l66Sz4slyOGjqRBRBqHcr7bu6gjo7mBh3XzS8ORnu5zn9Gj5XWr3emX5vwTq66UCfkyf6a2aa4knmYbGW0JiELVWU4rU2UhY5NjhxDW4omlOGiLpNhaX3LAgvA5nvNLi8HFlhVG8-GO4malIjj6rFdpwpZXm3G-sMbpWCcNyu3DUxRDKgjIWjX2SpGLqgXYZEMcAjmF2CA3tsxy43aUalMYQ";
View Full Code Here

TOP

Related Classes of org.jose4j.keys.RsaKeyUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.