List of usage examples for org.springframework.security.jwt.crypto.sign Signer sign
byte[] sign(byte[] bytes);
From source file:org.cloudfoundry.identity.uaa.util.UaaTokenUtils.java
public static String constructToken(Map<String, Object> header, Map<String, Object> claims, Signer signer) { byte[] headerJson = header == null ? new byte[0] : JsonUtils.writeValueAsBytes(header); byte[] claimsJson = claims == null ? new byte[0] : JsonUtils.writeValueAsBytes(claims); String headerBase64 = Base64.encodeBase64URLSafeString(headerJson); String claimsBase64 = Base64.encodeBase64URLSafeString(claimsJson); String headerAndClaims = headerBase64 + "." + claimsBase64; byte[] signature = signer.sign(headerAndClaims.getBytes()); String signatureBase64 = Base64.encodeBase64URLSafeString(signature); return headerAndClaims + "." + signatureBase64; }