Example usage for org.springframework.security.jwt.codec Codecs b64UrlDecode

List of usage examples for org.springframework.security.jwt.codec Codecs b64UrlDecode

Introduction

In this page you can find the example usage for org.springframework.security.jwt.codec Codecs b64UrlDecode.

Prototype

public static byte[] b64UrlDecode(CharSequence value) 

Source Link

Usage

From source file:org.springframework.security.oauth2.provider.token.store.jwk.JwkDefinitionSourceTest.java

@Test
public void getVerifierWhenModulusMostSignificantBitIs1ThenVerifierStillVerifyContentSignature()
        throws Exception {
    String jwkSetUrl = JwkDefinitionSourceTest.class.getResource("jwk-set.json").toString();
    JwkDefinitionSource jwkDefinitionSource = new JwkDefinitionSource(jwkSetUrl);
    SignatureVerifier verifier = jwkDefinitionSource.getVerifier("_Ci3-VfV_N0YAG22NQOgOUpFBDDcDe_rJxpu5JK702o");
    String token = this.readToken("token.jwt");
    int secondPeriodIndex = token.indexOf('.', token.indexOf('.') + 1);
    String contentString = token.substring(0, secondPeriodIndex);
    byte[] content = contentString.getBytes(Charsets.UTF_8);
    String signatureString = token.substring(secondPeriodIndex + 1);
    byte[] signature = Codecs.b64UrlDecode(signatureString);
    verifier.verify(content, signature);
}