Examples of PublicJsonWebKey


Examples of org.jose4j.jwk.PublicJsonWebKey

                "MsFfI_K767G9C9Azp73gKZD0DyUn1mn0WW5LmyX_yJ-3AROq8p1WZBfG-ZyJ61" +
                "95_JGG2m9Csg" +
                "." +
                "WCCkNa-x4BeB9hIDIfFuhg";

        PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(jwkJson);

        // verify that we can decrypt it
        JsonWebEncryption jwe = new JsonWebEncryption();
        jwe.setCompactSerialization(exampleCompactSerialization);
        jwe.setKey(jwk.getPrivateKey());
        assertThat(jwePlaintext, equalTo(jwe.getPlaintextString()));
    }
View Full Code Here

Examples of org.jose4j.jwk.PublicJsonWebKey

        jceProviderTestSupport.runWithBouncyCastleProviderIfNeeded(new RunnableTest()
        {
            @Override
            public void runTest() throws Exception
            {
                PublicJsonWebKey encJwk = PublicJsonWebKey.Factory.newPublicJwk(figure62RsaJwkJsonString);

                JsonWebEncryption jwe = new JsonWebEncryption();
                jwe.setCompactSerialization(jweCs);
                jwe.setKey(encJwk.getPrivateKey());
                String jwePayload = jwe.getPayload();

                PublicJsonWebKey sigJwk = PublicJsonWebKey.Factory.newPublicJwk(sigJwkJson);

                JsonWebSignature jws = new JsonWebSignature();
                jws.setCompactSerialization(jwePayload);
                jws.setKey(sigJwk.getPublicKey());
                assertTrue(jws.verifySignature());
                String payload = jws.getPayload();
                assertThat(expectedPayload, equalTo(payload));
            }
        });
View Full Code Here

Examples of org.jose4j.jwk.PublicJsonWebKey

                " \"crv\":\"P-256\",\n" +
                " \"x\":\"weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ\",\n" +
                " \"y\":\"e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck\",\n" +
                " \"d\":\"VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw\"\n" +
                "}";
        PublicJsonWebKey receiverJwk = PublicJsonWebKey.Factory.newPublicJwk(receiverJwkJson);

        jwe.setAlgorithmHeaderValue(alg);
        jwe.setEncryptionMethodHeaderParameter(enc);
        String plaintext = "Gambling is illegal at Bushwood sir, and I never slice.";
        jwe.setPlaintext(plaintext);

        jwe.setKey(receiverJwk.getPublicKey());

        String compactSerialization = jwe.getCompactSerialization();

        log.debug("JWE w/ " + alg + " & " + enc +": " + compactSerialization);

        JsonWebEncryption receiverJwe = new JsonWebEncryption();
        receiverJwe.setCompactSerialization(compactSerialization);
        receiverJwe.setKey(receiverJwk.getPrivateKey());

        assertEquals(plaintext, receiverJwe.getPlaintextString());
    }
View Full Code Here

Examples of org.jose4j.jwk.PublicJsonWebKey

        // JSON representation of the header)
        jws = new JsonWebSignature();
        jws.setPayload(jwsPayload);
        jws.setAlgorithmHeaderValue(alg);
        jws.setKeyIdHeaderValue(jwk.getKeyId());
        PublicJsonWebKey rsaJwk = (PublicJsonWebKey) jwk;
        jws.setKey(rsaJwk.getPrivateKey());
        String compactSerialization = jws.getCompactSerialization();
        assertThat(jwsCompactSerialization, equalTo(compactSerialization));
    }
View Full Code Here

Examples of org.jose4j.jwk.PublicJsonWebKey

        PbkdfKey key = new PbkdfKey(PASSWORD);
        JsonWebEncryption jwe = new JsonWebEncryption();
        jwe.setCompactSerialization(CS);
        jwe.setKey(key);
        String payload = jwe.getPayload();
        PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(payload);
        assertThat("juliet@capulet.lit", is(equalTo(jwk.getKeyId())));
        assertThat(RsaJsonWebKey.KEY_TYPE, is(equalTo(jwk.getKeyType())));
        assertThat(Use.ENCRYPTION, is(equalTo(jwk.getUse())));
    }
View Full Code Here

Examples of org.jose4j.jwk.PublicJsonWebKey

        String pem = x5u.toPem(x509Certificate);
        assertTrue(pem.charAt(BaseNCodec.PEM_CHUNK_SIZE) == '\r');
        assertTrue(pem.charAt(BaseNCodec.PEM_CHUNK_SIZE + 1) == '\n');

        PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(x509Certificate.getPublicKey());
        jwk.setCertificateChain(x509Certificate);
        String jsonJwk = jwk.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY);

        PublicJsonWebKey jwkFromJson = PublicJsonWebKey.Factory.newPublicJwk(jsonJwk);
        assertEquals(x509Certificate.getPublicKey(), jwkFromJson.getPublicKey());
        assertEquals(x509Certificate, jwkFromJson.getLeafCertificate());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.