diff --git a/README.md b/README.md index 93a7932..d1c29e1 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,7 @@ 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 verify install -Dgpg.skip` to run the project - -## Before PR -Please run `mvn clean spotless:check` command before uploading changes to verify the syntax +On dev mode use the command `mvn clean install -Dgpg.skip` to run the project ## Releases diff --git a/pom.xml b/pom.xml index 1df50de..4d64d02 100644 --- a/pom.xml +++ b/pom.xml @@ -124,60 +124,6 @@ - - net.revelc.code.formatter - formatter-maven-plugin - 2.19.0 - - eclipse-formatter.xml - LF - - - - - format - - - - - - net.revelc.code - impsort-maven-plugin - 1.8.0 - - java.,javax.,org.,com. - java,* - true - - - - sort-imports - - sort - - - - - - com.diffplug.spotless - spotless-maven-plugin - 2.43.0 - - - - ${basedir}/eclipse-formatter.xml - - - - - 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 c4315b5..85abaf3 100644 --- a/src/main/java/io/twentysixty/sa/client/enums/Mrz.java +++ b/src/main/java/io/twentysixty/sa/client/enums/Mrz.java @@ -15,69 +15,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 a4a4cd3..bef9940 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java +++ b/src/main/java/io/twentysixty/sa/client/jms/AbstractConsumer.java @@ -1,17 +1,13 @@ 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 org.jboss.logging.Logger; - -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; @@ -20,27 +16,42 @@ import jakarta.jms.Queue; import jakarta.jms.Session; -public class AbstractConsumer implements ConsumerInterface { +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 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 < threads; i++) { + + for (int i=0; i consumer(UUID uuid) { runnings.put(uuid, true); } + long now = System.currentTimeMillis(); - /* - * synchronized (lockObj) { try { lockObj.wait(10000l); } catch (InterruptedException e) { - * - * } } + /*synchronized (lockObj) { + try { + lockObj.wait(10000l); + } catch (InterruptedException e) { + + } + } */ while (true) { Boolean started = null; - synchronized (starteds) { + synchronized(starteds) { started = starteds.get(uuid); } @@ -184,13 +211,13 @@ public Uni consumer(UUID uuid) { break; } - if (debug) - logger.info("consumer: running " + uuid); - try { + if (debug) logger.info("consumer: running " + uuid); + + try { + + if (debug) logger.info("consumer " + queueName + ": create session " + uuid ); - if (debug) - logger.info("consumer " + queueName + ": create session " + uuid); if (context == null) { context = getConnectionFactory().createContext(Session.SESSION_TRANSACTED); @@ -200,14 +227,13 @@ public Uni consumer(UUID uuid) { } - if (debug) - logger.info("consumer " + queueName + ": session created " + uuid); + + 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); + if (debug) logger.info("consumer " + queueName + ": create consumer " + uuid ); JMSConsumer consumer = null; String messageSelector = getMessageSelector(); @@ -217,39 +243,42 @@ public Uni consumer(UUID uuid) { consumer = context.createConsumer(queue); } - if (debug) - logger.info("consumer " + queueName + ": waiting for message... " + uuid); + + + if (debug) logger.info("consumer " + queueName + ": waiting for message... " + uuid); + while (true) { started = null; - synchronized (starteds) { + 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)); + 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)); + if (debug) + logger.info("consumer: received message " + uuid + " " + (System.currentTimeMillis() - now)); + - // BaseMessage baseMessage = null; + + //BaseMessage baseMessage = null; if (message instanceof ObjectMessage) { ObjectMessage objMsg = (ObjectMessage) message; - // baseMessage = (BaseMessage) objMsg.getObject(); + //baseMessage = (BaseMessage) objMsg.getObject(); if (debug) { try { @@ -261,58 +290,53 @@ public Uni consumer(UUID uuid) { try { M baseMessage = (M) objMsg.getObject(); this.receiveMessage(baseMessage); - // messageResource.sendMessage(baseMessage); + //messageResource.sendMessage(baseMessage); + context.commit(); - if (debug) - logger.info("consumer: " + queueName + " after commit " + uuid + " " - + (System.currentTimeMillis() - now)); + 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); + 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); + logger.warn("consumer: " + queueName + " "+ uuid + " " + (System.currentTimeMillis() - now)+ ": exception", e); } context.rollback(); - // if (debug) - logger.info("consumer: " + queueName + " after rollback " + uuid + " " - + (System.currentTimeMillis() - now)); + //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); + 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)); + + } 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)); + 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 { @@ -323,6 +347,8 @@ public Uni consumer(UUID uuid) { context = null; queue = null; + + synchronized (lockObj) { try { lockObj.wait(exDelay); @@ -371,10 +397,12 @@ public ConnectionFactory getConnectionFactory() { public void setConnectionFactory(ConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; } - @Override public String getMessageSelector() { return null; } -} + + + +} \ No newline at end of file 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 81e0050..a560813 100644 --- a/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java +++ b/src/main/java/io/twentysixty/sa/client/jms/AbstractProducer.java @@ -3,13 +3,8 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.UUID; -import org.graalvm.collections.Pair; -import org.jboss.logging.Logger; - -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; @@ -17,51 +12,61 @@ import jakarta.jms.Queue; import jakarta.jms.Session; -public abstract class AbstractProducer implements ProducerInterface { +import org.graalvm.collections.Pair; +import org.jboss.logging.Logger; - private Integer producerId = 0; - private Integer producerCount = 8; +import com.fasterxml.jackson.core.JsonProcessingException; + +import io.twentysixty.sa.client.model.message.BaseMessage; +import io.twentysixty.sa.client.util.JsonUtil; - private Map producers = new HashMap(); - private Map contexts = new HashMap(); +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) { + + + 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); - } + 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++; @@ -69,107 +74,109 @@ protected Pair> getProducer(ConnectionFac producerId = 0; } } - return Pair.create(id, Pair.create(context, producer)); - } - - protected void purgeAllProducers() { - - synchronized (contextLockObj) { - - for (int id = 0; id < contexts.size(); id++) { - JMSContext context = contexts.get(id); - if (context != null) { - try { - context.close(); - logger.info("purgeAllProducers: closed producer #" + id); - } catch (Exception e1) { - logger.error("purgeProducer: error closing producer #" + id, e1); - } - } - contexts.remove(id); - producers.remove(id); - } - - logger.info("purgeAllProducers: remaining contexts size: " + contexts.size() + " producer size: " - + producers.size()); - - contexts.clear(); - producers.clear(); - - logger.info("purgeAllProducers: cleared contexts size: " + contexts.size() + " producer size: " - + producers.size()); - - } - } + return Pair.create(id, Pair.create(context, producer)); + } + + 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 < threads) { - logger.info("spool: will retry attempt #" + attempt); - retry = true; - } else { - throw (e); - } - } - - if (retry) - this.spool(sms, attempt); - - } - - private Queue getQueue(JMSContext context, String conn) { + + JMSProducer producer = null; + JMSContext context = null; + Queue queue = null; + boolean retry = false; + try { + + + + Pair> 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 { 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; - + + } 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 6b1a0f5..1e21a68 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,14 @@ 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; - + + + } 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 3a20d5d..37f51fa 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 @@ -9,51 +9,44 @@ @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; } + + + } 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 4fe15e4..a1b205e 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 @@ -9,8 +9,8 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ConnectionStateUpdated extends Event implements Serializable { - +public class ConnectionStateUpdated extends Event implements Serializable { + private static final long serialVersionUID = -2518124661250013725L; private UUID connectionId; private DidExchangeState state; @@ -19,23 +19,18 @@ public class ConnectionStateUpdated extends Event implements Serializable { 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 457f072..d9a57e5 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,47 @@ package io.twentysixty.sa.client.model.event; + import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonValue; -public enum CredentialReceptionState implements Serializable { +public enum CredentialReceptionState implements Serializable { /* - * Done = "done", Declined = "declined", Abandoned = "abandoned", - */ - + Done = "done", + Declined = "declined", + Abandoned = "abandoned", + */ + + DONE("done"), - DECLINED("declined"), - ABANDONED("abandoned"); - - private CredentialReceptionState(String index) { + DECLINED("declined"), + ABANDONED("abandoned"); + + private CredentialReceptionState(String index){ this.index = index; } private String index; - public String getIndex() { + public String getIndex(){ return this.index; } - public static CredentialReceptionState getEnum(String 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; + 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 + + @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 43b5366..e9057fe 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,17 +1,27 @@ package io.twentysixty.sa.client.model.event; + import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonValue; -public enum DidExchangeState implements Serializable { +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', } - */ - + 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"), @@ -22,51 +32,40 @@ public enum DidExchangeState implements Serializable { ABANDONED("abandoned"), COMPLETED("completed"), TERMINATED("terminated"), - + ; - - private DidExchangeState(String index) { + + private DidExchangeState(String index){ this.index = index; } private String index; - public String getIndex() { + public String getIndex(){ return this.index; } - public static DidExchangeState getEnum(String index) { + 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; + 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 + + @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 9e653e4..d5ef3e8 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 @@ -19,14 +19,15 @@ @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"), +@JsonSubTypes({ +@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; @@ -34,7 +35,7 @@ public class Event implements Serializable { @JsonSerialize(using = InstantSerializer.class) @JsonDeserialize(using = InstantDeserializer.class) private Instant timestamp; - + public String getType() { return type; } @@ -50,5 +51,8 @@ public Instant getTimestamp() { 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 61a101c..3bb937a 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,48 +1,47 @@ 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', - */ - + 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) { + + private EventType(String index){ this.index = index; } private String index; - public String getIndex() { + public String getIndex(){ return this.index; } - public static EventType getEnum(String 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; + 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 + + @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 3cb4370..bc83b07 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 @@ -10,8 +10,9 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageReceived extends Event implements Serializable { - +public class MessageReceived extends Event implements Serializable { + + private static final long serialVersionUID = 8579005132408573827L; private BaseMessage message; @@ -22,5 +23,6 @@ public BaseMessage getMessage() { 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 14db292..ed61ce1 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,55 @@ package io.twentysixty.sa.client.model.event; + import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonValue; -public enum MessageState implements 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" + */ + + CREATED("created"), SUBMITTED("submitted"), RECEIVED("received"), VIEWED("viewed"), DELETED("deleted"), - + ; - - private MessageState(String index) { + + private MessageState(String index){ this.index = index; } private String index; - public String getIndex() { + public String getIndex(){ return this.index; } - public static MessageState getEnum(String 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; - + 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 + + @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 a88bf44..7f2b835 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 @@ -9,34 +9,33 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageStateUpdated extends Event implements Serializable { - +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 4a3dc04..2ea6241 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 @@ -26,28 +26,31 @@ @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")}) +@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") +}) public abstract class BaseMessage implements Serializable { private static final long serialVersionUID = 8573230287869630604L; @@ -59,6 +62,7 @@ public abstract class BaseMessage implements Serializable { private Instant timestamp = null; private UUID threadId = null; + private SerializableObject lockObj = new SerializableObject(); public UUID getId() { @@ -70,19 +74,15 @@ 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 Instant getTimestamp() { synchronized (lockObj) { if (timestamp == null) { @@ -91,15 +91,12 @@ public Instant getTimestamp() { } return timestamp; } - public void setTimestamp(Instant timestamp) { this.timestamp = timestamp; } - public UUID getThreadId() { return threadId; } - public void setThreadId(UUID threadId) { this.threadId = threadId; } @@ -107,9 +104,9 @@ public void setThreadId(UUID 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 570dbfd..f838f55 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,31 @@ import java.io.Serializable; -public class Ciphering implements Serializable { +public class Ciphering implements Serializable { - private static final long serialVersionUID = -8660299956191649637L; + private static final long serialVersionUID = -8660299956191649637L; private String algorithm; - private Parameters parameters; + 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; - } + public void setParameters(Parameters parameters) { + this.parameters = parameters; + } - @Override - public String toString() { - return "Ciphering [algorithm=" + algorithm + ", 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 af59729..142827f 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 @@ -8,35 +8,31 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class Claim implements Serializable { +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 cda1f88..81e401a 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuItem implements Serializable { +public class ContextualMenuItem implements Serializable { private static final long serialVersionUID = 2236423396630045255L; private String id; @@ -18,23 +18,18 @@ public class ContextualMenuItem implements Serializable { 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; } 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 c3a0cab..e70b439 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuRequest extends BaseMessage implements Serializable { +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 9cb313b..777a979 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 @@ -8,7 +8,8 @@ @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; 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 afdba70..b58dcff 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 @@ -10,7 +10,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ContextualMenuUpdate extends BaseMessage implements Serializable { +public class ContextualMenuUpdate extends BaseMessage implements Serializable { private static final long serialVersionUID = 391973108938300769L; private String title; @@ -51,7 +51,7 @@ public ContextualMenuUpdate clone() { if (options != null) { List clonedOptions = new ArrayList<>(); - for (ContextualMenuItem i : options) { + for (ContextualMenuItem i: options) { ContextualMenuItem ci = new ContextualMenuItem(); ci.setDescription(i.getDescription()); ci.setId(i.getId()); 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 309c3cf..233e800 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 @@ -9,26 +9,23 @@ @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; } - 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 29214de..1be934a 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 @@ -10,7 +10,7 @@ @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; @@ -18,7 +18,6 @@ public class CredentialReceptionMessage extends BaseMessage implements Serializa 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 eae33aa..2e96dec 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 @@ -10,24 +10,20 @@ @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; } - 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 e81d222..a703bd0 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdMessage implements Serializable { +public class IdMessage implements Serializable { private static final long serialVersionUID = 8231578543615143747L; private String 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 21d41a9..f5fad27 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 @@ -9,7 +9,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdentityProofRequestMessage extends BaseMessage implements Serializable { +public class IdentityProofRequestMessage extends BaseMessage implements Serializable { private static final long serialVersionUID = 184932976790362365L; private List 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 2152f78..883da4b 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class IdentityProofResultMessage extends BaseMessage implements Serializable { +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 a73d4db..c2da93e 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 @@ -9,7 +9,7 @@ @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; 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 02f21f1..d9881df 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 @@ -8,38 +8,33 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class InvitationMessage extends BaseMessage implements Serializable { +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 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 b129f1b..325214b 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MediaItem implements Serializable { +public class MediaItem implements Serializable { private static final long serialVersionUID = -2718519112111712736L; private String id; @@ -149,9 +149,9 @@ public void setscreenOrientaton(String 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 + "]"; + 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 22ca7fc..81eb349 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 @@ -9,7 +9,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MediaMessage extends BaseMessage implements Serializable { +public class MediaMessage extends BaseMessage implements Serializable { private static final long serialVersionUID = -4859703743672351029L; private String description; 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 19db3f3..aafb8b6 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 @@ -10,7 +10,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuDisplayMessage extends BaseMessage implements Serializable { +public class MenuDisplayMessage extends BaseMessage implements Serializable { private static final long serialVersionUID = 815738354220531775L; @@ -41,7 +41,7 @@ public MenuDisplayMessage clone() { if (this.getMenuItems() != null) { List cloneMenuItems = new ArrayList<>(this.getMenuItems().size()); - for (MenuItem i : this.getMenuItems()) { + for (MenuItem i: this.getMenuItems()) { MenuItem ci = new MenuItem(); ci.setAction(i.getAction()); ci.setId(i.getId()); @@ -54,5 +54,7 @@ public MenuDisplayMessage clone() { 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 3182934..b0543f2 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 @@ -8,33 +8,27 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuItem implements Serializable { +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 a7edd8c..10b5cc0 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 @@ -8,7 +8,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MenuItemSelection implements Serializable { +public class MenuItemSelection implements Serializable { private static final long serialVersionUID = -6326294105243347432L; private String id; @@ -21,4 +21,5 @@ 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 dd0d57d..270d37c 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 @@ -9,7 +9,7 @@ @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; @@ -24,10 +24,10 @@ public void setMenuItems(List menuItems) { } public String getContent() { - return content; - } + 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 eb7c8da..03d0a19 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 @@ -12,7 +12,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MessageReceiptOptions implements Serializable { +public class MessageReceiptOptions implements Serializable { private static final long serialVersionUID = 449398087181657974L; private UUID messageId; @@ -22,23 +22,18 @@ public class MessageReceiptOptions implements Serializable { 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 0b99425..c28c39e 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 @@ -8,7 +8,7 @@ @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; 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 ef45a76..6ed22c7 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,31 +2,28 @@ import java.io.Serializable; -public class Parameters implements Serializable { +public class Parameters implements Serializable { - private static final long serialVersionUID = -3591319454008944749L; + 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 + "]"; - } + 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/ProofItemResult.java b/src/main/java/io/twentysixty/sa/client/model/message/ProofItemResult.java index d753ef8..fe69003 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 @@ -9,7 +9,7 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class ProofItemResult implements Serializable { +public class ProofItemResult implements Serializable { private static final long serialVersionUID = 60618296968339124L; private UUID id; @@ -19,23 +19,18 @@ public class ProofItemResult implements Serializable { 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 bea61a8..58f260f 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,7 +2,7 @@ import java.io.Serializable; -public class ProofItemResultValue implements Serializable { +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 653f778..58a4dea 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,7 +3,7 @@ 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; 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 01be42f..28a8be1 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,57 +4,49 @@ import java.util.List; import java.util.UUID; -public class RequestedProofItem implements Serializable { +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; - } - + 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/SubmitProofItem.java b/src/main/java/io/twentysixty/sa/client/model/message/SubmitProofItem.java index e41ad38..e9c4f63 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 @@ -10,44 +10,37 @@ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class SubmitProofItem implements Serializable { +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/TextMessage.java b/src/main/java/io/twentysixty/sa/client/model/message/TextMessage.java index 696d7ad..512768b 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,7 +3,8 @@ 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; @@ -32,7 +33,9 @@ public static TextMessage build(UUID connectionId, UUID threadId, String text) { textMessage.setId(UUID.randomUUID()); textMessage.setThreadId(threadId); + 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 e7a83f4..6400023 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 @@ -18,6 +18,6 @@ public class CallAcceptRequestMessage extends BaseMessage { 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 52e0d59..7268c32 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 @@ -11,5 +11,5 @@ public class CallEndRequestMessage extends BaseMessage { 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 e3505ec..4f17e5f 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 @@ -18,6 +18,6 @@ public class CallOfferRequestMessage extends BaseMessage { 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 cffb2b4..03ae809 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 @@ -11,5 +11,5 @@ public class CallRejectRequestMessage extends BaseMessage { 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 7c3c6d3..6efb10f 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 @@ -23,23 +23,23 @@ public class MrzData implements Serializable { private static final long serialVersionUID = -5234275638176689315L; private Object raw; - private ParsedData parsed; + 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; - } + 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; - } + private Mrz.Format format; + private Map fields; + private boolean valid; + } } 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 a4035fe..46ccff7 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 @@ -19,5 +19,5 @@ public class MrzDataSubmitMessage extends BaseMessage { private static final long serialVersionUID = -2840411856886673672L; 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 0316b03..e72b764 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 @@ -2,22 +2,26 @@ 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; + 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(); - + + + } 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 02aa946..e51f8e5 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,12 +1,13 @@ 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; -public interface MessageInterface { // cambiar void +import io.twentysixty.sa.client.model.message.BaseMessage; +import io.twentysixty.sa.client.model.message.IdMessage; + +public interface MessageInterface { //cambiar void @POST @Path("/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 8b8c270..7761604 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 @@ -2,12 +2,13 @@ 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; + @Path("") public interface CredentialTypeInterface { @@ -15,10 +16,13 @@ public interface CredentialTypeInterface { @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 653ea22..cd25bba 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,13 +1,14 @@ 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") 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 0517895..f968f71 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,12 +1,13 @@ 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 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 c587dcc..7109231 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,13 +1,14 @@ 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 @@ -15,11 +16,12 @@ public interface MessageEventInterface { @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 9769919..a27aa4a 100644 --- a/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java +++ b/src/main/java/io/twentysixty/sa/client/util/Aes256cbc.java @@ -1,45 +1,51 @@ 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; -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); +import io.twentysixty.sa.client.jms.AbstractConsumer; - 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; - } +import javax.crypto.spec.IvParameterSpec; - 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 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, 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; + } + } 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 a412415..2ceaa25 100644 --- a/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java +++ b/src/main/java/io/twentysixty/sa/client/util/ISOUtil.java @@ -2,178 +2,149 @@ 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 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(); - } - - /** - * @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; - } - 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 < 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; - } - } else - d.append(c); - - } - return d.toString(); - } - public static boolean isValidHexString(String s) { - return HEX_CHARACTERS.matcher(s).matches(); - } +public class ISOUtil { + private static final Pattern HEX_CHARACTERS = Pattern.compile("[0-9a-fA-F]+"); + /** - * Swaps nibbles of all bytes in an input array - * - * @param value - * @return - */ - public static byte[] swapNibbles(byte[] value) { - byte[] output = new byte[value.length]; + * 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); + } - 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; - } + 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>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(); + } + } + + /** + * 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); - 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); + } + 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; + } + + 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"))); - } - - public static byte[] swapNibbles(String value) { - return swapNibbles(hex2byte(value)); - } + return swapNibbles(hex2byte(paddedValue + .replace("*", "A") + .replace("#", "B"))); + } + + public static byte [] swapNibbles(String value) { + return swapNibbles(hex2byte(value)); + } + + + } \ No newline at end of file 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 860f6c0..9aff8e6 100644 --- a/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java +++ b/src/main/java/io/twentysixty/sa/client/util/InstantDeserializer.java @@ -9,13 +9,12 @@ import com.fasterxml.jackson.databind.JsonDeserializer; 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; - } + @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 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 f19fd05..786aa65 100644 --- a/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java +++ b/src/main/java/io/twentysixty/sa/client/util/InstantSerializer.java @@ -9,18 +9,21 @@ import com.fasterxml.jackson.databind.SerializerProvider; 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"); + }*/ + + arg1.writeString(result); + + } + } \ No newline at end of file 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 3a3cf8d..9adcee8 100644 --- a/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java +++ b/src/main/java/io/twentysixty/sa/client/util/JsonUtil.java @@ -9,45 +9,59 @@ public class JsonUtil { public static String serialize(Object obj, boolean pretty) throws JsonProcessingException { - ObjectMapper mapper = JsonMapper.builder().findAndAddModules() + ObjectMapper mapper = JsonMapper.builder() + .findAndAddModules() + + .build(); + mapper.registerModule(new JavaTimeModule()); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - .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); + } - 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; + } + - /* - * 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 } - */ + // 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 03ea37d..b0c2969 100644 --- a/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java +++ b/src/main/java/io/twentysixty/sa/client/util/TokenGenerator.java @@ -6,23 +6,23 @@ public class TokenGenerator { - public static String generateSHA256Token(String data) { - - try { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - 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); - } - return hexString.toString(); - } catch (NoSuchAlgorithmException e) { - return null; - } - } + public static String generateSHA256Token(String data) { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + 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); + } + 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 4574a32..2d50c23 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 @@ -13,13 +13,13 @@ 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)); - + System.out.println(JsonUtil.serialize((BaseMessage)textMessage, true)); + } }