Example usage for org.springframework.util Base64Utils encodeUrlSafe

List of usage examples for org.springframework.util Base64Utils encodeUrlSafe

Introduction

In this page you can find the example usage for org.springframework.util Base64Utils encodeUrlSafe.

Prototype

public static byte[] encodeUrlSafe(byte[] src) 

Source Link

Document

Base64-encode the given byte array using the RFC 4648 "URL and Filename Safe Alphabet".

Usage

From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.ReactiveTokenValidatorTests.java

private String getSignedToken(byte[] header, byte[] claims) throws Exception {
    PrivateKey privateKey = getPrivateKey();
    Signature signature = Signature.getInstance("SHA256WithRSA");
    signature.initSign(privateKey);//from www.  j  av a  2  s .co m
    byte[] content = dotConcat(Base64Utils.encodeUrlSafe(header), Base64Utils.encode(claims));
    signature.update(content);
    byte[] crypto = signature.sign();
    byte[] token = dotConcat(Base64Utils.encodeUrlSafe(header), Base64Utils.encodeUrlSafe(claims),
            Base64Utils.encodeUrlSafe(crypto));
    return new String(token, StandardCharsets.UTF_8);
}

From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.TokenValidatorTests.java

private String getSignedToken(byte[] header, byte[] claims) throws Exception {
    PrivateKey privateKey = getPrivateKey();
    Signature signature = Signature.getInstance("SHA256WithRSA");
    signature.initSign(privateKey);//from  w  ww.j av  a  2  s  . c  o m
    byte[] content = dotConcat(Base64Utils.encodeUrlSafe(header), Base64Utils.encode(claims));
    signature.update(content);
    byte[] crypto = signature.sign();
    byte[] token = dotConcat(Base64Utils.encodeUrlSafe(header), Base64Utils.encodeUrlSafe(claims),
            Base64Utils.encodeUrlSafe(crypto));
    return new String(token, UTF_8);
}