From 9bbb73596c7b5a6f1de575565cb92d5afeca1cc1 Mon Sep 17 00:00:00 2001 From: andresfv95 Date: Mon, 7 Oct 2024 06:46:00 -0500 Subject: [PATCH] style: add Java linter (#17) --- .github/workflows/pr.yml | 28 + README.md | 3 +- pom.xml | 17 +- .../io/twentysixty/sa/client/enums/Mrz.java | 129 ++-- .../sa/client/jms/AbstractConsumer.java | 727 +++++++++--------- .../sa/client/jms/AbstractProducer.java | 357 +++++---- .../sa/client/jms/ConsumerInterface.java | 21 +- .../sa/client/jms/ProducerInterface.java | 19 +- .../model/credential/CredentialType.java | 87 ++- .../model/event/ConnectionStateUpdated.java | 59 +- .../model/event/CredentialReceptionState.java | 76 +- .../client/model/event/DidExchangeState.java | 113 ++- .../sa/client/model/event/Event.java | 64 +- .../sa/client/model/event/EventType.java | 74 +- .../client/model/event/MessageReceived.java | 25 +- .../sa/client/model/event/MessageState.java | 93 ++- .../model/event/MessageStateUpdated.java | 61 +- .../sa/client/model/message/BaseMessage.java | 169 ++-- .../sa/client/model/message/Ciphering.java | 41 +- .../sa/client/model/message/Claim.java | 54 +- .../model/message/ContextualMenuItem.java | 73 +- .../model/message/ContextualMenuRequest.java | 8 +- .../model/message/ContextualMenuSelect.java | 22 +- .../model/message/ContextualMenuUpdate.java | 113 ++- .../message/CredentialIssuanceMessage.java | 39 +- .../message/CredentialReceptionMessage.java | 22 +- .../message/CredentialRequestMessage.java | 42 +- .../sa/client/model/message/IdMessage.java | 30 +- .../message/IdentityProofRequestMessage.java | 24 +- .../message/IdentityProofResultMessage.java | 8 +- .../message/IdentityProofSubmitMessage.java | 23 +- .../model/message/InvitationMessage.java | 67 +- .../sa/client/model/message/MediaItem.java | 314 ++++---- .../sa/client/model/message/MediaMessage.java | 46 +- .../model/message/MenuDisplayMessage.java | 76 +- .../sa/client/model/message/MenuItem.java | 57 +- .../model/message/MenuItemSelection.java | 23 +- .../model/message/MenuSelectMessage.java | 37 +- .../model/message/MessageReceiptOptions.java | 62 +- .../client/model/message/MessageResponse.java | 9 +- .../sa/client/model/message/Parameters.java | 48 +- .../client/model/message/ProfileMessage.java | 14 +- .../client/model/message/ProofItemResult.java | 59 +- .../model/message/ProofItemResultValue.java | 5 +- .../client/model/message/ReceiptsMessage.java | 19 +- .../model/message/RequestedProofItem.java | 89 ++- .../model/message/SerializableObject.java | 3 +- .../client/model/message/SubmitProofItem.java | 75 +- .../message/TerminateConnectionMessage.java | 3 +- .../sa/client/model/message/TextMessage.java | 50 +- .../calls/CallAcceptRequestMessage.java | 9 +- .../message/calls/CallEndRequestMessage.java | 4 +- .../calls/CallOfferRequestMessage.java | 9 +- .../calls/CallRejectRequestMessage.java | 4 +- .../sa/client/model/message/mrtd/MrzData.java | 46 +- .../message/mrtd/MrzDataRequestMessage.java | 18 +- .../message/mrtd/MrzDataSubmitMessage.java | 6 +- .../client/res/c/CredentialTypeInterface.java | 28 +- .../sa/client/res/c/MessageInterface.java | 15 +- .../res/c/v1/CredentialTypeInterface.java | 28 +- .../sa/client/res/c/v1/MessageInterface.java | 15 +- .../res/s/ConnectionEventInterface.java | 13 +- .../client/res/s/MessageEventInterface.java | 29 +- .../twentysixty/sa/client/util/Aes256cbc.java | 72 +- .../twentysixty/sa/client/util/ISOUtil.java | 287 +++---- .../sa/client/util/InstantDeserializer.java | 24 +- .../sa/client/util/InstantSerializer.java | 37 +- .../twentysixty/sa/client/util/JsonUtil.java | 106 ++- .../sa/client/util/TokenGenerator.java | 11 +- .../sa/client/util/testing/Tryme.java | 24 +- 70 files changed, 2218 insertions(+), 2244 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..230e311 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,28 @@ +name: PR Check + +on: + pull_request: + branches: [ main, dev ] + +env: + QUARKUS_CONTAINER_IMAGE_USERNAME: ${{ secrets.DOCKER_HUB_LOGIN }} + QUARKUS_CONTAINER_IMAGE_PASSWORD: ${{ secrets.DOCKER_HUB_PWD }} + +jobs: + pr_check: + runs-on: ubuntu-latest + steps: + - name: Checkout gh-repo + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + cache: maven + + - name: Clean and spotless + run: | + # Skipping Docker image build for PR verification + mvn clean fmt:check \ No newline at end of file diff --git a/README.md b/README.md index d1c29e1..adbad1a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Client tools for building Quarkus java DIDcomm Verifiable Credential powered conversational service (Chatbots) with [2060.io Service Agent](https://github.com/2060-io/2060-service-agent/blob/main/doc/service-agent-api.md) ## How to use -On dev mode use the command `mvn clean install -Dgpg.skip` to run the project +- On dev mode use the command `mvn clean install -Dgpg.skip` to run the project +- To apply format run `mvn fmt:format` ## Releases diff --git a/pom.xml b/pom.xml index 4d64d02..6aed79d 100644 --- a/pom.xml +++ b/pom.xml @@ -70,6 +70,21 @@ ${project.artifactId} + + com.spotify.fmt + fmt-maven-plugin + 2.23 + + + + format + + + + + true + + org.sonatype.central central-publishing-maven-plugin @@ -124,7 +139,7 @@ - + diff --git a/src/main/java/io/twentysixty/sa/client/enums/Mrz.java b/src/main/java/io/twentysixty/sa/client/enums/Mrz.java index 85abaf3..f80d3cf 100644 --- a/src/main/java/io/twentysixty/sa/client/enums/Mrz.java +++ b/src/main/java/io/twentysixty/sa/client/enums/Mrz.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -15,69 +14,69 @@ @Setter @ToString public class Mrz { - public enum Format { - @JsonProperty("TD1") - TD1, - @JsonProperty("TD2") - TD2, - @JsonProperty("TD3") - TD3, - @JsonProperty("FRENCH_NATIONAL_ID") - FRENCH_NATIONAL_ID, - @JsonProperty("FRENCH_DRIVING_LICENSE") - FRENCH_DRIVING_LICENSE, - @JsonProperty("SWISS_DRIVING_LICENSE") - SWISS_DRIVING_LICENSE; - } + public enum Format { + @JsonProperty("TD1") + TD1, + @JsonProperty("TD2") + TD2, + @JsonProperty("TD3") + TD3, + @JsonProperty("FRENCH_NATIONAL_ID") + FRENCH_NATIONAL_ID, + @JsonProperty("FRENCH_DRIVING_LICENSE") + FRENCH_DRIVING_LICENSE, + @JsonProperty("SWISS_DRIVING_LICENSE") + SWISS_DRIVING_LICENSE; + } - public enum FieldName { - @JsonProperty("administrativeCode") - ADMINISTRATIVE_CODE, - @JsonProperty("administrativeCode2") - ADMINISTRATIVE_CODE2, - @JsonProperty("birthDate") - BIRTH_DATE, - @JsonProperty("birthDateCheckDigit") - BIRTH_DATE_CHECK_DIGIT, - @JsonProperty("compositeCheckDigit") - COMPOSITE_CHECK_DIGIT, - @JsonProperty("documentNumber") - DOCUMENT_NUMBER, - @JsonProperty("documentNumberCheckDigit") - DOCUMENT_NUMBER_CHECK_DIGIT, - @JsonProperty("documentCode") - DOCUMENT_CODE, - @JsonProperty("expirationDate") - EXPIRATION_DATE, - @JsonProperty("expirationDateCheckDigit") - EXPIRATION_DATE_CHECK_DIGIT, - @JsonProperty("firstName") - FIRST_NAME, - @JsonProperty("issueDate") - ISSUE_DATE, - @JsonProperty("issuingState") - ISSUING_STATE, - @JsonProperty("languageCode") - LANGUAGE_CODE, - @JsonProperty("lastName") - LAST_NAME, - @JsonProperty("nationality") - NATIONALITY, - @JsonProperty("optional") - OPTIONAL, - @JsonProperty("optional1") - OPTIONAL1, - @JsonProperty("optional2") - OPTIONAL2, - @JsonProperty("personalNumber") - PERSONAL_NUMBER, - @JsonProperty("personalNumberCheckDigit") - PERSONAL_NUMBER_CHECK_DIGIT, - @JsonProperty("pinCode") - PIN_CODE, - @JsonProperty("sex") - SEX, - @JsonProperty("versionNumber") - VERSION_NUMBER; - } + public enum FieldName { + @JsonProperty("administrativeCode") + ADMINISTRATIVE_CODE, + @JsonProperty("administrativeCode2") + ADMINISTRATIVE_CODE2, + @JsonProperty("birthDate") + BIRTH_DATE, + @JsonProperty("birthDateCheckDigit") + BIRTH_DATE_CHECK_DIGIT, + @JsonProperty("compositeCheckDigit") + COMPOSITE_CHECK_DIGIT, + @JsonProperty("documentNumber") + DOCUMENT_NUMBER, + @JsonProperty("documentNumberCheckDigit") + DOCUMENT_NUMBER_CHECK_DIGIT, + @JsonProperty("documentCode") + DOCUMENT_CODE, + @JsonProperty("expirationDate") + EXPIRATION_DATE, + @JsonProperty("expirationDateCheckDigit") + EXPIRATION_DATE_CHECK_DIGIT, + @JsonProperty("firstName") + FIRST_NAME, + @JsonProperty("issueDate") + ISSUE_DATE, + @JsonProperty("issuingState") + ISSUING_STATE, + @JsonProperty("languageCode") + LANGUAGE_CODE, + @JsonProperty("lastName") + LAST_NAME, + @JsonProperty("nationality") + NATIONALITY, + @JsonProperty("optional") + OPTIONAL, + @JsonProperty("optional1") + OPTIONAL1, + @JsonProperty("optional2") + OPTIONAL2, + @JsonProperty("personalNumber") + PERSONAL_NUMBER, + @JsonProperty("personalNumberCheckDigit") + PERSONAL_NUMBER_CHECK_DIGIT, + @JsonProperty("pinCode") + PIN_CODE, + @JsonProperty("sex") + SEX, + @JsonProperty("versionNumber") + VERSION_NUMBER; + } } diff --git a/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java b/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java index bef9940..05847dc 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java +++ b/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java @@ -1,13 +1,8 @@ package io.twentysixty.sa.client.jms; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - +import com.fasterxml.jackson.core.JsonProcessingException; +import io.smallrye.mutiny.Uni; +import io.twentysixty.sa.client.util.JsonUtil; import jakarta.jms.ConnectionFactory; import jakarta.jms.JMSConsumer; import jakarta.jms.JMSContext; @@ -15,394 +10,392 @@ import jakarta.jms.ObjectMessage; import jakarta.jms.Queue; import jakarta.jms.Session; - +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import org.jboss.logging.Logger; -import com.fasterxml.jackson.core.JsonProcessingException; - -import io.smallrye.mutiny.Uni; -import io.twentysixty.sa.client.model.message.BaseMessage; -import io.twentysixty.sa.client.util.JsonUtil; - - -public class AbstractConsumer implements ConsumerInterface { - - private ConnectionFactory connectionFactory; - - - private Long exDelay; - private String queueName; - private Integer threads; - private Boolean debug; - - - - private static final Logger logger = Logger.getLogger(AbstractConsumer.class); - - private Map lockObjs = new HashMap(); - private Map runnings = new HashMap(); - private Map starteds = new HashMap(); - private Map contexts = new HashMap(); - - - private static ExecutorService executor = Executors.newCachedThreadPool(); - - - protected void _onStart() { - - - for (int i=0; i consumer(UUID uuid) { - - JMSContext context = null; - Queue queue = null; - - Object lockObj = new Object(); - synchronized (lockObjs) { - lockObjs.put(uuid, lockObj); - } - synchronized (runnings) { - runnings.put(uuid, true); - } - - - long now = System.currentTimeMillis(); - /*synchronized (lockObj) { - try { - lockObj.wait(10000l); - } catch (InterruptedException e) { - - } - } - */ - - while (true) { - Boolean started = null; - synchronized(starteds) { - started = starteds.get(uuid); - - } - if ((started == null) || (!started)) { - break; - } - - - if (debug) logger.info("consumer: running " + uuid); - - try { - - if (debug) logger.info("consumer " + queueName + ": create session " + uuid ); - - - if (context == null) { - context = getConnectionFactory().createContext(Session.SESSION_TRANSACTED); - synchronized (contexts) { - contexts.put(uuid, context); - } - - } - - - if (debug) logger.info("consumer " + queueName + ": session created " + uuid ); - - if (queue == null) { - queue = context.createQueue(queueName); - } - if (debug) logger.info("consumer " + queueName + ": create consumer " + uuid ); - JMSConsumer consumer = null; - String messageSelector = getMessageSelector(); - - if (messageSelector != null) { - consumer = context.createConsumer(queue, getMessageSelector()); - } else { - consumer = context.createConsumer(queue); - } - - - - if (debug) logger.info("consumer " + queueName + ": waiting for message... " + uuid); - - - while (true) { - started = null; - - synchronized(starteds) { - started = starteds.get(uuid); - - } - if ((started == null) || (!started)) { - break; - } - - - now = System.currentTimeMillis(); - - if (debug) - logger.info("consumer: waiting for message... " + uuid + " " + (System.currentTimeMillis() - now)); - - Message message = consumer.receive(); - - if (message != null) { - if (debug) - logger.info("consumer: received message " + uuid + " " + (System.currentTimeMillis() - now)); - - +public class AbstractConsumer implements ConsumerInterface { - //BaseMessage baseMessage = null; + private ConnectionFactory connectionFactory; - if (message instanceof ObjectMessage) { + private Long exDelay; + private String queueName; + private Integer threads; + private Boolean debug; - ObjectMessage objMsg = (ObjectMessage) message; - //baseMessage = (BaseMessage) objMsg.getObject(); + private static final Logger logger = Logger.getLogger(AbstractConsumer.class); - if (debug) { - try { - logger.info(JsonUtil.serialize(objMsg.getObject(), false)); - } catch (JsonProcessingException e2) { + private Map lockObjs = new HashMap(); + private Map runnings = new HashMap(); + private Map starteds = new HashMap(); + private Map contexts = new HashMap(); - } - } - try { - M baseMessage = (M) objMsg.getObject(); - this.receiveMessage(baseMessage); - //messageResource.sendMessage(baseMessage); + private static ExecutorService executor = Executors.newCachedThreadPool(); + protected void _onStart() { - context.commit(); - if (debug) - logger.info("consumer: " + queueName + " after commit "+ uuid + " " + (System.currentTimeMillis() - now)); + for (int i = 0; i < threads; i++) { + logger.info("onStart: starting consumer #" + i + " for " + queueName); + UUID uuid = UUID.randomUUID(); + synchronized (starteds) { + starteds.put(uuid, true); + } - } catch (Exception e) { - try { - logger.warn("consumer: " + queueName + " "+ uuid + " " + (System.currentTimeMillis() - now)+ ": exception " + JsonUtil.serialize(objMsg, false), e); - } catch (JsonProcessingException e1) { - logger.warn("consumer: " + queueName + " "+ uuid + " " + (System.currentTimeMillis() - now)+ ": exception", e); - } - context.rollback(); - //if (debug) - logger.info("consumer: " + queueName + " after rollback "+ uuid + " " + (System.currentTimeMillis() - now)); + startConsumer(uuid); + } + } - } - } else { - if (debug) logger.info("consumer " + queueName + " "+ uuid + " " + (System.currentTimeMillis() - now)+ ": unkown event " + message); - context.commit(); - } + protected void _onStop() { + this.stopConsumers(); + } - } else { - if (debug) - logger.info("consumer: no delivered message " + uuid + " " + (System.currentTimeMillis() - now)); + private void stopConsumers() { - synchronized (lockObj) { - try { - if (debug) logger.info("consumer: waiting thread " + uuid + " " + (System.currentTimeMillis() - now)); - lockObj.wait(1000); - } catch (InterruptedException e1) { - } - } - } + UUID[] keySet = null; + synchronized (lockObjs) { + keySet = lockObjs.keySet().toArray(new UUID[0]); + } + for (UUID uuid : keySet) { + if (debug) logger.info("stopConsumers: stopping consumer " + uuid + " for " + queueName); + setStoppedConsumer(uuid); - } - consumer.close(); - context.close(); - consumer = null; - context = null; - } catch (Exception e) { - - logger.error("", e); - try { + JMSContext context = null; - context.close(); - } catch (Exception e1) { + synchronized (contexts) { + context = contexts.get(uuid); + } - } - context = null; - queue = null; + if (context != null) { + if (debug) logger.info("stopConsumers: closing context " + uuid); + context.close(); + } + if (debug) logger.info("stopConsumers: closing context done, calling stopConsumer " + uuid); + stopConsumer(uuid); + if (debug) logger.info("stopConsumers: removing lockObj " + uuid); - synchronized (lockObj) { - try { - lockObj.wait(exDelay); - } catch (InterruptedException e1) { - } - } - } - } - synchronized (runnings) { - runnings.put(uuid, false); - } + synchronized (lockObjs) { + lockObjs.remove(uuid); + } + } + } - return Uni.createFrom().voidItem(); - } + public void startConsumer(UUID uuid) { + Uni.createFrom() + .item(uuid) + .emitOn(executor) + .subscribe() + .with(this::consumer, Throwable::printStackTrace); + } - @Override - public void setExDelay(Long exDelay) { - this.exDelay = exDelay; - } + private static Object shutdownLockObj = new Object(); - @Override - public void setQueueName(String queueName) { - this.queueName = queueName; - } + public void setStoppedConsumer(UUID uuid) { - @Override - public void setThreads(Integer threads) { - this.threads = threads; - } - - @Override - public void setDebug(boolean debug) { - this.debug = debug; - } + synchronized (starteds) { + starteds.put(uuid, false); + } + } - @Override - public void receiveMessage(M message) throws Exception { - // TODO Auto-generated method stub - - } - - public ConnectionFactory getConnectionFactory() { - return connectionFactory; - } - - public void setConnectionFactory(ConnectionFactory connectionFactory) { - this.connectionFactory = connectionFactory; - } - @Override - public String getMessageSelector() { - return null; - } + public void stopConsumer(UUID uuid) { + Object lockObj = lockObjs.get(uuid); + if (lockObj != null) { + synchronized (lockObj) { + try { + lockObj.notifyAll(); + } catch (Exception e) { + logger.error("stopConsumer", e); + } + } + } + while (true) { + + Boolean running = null; + synchronized (runnings) { + running = runnings.get(uuid); + } + if (!running) { + break; + } + synchronized (shutdownLockObj) { + try { + shutdownLockObj.wait(100); + } catch (InterruptedException e) { -} \ No newline at end of file + } + } + synchronized (lockObj) { + lockObj.notifyAll(); + } + } + + logger.info("stopConsumer: stopped: " + uuid); + } + + public Uni consumer(UUID uuid) { + + JMSContext context = null; + Queue queue = null; + + Object lockObj = new Object(); + synchronized (lockObjs) { + lockObjs.put(uuid, lockObj); + } + synchronized (runnings) { + runnings.put(uuid, true); + } + + long now = System.currentTimeMillis(); + /*synchronized (lockObj) { + try { + lockObj.wait(10000l); + } catch (InterruptedException e) { + + } + } + */ + + while (true) { + Boolean started = null; + synchronized (starteds) { + started = starteds.get(uuid); + } + if ((started == null) || (!started)) { + break; + } + + if (debug) logger.info("consumer: running " + uuid); + + try { + + if (debug) logger.info("consumer " + queueName + ": create session " + uuid); + + if (context == null) { + context = getConnectionFactory().createContext(Session.SESSION_TRANSACTED); + synchronized (contexts) { + contexts.put(uuid, context); + } + } + + if (debug) logger.info("consumer " + queueName + ": session created " + uuid); + + if (queue == null) { + queue = context.createQueue(queueName); + } + if (debug) logger.info("consumer " + queueName + ": create consumer " + uuid); + JMSConsumer consumer = null; + String messageSelector = getMessageSelector(); + + if (messageSelector != null) { + consumer = context.createConsumer(queue, getMessageSelector()); + } else { + consumer = context.createConsumer(queue); + } + + if (debug) logger.info("consumer " + queueName + ": waiting for message... " + uuid); + + while (true) { + started = null; + + synchronized (starteds) { + started = starteds.get(uuid); + } + if ((started == null) || (!started)) { + break; + } + + now = System.currentTimeMillis(); + + if (debug) + logger.info( + "consumer: waiting for message... " + + uuid + + " " + + (System.currentTimeMillis() - now)); + + Message message = consumer.receive(); + + if (message != null) { + if (debug) + logger.info( + "consumer: received message " + uuid + " " + (System.currentTimeMillis() - now)); + + // BaseMessage baseMessage = null; + + if (message instanceof ObjectMessage) { + + ObjectMessage objMsg = (ObjectMessage) message; + // baseMessage = (BaseMessage) objMsg.getObject(); + + if (debug) { + try { + logger.info(JsonUtil.serialize(objMsg.getObject(), false)); + } catch (JsonProcessingException e2) { + + } + } + try { + M baseMessage = (M) objMsg.getObject(); + this.receiveMessage(baseMessage); + // messageResource.sendMessage(baseMessage); + + context.commit(); + if (debug) + logger.info( + "consumer: " + + queueName + + " after commit " + + uuid + + " " + + (System.currentTimeMillis() - now)); + + } catch (Exception e) { + try { + logger.warn( + "consumer: " + + queueName + + " " + + uuid + + " " + + (System.currentTimeMillis() - now) + + ": exception " + + JsonUtil.serialize(objMsg, false), + e); + } catch (JsonProcessingException e1) { + logger.warn( + "consumer: " + + queueName + + " " + + uuid + + " " + + (System.currentTimeMillis() - now) + + ": exception", + e); + } + context.rollback(); + // if (debug) + logger.info( + "consumer: " + + queueName + + " after rollback " + + uuid + + " " + + (System.currentTimeMillis() - now)); + } + } else { + if (debug) + logger.info( + "consumer " + + queueName + + " " + + uuid + + " " + + (System.currentTimeMillis() - now) + + ": unkown event " + + message); + context.commit(); + } + + } else { + if (debug) + logger.info( + "consumer: no delivered message " + + uuid + + " " + + (System.currentTimeMillis() - now)); + + synchronized (lockObj) { + try { + if (debug) + logger.info( + "consumer: waiting thread " + + uuid + + " " + + (System.currentTimeMillis() - now)); + lockObj.wait(1000); + } catch (InterruptedException e1) { + } + } + } + } + consumer.close(); + context.close(); + consumer = null; + context = null; + } catch (Exception e) { + + logger.error("", e); + try { + + context.close(); + } catch (Exception e1) { + + } + context = null; + queue = null; + + synchronized (lockObj) { + try { + lockObj.wait(exDelay); + } catch (InterruptedException e1) { + } + } + } + } + synchronized (runnings) { + runnings.put(uuid, false); + } + + return Uni.createFrom().voidItem(); + } + + @Override + public void setExDelay(Long exDelay) { + this.exDelay = exDelay; + } + + @Override + public void setQueueName(String queueName) { + this.queueName = queueName; + } + + @Override + public void setThreads(Integer threads) { + this.threads = threads; + } + + @Override + public void setDebug(boolean debug) { + this.debug = debug; + } + + @Override + public void receiveMessage(M message) throws Exception { + // TODO Auto-generated method stub + + } + + public ConnectionFactory getConnectionFactory() { + return connectionFactory; + } + + public void setConnectionFactory(ConnectionFactory connectionFactory) { + this.connectionFactory = connectionFactory; + } + + @Override + public String getMessageSelector() { + return null; + } +} diff --git a/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java b/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java index a560813..fe4d170 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java +++ b/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java @@ -1,208 +1,197 @@ package io.twentysixty.sa.client.jms; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - +import com.fasterxml.jackson.core.JsonProcessingException; +import io.twentysixty.sa.client.util.JsonUtil; import jakarta.jms.ConnectionFactory; import jakarta.jms.JMSContext; import jakarta.jms.JMSProducer; import jakarta.jms.ObjectMessage; import jakarta.jms.Queue; import jakarta.jms.Session; - +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; import org.graalvm.collections.Pair; import org.jboss.logging.Logger; -import com.fasterxml.jackson.core.JsonProcessingException; - -import io.twentysixty.sa.client.model.message.BaseMessage; -import io.twentysixty.sa.client.util.JsonUtil; - - public abstract class AbstractProducer implements ProducerInterface { - - private Integer producerId = 0; - private Integer producerCount = 8; - - private Map producers = new HashMap(); - private Map contexts = new HashMap(); - - private static final Logger logger = Logger.getLogger(AbstractProducer.class); - - private Object contextLockObj = new Object(); - - - private Map queues = new HashMap(); - - private ConnectionFactory connectionFactory; - - private Long exDelay; - private String queueName; - private Integer threads; - private Boolean debug; - - int id = 0; - - - protected Pair> getProducer(ConnectionFactory connectionFactory, boolean debug) { - JMSProducer producer = null; - JMSContext context = null; - int id = 0; - - synchronized (contextLockObj) { - if (debug) { - logger.info("spool: with use contexts/producer #" + producerId); - } - context = contexts.get(producerId); - if (context == null) { - context = connectionFactory.createContext(Session.CLIENT_ACKNOWLEDGE); - contexts.put(producerId, context); - - } - - producer = producers.get(producerId); - if (producer == null) { - producer = context.createProducer(); - producers.put(producerId, producer); - - } - id = producerId; - producerId++; - if (producerId == producerCount) { - producerId = 0; - } - } - return Pair.create(id, Pair.create(context, producer)); + + private Integer producerId = 0; + private Integer producerCount = 8; + + private Map producers = new HashMap(); + private Map contexts = new HashMap(); + + private static final Logger logger = Logger.getLogger(AbstractProducer.class); + + private Object contextLockObj = new Object(); + + private Map queues = new HashMap(); + + private ConnectionFactory connectionFactory; + + private Long exDelay; + private String queueName; + private Integer threads; + private Boolean debug; + + int id = 0; + + protected Pair> getProducer( + ConnectionFactory connectionFactory, boolean debug) { + JMSProducer producer = null; + JMSContext context = null; + int id = 0; + + synchronized (contextLockObj) { + if (debug) { + logger.info("spool: with use contexts/producer #" + producerId); + } + context = contexts.get(producerId); + if (context == null) { + context = connectionFactory.createContext(Session.CLIENT_ACKNOWLEDGE); + contexts.put(producerId, context); + } + + producer = producers.get(producerId); + if (producer == null) { + producer = context.createProducer(); + producers.put(producerId, producer); + } + id = producerId; + producerId++; + if (producerId == producerCount) { + producerId = 0; + } } - - protected void purgeAllProducers() { - - synchronized (contextLockObj) { - - for (int id=0; id> jms = getProducer(connectionFactory, debug); - - producer = jms.getRight().getRight(); - context = jms.getRight().getLeft(); - id = jms.getLeft(); - - - //if (sms.getEndpoint() != null) { - - //logger.info("context.createObjectMessage(sms) "); - ObjectMessage message = context.createObjectMessage(sms); - //logger.info("context.createObjectMessage(sms) 2 "); - - synchronized (producer) { - queue = this.getQueue(context, queueName); - - producer.send(queue, message); - message.acknowledge(); - - } - - if (debug) { - try { - logger.info("spool: Object spooled to " + queue.getQueueName() + " " + JsonUtil.serialize(sms, false)); - } catch (JsonProcessingException e) { - logger.info("spool: Object spooled to " + queue.getQueueName() + " ", e); - - } - } - - - - - } catch (Exception e) { - - this.purgeAllProducers(); - logger.error("error", e); - attempt++; - if (attempt> jms = getProducer(connectionFactory, debug); + + producer = jms.getRight().getRight(); + context = jms.getRight().getLeft(); + id = jms.getLeft(); + + // if (sms.getEndpoint() != null) { + + // logger.info("context.createObjectMessage(sms) "); + ObjectMessage message = context.createObjectMessage(sms); + // logger.info("context.createObjectMessage(sms) 2 "); + + synchronized (producer) { + queue = this.getQueue(context, queueName); + + producer.send(queue, message); + message.acknowledge(); + } + + if (debug) { + try { + logger.info( + "spool: Object spooled to " + + queue.getQueueName() + + " " + + JsonUtil.serialize(sms, false)); + } catch (JsonProcessingException e) { + logger.info("spool: Object spooled to " + queue.getQueueName() + " ", e); + } + } + + } catch (Exception e) { + + this.purgeAllProducers(); + logger.error("error", e); + attempt++; + if (attempt < threads) { + logger.info("spool: will retry attempt #" + attempt); + retry = true; + } else { + throw (e); + } } - - private Queue getQueue(JMSContext context, String conn) { - Queue queue = queues.get(conn); - if (queue == null) { - queue = context.createQueue(queueName); - queues.put(conn, queue); - } - return queue; + + if (retry) this.spool(sms, attempt); + } + + private Queue getQueue(JMSContext context, String conn) { + Queue queue = queues.get(conn); + if (queue == null) { + queue = context.createQueue(queueName); + queues.put(conn, queue); } + return queue; + } - public void setExDelay(Long exDelay) { - this.exDelay = exDelay; - } + public void setExDelay(Long exDelay) { + this.exDelay = exDelay; + } - public void setQueueName(String queueName) { - this.queueName = queueName; - } + public void setQueueName(String queueName) { + this.queueName = queueName; + } - public void setThreads(Integer threads) { - this.threads = threads; - } + public void setThreads(Integer threads) { + this.threads = threads; + } - public void setDebug(Boolean debug) { - this.debug = debug; - } + public void setDebug(Boolean debug) { + this.debug = debug; + } - @Override - public void sendMessage(M message) throws Exception { - // TODO Auto-generated method stub - - } + @Override + public void sendMessage(M message) throws Exception { + // TODO Auto-generated method stub - public void setConnectionFactory(ConnectionFactory connectionFactory) { - this.connectionFactory = connectionFactory; - } + } - + public void setConnectionFactory(ConnectionFactory connectionFactory) { + this.connectionFactory = connectionFactory; + } } diff --git a/src/main/java/io/twentysixty/sa/client/jms/ConsumerInterface.java b/src/main/java/io/twentysixty/sa/client/jms/ConsumerInterface.java index 5c8fb25..4bcd2a5 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/ConsumerInterface.java +++ b/src/main/java/io/twentysixty/sa/client/jms/ConsumerInterface.java @@ -1,17 +1,16 @@ package io.twentysixty.sa.client.jms; -import io.twentysixty.sa.client.model.message.BaseMessage; +public interface ConsumerInterface { + public void setExDelay(Long exDelay); -public interface ConsumerInterface { + public void setQueueName(String queueName); + + public void setThreads(Integer threads); + + public void setDebug(boolean debug); + + public String getMessageSelector(); - public void setExDelay(Long exDelay); - public void setQueueName(String queueName); - public void setThreads(Integer threads); - public void setDebug(boolean debug); - public String getMessageSelector(); - - public void receiveMessage(M message) throws Exception; - - + public void receiveMessage(M message) throws Exception; } diff --git a/src/main/java/io/twentysixty/sa/client/jms/ProducerInterface.java b/src/main/java/io/twentysixty/sa/client/jms/ProducerInterface.java index 1e21a68..d5f888e 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/ProducerInterface.java +++ b/src/main/java/io/twentysixty/sa/client/jms/ProducerInterface.java @@ -4,14 +4,13 @@ public interface ProducerInterface { - - public void setExDelay(Long exDelay); - public void setQueueName(String queueName); - public void setThreads(Integer threads); - public void setDebug(Boolean debug); - - public void sendMessage(M message) throws Exception; - - - + public void setExDelay(Long exDelay); + + public void setQueueName(String queueName); + + public void setThreads(Integer threads); + + public void setDebug(Boolean debug); + + public void sendMessage(M message) throws Exception; } diff --git a/src/main/java/io/twentysixty/sa/client/model/credential/CredentialType.java b/src/main/java/io/twentysixty/sa/client/model/credential/CredentialType.java index 37f51fa..5745520 100644 --- a/src/main/java/io/twentysixty/sa/client/model/credential/CredentialType.java +++ b/src/main/java/io/twentysixty/sa/client/model/credential/CredentialType.java @@ -1,52 +1,57 @@ package io.twentysixty.sa.client.model.credential; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class CredentialType { - - private String name; - private String version; - private List attributes; - private String schemaId; - private String id; - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - public List getAttributes() { - return attributes; - } - public void setAttributes(List attributes) { - this.attributes = attributes; - } - public String getSchemaId() { - return schemaId; - } - public void setSchemaId(String schemaId) { - this.schemaId = schemaId; - } - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - - + private String name; + private String version; + private List attributes; + private String schemaId; + private String id; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public List getAttributes() { + return attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/ConnectionStateUpdated.java b/src/main/java/io/twentysixty/sa/client/model/event/ConnectionStateUpdated.java index a1b205e..8425c6a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/ConnectionStateUpdated.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/ConnectionStateUpdated.java @@ -1,38 +1,41 @@ package io.twentysixty.sa.client.model.event; -import java.io.Serializable; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ConnectionStateUpdated extends Event implements Serializable { - - private static final long serialVersionUID = -2518124661250013725L; - private UUID connectionId; - private DidExchangeState state; - private UUID invitationId; - - public UUID getInvitationId() { - return invitationId; - } - public void setInvitationId(UUID invitationId) { - this.invitationId = invitationId; - } - public UUID getConnectionId() { - return connectionId; - } - public void setConnectionId(UUID connectionId) { - this.connectionId = connectionId; - } - public DidExchangeState getState() { - return state; - } - public void setState(DidExchangeState state) { - this.state = state; - } +public class ConnectionStateUpdated extends Event implements Serializable { + + private static final long serialVersionUID = -2518124661250013725L; + private UUID connectionId; + private DidExchangeState state; + private UUID invitationId; + + public UUID getInvitationId() { + return invitationId; + } + + public void setInvitationId(UUID invitationId) { + this.invitationId = invitationId; + } + + public UUID getConnectionId() { + return connectionId; + } + + public void setConnectionId(UUID connectionId) { + this.connectionId = connectionId; + } + + public DidExchangeState getState() { + return state; + } + public void setState(DidExchangeState state) { + this.state = state; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/CredentialReceptionState.java b/src/main/java/io/twentysixty/sa/client/model/event/CredentialReceptionState.java index d9a57e5..a0c8387 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/CredentialReceptionState.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/CredentialReceptionState.java @@ -1,47 +1,41 @@ package io.twentysixty.sa.client.model.event; - +import com.fasterxml.jackson.annotation.JsonValue; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonValue; +public enum CredentialReceptionState implements Serializable { + + /* + Done = "done", + Declined = "declined", + Abandoned = "abandoned", + */ + + DONE("done"), + DECLINED("declined"), + ABANDONED("abandoned"); + + private CredentialReceptionState(String index) { + this.index = index; + } + + private String index; + + public String getIndex() { + return this.index; + } + + public static CredentialReceptionState getEnum(String index) { + if (index == null) return null; + + if (index.equals("done")) return DONE; + else if (index.equals("declined")) return DECLINED; + else if (index.equals("abandoned")) return ABANDONED; + else return null; + } -public enum CredentialReceptionState implements Serializable { - - /* - Done = "done", - Declined = "declined", - Abandoned = "abandoned", - */ - - - DONE("done"), - DECLINED("declined"), - ABANDONED("abandoned"); - - private CredentialReceptionState(String index){ - this.index = index; - } - - private String index; - - public String getIndex(){ - return this.index; - } - - public static CredentialReceptionState getEnum(String index){ - if (index == null) - return null; - - if (index.equals("done")) return DONE; - else if (index.equals("declined")) return DECLINED; - else if (index.equals("abandoned")) return ABANDONED; - else return null; - - } - - @JsonValue - public String getValue() { - return index; - } - + @JsonValue + public String getValue() { + return index; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/DidExchangeState.java b/src/main/java/io/twentysixty/sa/client/model/event/DidExchangeState.java index e9057fe..a5e20b0 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/DidExchangeState.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/DidExchangeState.java @@ -1,71 +1,64 @@ package io.twentysixty.sa.client.model.event; - +import com.fasterxml.jackson.annotation.JsonValue; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonValue; +public enum DidExchangeState implements Serializable { + + /* + export enum DidExchangeState { + Start = 'start', + InvitationSent = 'invitation-sent', + InvitationReceived = 'invitation-received', + RequestSent = 'request-sent', + RequestReceived = 'request-received', + ResponseSent = 'response-sent', + ResponseReceived = 'response-received', + Abandoned = 'abandoned', + Completed = 'completed', + } + */ + + START("start"), + INVITATION_SENT("invitation-sent"), + INVITATION_RECEIVED("invitation-received"), + REQUEST_SENT("request-sent"), + REQUEST_RECEIVED("request-received"), + RESPONSE_SENT("response-sent"), + RESPONSE_RECEIVED("response-received"), + ABANDONED("abandoned"), + COMPLETED("completed"), + TERMINATED("terminated"), + ; -public enum DidExchangeState implements Serializable { + private DidExchangeState(String index) { + this.index = index; + } - /* - export enum DidExchangeState { - Start = 'start', - InvitationSent = 'invitation-sent', - InvitationReceived = 'invitation-received', - RequestSent = 'request-sent', - RequestReceived = 'request-received', - ResponseSent = 'response-sent', - ResponseReceived = 'response-received', - Abandoned = 'abandoned', - Completed = 'completed', - } - */ - - - START("start"), - INVITATION_SENT("invitation-sent"), - INVITATION_RECEIVED("invitation-received"), - REQUEST_SENT("request-sent"), - REQUEST_RECEIVED("request-received"), - RESPONSE_SENT("response-sent"), - RESPONSE_RECEIVED("response-received"), - ABANDONED("abandoned"), - COMPLETED("completed"), - TERMINATED("terminated"), - - ; - - private DidExchangeState(String index){ - this.index = index; - } + private String index; - private String index; + public String getIndex() { + return this.index; + } - public String getIndex(){ - return this.index; - } + public static DidExchangeState getEnum(String index) { + if (index == null) return null; - public static DidExchangeState getEnum(String index){ - if (index == null) - return null; + if (index.equals("start")) return START; + else if (index.equals("invitation-sent")) return INVITATION_SENT; + else if (index.equals("invitation-received")) return INVITATION_RECEIVED; + else if (index.equals("request-sent")) return REQUEST_SENT; + else if (index.equals("request-received")) return REQUEST_RECEIVED; + else if (index.equals("response-sent")) return RESPONSE_SENT; + else if (index.equals("response-received")) return RESPONSE_RECEIVED; + else if (index.equals("abandoned")) return ABANDONED; + else if (index.equals("completed")) return COMPLETED; + else if (index.equals("terminated")) return TERMINATED; + else return null; + } - if (index.equals("start")) return START; - else if (index.equals("invitation-sent")) return INVITATION_SENT; - else if (index.equals("invitation-received")) return INVITATION_RECEIVED; - else if (index.equals("request-sent")) return REQUEST_SENT; - else if (index.equals("request-received")) return REQUEST_RECEIVED; - else if (index.equals("response-sent")) return RESPONSE_SENT; - else if (index.equals("response-received")) return RESPONSE_RECEIVED; - else if (index.equals("abandoned")) return ABANDONED; - else if (index.equals("completed")) return COMPLETED; - else if (index.equals("terminated")) return TERMINATED; - else return null; - - } - - @JsonValue - public String getValue() { - return index; - } - + @JsonValue + public String getValue() { + return index; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/Event.java b/src/main/java/io/twentysixty/sa/client/model/event/Event.java index d5ef3e8..09ec9b5 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/Event.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/Event.java @@ -1,8 +1,5 @@ package io.twentysixty.sa.client.model.event; -import java.io.Serializable; -import java.time.Instant; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -12,47 +9,42 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; - import io.twentysixty.sa.client.util.InstantDeserializer; import io.twentysixty.sa.client.util.InstantSerializer; +import java.io.Serializable; +import java.time.Instant; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @JsonTypeInfo(use = Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ -@Type(value = ConnectionStateUpdated.class, name ="connection-state-updated"), -@Type(value = MessageStateUpdated.class, name ="message-state-updated"), -@Type(value = MessageReceived.class, name ="message-received"), - + @Type(value = ConnectionStateUpdated.class, name = "connection-state-updated"), + @Type(value = MessageStateUpdated.class, name = "message-state-updated"), + @Type(value = MessageReceived.class, name = "message-received"), }) - public class Event implements Serializable { - - private static final long serialVersionUID = -3403163200817960597L; - - private String type; - - @JsonSerialize(using = InstantSerializer.class) - @JsonDeserialize(using = InstantDeserializer.class) - private Instant timestamp; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Instant getTimestamp() { - return timestamp; - } - - public void setTimestamp(Instant timestamp) { - this.timestamp = timestamp; - } - - - + private static final long serialVersionUID = -3403163200817960597L; + + private String type; + + @JsonSerialize(using = InstantSerializer.class) + @JsonDeserialize(using = InstantDeserializer.class) + private Instant timestamp; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Instant getTimestamp() { + return timestamp; + } + + public void setTimestamp(Instant timestamp) { + this.timestamp = timestamp; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/EventType.java b/src/main/java/io/twentysixty/sa/client/model/event/EventType.java index 3bb937a..567aecf 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/EventType.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/EventType.java @@ -1,47 +1,41 @@ package io.twentysixty.sa.client.model.event; - import com.fasterxml.jackson.annotation.JsonValue; public enum EventType { - /* - ConnectionState = 'connection-state-updated', - MessageStateUpdated = 'message-state-updated', - MessageReceived = 'message-received', - */ - - - CONNECTION_STATE_UPDATED("connection-state-updated"), - MESSAGE_STATE_UPDATED("message-state-updated"), - MESSAGE_RECEIVED("message-received"), - - ; - - private EventType(String index){ - this.index = index; - } - - private String index; - - public String getIndex(){ - return this.index; - } - - public static EventType getEnum(String index){ - if (index == null) - return null; - - if (index.equals("connection-state-updated")) return CONNECTION_STATE_UPDATED; - else if (index.equals("message-state-updated")) return MESSAGE_STATE_UPDATED; - else if (index.equals("message-received")) return MESSAGE_RECEIVED; - else return null; - - } - - @JsonValue - public String getValue() { - return index; - } - + /* + ConnectionState = 'connection-state-updated', + MessageStateUpdated = 'message-state-updated', + MessageReceived = 'message-received', + */ + + CONNECTION_STATE_UPDATED("connection-state-updated"), + MESSAGE_STATE_UPDATED("message-state-updated"), + MESSAGE_RECEIVED("message-received"), + ; + + private EventType(String index) { + this.index = index; + } + + private String index; + + public String getIndex() { + return this.index; + } + + public static EventType getEnum(String index) { + if (index == null) return null; + + if (index.equals("connection-state-updated")) return CONNECTION_STATE_UPDATED; + else if (index.equals("message-state-updated")) return MESSAGE_STATE_UPDATED; + else if (index.equals("message-received")) return MESSAGE_RECEIVED; + else return null; + } + + @JsonValue + public String getValue() { + return index; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/MessageReceived.java b/src/main/java/io/twentysixty/sa/client/model/event/MessageReceived.java index bc83b07..17fc210 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/MessageReceived.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/MessageReceived.java @@ -1,28 +1,23 @@ package io.twentysixty.sa.client.model.event; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageReceived extends Event implements Serializable { - - - private static final long serialVersionUID = 8579005132408573827L; - private BaseMessage message; +public class MessageReceived extends Event implements Serializable { - public BaseMessage getMessage() { - return message; - } + private static final long serialVersionUID = 8579005132408573827L; + private BaseMessage message; - public void setMessage(BaseMessage message) { - this.message = message; - } - + public BaseMessage getMessage() { + return message; + } + public void setMessage(BaseMessage message) { + this.message = message; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/MessageState.java b/src/main/java/io/twentysixty/sa/client/model/event/MessageState.java index ed61ce1..f74b9bb 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/MessageState.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/MessageState.java @@ -1,55 +1,48 @@ package io.twentysixty.sa.client.model.event; - -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonValue; +import java.io.Serializable; -public enum MessageState implements Serializable { - - /* - Created = "created", - Submitted = "submitted", - Received = "received", - Viewed = "viewed", - Deleted = "deleted" - */ - - - CREATED("created"), - SUBMITTED("submitted"), - RECEIVED("received"), - VIEWED("viewed"), - DELETED("deleted"), - - ; - - private MessageState(String index){ - this.index = index; - } - - private String index; - - public String getIndex(){ - return this.index; - } - - public static MessageState getEnum(String index){ - if (index == null) - return null; - - if (index.equals("created")) return CREATED; - else if (index.equals("submitted")) return SUBMITTED; - else if (index.equals("received")) return RECEIVED; - else if (index.equals("viewed")) return VIEWED; - else if (index.equals("deleted")) return DELETED; - else return null; - - } - - @JsonValue - public String getValue() { - return index; - } - +public enum MessageState implements Serializable { + + /* + Created = "created", + Submitted = "submitted", + Received = "received", + Viewed = "viewed", + Deleted = "deleted" + */ + + CREATED("created"), + SUBMITTED("submitted"), + RECEIVED("received"), + VIEWED("viewed"), + DELETED("deleted"), + ; + + private MessageState(String index) { + this.index = index; + } + + private String index; + + public String getIndex() { + return this.index; + } + + public static MessageState getEnum(String index) { + if (index == null) return null; + + if (index.equals("created")) return CREATED; + else if (index.equals("submitted")) return SUBMITTED; + else if (index.equals("received")) return RECEIVED; + else if (index.equals("viewed")) return VIEWED; + else if (index.equals("deleted")) return DELETED; + else return null; + } + + @JsonValue + public String getValue() { + return index; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/event/MessageStateUpdated.java b/src/main/java/io/twentysixty/sa/client/model/event/MessageStateUpdated.java index 7f2b835..3a43f94 100644 --- a/src/main/java/io/twentysixty/sa/client/model/event/MessageStateUpdated.java +++ b/src/main/java/io/twentysixty/sa/client/model/event/MessageStateUpdated.java @@ -1,41 +1,40 @@ package io.twentysixty.sa.client.model.event; -import java.io.Serializable; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageStateUpdated extends Event implements Serializable { - - private UUID messageId; - private UUID connectionId; - private MessageState state; - - - public UUID getMessageId() { - return messageId; - } - public void setMessageId(UUID messageId) { - this.messageId = messageId; - } - public MessageState getState() { - return state; - } - public void setState(MessageState state) { - this.state = state; - } - public UUID getConnectionId() { - return connectionId; - } - public void setConnectionId(UUID connectionId) { - this.connectionId = connectionId; - } - - - +public class MessageStateUpdated extends Event implements Serializable { + + private UUID messageId; + private UUID connectionId; + private MessageState state; + + public UUID getMessageId() { + return messageId; + } + + public void setMessageId(UUID messageId) { + this.messageId = messageId; + } + + public MessageState getState() { + return state; + } + + public void setState(MessageState state) { + this.state = state; + } + + public UUID getConnectionId() { + return connectionId; + } + public void setConnectionId(UUID connectionId) { + this.connectionId = connectionId; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/BaseMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/BaseMessage.java index 2ea6241..d7be6be 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/BaseMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/BaseMessage.java @@ -1,9 +1,5 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -13,7 +9,6 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; - import io.twentysixty.sa.client.model.message.calls.CallAcceptRequestMessage; import io.twentysixty.sa.client.model.message.calls.CallEndRequestMessage; import io.twentysixty.sa.client.model.message.calls.CallOfferRequestMessage; @@ -22,91 +17,101 @@ import io.twentysixty.sa.client.model.message.mrtd.MrzDataSubmitMessage; import io.twentysixty.sa.client.util.InstantDeserializer; import io.twentysixty.sa.client.util.InstantSerializer; +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) @JsonTypeInfo(use = Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ - @Type(value = ContextualMenuRequest.class, name ="contextual-menu-request"), - @Type(value = ContextualMenuSelect.class, name ="contextual-menu-select"), - @Type(value = ContextualMenuUpdate.class, name ="contextual-menu-update"), - @Type(value = CredentialIssuanceMessage.class, name ="credential-issuance"), - @Type(value = CredentialRequestMessage.class, name ="credential-request"), - @Type(value = CredentialReceptionMessage.class, name ="credential-reception"), - @Type(value = IdentityProofRequestMessage.class, name ="identity-proof-request"), - @Type(value = IdentityProofResultMessage.class, name ="identity-proof-result"), - @Type(value = IdentityProofSubmitMessage.class, name ="identity-proof-submit"), - @Type(value = MediaMessage.class, name ="media"), - @Type(value = MenuDisplayMessage.class, name ="menu-display"), - @Type(value = MenuSelectMessage.class, name ="menu-select"), - @Type(value = ReceiptsMessage.class, name ="receipts"), - @Type(value = TextMessage.class, name ="text"), - @Type(value = InvitationMessage.class, name ="invitation"), - @Type(value = ProfileMessage.class, name ="profile"), - @Type(value = TerminateConnectionMessage.class, name ="terminate-connection"), - @Type(value = CallAcceptRequestMessage.class, name ="call-accept"), - @Type(value = CallEndRequestMessage.class, name ="call-end"), - @Type(value = CallOfferRequestMessage.class, name ="call-offer"), - @Type(value = CallRejectRequestMessage.class, name ="call-reject"), - @Type(value = MrzDataRequestMessage.class, name ="mrz-data-request"), - @Type(value = MrzDataSubmitMessage.class, name ="mrz-data-submit") + @Type(value = ContextualMenuRequest.class, name = "contextual-menu-request"), + @Type(value = ContextualMenuSelect.class, name = "contextual-menu-select"), + @Type(value = ContextualMenuUpdate.class, name = "contextual-menu-update"), + @Type(value = CredentialIssuanceMessage.class, name = "credential-issuance"), + @Type(value = CredentialRequestMessage.class, name = "credential-request"), + @Type(value = CredentialReceptionMessage.class, name = "credential-reception"), + @Type(value = IdentityProofRequestMessage.class, name = "identity-proof-request"), + @Type(value = IdentityProofResultMessage.class, name = "identity-proof-result"), + @Type(value = IdentityProofSubmitMessage.class, name = "identity-proof-submit"), + @Type(value = MediaMessage.class, name = "media"), + @Type(value = MenuDisplayMessage.class, name = "menu-display"), + @Type(value = MenuSelectMessage.class, name = "menu-select"), + @Type(value = ReceiptsMessage.class, name = "receipts"), + @Type(value = TextMessage.class, name = "text"), + @Type(value = InvitationMessage.class, name = "invitation"), + @Type(value = ProfileMessage.class, name = "profile"), + @Type(value = TerminateConnectionMessage.class, name = "terminate-connection"), + @Type(value = CallAcceptRequestMessage.class, name = "call-accept"), + @Type(value = CallEndRequestMessage.class, name = "call-end"), + @Type(value = CallOfferRequestMessage.class, name = "call-offer"), + @Type(value = CallRejectRequestMessage.class, name = "call-reject"), + @Type(value = MrzDataRequestMessage.class, name = "mrz-data-request"), + @Type(value = MrzDataSubmitMessage.class, name = "mrz-data-submit") }) public abstract class BaseMessage implements Serializable { - private static final long serialVersionUID = 8573230287869630604L; - protected UUID id = null; - private String type = null; - private UUID connectionId = null; - @JsonSerialize(using = InstantSerializer.class) - @JsonDeserialize(using = InstantDeserializer.class) - private Instant timestamp = null; - private UUID threadId = null; - - - private SerializableObject lockObj = new SerializableObject(); - - public UUID getId() { - synchronized (lockObj) { - if (id == null) { - id = UUID.randomUUID(); - } - } - - return id; - } - public void setId(UUID id) { - this.id = id; - } - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - public Instant getTimestamp() { - synchronized (lockObj) { - if (timestamp == null) { - timestamp = Instant.now(); - } - } - return timestamp; - } - public void setTimestamp(Instant timestamp) { - this.timestamp = timestamp; - } - public UUID getThreadId() { - return threadId; - } - public void setThreadId(UUID threadId) { - this.threadId = threadId; - } - - public UUID getConnectionId() { - return connectionId; - } - public void setConnectionId(UUID connectionId) { - this.connectionId = connectionId; - } + private static final long serialVersionUID = 8573230287869630604L; + protected UUID id = null; + private String type = null; + private UUID connectionId = null; + + @JsonSerialize(using = InstantSerializer.class) + @JsonDeserialize(using = InstantDeserializer.class) + private Instant timestamp = null; + + private UUID threadId = null; + + private SerializableObject lockObj = new SerializableObject(); + + public UUID getId() { + synchronized (lockObj) { + if (id == null) { + id = UUID.randomUUID(); + } + } + + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Instant getTimestamp() { + synchronized (lockObj) { + if (timestamp == null) { + timestamp = Instant.now(); + } + } + return timestamp; + } + + public void setTimestamp(Instant timestamp) { + this.timestamp = timestamp; + } + + public UUID getThreadId() { + return threadId; + } + + public void setThreadId(UUID threadId) { + this.threadId = threadId; + } + public UUID getConnectionId() { + return connectionId; + } + public void setConnectionId(UUID connectionId) { + this.connectionId = connectionId; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/Ciphering.java b/src/main/java/io/twentysixty/sa/client/model/message/Ciphering.java index f838f55..8996835 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/Ciphering.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/Ciphering.java @@ -2,31 +2,30 @@ import java.io.Serializable; -public class Ciphering implements Serializable { +public class Ciphering implements Serializable { - private static final long serialVersionUID = -8660299956191649637L; - private String algorithm; - private Parameters parameters; + private static final long serialVersionUID = -8660299956191649637L; + private String algorithm; + private Parameters parameters; - public String getAlgorithm() { - return algorithm; - } + public String getAlgorithm() { + return algorithm; + } - public void setAlgorithm(String algorithm) { - this.algorithm = algorithm; - } + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } - public Parameters getParameters() { - return parameters; - } + public Parameters getParameters() { + return parameters; + } - public void setParameters(Parameters parameters) { - this.parameters = parameters; - } - - @Override - public String toString() { - return "Ciphering [algorithm=" + algorithm + ", parameters=" + parameters + "]"; - } + public void setParameters(Parameters parameters) { + this.parameters = parameters; + } + @Override + public String toString() { + return "Ciphering [algorithm=" + algorithm + ", parameters=" + parameters + "]"; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/Claim.java b/src/main/java/io/twentysixty/sa/client/model/message/Claim.java index 142827f..0ed653f 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/Claim.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/Claim.java @@ -1,38 +1,40 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class Claim implements Serializable { - - private static final long serialVersionUID = -4617363940212616313L; - private String name; - private String mimeType; - private String value; - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getMimeType() { - return mimeType; - } - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - } +public class Claim implements Serializable { + + private static final long serialVersionUID = -4617363940212616313L; + private String name; + private String mimeType; + private String value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMimeType() { + return mimeType; + } + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuItem.java b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuItem.java index 81e401a..d798975 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuItem.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuItem.java @@ -1,45 +1,48 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuItem implements Serializable { - - private static final long serialVersionUID = 2236423396630045255L; - private String id; - private String title; - private String description; - - public String getTitle() { - return title; - } - public void setTitle(String title) { - this.title = title; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - public static ContextualMenuItem build(String id, String title, String description) { - ContextualMenuItem item = new ContextualMenuItem(); - item.setDescription(description); - item.setId(id); - item.setTitle(title); - return item; - } +public class ContextualMenuItem implements Serializable { + + private static final long serialVersionUID = 2236423396630045255L; + private String id; + private String title; + private String description; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public static ContextualMenuItem build(String id, String title, String description) { + ContextualMenuItem item = new ContextualMenuItem(); + item.setDescription(description); + item.setId(id); + item.setTitle(title); + return item; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuRequest.java b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuRequest.java index e70b439..307a339 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuRequest.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuRequest.java @@ -1,15 +1,13 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuRequest extends BaseMessage implements Serializable { - - private static final long serialVersionUID = 6901833429017318747L; +public class ContextualMenuRequest extends BaseMessage implements Serializable { + private static final long serialVersionUID = 6901833429017318747L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuSelect.java b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuSelect.java index 777a979..7290afc 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuSelect.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuSelect.java @@ -1,24 +1,22 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuSelect extends BaseMessage implements Serializable { - +public class ContextualMenuSelect extends BaseMessage implements Serializable { - private static final long serialVersionUID = -4666174067446573357L; - private String selectionId; + private static final long serialVersionUID = -4666174067446573357L; + private String selectionId; - public String getSelectionId() { - return selectionId; - } + public String getSelectionId() { + return selectionId; + } - public void setSelectionId(String selectionId) { - this.selectionId = selectionId; - } + public void setSelectionId(String selectionId) { + this.selectionId = selectionId; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuUpdate.java b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuUpdate.java index b58dcff..d577092 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuUpdate.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ContextualMenuUpdate.java @@ -1,67 +1,64 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuUpdate extends BaseMessage implements Serializable { - - private static final long serialVersionUID = 391973108938300769L; - private String title; - private String description; - - private List options; - - public List getOptions() { - return options; - } - - public void setOptions(List options) { - this.options = options; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @Override - public ContextualMenuUpdate clone() { - ContextualMenuUpdate clone = new ContextualMenuUpdate(); - clone.setTitle(title); - clone.setDescription(description); - clone.setId(id); - if (options != null) { - List clonedOptions = new ArrayList<>(); - - for (ContextualMenuItem i: options) { - ContextualMenuItem ci = new ContextualMenuItem(); - ci.setDescription(i.getDescription()); - ci.setId(i.getId()); - ci.setTitle(i.getTitle()); - } - clone.setOptions(clonedOptions); - } - - return clone; - - } - +public class ContextualMenuUpdate extends BaseMessage implements Serializable { + + private static final long serialVersionUID = 391973108938300769L; + private String title; + private String description; + + private List options; + + public List getOptions() { + return options; + } + + public void setOptions(List options) { + this.options = options; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public ContextualMenuUpdate clone() { + ContextualMenuUpdate clone = new ContextualMenuUpdate(); + clone.setTitle(title); + clone.setDescription(description); + clone.setId(id); + if (options != null) { + List clonedOptions = new ArrayList<>(); + + for (ContextualMenuItem i : options) { + ContextualMenuItem ci = new ContextualMenuItem(); + ci.setDescription(i.getDescription()); + ci.setId(i.getId()); + ci.setTitle(i.getTitle()); + } + clone.setOptions(clonedOptions); + } + + return clone; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/CredentialIssuanceMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/CredentialIssuanceMessage.java index 233e800..36be39a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/CredentialIssuanceMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/CredentialIssuanceMessage.java @@ -1,31 +1,32 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class CredentialIssuanceMessage extends BaseMessage implements Serializable { +public class CredentialIssuanceMessage extends BaseMessage implements Serializable { + + private static final long serialVersionUID = 2516235892249987546L; + private String credentialDefinitionId; + private List claims; + + public String getCredentialDefinitionId() { + return credentialDefinitionId; + } - private static final long serialVersionUID = 2516235892249987546L; - private String credentialDefinitionId; - private List claims; - public String getCredentialDefinitionId() { - return credentialDefinitionId; - } - public void setCredentialDefinitionId(String credentialDefinitionId) { - this.credentialDefinitionId = credentialDefinitionId; - } - public List getClaims() { - return claims; - } - public void setClaims(List claims) { - this.claims = claims; - } + public void setCredentialDefinitionId(String credentialDefinitionId) { + this.credentialDefinitionId = credentialDefinitionId; + } + public List getClaims() { + return claims; + } + public void setClaims(List claims) { + this.claims = claims; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/CredentialReceptionMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/CredentialReceptionMessage.java index 1be934a..1f43f1b 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/CredentialReceptionMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/CredentialReceptionMessage.java @@ -1,25 +1,23 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.event.CredentialReceptionState; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class CredentialReceptionMessage extends BaseMessage implements Serializable { +public class CredentialReceptionMessage extends BaseMessage implements Serializable { - private static final long serialVersionUID = 9137654378945678321L; - private CredentialReceptionState state; + private static final long serialVersionUID = 9137654378945678321L; + private CredentialReceptionState state; - public CredentialReceptionState getState() { - return state; - } - public void setState(CredentialReceptionState state) { - this.state = state; - } + public CredentialReceptionState getState() { + return state; + } + public void setState(CredentialReceptionState state) { + this.state = state; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/CredentialRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/CredentialRequestMessage.java index 2e96dec..32e8d10 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/CredentialRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/CredentialRequestMessage.java @@ -1,31 +1,33 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class CredentialRequestMessage extends BaseMessage implements Serializable { +public class CredentialRequestMessage extends BaseMessage implements Serializable { + + private static final long serialVersionUID = 5136530051273882680L; + private UUID credentialDefinitionId; + private List claims; + + public UUID getCredentialDefinitionId() { + return credentialDefinitionId; + } + + public void setCredentialDefinitionId(UUID credentialDefinitionId) { + this.credentialDefinitionId = credentialDefinitionId; + } - private static final long serialVersionUID = 5136530051273882680L; - private UUID credentialDefinitionId; - private List claims; - public UUID getCredentialDefinitionId() { - return credentialDefinitionId; - } - public void setCredentialDefinitionId(UUID credentialDefinitionId) { - this.credentialDefinitionId = credentialDefinitionId; - } - public List getClaims() { - return claims; - } - public void setClaims(List claims) { - this.claims = claims; - } + public List getClaims() { + return claims; + } + public void setClaims(List claims) { + this.claims = claims; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/IdMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/IdMessage.java index a703bd0..eea3b5a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/IdMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/IdMessage.java @@ -1,29 +1,27 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdMessage implements Serializable { - - private static final long serialVersionUID = 8231578543615143747L; - private String id; +public class IdMessage implements Serializable { - public String getId() { - return id; - } + private static final long serialVersionUID = 8231578543615143747L; + private String id; - public void setId(String id) { - this.id = id; - } + public String getId() { + return id; + } - @Override - public String toString() { - return "IdMessage [id=" + id + "]"; - } + public void setId(String id) { + this.id = id; + } + @Override + public String toString() { + return "IdMessage [id=" + id + "]"; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofRequestMessage.java index f5fad27..b1dbe7f 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofRequestMessage.java @@ -1,25 +1,23 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdentityProofRequestMessage extends BaseMessage implements Serializable { - - private static final long serialVersionUID = 184932976790362365L; - private List requestedProofItems; +public class IdentityProofRequestMessage extends BaseMessage implements Serializable { - public List getRequestedProofItems() { - return requestedProofItems; - } + private static final long serialVersionUID = 184932976790362365L; + private List requestedProofItems; - public void setRequestedProofItems(List requestedProofItems) { - this.requestedProofItems = requestedProofItems; - } + public List getRequestedProofItems() { + return requestedProofItems; + } + public void setRequestedProofItems(List requestedProofItems) { + this.requestedProofItems = requestedProofItems; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofResultMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofResultMessage.java index 883da4b..23fa33a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofResultMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofResultMessage.java @@ -1,15 +1,13 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdentityProofResultMessage extends BaseMessage implements Serializable { - - private static final long serialVersionUID = -2840211856886973672L; +public class IdentityProofResultMessage extends BaseMessage implements Serializable { + private static final long serialVersionUID = -2840211856886973672L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofSubmitMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofSubmitMessage.java index c2da93e..60b5761 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofSubmitMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/IdentityProofSubmitMessage.java @@ -1,24 +1,23 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdentityProofSubmitMessage extends BaseMessage implements Serializable { +public class IdentityProofSubmitMessage extends BaseMessage implements Serializable { - private static final long serialVersionUID = -5772627818716475038L; - private List submittedProofItems; + private static final long serialVersionUID = -5772627818716475038L; + private List submittedProofItems; - public List getSubmittedProofItems() { - return submittedProofItems; - } + public List getSubmittedProofItems() { + return submittedProofItems; + } - public void setSubmittedProofItems(List submittedProofItems) { - this.submittedProofItems = submittedProofItems; - } + public void setSubmittedProofItems(List submittedProofItems) { + this.submittedProofItems = submittedProofItems; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/InvitationMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/InvitationMessage.java index d9881df..373a071 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/InvitationMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/InvitationMessage.java @@ -1,42 +1,45 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class InvitationMessage extends BaseMessage implements Serializable { - - private static final long serialVersionUID = 2414948709300337368L; - private String label; - private String imageUrl; - private String did; - - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - public String getImageUrl() { - return imageUrl; - } - public void setImageUrl(String imageUrl) { - this.imageUrl = imageUrl; - } - - @Override - public String toString() { - return "InvitationMessage [label=" + label + ", imageUrl=" + imageUrl + "]"; - } - public String getDid() { - return did; - } - public void setDid(String did) { - this.did = did; - } +public class InvitationMessage extends BaseMessage implements Serializable { + + private static final long serialVersionUID = 2414948709300337368L; + private String label; + private String imageUrl; + private String did; + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + @Override + public String toString() { + return "InvitationMessage [label=" + label + ", imageUrl=" + imageUrl + "]"; + } + + public String getDid() { + return did; + } + public void setDid(String did) { + this.did = did; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MediaItem.java b/src/main/java/io/twentysixty/sa/client/model/message/MediaItem.java index 325214b..befb6e8 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MediaItem.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MediaItem.java @@ -1,157 +1,175 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MediaItem implements Serializable { - - private static final long serialVersionUID = -2718519112111712736L; - private String id; - private String description; - private String mimeType; - private String filename; - private Integer byteCount; - private String uri; - private Ciphering ciphering; - private String preview; - private Integer width; - private Integer height; - private String duration; - private String title; - private String icon; - private String openingMode; - private String screenOrientaton; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - public String getFilename() { - return filename; - } - - public void setFilename(String filename) { - this.filename = filename; - } - - public Integer getByteCount() { - return byteCount; - } - - public void setByteCount(Integer byteCount) { - this.byteCount = byteCount; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public Ciphering getCiphering() { - return ciphering; - } - - public void setCiphering(Ciphering ciphering) { - this.ciphering = ciphering; - } - - public String getPreview() { - return preview; - } - - public void setPreview(String preview) { - this.preview = preview; - } - - public Integer getWidth() { - return width; - } - - public void setWidth(Integer width) { - this.width = width; - } - - public Integer getHeight() { - return height; - } - - public void setHeight(Integer height) { - this.height = height; - } - - public String getDuration() { - return duration; - } - - public void setDuration(String duration) { - this.duration = duration; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getIcon() { - return icon; - } - - public void setIcon(String icon) { - this.icon = icon; - } - - public String getOpeningMode() { - return openingMode; - } - - public void setOpeningMode(String openingMode) { - this.openingMode = openingMode; - } - - public String getscreenOrientaton() { - return screenOrientaton; - } - - public void setscreenOrientaton(String screenOrientaton) { - this.screenOrientaton = screenOrientaton; - } - - @Override - public String toString() { - return "MediaItem [description=" + description + ", mimeType=" + mimeType + ", uri=" + uri - + ", preview=" + preview + ", width=" + width + ", height=" + height + ", duration=" + duration - + ", title=" + title + ", icon=" + icon + ", openingMode=" + openingMode + ", screenOrientaton=" + screenOrientaton + "]"; - } - +public class MediaItem implements Serializable { + + private static final long serialVersionUID = -2718519112111712736L; + private String id; + private String description; + private String mimeType; + private String filename; + private Integer byteCount; + private String uri; + private Ciphering ciphering; + private String preview; + private Integer width; + private Integer height; + private String duration; + private String title; + private String icon; + private String openingMode; + private String screenOrientaton; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMimeType() { + return mimeType; + } + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + + public Integer getByteCount() { + return byteCount; + } + + public void setByteCount(Integer byteCount) { + this.byteCount = byteCount; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public Ciphering getCiphering() { + return ciphering; + } + + public void setCiphering(Ciphering ciphering) { + this.ciphering = ciphering; + } + + public String getPreview() { + return preview; + } + + public void setPreview(String preview) { + this.preview = preview; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getOpeningMode() { + return openingMode; + } + + public void setOpeningMode(String openingMode) { + this.openingMode = openingMode; + } + + public String getscreenOrientaton() { + return screenOrientaton; + } + + public void setscreenOrientaton(String screenOrientaton) { + this.screenOrientaton = screenOrientaton; + } + + @Override + public String toString() { + return "MediaItem [description=" + + description + + ", mimeType=" + + mimeType + + ", uri=" + + uri + + ", preview=" + + preview + + ", width=" + + width + + ", height=" + + height + + ", duration=" + + duration + + ", title=" + + title + + ", icon=" + + icon + + ", openingMode=" + + openingMode + + ", screenOrientaton=" + + screenOrientaton + + "]"; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MediaMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/MediaMessage.java index 81eb349..70aacfe 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MediaMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MediaMessage.java @@ -1,39 +1,37 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MediaMessage extends BaseMessage implements Serializable { - - private static final long serialVersionUID = -4859703743672351029L; - private String description; - private List items; +public class MediaMessage extends BaseMessage implements Serializable { - public String getDescription() { - return description; - } + private static final long serialVersionUID = -4859703743672351029L; + private String description; + private List items; - public void setDescription(String description) { - this.description = description; - } + public String getDescription() { + return description; + } - @Override - public String toString() { - return "MediaMessage [description=" + description + ", items=" + items + "]"; - } + public void setDescription(String description) { + this.description = description; + } - public List getItems() { - return items; - } + @Override + public String toString() { + return "MediaMessage [description=" + description + ", items=" + items + "]"; + } - public void setItems(List items) { - this.items = items; - } + public List getItems() { + return items; + } + public void setItems(List items) { + this.items = items; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MenuDisplayMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/MenuDisplayMessage.java index aafb8b6..273606c 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MenuDisplayMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MenuDisplayMessage.java @@ -1,60 +1,56 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuDisplayMessage extends BaseMessage implements Serializable { - - private static final long serialVersionUID = 815738354220531775L; - - private String prompt; - - private List menuItems; +public class MenuDisplayMessage extends BaseMessage implements Serializable { - public List getMenuItems() { - return menuItems; - } + private static final long serialVersionUID = 815738354220531775L; - public void setMenuItems(List menuItems) { - this.menuItems = menuItems; - } + private String prompt; - public String getPrompt() { - return prompt; - } + private List menuItems; - public void setPrompt(String prompt) { - this.prompt = prompt; - } + public List getMenuItems() { + return menuItems; + } - @Override - public MenuDisplayMessage clone() { - MenuDisplayMessage clone = new MenuDisplayMessage(); - clone.setPrompt(prompt); + public void setMenuItems(List menuItems) { + this.menuItems = menuItems; + } - if (this.getMenuItems() != null) { - List cloneMenuItems = new ArrayList<>(this.getMenuItems().size()); - for (MenuItem i: this.getMenuItems()) { - MenuItem ci = new MenuItem(); - ci.setAction(i.getAction()); - ci.setId(i.getId()); - ci.setText(i.getText()); + public String getPrompt() { + return prompt; + } - cloneMenuItems.add(ci); - } - clone.setMenuItems(cloneMenuItems); - } + public void setPrompt(String prompt) { + this.prompt = prompt; + } - return clone; + @Override + public MenuDisplayMessage clone() { + MenuDisplayMessage clone = new MenuDisplayMessage(); + clone.setPrompt(prompt); + if (this.getMenuItems() != null) { + List cloneMenuItems = new ArrayList<>(this.getMenuItems().size()); + for (MenuItem i : this.getMenuItems()) { + MenuItem ci = new MenuItem(); + ci.setAction(i.getAction()); + ci.setId(i.getId()); + ci.setText(i.getText()); + cloneMenuItems.add(ci); + } + clone.setMenuItems(cloneMenuItems); + } - } + return clone; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MenuItem.java b/src/main/java/io/twentysixty/sa/client/model/message/MenuItem.java index b0543f2..f6156cd 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MenuItem.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MenuItem.java @@ -1,35 +1,40 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuItem implements Serializable { - - private static final long serialVersionUID = -5234451638176689315L; - private String id; - private String text; - private String action; - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public String getText() { - return text; - } - public void setText(String text) { - this.text = text; - } - public String getAction() { - return action; - } - public void setAction(String action) { - this.action = action; - } +public class MenuItem implements Serializable { + + private static final long serialVersionUID = -5234451638176689315L; + private String id; + private String text; + private String action; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MenuItemSelection.java b/src/main/java/io/twentysixty/sa/client/model/message/MenuItemSelection.java index 10b5cc0..5933110 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MenuItemSelection.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MenuItemSelection.java @@ -1,25 +1,22 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuItemSelection implements Serializable { - - private static final long serialVersionUID = -6326294105243347432L; - private String id; - - public String getId() { - return id; - } +public class MenuItemSelection implements Serializable { - public void setId(String id) { - this.id = id; - } + private static final long serialVersionUID = -6326294105243347432L; + private String id; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MenuSelectMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/MenuSelectMessage.java index 270d37c..cca061e 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MenuSelectMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MenuSelectMessage.java @@ -1,33 +1,32 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuSelectMessage extends BaseMessage implements Serializable { +public class MenuSelectMessage extends BaseMessage implements Serializable { - private static final long serialVersionUID = 2315457851863067424L; - private List menuItems; - private String content; + private static final long serialVersionUID = 2315457851863067424L; + private List menuItems; + private String content; - public List getMenuItems() { - return menuItems; - } + public List getMenuItems() { + return menuItems; + } - public void setMenuItems(List menuItems) { - this.menuItems = menuItems; - } + public void setMenuItems(List menuItems) { + this.menuItems = menuItems; + } - public String getContent() { - return content; - } + public String getContent() { + return content; + } - public void setContent(String content) { - this.content = content; - } + public void setContent(String content) { + this.content = content; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MessageReceiptOptions.java b/src/main/java/io/twentysixty/sa/client/model/message/MessageReceiptOptions.java index 03d0a19..0acd22d 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MessageReceiptOptions.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MessageReceiptOptions.java @@ -1,41 +1,43 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.event.MessageState; +import java.io.Serializable; +import java.time.Instant; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageReceiptOptions implements Serializable { - - private static final long serialVersionUID = 449398087181657974L; - private UUID messageId; - private MessageState state; - private Instant timestamp; - - public UUID getMessageId() { - return messageId; - } - public void setMessageId(UUID messageId) { - this.messageId = messageId; - } - public MessageState getState() { - return state; - } - public void setState(MessageState state) { - this.state = state; - } - public Instant getTimestamp() { - return timestamp; - } - public void setTimestamp(Instant timestamp) { - this.timestamp = timestamp; - } +public class MessageReceiptOptions implements Serializable { + + private static final long serialVersionUID = 449398087181657974L; + private UUID messageId; + private MessageState state; + private Instant timestamp; + + public UUID getMessageId() { + return messageId; + } + + public void setMessageId(UUID messageId) { + this.messageId = messageId; + } + + public MessageState getState() { + return state; + } + + public void setState(MessageState state) { + this.state = state; + } + + public Instant getTimestamp() { + return timestamp; + } + public void setTimestamp(Instant timestamp) { + this.timestamp = timestamp; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/MessageResponse.java b/src/main/java/io/twentysixty/sa/client/model/message/MessageResponse.java index c28c39e..20d4892 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/MessageResponse.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/MessageResponse.java @@ -1,15 +1,14 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageResponse implements Serializable { +public class MessageResponse implements Serializable { - private static final long serialVersionUID = 8147209590286984384L; - String message; + private static final long serialVersionUID = 8147209590286984384L; + String message; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/Parameters.java b/src/main/java/io/twentysixty/sa/client/model/message/Parameters.java index 6ed22c7..a053af0 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/Parameters.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/Parameters.java @@ -2,28 +2,30 @@ import java.io.Serializable; -public class Parameters implements Serializable { - - private static final long serialVersionUID = -3591319454008944749L; - private String key; - private String iv; - - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - public String getIv() { - return iv; - } - public void setIv(String iv) { - this.iv = iv; - } - - @Override - public String toString() { - return "Parameters [key=" + key + ", iv=" + iv + "]"; - } +public class Parameters implements Serializable { + private static final long serialVersionUID = -3591319454008944749L; + private String key; + private String iv; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getIv() { + return iv; + } + + public void setIv(String iv) { + this.iv = iv; + } + + @Override + public String toString() { + return "Parameters [key=" + key + ", iv=" + iv + "]"; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ProfileMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/ProfileMessage.java index 701007f..fc93c42 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ProfileMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ProfileMessage.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import lombok.Getter; import lombok.Setter; @@ -13,12 +12,11 @@ @Getter public class ProfileMessage extends BaseMessage { - private static final long serialVersionUID = 7632455409300337368L; - - private String displayName; - private String displayImageUrl; - private String displayIconUrl; - private String description; - private String preferredLanguage; + private static final long serialVersionUID = 7632455409300337368L; + private String displayName; + private String displayImageUrl; + private String displayIconUrl; + private String description; + private String preferredLanguage; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResult.java b/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResult.java index fe69003..c9b100d 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResult.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResult.java @@ -1,38 +1,41 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ProofItemResult implements Serializable { - - private static final long serialVersionUID = 60618296968339124L; - private UUID id; - private String type; - private ProofItemResultValue value; - - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - public ProofItemResultValue getValue() { - return value; - } - public void setValue(ProofItemResultValue value) { - this.value = value; - } +public class ProofItemResult implements Serializable { + + private static final long serialVersionUID = 60618296968339124L; + private UUID id; + private String type; + private ProofItemResultValue value; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ProofItemResultValue getValue() { + return value; + } + public void setValue(ProofItemResultValue value) { + this.value = value; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResultValue.java b/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResultValue.java index 58f260f..135ee8e 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResultValue.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResultValue.java @@ -2,8 +2,7 @@ import java.io.Serializable; -public class ProofItemResultValue implements Serializable { - - private static final long serialVersionUID = 6301649105435215111L; +public class ProofItemResultValue implements Serializable { + private static final long serialVersionUID = 6301649105435215111L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/ReceiptsMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/ReceiptsMessage.java index 58a4dea..774253a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/ReceiptsMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/ReceiptsMessage.java @@ -3,17 +3,16 @@ import java.io.Serializable; import java.util.List; -public class ReceiptsMessage extends BaseMessage implements Serializable { +public class ReceiptsMessage extends BaseMessage implements Serializable { - private static final long serialVersionUID = -7697839170763910025L; - public List receipts; + private static final long serialVersionUID = -7697839170763910025L; + public List receipts; - public List getReceipts() { - return receipts; - } - - public void setReceipts(List receipts) { - this.receipts = receipts; - } + public List getReceipts() { + return receipts; + } + public void setReceipts(List receipts) { + this.receipts = receipts; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/RequestedProofItem.java b/src/main/java/io/twentysixty/sa/client/model/message/RequestedProofItem.java index 28a8be1..ea3f747 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/RequestedProofItem.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/RequestedProofItem.java @@ -4,49 +4,56 @@ import java.util.List; import java.util.UUID; -public class RequestedProofItem implements Serializable { - - private static final long serialVersionUID = -3420017005051480727L; - private UUID id; - private String type; - - private String description; - private String credentialDefinitionId; - private List attributes; - public UUID getId() { - if (id == null) { - id = UUID.randomUUID(); - } - return id; - } - public void setId(UUID id) { - this.id = id; - } - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; +public class RequestedProofItem implements Serializable { + + private static final long serialVersionUID = -3420017005051480727L; + private UUID id; + private String type; + + private String description; + private String credentialDefinitionId; + private List attributes; + + public UUID getId() { + if (id == null) { + id = UUID.randomUUID(); } - public String getCredentialDefinitionId() { - return credentialDefinitionId; - } - public void setCredentialDefinitionId(String credentialDefinitionId) { - this.credentialDefinitionId = credentialDefinitionId; - } - public List getAttributes() { - return attributes; - } - public void setAttributes(List attributes) { - this.attributes = attributes; - } + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCredentialDefinitionId() { + return credentialDefinitionId; + } + public void setCredentialDefinitionId(String credentialDefinitionId) { + this.credentialDefinitionId = credentialDefinitionId; + } + public List getAttributes() { + return attributes; + } + public void setAttributes(List attributes) { + this.attributes = attributes; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/SerializableObject.java b/src/main/java/io/twentysixty/sa/client/model/message/SerializableObject.java index 2d15e18..8a3d04a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/SerializableObject.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/SerializableObject.java @@ -4,6 +4,5 @@ public class SerializableObject implements Serializable { - private static final long serialVersionUID = -4173924365197071974L; - + private static final long serialVersionUID = -4173924365197071974L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/SubmitProofItem.java b/src/main/java/io/twentysixty/sa/client/model/message/SubmitProofItem.java index e9c4f63..c4f695a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/SubmitProofItem.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/SubmitProofItem.java @@ -1,46 +1,51 @@ package io.twentysixty.sa.client.model.message; -import java.io.Serializable; -import java.util.List; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import java.io.Serializable; +import java.util.List; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class SubmitProofItem implements Serializable { - - private static final long serialVersionUID = 2574481615814359423L; - private UUID proofExchangeId; - private String type; - private Boolean verified; - private List claims; - public UUID getProofExchangeId() { - return proofExchangeId; - } - public void setProofExchangeId(UUID proofExchangeId) { - this.proofExchangeId = proofExchangeId; - } - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - public Boolean getVerified() { - return verified; - } - public void setVerified(Boolean verified) { - this.verified = verified; - } - public List getClaims() { - return claims; - } - public void setClaims(List claims) { - this.claims = claims; - } +public class SubmitProofItem implements Serializable { + + private static final long serialVersionUID = 2574481615814359423L; + private UUID proofExchangeId; + private String type; + private Boolean verified; + private List claims; + + public UUID getProofExchangeId() { + return proofExchangeId; + } + + public void setProofExchangeId(UUID proofExchangeId) { + this.proofExchangeId = proofExchangeId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Boolean getVerified() { + return verified; + } + + public void setVerified(Boolean verified) { + this.verified = verified; + } + public List getClaims() { + return claims; + } + public void setClaims(List claims) { + this.claims = claims; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/TerminateConnectionMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/TerminateConnectionMessage.java index 850743a..741c125 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/TerminateConnectionMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/TerminateConnectionMessage.java @@ -8,6 +8,5 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class TerminateConnectionMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886973672L; - + private static final long serialVersionUID = -2840211856886973672L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/TextMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/TextMessage.java index 512768b..bbeb49a 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/TextMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/TextMessage.java @@ -3,39 +3,35 @@ import java.io.Serializable; import java.util.UUID; +public class TextMessage extends BaseMessage implements Serializable { -public class TextMessage extends BaseMessage implements Serializable { + private static final long serialVersionUID = -1511458961424773105L; + private String content; - private static final long serialVersionUID = -1511458961424773105L; - private String content; + public String getContent() { + return content; + } - public String getContent() { - return content; - } + public void setContent(String content) { + this.content = content; + } - public void setContent(String content) { - this.content = content; - } + @Override + public TextMessage clone() { + TextMessage clone = new TextMessage(); + clone.setContent(content); + return clone; + } - @Override - public TextMessage clone() { - TextMessage clone = new TextMessage(); - clone.setContent(content); - return clone; - } + public static TextMessage build(UUID connectionId, UUID threadId, String text) { - public static TextMessage build(UUID connectionId, UUID threadId, String text) { + TextMessage textMessage = new TextMessage(); - TextMessage textMessage = new TextMessage(); + textMessage.setConnectionId(connectionId); + textMessage.setContent(text); + textMessage.setId(UUID.randomUUID()); + textMessage.setThreadId(threadId); - textMessage.setConnectionId(connectionId); - textMessage.setContent(text); - textMessage.setId(UUID.randomUUID()); - textMessage.setThreadId(threadId); - - - return textMessage; - - - } + return textMessage; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallAcceptRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallAcceptRequestMessage.java index 6400023..ae2590d 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallAcceptRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallAcceptRequestMessage.java @@ -1,12 +1,10 @@ package io.twentysixty.sa.client.model.message.calls; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; +import java.util.Map; import lombok.Getter; import lombok.Setter; @@ -16,8 +14,7 @@ @Getter public class CallAcceptRequestMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886973682L; + private static final long serialVersionUID = -2840211856886973682L; - private Map parameters; - + private Map parameters; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallEndRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallEndRequestMessage.java index 7268c32..995ddb6 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallEndRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallEndRequestMessage.java @@ -3,13 +3,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class CallEndRequestMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886973682L; - + private static final long serialVersionUID = -2840211856886973682L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallOfferRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallOfferRequestMessage.java index 4f17e5f..f25fc33 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallOfferRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallOfferRequestMessage.java @@ -1,12 +1,10 @@ package io.twentysixty.sa.client.model.message.calls; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; +import java.util.Map; import lombok.Getter; import lombok.Setter; @@ -16,8 +14,7 @@ @Getter public class CallOfferRequestMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886973682L; + private static final long serialVersionUID = -2840211856886973682L; - private Map parameters; - + private Map parameters; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallRejectRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallRejectRequestMessage.java index 03ae809..f0bf385 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/calls/CallRejectRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/calls/CallRejectRequestMessage.java @@ -3,13 +3,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class CallRejectRequestMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886973682L; - + private static final long serialVersionUID = -2840211856886973682L; } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzData.java b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzData.java index 6efb10f..7c0859d 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzData.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzData.java @@ -1,14 +1,12 @@ package io.twentysixty.sa.client.model.message.mrtd; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.enums.Mrz; +import java.io.Serializable; +import java.util.List; +import java.util.Map; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -20,26 +18,26 @@ @ToString public class MrzData implements Serializable { - private static final long serialVersionUID = -5234275638176689315L; + private static final long serialVersionUID = -5234275638176689315L; - private Object raw; - private ParsedData parsed; - - public String getRaw() { - if (raw instanceof List) { - return String.join(",", (List) raw); - } else if (raw instanceof String) { - return (String) raw; - } - return null; - } + private Object raw; + private ParsedData parsed; - @Getter - @Setter - @ToString - public static class ParsedData { - private Mrz.Format format; - private Map fields; - private boolean valid; + public String getRaw() { + if (raw instanceof List) { + return String.join(",", (List) raw); + } else if (raw instanceof String) { + return (String) raw; } + return null; + } + + @Getter + @Setter + @ToString + public static class ParsedData { + private Mrz.Format format; + private Map fields; + private boolean valid; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataRequestMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataRequestMessage.java index 32a638d..854c4fb 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataRequestMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataRequestMessage.java @@ -1,23 +1,21 @@ package io.twentysixty.sa.client.model.message.mrtd; -import java.util.UUID; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; +import java.util.UUID; @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class MrzDataRequestMessage extends BaseMessage { - private static final long serialVersionUID = -2840211856886673672L; + private static final long serialVersionUID = -2840211856886673672L; - public static MrzDataRequestMessage build(UUID connectionId, UUID threadId) { - MrzDataRequestMessage mrzr = new MrzDataRequestMessage(); - mrzr.setConnectionId(connectionId); - mrzr.setThreadId(threadId); - return mrzr; - } + public static MrzDataRequestMessage build(UUID connectionId, UUID threadId) { + MrzDataRequestMessage mrzr = new MrzDataRequestMessage(); + mrzr.setConnectionId(connectionId); + mrzr.setThreadId(threadId); + return mrzr; + } } diff --git a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataSubmitMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataSubmitMessage.java index 46ccff7..09ec749 100644 --- a/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataSubmitMessage.java +++ b/src/main/java/io/twentysixty/sa/client/model/message/mrtd/MrzDataSubmitMessage.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; - import io.twentysixty.sa.client.model.message.BaseMessage; import lombok.Getter; import lombok.Setter; @@ -16,8 +15,7 @@ @ToString public class MrzDataSubmitMessage extends BaseMessage { - private static final long serialVersionUID = -2840411856886673672L; + private static final long serialVersionUID = -2840411856886673672L; - private MrzData mrzData; - + private MrzData mrzData; } diff --git a/src/main/java/io/twentysixty/sa/client/res/c/CredentialTypeInterface.java b/src/main/java/io/twentysixty/sa/client/res/c/CredentialTypeInterface.java index e72b764..c1ea105 100644 --- a/src/main/java/io/twentysixty/sa/client/res/c/CredentialTypeInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/c/CredentialTypeInterface.java @@ -1,27 +1,21 @@ package io.twentysixty.sa.client.res.c; -import java.util.List; - +import io.twentysixty.sa.client.model.credential.CredentialType; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; - -import io.twentysixty.sa.client.model.credential.CredentialType; +import java.util.List; public interface CredentialTypeInterface { - @POST - @Path("/credential-types") - @Produces("application/json") - public void createCredentialType(CredentialType credentialType); - - - @GET - @Path("/credential-types") - @Produces("application/json") - public List getAllCredentialTypes(); - - - + @POST + @Path("/credential-types") + @Produces("application/json") + public void createCredentialType(CredentialType credentialType); + + @GET + @Path("/credential-types") + @Produces("application/json") + public List getAllCredentialTypes(); } diff --git a/src/main/java/io/twentysixty/sa/client/res/c/MessageInterface.java b/src/main/java/io/twentysixty/sa/client/res/c/MessageInterface.java index e51f8e5..5ab759f 100644 --- a/src/main/java/io/twentysixty/sa/client/res/c/MessageInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/c/MessageInterface.java @@ -1,16 +1,15 @@ package io.twentysixty.sa.client.res.c; +import io.twentysixty.sa.client.model.message.BaseMessage; +import io.twentysixty.sa.client.model.message.IdMessage; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; -import io.twentysixty.sa.client.model.message.BaseMessage; -import io.twentysixty.sa.client.model.message.IdMessage; - -public interface MessageInterface { //cambiar void +public interface MessageInterface { // cambiar void - @POST - @Path("/message") - @Produces("application/json") - public IdMessage sendMessage(BaseMessage message); + @POST + @Path("/message") + @Produces("application/json") + public IdMessage sendMessage(BaseMessage message); } diff --git a/src/main/java/io/twentysixty/sa/client/res/c/v1/CredentialTypeInterface.java b/src/main/java/io/twentysixty/sa/client/res/c/v1/CredentialTypeInterface.java index 7761604..0accb5d 100644 --- a/src/main/java/io/twentysixty/sa/client/res/c/v1/CredentialTypeInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/c/v1/CredentialTypeInterface.java @@ -1,28 +1,22 @@ package io.twentysixty.sa.client.res.c.v1; -import java.util.List; - +import io.twentysixty.sa.client.model.credential.CredentialType; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; - -import io.twentysixty.sa.client.model.credential.CredentialType; +import java.util.List; @Path("") public interface CredentialTypeInterface { - @POST - @Path("/v1/credential-types") - @Produces("application/json") - public void createCredentialType(CredentialType credentialType); - - - @GET - @Path("/v1/credential-types") - @Produces("application/json") - public List getAllCredentialTypes(); - - - + @POST + @Path("/v1/credential-types") + @Produces("application/json") + public void createCredentialType(CredentialType credentialType); + + @GET + @Path("/v1/credential-types") + @Produces("application/json") + public List getAllCredentialTypes(); } diff --git a/src/main/java/io/twentysixty/sa/client/res/c/v1/MessageInterface.java b/src/main/java/io/twentysixty/sa/client/res/c/v1/MessageInterface.java index cd25bba..c43cd38 100644 --- a/src/main/java/io/twentysixty/sa/client/res/c/v1/MessageInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/c/v1/MessageInterface.java @@ -1,17 +1,16 @@ package io.twentysixty.sa.client.res.c.v1; +import io.twentysixty.sa.client.model.message.BaseMessage; +import io.twentysixty.sa.client.model.message.IdMessage; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; -import io.twentysixty.sa.client.model.message.BaseMessage; -import io.twentysixty.sa.client.model.message.IdMessage; - @Path("") -public interface MessageInterface { //cambiar void +public interface MessageInterface { // cambiar void - @POST - @Path("/v1/message") - @Produces("application/json") - public IdMessage sendMessage(BaseMessage message); + @POST + @Path("/v1/message") + @Produces("application/json") + public IdMessage sendMessage(BaseMessage message); } diff --git a/src/main/java/io/twentysixty/sa/client/res/s/ConnectionEventInterface.java b/src/main/java/io/twentysixty/sa/client/res/s/ConnectionEventInterface.java index f968f71..5fe01d0 100644 --- a/src/main/java/io/twentysixty/sa/client/res/s/ConnectionEventInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/s/ConnectionEventInterface.java @@ -1,18 +1,17 @@ package io.twentysixty.sa.client.res.s; +import io.twentysixty.sa.client.model.event.ConnectionStateUpdated; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; -import io.twentysixty.sa.client.model.event.ConnectionStateUpdated; - public interface ConnectionEventInterface { - @POST - @Path("/connection-state-updated") - @Produces("application/json") - @Consumes("application/json") - public Response connectionStateUpdated(ConnectionStateUpdated event); + @POST + @Path("/connection-state-updated") + @Produces("application/json") + @Consumes("application/json") + public Response connectionStateUpdated(ConnectionStateUpdated event); } diff --git a/src/main/java/io/twentysixty/sa/client/res/s/MessageEventInterface.java b/src/main/java/io/twentysixty/sa/client/res/s/MessageEventInterface.java index 7109231..ed3bb69 100644 --- a/src/main/java/io/twentysixty/sa/client/res/s/MessageEventInterface.java +++ b/src/main/java/io/twentysixty/sa/client/res/s/MessageEventInterface.java @@ -1,27 +1,24 @@ package io.twentysixty.sa.client.res.s; +import io.twentysixty.sa.client.model.event.MessageReceived; +import io.twentysixty.sa.client.model.event.MessageStateUpdated; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; -import io.twentysixty.sa.client.model.event.MessageReceived; -import io.twentysixty.sa.client.model.event.MessageStateUpdated; - public interface MessageEventInterface { - @POST - @Path("/message-received") - @Produces("application/json") - @Consumes("application/json") - public Response messageReceived(MessageReceived event); - - @POST - @Path("/message-state-updated") - @Produces("application/json") - @Consumes("application/json") - public Response messageStateUpdated(MessageStateUpdated event); - - + @POST + @Path("/message-received") + @Produces("application/json") + @Consumes("application/json") + public Response messageReceived(MessageReceived event); + + @POST + @Path("/message-state-updated") + @Produces("application/json") + @Consumes("application/json") + public Response messageStateUpdated(MessageStateUpdated event); } diff --git a/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java b/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java index a27aa4a..65502f2 100644 --- a/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java +++ b/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java @@ -1,51 +1,43 @@ package io.twentysixty.sa.client.util; import javax.crypto.Cipher; +import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; - import org.jboss.logging.Logger; -import io.twentysixty.sa.client.jms.AbstractConsumer; +public class Aes256cbc { -import javax.crypto.spec.IvParameterSpec; + private static final String alg = "AES"; + private static final String cI = "AES/CBC/PKCS5Padding"; + private static final Logger logger = Logger.getLogger(Aes256cbc.class); + public static byte[] encrypt(String key, String iv, byte[] bytes) throws Exception { + Cipher cipher = Cipher.getInstance(cI); + SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); + IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); + // logger.info("encrypt: key: " + key + " iv: " + iv + " bytes: " + bytes); + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec); + byte[] encrypted = cipher.doFinal(bytes); + return encrypted; + } -public class Aes256cbc { - - private final static String alg = "AES"; - private final static String cI = "AES/CBC/PKCS5Padding"; - private static final Logger logger = Logger.getLogger(Aes256cbc.class); + public static byte[] encrypt(String key, String iv, String cleartext) throws Exception { + Cipher cipher = Cipher.getInstance(cI); + SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); + IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); + cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec); + byte[] encrypted = cipher.doFinal(cleartext.getBytes()); + return encrypted; + } - - - public static byte[] encrypt(String key, String iv, byte[] bytes) throws Exception { - Cipher cipher = Cipher.getInstance(cI); - SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); - IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); - // logger.info("encrypt: key: " + key + " iv: " + iv + " bytes: " + bytes); - cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec); - byte[] encrypted = cipher.doFinal(bytes); - return encrypted; - } - - public static byte[] encrypt(String key, String iv, String cleartext) throws Exception { - Cipher cipher = Cipher.getInstance(cI); - SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); - IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); - cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivParameterSpec); - byte[] encrypted = cipher.doFinal(cleartext.getBytes()); - return encrypted; - } - - public static byte[] decrypt(String key, String iv, byte[] encrypted) throws Exception { - Cipher cipher = Cipher.getInstance(cI); - // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), alg); - SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); - // IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes(), 0, 16); - IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); - cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivParameterSpec); - byte[] decrypted = cipher.doFinal(encrypted); - return decrypted; - } - + public static byte[] decrypt(String key, String iv, byte[] encrypted) throws Exception { + Cipher cipher = Cipher.getInstance(cI); + // SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), alg); + SecretKeySpec skeySpec = new SecretKeySpec(ISOUtil.hex2byte(key), alg); + // IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes(), 0, 16); + IvParameterSpec ivParameterSpec = new IvParameterSpec(ISOUtil.hex2byte(iv)); + cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivParameterSpec); + byte[] decrypted = cipher.doFinal(encrypted); + return decrypted; + } } diff --git a/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java b/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java index 2ceaa25..805ac55 100644 --- a/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java +++ b/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java @@ -2,149 +2,168 @@ import java.util.regex.Pattern; +public class ISOUtil { + private static final Pattern HEX_CHARACTERS = Pattern.compile("[0-9a-fA-F]+"); + /** + * converts a byte array to hex string (suitable for dumps and ASCII packaging of Binary fields + * + * @param b - byte array + * @return String representation + */ + public static String hexString(byte[] b) { + return hexString(b, 0, b.length); + } -public class ISOUtil { - private static final Pattern HEX_CHARACTERS = Pattern.compile("[0-9a-fA-F]+"); - - /** - * converts a byte array to hex string - * (suitable for dumps and ASCII packaging of Binary fields - * @param b - byte array - * @return String representation - */ - public static String hexString(byte[] b) { - return hexString(b, 0, b.length); + public static String hexString(byte[] b, int offset, int len) { + StringBuffer d = new StringBuffer(b.length * 2); + for (int i = 0; i < len; i++) { + char hi = Character.forDigit((b[offset + i] >> 4) & 0x0F, 16); + char lo = Character.forDigit(b[offset + i] & 0x0F, 16); + d.append(Character.toUpperCase(hi)); + d.append(Character.toUpperCase(lo)); } + return d.toString(); + } - public static String hexString(byte[] b, int offset, int len) { - StringBuffer d = new StringBuffer(b.length * 2); - for (int i=0; i> 4) & 0x0F, 16); - char lo = Character.forDigit (b[offset+i] & 0x0F, 16); - d.append(Character.toUpperCase(hi)); - d.append(Character.toUpperCase(lo)); - } - return d.toString(); + /** + * @param b source byte array + * @param offset starting offset + * @param len number of bytes in destination (processes len*2) + * @return byte[len] + */ + public static byte[] hex2byte(byte[] b, int offset, int len) { + byte[] d = new byte[len]; + for (int i = 0; i < len * 2; i++) { + int shift = i % 2 == 1 ? 0 : 4; + d[i >> 1] |= Character.digit((char) b[offset + i], 16) << shift; } - /** - * @param b source byte array - * @param offset starting offset - * @param len number of bytes in destination (processes len*2) - * @return byte[len] - */ - public static byte[] hex2byte (byte[] b, int offset, int len) { - byte[] d = new byte[len]; - for (int i=0; i>1] |= Character.digit((char) b[offset+i], 16) << shift; - } - return d; - } - /** - * @param s source string (with Hex representation) - * @return byte array - */ - public static byte[] hex2byte (String s) { - if (s.length() % 2 == 0) { - return hex2byte (s.getBytes(), 0, s.length() >> 1); - } else { - throw new RuntimeException(); - } + return d; + } + + /** + * @param s source string (with Hex representation) + * @return byte array + */ + public static byte[] hex2byte(String s) { + if (s.length() % 2 == 0) { + return hex2byte(s.getBytes(), 0, s.length() >> 1); + } else { + throw new RuntimeException(); } - - /** - * converts a byte array to printable characters - * @param b - byte array - * @return String representation - */ - public static String dumpString(byte[] b) { - StringBuffer d = new StringBuffer(b.length * 2); - for (int i=0; i> 4) & 0x0F, 16); - char lo = Character.forDigit (b[i] & 0x0F, 16); - d.append('['); - d.append(Character.toUpperCase(hi)); - d.append(Character.toUpperCase(lo)); - d.append(']'); - break; - } - } - else - d.append (c); + } + /** + * converts a byte array to printable characters + * + * @param b - byte array + * @return String representation + */ + public static String dumpString(byte[] b) { + StringBuffer d = new StringBuffer(b.length * 2); + for (int i = 0; i < b.length; i++) { + char c = (char) b[i]; + if (Character.isISOControl(c)) { + // TODO: complete list of control characters, + // use a String[] instead of this weird switch + switch (c) { + case '\r': + d.append("{CR}"); + break; + case '\n': + d.append("{LF}"); + break; + case '\000': + d.append("{NULL}"); + break; + case '\001': + d.append("{SOH}"); + break; + case '\002': + d.append("{STX}"); + break; + case '\003': + d.append("{ETX}"); + break; + case '\004': + d.append("{EOT}"); + break; + case '\005': + d.append("{ENQ}"); + break; + case '\006': + d.append("{ACK}"); + break; + case '\007': + d.append("{BEL}"); + break; + case '\020': + d.append("{DLE}"); + break; + case '\025': + d.append("{NAK}"); + break; + case '\026': + d.append("{SYN}"); + break; + case '\034': + d.append("{FS}"); + break; + case '\036': + d.append("{RS}"); + break; + default: + char hi = Character.forDigit((b[i] >> 4) & 0x0F, 16); + char lo = Character.forDigit(b[i] & 0x0F, 16); + d.append('['); + d.append(Character.toUpperCase(hi)); + d.append(Character.toUpperCase(lo)); + d.append(']'); + break; } - return d.toString(); - } - - public static boolean isValidHexString(String s) { - return HEX_CHARACTERS.matcher(s).matches(); - } - - /** - * Swaps nibbles of all bytes in an input array - * - * @param value - * @return - */ - public static byte [] swapNibbles(byte [] value) { - byte [] output = new byte[value.length]; - - for (int i = 0 ; i < output.length ; i++) { - int nibble0 = (value[i] << 4) & 0xf0; - int nibble1 = (value[i] >>> 4) & 0x0f; - output[i] = (byte)((nibble0 | nibble1)); - } - //System.out.println(ISOUtil.hexString(output)); - return output; + } else d.append(c); } - - public static String swapNibblesAndUnpad(byte [] value) { - byte[] output = swapNibbles(value); - String outputStr = hexString(output); - if (outputStr.endsWith("F")) { - return outputStr.substring(0, outputStr.length() - 1); - } - return outputStr; - } - - - - public static byte [] padAndSwapNibbles(String value) { - String paddedValue = new String(value); - if (paddedValue.length() % 2 != 0) - paddedValue += "F"; - return swapNibbles(hex2byte(paddedValue - .replace("*", "A") - .replace("#", "B"))); + return d.toString(); + } + + public static boolean isValidHexString(String s) { + return HEX_CHARACTERS.matcher(s).matches(); + } + + /** + * Swaps nibbles of all bytes in an input array + * + * @param value + * @return + */ + public static byte[] swapNibbles(byte[] value) { + byte[] output = new byte[value.length]; + + for (int i = 0; i < output.length; i++) { + int nibble0 = (value[i] << 4) & 0xf0; + int nibble1 = (value[i] >>> 4) & 0x0f; + output[i] = (byte) ((nibble0 | nibble1)); } - - public static byte [] swapNibbles(String value) { - return swapNibbles(hex2byte(value)); + // System.out.println(ISOUtil.hexString(output)); + return output; + } + + public static String swapNibblesAndUnpad(byte[] value) { + byte[] output = swapNibbles(value); + String outputStr = hexString(output); + if (outputStr.endsWith("F")) { + return outputStr.substring(0, outputStr.length() - 1); } + return outputStr; + } + + public static byte[] padAndSwapNibbles(String value) { + String paddedValue = new String(value); + if (paddedValue.length() % 2 != 0) paddedValue += "F"; + return swapNibbles(hex2byte(paddedValue.replace("*", "A").replace("#", "B"))); + } - - - -} \ No newline at end of file + public static byte[] swapNibbles(String value) { + return swapNibbles(hex2byte(value)); + } +} diff --git a/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java b/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java index 9aff8e6..f49cbdb 100644 --- a/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java +++ b/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java @@ -1,20 +1,20 @@ package io.twentysixty.sa.client.util; -import java.io.IOException; -import java.time.Instant; - import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.time.Instant; public class InstantDeserializer extends JsonDeserializer { - @Override - public Instant deserialize(JsonParser arg0, DeserializationContext arg1) throws IOException, JsonProcessingException { - String date = arg0.getText(); - date = date.replace(" ", "T"); - date = date.replace("NaN", "00"); - Instant result = Instant.parse(date); - return result; - } -} \ No newline at end of file + @Override + public Instant deserialize(JsonParser arg0, DeserializationContext arg1) + throws IOException, JsonProcessingException { + String date = arg0.getText(); + date = date.replace(" ", "T"); + date = date.replace("NaN", "00"); + Instant result = Instant.parse(date); + return result; + } +} diff --git a/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java b/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java index 786aa65..95ea014 100644 --- a/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java +++ b/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java @@ -1,29 +1,26 @@ package io.twentysixty.sa.client.util; -import java.io.IOException; -import java.time.Instant; - import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.time.Instant; public class InstantSerializer extends JsonSerializer { - @Override - public void serialize(Instant arg0, JsonGenerator arg1, SerializerProvider arg2) throws IOException, JsonProcessingException { - - String result = arg0.toString(); - /*if (result.length()==24) { - result = result.replace("Z", "000Z"); - } else if (result.length()==25) { - result = result.replace("Z", "00Z"); - } else if (result.length()==26) { - result = result.replace("Z", "0Z"); - }*/ - - arg1.writeString(result); - - } + @Override + public void serialize(Instant arg0, JsonGenerator arg1, SerializerProvider arg2) + throws IOException, JsonProcessingException { + + String result = arg0.toString(); + /*if (result.length()==24) { + result = result.replace("Z", "000Z"); + } else if (result.length()==25) { + result = result.replace("Z", "00Z"); + } else if (result.length()==26) { + result = result.replace("Z", "0Z"); + }*/ - -} \ No newline at end of file + arg1.writeString(result); + } +} diff --git a/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java b/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java index 9adcee8..98d82e9 100644 --- a/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java +++ b/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java @@ -8,60 +8,54 @@ public class JsonUtil { - public static String serialize(Object obj, boolean pretty) throws JsonProcessingException { - ObjectMapper mapper = JsonMapper.builder() - .findAndAddModules() - - .build(); - mapper.registerModule(new JavaTimeModule()); - mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - - - - if (pretty) { - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj); - } else { - return mapper.writeValueAsString(obj); - } - - - } - - /*public static Object deserialize(String json) throws JsonParseException, JsonMappingException, IOException { - - ObjectMapper mapper = new ObjectMapper(); - Request request = mapper.readValue(json, Request.class); - return - - } - - - public class RawJsonDeserializer extends JsonDeserializer { - - @Override - public String deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - ObjectMapper mapper = (ObjectMapper) jp.getCodec(); - JsonNode node = mapper.readTree(jp); - return mapper.writeValueAsString(node); - } - } - - public class Request { - - @JsonDeserialize(using = RawJsonDeserializer.class) - private String text; - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - - // Getters and setters omitted - }*/ + public static String serialize(Object obj, boolean pretty) throws JsonProcessingException { + ObjectMapper mapper = JsonMapper.builder().findAndAddModules().build(); + + mapper.registerModule(new JavaTimeModule()); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + + if (pretty) { + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj); + } else { + return mapper.writeValueAsString(obj); + } + } + + /*public static Object deserialize(String json) throws JsonParseException, JsonMappingException, IOException { + + ObjectMapper mapper = new ObjectMapper(); + Request request = mapper.readValue(json, Request.class); + return + + } + + + public class RawJsonDeserializer extends JsonDeserializer { + + @Override + public String deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + ObjectMapper mapper = (ObjectMapper) jp.getCodec(); + JsonNode node = mapper.readTree(jp); + return mapper.writeValueAsString(node); + } + } + + public class Request { + + @JsonDeserialize(using = RawJsonDeserializer.class) + private String text; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + + // Getters and setters omitted + }*/ } diff --git a/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java b/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java index b0c2969..b0c5b60 100644 --- a/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java +++ b/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java @@ -13,16 +13,15 @@ public static String generateSHA256Token(String data) { byte[] encodedhash = digest.digest(data.getBytes(StandardCharsets.UTF_8)); StringBuilder hexString = new StringBuilder(2 * encodedhash.length); for (byte b : encodedhash) { - String hex = Integer.toHexString(0xff & b); - if (hex.length() == 1) { - hexString.append('0'); - } - hexString.append(hex); + String hex = Integer.toHexString(0xff & b); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { return null; } } - } diff --git a/src/main/java/io/twentysixty/sa/client/util/testing/Tryme.java b/src/main/java/io/twentysixty/sa/client/util/testing/Tryme.java index 2d50c23..bf1788e 100644 --- a/src/main/java/io/twentysixty/sa/client/util/testing/Tryme.java +++ b/src/main/java/io/twentysixty/sa/client/util/testing/Tryme.java @@ -1,25 +1,21 @@ package io.twentysixty.sa.client.util.testing; -import java.time.Instant; -import java.util.UUID; - import com.fasterxml.jackson.core.JsonProcessingException; - import io.twentysixty.sa.client.model.message.BaseMessage; import io.twentysixty.sa.client.model.message.TextMessage; import io.twentysixty.sa.client.util.JsonUtil; +import java.time.Instant; +import java.util.UUID; public class Tryme { - public static void main(String[] args) throws JsonProcessingException { - TextMessage textMessage = new TextMessage(); - - textMessage.setConnectionId(UUID.randomUUID()); - textMessage.setId(UUID.randomUUID()); - textMessage.setThreadId(UUID.randomUUID()); - textMessage.setTimestamp(Instant.now()); - System.out.println(JsonUtil.serialize((BaseMessage)textMessage, true)); - - } + public static void main(String[] args) throws JsonProcessingException { + TextMessage textMessage = new TextMessage(); + textMessage.setConnectionId(UUID.randomUUID()); + textMessage.setId(UUID.randomUUID()); + textMessage.setThreadId(UUID.randomUUID()); + textMessage.setTimestamp(Instant.now()); + System.out.println(JsonUtil.serialize((BaseMessage) textMessage, true)); + } }