diff options
Diffstat (limited to 'eaaf_modules/eaaf_module_auth_sl20')
5 files changed, 46 insertions, 166 deletions
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java index 2387a9f2..6868ac97 100644 --- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java +++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonMapper.java @@ -1,44 +1,20 @@ package at.gv.egiz.eaaf.modules.auth.sl20.utils; -import java.io.IOException; -import java.io.InputStream; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.lang.NonNull; - import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.type.TypeFactory; - -import at.gv.egiz.eaaf.core.api.utils.IJsonMapper; -import at.gv.egiz.eaaf.core.exceptions.EaafJsonMapperException; - -public class JsonMapper implements IJsonMapper { - private static final Logger log = LoggerFactory.getLogger(JsonMapper.class); - private final ObjectMapper mapper = new ObjectMapper(); +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; - /** - * The default constructor where the default pretty printer is disabled. - */ - public JsonMapper() { - this(false); +@Slf4j +public class JsonMapper { + + @Getter + private static final ObjectMapper mapper = new ObjectMapper(); - } - - /** - * The constructor. - * - * @param prettyPrint enables or disables the default pretty printer - */ - public JsonMapper(@NonNull final boolean prettyPrint) { + static { log.trace("Initializing JSON object-mapper ... "); mapper.configure(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY, true); mapper.configure(DeserializationFeature.FAIL_ON_TRAILING_TOKENS, true); @@ -46,94 +22,7 @@ public class JsonMapper implements IJsonMapper { mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.setVisibility(PropertyAccessor.GETTER, Visibility.PUBLIC_ONLY); mapper.setVisibility(PropertyAccessor.IS_GETTER, Visibility.PUBLIC_ONLY); - if (prettyPrint) { - mapper.enable(SerializationFeature.INDENT_OUTPUT); - } - - log.debug("JSON object-mapper initialized"); - - } - - /* - * (non-Javadoc) - * - * @at.gv.egiz.eaaf.core.api.utils.IJsonMapper#getMapper() - */ - public ObjectMapper getMapper() { - return mapper; - - } - - /* - * (non-Javadoc) - * - * @see at.gv.egiz.eaaf.core.api.utils.IJsonMapper#serialize(java.lang.Object) - */ - @Override - public String serialize(final Object value) throws EaafJsonMapperException { - try { - return mapper.writeValueAsString(value); - - } catch (final JsonProcessingException e) { - log.warn("JSON mapping FAILED with error: {}", e.getMessage()); - throw new EaafJsonMapperException(e.getMessage(), e); - - } - - } - - /* - * (non-Javadoc) - * - * @see at.gv.egiz.eaaf.core.api.utils.IJsonMapper#deserialize(java.lang.String, - * java.lang.Class) - */ - @Override - public <T> Object deserialize(final String value, final Class<T> clazz) throws EaafJsonMapperException { - try { - if (clazz != null) { - if (clazz.isAssignableFrom(TypeReference.class)) { - return mapper.readValue(value, clazz); - } else { - final JavaType javaType = TypeFactory.defaultInstance().constructType(clazz); - return mapper.readValue(value, javaType); - - } - - } else { - return mapper.readValue(value, Object.class); - } - - } catch (final IOException e) { - log.warn("JSON mapping FAILED with error: {}", e.getMessage()); - throw new EaafJsonMapperException(e.getMessage(), e); - - } - - } - - @Override - public <T> Object deserialize(final InputStream is, final Class<T> clazz) throws EaafJsonMapperException { - try { - if (clazz != null) { - if (clazz.isAssignableFrom(TypeReference.class)) { - return mapper.readValue(is, clazz); - } else { - final JavaType javaType = TypeFactory.defaultInstance().constructType(clazz); - return mapper.readValue(is, javaType); - - } - - } else { - return mapper.readValue(is, Object.class); - } - - } catch (final IOException e) { - log.warn("JSON mapping FAILED with error: {}", e.getMessage()); - throw new EaafJsonMapperException(e.getMessage(), e); - - } - + } } diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonSecurityUtils.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonSecurityUtils.java index 690a07dd..4e939d55 100644 --- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonSecurityUtils.java +++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/JsonSecurityUtils.java @@ -23,8 +23,6 @@ import org.jose4j.jws.AlgorithmIdentifiers; import org.jose4j.jwx.HeaderParameterNames; import org.jose4j.keys.X509Util; import org.jose4j.lang.JoseException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; @@ -43,18 +41,19 @@ import at.gv.egiz.eaaf.core.impl.credential.KeyStoreConfiguration; import at.gv.egiz.eaaf.core.impl.credential.KeyStoreConfiguration.KeyStoreType; import at.gv.egiz.eaaf.core.impl.data.Pair; import at.gv.egiz.eaaf.core.impl.utils.JoseUtils; -import at.gv.egiz.eaaf.core.impl.utils.X509Utils; import at.gv.egiz.eaaf.core.impl.utils.JoseUtils.JwsResult; +import at.gv.egiz.eaaf.core.impl.utils.X509Utils; import at.gv.egiz.eaaf.modules.auth.sl20.Constants; import at.gv.egiz.eaaf.modules.auth.sl20.data.VerificationResult; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SL20Exception; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SL20SecurityException; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SlCommandoBuildException; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SlCommandoParserException; +import lombok.extern.slf4j.Slf4j; @Service +@Slf4j public class JsonSecurityUtils implements IJoseTools { - private static final Logger log = LoggerFactory.getLogger(JsonSecurityUtils.class); private static final String FRIENDLYNAME_KEYSTORE = "SL2.0 KeyStore"; private static final String FRIENDLYNAME_TRUSTSTORE = "SL2.0 TrustStore"; @@ -67,8 +66,6 @@ public class JsonSecurityUtils implements IJoseTools { private Pair<KeyStore, Provider> keyStore; private Pair<KeyStore, Provider> trustStore; - private static JsonMapper mapper = new JsonMapper(); - @PostConstruct protected void initalize() throws SL20Exception { log.info("Initialize SL2.0 authentication security constrains ... "); @@ -160,8 +157,8 @@ public class JsonSecurityUtils implements IJoseTools { final JwsResult result = JoseUtils.validateSignature(serializedContent, trustedCerts, constraints); return new VerificationResult( - mapper.getMapper().readTree(result.getFullJoseHeader().getFullHeaderAsJsonString()), - mapper.getMapper().readTree(result.getPayLoad()), + JsonMapper.getMapper().readTree(result.getFullJoseHeader().getFullHeaderAsJsonString()), + JsonMapper.getMapper().readTree(result.getPayLoad()), result.getX5cCerts(), result.isValid()); } @@ -279,7 +276,7 @@ public class JsonSecurityUtils implements IJoseTools { receiverJwe.setKey(JoseUtils.convertToBcKeyIfRequired(encryptionCred.getFirst())); // decrypt payload - return mapper.getMapper().readTree(receiverJwe.getPlaintextString()); + return JsonMapper.getMapper().readTree(receiverJwe.getPlaintextString()); } catch (final JoseException | EaafKeyAccessException e) { log.warn("SL2.0 result decryption FAILED", e); diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java index 2b6ddb96..96fd34e8 100644 --- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java +++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20HttpBindingUtils.java @@ -33,7 +33,6 @@ import lombok.Getter; public class SL20HttpBindingUtils { private static final Logger log = LoggerFactory.getLogger(SL20HttpBindingUtils.class); - private static JsonMapper mapper = new JsonMapper(); @Data @Getter @@ -81,7 +80,7 @@ public class SL20HttpBindingUtils { } final String sl20RespString = new URIBuilder(locationHeader[0].getValue()).getQueryParams().get(0).getValue(); - return new Sl20ResponseHolder(mapper.getMapper().readTree(Base64Url.decode(sl20RespString)), + return new Sl20ResponseHolder(JsonMapper.getMapper().readTree(Base64Url.decode(sl20RespString)), response.getStatusLine()); } else if ( @@ -96,7 +95,7 @@ public class SL20HttpBindingUtils { bodyMsg = EntityUtils.toString(response.getEntity()); log.info("SL20 response with http-code: {0} and errorMsg: {1}", httpStatusCode, bodyMsg); Sl20ResponseHolder holder = new Sl20ResponseHolder( - mapper.getMapper().readTree(bodyMsg), response.getStatusLine()); + JsonMapper.getMapper().readTree(bodyMsg), response.getStatusLine()); return holder; } catch (final IOException | ParseException e) { @@ -175,7 +174,7 @@ public class SL20HttpBindingUtils { if (resp != null && resp.getContent() != null) { final String rawSL20Resp = EntityUtils.toString(resp); try { - final JsonNode sl20Resp = mapper.getMapper().readTree(rawSL20Resp); + final JsonNode sl20Resp = JsonMapper.getMapper().readTree(rawSL20Resp); if (sl20Resp != null) { return sl20Resp; 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); diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonExtractorUtils.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonExtractorUtils.java index bed25c0c..4da46235 100644 --- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonExtractorUtils.java +++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/utils/SL20JsonExtractorUtils.java @@ -8,19 +8,16 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import at.gv.egiz.eaaf.modules.auth.sl20.data.VerificationResult; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SL20Exception; import at.gv.egiz.eaaf.modules.auth.sl20.exceptions.SlCommandoParserException; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class SL20JsonExtractorUtils { - private static final Logger log = LoggerFactory.getLogger(SL20JsonExtractorUtils.class); - private static JsonMapper mapper = new JsonMapper(); /** * Extract String value from JSON. @@ -234,7 +231,7 @@ public class SL20JsonExtractorUtils { // dummy code try { final String[] signedPayload = encryptedResult.toString().split("\\."); - final JsonNode payLoad = mapper.getMapper() + final JsonNode payLoad = JsonMapper.getMapper() .readTree(new String(Base64.getUrlDecoder().decode(signedPayload[1]), "UTF-8")); return payLoad; |