List of usage examples for org.springframework.util Base64Utils encodeToUrlSafeString
public static String encodeToUrlSafeString(byte[] src)
From source file:de.swm.nis.logicaldecoding.gwc.GWCInvalidator.java
@SuppressWarnings("serial") private HttpHeaders createHeaders(String username, String password) { return new HttpHeaders() { {/*from w ww . j a v a2 s . co m*/ String auth = username + ":" + password; String encodedAuth = Base64Utils.encodeToUrlSafeString(auth.getBytes(Charset.forName("US-ASCII"))); String authHeader = "Basic " + encodedAuth; set("Authorization", authHeader); } }; }
From source file:org.cloudfoundry.identity.uaa.mock.token.TokenKeyEndpointMockMvcTests.java
private void isUrlSafeBase64(String base64) { assertEquals(base64, Base64Utils.encodeToUrlSafeString(Base64Utils.decodeFromUrlSafeString(base64))); }
From source file:org.cloudfoundry.identity.uaa.oauth.TokenKeyEndpoint.java
public static VerificationKeyResponse getVerificationKeyResponse(KeyInfo key) { Map<String, Object> result = new HashMap<>(); result.put("alg", key.getSigner().algorithm()); result.put("value", key.getVerifierKey()); //new values per OpenID and JWK spec result.put("use", sig.name()); result.put("kid", key.getKeyId()); result.put("kty", key.getType()); if (key.isAssymetricKey() && "RSA".equals(key.getType())) { RSAPublicKey rsaKey = key.getRsaPublicKey(); if (rsaKey != null) { String n = Base64Utils.encodeToUrlSafeString(rsaKey.getModulus().toByteArray()); String e = Base64Utils.encodeToUrlSafeString(rsaKey.getPublicExponent().toByteArray()); result.put("n", n); result.put("e", e); }/*from ww w . j av a2 s .c o m*/ } return new VerificationKeyResponse(result); }
From source file:org.springframework.amqp.rabbit.junit.BrokerRunning.java
/** * Generate the connection id for the connection used by the rule's * connection factory./* w w w .j av a2s. c om*/ * @return the id. */ public String generateId() { UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()); return "SpringBrokerRunning." + Base64Utils.encodeToUrlSafeString(bb.array()).replaceAll("=", ""); }