当前位置: 首页>>代码示例>>Java>>正文


Java Base64Url.decode方法代码示例

本文整理汇总了Java中org.jose4j.base64url.Base64Url.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64Url.decode方法的具体用法?Java Base64Url.decode怎么用?Java Base64Url.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jose4j.base64url.Base64Url的用法示例。


在下文中一共展示了Base64Url.decode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSomeDataCompressedElsewhere

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
public void testSomeDataCompressedElsewhere() throws JoseException
{
    String s ="q1bKLC5WslLKKCkpKLaK0Y/Rz0wp0EutSMwtyEnVS87PVdLhUkqtKFCyMjQ2NTcyNTW3sACKJJamoGgqRujJL0o" +
            "H6ckqyQSqKMmNLIsMCzWqsPAp8zM3cjINjHdNTPbQizd1BClKTC4CKjICMYtLk4BMp6LMxDylWi4A";
    byte[] decoded = Base64Url.decode(s);
    CompressionAlgorithm ca = new DeflateRFC1951CompressionAlgorithm();
    byte[] decompress = ca.decompress(decoded);
    String decompedString = StringUtil.newStringUtf8(decompress);

    String expected = "{\"iss\":\"https:\\/\\/idp.example.com\",\n" +
            "\"exp\":1357255788,\n" +
            "\"aud\":\"https:\\/\\/sp.example.org\",\n" +
            "\"jti\":\"tmYvYVU2x8LvN72B5Q_EacH._5A\",\n" +
            "\"acr\":\"2\",\n" +
            "\"sub\":\"Brian\"}\n";

    assertEquals(expected, decompedString);
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:19,代码来源:DeflateRFC1951CompressionAlgorithmTest.java

示例2: testNpeWithNonExtractableKeyDataHS256

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
@Test
public void testNpeWithNonExtractableKeyDataHS256() throws Exception
{
    byte[] raw = Base64Url.decode("hup76LcA9B7pqrEtqyb4EBg6XCcr9r0iOCFF1FeZiJM");
    FakeHsmNonExtractableSecretKeySpec key = new FakeHsmNonExtractableSecretKeySpec(raw, "HmacSHA256");
    JwtClaims claims = new JwtClaims();
    claims.setExpirationTimeMinutesInTheFuture(5);
    claims.setSubject("subject");
    claims.setIssuer("issuer");
    JsonWebSignature jws = new JsonWebSignature();
    jws.setPayload(claims.toJson());
    jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.HMAC_SHA256);
    jws.setKey(key);
    String jwt = jws.getCompactSerialization();
    JwtConsumerBuilder jwtConsumerBuilder = new JwtConsumerBuilder();
    jwtConsumerBuilder.setAllowedClockSkewInSeconds(60);
    jwtConsumerBuilder.setRequireSubject();
    jwtConsumerBuilder.setExpectedIssuer("issuer");
    jwtConsumerBuilder.setVerificationKey(key);
    JwtConsumer jwtConsumer = jwtConsumerBuilder.build();
    JwtClaims processedClaims = jwtConsumer.processToClaims(jwt);
    System.out.println(processedClaims);
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:24,代码来源:JwtConsumerTest.java

示例3: littleJweRoundTrip

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
private void littleJweRoundTrip(String alg, String enc, String b64uKey) throws Exception
{
    byte[] raw = Base64Url.decode(b64uKey);
    Key key = new FakeHsmNonExtractableSecretKeySpec(raw, "AES");
    JwtClaims claims = new JwtClaims();
    claims.setExpirationTimeMinutesInTheFuture(5);
    claims.setSubject("subject");
    claims.setIssuer("issuer");
    JsonWebEncryption jwe = new JsonWebEncryption();
    jwe.setPayload(claims.toJson());
    jwe.setAlgorithmHeaderValue(alg);
    jwe.setEncryptionMethodHeaderParameter(enc);
    jwe.setKey(key);

    String jwt = jwe.getCompactSerialization();
    JwtConsumerBuilder jwtConsumerBuilder = new JwtConsumerBuilder();
    jwtConsumerBuilder.setAllowedClockSkewInSeconds(60);
    jwtConsumerBuilder.setRequireSubject();
    jwtConsumerBuilder.setExpectedIssuer("issuer");
    jwtConsumerBuilder.setDecryptionKey(key);
    jwtConsumerBuilder.setDisableRequireSignature();
    JwtConsumer jwtConsumer = jwtConsumerBuilder.build();
    JwtClaims processedClaims = jwtConsumer.processToClaims(jwt);
    Assert.assertThat(processedClaims.getSubject(), equalTo("subject"));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:26,代码来源:JwtConsumerTest.java

示例4: testKdf1

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
public void testKdf1() throws Exception
{
    // test values produced from implementation found at http://stackoverflow.com/questions/10879658
    String derivedKey = "pgs50IOZ6BxfqvTSie4t9OjWxGr4whiHo1v9Dti93CRiJE2PP60FojLatVVrcjg3BxpuFjnlQxL97GOwAfcwLA";
    byte[] z = Base64Url.decode("Sq8rGLm4rEtzScmnSsY5r1n-AqBl_iBU8FxN80Uc0S0");
    System.out.println(Base64Url.encode(z));
    KdfUtil kdfUtil = new KdfUtil();
    int keyDatalen = 512;
    String alg = ContentEncryptionAlgorithmIdentifiers.AES_256_CBC_HMAC_SHA_512;
    byte[] algId = kdfUtil.prependDatalen(StringUtil.getBytesUtf8(alg));
    byte[] partyU = new byte[] {0, 0, 0, 0};
    byte[] partyV = new byte[] {0, 0, 0, 0};
    byte[] pub = ByteUtil.getBytes(keyDatalen);
    byte[] priv = ByteUtil.EMPTY_BYTES;

    ConcatKeyDerivationFunction myConcatKdf = new ConcatKeyDerivationFunction("SHA-256", null);

    byte[] kdfed = myConcatKdf.kdf(z, keyDatalen, algId, partyU, partyV, pub, priv);
    assertEquals(derivedKey, Base64Url.encode(kdfed));

}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:22,代码来源:ConcatKeyDerivationFunctionTest.java

示例5: testKdf2

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
public void testKdf2() throws Exception
{
    // test values produced from implementation found at http://stackoverflow.com/questions/10879658
    String derivedKey = "vphyobtvExGXF7TaOvAkx6CCjHQNYamP2ET8xkhTu-0";
    byte[] z = Base64Url.decode("LfkHot2nGTVlmfxbgxQfMg");  // ByteUtil.randomBytes(16);
    System.out.println(Base64Url.encode(z));
    KdfUtil kdfUtil = new KdfUtil(null);
    int keyDatalen = 256;
    String alg = ContentEncryptionAlgorithmIdentifiers.AES_128_CBC_HMAC_SHA_256;
    byte[] algId = kdfUtil.prependDatalen(StringUtil.getBytesUtf8(alg));
    byte[] partyU = new byte[] {0, 0, 0, 0};
    byte[] partyV = new byte[] {0, 0, 0, 0};
    byte[] pub = ByteUtil.getBytes(keyDatalen);
    byte[] priv = ByteUtil.EMPTY_BYTES;

    ConcatKeyDerivationFunction myConcatKdf = new ConcatKeyDerivationFunction("SHA-256", null);

    byte[] kdfed = myConcatKdf.kdf(z, keyDatalen, algId, partyU, partyV, pub, priv);
    assertEquals(derivedKey, Base64Url.encode(kdfed));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:21,代码来源:ConcatKeyDerivationFunctionTest.java

示例6: testKdf3

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
public void testKdf3() throws Exception
{
    // test values produced from implementation found at http://stackoverflow.com/questions/10879658
    String derivedKey = "yRbmmZJpxv3H1aq3FgzESa453frljIaeMz6pt5rQZ4Q5Hs-4RYoFRXFh_qBsbTjlsj8JxIYTWj-cp5LKtgi1fBRsf_5yTEcLDv4pKH2fNxjbEOKuVVDWA1_Qv2IkEC0_QSi3lSSELcJaNX-hDG8occ7oQv-w8lg6lLJjg58kOes";
    byte[] z = Base64Url.decode("KSDnQpf2iurUsAbcuI4YH-FKfk2gecN6cWHTYlBzrd8");
    KdfUtil kdfUtil = new KdfUtil(null);
    int keyDatalen = 1024;
    String alg = "meh";
    byte[] algId = kdfUtil.prependDatalen(StringUtil.getBytesUtf8(alg));
    byte[] partyU = new byte[] {0, 0, 0, 5, 65, 108, 105, 99, 101};
    byte[] partyV = new byte[] {0, 0, 0, 3, 66, 111, 98};
    byte[] pub = ByteUtil.getBytes(keyDatalen);
    byte[] priv = ByteUtil.EMPTY_BYTES;

    ConcatKeyDerivationFunction myConcatKdf = new ConcatKeyDerivationFunction("SHA-256");

    byte[] kdfed = myConcatKdf.kdf(z, keyDatalen, algId, partyU, partyV, pub, priv);
    assertEquals(derivedKey, Base64Url.encode(kdfed));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:20,代码来源:ConcatKeyDerivationFunctionTest.java

示例7: testKdf4

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
public void testKdf4() throws Exception
{
    // test values produced from implementation found at http://stackoverflow.com/questions/10879658
    String derivedKey = "SNOvl6h5iSYWJ_EhlnvK8o6om9iyR8HkKMQtQYGkYKkVY0HFMleoUm-H6-kLz8sW";
    byte[] z = Base64Url.decode("zp9Hot2noTVlmfxbkXqfn1");
    KdfUtil kdfUtil = new KdfUtil();
    int keyDatalen = 384;
    String alg = ContentEncryptionAlgorithmIdentifiers.AES_192_CBC_HMAC_SHA_384;
    byte[] algId = kdfUtil.prependDatalen(StringUtil.getBytesUtf8(alg));
    byte[] partyU = new byte[] {0, 0, 0, 0};
    byte[] partyV = new byte[] {0, 0, 0, 0};
    byte[] pub = ByteUtil.getBytes(keyDatalen);
    byte[] priv = ByteUtil.EMPTY_BYTES;

    ConcatKeyDerivationFunction myConcatKdf = new ConcatKeyDerivationFunction("SHA-256");

    byte[] kdfed = myConcatKdf.kdf(z, keyDatalen, algId, partyU, partyV, pub, priv);
    assertEquals(derivedKey, Base64Url.encode(kdfed));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:20,代码来源:ConcatKeyDerivationFunctionTest.java

示例8: salesforce

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
@Test
public void salesforce() throws JoseException
{
    // ~8am Aug 26, '14 from https://login.salesforce.com/id/keys
    String jwks = "{\"keys\":[{\"kty\":\"RSA\",\"n\":\"AMCELStParLtaggkLtZh4enfxMsjpW6jAlfFjGnDsoWZ4NbG2hSWPtDyB-OisNboY2x4PeP69lBC2Hd9LxfMcFYhoQpqT7khoZMTaE-QjKCT0uiVvswaUe7Lh6gVJ2hnWehtrmGQ6cFmLP-EiQ7ls8VQa0Ki" +
            "DP2VYFKrrZ4kD5ozAF-TKs5wU5xt85u9vAZjc0u09oLc8bN4wIA7EgLtysadw-jQxhEYWgCfIzoMB75kCucRYvQHcO7L9pwh_sDPguXyyWJqRjkq0z9Ryzpavvk0TgL1i_YHDRHquGq68iGLsebMoOuqx0_FNlIW9T3V7e0XkGPMAZz9gQR9UB-68zme1G6hS20FEL" +
            "GRQFTHH5u4CTfCVi5XEiWXQts2mNMCOavD1jfjfxoACuuBSmUO6QdG0UOQEMfg91OLGBOBHIEr1fH1vOj2hdVV2hzBXKJuPIGdRsxP1dubj2_tMrntHL_ZXo6yCg70YieVIslD6Ya6OAMNmXA4v_K_K6n4JVoXJweGxkq4uJBAW_yHcL6isEQqsZTXUZ1NaKEHlAWl" +
            "UcHW6Y9t2darWIweeVn9ijgiensDMnXauGxABuiiKj5rLE-_3sb8oFMrluqoZwlfoE2RMBSNAOnY7BzOYrX5MzWOOwXrgLRl47mkZ1WCBL0650o9y8e2H7wiIhqhaxust9QJ\",\"e\":\"AQAB\",\"alg\":\"RS256\",\"use\":\"sig\",\"kid\":\"188\"}" +
            ",{\"kty\":\"RSA\",\"n\":\"AKPBc9I142dEc-Srdk5sz9MVaJH_kOAM_jEIOYuTAsTTU0Imae1ZMAGXjNJifpig2wsz5vcLON7_HMXoiJFWUKqwKHJ52_dDAwp1Pu6A-zLzlOEm5obi81QslWTyAUauc9DoI3MC3g-LazqKIJCzrtJMrsszaBZK-9dpvxmdcYnPl9D" +
            "JRSqt_tnCOFNpxLrofl3Mu21KgsdM0yRTzjioIRmBGWem4mdOFQvhEXFunAtfaRFpurwqmSRLCjwn2s1QKBymQLpDXdFyz0Hf1usQGhp6fHu2ubRR5-nVOopISPeGYnlaeliLVrEEw8CR_g-21aVURvpVi--JYHLkHRQLZXZv_5Oxb5U13aoi63dK2Lg50xYsFErFF1gS" +
            "W5hlbBDspWVT0AC_iuxu6dwUWOF9urzoH5bncAjo-y-1hW3dCF84k5u-MXtimRirBaaAoySNM_w-TnuW6H7MK9Qnmn4Zfe7LhuzqCJ6G7e0AEJ5y3AVc1D8_035Tlw3OVInj6bQNG8XXfDFRDYg20xhjc-gws3y_fOkH3CSzwfGmWt5RTdJFjwZDnJWWoC-FqciJZQenr" +
            "r2doX6bfCGNv25lDdOpbqOjexctIUkhTFr382g_PxX93M29Sr_m9MSOlIJOHeu0TTUm03ETNjLr8fnSYDsl6q3P4RPejjqnDI6xmSaF5wgD\",\"e\":\"AQAB\",\"alg\":\"RS256\",\"use\":\"sig\",\"kid\":\"190\"},{\"kty\":\"RSA\",\"n\":" +
            "\"AJznEDrx1fK3PoXHz_0ZsTBo8lZa7ki3hV06I2HG4sWgB9-rHFHo42sLN9aK1I5mKgeYrBPZ7XbC-A57HT_zAydprWA9hSIfLQZCY4F4rY3XA3Ja8BCwMfOOsASJUhEvMEenM6XSWX0sIS__dhBqQx-s-5ShApaoQ5W7WfshShY_QUEcGhF1le7rqtt4MVzqshDdF" +
            "l5d2ST4LKHQp5V0Z_cv6-QjVfVeML81xpSYU9zb_zf2eVzWSI2Zx3QrhP4rU-GtcRDRBHbOyY4OZkU5VRc2L-YkLQaO43WOaIDE4Cj5kYeoWLqi3pItwDgFH39QBmjfU2R-tFMcE8NN_g0CS-Qtkrgv7zOSiFsWcUJ4rm33oFAgV6SUgCWy7fM0hc7U3Ky0uPsIFB6N" +
            "QPEwzWjtvPyrAVE1rK4njq9zXwp-GzzW-7fBvdFOtJVtBiIRHWt3zWJ1dFlqWVTtYwkTcvyWFLNxAqNBNWUCWQ-9g5ulI4rh-3kd2YDSkfbZSzXcmUqWVGTxKy61yfdHeV25iWL0V_a_d8-hkKjr-RUMtSYWrcHn8YSncoZAxB7KhCztFw6pw55oMZBBFPpR2ElRs_o" +
            "g5VGTlGE0wrcbDw5gSFzjLsKdFMnSaYTt-qkUGg8hIxzbGCi4-Slb4wx0vBsNRYWxb7KFKwR63uIS2PT2uZnmrVf5\",\"e\":\"AQAB\",\"alg\":\"RS256\",\"use\":\"sig\",\"kid\":\"192\"}]}";

    JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jwks);
    List<JsonWebKey> jsonWebKeys = jsonWebKeySet.getJsonWebKeys();
    assertThat(jsonWebKeys.size(), is(equalTo(3)));

    // make sure that a JWK produced by jose4j doesn't have a leading zero byte on the RSA modulus (there are leading zeros in the salesforce json above)
    JsonWebKey jwk188 = jsonWebKeySet.findJsonWebKey("188", null, Use.SIGNATURE, null);
    Map<String,Object> parsed188 = JsonUtil.parseJson(jwk188.toJson());
    String jose4jModulus188 = JsonHelp.getString(parsed188, RsaJsonWebKey.MODULUS_MEMBER_NAME);
    byte[] decodedJose4jModulus = Base64Url.decode(jose4jModulus188);
    assertThat(decodedJose4jModulus[0], not(equalTo((byte)0)));

}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:30,代码来源:JwkGlitchesInDeploymentTest.java

示例9: tooShortPreviously

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
@Test
public void tooShortPreviously() throws Exception
{
    // a ECDSA 521 sig value produced before jose4j left zero padded the R & S values
    String encoded = "7w6JjwMqcWmTFaZfrOc5kSSj5WOi0vDbMoGqcLWUL5QrTmJ_KOPMkNOjNll4pRITxuyZo_owOswnDM4dYdS7ypo" +
            "PHOL13XDfdffG7sdwjXA6JthsItlk6l43Xtqt2ytJKqUMC-J7K5Cn1izOeuqzsI18Go9jcEEw5eUdQhR77OjfCA";

    byte[] decoded = Base64Url.decode(encoded);
    byte[] der = EcdsaUsingShaAlgorithm.convertConcatenatedToDer(decoded);
    int outputLength = 132;
    byte[] concatenated = EcdsaUsingShaAlgorithm.convertDerToConcatenated(der, outputLength);
    Assert.assertThat(outputLength, is(equalTo(concatenated.length)));
    Assert.assertThat((byte) 0, is(equalTo(concatenated[0])));
    Assert.assertThat((byte) 0, is(equalTo(concatenated[66])));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:16,代码来源:EcdsaUsingShaAlgorithmTest.java

示例10: testUsingAndSettingDefaults

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
@Test
public void testUsingAndSettingDefaults() throws JoseException
{
    Pbes2HmacShaWithAesKeyWrapAlgorithm pbes2 = new Pbes2HmacShaWithAesKeyWrapAlgorithm.HmacSha256Aes128();

    assertTrue(pbes2.getDefaultIterationCount() >= MINIMUM_ITERAION_COUNT);
    assertTrue(pbes2.getDefaultSaltByteLength() >= MINIMUM_SALT_BYTE_LENGTH);

    PbkdfKey key = new PbkdfKey("a password");

    Headers headers = new Headers();
    Key derivedKey = pbes2.deriveForEncrypt(key, headers, ProviderContextTest.EMPTY_CONTEXT);
    assertThat(derivedKey.getEncoded().length, equalTo(16));

    String saltInputString = headers.getStringHeaderValue(HeaderParameterNames.PBES2_SALT_INPUT);
    byte[] saltInput = Base64Url.decode(saltInputString);
    assertThat(saltInput.length, equalTo(pbes2.getDefaultSaltByteLength()));
    Long iterationCount = headers.getLongHeaderValue(HeaderParameterNames.PBES2_ITERATION_COUNT);
    assertThat(iterationCount, equalTo(pbes2.getDefaultIterationCount()));

    Pbes2HmacShaWithAesKeyWrapAlgorithm newPbes2 = new Pbes2HmacShaWithAesKeyWrapAlgorithm.HmacSha256Aes128();
    long newDefaultIterationCount = 1024;
    newPbes2.setDefaultIterationCount(newDefaultIterationCount);

    int newDefaultSaltByteLength = 16;
    newPbes2.setDefaultSaltByteLength(newDefaultSaltByteLength);

    headers = new Headers();
    derivedKey = newPbes2.deriveForEncrypt(key, headers, ProviderContextTest.EMPTY_CONTEXT);
    saltInputString = headers.getStringHeaderValue(HeaderParameterNames.PBES2_SALT_INPUT);
    saltInput = Base64Url.decode(saltInputString);
    assertThat(saltInput.length, equalTo(newDefaultSaltByteLength));
    iterationCount = headers.getLongHeaderValue(HeaderParameterNames.PBES2_ITERATION_COUNT);
    assertThat(iterationCount, equalTo(newDefaultIterationCount));

    assertThat(derivedKey.getEncoded().length, equalTo(16));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:38,代码来源:Pbes2HmacShaWithAesKeyWrapAlgorithmTest.java

示例11: testExamplesFromDraftEvenWithoutDirectSupportForTheHeader

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
@Test
public void testExamplesFromDraftEvenWithoutDirectSupportForTheHeader() throws Exception
{
    // a test of sorts to verify the examples from
    // http://tools.ietf.org/html/draft-ietf-jose-jws-signing-input-options-09#section-4
    // at Mike's request

    String jwkJson =
            "{" +
            "  \"kty\":\"oct\"," +
            "  \"k\":\"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75" +
            "      aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow\"" +
            "}";
    final JsonWebKey jsonWebKey = JsonWebKey.Factory.newJwk(jwkJson);
    final Key key = jsonWebKey.getKey();

    String payload = "$.02";

    final String encodedPayload = Base64Url.encode(payload, StringUtil.US_ASCII);
    assertThat(encodedPayload, equalTo("JC4wMg"));

    String jwscsWithB64 = "eyJhbGciOiJIUzI1NiJ9.JC4wMg.5mvfOroL-g7HyqJoozehmsaqmvTYGEq5jTI1gVvoEoQ";

    JsonWebSignature jws = new JsonWebSignature();
    jws.setCompactSerialization(jwscsWithB64);
    jws.setKey(key);
    assertThat(jws.getPayload(), equalTo(payload));
    assertTrue(jws.verifySignature());

    jws = new JsonWebSignature();
    jws.setPayload(payload);
    jws.setKey(key);
    jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.HMAC_SHA256);
    assertThat(jws.getCompactSerialization(), equalTo(jwscsWithB64));

    String jwscsWithoutB64andDetachedPaylod = "eyJhbGciOiJIUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19.." +
            "A5dxf2s96_n5FLueVuW1Z_vh161FwXZC4YLPff6dmDY";

    jws = new JsonWebSignature();
    jws.setCompactSerialization(jwscsWithoutB64andDetachedPaylod);
    assertThat(jws.getHeaders().getFullHeaderAsJsonString(), equalTo("{\"alg\":\"HS256\",\"b64\":false,\"crit\":[\"b64\"]}"));

    HmacUsingShaAlgorithm.HmacSha256 hmacSha256 = new HmacUsingShaAlgorithm.HmacSha256();

    final String signingInputString = jws.getHeaders().getEncodedHeader() + "." + payload;

    final byte[] signatureBytes = Base64Url.decode(jws.getEncodedSignature());
    final byte[] securedInputBytes = StringUtil.getBytesAscii(signingInputString);
    final ProviderContext providerContext = new ProviderContext();
    boolean okay = hmacSha256.verifySignature(signatureBytes, key, securedInputBytes, providerContext);
    assertTrue(okay);

    final byte[] signed = hmacSha256.sign(key, securedInputBytes, providerContext);
    assertThat(Base64Url.encode(signed), equalTo(jws.getEncodedSignature()));
}
 
开发者ID:RbkGh,项目名称:Jose4j,代码行数:56,代码来源:JwsUnencodedPayloadOptionTest.java

示例12: base64UrlDecode

import org.jose4j.base64url.Base64Url; //导入方法依赖的package包/类
/**
 * Base64 decodes to a byte array, using URL style encoding.
 *
 * @param base64
 *            base64 encoded string
 * @return decoded data
 */
public static byte[] base64UrlDecode(String base64) {
    return Base64Url.decode(base64);
}
 
开发者ID:shred,项目名称:acme4j,代码行数:11,代码来源:AcmeUtils.java


注:本文中的org.jose4j.base64url.Base64Url.decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。