Package com.nimbusds.jose.util

Examples of com.nimbusds.jose.util.Base64URL


  private SignedAuthRequestUrlBuilder urlBuilder = new SignedAuthRequestUrlBuilder();

  @Before
  public void prepare() throws NoSuchAlgorithmException, InvalidKeySpecException {

    RSAKey key = new RSAKey(new Base64URL(n), new Base64URL(e), new Base64URL(d), KeyUse.SIGNATURE, null, new Algorithm(alg), kid, null, null, null);
    Map<String, JWK> keys = Maps.newHashMap();
    keys.put("client", key);

    signingAndValidationService = new DefaultJwtSigningAndValidationService(keys);
    signingAndValidationService.setDefaultSignerKeyId("client");
View Full Code Here


    Set<String> responseTypes = request.getResponseTypes();

    if (responseTypes.contains("token")) {
      // calculate the token hash
      Base64URL at_hash = IdTokenHashUtils.getAccessTokenHash(signingAlg, accessToken);
      idClaims.setClaim("at_hash", at_hash);
    }

    if (client.getIdTokenEncryptedResponseAlg() != null && !client.getIdTokenEncryptedResponseAlg().equals(Algorithm.NONE)
        && client.getIdTokenEncryptedResponseEnc() != null && !client.getIdTokenEncryptedResponseEnc().equals(Algorithm.NONE)
View Full Code Here

     * independently generate hash
     ascii of token = eyJhbGciOiJub25lIn0.eyJhbGciOiJIUzI1NiIsInN1YiI6ImV4YW1wbGVfdXNlciIsImlzcyI6Ind3dy5leGFtcGxlLmNvbSIsInR5cCI6IkpXVCJ9.
     base64url of hash = EP1gXNeESRH-n57baopfTQ
     */
    String token = mockToken256.getJwt().serialize();
    Base64URL expectedHash = new Base64URL("EP1gXNeESRH-n57baopfTQ");

    Base64URL resultHash = IdTokenHashUtils.getAccessTokenHash(JWSAlgorithm.HS256, mockToken256);

    assertEquals(expectedHash, resultHash);
  }
View Full Code Here

     ascii of token = eyJhbGciOiJub25lIn0.eyJhbGciOiJFUzM4NCIsInN1YiI6ImFub3RoZXJfdXNlciIsImlzcyI6Ind3dy5hbm90aGVyLWV4YW1wbGUubmV0IiwidHlwIjoiSldUIn0.
     base64url of hash = BWfFK73PQI36M1rg9R6VjMyWOE0-XvBK
     */

    String token = mockToken384.getJwt().serialize();
    Base64URL expectedHash = new Base64URL("BWfFK73PQI36M1rg9R6VjMyWOE0-XvBK");

    Base64URL resultHash = IdTokenHashUtils.getAccessTokenHash(JWSAlgorithm.ES384, mockToken384);

    assertEquals(expectedHash, resultHash);
  }
View Full Code Here

     ascii of token = eyJhbGciOiJub25lIn0.eyJhbGciOiJSUzUxMiIsInN1YiI6ImRpZmZlcmVudF91c2VyIiwiaXNzIjoid3d3LmRpZmZlcmVudC5jb20iLCJ0eXAiOiJKV1QifQ.
     base64url of hash = vGH3QMY-knpACkLgzdkTqu3C9jtvbf2Wk_RSu2vAx8k
     */

    String token = mockToken512.getJwt().serialize();
    Base64URL expectedHash = new Base64URL("vGH3QMY-knpACkLgzdkTqu3C9jtvbf2Wk_RSu2vAx8k");

    Base64URL resultHash = IdTokenHashUtils.getAccessTokenHash(JWSAlgorithm.RS512, mockToken512);

    assertEquals(expectedHash, resultHash);
  }
View Full Code Here

  @Test
  public void getCodeHash512() {

    String testCode = "b0x0rZ";

    Base64URL expectedHash = new Base64URL("R5DCRi5eOjlvyTAJfry2dNM9adJ2ElpDEKYYByYU920"); // independently generated

    Base64URL resultHash = IdTokenHashUtils.getCodeHash(JWSAlgorithm.ES512, testCode);

    assertEquals(expectedHash, resultHash);
  }
View Full Code Here

        hasher.reset();
        hasher.update(bytes);

        byte[] hashBytes = hasher.digest();
        byte[] hashBytesLeftHalf = Arrays.copyOf(hashBytes, hashBytes.length / 2);
        Base64URL encodedHash = Base64URL.encode(hashBytesLeftHalf);

        return encodedHash;

      } catch (NoSuchAlgorithmException e) {
View Full Code Here

          break;
        case "x5u":
          header = header.x509CertURL(JSONObjectUtils.getURL(jsonObject, name));
          break;
        case "x5t":
          header = header.x509CertThumbprint(new Base64URL(JSONObjectUtils.getString(jsonObject, name)));
          break;
        case "x5t#S256":
          header = header.x509CertSHA256Thumbprint(new Base64URL(JSONObjectUtils.getString(jsonObject, name)));
          break;
        case "x5c":
          header = header.x509CertChain(X509CertChainUtils.parseX509CertChain(JSONObjectUtils.getJSONArray(jsonObject, name)));
          break;
        case "kid":
View Full Code Here

    throws Exception {

    // Vectors from http://openidtest.uninett.no/jwt#

    byte[] msg = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJodHRwczovL2V4YW1wbGUub3JnIiwidHlwIjoiSldUIn0".getBytes("UTF-8");
    byte[] mac = new Base64URL("eagkgLML8Ccrn4eIvidX4a10JBE4Q3eaOAf4Blj9P4c").decode();
    byte[] key = "1879197b29d8ec57".getBytes("UTF-8");

    final Provider provider = null;
    byte[] computedMac = HMAC.compute("HMACSHA256", key, msg, provider);
View Full Code Here

    throws Exception {

    // Vectors from http://openidtest.uninett.no/jwt#

    byte[] msg = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJodHRwczovL2V4YW1wbGUub3JnIiwidHlwIjoiSldUIn0".getBytes("UTF-8");
    byte[] mac = new Base64URL("eagkgLML8Ccrn4eIvidX4a10JBE4Q3eaOAf4Blj9P4c").decode();
    byte[] key = "1879197b29d8ec57".getBytes("UTF-8");

    final Provider provider =Mac.getInstance("HMACSHA256").getProvider();
    byte[] computedMac = HMAC.compute("HMACSHA256", key, msg, provider);
View Full Code Here

TOP

Related Classes of com.nimbusds.jose.util.Base64URL

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.