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.java88
1 files changed, 56 insertions, 32 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 611bb339..84e02887 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
@@ -27,7 +27,7 @@ public class SL20JSONBuilderUtils {
*/
public static ObjectNode createCommand(String name, ObjectNode params) throws SLCommandoBuildException {
- ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = mapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addSingleJSONElement(command, SL20Constants.SL20_COMMAND_CONTAINER_PARAMS, params, true);
return command;
@@ -44,7 +44,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static String createSignedCommand(String name, ObjectNode params, IJOSETools signer) throws SLCommandoBuildException {
- ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = mapper.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());
@@ -63,9 +63,9 @@ public class SL20JSONBuilderUtils {
public static String createEncryptedCommandoResult(ObjectNode result, JsonSecurityUtils encrypter) throws SLCommandoBuildException {
//TODO: add real implementation
//create header and footer
- String dummyHeader = createJsonEncryptionHeader(encrypter).toString();
- String payLoad = result.toString();
- String dummyFooter = createJsonSignedFooter(encrypter);
+ final String dummyHeader = createJsonEncryptionHeader(encrypter).toString();
+ final String payLoad = result.toString();
+ final String dummyFooter = createJsonSignedFooter(encrypter);
return Base64.getUrlEncoder().encodeToString(dummyHeader.getBytes()) + "."
+ Base64.getUrlEncoder().encodeToString(payLoad.getBytes()) + "."
@@ -84,7 +84,7 @@ public class SL20JSONBuilderUtils {
* @return
*/
public static ObjectNode createCommandResponse(String name, ObjectNode result, String encryptedResult) throws SLCommandoBuildException {
- ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = mapper.getMapper().createObjectNode();
addSingleStringElement(command, SL20Constants.SL20_COMMAND_CONTAINER_NAME, name, true);
addOnlyOnceOfTwo(command,
SL20Constants.SL20_COMMAND_CONTAINER_RESULT, SL20Constants.SL20_COMMAND_CONTAINER_ENCRYPTEDRESULT,
@@ -103,17 +103,17 @@ public class SL20JSONBuilderUtils {
* @return
*/
public static String createSignedCommandResponse(String name, ObjectNode result, String encryptedResult, JsonSecurityUtils signer) throws SLCommandoBuildException {
- ObjectNode command = mapper.getMapper().createObjectNode();
+ final ObjectNode command = mapper.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);
- String encodedCommand = command.toString();
+ final String encodedCommand = command.toString();
//TODO: add real implementation
//create header and footer
- String dummyHeader = createJsonSignedHeader(signer).toString();
- String dummyFooter = createJsonSignedFooter(signer);
+ final String dummyHeader = createJsonSignedHeader(signer).toString();
+ final String dummyFooter = createJsonSignedFooter(signer);
return Base64.getUrlEncoder().encodeToString(dummyHeader.getBytes()) + "."
+ Base64.getUrlEncoder().encodeToString(encodedCommand.getBytes()) + "."
@@ -132,7 +132,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createRedirectCommandParameters(String url, ObjectNode command, ObjectNode signedCommand, Boolean ipcRedirect) throws SLCommandoBuildException{
- ObjectNode redirectReqParams = mapper.getMapper().createObjectNode();
+ final ObjectNode redirectReqParams = mapper.getMapper().createObjectNode();
addOnlyOnceOfTwo(redirectReqParams,
SL20Constants.SL20_COMMAND_PARAM_GENERAL_REDIRECT_COMMAND, SL20Constants.SL20_COMMAND_PARAM_GENERAL_REDIRECT_SIGNEDCOMMAND,
command, signedCommand);
@@ -153,7 +153,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createCallCommandParameters(String url, String method, Boolean includeTransactionId, Map<String, String> reqParameters) throws SLCommandoBuildException {
- ObjectNode callReqParams = mapper.getMapper().createObjectNode();
+ final ObjectNode callReqParams = mapper.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, includeTransactionId, false);
@@ -171,13 +171,36 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createErrorCommandResult(String errorCode, String errorMsg) throws SLCommandoBuildException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.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;
}
+ /**
+ * Create parameters for qualifiedeID command
+ *
+ * @param consentTemplateId Identifier of the template that is used for consent visualization
+ * @param consent Consent that has to be signed by user
+ * @param dataUrl
+ * @param additionalReqParameters
+ * @param x5cEnc
+ * @return
+ * @throws CertificateEncodingException
+ * @throws SLCommandoBuildException
+ */
+ public static ObjectNode createQualifiedeEIDConsent(String consentTemplateId, byte[] consent, String dataUrl,
+ X509Certificate x5cEnc) throws CertificateEncodingException, SLCommandoBuildException {
+ final ObjectNode params = mapper.getMapper().createObjectNode();
+ addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_CONSENTTEMPLATEID, consentTemplateId, true);
+ addSingleByteElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_CONSENT, consent, true);
+ addSingleStringElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_DATAURL, dataUrl, true);
+ addSingleCertificateElement(params, SL20Constants.SL20_COMMAND_PARAM_EID_X5CENC, x5cEnc, false);
+ return params;
+
+ }
+
/**
* Create parameters for qualifiedeID command
@@ -190,9 +213,10 @@ public class SL20JSONBuilderUtils {
* @throws CertificateEncodingException
* @throws SLCommandoBuildException
*/
+ @Deprecated
public static ObjectNode createQualifiedeIDCommandParameters(String authBlockId, String dataUrl,
Map<String, String> additionalReqParameters, X509Certificate x5cEnc) throws CertificateEncodingException, SLCommandoBuildException {
- ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = mapper.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);
@@ -212,7 +236,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createQualifiedeIDCommandResult(byte[] idl, byte[] authBlock, String ccsURL, String LoA) throws SLCommandoBuildException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.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);
@@ -240,7 +264,7 @@ public class SL20JSONBuilderUtils {
*/
public static ObjectNode createBindingKeyCommandParams(String kontoId, String subjectName, int keySize, String keyAlg,
Map<String, String> policies, String dataUrl, X509Certificate x5cVdaTrust, Boolean reqUserPassword, X509Certificate x5cEnc) throws SLCommandoBuildException, CertificateEncodingException {
- ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = mapper.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);
@@ -266,7 +290,7 @@ public class SL20JSONBuilderUtils {
* @throws CertificateEncodingException
*/
public static ObjectNode createBindingKeyCommandResult(String appId, byte[] csr, X509Certificate attCert, byte[] password) throws SLCommandoBuildException, CertificateEncodingException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.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, SL20Constants.SL20_COMMAND_PARAM_BINDING_CREATE_RESULT_KEYATTESTATIONZERTIFICATE, attCert, false);
@@ -285,7 +309,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createStoreBindingCertCommandParams(X509Certificate cert, String dataUrl) throws CertificateEncodingException, SLCommandoBuildException {
- ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = mapper.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;
@@ -299,7 +323,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createStoreBindingCertCommandSuccessResult() throws SLCommandoBuildException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_RESULT_SUCESS,
SL20Constants.SL20_COMMAND_PARAM_BINDING_STORE_RESULT_SUCESS_VALUE, true);
return result;
@@ -318,7 +342,7 @@ public class SL20JSONBuilderUtils {
* @throws CertificateEncodingException
*/
public static ObjectNode createIdAndPasswordCommandParameters(String keyAlg, String dataUrl, X509Certificate x5cEnc) throws SLCommandoBuildException, CertificateEncodingException {
- ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = mapper.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);
@@ -335,7 +359,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createIdAndPasswordCommandResult(String kontoId, byte[] password) throws SLCommandoBuildException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.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);
return result;
@@ -353,7 +377,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createJwsTokenAuthCommandParams(String nonce, String dataUrl, List<String> displayData, List<String> displayUrl) throws SLCommandoBuildException {
- ObjectNode params = mapper.getMapper().createObjectNode();
+ final ObjectNode params = mapper.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);
@@ -370,7 +394,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createJwsTokenAuthCommandResult(String nonce) throws SLCommandoBuildException {
- ObjectNode result = mapper.getMapper().createObjectNode();
+ final ObjectNode result = mapper.getMapper().createObjectNode();
addSingleStringElement(result, SL20Constants.SL20_COMMAND_PARAM_AUTH_JWSTOKEN_RESULT_NONCE, nonce, true);
return result;
@@ -388,7 +412,7 @@ public class SL20JSONBuilderUtils {
* @throws SLCommandoBuildException
*/
public static ObjectNode createGenericRequest(String reqId, String transactionId, ObjectNode payLoad, String signedPayload) throws SLCommandoBuildException {
- ObjectNode req = mapper.getMapper().createObjectNode();
+ final ObjectNode req = mapper.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);
@@ -411,7 +435,7 @@ public class SL20JSONBuilderUtils {
*/
public static final ObjectNode createGenericResponse(String respId, String inResponseTo, String transactionId,
ObjectNode payLoad, String signedPayload) throws SLCommandoBuildException {
- ObjectNode req = mapper.getMapper().createObjectNode();
+ final ObjectNode req = mapper.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, true);
@@ -454,7 +478,7 @@ public class SL20JSONBuilderUtils {
//TODO!!!!
private static ObjectNode createJsonSignedHeader(JsonSecurityUtils signer) throws SLCommandoBuildException {
- ObjectNode header = mapper.getMapper().createObjectNode();
+ final ObjectNode header = mapper.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));
@@ -464,7 +488,7 @@ public class SL20JSONBuilderUtils {
//TODO!!!!
private static ObjectNode createJsonEncryptionHeader(JsonSecurityUtils signer) throws SLCommandoBuildException {
- ObjectNode header = mapper.getMapper().createObjectNode();
+ final ObjectNode header = mapper.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);
addSingleStringElement(header, SL20Constants.JSON_CONTENTTYPE, SL20Constants.SL20_CONTENTTYPE_ENCRYPTED_RESULT, true);
@@ -488,9 +512,9 @@ public class SL20JSONBuilderUtils {
private static void addArrayOfStrings(ObjectNode parent, String keyId, List<String> values) throws SLCommandoBuildException {
validateParentAndKey(parent, keyId);
if (values != null) {
- ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
+ final ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
parent.set(keyId, callReqParamsArray );
- for(String el : values)
+ for(final String el : values)
callReqParamsArray.add(el);
}
@@ -500,11 +524,11 @@ public class SL20JSONBuilderUtils {
private static void addArrayOfStringElements(ObjectNode parent, String keyId, Map<String, String> keyValuePairs) throws SLCommandoBuildException {
validateParentAndKey(parent, keyId);
if (keyValuePairs != null) {
- ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
+ final ArrayNode callReqParamsArray = mapper.getMapper().createArrayNode();
parent.set(keyId, callReqParamsArray);
- for(Entry<String, String> el : keyValuePairs.entrySet()) {
- ObjectNode callReqParams = mapper.getMapper().createObjectNode();
+ for(final Entry<String, String> el : keyValuePairs.entrySet()) {
+ final ObjectNode callReqParams = mapper.getMapper().createObjectNode();
callReqParams.put(el.getKey(), el.getValue());
callReqParamsArray.add(callReqParams);