Examples of JwtHeaders


Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

        this.supportedAlgorithms = supportedAlgorithms;
    }
   
    protected JwtHeaders prepareHeaders(JwtHeaders headers) {
        if (headers == null) {
            headers = new JwtHeaders();
        }
        String algo = headers.getAlgorithm();
        if (algo != null) {
            checkAlgorithm(algo);
        } else {
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

        }
        this.plainJwsPayload = plainJwsPayload;
    }
    public JwtHeaders getHeaders() {
        if (headers == null) {
            headers = new JwtHeaders();
        }
        return headers;
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

            if (mt != null) {
                ctString = JAXRSUtils.mediaTypeToString(mt);
            }
        }
        if (useJwsOutputStream) {
            JwtHeaders headers = new JwtHeaders();
            JwsSignature jwsSignature = getInitializedSigProvider().createJwsSignature(headers);
            if (ctString != null) {
                headers.setContentType(ctString);
            }
            JwsOutputStream jwsStream = new JwsOutputStream(actualOs, jwsSignature);
            byte[] headerBytes = writer.headersToJson(headers).getBytes("UTF-8");
            Base64UrlUtility.encodeAndStream(headerBytes, 0, headerBytes.length, jwsStream);
            jwsStream.write(new byte[]{'.'});
                       
            Base64UrlOutputStream base64Stream = new Base64UrlOutputStream(jwsStream);
            ctx.setOutputStream(base64Stream);
            ctx.proceed();
            base64Stream.flush();
            jwsStream.flush();
        } else {
            CachedOutputStream cos = new CachedOutputStream();
            ctx.setOutputStream(cos);
            ctx.proceed();
           
            JwtHeaders headers = new JwtHeaders();
            if (ctString != null) {
                headers.setContentType(ctString);
            }
            JwsCompactProducer p = new JwsCompactProducer(headers, new String(cos.getBytes(), "UTF-8"));
            writeJws(p, actualOs);
        }
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

        + "hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB"
        + "p0igcN_IoypGlUPQGe77Rw";
    
    @Test
    public void testWriteJwsSignedByMacSpecExample() throws Exception {
        JwtHeaders headers = new JwtHeaders(Algorithm.HmacSHA256.getJwtName());
        JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
        jws.signWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY));
       
        assertEquals(ENCODED_TOKEN_SIGNED_BY_MAC, jws.getSignedEncodedJws());
       
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

       
    }
   
    @Test
    public void testWriteReadJwsUnsigned() throws Exception {
        JwtHeaders headers = new JwtHeaders(JwtConstants.PLAIN_TEXT_ALGO);
       
        JwtClaims claims = new JwtClaims();
        claims.setIssuer("https://jwt-idp.example.com");
        claims.setSubject("mailto:mike@example.com");
        claims.setAudience("https://jwt-rp.example.net");
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

    @Test
    public void testReadJwsSignedByMacSpecExample() throws Exception {
        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_MAC);
        assertTrue(jws.verifySignatureWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY)));
        JwtToken token = jws.getJwtToken();
        JwtHeaders headers = token.getHeaders();
        assertEquals(JwtConstants.TYPE_JWT, headers.getType());
        assertEquals(Algorithm.HmacSHA256.getJwtName(), headers.getAlgorithm());
        validateSpecClaim(token.getClaims());
    }
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

                new String[]{JsonWebKey.KEY_OPER_SIGN, JsonWebKey.KEY_OPER_VERIFY});
        doTestWriteJwsWithJwkSignedByMac(map);
    }
   
    private void doTestWriteJwsWithJwkSignedByMac(Object jsonWebKey) throws Exception {
        JwtHeaders headers = new JwtHeaders(Algorithm.HmacSHA256.getJwtName());
       
        headers.setHeader(JwtConstants.HEADER_JSON_WEB_KEY, jsonWebKey);
       
        JwtClaims claims = new JwtClaims();
        claims.setIssuer("joe");
        claims.setExpiryTime(1300819380);
        claims.setClaim("http://example.com/is_root", Boolean.TRUE);
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

    @Test
    public void testReadJwsWithJwkSignedByMac() throws Exception {
        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_WITH_JSON_KEY_SIGNED_BY_MAC);
        assertTrue(jws.verifySignatureWith(new HmacJwsSignatureProvider(ENCODED_MAC_KEY)));
        JwtToken token = jws.getJwtToken();
        JwtHeaders headers = token.getHeaders();
        assertEquals(JwtConstants.TYPE_JWT, headers.getType());
        assertEquals(Algorithm.HmacSHA256.getJwtName(), headers.getAlgorithm());
       
        JsonWebKey key = headers.getJsonWebKey();
        assertEquals(JsonWebKey.KEY_TYPE_OCTET, key.getKeyType());
        List<String> keyOps = key.getKeyOperation();
        assertEquals(2, keyOps.size());
        assertEquals(JsonWebKey.KEY_OPER_SIGN, keyOps.get(0));
        assertEquals(JsonWebKey.KEY_OPER_VERIFY, keyOps.get(1));
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

        assertEquals(Boolean.TRUE, claims.getClaim("http://example.com/is_root"));
    }
   
    @Test
    public void testWriteReadJwsSignedByPrivateKey() throws Exception {
        JwtHeaders headers = new JwtHeaders();
        headers.setAlgorithm(Algorithm.SHA256withRSA.getJwtName());
        JwsCompactProducer jws = initSpecJwtTokenWriter(headers);
        PrivateKey key = CryptoUtils.getRSAPrivateKey(RSA_MODULUS_ENCODED, RSA_PRIVATE_EXPONENT_ENCODED);
        jws.signWith(new PrivateKeyJwsSignatureProvider(key));
       
        assertEquals(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY, jws.getSignedEncodedJws());
View Full Code Here

Examples of org.apache.cxf.rs.security.oauth2.jwt.JwtHeaders

    public void testReadJwsSignedByPrivateKey() throws Exception {
        JwsJwtCompactConsumer jws = new JwsJwtCompactConsumer(ENCODED_TOKEN_SIGNED_BY_PRIVATE_KEY);
        RSAPublicKey key = CryptoUtils.getRSAPublicKey(RSA_MODULUS_ENCODED, RSA_PUBLIC_EXPONENT_ENCODED);
        assertTrue(jws.verifySignatureWith(new PublicKeyJwsSignatureVerifier(key)));
        JwtToken token = jws.getJwtToken();
        JwtHeaders headers = token.getHeaders();
        assertEquals(Algorithm.SHA256withRSA.getJwtName(), headers.getAlgorithm());
        validateSpecClaim(token.getClaims());
    }
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.