com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-keyvault-webkey Show documentation
Show all versions of azure-keyvault-webkey Show documentation
This library has been replaced by new Azure SDKs, you can read about them at https://aka.ms/azsdkvalueprop. The latest libraries to interact with the Azure Key Vault service are:
(1) https://search.maven.org/artifact/com.azure/azure-security-keyvault-keys.
(2) https://search.maven.org/artifact/com.azure/azure-security-keyvault-secrets.
(3) https://search.maven.org/artifact/com.azure/azure-security-keyvault-certificates.
It is recommended that you move to the new package.
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
package com.microsoft.azure.keyvault.webkey;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
/**
* The base64 URL JSON serializer.
*/
public class Base64UrlJsonSerializer extends JsonSerializer {
static final Base64 BASE64 = new Base64(-1, null, true);
@Override
public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
String text;
if (value == null) {
text = null;
} else if (value.length == 0) {
text = "";
} else {
text = BASE64.encodeAsString(value);
}
jgen.writeString(text);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy