@Override protected String encodeToken(String token) throws Base64Exception { return Base64UrlUtility.encode(token); } }
public JweCompactBuilder(String headersJson, byte[] encryptedContentEncryptionKey, byte[] cipherInitVector, byte[] encryptedContentNoTag, byte[] authenticationTag) { jweContentBuilder = startJweContent(new StringBuilder(), headersJson, encryptedContentEncryptionKey, cipherInitVector); this.encodedEncryptedContent = Base64UrlUtility.encode(encryptedContentNoTag); this.encodedAuthTag = Base64UrlUtility.encode(authenticationTag); }
protected String encodeAssertion() { if (encoded) { return assertion; } try { return Base64UrlUtility.encode(assertion); } catch (Exception ex) { throw new OAuthServiceException(ex.getMessage(), ex); } } }
public String transformCodeVerifier(String codeVerifier) { byte[] digest = MessageDigestUtils.createDigest(codeVerifier, MessageDigestUtils.ALGO_SHA_256); return Base64UrlUtility.encode(digest); }
public String getUnsignedEncodedPayload() { if (encodedPayload == null) { encodedPayload = Base64UrlUtility.encode(getPlainPayload()); } return encodedPayload; } public String getJwsJsonSignedDocument() {
public static JsonWebKey fromRSAPublicKey(RSAPublicKey pk, String algo, String kid) { JsonWebKey jwk = prepareRSAJwk(pk.getModulus(), algo, kid); String encodedPublicExponent = Base64UrlUtility.encode(pk.getPublicExponent().toByteArray()); jwk.setProperty(JsonWebKey.RSA_PUBLIC_EXP, encodedPublicExponent); return jwk; } public static JsonWebKey fromPublicKey(PublicKey key, Properties props, String algoProp) {
public static JsonWebKey fromRSAPublicKey(RSAPublicKey pk, String algo, String kid) { JsonWebKey jwk = prepareRSAJwk(pk.getModulus(), algo, kid); String encodedPublicExponent = Base64UrlUtility.encode(pk.getPublicExponent().toByteArray()); jwk.setProperty(JsonWebKey.RSA_PUBLIC_EXP, encodedPublicExponent); return jwk; } public static JsonWebKey fromPublicKey(PublicKey key, Properties props, String algoProp) {
public static byte[] toCipherAdditionalAuthData(String headersJson) { byte[] headerBytes = StringUtils.toBytesUTF8(headersJson); String base64UrlHeadersInJson = Base64UrlUtility.encode(headerBytes); return StringUtils.toBytesASCII(base64UrlHeadersInJson); }
protected String generateClientId() { return Base64UrlUtility.encode( CryptoUtils.generateSecureRandomBytes( getClientIdSizeInBytes())); }
protected String generateClientSecret(ClientRegistration request) { return Base64UrlUtility.encode( CryptoUtils.generateSecureRandomBytes( getClientSecretSizeInBytes(request))); }
protected String generateClientId() { return Base64UrlUtility.encode( CryptoUtils.generateSecureRandomBytes( getClientIdSizeInBytes())); }
public static JsonWebKey fromECPrivateKey(ECPrivateKey pk, String curve, String kid) { JsonWebKey jwk = prepareECJwk(curve, kid); jwk.setProperty(JsonWebKey.EC_PRIVATE_KEY, Base64UrlUtility.encode(pk.getS().toByteArray())); return jwk; } public static JsonWebKey fromRSAPublicKey(RSAPublicKey pk, String algo) {
private String getSigningInput() { checkAlgorithm(); boolean unencoded = JwsUtils.isPayloadUnencoded(getJwsHeaders()); return Base64UrlUtility.encode(writer.toJson(getJwsHeaders())) + "." + (unencoded ? plainJwsPayload : Base64UrlUtility.encode(plainJwsPayload)); } public String getEncodedSignature() {
public static JsonWebKey fromECPublicKey(ECPublicKey pk, String curve, String kid) { JsonWebKey jwk = prepareECJwk(curve, kid); jwk.setProperty(JsonWebKey.EC_X_COORDINATE, Base64UrlUtility.encode(pk.getW().getAffineX().toByteArray())); jwk.setProperty(JsonWebKey.EC_Y_COORDINATE, Base64UrlUtility.encode(pk.getW().getAffineY().toByteArray())); return jwk; } public static JsonWebKey fromECPrivateKey(ECPrivateKey pk, String curve) {
public static JsonWebKey fromECPublicKey(ECPublicKey pk, String curve, String kid) { JsonWebKey jwk = prepareECJwk(curve, kid); jwk.setProperty(JsonWebKey.EC_X_COORDINATE, Base64UrlUtility.encode(pk.getW().getAffineX().toByteArray())); jwk.setProperty(JsonWebKey.EC_Y_COORDINATE, Base64UrlUtility.encode(pk.getW().getAffineY().toByteArray())); return jwk; } public static JsonWebKey fromECPrivateKey(ECPrivateKey pk, String curve) {
protected AlgorithmParameterSpec getAlgorithmParameterSpec(JweHeaders headers) { byte[] iv = CryptoUtils.generateSecureRandomBytes(96 / 8); String encodedIv = Base64UrlUtility.encode(iv); headers.setHeader("iv", encodedIv); return CryptoUtils.getContentEncryptionCipherSpec(128, iv); } }
public static void setCertificateThumbprintConfirmation(MessageContext mc, X509Certificate cert) { try { byte[] thumbprint = createCertificateThumbprint(cert); String encodedThumbprint = Base64UrlUtility.encode(thumbprint); mc.put(JoseConstants.HEADER_X509_THUMBPRINT_SHA256, encodedThumbprint); } catch (Exception ex) { throw new OAuthServiceException(ex); } }
public static String getThumbprint(JsonWebKey key) { List<String> fields = getRequiredFields(key.getKeyType()); JsonWebKey thumbprintKey = new JsonWebKey(); for (String f : fields) { thumbprintKey.setProperty(f, key.getProperty(f)); } String json = new JsonMapObjectReaderWriter().toJson(thumbprintKey); byte[] digest = MessageDigestUtils.createDigest(json, MessageDigestUtils.ALGO_SHA_256); return Base64UrlUtility.encode(digest); } public static List<String> getRequiredFields(KeyType keyType) {
public static String getThumbprint(JsonWebKey key) { List<String> fields = getRequiredFields(key.getKeyType()); JsonWebKey thumbprintKey = new JsonWebKey(); for (String f : fields) { thumbprintKey.setProperty(f, key.getProperty(f)); } String json = new JsonMapObjectReaderWriter().toJson(thumbprintKey); byte[] digest = MessageDigestUtils.createDigest(json, MessageDigestUtils.ALGO_SHA_256); return Base64UrlUtility.encode(digest); } public static List<String> getRequiredFields(KeyType keyType) {