summaryrefslogtreecommitdiff
path: root/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java')
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java52
1 files changed, 25 insertions, 27 deletions
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java
index aa749d73..10e34334 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonBuilderUtils.java
@@ -17,8 +17,6 @@ import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SlCommandoBuildException;
public class SL20JsonBuilderUtils {
- private static JsonMapper mapper = new JsonMapper();
-
/**
* Create command request.
*
@@ -29,7 +27,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createCommand(final String name, final ObjectNode params) throws SlCommandoBuildException {
- final ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addSingleJsonElement(command, SL20Constants.SL20_COMMAND_CONTAINER_PARAMS, params, true);
return command;
@@ -47,7 +45,7 @@ public class SL20JsonBuilderUtils {
*/
public static String createSignedCommand(final String name, final ObjectNode params, final IJoseTools signer)
throws SlCommandoBuildException {
- final ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addSingleJsonElement(command, SL20Constants.SL20_COMMAND_CONTAINER_PARAMS, params, true);
return signer.createSignature(command.toString());
@@ -91,7 +89,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createCommandResponse(final String name, final ObjectNode result,
final String encryptedResult) throws SlCommandoBuildException {
- final ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addOnlyOnceOfTwo(command, SL20Constants.SL20_COMMAND_CONTAINER_RESULT,
SL20Constants.SL20_COMMAND_CONTAINER_ENCRYPTEDRESULT, result, encryptedResult);
@@ -112,7 +110,7 @@ public class SL20JsonBuilderUtils {
*/
public static String createSignedCommandResponse(final String name, final ObjectNode result,
final String encryptedResult, final JsonSecurityUtils signer) throws SlCommandoBuildException {
- final ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addOnlyOnceOfTwo(command, SL20Constants.SL20_COMMAND_CONTAINER_RESULT,
SL20Constants.SL20_COMMAND_CONTAINER_ENCRYPTEDRESULT, result, encryptedResult);
@@ -146,7 +144,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createRedirectCommandParameters(final String url, final ObjectNode command,
final ObjectNode signedCommand, final Boolean ipcRedirect) throws SlCommandoBuildException {
- final ObjectNode redirectReqParams = mapper.getMapper().createObjectNode();
+ final ObjectNode redirectReqParams = JsonMapper.getMapper().createObjectNode();
addOnlyOnceOfTwo(redirectReqParams, SL20Constants.SL20_COMMAND_PARAM_GENERAL_REDIRECT_COMMAND,
SL20Constants.SL20_COMMAND_PARAM_GENERAL_REDIRECT_SIGNEDCOMMAND, command, signedCommand);
addSingleStringElement(redirectReqParams, SL20Constants.SL20_COMMAND_PARAM_GENERAL_REDIRECT_URL, url, false);
@@ -168,7 +166,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createCallCommandParameters(final String url, final String method,
final Boolean includeTransactionId, final Map<String, String> reqParameters) throws SlCommandoBuildException {
- final ObjectNode callReqParams = mapper.getMapper().createObjectNode();
+ final ObjectNode callReqParams = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(callReqParams, SL20Constants.SL20_COMMAND_PARAM_GENERAL_CALL_URL, url, true);
addSingleStringElement(callReqParams, SL20Constants.SL20_COMMAND_PARAM_GENERAL_CALL_METHOD, method, true);
addSingleBooleanElement(callReqParams, SL20Constants.SL20_COMMAND_PARAM_GENERAL_CALL_INCLUDETRANSACTIONID,
@@ -188,7 +186,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createErrorCommandResult(final String errorCode, final String errorMsg)
throws SlCommandoBuildException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_GENERAL_RESPONSE_ERRORCODE, errorCode, true);
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_GENERAL_RESPONSE_ERRORMESSAGE, errorMsg, true);
return result;
@@ -212,7 +210,7 @@ public class SL20JsonBuilderUtils {
public static ObjectNode createQualifiedeEidConsent(final String consentTemplateId, final byte[] consent,
final boolean eidasAuthentication, final String dataUrl, final X509Certificate x5cEnc)
throws CertificateEncodingException, SlCommandoBuildException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_CONSENTTEMPLATEID, consentTemplateId, true);
addSingleByteElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_CONSENT, consent, true);
addSingleBooleanElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_EIDAS_AUTH, eidasAuthentication, false);
@@ -238,7 +236,7 @@ public class SL20JsonBuilderUtils {
public static ObjectNode createQualifiedEidCommandParameters(final String authBlockId, final String dataUrl,
final Map<String, String> additionalReqParameters, final X509Certificate x5cEnc)
throws CertificateEncodingException, SlCommandoBuildException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_AUTHBLOCKID, authBlockId, true);
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_DATAURL, dataUrl, true);
addArrayOfStringElements(params, SL20Constants.SL20_COMMAND_PARAM_EID_ATTRIBUTES, additionalReqParameters);
@@ -259,7 +257,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createQualifiedEidCommandResult(final byte[] idl, final byte[] authBlock,
final String ccsUrl, final String loa) throws SlCommandoBuildException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleByteElement(result, SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_IDL, idl, true);
addSingleByteElement(result, SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_AUTHBLOCK, authBlock, true);
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_EID_RESULT_CCSURL, ccsUrl, true);
@@ -288,7 +286,7 @@ public class SL20JsonBuilderUtils {
final int keySize, final String keyAlg, final Map<String, String> policies, final String dataUrl,
final X509Certificate x5cVdaTrust, final Boolean reqUserPassword, final X509Certificate x5cEnc)
throws SlCommandoBuildException, CertificateEncodingException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_KONTOID, kontoId, true);
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_SN, subjectName, true);
addSingleNumberElement(params, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_KEYLENGTH, keySize, true);
@@ -319,7 +317,7 @@ public class SL20JsonBuilderUtils {
public static ObjectNode createBindingKeyCommandResult(final String appId, final byte[] csr,
final X509Certificate attCert, final byte[] password)
throws SlCommandoBuildException, CertificateEncodingException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_RESULT_APPID, appId, true);
addSingleByteElement(result, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_RESULT_CSR, csr, true);
addSingleCertificateElement(result,
@@ -341,7 +339,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createStoreBindingCertCommandParams(final X509Certificate cert, final String dataUrl)
throws CertificateEncodingException, SlCommandoBuildException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleCertificateElement(params, SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_CERTIFICATE, cert, true);
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_DATAURL, dataUrl, true);
return params;
@@ -355,7 +353,7 @@ public class SL20JsonBuilderUtils {
* @throws SlCommandoBuildException In case of an error
*/
public static ObjectNode createStoreBindingCertCommandSuccessResult() throws SlCommandoBuildException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_RESULT_SUCESS,
SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_RESULT_SUCESS_VALUE, true);
return result;
@@ -375,7 +373,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createIdAndPasswordCommandParameters(final String keyAlg, final String dataUrl,
final X509Certificate x5cEnc) throws SlCommandoBuildException, CertificateEncodingException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_IDANDPASSWORD_KEYALG, keyAlg, true);
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_IDANDPASSWORD_DATAURL, dataUrl, true);
addSingleCertificateElement(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_IDANDPASSWORD_X5CENC, x5cEnc, false);
@@ -393,7 +391,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createIdAndPasswordCommandResult(final String kontoId, final byte[] password)
throws SlCommandoBuildException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_AUTH_IDANDPASSWORD_RESULT_KONTOID, kontoId, true);
addSingleByteElement(result, SL20Constants.SL20_COMMAND_PARAM_AUTH_IDANDPASSWORD_RESULT_USERPASSWORD, password,
true);
@@ -413,7 +411,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createJwsTokenAuthCommandParams(final String nonce, final String dataUrl,
final List<String> displayData, final List<String> displayUrl) throws SlCommandoBuildException {
- final ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_JWSTOKEN_NONCE, nonce, true);
addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_JWSTOKEN_DATAURL, dataUrl, true);
addArrayOfStrings(params, SL20Constants.SL20_COMMAND_PARAM_AUTH_JWSTOKEN_DISPLAYDATA, displayData);
@@ -430,7 +428,7 @@ public class SL20JsonBuilderUtils {
* @throws SlCommandoBuildException In case of an error
*/
public static ObjectNode createJwsTokenAuthCommandResult(final String nonce) throws SlCommandoBuildException {
- final ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_AUTH_JWSTOKEN_RESULT_NONCE, nonce, true);
return result;
@@ -448,7 +446,7 @@ public class SL20JsonBuilderUtils {
*/
public static ObjectNode createGenericRequest(final String reqId, final String transactionId,
final ObjectNode payLoad, final String signedPayload) throws SlCommandoBuildException {
- final ObjectNode req = mapper.getMapper().createObjectNode();
+ final ObjectNode req = JsonMapper.getMapper().createObjectNode();
addSingleIntegerElement(req, SL20Constants.SL20_VERSION, SL20Constants.CURRENT_SL20_VERSION, true);
addSingleStringElement(req, SL20Constants.SL20_REQID, reqId, true);
addSingleStringElement(req, SL20Constants.SL20_TRANSACTIONID, transactionId, false);
@@ -471,7 +469,7 @@ public class SL20JsonBuilderUtils {
public static final ObjectNode createGenericResponse(final String respId, final String inResponseTo,
final String transactionId, final ObjectNode payLoad, final String signedPayload)
throws SlCommandoBuildException {
- final ObjectNode req = mapper.getMapper().createObjectNode();
+ final ObjectNode req = JsonMapper.getMapper().createObjectNode();
addSingleIntegerElement(req, SL20Constants.SL20_VERSION, SL20Constants.CURRENT_SL20_VERSION, true);
addSingleStringElement(req, SL20Constants.SL20_RESPID, respId, true);
addSingleStringElement(req, SL20Constants.SL20_INRESPTO, inResponseTo, false);
@@ -525,7 +523,7 @@ public class SL20JsonBuilderUtils {
// TODO!!!!
private static ObjectNode createJsonSignedHeader() throws SlCommandoBuildException {
- final ObjectNode header = mapper.getMapper().createObjectNode();
+ final ObjectNode header = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(header, SL20Constants.JSON_ALGORITHM, SL20Constants.JSON_ALGORITHM_SIGNING_RS256, true);
addSingleStringElement(header, SL20Constants.JSON_CONTENTTYPE, SL20Constants.SL20_CONTENTTYPE_SIGNED_COMMAND, true);
addArrayOfStrings(header, SL20Constants.JSON_X509_CERTIFICATE, Arrays.asList(Constants.DUMMY_SIGNING_CERT));
@@ -535,7 +533,7 @@ public class SL20JsonBuilderUtils {
// TODO!!!!
private static ObjectNode createJsonEncryptionHeader() throws SlCommandoBuildException {
- final ObjectNode header = mapper.getMapper().createObjectNode();
+ final ObjectNode header = JsonMapper.getMapper().createObjectNode();
addSingleStringElement(header, SL20Constants.JSON_ALGORITHM, SL20Constants.JSON_ALGORITHM_ENC_KEY_RSAOAEP, true);
addSingleStringElement(header, SL20Constants.JSON_ENCRYPTION_PAYLOAD,
SL20Constants.JSON_ALGORITHM_ENC_PAYLOAD_A128CBCHS256, true);
@@ -559,7 +557,7 @@ public class SL20JsonBuilderUtils {
throws SlCommandoBuildException {
validateParentAndKey(parent, keyId);
if (values != null) {
- final ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
+ final ArrayNode callReqParamsArray = JsonMapper.getMapper().createArrayNode();
parent.set(keyId, callReqParamsArray);
for (final String el : values) {
callReqParamsArray.add(el);
@@ -572,11 +570,11 @@ public class SL20JsonBuilderUtils {
final Map<String, String> keyValuePairs) throws SlCommandoBuildException {
validateParentAndKey(parent, keyId);
if (keyValuePairs != null) {
- final ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
+ final ArrayNode callReqParamsArray = JsonMapper.getMapper().createArrayNode();
parent.set(keyId, callReqParamsArray);
for (final Entry<String, String> el : keyValuePairs.entrySet()) {
- final ObjectNode callReqParams = mapper.getMapper().createObjectNode();
+ final ObjectNode callReqParams = JsonMapper.getMapper().createObjectNode();
callReqParams.put(el.getKey(), el.getValue());
callReqParamsArray.add(callReqParams);