From acd74d1f388190024cff6e7a90d425a8d6949f8b Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 21 Aug 2020 16:22:04 +0300 Subject: [PATCH 01/42] apl-id and apl-comm compilaton mdules added --- apl-comm/pom.xml | 59 ++++++++++++ .../apl/comm/sv}/client/ConnectionStatus.java | 2 +- .../comm/sv}/client/MessageDispatcher.java | 6 +- .../sv}/client/ResponseTimeoutException.java | 2 +- .../apl/comm/sv}/client/SubscribePath.java | 2 +- .../SubscribePathAnnotationProcessor.java | 2 +- .../apl/comm/sv}/client/SvBusService.java | 8 +- .../apl/comm/sv}/client/SvRequestHandler.java | 8 +- .../comm/sv}/client/impl/HandlerRecord.java | 4 +- .../client/impl/MessageDispatcherImpl.java | 34 ++++--- .../client/impl/MessageSendingException.java | 2 +- .../sv}/client/impl/PathParamProcessor.java | 10 +- .../sv}/client/impl/PathSpecification.java | 2 +- .../comm/sv}/client/impl/ResponseLatch.java | 4 +- .../apl/comm/sv}/client/impl/SvBusClient.java | 18 ++-- .../sv}/client/impl/SvBusServiceImpl.java | 16 ++-- .../apl/comm/sv}/client/impl/SvSessions.java | 4 +- .../apl/comm/sv}/msg/SvBusErrorCodes.java | 2 +- .../apl/comm/sv}/msg/SvBusHello.java | 2 +- .../apl/comm/sv}/msg/SvBusMessage.java | 2 +- .../apl/comm/sv}/msg/SvBusRequest.java | 2 +- .../apl/comm/sv}/msg/SvBusResponse.java | 2 +- .../apl/comm/sv}/msg/SvBusStatus.java | 2 +- .../apl/comm/sv}/msg/SvChannelHeader.java | 2 +- .../apl/comm/sv}/msg/SvChannelMessage.java | 2 +- .../apl/comm/sv}/msg/SvCommandRequest.java | 2 +- .../apl/comm/sv}/msg/SvCommandResponse.java | 2 +- .../apl/comm/sv}/msg/UpdateMessage.java | 2 +- .../apl/comm/sv}/ws/WSClient.java | 2 +- .../apl/comm/sv}/ws/WSListener.java | 2 +- .../apl/comm}/PathSpecificationTest.java | 3 +- apl-core/pom.xml | 5 + .../apl/core/identity/IdValidator.java | 13 --- .../apl/core/identity/IdValidatorImpl.java | 12 --- .../apl/core/identity/ThisNodeIdHandler.java | 12 --- .../core/identity/ThisNodeIdHandlerImpl.java | 12 --- .../messages/update/CertificateLoader.java | 2 +- .../update/CertificateMemoryStore.java | 2 +- apl-id/pom.xml | 91 +++++++++++++++++++ .../apl/id}/cert/ActorType.java | 5 +- .../apl/id}/cert/ApolloCSR.java | 10 +- .../apl/id}/cert/ApolloCertificate.java | 37 +++----- .../id}/cert/ApolloCertificateException.java | 2 +- .../apl/id}/cert/AuthorityID.java | 2 +- .../apl/id}/cert/CertAttributes.java | 2 +- .../apollocurrency/apl/id}/cert/CertBase.java | 2 +- .../apl/id}/cert/CertificateHolder.java | 2 +- .../apl/id}/cert/TrustAllSSLProvider.java | 2 +- .../apl/id/handler/IdValidator.java | 16 ++++ .../apl/id/handler/IdValidatorImpl.java | 24 +++++ .../apl/id/handler/ThisNodeIdHandler.java | 17 ++++ .../apl/id/handler/ThisNodeIdHandlerImpl.java | 51 +++++++++++ .../apl/id/utils/StringList.java | 30 ++++++ .../apl/id}/cert/ApolloCertificateTest.java | 6 +- .../src/test/resources/test_cert.pem | 0 .../src/test/resources/test_cert_pvtkey.pem | 0 pom.xml | 2 + 57 files changed, 406 insertions(+), 165 deletions(-) create mode 100644 apl-comm/pom.xml rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/ConnectionStatus.java (77%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/MessageDispatcher.java (89%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/ResponseTimeoutException.java (85%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/SubscribePath.java (87%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/SubscribePathAnnotationProcessor.java (96%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/SvBusService.java (76%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/SvRequestHandler.java (57%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/HandlerRecord.java (74%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/MessageDispatcherImpl.java (91%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/MessageSendingException.java (71%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/PathParamProcessor.java (92%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/PathSpecification.java (97%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/ResponseLatch.java (92%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/SvBusClient.java (92%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/SvBusServiceImpl.java (82%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/client/impl/SvSessions.java (94%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusErrorCodes.java (90%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusHello.java (88%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusMessage.java (85%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusRequest.java (92%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusResponse.java (92%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvBusStatus.java (87%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvChannelHeader.java (95%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvChannelMessage.java (88%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvCommandRequest.java (86%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/SvCommandResponse.java (89%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/msg/UpdateMessage.java (84%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/ws/WSClient.java (96%) rename {apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util => apl-comm/src/main/java/com/apollocurrency/apl/comm/sv}/ws/WSListener.java (95%) rename {apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl => apl-comm/src/test/java/com/apollocurrency/apl/comm}/PathSpecificationTest.java (96%) delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidator.java delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidatorImpl.java delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandler.java delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandlerImpl.java create mode 100644 apl-id/pom.xml rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/ActorType.java (95%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/ApolloCSR.java (97%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/ApolloCertificate.java (86%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/ApolloCertificateException.java (79%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/AuthorityID.java (99%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/CertAttributes.java (98%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/CertBase.java (96%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/CertificateHolder.java (98%) rename {apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto => apl-id/src/main/java/com/apollocurrency/apl/id}/cert/TrustAllSSLProvider.java (97%) create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java rename {apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util => apl-id/src/test/java/com/apollocurrency/apl/id}/cert/ApolloCertificateTest.java (93%) rename {apl-utils => apl-id}/src/test/resources/test_cert.pem (100%) rename {apl-utils => apl-id}/src/test/resources/test_cert_pvtkey.pem (100%) diff --git a/apl-comm/pom.xml b/apl-comm/pom.xml new file mode 100644 index 0000000000..ba798deea7 --- /dev/null +++ b/apl-comm/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + com.apollocurrency + apollo-blockchain + 1.46.1 + + apl-comm + jar + + + org.projectlombok + lombok + provided + + + ch.qos.logback + logback-classic + + + org.slf4j + slf4j-api + + + com.fasterxml.jackson.datatype + jackson-datatype-json-org + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + + org.junit.platform + junit-platform-engine + test + + + org.junit.platform + junit-platform-commons + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + \ No newline at end of file diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ConnectionStatus.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java similarity index 77% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ConnectionStatus.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java index 3b9ff7ca4a..4b5c997507 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ConnectionStatus.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; /** * Sv connection status diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/MessageDispatcher.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java similarity index 89% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/MessageDispatcher.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java index 9bc967198f..fe656334ae 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/MessageDispatcher.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java @@ -1,10 +1,10 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusMessage; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; /** * Public interface to message dispatcher. Though dispatcher is a core of diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ResponseTimeoutException.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java similarity index 85% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ResponseTimeoutException.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java index b762253caf..9c9efa9194 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/ResponseTimeoutException.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; /** * Represent exception occurred during sending request, when sender did not receive response for some amount of time diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePath.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java similarity index 87% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePath.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java index 1f6eed12b8..f896588311 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePath.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePathAnnotationProcessor.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java similarity index 96% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePathAnnotationProcessor.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java index 5432047b08..c14c586cfe 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SubscribePathAnnotationProcessor.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; import java.util.LinkedHashSet; import java.util.Set; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvBusService.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java similarity index 76% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvBusService.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java index ec5ced6043..d094113cfe 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvBusService.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java @@ -1,11 +1,11 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusHello; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusRequest; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvBusHello; +import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; import java.net.URI; import java.util.Map; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvRequestHandler.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java similarity index 57% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvRequestHandler.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java index 190a8fb58b..61aef2ab74 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/SvRequestHandler.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java @@ -1,11 +1,11 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client; +package com.apollocurrency.apl.comm.sv.client; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusRequest; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvChannelHeader; +import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; /** * incoming message (request) handler prototype diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/HandlerRecord.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java similarity index 74% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/HandlerRecord.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java index 7f795fc595..9b69ceeace 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/HandlerRecord.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java @@ -1,9 +1,9 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.SvRequestHandler; +import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; import com.fasterxml.jackson.databind.JavaType; import java.util.HashMap; import java.util.Map; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageDispatcherImpl.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java similarity index 91% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageDispatcherImpl.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java index c2dcf72a61..7848af4660 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageDispatcherImpl.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java @@ -1,20 +1,19 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; - -import com.apollocurrency.aplwallet.apl.util.ThreadUtils; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.MessageDispatcher; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.ResponseTimeoutException; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.SvRequestHandler; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusStatus; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusErrorCodes; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusHello; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusMessage; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusRequest; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvChannelHeader; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvChannelMessage; +package com.apollocurrency.apl.comm.sv.client.impl; + +import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; +import com.apollocurrency.apl.comm.sv.client.ResponseTimeoutException; +import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; +import com.apollocurrency.apl.comm.sv.msg.SvBusStatus; +import com.apollocurrency.apl.comm.sv.msg.SvBusErrorCodes; +import com.apollocurrency.apl.comm.sv.msg.SvBusHello; +import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; +import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; +import com.apollocurrency.apl.comm.sv.msg.SvChannelMessage; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonNode; @@ -33,6 +32,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Implementation of MessageDispoatcher. Actually it is the core of messaging @@ -292,7 +293,10 @@ private void trySayHello(URI uri) { if (attempts == 0) { throw new MessageSendingException("Unable to send hello to " + uri + " due to response timeout", e); } - ThreadUtils.sleep(500); + try { + Thread.sleep(500); + } catch (InterruptedException ex) { + } } } } diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageSendingException.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java similarity index 71% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageSendingException.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java index 706ee0d3a2..175bf4f9f3 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/MessageSendingException.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; public class MessageSendingException extends RuntimeException { public MessageSendingException(String message, Throwable cause) { diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathParamProcessor.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java similarity index 92% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathParamProcessor.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java index 87509e9cc6..46dc3d6dd2 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathParamProcessor.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java @@ -1,12 +1,12 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.SvRequestHandler; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusMessage; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusRequest; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; +import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; +import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecification.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java similarity index 97% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecification.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java index f3249c29ba..c2b8be969f 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecification.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; import java.util.ArrayList; import java.util.HashMap; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/ResponseLatch.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java similarity index 92% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/ResponseLatch.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java index c694aabad3..074742ed83 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/ResponseLatch.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java @@ -1,9 +1,9 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; import lombok.extern.slf4j.Slf4j; import java.net.SocketTimeoutException; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusClient.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java similarity index 92% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusClient.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java index 2a0ac1ec03..8563a863f4 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusClient.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java @@ -1,15 +1,15 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; - -import com.apollocurrency.aplwallet.apl.util.supervisor.client.ConnectionStatus; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.MessageDispatcher; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusStatus; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusErrorCodes; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvChannelHeader; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvChannelMessage; +package com.apollocurrency.apl.comm.sv.client.impl; + +import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; +import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; +import com.apollocurrency.apl.comm.sv.msg.SvBusStatus; +import com.apollocurrency.apl.comm.sv.msg.SvBusErrorCodes; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; +import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; +import com.apollocurrency.apl.comm.sv.msg.SvChannelMessage; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusServiceImpl.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java similarity index 82% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusServiceImpl.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java index eb12631332..dd8f47b38a 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvBusServiceImpl.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java @@ -1,14 +1,14 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; - -import com.apollocurrency.aplwallet.apl.util.supervisor.client.ConnectionStatus; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.MessageDispatcher; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.SvBusService; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusHello; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusRequest; -import com.apollocurrency.aplwallet.apl.util.supervisor.msg.SvBusResponse; +package com.apollocurrency.apl.comm.sv.client.impl; + +import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; +import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; +import com.apollocurrency.apl.comm.sv.client.SvBusService; +import com.apollocurrency.apl.comm.sv.msg.SvBusHello; +import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; +import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; import java.net.URI; import java.util.HashMap; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvSessions.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java similarity index 94% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvSessions.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java index 70cb8bc31e..4a5cefc945 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/SvSessions.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java @@ -1,9 +1,9 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm.sv.client.impl; -import com.apollocurrency.aplwallet.apl.util.supervisor.client.ConnectionStatus; +import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; import lombok.extern.slf4j.Slf4j; import java.net.URI; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusErrorCodes.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java similarity index 90% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusErrorCodes.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java index e7d8a80775..99a75571c6 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusErrorCodes.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; /** * Error codes for communication channel diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusHello.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java similarity index 88% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusHello.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java index e76a7573c9..edc0a48e9c 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusHello.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java similarity index 85% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusMessage.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java index 59f2055d90..4cd0a15800 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusMessage.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusRequest.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java similarity index 92% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusRequest.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java index 24c913161f..faf42c6db7 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusRequest.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import java.util.HashMap; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusResponse.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java similarity index 92% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusResponse.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java index 9c150bd47b..ea9ab2b48a 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusResponse.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusStatus.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java similarity index 87% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusStatus.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java index 91ac71f25d..9a52443192 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvBusStatus.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelHeader.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java similarity index 95% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelHeader.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java index 6f7300afee..5e4edf2613 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelHeader.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import java.util.Date; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java similarity index 88% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelMessage.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java index fd9a560751..8ded29538a 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvChannelMessage.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java @@ -2,7 +2,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandRequest.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java similarity index 86% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandRequest.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java index e9f822027f..f62137db94 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandRequest.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import java.util.HashMap; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandResponse.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java similarity index 89% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandResponse.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java index e72f4ff719..5b9aa47d95 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/SvCommandResponse.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; import java.util.ArrayList; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/UpdateMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java similarity index 84% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/UpdateMessage.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java index 676e824df5..33f81fe6ae 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/supervisor/msg/UpdateMessage.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java @@ -1,7 +1,7 @@ /* * Copyright © 2020 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.supervisor.msg; +package com.apollocurrency.apl.comm.sv.msg; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSClient.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java similarity index 96% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSClient.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java index 652874921a..16a37e52b3 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSClient.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java @@ -1,7 +1,7 @@ /* * Copyright © 2018 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.ws; +package com.apollocurrency.apl.comm.sv.ws; import java.io.Closeable; import java.net.URI; diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSListener.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java similarity index 95% rename from apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSListener.java rename to apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java index 361d59bbe7..a971c63297 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/ws/WSListener.java +++ b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java @@ -1,7 +1,7 @@ /* * Copyright © 2018 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.util.ws; +package com.apollocurrency.apl.comm.sv.ws; import java.net.http.WebSocket; import java.net.http.WebSocket.Listener; diff --git a/apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecificationTest.java b/apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java similarity index 96% rename from apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecificationTest.java rename to apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java index 5a4bf91865..9bd305e01b 100644 --- a/apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/supervisor/client/impl/PathSpecificationTest.java +++ b/apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java @@ -3,8 +3,9 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package com.apollocurrency.aplwallet.apl.util.supervisor.client.impl; +package com.apollocurrency.apl.comm; +import com.apollocurrency.apl.comm.sv.client.impl.PathSpecification; import java.util.Map; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; diff --git a/apl-core/pom.xml b/apl-core/pom.xml index a34d6aece1..bff46da70f 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -19,6 +19,11 @@ apl-utils ${project.version} + + com.apollocurrency + apl-id + ${project.version} + com.apollocurrency apl-api diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidator.java deleted file mode 100644 index 0c43515a95..0000000000 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidator.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ - -package com.apollocurrency.aplwallet.apl.core.identity; - -/** - * - * @author alukin@gmail.com - */ -public interface IdValidator { - -} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidatorImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidatorImpl.java deleted file mode 100644 index 82b4622273..0000000000 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/IdValidatorImpl.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.aplwallet.apl.core.identity; - -/** - * - * @author alukin@gmail.com - */ -public class IdValidatorImpl implements IdValidator{ - -} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandler.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandler.java deleted file mode 100644 index fa2fd5374f..0000000000 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandler.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.aplwallet.apl.core.identity; - -/** - * - * @author alukin@gmail.com - */ -public interface ThisNodeIdHandler { - -} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandlerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandlerImpl.java deleted file mode 100644 index c7eeea406f..0000000000 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/identity/ThisNodeIdHandlerImpl.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.aplwallet.apl.core.identity; - -/** - * - * @author alukin@gmail.com - */ -public class ThisNodeIdHandlerImpl implements ThisNodeIdHandler { - -} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java index 2d5d86b16b..39a09085b6 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; import com.apollocurrency.aplwallet.apl.util.Version; -import com.apollocurrency.aplwallet.apl.crypto.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.ApolloCertificate; import lombok.extern.slf4j.Slf4j; import java.io.IOException; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java index c3a5aff555..290a0dd53d 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; import com.apollocurrency.aplwallet.apl.core.config.Property; -import com.apollocurrency.aplwallet.apl.crypto.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.ApolloCertificate; import io.firstbridge.cryptolib.CryptoFactory; import java.io.IOException; import lombok.extern.slf4j.Slf4j; diff --git a/apl-id/pom.xml b/apl-id/pom.xml new file mode 100644 index 0000000000..301c94c4f4 --- /dev/null +++ b/apl-id/pom.xml @@ -0,0 +1,91 @@ + + + 4.0.0 + + com.apollocurrency + apollo-blockchain + 1.46.1 + + apl-id + jar + + + io.firstbridge + cryptolib + + + org.slf4j + slf4j-log4j12 + + + org.junit + junit-bom + + + + + org.bouncycastle + bcprov-jdk15on + + + org.bouncycastle + bcpkix-jdk15on + jar + + + org.slf4j + slf4j-api + + + org.projectlombok + lombok + provided + + + + org.junit.platform + junit-platform-engine + test + + + org.junit.platform + junit-platform-commons + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.jboss.weld + weld-junit5 + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.codehaus.janino + janino + test + + + ch.qos.logback + logback-classic + test + + + \ No newline at end of file diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ActorType.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java similarity index 95% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ActorType.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java index 95fc533292..dfb43d9a8a 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ActorType.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java @@ -1,4 +1,7 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +/* + * Copyright (c) 2018-2020. Apollo Foundation. + */ +package com.apollocurrency.apl.id.cert; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCSR.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java similarity index 97% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCSR.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java index 2c437d2511..49e139daa9 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCSR.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java @@ -1,5 +1,9 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +/* + * Copyright (c) 2018-2020. Apollo Foundation. + */ +package com.apollocurrency.apl.id.cert; +import com.apollocurrency.apl.id.utils.StringList; import io.firstbridge.cryptolib.CryptoFactory; import io.firstbridge.cryptolib.CryptoNotValidException; import io.firstbridge.cryptolib.KeyGenerator; @@ -95,8 +99,8 @@ public static ApolloCSR fromCertificate(ApolloCertificate cert) { res.setCountry(cert.getCountry()); res.setState(cert.getStateOrProvince()); res.setCity(cert.getCity()); - res.setIP(cert.fromList(cert.getIPAddresses())); - res.setDNSNames(cert.fromList(cert.getDNSNames())); + res.setIP(StringList.fromList(cert.getIPAddresses())); + res.setDNSNames(StringList.fromList(cert.getDNSNames())); res.pubKey = cert.getPublicKey(); res.pvtKey = cert.getPrivateKey(); return res; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificate.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java similarity index 86% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificate.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java index 661b311251..7ae3f3c3e6 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificate.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java @@ -1,5 +1,6 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; +import com.apollocurrency.apl.id.utils.StringList; import io.firstbridge.cryptolib.KeyReader; import io.firstbridge.cryptolib.KeyWriter; import io.firstbridge.cryptolib.impl.KeyReaderImpl; @@ -20,6 +21,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.logging.Level; /** * Represents X.509 certificate with Apollo-specific attributes and signed by @@ -113,26 +115,6 @@ public String getEmail() { return cert_attr.geteMail(); } - public String fromList(List sl) { - String res = ""; - for (int i = 0; i < sl.size(); i++) { - String semicolon = i < sl.size() - 1 ? ";" : ""; - res += sl.get(i) + semicolon; - } - return res; - } - - public List fromString(String l) { - List res = new ArrayList<>(); - String[] ll = l.split(";"); - for (String s : ll) { - if (!s.isEmpty()) { - res.add(s); - } - } - return res; - } - @Override public String toString() { String res = "Apollo X.509 Certificate:\n"; @@ -143,18 +125,18 @@ public String toString() { res += "Country=" + getCountry() + " State/Province=" + getStateOrProvince() + " City=" + getCity(); res += "Organization=" + getOrganization() + " Org. Unit=" + getOrganizationUnit() + "\n"; - res += "IP address=" + fromList(getIPAddresses()) + "\n"; - res += "DNS names=" + fromList(getDNSNames()) + "\n"; + res += "IP address=" + StringList.fromList(getIPAddresses()) + "\n"; + res += "DNS names=" + StringList.fromList(getDNSNames()) + "\n"; return res; } public String getPEM() { - String res = ""; KeyWriter kw = new KeyWriterImpl(); + String res=""; try { res = kw.getX509CertificatePEM(certificate); } catch (IOException ex) { - log.error("Can not get certificate PEM", ex); + java.util.logging.Logger.getLogger(ApolloCertificate.class.getName()).log(Level.SEVERE, null, ex); } return res; } @@ -190,4 +172,9 @@ public boolean verify(X509Certificate certificate) { } return true; } + + public boolean isSelfSigned(){ + //TODO: implement + return true; + } } diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificateException.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java similarity index 79% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificateException.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java index a1f666ba14..f0b86b37d3 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/ApolloCertificateException.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; /** * @author alukin@gmail.com diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/AuthorityID.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java similarity index 99% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/AuthorityID.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java index 05c52b6d37..e62716e225 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/AuthorityID.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; import org.bouncycastle.util.encoders.Hex; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertAttributes.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java similarity index 98% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertAttributes.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java index e5c963bb0a..8ba21151df 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertAttributes.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; import org.bouncycastle.asn1.pkcs.Attribute; import org.bouncycastle.asn1.x500.X500Name; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertBase.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java similarity index 96% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertBase.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java index fdc1f76184..c2efaab07b 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertBase.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; import io.firstbridge.cryptolib.AsymCryptor; import io.firstbridge.cryptolib.AsymKeysHolder; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertificateHolder.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java similarity index 98% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertificateHolder.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java index ecef4844d7..f9987ecdec 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/CertificateHolder.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; import io.firstbridge.cryptolib.KeyReader; import io.firstbridge.cryptolib.impl.KeyReaderImpl; diff --git a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/TrustAllSSLProvider.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java similarity index 97% rename from apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/TrustAllSSLProvider.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java index e3ef5fbdec..763f1caa90 100644 --- a/apl-crypto/src/main/java/com/apollocurrency/aplwallet/apl/crypto/cert/TrustAllSSLProvider.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java @@ -14,7 +14,7 @@ * */ -package com.apollocurrency.aplwallet.apl.crypto.cert; +package com.apollocurrency.apl.id.cert; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java new file mode 100644 index 0000000000..a159a1f0c8 --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java @@ -0,0 +1,16 @@ +/* + * Copyright © 2020 Apollo Foundation + */ + +package com.apollocurrency.apl.id.handler; + +import com.apollocurrency.apl.id.cert.ApolloCertificate; + +/** + * + * @author alukin@gmail.com + */ +public interface IdValidator { + boolean isSelfSigned(ApolloCertificate cert); + boolean isTrusted(ApolloCertificate cert); +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java new file mode 100644 index 0000000000..69028a7269 --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2020 Apollo Foundation + */ +package com.apollocurrency.apl.id.handler; + +import com.apollocurrency.apl.id.cert.ApolloCertificate; + +/** + * + * @author alukin@gmail.com + */ +public class IdValidatorImpl implements IdValidator{ + + @Override + public boolean isSelfSigned(ApolloCertificate cert) { + return false; + } + + @Override + public boolean isTrusted(ApolloCertificate cert) { + return true; + } + +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java new file mode 100644 index 0000000000..c6a543ec9e --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java @@ -0,0 +1,17 @@ +/* + * Copyright © 2020 Apollo Foundation + */ +package com.apollocurrency.apl.id.handler; + +import com.apollocurrency.apl.id.cert.ApolloCertificate; +import java.math.BigInteger; + +/** + * + * @author alukin@gmail.com + */ +public interface ThisNodeIdHandler { + BigInteger getApolloId(); + ApolloCertificate getCertificate(); + byte[] sign(byte[] message); +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java new file mode 100644 index 0000000000..69ab4cd332 --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java @@ -0,0 +1,51 @@ +/* + * Copyright © 2020 Apollo Foundation + */ +package com.apollocurrency.apl.id.handler; + +import com.apollocurrency.apl.id.cert.ApolloCertificate; +import io.firstbridge.cryptolib.AsymKeysHolder; +import io.firstbridge.cryptolib.CryptoFactory; +import io.firstbridge.cryptolib.CryptoNotValidException; +import io.firstbridge.cryptolib.CryptoSignature; +import java.math.BigInteger; +import java.security.KeyPair; +import lombok.extern.slf4j.Slf4j; + +/** + * + * @author alukin@gmail.com + */ +@Slf4j +public class ThisNodeIdHandlerImpl implements ThisNodeIdHandler { + BigInteger myApolloId; + KeyPair myKeys; + ApolloCertificate myCert; + CryptoFactory cryptoFactory; + + @Override + public BigInteger getApolloId() { + return myApolloId; + } + + @Override + public ApolloCertificate getCertificate() { + return myCert; + } + + @Override + public byte[] sign(byte[] message) { + byte[] res = null; + CryptoSignature signer = cryptoFactory.getCryptoSiganture(); + AsymKeysHolder kh = new AsymKeysHolder(myKeys.getPublic(), myKeys.getPrivate(), null); + signer.setKeys(kh); + try { + res = signer.sign(message); + } catch (CryptoNotValidException ex) { + log.error("Can not sign message with my node private key", ex); + } + return res; + } + + +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java new file mode 100644 index 0000000000..51fd48c47a --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java @@ -0,0 +1,30 @@ +package com.apollocurrency.apl.id.utils; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author al + */ +public class StringList { + public static String fromList(List sl) { + String res = ""; + for (int i = 0; i < sl.size(); i++) { + String semicolon = i < sl.size() - 1 ? ";" : ""; + res += sl.get(i) + semicolon; + } + return res; + } + + public static List fromString(String l) { + List res = new ArrayList<>(); + String[] ll = l.split(";"); + for (String s : ll) { + if (!s.isEmpty()) { + res.add(s); + } + } + return res; + } +} diff --git a/apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/cert/ApolloCertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java similarity index 93% rename from apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/cert/ApolloCertificateTest.java rename to apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java index 3032d252a4..a7d5c03019 100644 --- a/apl-utils/src/test/java/com/apollocurrency/aplwallet/apl/util/cert/ApolloCertificateTest.java +++ b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java @@ -1,9 +1,5 @@ -package com.apollocurrency.aplwallet.apl.util.cert; +package com.apollocurrency.apl.id.cert; -import com.apollocurrency.aplwallet.apl.crypto.cert.ApolloCertificate; -import com.apollocurrency.aplwallet.apl.crypto.cert.AuthorityID; -import com.apollocurrency.aplwallet.apl.crypto.cert.CertAttributes; -import com.apollocurrency.aplwallet.apl.crypto.cert.ApolloCertificateException; import io.firstbridge.cryptolib.CryptoConfig; import io.firstbridge.cryptolib.CryptoParams; import org.junit.jupiter.api.BeforeAll; diff --git a/apl-utils/src/test/resources/test_cert.pem b/apl-id/src/test/resources/test_cert.pem similarity index 100% rename from apl-utils/src/test/resources/test_cert.pem rename to apl-id/src/test/resources/test_cert.pem diff --git a/apl-utils/src/test/resources/test_cert_pvtkey.pem b/apl-id/src/test/resources/test_cert_pvtkey.pem similarity index 100% rename from apl-utils/src/test/resources/test_cert_pvtkey.pem rename to apl-id/src/test/resources/test_cert_pvtkey.pem diff --git a/pom.xml b/pom.xml index 538c990457..a9513db5d3 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,8 @@ apl-bom apl-conf apl-exec + apl-id + apl-comm From c8bf7cdd3e3eabc5f7b19723f1f130c4388945ad Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 25 Aug 2020 12:11:28 +0300 Subject: [PATCH 02/42] new FBCrypto on apl-bom-ext 1.0.2 --- apl-core/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/apl-core/pom.xml b/apl-core/pom.xml index bff46da70f..a8caaee3c7 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -318,6 +318,7 @@ com.apollocurrency.antifraud antifraud + 1.0.7 From 591fe0be16b2633ab4155cfde78e8af875b0d34e Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 26 Aug 2020 10:23:02 +0300 Subject: [PATCH 03/42] after-merge fix --- apl-core/pom.xml | 1 - .../apl/core/transaction/TransactionValidator.java | 11 +++++++++-- pom.xml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apl-core/pom.xml b/apl-core/pom.xml index a8caaee3c7..bff46da70f 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -318,7 +318,6 @@ com.apollocurrency.antifraud antifraud - 1.0.7 diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java index 5387db9be6..d1a29cc8bf 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java @@ -110,8 +110,15 @@ public void validate(Transaction transaction) throws AplException.ValidationExce throw new AplException.NotValidException("Transactions of this type must have a valid recipient"); } - if (!AntifraudValidator.validate(blockchain.getHeight(), blockchainConfig.getChain().getChainId(), transaction.getSenderId(), - transaction.getRecipientId())) throw new AplException.NotValidException("Incorrect Passphrase"); + if (!AntifraudValidator.validate( + blockchain.getHeight(), + blockchainConfig.getChain().getChainId(), + transaction.getSenderId(), + transaction.getRecipientId()) + ) + { + throw new AplException.NotValidException("Incorrect Passphrase"); + } Account sender = accountService.getAccount(transaction.getSenderId()); if (sender != null && sender.isChild()) { diff --git a/pom.xml b/pom.xml index 08eef89935..95c471897e 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 1.0.8 - 1.0.1 + 1.0.2 ApolloWallet/apollo-blockchain 1.9.1 From 8f6df59fc9298f4cb0a8d897f6d7d47a7e58310c Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 28 Aug 2020 17:03:04 +0300 Subject: [PATCH 04/42] generated sources deleted --- .../aplwallet/api/v2/AccountApi.java | 120 ----- .../aplwallet/api/v2/AccountApiService.java | 30 -- .../aplwallet/api/v2/InfoApi.java | 51 --- .../aplwallet/api/v2/InfoApiService.java | 20 - .../aplwallet/api/v2/OperationApi.java | 82 ---- .../aplwallet/api/v2/OperationApiService.java | 24 - .../aplwallet/api/v2/StateApi.java | 149 ------- .../aplwallet/api/v2/StateApiService.java | 36 -- .../aplwallet/api/v2/TransactionApi.java | 94 ---- .../api/v2/TransactionApiService.java | 27 -- .../aplwallet/api/v2/model/AccountInfo.java | 156 ------- .../api/v2/model/AccountInfoResp.java | 158 ------- .../aplwallet/api/v2/model/AccountReq.java | 81 ---- .../api/v2/model/AccountReqSendMoney.java | 141 ------ .../api/v2/model/AccountReqTest.java | 96 ---- .../aplwallet/api/v2/model/BlockInfo.java | 323 -------------- .../api/v2/model/BlockchainInfo.java | 183 -------- .../aplwallet/api/v2/model/CountResponse.java | 65 --- .../api/v2/model/CreateChildAccountResp.java | 83 ---- .../api/v2/model/HealthResponse.java | 156 ------- .../aplwallet/api/v2/model/ListResponse.java | 65 --- .../api/v2/model/QueryCountResult.java | 80 ---- .../aplwallet/api/v2/model/QueryObject.java | 203 --------- .../aplwallet/api/v2/model/QueryResult.java | 96 ---- .../api/v2/model/TransactionInfo.java | 410 ----------------- .../v2/model/TransactionInfoArrayResp.java | 67 --- .../api/v2/model/TransactionInfoResp.java | 412 ------------------ .../aplwallet/api/v2/model/TxReceipt.java | 279 ------------ .../aplwallet/api/v2/model/TxRequest.java | 66 --- 29 files changed, 3753 deletions(-) delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java deleted file mode 100644 index 900b165785..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.AccountApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.AccountInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.AccountReq; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqSendMoney; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqTest; -import com.apollocurrency.aplwallet.api.v2.model.CreateChildAccountResp; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/account") - - -public class AccountApi { - - @Inject AccountApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns unsigned CreateChildAccount transaction for creating child accounts", description = "Returns unsigned CreateChildAccount transaction as a byte array. The list of child public keys is attached in the transaction appendix. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTx(@Parameter(description = "the parent account and the list of public keys" ,required=true) AccountReq body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTx(body,securityContext); - } - @POST - @Path("/money") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns signed SendMoney transaction from child account", description = "Returns signed SendMoney transaction as a byte array. This transaction is a multi-signature signed tx. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTxSendMony(@Parameter(description = "the parent account, child account and other" ,required=true) AccountReqSendMoney body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTxSendMony(body,securityContext); - } - @POST - @Path("/test") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns signed CreateChildAccount transaction for creating child accounts", description = "Returns signed CreateChildAccount transaction as a byte array. The list of child public keys is attached in the transaction appendix. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTxTest(@Parameter(description = "the parent account and the list of public keys" ,required=true) AccountReqTest body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTxTest(body,securityContext); - } - @GET - @Path("/{account}") - - @Produces({ "application/json" }) - @Operation(summary = "Returns the details account information", description = "", tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = AccountInfoResp.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getAccountInfo( @PathParam("account") String account,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getAccountInfo(account,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java deleted file mode 100644 index 03ab1d601e..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.AccountInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.AccountReq; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqSendMoney; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqTest; -import com.apollocurrency.aplwallet.api.v2.model.CreateChildAccountResp; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface AccountApiService { - Response createChildAccountTx(AccountReq body,SecurityContext securityContext) - throws NotFoundException; - Response createChildAccountTxSendMony(AccountReqSendMoney body,SecurityContext securityContext) - throws NotFoundException; - Response createChildAccountTxTest(AccountReqTest body,SecurityContext securityContext) - throws NotFoundException; - Response getAccountInfo(String account,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java deleted file mode 100644 index 44c0b0e283..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.InfoApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.HealthResponse; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/info") - - -public class InfoApi { - - @Inject InfoApiService service; - - @GET - @Path("/health") - - @Produces({ "application/json" }) - @Operation(summary = "Gets node health", description = "", tags={ "info" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = HealthResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getHealthInfo(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getHealthInfo(securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java deleted file mode 100644 index e9d204e1f2..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.HealthResponse; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface InfoApiService { - Response getHealthInfo(SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java deleted file mode 100644 index 8de23b2460..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.OperationApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryCountResult; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.QueryResult; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/operation") - - -public class OperationApi { - - @Inject OperationApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns the operation list corresponding the query object group by account", description = "", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "operations" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = QueryResult.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getOperations(@Parameter(description = "the query object" ,required=true) QueryObject body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getOperations(body,securityContext); - } - @POST - @Path("/count") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns the count of operations corresponding the query object group by account", description = "", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "operations" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = QueryCountResult.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getOperationsCount(@Parameter(description = "the query object" ,required=true) QueryObject body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getOperationsCount(body,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java deleted file mode 100644 index 408487a37a..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryCountResult; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.QueryResult; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface OperationApiService { - Response getOperations(QueryObject body,SecurityContext securityContext) - throws NotFoundException; - Response getOperationsCount(QueryObject body,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java deleted file mode 100644 index 84184452e6..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.StateApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.BlockInfo; -import com.apollocurrency.aplwallet.api.v2.model.BlockchainInfo; -import com.apollocurrency.aplwallet.api.v2.model.CountResponse; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoArrayResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/state") - - -public class StateApi { - - @Inject StateApiService service; - - @GET - @Path("/block") - - @Produces({ "application/json" }) - @Operation(summary = "Get block object", description = "Return details information about the block given block height. If no height is provided, it will fetch the latest block.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockInfo.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockByHeight( @DefaultValue("-1") @QueryParam("height") String height,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockByHeight(height,securityContext); - } - @GET - @Path("/block/{block}") - - @Produces({ "application/json" }) - @Operation(summary = "Get block object given block id", description = "Return the detail information about block given id", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockInfo.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockById( @PathParam("block") String block,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockById(block,securityContext); - } - @GET - @Path("/blockchain") - - @Produces({ "application/json" }) - @Operation(summary = "Get blockchain object", description = "Return details information about the blockchain", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockchainInfo.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockchainInfo(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockchainInfo(securityContext); - } - @GET - @Path("/tx/{transaction}") - - @Produces({ "application/json" }) - @Operation(summary = "Get transaction receipt given transaction id.", description = "Return the brief information about transaction given id.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TxReceipt.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxReceiptById( @PathParam("transaction") String transaction,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxReceiptById(transaction,securityContext); - } - @POST - @Path("/tx") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Get transaction receipt list given list of the transaction id.", description = "Return the list of the brief information about transactions.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TxReceipt.class)))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxReceiptList(@Parameter(description = "the list of transaction id" ,required=true) java.util.List body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxReceiptList(body,securityContext); - } - @GET - @Path("/unconfirmed") - - @Produces({ "application/json" }) - @Operation(summary = "Get list of unconfirmed transaction receipts.", description = "Return the list of the detail information about unconfirmed transactions.", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TransactionInfoArrayResp.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getUnconfirmedTx( @DefaultValue("1") @QueryParam("page") Integer page, @Max(100) @DefaultValue("50") @QueryParam("perPage") Integer perPage,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getUnconfirmedTx(page,perPage,securityContext); - } - @GET - @Path("/unconfirmed/count") - - @Produces({ "application/json" }) - @Operation(summary = "Get count of unconfirmed transaction receipts.", description = "Return the count of unconfirmed transactions.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CountResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getUnconfirmedTxCount(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getUnconfirmedTxCount(securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java deleted file mode 100644 index 1daf73b405..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.BlockInfo; -import com.apollocurrency.aplwallet.api.v2.model.BlockchainInfo; -import com.apollocurrency.aplwallet.api.v2.model.CountResponse; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoArrayResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface StateApiService { - Response getBlockByHeight(String height,SecurityContext securityContext) - throws NotFoundException; - Response getBlockById(String block,SecurityContext securityContext) - throws NotFoundException; - Response getBlockchainInfo(SecurityContext securityContext) - throws NotFoundException; - Response getTxReceiptById(String transaction,SecurityContext securityContext) - throws NotFoundException; - Response getTxReceiptList(java.util.List body,SecurityContext securityContext) - throws NotFoundException; - Response getUnconfirmedTx(Integer page,Integer perPage,SecurityContext securityContext) - throws NotFoundException; - Response getUnconfirmedTxCount(SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java deleted file mode 100644 index e4e9ac9098..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.TransactionApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.ListResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.apollocurrency.aplwallet.api.v2.model.TxRequest; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/transaction") - - -public class TransactionApi { - - @Inject TransactionApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Broadcast transaction and return transaction receipt.", description = "Asynchronously broadcast the signed transaction to the network. The transaction is validated and immediately put into an unconfirmed transaction pool for further sending to the blockchain. ", tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TxReceipt.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "409", description = "The request could not be completed due to a conflict with the current state of the resource. The resource is busy and the request might be reissued later. "), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response broadcastTx(@Parameter(description = "the signed transaction is a byte array in hex format" ,required=true) TxRequest body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.broadcastTx(body,securityContext); - } - @POST - @Path("/batch") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Broadcast a batch of transactions and return the transaction receipt list.", description = "Asynchronously broadcast the batch of the signed transaction to the network. The transactions are immediately put into an unconfirmed transaction pool in the same order as in the batch and later are sending to the network.", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ListResponse.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response broadcastTxBatch(@Parameter(description = "an array of signed transactions, each item is a byte array in hex format" ,required=true) java.util.List body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.broadcastTxBatch(body,securityContext); - } - @GET - @Path("/{transaction}") - - @Produces({ "application/json" }) - @Operation(summary = "Get transaction object given transaction id.", description = "Return the detail information about transaction by id.", tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TransactionInfoResp.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxById( @PathParam("transaction") String transaction,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxById(transaction,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java deleted file mode 100644 index 99f2cc81a7..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.ListResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.apollocurrency.aplwallet.api.v2.model.TxRequest; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface TransactionApiService { - Response broadcastTx(TxRequest body,SecurityContext securityContext) - throws NotFoundException; - Response broadcastTxBatch(java.util.List body,SecurityContext securityContext) - throws NotFoundException; - Response getTxById(String transaction,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java deleted file mode 100644 index 1546fd9f86..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountInfo { - private String account = null; private String publicKey = null; private String parent = null; private String balance = null; private String unconfirmedbalance = null; /** - * Gets or Sets status - */ - public enum StatusEnum { - CREATED("created"), - VERIFIED("verified"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("account") - @NotNull - public String getAccount() { - return account; - } - public void setAccount(String account) { - this.account = account; - } - - /** - * The account public key in a hex string format - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", required = true, description = "The account public key in a hex string format") - @JsonProperty("publicKey") - @NotNull - public String getPublicKey() { - return publicKey; - } - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - /** - **/ - - @Schema(example = "APL-AHYW-P3YX-V426-4UMP2", description = "") - @JsonProperty("parent") - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("balance") - public String getBalance() { - return balance; - } - public void setBalance(String balance) { - this.balance = balance; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("unconfirmedbalance") - public String getUnconfirmedbalance() { - return unconfirmedbalance; - } - public void setUnconfirmedbalance(String unconfirmedbalance) { - this.unconfirmedbalance = unconfirmedbalance; - } - - /** - **/ - - @Schema(example = "created", description = "") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountInfo accountInfo = (AccountInfo) o; - return Objects.equals(account, accountInfo.account) && - Objects.equals(publicKey, accountInfo.publicKey) && - Objects.equals(parent, accountInfo.parent) && - Objects.equals(balance, accountInfo.balance) && - Objects.equals(unconfirmedbalance, accountInfo.unconfirmedbalance) && - Objects.equals(status, accountInfo.status); - } - - @Override - public int hashCode() { - return Objects.hash(account, publicKey, parent, balance, unconfirmedbalance, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountInfo {\n"); - - sb.append(" account: ").append(toIndentedString(account)).append("\n"); - sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" balance: ").append(toIndentedString(balance)).append("\n"); - sb.append(" unconfirmedbalance: ").append(toIndentedString(unconfirmedbalance)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java deleted file mode 100644 index 7ec7e494ad..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.AccountInfo; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountInfoResp extends BaseResponse { - private String account = null; private String publicKey = null; private String parent = null; private String balance = null; private String unconfirmedbalance = null; /** - * Gets or Sets status - */ - public enum StatusEnum { - CREATED("created"), - VERIFIED("verified"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("account") - @NotNull - public String getAccount() { - return account; - } - public void setAccount(String account) { - this.account = account; - } - - /** - * The account public key in a hex string format - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", required = true, description = "The account public key in a hex string format") - @JsonProperty("publicKey") - @NotNull - public String getPublicKey() { - return publicKey; - } - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - /** - **/ - - @Schema(example = "APL-AHYW-P3YX-V426-4UMP2", description = "") - @JsonProperty("parent") - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("balance") - public String getBalance() { - return balance; - } - public void setBalance(String balance) { - this.balance = balance; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("unconfirmedbalance") - public String getUnconfirmedbalance() { - return unconfirmedbalance; - } - public void setUnconfirmedbalance(String unconfirmedbalance) { - this.unconfirmedbalance = unconfirmedbalance; - } - - /** - **/ - - @Schema(example = "created", description = "") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountInfoResp accountInfoResp = (AccountInfoResp) o; - return Objects.equals(account, accountInfoResp.account) && - Objects.equals(publicKey, accountInfoResp.publicKey) && - Objects.equals(parent, accountInfoResp.parent) && - Objects.equals(balance, accountInfoResp.balance) && - Objects.equals(unconfirmedbalance, accountInfoResp.unconfirmedbalance) && - Objects.equals(status, accountInfoResp.status); - } - - @Override - public int hashCode() { - return Objects.hash(account, publicKey, parent, balance, unconfirmedbalance, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountInfoResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" account: ").append(toIndentedString(account)).append("\n"); - sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" balance: ").append(toIndentedString(balance)).append("\n"); - sb.append(" unconfirmedbalance: ").append(toIndentedString(unconfirmedbalance)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java deleted file mode 100644 index e63733e3e8..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReq { - private String parent = null; private java.util.List childPublicKeyList = new java.util.ArrayList(); - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * list of child account public keys - **/ - - @Schema(description = "list of child account public keys") - @JsonProperty("child_publicKey_list") - @Size(max=128) public java.util.List getChildPublicKeyList() { - return childPublicKeyList; - } - public void setChildPublicKeyList(java.util.List childPublicKeyList) { - this.childPublicKeyList = childPublicKeyList; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReq accountReq = (AccountReq) o; - return Objects.equals(parent, accountReq.parent) && - Objects.equals(childPublicKeyList, accountReq.childPublicKeyList); - } - - @Override - public int hashCode() { - return Objects.hash(parent, childPublicKeyList); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReq {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" childPublicKeyList: ").append(toIndentedString(childPublicKeyList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java deleted file mode 100644 index de61dab31e..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReqSendMoney { - private String parent = null; private String psecret = null; private String sender = null; private String csecret = null; private String recipient = null; private Long amount = null; - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * parent account secret phrase - **/ - - @Schema(example = "ParenttopSecretPhrase", description = "parent account secret phrase") - @JsonProperty("psecret") - public String getPsecret() { - return psecret; - } - public void setPsecret(String psecret) { - this.psecret = psecret; - } - - /** - * child account id - **/ - - @Schema(example = "APL-632K-TWX3-2ALQ-973CU", description = "child account id") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * child account secret phrase - **/ - - @Schema(example = "ChildtopSecretPhrase", description = "child account secret phrase") - @JsonProperty("csecret") - public String getCsecret() { - return csecret; - } - public void setCsecret(String csecret) { - this.csecret = csecret; - } - - /** - * recipient account id - **/ - - @Schema(example = "APL-VWMY-APVK-UFHN-3MC7N", description = "recipient account id") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * the amount - **/ - - @Schema(description = "the amount") - @JsonProperty("amount") - public Long getAmount() { - return amount; - } - public void setAmount(Long amount) { - this.amount = amount; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReqSendMoney accountReqSendMoney = (AccountReqSendMoney) o; - return Objects.equals(parent, accountReqSendMoney.parent) && - Objects.equals(psecret, accountReqSendMoney.psecret) && - Objects.equals(sender, accountReqSendMoney.sender) && - Objects.equals(csecret, accountReqSendMoney.csecret) && - Objects.equals(recipient, accountReqSendMoney.recipient) && - Objects.equals(amount, accountReqSendMoney.amount); - } - - @Override - public int hashCode() { - return Objects.hash(parent, psecret, sender, csecret, recipient, amount); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReqSendMoney {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" psecret: ").append(toIndentedString(psecret)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" csecret: ").append(toIndentedString(csecret)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java deleted file mode 100644 index 61e7f8a84b..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReqTest { - private String parent = null; private String secret = null; private java.util.List childSecretList = new java.util.ArrayList(); - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * parent account secret phrase - **/ - - @Schema(example = "topSecretPhrase", description = "parent account secret phrase") - @JsonProperty("secret") - public String getSecret() { - return secret; - } - public void setSecret(String secret) { - this.secret = secret; - } - - /** - * list of child secret phrases - **/ - - @Schema(description = "list of child secret phrases") - @JsonProperty("child_secret_list") - @Size(max=128) public java.util.List getChildSecretList() { - return childSecretList; - } - public void setChildSecretList(java.util.List childSecretList) { - this.childSecretList = childSecretList; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReqTest accountReqTest = (AccountReqTest) o; - return Objects.equals(parent, accountReqTest.parent) && - Objects.equals(secret, accountReqTest.secret) && - Objects.equals(childSecretList, accountReqTest.childSecretList); - } - - @Override - public int hashCode() { - return Objects.hash(parent, secret, childSecretList); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReqTest {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" secret: ").append(toIndentedString(secret)).append("\n"); - sb.append(" childSecretList: ").append(toIndentedString(childSecretList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java deleted file mode 100644 index 8f0ee0cd16..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class BlockInfo extends BaseResponse { - private String id = null; private String blockSignature = null; private Long height = null; private String generator = null; private String generationSignature = null; private String generatorPublicKey = null; private Long timestamp = null; private Integer timeout = null; private Integer version = null; private String baseTarget = null; private String cumulativeDifficulty = null; private String previousBlock = null; private String previousBlockHash = null; private String nextBlock = null; private String payloadHash = null; private Integer payloadLength = null; private Integer numberOfTransactions = null; private String totalAmountATM = null; private String totalFeeATM = null; - - /** - **/ - - @Schema(example = "1130faaeb604315160401", description = "") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - **/ - - @Schema(example = "ff080e64436603df0c3b9a5b792b03a26725a83bbe6aa46eb7eed9ee83707f071b6d529d09be1f2594c6f8545c2772a091896bc808553c1774e39a41248b1e1c", description = "") - @JsonProperty("blockSignature") - public String getBlockSignature() { - return blockSignature; - } - public void setBlockSignature(String blockSignature) { - this.blockSignature = blockSignature; - } - - /** - **/ - - @Schema(example = "1319854", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "") - @JsonProperty("generator") - public String getGenerator() { - return generator; - } - public void setGenerator(String generator) { - this.generator = generator; - } - - /** - **/ - - @Schema(example = "60e598f6276371119720786b05e507cd628665473b24c8f76de436d99cf113f7", description = "") - @JsonProperty("generationSignature") - public String getGenerationSignature() { - return generationSignature; - } - public void setGenerationSignature(String generationSignature) { - this.generationSignature = generationSignature; - } - - /** - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "") - @JsonProperty("generatorPublicKey") - public String getGeneratorPublicKey() { - return generatorPublicKey; - } - public void setGeneratorPublicKey(String generatorPublicKey) { - this.generatorPublicKey = generatorPublicKey; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - **/ - - @Schema(example = "1", description = "") - @JsonProperty("timeout") - public Integer getTimeout() { - return timeout; - } - public void setTimeout(Integer timeout) { - this.timeout = timeout; - } - - /** - * The block version - **/ - - @Schema(example = "6", description = "The block version") - @JsonProperty("version") - public Integer getVersion() { - return version; - } - public void setVersion(Integer version) { - this.version = version; - } - - /** - **/ - - @Schema(example = "7686143350", description = "") - @JsonProperty("baseTarget") - public String getBaseTarget() { - return baseTarget; - } - public void setBaseTarget(String baseTarget) { - this.baseTarget = baseTarget; - } - - /** - **/ - - @Schema(example = "8728234277524822", description = "") - @JsonProperty("cumulativeDifficulty") - public String getCumulativeDifficulty() { - return cumulativeDifficulty; - } - public void setCumulativeDifficulty(String cumulativeDifficulty) { - this.cumulativeDifficulty = cumulativeDifficulty; - } - - /** - * Prev block id - **/ - - @Schema(example = "80faaeb4787337264514", description = "Prev block id") - @JsonProperty("previousBlock") - public String getPreviousBlock() { - return previousBlock; - } - public void setPreviousBlock(String previousBlock) { - this.previousBlock = previousBlock; - } - - /** - **/ - - @Schema(example = "5b8ba14eaebba8cdc682c946947f5352a596d00ac63c4e616785d00cf8b8e016", description = "") - @JsonProperty("previousBlockHash") - public String getPreviousBlockHash() { - return previousBlockHash; - } - public void setPreviousBlockHash(String previousBlockHash) { - this.previousBlockHash = previousBlockHash; - } - - /** - * Next block id - **/ - - @Schema(example = "140faaeb81930093118053", description = "Next block id") - @JsonProperty("nextBlock") - public String getNextBlock() { - return nextBlock; - } - public void setNextBlock(String nextBlock) { - this.nextBlock = nextBlock; - } - - /** - * Hash of the paylod (all transactions) - **/ - - @Schema(example = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", description = "Hash of the paylod (all transactions)") - @JsonProperty("payloadHash") - public String getPayloadHash() { - return payloadHash; - } - public void setPayloadHash(String payloadHash) { - this.payloadHash = payloadHash; - } - - /** - * The length in bytes of all transactions - **/ - - @Schema(example = "523423", description = "The length in bytes of all transactions") - @JsonProperty("payloadLength") - public Integer getPayloadLength() { - return payloadLength; - } - public void setPayloadLength(Integer payloadLength) { - this.payloadLength = payloadLength; - } - - /** - **/ - - @Schema(example = "14", description = "") - @JsonProperty("numberOfTransactions") - public Integer getNumberOfTransactions() { - return numberOfTransactions; - } - public void setNumberOfTransactions(Integer numberOfTransactions) { - this.numberOfTransactions = numberOfTransactions; - } - - /** - **/ - - @Schema(example = "569000000000000", description = "") - @JsonProperty("totalAmountATM") - public String getTotalAmountATM() { - return totalAmountATM; - } - public void setTotalAmountATM(String totalAmountATM) { - this.totalAmountATM = totalAmountATM; - } - - /** - **/ - - @Schema(example = "2800000000", description = "") - @JsonProperty("totalFeeATM") - public String getTotalFeeATM() { - return totalFeeATM; - } - public void setTotalFeeATM(String totalFeeATM) { - this.totalFeeATM = totalFeeATM; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BlockInfo blockInfo = (BlockInfo) o; - return Objects.equals(id, blockInfo.id) && - Objects.equals(blockSignature, blockInfo.blockSignature) && - Objects.equals(height, blockInfo.height) && - Objects.equals(generator, blockInfo.generator) && - Objects.equals(generationSignature, blockInfo.generationSignature) && - Objects.equals(generatorPublicKey, blockInfo.generatorPublicKey) && - Objects.equals(timestamp, blockInfo.timestamp) && - Objects.equals(timeout, blockInfo.timeout) && - Objects.equals(version, blockInfo.version) && - Objects.equals(baseTarget, blockInfo.baseTarget) && - Objects.equals(cumulativeDifficulty, blockInfo.cumulativeDifficulty) && - Objects.equals(previousBlock, blockInfo.previousBlock) && - Objects.equals(previousBlockHash, blockInfo.previousBlockHash) && - Objects.equals(nextBlock, blockInfo.nextBlock) && - Objects.equals(payloadHash, blockInfo.payloadHash) && - Objects.equals(payloadLength, blockInfo.payloadLength) && - Objects.equals(numberOfTransactions, blockInfo.numberOfTransactions) && - Objects.equals(totalAmountATM, blockInfo.totalAmountATM) && - Objects.equals(totalFeeATM, blockInfo.totalFeeATM); - } - - @Override - public int hashCode() { - return Objects.hash(id, blockSignature, height, generator, generationSignature, generatorPublicKey, timestamp, timeout, version, baseTarget, cumulativeDifficulty, previousBlock, previousBlockHash, nextBlock, payloadHash, payloadLength, numberOfTransactions, totalAmountATM, totalFeeATM); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BlockInfo {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" blockSignature: ").append(toIndentedString(blockSignature)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" generator: ").append(toIndentedString(generator)).append("\n"); - sb.append(" generationSignature: ").append(toIndentedString(generationSignature)).append("\n"); - sb.append(" generatorPublicKey: ").append(toIndentedString(generatorPublicKey)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" baseTarget: ").append(toIndentedString(baseTarget)).append("\n"); - sb.append(" cumulativeDifficulty: ").append(toIndentedString(cumulativeDifficulty)).append("\n"); - sb.append(" previousBlock: ").append(toIndentedString(previousBlock)).append("\n"); - sb.append(" previousBlockHash: ").append(toIndentedString(previousBlockHash)).append("\n"); - sb.append(" nextBlock: ").append(toIndentedString(nextBlock)).append("\n"); - sb.append(" payloadHash: ").append(toIndentedString(payloadHash)).append("\n"); - sb.append(" payloadLength: ").append(toIndentedString(payloadLength)).append("\n"); - sb.append(" numberOfTransactions: ").append(toIndentedString(numberOfTransactions)).append("\n"); - sb.append(" totalAmountATM: ").append(toIndentedString(totalAmountATM)).append("\n"); - sb.append(" totalFeeATM: ").append(toIndentedString(totalFeeATM)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java deleted file mode 100644 index 5f1ddb35ea..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class BlockchainInfo extends BaseResponse { - private String chainid = null; private Long height = null; private String genesisAccount = null; private String genesisBlockId = null; private Long genesisBlockTimestamp = null; private String ecBlockId = null; private Long ecBlockHeight = null; private Long txTimestamp = null; private Long timestamp = null; - - /** - **/ - - @Schema(example = "a2e9b946290b48b69985dc2e5a5860a1", description = "") - @JsonProperty("chainid") - public String getChainid() { - return chainid; - } - public void setChainid(String chainid) { - this.chainid = chainid; - } - - /** - **/ - - @Schema(example = "4789567", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - **/ - - @Schema(example = "90001259ec21d31a30898d7", description = "") - @JsonProperty("genesisAccount") - public String getGenesisAccount() { - return genesisAccount; - } - public void setGenesisAccount(String genesisAccount) { - this.genesisAccount = genesisAccount; - } - - /** - * Genesis block ID - **/ - - @Schema(example = "15856251679437054149169000", description = "Genesis block ID") - @JsonProperty("genesisBlockId") - public String getGenesisBlockId() { - return genesisBlockId; - } - public void setGenesisBlockId(String genesisBlockId) { - this.genesisBlockId = genesisBlockId; - } - - /** - * Genesis block timestamp (epoch beginning), Unix timestamp in milliseconds - **/ - - @Schema(example = "1491696372000", description = "Genesis block timestamp (epoch beginning), Unix timestamp in milliseconds") - @JsonProperty("genesisBlockTimestamp") - public Long getGenesisBlockTimestamp() { - return genesisBlockTimestamp; - } - public void setGenesisBlockTimestamp(Long genesisBlockTimestamp) { - this.genesisBlockTimestamp = genesisBlockTimestamp; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * Request timestamp in seconds since the genesis block - **/ - - @Schema(example = "1591696371", description = "Request timestamp in seconds since the genesis block") - @JsonProperty("txTimestamp") - public Long getTxTimestamp() { - return txTimestamp; - } - public void setTxTimestamp(Long txTimestamp) { - this.txTimestamp = txTimestamp; - } - - /** - * Request timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372300", description = "Request timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BlockchainInfo blockchainInfo = (BlockchainInfo) o; - return Objects.equals(chainid, blockchainInfo.chainid) && - Objects.equals(height, blockchainInfo.height) && - Objects.equals(genesisAccount, blockchainInfo.genesisAccount) && - Objects.equals(genesisBlockId, blockchainInfo.genesisBlockId) && - Objects.equals(genesisBlockTimestamp, blockchainInfo.genesisBlockTimestamp) && - Objects.equals(ecBlockId, blockchainInfo.ecBlockId) && - Objects.equals(ecBlockHeight, blockchainInfo.ecBlockHeight) && - Objects.equals(txTimestamp, blockchainInfo.txTimestamp) && - Objects.equals(timestamp, blockchainInfo.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash(chainid, height, genesisAccount, genesisBlockId, genesisBlockTimestamp, ecBlockId, ecBlockHeight, txTimestamp, timestamp); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BlockchainInfo {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" chainid: ").append(toIndentedString(chainid)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" genesisAccount: ").append(toIndentedString(genesisAccount)).append("\n"); - sb.append(" genesisBlockId: ").append(toIndentedString(genesisBlockId)).append("\n"); - sb.append(" genesisBlockTimestamp: ").append(toIndentedString(genesisBlockTimestamp)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" txTimestamp: ").append(toIndentedString(txTimestamp)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java deleted file mode 100644 index a9111ea71c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class CountResponse extends BaseResponse { - private Long count = null; - - /** - **/ - - @Schema(example = "345", description = "") - @JsonProperty("count") - public Long getCount() { - return count; - } - public void setCount(Long count) { - this.count = count; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CountResponse countResponse = (CountResponse) o; - return Objects.equals(count, countResponse.count); - } - - @Override - public int hashCode() { - return Objects.hash(count); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CountResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java deleted file mode 100644 index 18eac051ef..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class CreateChildAccountResp extends BaseResponse { - private String parent = null; private String tx = null; - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * Unsigned transaction data - **/ - - @Schema(example = "001047857c04a00539dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152eef5365f2400292d00ca9a3b0000000000c2eb0b000000000000000000000000000000000000000000000000000000000000000000000000920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d5600000000f1da1300fe7062e6fb2fbb37", required = true, description = "Unsigned transaction data") - @JsonProperty("tx") - @NotNull - public String getTx() { - return tx; - } - public void setTx(String tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CreateChildAccountResp createChildAccountResp = (CreateChildAccountResp) o; - return Objects.equals(parent, createChildAccountResp.parent) && - Objects.equals(tx, createChildAccountResp.tx); - } - - @Override - public int hashCode() { - return Objects.hash(parent, tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CreateChildAccountResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java deleted file mode 100644 index b80ee24f93..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class HealthResponse extends BaseResponse { - private Integer blockchainHeight = null; private Integer dbConnectionTotal = null; private Integer dbConnectionActive = null; private Integer dbConnectionIdle = null; private Integer unconfirmedTxCacheSize = null; private Integer maxUnconfirmedTxCount = null; private Boolean isTrimActive = null; - - /** - * Current height of blockchain - **/ - - @Schema(example = "9900345", description = "Current height of blockchain") - @JsonProperty("blockchainHeight") - public Integer getBlockchainHeight() { - return blockchainHeight; - } - public void setBlockchainHeight(Integer blockchainHeight) { - this.blockchainHeight = blockchainHeight; - } - - /** - * Total connections in the pool - **/ - - @Schema(description = "Total connections in the pool") - @JsonProperty("dbConnectionTotal") - public Integer getDbConnectionTotal() { - return dbConnectionTotal; - } - public void setDbConnectionTotal(Integer dbConnectionTotal) { - this.dbConnectionTotal = dbConnectionTotal; - } - - /** - * Active connections in the pool - **/ - - @Schema(description = "Active connections in the pool") - @JsonProperty("dbConnectionActive") - public Integer getDbConnectionActive() { - return dbConnectionActive; - } - public void setDbConnectionActive(Integer dbConnectionActive) { - this.dbConnectionActive = dbConnectionActive; - } - - /** - * Idle connections in the pool - **/ - - @Schema(description = "Idle connections in the pool") - @JsonProperty("dbConnectionIdle") - public Integer getDbConnectionIdle() { - return dbConnectionIdle; - } - public void setDbConnectionIdle(Integer dbConnectionIdle) { - this.dbConnectionIdle = dbConnectionIdle; - } - - /** - * The waiting transactions cache size - **/ - - @Schema(description = "The waiting transactions cache size") - @JsonProperty("unconfirmedTxCacheSize") - public Integer getUnconfirmedTxCacheSize() { - return unconfirmedTxCacheSize; - } - public void setUnconfirmedTxCacheSize(Integer unconfirmedTxCacheSize) { - this.unconfirmedTxCacheSize = unconfirmedTxCacheSize; - } - - /** - * The max count of the unconfirmed transactions - **/ - - @Schema(description = "The max count of the unconfirmed transactions") - @JsonProperty("maxUnconfirmedTxCount") - public Integer getMaxUnconfirmedTxCount() { - return maxUnconfirmedTxCount; - } - public void setMaxUnconfirmedTxCount(Integer maxUnconfirmedTxCount) { - this.maxUnconfirmedTxCount = maxUnconfirmedTxCount; - } - - /** - * Returns true if the trimming process is active - **/ - - @Schema(description = "Returns true if the trimming process is active") - @JsonProperty("isTrimActive") - public Boolean isIsTrimActive() { - return isTrimActive; - } - public void setIsTrimActive(Boolean isTrimActive) { - this.isTrimActive = isTrimActive; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HealthResponse healthResponse = (HealthResponse) o; - return Objects.equals(blockchainHeight, healthResponse.blockchainHeight) && - Objects.equals(dbConnectionTotal, healthResponse.dbConnectionTotal) && - Objects.equals(dbConnectionActive, healthResponse.dbConnectionActive) && - Objects.equals(dbConnectionIdle, healthResponse.dbConnectionIdle) && - Objects.equals(unconfirmedTxCacheSize, healthResponse.unconfirmedTxCacheSize) && - Objects.equals(maxUnconfirmedTxCount, healthResponse.maxUnconfirmedTxCount) && - Objects.equals(isTrimActive, healthResponse.isTrimActive); - } - - @Override - public int hashCode() { - return Objects.hash(blockchainHeight, dbConnectionTotal, dbConnectionActive, dbConnectionIdle, unconfirmedTxCacheSize, maxUnconfirmedTxCount, isTrimActive); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class HealthResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" blockchainHeight: ").append(toIndentedString(blockchainHeight)).append("\n"); - sb.append(" dbConnectionTotal: ").append(toIndentedString(dbConnectionTotal)).append("\n"); - sb.append(" dbConnectionActive: ").append(toIndentedString(dbConnectionActive)).append("\n"); - sb.append(" dbConnectionIdle: ").append(toIndentedString(dbConnectionIdle)).append("\n"); - sb.append(" unconfirmedTxCacheSize: ").append(toIndentedString(unconfirmedTxCacheSize)).append("\n"); - sb.append(" maxUnconfirmedTxCount: ").append(toIndentedString(maxUnconfirmedTxCount)).append("\n"); - sb.append(" isTrimActive: ").append(toIndentedString(isTrimActive)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java deleted file mode 100644 index ef411cb145..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class ListResponse extends BaseResponse { - private java.util.List result = new java.util.ArrayList(); - - /** - **/ - - @Schema(description = "") - @JsonProperty("result") - public java.util.List getResult() { - return result; - } - public void setResult(java.util.List result) { - this.result = result; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ListResponse listResponse = (ListResponse) o; - return Objects.equals(result, listResponse.result); - } - - @Override - public int hashCode() { - return Objects.hash(result); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ListResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java deleted file mode 100644 index ba370a18d0..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryCountResult extends BaseResponse { - private Long count = null; private QueryObject query = null; - - /** - **/ - - @Schema(example = "345", description = "") - @JsonProperty("count") - public Long getCount() { - return count; - } - public void setCount(Long count) { - this.count = count; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("query") - public QueryObject getQuery() { - return query; - } - public void setQuery(QueryObject query) { - this.query = query; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryCountResult queryCountResult = (QueryCountResult) o; - return Objects.equals(count, queryCountResult.count) && - Objects.equals(query, queryCountResult.query); - } - - @Override - public int hashCode() { - return Objects.hash(count, query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryCountResult {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java deleted file mode 100644 index f7f8be6783..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryObject { - private Integer type = -1; private java.util.List accounts = new java.util.ArrayList(); private Long first = null; private Long last = null; private Long startTime = null; private Long endTime = null; private Integer page = 1; private Integer perPage = 25; /** - * Gets or Sets orderBy - */ - public enum OrderByEnum { - ASC("asc"), - DESC("desc"); - private String value; - - OrderByEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private OrderByEnum orderBy = OrderByEnum.ASC; - - /** - * The transaction type, it's an optional parameter and can be missed or specified negative value to avoid filtering by that criteria. There are eleven types: PAYMENT = 0; MESSAGING = 1; COLORED_COINS = 2; DIGITAL_GOODS = 3; ACCOUNT_CONTROL = 4; MONETARY_SYSTEM = 5; DATA = 6; SHUFFLING = 7; UPDATE = 8; DEX = 9; CHILD_ACCOUNT = 10; - **/ - - @Schema(example = "0", description = "The transaction type, it's an optional parameter and can be missed or specified negative value to avoid filtering by that criteria. There are eleven types: PAYMENT = 0; MESSAGING = 1; COLORED_COINS = 2; DIGITAL_GOODS = 3; ACCOUNT_CONTROL = 4; MONETARY_SYSTEM = 5; DATA = 6; SHUFFLING = 7; UPDATE = 8; DEX = 9; CHILD_ACCOUNT = 10; ") - @JsonProperty("type") - public Integer getType() { - return type; - } - public void setType(Integer type) { - this.type = type; - } - - /** - * Exactly all items. - **/ - - @Schema(description = "Exactly all items.") - @JsonProperty("accounts") - public java.util.List getAccounts() { - return accounts; - } - public void setAccounts(java.util.List accounts) { - this.accounts = accounts; - } - - /** - * The first block height - **/ - - @Schema(example = "4000123", description = "The first block height") - @JsonProperty("first") - public Long getFirst() { - return first; - } - public void setFirst(Long first) { - this.first = first; - } - - /** - * The last block height - **/ - - @Schema(example = "4999000", description = "The last block height") - @JsonProperty("last") - public Long getLast() { - return last; - } - public void setLast(Long last) { - this.last = last; - } - - /** - * The start of the time period, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696310000", description = "The start of the time period, Unix timestamp in milliseconds") - @JsonProperty("startTime") - public Long getStartTime() { - return startTime; - } - public void setStartTime(Long startTime) { - this.startTime = startTime; - } - - /** - * The end of the time period, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "The end of the time period, Unix timestamp in milliseconds") - @JsonProperty("endTime") - public Long getEndTime() { - return endTime; - } - public void setEndTime(Long endTime) { - this.endTime = endTime; - } - - /** - * page number (1-based) - **/ - - @Schema(example = "1", description = "page number (1-based)") - @JsonProperty("page") - public Integer getPage() { - return page; - } - public void setPage(Integer page) { - this.page = page; - } - - /** - * Number of entries per page (max=100) - **/ - - @Schema(example = "25", description = "Number of entries per page (max=100)") - @JsonProperty("perPage") - public Integer getPerPage() { - return perPage; - } - public void setPerPage(Integer perPage) { - this.perPage = perPage; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("orderBy") - public OrderByEnum getOrderBy() { - return orderBy; - } - public void setOrderBy(OrderByEnum orderBy) { - this.orderBy = orderBy; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryObject queryObject = (QueryObject) o; - return Objects.equals(type, queryObject.type) && - Objects.equals(accounts, queryObject.accounts) && - Objects.equals(first, queryObject.first) && - Objects.equals(last, queryObject.last) && - Objects.equals(startTime, queryObject.startTime) && - Objects.equals(endTime, queryObject.endTime) && - Objects.equals(page, queryObject.page) && - Objects.equals(perPage, queryObject.perPage) && - Objects.equals(orderBy, queryObject.orderBy); - } - - @Override - public int hashCode() { - return Objects.hash(type, accounts, first, last, startTime, endTime, page, perPage, orderBy); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryObject {\n"); - - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" accounts: ").append(toIndentedString(accounts)).append("\n"); - sb.append(" first: ").append(toIndentedString(first)).append("\n"); - sb.append(" last: ").append(toIndentedString(last)).append("\n"); - sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); - sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); - sb.append(" page: ").append(toIndentedString(page)).append("\n"); - sb.append(" perPage: ").append(toIndentedString(perPage)).append("\n"); - sb.append(" orderBy: ").append(toIndentedString(orderBy)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java deleted file mode 100644 index 5d2268c83c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryResult extends BaseResponse { - private Integer count = null; private java.util.List result = new java.util.ArrayList(); private QueryObject query = null; - - /** - * Count of result items - **/ - - @Schema(example = "345", description = "Count of result items") - @JsonProperty("count") - public Integer getCount() { - return count; - } - public void setCount(Integer count) { - this.count = count; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("result") - public java.util.List getResult() { - return result; - } - public void setResult(java.util.List result) { - this.result = result; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("query") - public QueryObject getQuery() { - return query; - } - public void setQuery(QueryObject query) { - this.query = query; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryResult queryResult = (QueryResult) o; - return Objects.equals(count, queryResult.count) && - Objects.equals(result, queryResult.result) && - Objects.equals(query, queryResult.query); - } - - @Override - public int hashCode() { - return Objects.hash(count, result, query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryResult {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java deleted file mode 100644 index 61541612a9..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java +++ /dev/null @@ -1,410 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfo { - private String id = null; private String type = null; private String subtype = null; private Boolean phased = null; private Long timestamp = null; private Integer deadline = null; private String senderPublicKey = null; private String recipient = null; private String amount = null; private String fee = null; private String referencedTransactionFullHash = null; private String signature = null; private String signatureHash = null; private String fullHash = null; private java.util.Map attachment = new java.util.HashMap(); private String sender = null; private Long height = null; private String version = null; private String ecBlockId = null; private Long ecBlockHeight = null; private String block = null; private Integer confirmations = null; private Long blockTimestamp = null; private Integer index = null; - - /** - * The transaction ID - **/ - - @Schema(example = "1a0feb1306043151604016701", description = "The transaction ID") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - * Transaction type - **/ - - @Schema(example = "2", description = "Transaction type") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - * Transaction subtype - **/ - - @Schema(example = "1", description = "Transaction subtype") - @JsonProperty("subtype") - public String getSubtype() { - return subtype; - } - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - /** - * is true if the transaction is phased - **/ - - @Schema(example = "false", description = "is true if the transaction is phased") - @JsonProperty("phased") - public Boolean isPhased() { - return phased; - } - public void setPhased(Boolean phased) { - this.phased = phased; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - * the deadline for the transaction to be confirmed in minutes,ex.1440=24h - **/ - - @Schema(example = "1440", description = "the deadline for the transaction to be confirmed in minutes,ex.1440=24h") - @JsonProperty("deadline") - public Integer getDeadline() { - return deadline; - } - public void setDeadline(Integer deadline) { - this.deadline = deadline; - } - - /** - * The public key of the sending account for the transaction - **/ - - @Schema(description = "The public key of the sending account for the transaction") - @JsonProperty("senderPublicKey") - public String getSenderPublicKey() { - return senderPublicKey; - } - public void setSenderPublicKey(String senderPublicKey) { - this.senderPublicKey = senderPublicKey; - } - - /** - * The account Id of the recipient - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "The account Id of the recipient") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * The amount of the transaction - **/ - - @Schema(example = "34500000000", description = "The amount of the transaction") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - * The fee of the transaction - **/ - - @Schema(example = "200000000", description = "The fee of the transaction") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - * The full hash of a transaction referenced by this one - **/ - - @Schema(example = "5424ca4dd976a873839c7d5c9952fa15ae619f678365e8ebbc73f967142eb40d", description = "The full hash of a transaction referenced by this one") - @JsonProperty("referencedTransactionFullHash") - public String getReferencedTransactionFullHash() { - return referencedTransactionFullHash; - } - public void setReferencedTransactionFullHash(String referencedTransactionFullHash) { - this.referencedTransactionFullHash = referencedTransactionFullHash; - } - - /** - * The digital signature of the transaction - **/ - - @Schema(example = "920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d56", description = "The digital signature of the transaction") - @JsonProperty("signature") - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * SHA-256 hash of the transaction signature - **/ - - @Schema(example = "2fc1883e9b76fdc67fabee0a3def5f4b7fc2de9cd65bc8bb6d39eaf5e99498d8", description = "SHA-256 hash of the transaction signature") - @JsonProperty("signatureHash") - public String getSignatureHash() { - return signatureHash; - } - public void setSignatureHash(String signatureHash) { - this.signatureHash = signatureHash; - } - - /** - * The full hash of the transaction - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "The full hash of the transaction") - @JsonProperty("fullHash") - public String getFullHash() { - return fullHash; - } - public void setFullHash(String fullHash) { - this.fullHash = fullHash; - } - - /** - * An object containong any additional data needed for the transaction - **/ - - @Schema(description = "An object containong any additional data needed for the transaction") - @JsonProperty("attachment") - public java.util.Map getAttachment() { - return attachment; - } - public void setAttachment(java.util.Map attachment) { - this.attachment = attachment; - } - - /** - * The sender account - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", description = "The sender account") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * The height of the block in the blockchain - **/ - - @Schema(example = "4365987", description = "The height of the block in the blockchain") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * The transaction version number - **/ - - @Schema(example = "1", description = "The transaction version number") - @JsonProperty("version") - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * The block id - **/ - - @Schema(example = "230aeb0f4585625167943", description = "The block id") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * the number of transaction confirmations - **/ - - @Schema(example = "387", description = "the number of transaction confirmations") - @JsonProperty("confirmations") - public Integer getConfirmations() { - return confirmations; - } - public void setConfirmations(Integer confirmations) { - this.confirmations = confirmations; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfo transactionInfo = (TransactionInfo) o; - return Objects.equals(id, transactionInfo.id) && - Objects.equals(type, transactionInfo.type) && - Objects.equals(subtype, transactionInfo.subtype) && - Objects.equals(phased, transactionInfo.phased) && - Objects.equals(timestamp, transactionInfo.timestamp) && - Objects.equals(deadline, transactionInfo.deadline) && - Objects.equals(senderPublicKey, transactionInfo.senderPublicKey) && - Objects.equals(recipient, transactionInfo.recipient) && - Objects.equals(amount, transactionInfo.amount) && - Objects.equals(fee, transactionInfo.fee) && - Objects.equals(referencedTransactionFullHash, transactionInfo.referencedTransactionFullHash) && - Objects.equals(signature, transactionInfo.signature) && - Objects.equals(signatureHash, transactionInfo.signatureHash) && - Objects.equals(fullHash, transactionInfo.fullHash) && - Objects.equals(attachment, transactionInfo.attachment) && - Objects.equals(sender, transactionInfo.sender) && - Objects.equals(height, transactionInfo.height) && - Objects.equals(version, transactionInfo.version) && - Objects.equals(ecBlockId, transactionInfo.ecBlockId) && - Objects.equals(ecBlockHeight, transactionInfo.ecBlockHeight) && - Objects.equals(block, transactionInfo.block) && - Objects.equals(confirmations, transactionInfo.confirmations) && - Objects.equals(blockTimestamp, transactionInfo.blockTimestamp) && - Objects.equals(index, transactionInfo.index); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, subtype, phased, timestamp, deadline, senderPublicKey, recipient, amount, fee, referencedTransactionFullHash, signature, signatureHash, fullHash, attachment, sender, height, version, ecBlockId, ecBlockHeight, block, confirmations, blockTimestamp, index); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfo {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); - sb.append(" phased: ").append(toIndentedString(phased)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" deadline: ").append(toIndentedString(deadline)).append("\n"); - sb.append(" senderPublicKey: ").append(toIndentedString(senderPublicKey)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" referencedTransactionFullHash: ").append(toIndentedString(referencedTransactionFullHash)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" signatureHash: ").append(toIndentedString(signatureHash)).append("\n"); - sb.append(" fullHash: ").append(toIndentedString(fullHash)).append("\n"); - sb.append(" attachment: ").append(toIndentedString(attachment)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java deleted file mode 100644 index 06ced7c633..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfo; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfoArrayResp extends BaseResponse { - private java.util.List tx = new java.util.ArrayList(); - - /** - * The array of transactions - **/ - - @Schema(description = "The array of transactions") - @JsonProperty("tx") - public java.util.List getTx() { - return tx; - } - public void setTx(java.util.List tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfoArrayResp transactionInfoArrayResp = (TransactionInfoArrayResp) o; - return Objects.equals(tx, transactionInfoArrayResp.tx); - } - - @Override - public int hashCode() { - return Objects.hash(tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfoArrayResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java deleted file mode 100644 index efc454140a..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java +++ /dev/null @@ -1,412 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfo; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfoResp extends BaseResponse { - private String id = null; private String type = null; private String subtype = null; private Boolean phased = null; private Long timestamp = null; private Integer deadline = null; private String senderPublicKey = null; private String recipient = null; private String amount = null; private String fee = null; private String referencedTransactionFullHash = null; private String signature = null; private String signatureHash = null; private String fullHash = null; private java.util.Map attachment = new java.util.HashMap(); private String sender = null; private Long height = null; private String version = null; private String ecBlockId = null; private Long ecBlockHeight = null; private String block = null; private Integer confirmations = null; private Long blockTimestamp = null; private Integer index = null; - - /** - * The transaction ID - **/ - - @Schema(example = "1a0feb1306043151604016701", description = "The transaction ID") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - * Transaction type - **/ - - @Schema(example = "2", description = "Transaction type") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - * Transaction subtype - **/ - - @Schema(example = "1", description = "Transaction subtype") - @JsonProperty("subtype") - public String getSubtype() { - return subtype; - } - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - /** - * is true if the transaction is phased - **/ - - @Schema(example = "false", description = "is true if the transaction is phased") - @JsonProperty("phased") - public Boolean isPhased() { - return phased; - } - public void setPhased(Boolean phased) { - this.phased = phased; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - * the deadline for the transaction to be confirmed in minutes,ex.1440=24h - **/ - - @Schema(example = "1440", description = "the deadline for the transaction to be confirmed in minutes,ex.1440=24h") - @JsonProperty("deadline") - public Integer getDeadline() { - return deadline; - } - public void setDeadline(Integer deadline) { - this.deadline = deadline; - } - - /** - * The public key of the sending account for the transaction - **/ - - @Schema(description = "The public key of the sending account for the transaction") - @JsonProperty("senderPublicKey") - public String getSenderPublicKey() { - return senderPublicKey; - } - public void setSenderPublicKey(String senderPublicKey) { - this.senderPublicKey = senderPublicKey; - } - - /** - * The account Id of the recipient - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "The account Id of the recipient") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * The amount of the transaction - **/ - - @Schema(example = "34500000000", description = "The amount of the transaction") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - * The fee of the transaction - **/ - - @Schema(example = "200000000", description = "The fee of the transaction") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - * The full hash of a transaction referenced by this one - **/ - - @Schema(example = "5424ca4dd976a873839c7d5c9952fa15ae619f678365e8ebbc73f967142eb40d", description = "The full hash of a transaction referenced by this one") - @JsonProperty("referencedTransactionFullHash") - public String getReferencedTransactionFullHash() { - return referencedTransactionFullHash; - } - public void setReferencedTransactionFullHash(String referencedTransactionFullHash) { - this.referencedTransactionFullHash = referencedTransactionFullHash; - } - - /** - * The digital signature of the transaction - **/ - - @Schema(example = "920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d56", description = "The digital signature of the transaction") - @JsonProperty("signature") - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * SHA-256 hash of the transaction signature - **/ - - @Schema(example = "2fc1883e9b76fdc67fabee0a3def5f4b7fc2de9cd65bc8bb6d39eaf5e99498d8", description = "SHA-256 hash of the transaction signature") - @JsonProperty("signatureHash") - public String getSignatureHash() { - return signatureHash; - } - public void setSignatureHash(String signatureHash) { - this.signatureHash = signatureHash; - } - - /** - * The full hash of the transaction - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "The full hash of the transaction") - @JsonProperty("fullHash") - public String getFullHash() { - return fullHash; - } - public void setFullHash(String fullHash) { - this.fullHash = fullHash; - } - - /** - * An object containong any additional data needed for the transaction - **/ - - @Schema(description = "An object containong any additional data needed for the transaction") - @JsonProperty("attachment") - public java.util.Map getAttachment() { - return attachment; - } - public void setAttachment(java.util.Map attachment) { - this.attachment = attachment; - } - - /** - * The sender account - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", description = "The sender account") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * The height of the block in the blockchain - **/ - - @Schema(example = "4365987", description = "The height of the block in the blockchain") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * The transaction version number - **/ - - @Schema(example = "1", description = "The transaction version number") - @JsonProperty("version") - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * The block id - **/ - - @Schema(example = "230aeb0f4585625167943", description = "The block id") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * the number of transaction confirmations - **/ - - @Schema(example = "387", description = "the number of transaction confirmations") - @JsonProperty("confirmations") - public Integer getConfirmations() { - return confirmations; - } - public void setConfirmations(Integer confirmations) { - this.confirmations = confirmations; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfoResp transactionInfoResp = (TransactionInfoResp) o; - return Objects.equals(id, transactionInfoResp.id) && - Objects.equals(type, transactionInfoResp.type) && - Objects.equals(subtype, transactionInfoResp.subtype) && - Objects.equals(phased, transactionInfoResp.phased) && - Objects.equals(timestamp, transactionInfoResp.timestamp) && - Objects.equals(deadline, transactionInfoResp.deadline) && - Objects.equals(senderPublicKey, transactionInfoResp.senderPublicKey) && - Objects.equals(recipient, transactionInfoResp.recipient) && - Objects.equals(amount, transactionInfoResp.amount) && - Objects.equals(fee, transactionInfoResp.fee) && - Objects.equals(referencedTransactionFullHash, transactionInfoResp.referencedTransactionFullHash) && - Objects.equals(signature, transactionInfoResp.signature) && - Objects.equals(signatureHash, transactionInfoResp.signatureHash) && - Objects.equals(fullHash, transactionInfoResp.fullHash) && - Objects.equals(attachment, transactionInfoResp.attachment) && - Objects.equals(sender, transactionInfoResp.sender) && - Objects.equals(height, transactionInfoResp.height) && - Objects.equals(version, transactionInfoResp.version) && - Objects.equals(ecBlockId, transactionInfoResp.ecBlockId) && - Objects.equals(ecBlockHeight, transactionInfoResp.ecBlockHeight) && - Objects.equals(block, transactionInfoResp.block) && - Objects.equals(confirmations, transactionInfoResp.confirmations) && - Objects.equals(blockTimestamp, transactionInfoResp.blockTimestamp) && - Objects.equals(index, transactionInfoResp.index); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, subtype, phased, timestamp, deadline, senderPublicKey, recipient, amount, fee, referencedTransactionFullHash, signature, signatureHash, fullHash, attachment, sender, height, version, ecBlockId, ecBlockHeight, block, confirmations, blockTimestamp, index); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfoResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); - sb.append(" phased: ").append(toIndentedString(phased)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" deadline: ").append(toIndentedString(deadline)).append("\n"); - sb.append(" senderPublicKey: ").append(toIndentedString(senderPublicKey)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" referencedTransactionFullHash: ").append(toIndentedString(referencedTransactionFullHash)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" signatureHash: ").append(toIndentedString(signatureHash)).append("\n"); - sb.append(" fullHash: ").append(toIndentedString(fullHash)).append("\n"); - sb.append(" attachment: ").append(toIndentedString(attachment)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java deleted file mode 100644 index 0832bd162c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java +++ /dev/null @@ -1,279 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description="Transaction receipt") -public class TxReceipt extends BaseResponse { - private String transaction = null; private String sender = null; private String recipient = null; private String signature = null; private Long timestamp = null; private String amount = null; private String fee = null; private String payload = null; /** - * The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. - */ - public enum StatusEnum { - UNCONFIRMED("unconfirmed"), - CONFIRMED("confirmed"), - IRREVERSIBLE("irreversible"), - PERMANENT("permanent"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; private String block = null; private Long blockTimestamp = null; private Long height = null; private Integer index = null; private Long confirmations = null; - - /** - **/ - - @Schema(example = "8330faaeb404178613417", required = true, description = "") - @JsonProperty("transaction") - @NotNull - public String getTransaction() { - return transaction; - } - public void setTransaction(String transaction) { - this.transaction = transaction; - } - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("sender") - @NotNull - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", required = true, description = "") - @JsonProperty("recipient") - @NotNull - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - **/ - - @Schema(example = "B98CB1890E76C772A10994B210ED9CF7F9A5488672A5D82C2734BBF9D11505D1", required = true, description = "") - @JsonProperty("signature") - @NotNull - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - **/ - - @Schema(example = "34500000000", description = "") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - **/ - - @Schema(example = "0", description = "") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - **/ - - @Schema(example = "{\"transaction\":\"1234567890\", \"amount\":\"1234567890.12\"}", description = "") - @JsonProperty("payload") - public String getPayload() { - return payload; - } - public void setPayload(String payload) { - this.payload = payload; - } - - /** - * The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. - **/ - - @Schema(example = "unconfirmed", description = "The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. ") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * The Id of the block containing the confirmed transaction - **/ - - @Schema(example = "40faaeb1585625167943", description = "The Id of the block containing the confirmed transaction") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - **/ - - @Schema(example = "15623658", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - /** - * the amount of block transaction - **/ - - @Schema(example = "1758", description = "the amount of block transaction") - @JsonProperty("confirmations") - public Long getConfirmations() { - return confirmations; - } - public void setConfirmations(Long confirmations) { - this.confirmations = confirmations; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TxReceipt txReceipt = (TxReceipt) o; - return Objects.equals(transaction, txReceipt.transaction) && - Objects.equals(sender, txReceipt.sender) && - Objects.equals(recipient, txReceipt.recipient) && - Objects.equals(signature, txReceipt.signature) && - Objects.equals(timestamp, txReceipt.timestamp) && - Objects.equals(amount, txReceipt.amount) && - Objects.equals(fee, txReceipt.fee) && - Objects.equals(payload, txReceipt.payload) && - Objects.equals(status, txReceipt.status) && - Objects.equals(block, txReceipt.block) && - Objects.equals(blockTimestamp, txReceipt.blockTimestamp) && - Objects.equals(height, txReceipt.height) && - Objects.equals(index, txReceipt.index) && - Objects.equals(confirmations, txReceipt.confirmations); - } - - @Override - public int hashCode() { - return Objects.hash(transaction, sender, recipient, signature, timestamp, amount, fee, payload, status, block, blockTimestamp, height, index, confirmations); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TxReceipt {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" transaction: ").append(toIndentedString(transaction)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" payload: ").append(toIndentedString(payload)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java deleted file mode 100644 index 91cdf2cad7..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TxRequest { - private String tx = null; - - /** - * Signed transaction data - **/ - - @Schema(example = "001047857c04a00539dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152eef5365f2400292d00ca9a3b0000000000c2eb0b000000000000000000000000000000000000000000000000000000000000000000000000920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d5600000000f1da1300fe7062e6fb2fbb37", required = true, description = "Signed transaction data") - @JsonProperty("tx") - @NotNull - public String getTx() { - return tx; - } - public void setTx(String tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TxRequest txRequest = (TxRequest) o; - return Objects.equals(tx, txRequest.tx); - } - - @Override - public int hashCode() { - return Objects.hash(tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TxRequest {\n"); - - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} From 7dff9704dbbc5b3fc50c1f7431faf547ed69b3a7 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 31 Aug 2020 13:39:17 +0300 Subject: [PATCH 05/42] delete of generated classes --- .../aplwallet/api/v2/AccountApi.java | 120 ----- .../aplwallet/api/v2/AccountApiService.java | 30 -- .../aplwallet/api/v2/InfoApi.java | 51 --- .../aplwallet/api/v2/InfoApiService.java | 20 - .../aplwallet/api/v2/OperationApi.java | 82 ---- .../aplwallet/api/v2/OperationApiService.java | 24 - .../aplwallet/api/v2/StateApi.java | 149 ------- .../aplwallet/api/v2/StateApiService.java | 36 -- .../aplwallet/api/v2/TransactionApi.java | 94 ---- .../api/v2/TransactionApiService.java | 27 -- .../aplwallet/api/v2/model/AccountInfo.java | 156 ------- .../api/v2/model/AccountInfoResp.java | 158 ------- .../aplwallet/api/v2/model/AccountReq.java | 81 ---- .../api/v2/model/AccountReqSendMoney.java | 141 ------ .../api/v2/model/AccountReqTest.java | 96 ---- .../aplwallet/api/v2/model/BlockInfo.java | 323 -------------- .../api/v2/model/BlockchainInfo.java | 183 -------- .../aplwallet/api/v2/model/CountResponse.java | 65 --- .../api/v2/model/CreateChildAccountResp.java | 83 ---- .../api/v2/model/HealthResponse.java | 156 ------- .../aplwallet/api/v2/model/ListResponse.java | 65 --- .../api/v2/model/QueryCountResult.java | 80 ---- .../aplwallet/api/v2/model/QueryObject.java | 203 --------- .../aplwallet/api/v2/model/QueryResult.java | 96 ---- .../api/v2/model/TransactionInfo.java | 410 ----------------- .../v2/model/TransactionInfoArrayResp.java | 67 --- .../api/v2/model/TransactionInfoResp.java | 412 ------------------ .../aplwallet/api/v2/model/TxReceipt.java | 279 ------------ .../aplwallet/api/v2/model/TxRequest.java | 66 --- 29 files changed, 3753 deletions(-) delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java delete mode 100644 apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java deleted file mode 100644 index 900b165785..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApi.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.AccountApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.AccountInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.AccountReq; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqSendMoney; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqTest; -import com.apollocurrency.aplwallet.api.v2.model.CreateChildAccountResp; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/account") - - -public class AccountApi { - - @Inject AccountApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns unsigned CreateChildAccount transaction for creating child accounts", description = "Returns unsigned CreateChildAccount transaction as a byte array. The list of child public keys is attached in the transaction appendix. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTx(@Parameter(description = "the parent account and the list of public keys" ,required=true) AccountReq body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTx(body,securityContext); - } - @POST - @Path("/money") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns signed SendMoney transaction from child account", description = "Returns signed SendMoney transaction as a byte array. This transaction is a multi-signature signed tx. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTxSendMony(@Parameter(description = "the parent account, child account and other" ,required=true) AccountReqSendMoney body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTxSendMony(body,securityContext); - } - @POST - @Path("/test") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns signed CreateChildAccount transaction for creating child accounts", description = "Returns signed CreateChildAccount transaction as a byte array. The list of child public keys is attached in the transaction appendix. ", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CreateChildAccountResp.class))), - - @ApiResponse(responseCode = "401", description = "Unauthorized Error"), - - @ApiResponse(responseCode = "403", description = "Access Forbidden"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response createChildAccountTxTest(@Parameter(description = "the parent account and the list of public keys" ,required=true) AccountReqTest body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.createChildAccountTxTest(body,securityContext); - } - @GET - @Path("/{account}") - - @Produces({ "application/json" }) - @Operation(summary = "Returns the details account information", description = "", tags={ "account" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = AccountInfoResp.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getAccountInfo( @PathParam("account") String account,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getAccountInfo(account,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java deleted file mode 100644 index 03ab1d601e..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/AccountApiService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.AccountInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.AccountReq; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqSendMoney; -import com.apollocurrency.aplwallet.api.v2.model.AccountReqTest; -import com.apollocurrency.aplwallet.api.v2.model.CreateChildAccountResp; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface AccountApiService { - Response createChildAccountTx(AccountReq body,SecurityContext securityContext) - throws NotFoundException; - Response createChildAccountTxSendMony(AccountReqSendMoney body,SecurityContext securityContext) - throws NotFoundException; - Response createChildAccountTxTest(AccountReqTest body,SecurityContext securityContext) - throws NotFoundException; - Response getAccountInfo(String account,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java deleted file mode 100644 index 44c0b0e283..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApi.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.InfoApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.HealthResponse; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/info") - - -public class InfoApi { - - @Inject InfoApiService service; - - @GET - @Path("/health") - - @Produces({ "application/json" }) - @Operation(summary = "Gets node health", description = "", tags={ "info" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = HealthResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getHealthInfo(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getHealthInfo(securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java deleted file mode 100644 index e9d204e1f2..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/InfoApiService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.HealthResponse; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface InfoApiService { - Response getHealthInfo(SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java deleted file mode 100644 index 8de23b2460..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApi.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.OperationApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryCountResult; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.QueryResult; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/operation") - - -public class OperationApi { - - @Inject OperationApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns the operation list corresponding the query object group by account", description = "", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "operations" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = QueryResult.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getOperations(@Parameter(description = "the query object" ,required=true) QueryObject body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getOperations(body,securityContext); - } - @POST - @Path("/count") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Returns the count of operations corresponding the query object group by account", description = "", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "operations" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = QueryCountResult.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getOperationsCount(@Parameter(description = "the query object" ,required=true) QueryObject body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getOperationsCount(body,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java deleted file mode 100644 index 408487a37a..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/OperationApiService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryCountResult; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.QueryResult; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface OperationApiService { - Response getOperations(QueryObject body,SecurityContext securityContext) - throws NotFoundException; - Response getOperationsCount(QueryObject body,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java deleted file mode 100644 index 84184452e6..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApi.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.StateApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.BlockInfo; -import com.apollocurrency.aplwallet.api.v2.model.BlockchainInfo; -import com.apollocurrency.aplwallet.api.v2.model.CountResponse; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoArrayResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/state") - - -public class StateApi { - - @Inject StateApiService service; - - @GET - @Path("/block") - - @Produces({ "application/json" }) - @Operation(summary = "Get block object", description = "Return details information about the block given block height. If no height is provided, it will fetch the latest block.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockInfo.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockByHeight( @DefaultValue("-1") @QueryParam("height") String height,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockByHeight(height,securityContext); - } - @GET - @Path("/block/{block}") - - @Produces({ "application/json" }) - @Operation(summary = "Get block object given block id", description = "Return the detail information about block given id", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockInfo.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockById( @PathParam("block") String block,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockById(block,securityContext); - } - @GET - @Path("/blockchain") - - @Produces({ "application/json" }) - @Operation(summary = "Get blockchain object", description = "Return details information about the blockchain", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = BlockchainInfo.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getBlockchainInfo(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getBlockchainInfo(securityContext); - } - @GET - @Path("/tx/{transaction}") - - @Produces({ "application/json" }) - @Operation(summary = "Get transaction receipt given transaction id.", description = "Return the brief information about transaction given id.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TxReceipt.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxReceiptById( @PathParam("transaction") String transaction,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxReceiptById(transaction,securityContext); - } - @POST - @Path("/tx") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Get transaction receipt list given list of the transaction id.", description = "Return the list of the brief information about transactions.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = TxReceipt.class)))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxReceiptList(@Parameter(description = "the list of transaction id" ,required=true) java.util.List body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxReceiptList(body,securityContext); - } - @GET - @Path("/unconfirmed") - - @Produces({ "application/json" }) - @Operation(summary = "Get list of unconfirmed transaction receipts.", description = "Return the list of the detail information about unconfirmed transactions.", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TransactionInfoArrayResp.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getUnconfirmedTx( @DefaultValue("1") @QueryParam("page") Integer page, @Max(100) @DefaultValue("50") @QueryParam("perPage") Integer perPage,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getUnconfirmedTx(page,perPage,securityContext); - } - @GET - @Path("/unconfirmed/count") - - @Produces({ "application/json" }) - @Operation(summary = "Get count of unconfirmed transaction receipts.", description = "Return the count of unconfirmed transactions.", tags={ "state" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = CountResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getUnconfirmedTxCount(@Context SecurityContext securityContext) - throws NotFoundException { - return service.getUnconfirmedTxCount(securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java deleted file mode 100644 index 1daf73b405..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/StateApiService.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.BlockInfo; -import com.apollocurrency.aplwallet.api.v2.model.BlockchainInfo; -import com.apollocurrency.aplwallet.api.v2.model.CountResponse; -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoArrayResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface StateApiService { - Response getBlockByHeight(String height,SecurityContext securityContext) - throws NotFoundException; - Response getBlockById(String block,SecurityContext securityContext) - throws NotFoundException; - Response getBlockchainInfo(SecurityContext securityContext) - throws NotFoundException; - Response getTxReceiptById(String transaction,SecurityContext securityContext) - throws NotFoundException; - Response getTxReceiptList(java.util.List body,SecurityContext securityContext) - throws NotFoundException; - Response getUnconfirmedTx(Integer page,Integer perPage,SecurityContext securityContext) - throws NotFoundException; - Response getUnconfirmedTxCount(SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java deleted file mode 100644 index e4e9ac9098..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApi.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.model.*; -import com.apollocurrency.aplwallet.api.v2.TransactionApiService; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.ListResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.apollocurrency.aplwallet.api.v2.model.TxRequest; - -import java.util.Map; -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; -import javax.ws.rs.*; -import javax.inject.Inject; - -import javax.validation.constraints.*; -@Path("/v2/transaction") - - -public class TransactionApi { - - @Inject TransactionApiService service; - - @POST - - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Broadcast transaction and return transaction receipt.", description = "Asynchronously broadcast the signed transaction to the network. The transaction is validated and immediately put into an unconfirmed transaction pool for further sending to the blockchain. ", tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TxReceipt.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "409", description = "The request could not be completed due to a conflict with the current state of the resource. The resource is busy and the request might be reissued later. "), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response broadcastTx(@Parameter(description = "the signed transaction is a byte array in hex format" ,required=true) TxRequest body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.broadcastTx(body,securityContext); - } - @POST - @Path("/batch") - @Consumes({ "application/json" }) - @Produces({ "application/json" }) - @Operation(summary = "Broadcast a batch of transactions and return the transaction receipt list.", description = "Asynchronously broadcast the batch of the signed transaction to the network. The transactions are immediately put into an unconfirmed transaction pool in the same order as in the batch and later are sending to the network.", security = { - @SecurityRequirement(name = "bearerAuth") - }, tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ListResponse.class))), - - @ApiResponse(responseCode = "401", description = "Not authenticated"), - - @ApiResponse(responseCode = "403", description = "Access token does not have the required scope"), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response broadcastTxBatch(@Parameter(description = "an array of signed transactions, each item is a byte array in hex format" ,required=true) java.util.List body,@Context SecurityContext securityContext) - throws NotFoundException { - return service.broadcastTxBatch(body,securityContext); - } - @GET - @Path("/{transaction}") - - @Produces({ "application/json" }) - @Operation(summary = "Get transaction object given transaction id.", description = "Return the detail information about transaction by id.", tags={ "tx" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = TransactionInfoResp.class))), - - @ApiResponse(responseCode = "400", description = "Bad request - malformed request or wrong parameters", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), - - @ApiResponse(responseCode = "500", description = "Server error - internal server error", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) }) - public Response getTxById( @PathParam("transaction") String transaction,@Context SecurityContext securityContext) - throws NotFoundException { - return service.getTxById(transaction,securityContext); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java deleted file mode 100644 index 99f2cc81a7..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/TransactionApiService.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2; - -import com.apollocurrency.aplwallet.api.v2.*; -import com.apollocurrency.aplwallet.api.v2.model.*; - -import com.apollocurrency.aplwallet.api.v2.model.ErrorResponse; -import com.apollocurrency.aplwallet.api.v2.model.ListResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfoResp; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.apollocurrency.aplwallet.api.v2.model.TxRequest; - -import java.util.List; -import com.apollocurrency.aplwallet.api.v2.NotFoundException; - -import java.io.InputStream; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; - -public interface TransactionApiService { - Response broadcastTx(TxRequest body,SecurityContext securityContext) - throws NotFoundException; - Response broadcastTxBatch(java.util.List body,SecurityContext securityContext) - throws NotFoundException; - Response getTxById(String transaction,SecurityContext securityContext) - throws NotFoundException; -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java deleted file mode 100644 index 1546fd9f86..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfo.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountInfo { - private String account = null; private String publicKey = null; private String parent = null; private String balance = null; private String unconfirmedbalance = null; /** - * Gets or Sets status - */ - public enum StatusEnum { - CREATED("created"), - VERIFIED("verified"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("account") - @NotNull - public String getAccount() { - return account; - } - public void setAccount(String account) { - this.account = account; - } - - /** - * The account public key in a hex string format - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", required = true, description = "The account public key in a hex string format") - @JsonProperty("publicKey") - @NotNull - public String getPublicKey() { - return publicKey; - } - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - /** - **/ - - @Schema(example = "APL-AHYW-P3YX-V426-4UMP2", description = "") - @JsonProperty("parent") - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("balance") - public String getBalance() { - return balance; - } - public void setBalance(String balance) { - this.balance = balance; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("unconfirmedbalance") - public String getUnconfirmedbalance() { - return unconfirmedbalance; - } - public void setUnconfirmedbalance(String unconfirmedbalance) { - this.unconfirmedbalance = unconfirmedbalance; - } - - /** - **/ - - @Schema(example = "created", description = "") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountInfo accountInfo = (AccountInfo) o; - return Objects.equals(account, accountInfo.account) && - Objects.equals(publicKey, accountInfo.publicKey) && - Objects.equals(parent, accountInfo.parent) && - Objects.equals(balance, accountInfo.balance) && - Objects.equals(unconfirmedbalance, accountInfo.unconfirmedbalance) && - Objects.equals(status, accountInfo.status); - } - - @Override - public int hashCode() { - return Objects.hash(account, publicKey, parent, balance, unconfirmedbalance, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountInfo {\n"); - - sb.append(" account: ").append(toIndentedString(account)).append("\n"); - sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" balance: ").append(toIndentedString(balance)).append("\n"); - sb.append(" unconfirmedbalance: ").append(toIndentedString(unconfirmedbalance)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java deleted file mode 100644 index 7ec7e494ad..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountInfoResp.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.AccountInfo; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountInfoResp extends BaseResponse { - private String account = null; private String publicKey = null; private String parent = null; private String balance = null; private String unconfirmedbalance = null; /** - * Gets or Sets status - */ - public enum StatusEnum { - CREATED("created"), - VERIFIED("verified"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("account") - @NotNull - public String getAccount() { - return account; - } - public void setAccount(String account) { - this.account = account; - } - - /** - * The account public key in a hex string format - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", required = true, description = "The account public key in a hex string format") - @JsonProperty("publicKey") - @NotNull - public String getPublicKey() { - return publicKey; - } - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - /** - **/ - - @Schema(example = "APL-AHYW-P3YX-V426-4UMP2", description = "") - @JsonProperty("parent") - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("balance") - public String getBalance() { - return balance; - } - public void setBalance(String balance) { - this.balance = balance; - } - - /** - **/ - - @Schema(example = "45225600000000", description = "") - @JsonProperty("unconfirmedbalance") - public String getUnconfirmedbalance() { - return unconfirmedbalance; - } - public void setUnconfirmedbalance(String unconfirmedbalance) { - this.unconfirmedbalance = unconfirmedbalance; - } - - /** - **/ - - @Schema(example = "created", description = "") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountInfoResp accountInfoResp = (AccountInfoResp) o; - return Objects.equals(account, accountInfoResp.account) && - Objects.equals(publicKey, accountInfoResp.publicKey) && - Objects.equals(parent, accountInfoResp.parent) && - Objects.equals(balance, accountInfoResp.balance) && - Objects.equals(unconfirmedbalance, accountInfoResp.unconfirmedbalance) && - Objects.equals(status, accountInfoResp.status); - } - - @Override - public int hashCode() { - return Objects.hash(account, publicKey, parent, balance, unconfirmedbalance, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountInfoResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" account: ").append(toIndentedString(account)).append("\n"); - sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" balance: ").append(toIndentedString(balance)).append("\n"); - sb.append(" unconfirmedbalance: ").append(toIndentedString(unconfirmedbalance)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java deleted file mode 100644 index e63733e3e8..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReq.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReq { - private String parent = null; private java.util.List childPublicKeyList = new java.util.ArrayList(); - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * list of child account public keys - **/ - - @Schema(description = "list of child account public keys") - @JsonProperty("child_publicKey_list") - @Size(max=128) public java.util.List getChildPublicKeyList() { - return childPublicKeyList; - } - public void setChildPublicKeyList(java.util.List childPublicKeyList) { - this.childPublicKeyList = childPublicKeyList; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReq accountReq = (AccountReq) o; - return Objects.equals(parent, accountReq.parent) && - Objects.equals(childPublicKeyList, accountReq.childPublicKeyList); - } - - @Override - public int hashCode() { - return Objects.hash(parent, childPublicKeyList); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReq {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" childPublicKeyList: ").append(toIndentedString(childPublicKeyList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java deleted file mode 100644 index de61dab31e..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqSendMoney.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReqSendMoney { - private String parent = null; private String psecret = null; private String sender = null; private String csecret = null; private String recipient = null; private Long amount = null; - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * parent account secret phrase - **/ - - @Schema(example = "ParenttopSecretPhrase", description = "parent account secret phrase") - @JsonProperty("psecret") - public String getPsecret() { - return psecret; - } - public void setPsecret(String psecret) { - this.psecret = psecret; - } - - /** - * child account id - **/ - - @Schema(example = "APL-632K-TWX3-2ALQ-973CU", description = "child account id") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * child account secret phrase - **/ - - @Schema(example = "ChildtopSecretPhrase", description = "child account secret phrase") - @JsonProperty("csecret") - public String getCsecret() { - return csecret; - } - public void setCsecret(String csecret) { - this.csecret = csecret; - } - - /** - * recipient account id - **/ - - @Schema(example = "APL-VWMY-APVK-UFHN-3MC7N", description = "recipient account id") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * the amount - **/ - - @Schema(description = "the amount") - @JsonProperty("amount") - public Long getAmount() { - return amount; - } - public void setAmount(Long amount) { - this.amount = amount; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReqSendMoney accountReqSendMoney = (AccountReqSendMoney) o; - return Objects.equals(parent, accountReqSendMoney.parent) && - Objects.equals(psecret, accountReqSendMoney.psecret) && - Objects.equals(sender, accountReqSendMoney.sender) && - Objects.equals(csecret, accountReqSendMoney.csecret) && - Objects.equals(recipient, accountReqSendMoney.recipient) && - Objects.equals(amount, accountReqSendMoney.amount); - } - - @Override - public int hashCode() { - return Objects.hash(parent, psecret, sender, csecret, recipient, amount); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReqSendMoney {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" psecret: ").append(toIndentedString(psecret)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" csecret: ").append(toIndentedString(csecret)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java deleted file mode 100644 index 61e7f8a84b..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/AccountReqTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class AccountReqTest { - private String parent = null; private String secret = null; private java.util.List childSecretList = new java.util.ArrayList(); - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * parent account secret phrase - **/ - - @Schema(example = "topSecretPhrase", description = "parent account secret phrase") - @JsonProperty("secret") - public String getSecret() { - return secret; - } - public void setSecret(String secret) { - this.secret = secret; - } - - /** - * list of child secret phrases - **/ - - @Schema(description = "list of child secret phrases") - @JsonProperty("child_secret_list") - @Size(max=128) public java.util.List getChildSecretList() { - return childSecretList; - } - public void setChildSecretList(java.util.List childSecretList) { - this.childSecretList = childSecretList; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AccountReqTest accountReqTest = (AccountReqTest) o; - return Objects.equals(parent, accountReqTest.parent) && - Objects.equals(secret, accountReqTest.secret) && - Objects.equals(childSecretList, accountReqTest.childSecretList); - } - - @Override - public int hashCode() { - return Objects.hash(parent, secret, childSecretList); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AccountReqTest {\n"); - - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" secret: ").append(toIndentedString(secret)).append("\n"); - sb.append(" childSecretList: ").append(toIndentedString(childSecretList)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java deleted file mode 100644 index 8f0ee0cd16..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockInfo.java +++ /dev/null @@ -1,323 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class BlockInfo extends BaseResponse { - private String id = null; private String blockSignature = null; private Long height = null; private String generator = null; private String generationSignature = null; private String generatorPublicKey = null; private Long timestamp = null; private Integer timeout = null; private Integer version = null; private String baseTarget = null; private String cumulativeDifficulty = null; private String previousBlock = null; private String previousBlockHash = null; private String nextBlock = null; private String payloadHash = null; private Integer payloadLength = null; private Integer numberOfTransactions = null; private String totalAmountATM = null; private String totalFeeATM = null; - - /** - **/ - - @Schema(example = "1130faaeb604315160401", description = "") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - **/ - - @Schema(example = "ff080e64436603df0c3b9a5b792b03a26725a83bbe6aa46eb7eed9ee83707f071b6d529d09be1f2594c6f8545c2772a091896bc808553c1774e39a41248b1e1c", description = "") - @JsonProperty("blockSignature") - public String getBlockSignature() { - return blockSignature; - } - public void setBlockSignature(String blockSignature) { - this.blockSignature = blockSignature; - } - - /** - **/ - - @Schema(example = "1319854", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "") - @JsonProperty("generator") - public String getGenerator() { - return generator; - } - public void setGenerator(String generator) { - this.generator = generator; - } - - /** - **/ - - @Schema(example = "60e598f6276371119720786b05e507cd628665473b24c8f76de436d99cf113f7", description = "") - @JsonProperty("generationSignature") - public String getGenerationSignature() { - return generationSignature; - } - public void setGenerationSignature(String generationSignature) { - this.generationSignature = generationSignature; - } - - /** - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "") - @JsonProperty("generatorPublicKey") - public String getGeneratorPublicKey() { - return generatorPublicKey; - } - public void setGeneratorPublicKey(String generatorPublicKey) { - this.generatorPublicKey = generatorPublicKey; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - **/ - - @Schema(example = "1", description = "") - @JsonProperty("timeout") - public Integer getTimeout() { - return timeout; - } - public void setTimeout(Integer timeout) { - this.timeout = timeout; - } - - /** - * The block version - **/ - - @Schema(example = "6", description = "The block version") - @JsonProperty("version") - public Integer getVersion() { - return version; - } - public void setVersion(Integer version) { - this.version = version; - } - - /** - **/ - - @Schema(example = "7686143350", description = "") - @JsonProperty("baseTarget") - public String getBaseTarget() { - return baseTarget; - } - public void setBaseTarget(String baseTarget) { - this.baseTarget = baseTarget; - } - - /** - **/ - - @Schema(example = "8728234277524822", description = "") - @JsonProperty("cumulativeDifficulty") - public String getCumulativeDifficulty() { - return cumulativeDifficulty; - } - public void setCumulativeDifficulty(String cumulativeDifficulty) { - this.cumulativeDifficulty = cumulativeDifficulty; - } - - /** - * Prev block id - **/ - - @Schema(example = "80faaeb4787337264514", description = "Prev block id") - @JsonProperty("previousBlock") - public String getPreviousBlock() { - return previousBlock; - } - public void setPreviousBlock(String previousBlock) { - this.previousBlock = previousBlock; - } - - /** - **/ - - @Schema(example = "5b8ba14eaebba8cdc682c946947f5352a596d00ac63c4e616785d00cf8b8e016", description = "") - @JsonProperty("previousBlockHash") - public String getPreviousBlockHash() { - return previousBlockHash; - } - public void setPreviousBlockHash(String previousBlockHash) { - this.previousBlockHash = previousBlockHash; - } - - /** - * Next block id - **/ - - @Schema(example = "140faaeb81930093118053", description = "Next block id") - @JsonProperty("nextBlock") - public String getNextBlock() { - return nextBlock; - } - public void setNextBlock(String nextBlock) { - this.nextBlock = nextBlock; - } - - /** - * Hash of the paylod (all transactions) - **/ - - @Schema(example = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", description = "Hash of the paylod (all transactions)") - @JsonProperty("payloadHash") - public String getPayloadHash() { - return payloadHash; - } - public void setPayloadHash(String payloadHash) { - this.payloadHash = payloadHash; - } - - /** - * The length in bytes of all transactions - **/ - - @Schema(example = "523423", description = "The length in bytes of all transactions") - @JsonProperty("payloadLength") - public Integer getPayloadLength() { - return payloadLength; - } - public void setPayloadLength(Integer payloadLength) { - this.payloadLength = payloadLength; - } - - /** - **/ - - @Schema(example = "14", description = "") - @JsonProperty("numberOfTransactions") - public Integer getNumberOfTransactions() { - return numberOfTransactions; - } - public void setNumberOfTransactions(Integer numberOfTransactions) { - this.numberOfTransactions = numberOfTransactions; - } - - /** - **/ - - @Schema(example = "569000000000000", description = "") - @JsonProperty("totalAmountATM") - public String getTotalAmountATM() { - return totalAmountATM; - } - public void setTotalAmountATM(String totalAmountATM) { - this.totalAmountATM = totalAmountATM; - } - - /** - **/ - - @Schema(example = "2800000000", description = "") - @JsonProperty("totalFeeATM") - public String getTotalFeeATM() { - return totalFeeATM; - } - public void setTotalFeeATM(String totalFeeATM) { - this.totalFeeATM = totalFeeATM; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BlockInfo blockInfo = (BlockInfo) o; - return Objects.equals(id, blockInfo.id) && - Objects.equals(blockSignature, blockInfo.blockSignature) && - Objects.equals(height, blockInfo.height) && - Objects.equals(generator, blockInfo.generator) && - Objects.equals(generationSignature, blockInfo.generationSignature) && - Objects.equals(generatorPublicKey, blockInfo.generatorPublicKey) && - Objects.equals(timestamp, blockInfo.timestamp) && - Objects.equals(timeout, blockInfo.timeout) && - Objects.equals(version, blockInfo.version) && - Objects.equals(baseTarget, blockInfo.baseTarget) && - Objects.equals(cumulativeDifficulty, blockInfo.cumulativeDifficulty) && - Objects.equals(previousBlock, blockInfo.previousBlock) && - Objects.equals(previousBlockHash, blockInfo.previousBlockHash) && - Objects.equals(nextBlock, blockInfo.nextBlock) && - Objects.equals(payloadHash, blockInfo.payloadHash) && - Objects.equals(payloadLength, blockInfo.payloadLength) && - Objects.equals(numberOfTransactions, blockInfo.numberOfTransactions) && - Objects.equals(totalAmountATM, blockInfo.totalAmountATM) && - Objects.equals(totalFeeATM, blockInfo.totalFeeATM); - } - - @Override - public int hashCode() { - return Objects.hash(id, blockSignature, height, generator, generationSignature, generatorPublicKey, timestamp, timeout, version, baseTarget, cumulativeDifficulty, previousBlock, previousBlockHash, nextBlock, payloadHash, payloadLength, numberOfTransactions, totalAmountATM, totalFeeATM); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BlockInfo {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" blockSignature: ").append(toIndentedString(blockSignature)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" generator: ").append(toIndentedString(generator)).append("\n"); - sb.append(" generationSignature: ").append(toIndentedString(generationSignature)).append("\n"); - sb.append(" generatorPublicKey: ").append(toIndentedString(generatorPublicKey)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" baseTarget: ").append(toIndentedString(baseTarget)).append("\n"); - sb.append(" cumulativeDifficulty: ").append(toIndentedString(cumulativeDifficulty)).append("\n"); - sb.append(" previousBlock: ").append(toIndentedString(previousBlock)).append("\n"); - sb.append(" previousBlockHash: ").append(toIndentedString(previousBlockHash)).append("\n"); - sb.append(" nextBlock: ").append(toIndentedString(nextBlock)).append("\n"); - sb.append(" payloadHash: ").append(toIndentedString(payloadHash)).append("\n"); - sb.append(" payloadLength: ").append(toIndentedString(payloadLength)).append("\n"); - sb.append(" numberOfTransactions: ").append(toIndentedString(numberOfTransactions)).append("\n"); - sb.append(" totalAmountATM: ").append(toIndentedString(totalAmountATM)).append("\n"); - sb.append(" totalFeeATM: ").append(toIndentedString(totalFeeATM)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java deleted file mode 100644 index 5f1ddb35ea..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/BlockchainInfo.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class BlockchainInfo extends BaseResponse { - private String chainid = null; private Long height = null; private String genesisAccount = null; private String genesisBlockId = null; private Long genesisBlockTimestamp = null; private String ecBlockId = null; private Long ecBlockHeight = null; private Long txTimestamp = null; private Long timestamp = null; - - /** - **/ - - @Schema(example = "a2e9b946290b48b69985dc2e5a5860a1", description = "") - @JsonProperty("chainid") - public String getChainid() { - return chainid; - } - public void setChainid(String chainid) { - this.chainid = chainid; - } - - /** - **/ - - @Schema(example = "4789567", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - **/ - - @Schema(example = "90001259ec21d31a30898d7", description = "") - @JsonProperty("genesisAccount") - public String getGenesisAccount() { - return genesisAccount; - } - public void setGenesisAccount(String genesisAccount) { - this.genesisAccount = genesisAccount; - } - - /** - * Genesis block ID - **/ - - @Schema(example = "15856251679437054149169000", description = "Genesis block ID") - @JsonProperty("genesisBlockId") - public String getGenesisBlockId() { - return genesisBlockId; - } - public void setGenesisBlockId(String genesisBlockId) { - this.genesisBlockId = genesisBlockId; - } - - /** - * Genesis block timestamp (epoch beginning), Unix timestamp in milliseconds - **/ - - @Schema(example = "1491696372000", description = "Genesis block timestamp (epoch beginning), Unix timestamp in milliseconds") - @JsonProperty("genesisBlockTimestamp") - public Long getGenesisBlockTimestamp() { - return genesisBlockTimestamp; - } - public void setGenesisBlockTimestamp(Long genesisBlockTimestamp) { - this.genesisBlockTimestamp = genesisBlockTimestamp; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * Request timestamp in seconds since the genesis block - **/ - - @Schema(example = "1591696371", description = "Request timestamp in seconds since the genesis block") - @JsonProperty("txTimestamp") - public Long getTxTimestamp() { - return txTimestamp; - } - public void setTxTimestamp(Long txTimestamp) { - this.txTimestamp = txTimestamp; - } - - /** - * Request timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372300", description = "Request timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BlockchainInfo blockchainInfo = (BlockchainInfo) o; - return Objects.equals(chainid, blockchainInfo.chainid) && - Objects.equals(height, blockchainInfo.height) && - Objects.equals(genesisAccount, blockchainInfo.genesisAccount) && - Objects.equals(genesisBlockId, blockchainInfo.genesisBlockId) && - Objects.equals(genesisBlockTimestamp, blockchainInfo.genesisBlockTimestamp) && - Objects.equals(ecBlockId, blockchainInfo.ecBlockId) && - Objects.equals(ecBlockHeight, blockchainInfo.ecBlockHeight) && - Objects.equals(txTimestamp, blockchainInfo.txTimestamp) && - Objects.equals(timestamp, blockchainInfo.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash(chainid, height, genesisAccount, genesisBlockId, genesisBlockTimestamp, ecBlockId, ecBlockHeight, txTimestamp, timestamp); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BlockchainInfo {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" chainid: ").append(toIndentedString(chainid)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" genesisAccount: ").append(toIndentedString(genesisAccount)).append("\n"); - sb.append(" genesisBlockId: ").append(toIndentedString(genesisBlockId)).append("\n"); - sb.append(" genesisBlockTimestamp: ").append(toIndentedString(genesisBlockTimestamp)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" txTimestamp: ").append(toIndentedString(txTimestamp)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java deleted file mode 100644 index a9111ea71c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CountResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class CountResponse extends BaseResponse { - private Long count = null; - - /** - **/ - - @Schema(example = "345", description = "") - @JsonProperty("count") - public Long getCount() { - return count; - } - public void setCount(Long count) { - this.count = count; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CountResponse countResponse = (CountResponse) o; - return Objects.equals(count, countResponse.count); - } - - @Override - public int hashCode() { - return Objects.hash(count); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CountResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java deleted file mode 100644 index 18eac051ef..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/CreateChildAccountResp.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class CreateChildAccountResp extends BaseResponse { - private String parent = null; private String tx = null; - - /** - * parent account id - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "parent account id") - @JsonProperty("parent") - @NotNull - public String getParent() { - return parent; - } - public void setParent(String parent) { - this.parent = parent; - } - - /** - * Unsigned transaction data - **/ - - @Schema(example = "001047857c04a00539dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152eef5365f2400292d00ca9a3b0000000000c2eb0b000000000000000000000000000000000000000000000000000000000000000000000000920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d5600000000f1da1300fe7062e6fb2fbb37", required = true, description = "Unsigned transaction data") - @JsonProperty("tx") - @NotNull - public String getTx() { - return tx; - } - public void setTx(String tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CreateChildAccountResp createChildAccountResp = (CreateChildAccountResp) o; - return Objects.equals(parent, createChildAccountResp.parent) && - Objects.equals(tx, createChildAccountResp.tx); - } - - @Override - public int hashCode() { - return Objects.hash(parent, tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class CreateChildAccountResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java deleted file mode 100644 index b80ee24f93..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/HealthResponse.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class HealthResponse extends BaseResponse { - private Integer blockchainHeight = null; private Integer dbConnectionTotal = null; private Integer dbConnectionActive = null; private Integer dbConnectionIdle = null; private Integer unconfirmedTxCacheSize = null; private Integer maxUnconfirmedTxCount = null; private Boolean isTrimActive = null; - - /** - * Current height of blockchain - **/ - - @Schema(example = "9900345", description = "Current height of blockchain") - @JsonProperty("blockchainHeight") - public Integer getBlockchainHeight() { - return blockchainHeight; - } - public void setBlockchainHeight(Integer blockchainHeight) { - this.blockchainHeight = blockchainHeight; - } - - /** - * Total connections in the pool - **/ - - @Schema(description = "Total connections in the pool") - @JsonProperty("dbConnectionTotal") - public Integer getDbConnectionTotal() { - return dbConnectionTotal; - } - public void setDbConnectionTotal(Integer dbConnectionTotal) { - this.dbConnectionTotal = dbConnectionTotal; - } - - /** - * Active connections in the pool - **/ - - @Schema(description = "Active connections in the pool") - @JsonProperty("dbConnectionActive") - public Integer getDbConnectionActive() { - return dbConnectionActive; - } - public void setDbConnectionActive(Integer dbConnectionActive) { - this.dbConnectionActive = dbConnectionActive; - } - - /** - * Idle connections in the pool - **/ - - @Schema(description = "Idle connections in the pool") - @JsonProperty("dbConnectionIdle") - public Integer getDbConnectionIdle() { - return dbConnectionIdle; - } - public void setDbConnectionIdle(Integer dbConnectionIdle) { - this.dbConnectionIdle = dbConnectionIdle; - } - - /** - * The waiting transactions cache size - **/ - - @Schema(description = "The waiting transactions cache size") - @JsonProperty("unconfirmedTxCacheSize") - public Integer getUnconfirmedTxCacheSize() { - return unconfirmedTxCacheSize; - } - public void setUnconfirmedTxCacheSize(Integer unconfirmedTxCacheSize) { - this.unconfirmedTxCacheSize = unconfirmedTxCacheSize; - } - - /** - * The max count of the unconfirmed transactions - **/ - - @Schema(description = "The max count of the unconfirmed transactions") - @JsonProperty("maxUnconfirmedTxCount") - public Integer getMaxUnconfirmedTxCount() { - return maxUnconfirmedTxCount; - } - public void setMaxUnconfirmedTxCount(Integer maxUnconfirmedTxCount) { - this.maxUnconfirmedTxCount = maxUnconfirmedTxCount; - } - - /** - * Returns true if the trimming process is active - **/ - - @Schema(description = "Returns true if the trimming process is active") - @JsonProperty("isTrimActive") - public Boolean isIsTrimActive() { - return isTrimActive; - } - public void setIsTrimActive(Boolean isTrimActive) { - this.isTrimActive = isTrimActive; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - HealthResponse healthResponse = (HealthResponse) o; - return Objects.equals(blockchainHeight, healthResponse.blockchainHeight) && - Objects.equals(dbConnectionTotal, healthResponse.dbConnectionTotal) && - Objects.equals(dbConnectionActive, healthResponse.dbConnectionActive) && - Objects.equals(dbConnectionIdle, healthResponse.dbConnectionIdle) && - Objects.equals(unconfirmedTxCacheSize, healthResponse.unconfirmedTxCacheSize) && - Objects.equals(maxUnconfirmedTxCount, healthResponse.maxUnconfirmedTxCount) && - Objects.equals(isTrimActive, healthResponse.isTrimActive); - } - - @Override - public int hashCode() { - return Objects.hash(blockchainHeight, dbConnectionTotal, dbConnectionActive, dbConnectionIdle, unconfirmedTxCacheSize, maxUnconfirmedTxCount, isTrimActive); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class HealthResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" blockchainHeight: ").append(toIndentedString(blockchainHeight)).append("\n"); - sb.append(" dbConnectionTotal: ").append(toIndentedString(dbConnectionTotal)).append("\n"); - sb.append(" dbConnectionActive: ").append(toIndentedString(dbConnectionActive)).append("\n"); - sb.append(" dbConnectionIdle: ").append(toIndentedString(dbConnectionIdle)).append("\n"); - sb.append(" unconfirmedTxCacheSize: ").append(toIndentedString(unconfirmedTxCacheSize)).append("\n"); - sb.append(" maxUnconfirmedTxCount: ").append(toIndentedString(maxUnconfirmedTxCount)).append("\n"); - sb.append(" isTrimActive: ").append(toIndentedString(isTrimActive)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java deleted file mode 100644 index ef411cb145..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/ListResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class ListResponse extends BaseResponse { - private java.util.List result = new java.util.ArrayList(); - - /** - **/ - - @Schema(description = "") - @JsonProperty("result") - public java.util.List getResult() { - return result; - } - public void setResult(java.util.List result) { - this.result = result; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ListResponse listResponse = (ListResponse) o; - return Objects.equals(result, listResponse.result); - } - - @Override - public int hashCode() { - return Objects.hash(result); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ListResponse {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java deleted file mode 100644 index ba370a18d0..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryCountResult.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryCountResult extends BaseResponse { - private Long count = null; private QueryObject query = null; - - /** - **/ - - @Schema(example = "345", description = "") - @JsonProperty("count") - public Long getCount() { - return count; - } - public void setCount(Long count) { - this.count = count; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("query") - public QueryObject getQuery() { - return query; - } - public void setQuery(QueryObject query) { - this.query = query; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryCountResult queryCountResult = (QueryCountResult) o; - return Objects.equals(count, queryCountResult.count) && - Objects.equals(query, queryCountResult.query); - } - - @Override - public int hashCode() { - return Objects.hash(count, query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryCountResult {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java deleted file mode 100644 index f7f8be6783..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryObject.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryObject { - private Integer type = -1; private java.util.List accounts = new java.util.ArrayList(); private Long first = null; private Long last = null; private Long startTime = null; private Long endTime = null; private Integer page = 1; private Integer perPage = 25; /** - * Gets or Sets orderBy - */ - public enum OrderByEnum { - ASC("asc"), - DESC("desc"); - private String value; - - OrderByEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private OrderByEnum orderBy = OrderByEnum.ASC; - - /** - * The transaction type, it's an optional parameter and can be missed or specified negative value to avoid filtering by that criteria. There are eleven types: PAYMENT = 0; MESSAGING = 1; COLORED_COINS = 2; DIGITAL_GOODS = 3; ACCOUNT_CONTROL = 4; MONETARY_SYSTEM = 5; DATA = 6; SHUFFLING = 7; UPDATE = 8; DEX = 9; CHILD_ACCOUNT = 10; - **/ - - @Schema(example = "0", description = "The transaction type, it's an optional parameter and can be missed or specified negative value to avoid filtering by that criteria. There are eleven types: PAYMENT = 0; MESSAGING = 1; COLORED_COINS = 2; DIGITAL_GOODS = 3; ACCOUNT_CONTROL = 4; MONETARY_SYSTEM = 5; DATA = 6; SHUFFLING = 7; UPDATE = 8; DEX = 9; CHILD_ACCOUNT = 10; ") - @JsonProperty("type") - public Integer getType() { - return type; - } - public void setType(Integer type) { - this.type = type; - } - - /** - * Exactly all items. - **/ - - @Schema(description = "Exactly all items.") - @JsonProperty("accounts") - public java.util.List getAccounts() { - return accounts; - } - public void setAccounts(java.util.List accounts) { - this.accounts = accounts; - } - - /** - * The first block height - **/ - - @Schema(example = "4000123", description = "The first block height") - @JsonProperty("first") - public Long getFirst() { - return first; - } - public void setFirst(Long first) { - this.first = first; - } - - /** - * The last block height - **/ - - @Schema(example = "4999000", description = "The last block height") - @JsonProperty("last") - public Long getLast() { - return last; - } - public void setLast(Long last) { - this.last = last; - } - - /** - * The start of the time period, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696310000", description = "The start of the time period, Unix timestamp in milliseconds") - @JsonProperty("startTime") - public Long getStartTime() { - return startTime; - } - public void setStartTime(Long startTime) { - this.startTime = startTime; - } - - /** - * The end of the time period, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "The end of the time period, Unix timestamp in milliseconds") - @JsonProperty("endTime") - public Long getEndTime() { - return endTime; - } - public void setEndTime(Long endTime) { - this.endTime = endTime; - } - - /** - * page number (1-based) - **/ - - @Schema(example = "1", description = "page number (1-based)") - @JsonProperty("page") - public Integer getPage() { - return page; - } - public void setPage(Integer page) { - this.page = page; - } - - /** - * Number of entries per page (max=100) - **/ - - @Schema(example = "25", description = "Number of entries per page (max=100)") - @JsonProperty("perPage") - public Integer getPerPage() { - return perPage; - } - public void setPerPage(Integer perPage) { - this.perPage = perPage; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("orderBy") - public OrderByEnum getOrderBy() { - return orderBy; - } - public void setOrderBy(OrderByEnum orderBy) { - this.orderBy = orderBy; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryObject queryObject = (QueryObject) o; - return Objects.equals(type, queryObject.type) && - Objects.equals(accounts, queryObject.accounts) && - Objects.equals(first, queryObject.first) && - Objects.equals(last, queryObject.last) && - Objects.equals(startTime, queryObject.startTime) && - Objects.equals(endTime, queryObject.endTime) && - Objects.equals(page, queryObject.page) && - Objects.equals(perPage, queryObject.perPage) && - Objects.equals(orderBy, queryObject.orderBy); - } - - @Override - public int hashCode() { - return Objects.hash(type, accounts, first, last, startTime, endTime, page, perPage, orderBy); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryObject {\n"); - - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" accounts: ").append(toIndentedString(accounts)).append("\n"); - sb.append(" first: ").append(toIndentedString(first)).append("\n"); - sb.append(" last: ").append(toIndentedString(last)).append("\n"); - sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n"); - sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); - sb.append(" page: ").append(toIndentedString(page)).append("\n"); - sb.append(" perPage: ").append(toIndentedString(perPage)).append("\n"); - sb.append(" orderBy: ").append(toIndentedString(orderBy)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java deleted file mode 100644 index 5d2268c83c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/QueryResult.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.QueryObject; -import com.apollocurrency.aplwallet.api.v2.model.TxReceipt; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class QueryResult extends BaseResponse { - private Integer count = null; private java.util.List result = new java.util.ArrayList(); private QueryObject query = null; - - /** - * Count of result items - **/ - - @Schema(example = "345", description = "Count of result items") - @JsonProperty("count") - public Integer getCount() { - return count; - } - public void setCount(Integer count) { - this.count = count; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("result") - public java.util.List getResult() { - return result; - } - public void setResult(java.util.List result) { - this.result = result; - } - - /** - **/ - - @Schema(description = "") - @JsonProperty("query") - public QueryObject getQuery() { - return query; - } - public void setQuery(QueryObject query) { - this.query = query; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QueryResult queryResult = (QueryResult) o; - return Objects.equals(count, queryResult.count) && - Objects.equals(result, queryResult.result) && - Objects.equals(query, queryResult.query); - } - - @Override - public int hashCode() { - return Objects.hash(count, result, query); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class QueryResult {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" count: ").append(toIndentedString(count)).append("\n"); - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java deleted file mode 100644 index 61541612a9..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfo.java +++ /dev/null @@ -1,410 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfo { - private String id = null; private String type = null; private String subtype = null; private Boolean phased = null; private Long timestamp = null; private Integer deadline = null; private String senderPublicKey = null; private String recipient = null; private String amount = null; private String fee = null; private String referencedTransactionFullHash = null; private String signature = null; private String signatureHash = null; private String fullHash = null; private java.util.Map attachment = new java.util.HashMap(); private String sender = null; private Long height = null; private String version = null; private String ecBlockId = null; private Long ecBlockHeight = null; private String block = null; private Integer confirmations = null; private Long blockTimestamp = null; private Integer index = null; - - /** - * The transaction ID - **/ - - @Schema(example = "1a0feb1306043151604016701", description = "The transaction ID") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - * Transaction type - **/ - - @Schema(example = "2", description = "Transaction type") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - * Transaction subtype - **/ - - @Schema(example = "1", description = "Transaction subtype") - @JsonProperty("subtype") - public String getSubtype() { - return subtype; - } - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - /** - * is true if the transaction is phased - **/ - - @Schema(example = "false", description = "is true if the transaction is phased") - @JsonProperty("phased") - public Boolean isPhased() { - return phased; - } - public void setPhased(Boolean phased) { - this.phased = phased; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - * the deadline for the transaction to be confirmed in minutes,ex.1440=24h - **/ - - @Schema(example = "1440", description = "the deadline for the transaction to be confirmed in minutes,ex.1440=24h") - @JsonProperty("deadline") - public Integer getDeadline() { - return deadline; - } - public void setDeadline(Integer deadline) { - this.deadline = deadline; - } - - /** - * The public key of the sending account for the transaction - **/ - - @Schema(description = "The public key of the sending account for the transaction") - @JsonProperty("senderPublicKey") - public String getSenderPublicKey() { - return senderPublicKey; - } - public void setSenderPublicKey(String senderPublicKey) { - this.senderPublicKey = senderPublicKey; - } - - /** - * The account Id of the recipient - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "The account Id of the recipient") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * The amount of the transaction - **/ - - @Schema(example = "34500000000", description = "The amount of the transaction") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - * The fee of the transaction - **/ - - @Schema(example = "200000000", description = "The fee of the transaction") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - * The full hash of a transaction referenced by this one - **/ - - @Schema(example = "5424ca4dd976a873839c7d5c9952fa15ae619f678365e8ebbc73f967142eb40d", description = "The full hash of a transaction referenced by this one") - @JsonProperty("referencedTransactionFullHash") - public String getReferencedTransactionFullHash() { - return referencedTransactionFullHash; - } - public void setReferencedTransactionFullHash(String referencedTransactionFullHash) { - this.referencedTransactionFullHash = referencedTransactionFullHash; - } - - /** - * The digital signature of the transaction - **/ - - @Schema(example = "920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d56", description = "The digital signature of the transaction") - @JsonProperty("signature") - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * SHA-256 hash of the transaction signature - **/ - - @Schema(example = "2fc1883e9b76fdc67fabee0a3def5f4b7fc2de9cd65bc8bb6d39eaf5e99498d8", description = "SHA-256 hash of the transaction signature") - @JsonProperty("signatureHash") - public String getSignatureHash() { - return signatureHash; - } - public void setSignatureHash(String signatureHash) { - this.signatureHash = signatureHash; - } - - /** - * The full hash of the transaction - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "The full hash of the transaction") - @JsonProperty("fullHash") - public String getFullHash() { - return fullHash; - } - public void setFullHash(String fullHash) { - this.fullHash = fullHash; - } - - /** - * An object containong any additional data needed for the transaction - **/ - - @Schema(description = "An object containong any additional data needed for the transaction") - @JsonProperty("attachment") - public java.util.Map getAttachment() { - return attachment; - } - public void setAttachment(java.util.Map attachment) { - this.attachment = attachment; - } - - /** - * The sender account - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", description = "The sender account") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * The height of the block in the blockchain - **/ - - @Schema(example = "4365987", description = "The height of the block in the blockchain") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * The transaction version number - **/ - - @Schema(example = "1", description = "The transaction version number") - @JsonProperty("version") - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * The block id - **/ - - @Schema(example = "230aeb0f4585625167943", description = "The block id") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * the number of transaction confirmations - **/ - - @Schema(example = "387", description = "the number of transaction confirmations") - @JsonProperty("confirmations") - public Integer getConfirmations() { - return confirmations; - } - public void setConfirmations(Integer confirmations) { - this.confirmations = confirmations; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfo transactionInfo = (TransactionInfo) o; - return Objects.equals(id, transactionInfo.id) && - Objects.equals(type, transactionInfo.type) && - Objects.equals(subtype, transactionInfo.subtype) && - Objects.equals(phased, transactionInfo.phased) && - Objects.equals(timestamp, transactionInfo.timestamp) && - Objects.equals(deadline, transactionInfo.deadline) && - Objects.equals(senderPublicKey, transactionInfo.senderPublicKey) && - Objects.equals(recipient, transactionInfo.recipient) && - Objects.equals(amount, transactionInfo.amount) && - Objects.equals(fee, transactionInfo.fee) && - Objects.equals(referencedTransactionFullHash, transactionInfo.referencedTransactionFullHash) && - Objects.equals(signature, transactionInfo.signature) && - Objects.equals(signatureHash, transactionInfo.signatureHash) && - Objects.equals(fullHash, transactionInfo.fullHash) && - Objects.equals(attachment, transactionInfo.attachment) && - Objects.equals(sender, transactionInfo.sender) && - Objects.equals(height, transactionInfo.height) && - Objects.equals(version, transactionInfo.version) && - Objects.equals(ecBlockId, transactionInfo.ecBlockId) && - Objects.equals(ecBlockHeight, transactionInfo.ecBlockHeight) && - Objects.equals(block, transactionInfo.block) && - Objects.equals(confirmations, transactionInfo.confirmations) && - Objects.equals(blockTimestamp, transactionInfo.blockTimestamp) && - Objects.equals(index, transactionInfo.index); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, subtype, phased, timestamp, deadline, senderPublicKey, recipient, amount, fee, referencedTransactionFullHash, signature, signatureHash, fullHash, attachment, sender, height, version, ecBlockId, ecBlockHeight, block, confirmations, blockTimestamp, index); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfo {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); - sb.append(" phased: ").append(toIndentedString(phased)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" deadline: ").append(toIndentedString(deadline)).append("\n"); - sb.append(" senderPublicKey: ").append(toIndentedString(senderPublicKey)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" referencedTransactionFullHash: ").append(toIndentedString(referencedTransactionFullHash)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" signatureHash: ").append(toIndentedString(signatureHash)).append("\n"); - sb.append(" fullHash: ").append(toIndentedString(fullHash)).append("\n"); - sb.append(" attachment: ").append(toIndentedString(attachment)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java deleted file mode 100644 index 06ced7c633..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoArrayResp.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfo; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfoArrayResp extends BaseResponse { - private java.util.List tx = new java.util.ArrayList(); - - /** - * The array of transactions - **/ - - @Schema(description = "The array of transactions") - @JsonProperty("tx") - public java.util.List getTx() { - return tx; - } - public void setTx(java.util.List tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfoArrayResp transactionInfoArrayResp = (TransactionInfoArrayResp) o; - return Objects.equals(tx, transactionInfoArrayResp.tx); - } - - @Override - public int hashCode() { - return Objects.hash(tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfoArrayResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java deleted file mode 100644 index efc454140a..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TransactionInfoResp.java +++ /dev/null @@ -1,412 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.apollocurrency.aplwallet.api.v2.model.TransactionInfo; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TransactionInfoResp extends BaseResponse { - private String id = null; private String type = null; private String subtype = null; private Boolean phased = null; private Long timestamp = null; private Integer deadline = null; private String senderPublicKey = null; private String recipient = null; private String amount = null; private String fee = null; private String referencedTransactionFullHash = null; private String signature = null; private String signatureHash = null; private String fullHash = null; private java.util.Map attachment = new java.util.HashMap(); private String sender = null; private Long height = null; private String version = null; private String ecBlockId = null; private Long ecBlockHeight = null; private String block = null; private Integer confirmations = null; private Long blockTimestamp = null; private Integer index = null; - - /** - * The transaction ID - **/ - - @Schema(example = "1a0feb1306043151604016701", description = "The transaction ID") - @JsonProperty("id") - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - /** - * Transaction type - **/ - - @Schema(example = "2", description = "Transaction type") - @JsonProperty("type") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - /** - * Transaction subtype - **/ - - @Schema(example = "1", description = "Transaction subtype") - @JsonProperty("subtype") - public String getSubtype() { - return subtype; - } - public void setSubtype(String subtype) { - this.subtype = subtype; - } - - /** - * is true if the transaction is phased - **/ - - @Schema(example = "false", description = "is true if the transaction is phased") - @JsonProperty("phased") - public Boolean isPhased() { - return phased; - } - public void setPhased(Boolean phased) { - this.phased = phased; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - * the deadline for the transaction to be confirmed in minutes,ex.1440=24h - **/ - - @Schema(example = "1440", description = "the deadline for the transaction to be confirmed in minutes,ex.1440=24h") - @JsonProperty("deadline") - public Integer getDeadline() { - return deadline; - } - public void setDeadline(Integer deadline) { - this.deadline = deadline; - } - - /** - * The public key of the sending account for the transaction - **/ - - @Schema(description = "The public key of the sending account for the transaction") - @JsonProperty("senderPublicKey") - public String getSenderPublicKey() { - return senderPublicKey; - } - public void setSenderPublicKey(String senderPublicKey) { - this.senderPublicKey = senderPublicKey; - } - - /** - * The account Id of the recipient - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", description = "The account Id of the recipient") - @JsonProperty("recipient") - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - * The amount of the transaction - **/ - - @Schema(example = "34500000000", description = "The amount of the transaction") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - * The fee of the transaction - **/ - - @Schema(example = "200000000", description = "The fee of the transaction") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - * The full hash of a transaction referenced by this one - **/ - - @Schema(example = "5424ca4dd976a873839c7d5c9952fa15ae619f678365e8ebbc73f967142eb40d", description = "The full hash of a transaction referenced by this one") - @JsonProperty("referencedTransactionFullHash") - public String getReferencedTransactionFullHash() { - return referencedTransactionFullHash; - } - public void setReferencedTransactionFullHash(String referencedTransactionFullHash) { - this.referencedTransactionFullHash = referencedTransactionFullHash; - } - - /** - * The digital signature of the transaction - **/ - - @Schema(example = "920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d56", description = "The digital signature of the transaction") - @JsonProperty("signature") - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * SHA-256 hash of the transaction signature - **/ - - @Schema(example = "2fc1883e9b76fdc67fabee0a3def5f4b7fc2de9cd65bc8bb6d39eaf5e99498d8", description = "SHA-256 hash of the transaction signature") - @JsonProperty("signatureHash") - public String getSignatureHash() { - return signatureHash; - } - public void setSignatureHash(String signatureHash) { - this.signatureHash = signatureHash; - } - - /** - * The full hash of the transaction - **/ - - @Schema(example = "39dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152", description = "The full hash of the transaction") - @JsonProperty("fullHash") - public String getFullHash() { - return fullHash; - } - public void setFullHash(String fullHash) { - this.fullHash = fullHash; - } - - /** - * An object containong any additional data needed for the transaction - **/ - - @Schema(description = "An object containong any additional data needed for the transaction") - @JsonProperty("attachment") - public java.util.Map getAttachment() { - return attachment; - } - public void setAttachment(java.util.Map attachment) { - this.attachment = attachment; - } - - /** - * The sender account - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", description = "The sender account") - @JsonProperty("sender") - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - * The height of the block in the blockchain - **/ - - @Schema(example = "4365987", description = "The height of the block in the blockchain") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * The transaction version number - **/ - - @Schema(example = "1", description = "The transaction version number") - @JsonProperty("version") - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - - /** - * The economic clustering block ID - **/ - - @Schema(example = "40faaeb15856251679437054", description = "The economic clustering block ID") - @JsonProperty("ecBlockId") - public String getEcBlockId() { - return ecBlockId; - } - public void setEcBlockId(String ecBlockId) { - this.ecBlockId = ecBlockId; - } - - /** - * The economic clustering block height - **/ - - @Schema(example = "3301233", description = "The economic clustering block height") - @JsonProperty("ecBlockHeight") - public Long getEcBlockHeight() { - return ecBlockHeight; - } - public void setEcBlockHeight(Long ecBlockHeight) { - this.ecBlockHeight = ecBlockHeight; - } - - /** - * The block id - **/ - - @Schema(example = "230aeb0f4585625167943", description = "The block id") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * the number of transaction confirmations - **/ - - @Schema(example = "387", description = "the number of transaction confirmations") - @JsonProperty("confirmations") - public Integer getConfirmations() { - return confirmations; - } - public void setConfirmations(Integer confirmations) { - this.confirmations = confirmations; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionInfoResp transactionInfoResp = (TransactionInfoResp) o; - return Objects.equals(id, transactionInfoResp.id) && - Objects.equals(type, transactionInfoResp.type) && - Objects.equals(subtype, transactionInfoResp.subtype) && - Objects.equals(phased, transactionInfoResp.phased) && - Objects.equals(timestamp, transactionInfoResp.timestamp) && - Objects.equals(deadline, transactionInfoResp.deadline) && - Objects.equals(senderPublicKey, transactionInfoResp.senderPublicKey) && - Objects.equals(recipient, transactionInfoResp.recipient) && - Objects.equals(amount, transactionInfoResp.amount) && - Objects.equals(fee, transactionInfoResp.fee) && - Objects.equals(referencedTransactionFullHash, transactionInfoResp.referencedTransactionFullHash) && - Objects.equals(signature, transactionInfoResp.signature) && - Objects.equals(signatureHash, transactionInfoResp.signatureHash) && - Objects.equals(fullHash, transactionInfoResp.fullHash) && - Objects.equals(attachment, transactionInfoResp.attachment) && - Objects.equals(sender, transactionInfoResp.sender) && - Objects.equals(height, transactionInfoResp.height) && - Objects.equals(version, transactionInfoResp.version) && - Objects.equals(ecBlockId, transactionInfoResp.ecBlockId) && - Objects.equals(ecBlockHeight, transactionInfoResp.ecBlockHeight) && - Objects.equals(block, transactionInfoResp.block) && - Objects.equals(confirmations, transactionInfoResp.confirmations) && - Objects.equals(blockTimestamp, transactionInfoResp.blockTimestamp) && - Objects.equals(index, transactionInfoResp.index); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, subtype, phased, timestamp, deadline, senderPublicKey, recipient, amount, fee, referencedTransactionFullHash, signature, signatureHash, fullHash, attachment, sender, height, version, ecBlockId, ecBlockHeight, block, confirmations, blockTimestamp, index); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionInfoResp {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); - sb.append(" phased: ").append(toIndentedString(phased)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" deadline: ").append(toIndentedString(deadline)).append("\n"); - sb.append(" senderPublicKey: ").append(toIndentedString(senderPublicKey)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" referencedTransactionFullHash: ").append(toIndentedString(referencedTransactionFullHash)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" signatureHash: ").append(toIndentedString(signatureHash)).append("\n"); - sb.append(" fullHash: ").append(toIndentedString(fullHash)).append("\n"); - sb.append(" attachment: ").append(toIndentedString(attachment)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" ecBlockId: ").append(toIndentedString(ecBlockId)).append("\n"); - sb.append(" ecBlockHeight: ").append(toIndentedString(ecBlockHeight)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java deleted file mode 100644 index 0832bd162c..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxReceipt.java +++ /dev/null @@ -1,279 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.apollocurrency.aplwallet.api.v2.model.BaseResponse; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description="Transaction receipt") -public class TxReceipt extends BaseResponse { - private String transaction = null; private String sender = null; private String recipient = null; private String signature = null; private Long timestamp = null; private String amount = null; private String fee = null; private String payload = null; /** - * The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. - */ - public enum StatusEnum { - UNCONFIRMED("unconfirmed"), - CONFIRMED("confirmed"), - IRREVERSIBLE("irreversible"), - PERMANENT("permanent"); - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - } - private StatusEnum status = null; private String block = null; private Long blockTimestamp = null; private Long height = null; private Integer index = null; private Long confirmations = null; - - /** - **/ - - @Schema(example = "8330faaeb404178613417", required = true, description = "") - @JsonProperty("transaction") - @NotNull - public String getTransaction() { - return transaction; - } - public void setTransaction(String transaction) { - this.transaction = transaction; - } - - /** - **/ - - @Schema(example = "APL-X5JH-TJKJ-DVGC-5T2V8", required = true, description = "") - @JsonProperty("sender") - @NotNull - public String getSender() { - return sender; - } - public void setSender(String sender) { - this.sender = sender; - } - - /** - **/ - - @Schema(example = "APL-FXHG-6KHM-23LE-42ACU", required = true, description = "") - @JsonProperty("recipient") - @NotNull - public String getRecipient() { - return recipient; - } - public void setRecipient(String recipient) { - this.recipient = recipient; - } - - /** - **/ - - @Schema(example = "B98CB1890E76C772A10994B210ED9CF7F9A5488672A5D82C2734BBF9D11505D1", required = true, description = "") - @JsonProperty("signature") - @NotNull - public String getSignature() { - return signature; - } - public void setSignature(String signature) { - this.signature = signature; - } - - /** - * Transaction timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Transaction timestamp, Unix timestamp in milliseconds") - @JsonProperty("timestamp") - public Long getTimestamp() { - return timestamp; - } - public void setTimestamp(Long timestamp) { - this.timestamp = timestamp; - } - - /** - **/ - - @Schema(example = "34500000000", description = "") - @JsonProperty("amount") - public String getAmount() { - return amount; - } - public void setAmount(String amount) { - this.amount = amount; - } - - /** - **/ - - @Schema(example = "0", description = "") - @JsonProperty("fee") - public String getFee() { - return fee; - } - public void setFee(String fee) { - this.fee = fee; - } - - /** - **/ - - @Schema(example = "{\"transaction\":\"1234567890\", \"amount\":\"1234567890.12\"}", description = "") - @JsonProperty("payload") - public String getPayload() { - return payload; - } - public void setPayload(String payload) { - this.payload = payload; - } - - /** - * The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. - **/ - - @Schema(example = "unconfirmed", description = "The transaction status. A transaction is considered as unconfirmed until it is included in a valid block. A transaction is considered as confirmed after at least one confirmations, so a transaction is considered as irreversible after 721 confirmations and finally a transaction is permanent if it's confirmed 1440 times. ") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * The Id of the block containing the confirmed transaction - **/ - - @Schema(example = "40faaeb1585625167943", description = "The Id of the block containing the confirmed transaction") - @JsonProperty("block") - public String getBlock() { - return block; - } - public void setBlock(String block) { - this.block = block; - } - - /** - * Block timestamp, Unix timestamp in milliseconds - **/ - - @Schema(example = "1591696372000", description = "Block timestamp, Unix timestamp in milliseconds") - @JsonProperty("blockTimestamp") - public Long getBlockTimestamp() { - return blockTimestamp; - } - public void setBlockTimestamp(Long blockTimestamp) { - this.blockTimestamp = blockTimestamp; - } - - /** - **/ - - @Schema(example = "15623658", description = "") - @JsonProperty("height") - public Long getHeight() { - return height; - } - public void setHeight(Long height) { - this.height = height; - } - - /** - * the order of the transaction in the block - **/ - - @Schema(example = "1", description = "the order of the transaction in the block") - @JsonProperty("index") - public Integer getIndex() { - return index; - } - public void setIndex(Integer index) { - this.index = index; - } - - /** - * the amount of block transaction - **/ - - @Schema(example = "1758", description = "the amount of block transaction") - @JsonProperty("confirmations") - public Long getConfirmations() { - return confirmations; - } - public void setConfirmations(Long confirmations) { - this.confirmations = confirmations; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TxReceipt txReceipt = (TxReceipt) o; - return Objects.equals(transaction, txReceipt.transaction) && - Objects.equals(sender, txReceipt.sender) && - Objects.equals(recipient, txReceipt.recipient) && - Objects.equals(signature, txReceipt.signature) && - Objects.equals(timestamp, txReceipt.timestamp) && - Objects.equals(amount, txReceipt.amount) && - Objects.equals(fee, txReceipt.fee) && - Objects.equals(payload, txReceipt.payload) && - Objects.equals(status, txReceipt.status) && - Objects.equals(block, txReceipt.block) && - Objects.equals(blockTimestamp, txReceipt.blockTimestamp) && - Objects.equals(height, txReceipt.height) && - Objects.equals(index, txReceipt.index) && - Objects.equals(confirmations, txReceipt.confirmations); - } - - @Override - public int hashCode() { - return Objects.hash(transaction, sender, recipient, signature, timestamp, amount, fee, payload, status, block, blockTimestamp, height, index, confirmations); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TxReceipt {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" transaction: ").append(toIndentedString(transaction)).append("\n"); - sb.append(" sender: ").append(toIndentedString(sender)).append("\n"); - sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); - sb.append(" signature: ").append(toIndentedString(signature)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" payload: ").append(toIndentedString(payload)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" block: ").append(toIndentedString(block)).append("\n"); - sb.append(" blockTimestamp: ").append(toIndentedString(blockTimestamp)).append("\n"); - sb.append(" height: ").append(toIndentedString(height)).append("\n"); - sb.append(" index: ").append(toIndentedString(index)).append("\n"); - sb.append(" confirmations: ").append(toIndentedString(confirmations)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java b/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java deleted file mode 100644 index 91cdf2cad7..0000000000 --- a/apl-api2/src/gen/java/com/apollocurrency/aplwallet/api/v2/model/TxRequest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.apollocurrency.aplwallet.api.v2.model; - -import java.util.Objects; -import java.util.ArrayList; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import javax.validation.constraints.*; -import io.swagger.v3.oas.annotations.media.Schema; - - -public class TxRequest { - private String tx = null; - - /** - * Signed transaction data - **/ - - @Schema(example = "001047857c04a00539dc2e813bb45ff063a376e316b10cd0addd7306555ca0dd2890194d37960152eef5365f2400292d00ca9a3b0000000000c2eb0b000000000000000000000000000000000000000000000000000000000000000000000000920173ae606d36c1c77fc5bdf294bd048d04f85c46535525771b524dbb1ed20b73311900d4a409c293a10d8a5ab987430be4bd7478fb16a41cf775afa33c4d5600000000f1da1300fe7062e6fb2fbb37", required = true, description = "Signed transaction data") - @JsonProperty("tx") - @NotNull - public String getTx() { - return tx; - } - public void setTx(String tx) { - this.tx = tx; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TxRequest txRequest = (TxRequest) o; - return Objects.equals(tx, txRequest.tx); - } - - @Override - public int hashCode() { - return Objects.hash(tx); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TxRequest {\n"); - - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} From db8eb791710fc30d6e5e671c0ecad25f4b94ebf4 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 31 Aug 2020 15:48:30 +0300 Subject: [PATCH 06/42] APL-1676 node ID handler work in progress --- ...cateHolder.java => CertificateLoader.java} | 4 ++-- .../apl/id/handler/CertKeyHolder.java | 21 +++++++++++++++++++ .../apl/id/handler/ThisNodeIdHandler.java | 3 ++- .../apl/id/handler/ThisNodeIdHandlerImpl.java | 5 +++++ 4 files changed, 30 insertions(+), 3 deletions(-) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{CertificateHolder.java => CertificateLoader.java} (98%) create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java similarity index 98% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java index f9987ecdec..a21593a441 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateHolder.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java @@ -20,9 +20,9 @@ * * @author alukin@gmail.com */ -public class CertificateHolder { +public class CertificateLoader { public static final String PVT_SEARCH_PATH = "/../private/"; - private static final Logger log = LoggerFactory.getLogger(CertificateHolder.class); + private static final Logger log = LoggerFactory.getLogger(CertificateLoader.class); private final Map> certMap = new TreeMap<>(); public static String rmSuffixes(String fn) { diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java new file mode 100644 index 0000000000..b49463fad4 --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java @@ -0,0 +1,21 @@ +/* + * Copyright © 2020 Apollo Foundation + */ +package com.apollocurrency.apl.id.handler; + +import com.apollocurrency.apl.id.cert.ApolloCertificate; +import java.security.PrivateKey; +/** + * + * @author alukion@gmail.com + */ +public class CertKeyHolder { + private final ApolloCertificate cert; + private final PrivateKey privateKey; + + public CertKeyHolder(ApolloCertificate cert, PrivateKey privateKey) { + this.cert = cert; + this.privateKey = privateKey; + } + +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java index c6a543ec9e..4255543b31 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java @@ -7,11 +7,12 @@ import java.math.BigInteger; /** - * + * Handles operations with X509 certificate and private key of this node * @author alukin@gmail.com */ public interface ThisNodeIdHandler { BigInteger getApolloId(); ApolloCertificate getCertificate(); byte[] sign(byte[] message); + CertKeyHolder generateSelfSignedCert(); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java index 69ab4cd332..2adaa97c2b 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java @@ -46,6 +46,11 @@ public byte[] sign(byte[] message) { } return res; } + + @Override + public CertKeyHolder generateSelfSignedCert() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } } From 95b105efb0da5e88dc22b3b92a46d3945b54b9a8 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 2 Sep 2020 16:47:01 +0300 Subject: [PATCH 07/42] cleanup of unneded stuff and fixes --- .../main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java | 2 -- .../com/apollocurrency/apl/id/cert/ApolloCertificate.java | 1 - .../apl/id/cert/{CertificateLoader.java => CertKeyDirs.java} | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{CertificateLoader.java => CertKeyDirs.java} (98%) diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java index 49e139daa9..23b89e1dfc 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java @@ -4,13 +4,11 @@ package com.apollocurrency.apl.id.cert; import com.apollocurrency.apl.id.utils.StringList; -import io.firstbridge.cryptolib.CryptoFactory; import io.firstbridge.cryptolib.CryptoNotValidException; import io.firstbridge.cryptolib.KeyGenerator; import io.firstbridge.cryptolib.KeyWriter; import io.firstbridge.cryptolib.csr.CertificateRequestData; import io.firstbridge.cryptolib.csr.X509CertOperations; -import io.firstbridge.cryptolib.impl.KeyWriterImpl; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java index 7ae3f3c3e6..2719b7b6c0 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java @@ -18,7 +18,6 @@ import java.security.SignatureException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.logging.Level; diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java similarity index 98% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java index a21593a441..244c26fb0d 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertificateLoader.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java @@ -20,9 +20,9 @@ * * @author alukin@gmail.com */ -public class CertificateLoader { +public class CertKeyDirs { public static final String PVT_SEARCH_PATH = "/../private/"; - private static final Logger log = LoggerFactory.getLogger(CertificateLoader.class); + private static final Logger log = LoggerFactory.getLogger(CertKeyDirs.class); private final Map> certMap = new TreeMap<>(); public static String rmSuffixes(String fn) { From d7c39439472a7dd2e9778f850747242c4a944e01 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 2 Sep 2020 18:27:08 +0300 Subject: [PATCH 08/42] hash of classed corrented --- .../java/com/apollocurrency/apl/id/cert/ActorType.java | 5 ++++- .../java/com/apollocurrency/apl/id/cert/AuthorityID.java | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java index dfb43d9a8a..65a10fd79e 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java @@ -84,8 +84,11 @@ public boolean equals(Object obj) { } @Override + //generated by IDE public int hashCode() { - return at.hashCode(); + int hash = 3; + hash = 43 * hash + Arrays.hashCode(this.at); + return hash; } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java index e62716e225..c7d651c7ff 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java @@ -228,10 +228,15 @@ public boolean equals(Object obj) { } @Override + //generated by IDE public int hashCode() { - return authorityID.hashCode(); + int hash = 5; + hash = 89 * hash + Arrays.hashCode(this.authorityID); + return hash; } + + @Override public String toString() { return "AuthorityID{" + "authorityID=" + Hex.toHexString(authorityID) + '}'; From 518856ffbd57740fb2a13cdb13d480e123e0685e Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 4 Sep 2020 12:11:57 +0300 Subject: [PATCH 09/42] Apollo ID work in progress --- .../apl/id/cert/ApolloCertificate.java | 4 ++++ .../apollocurrency/apl/id/cert/CertBase.java | 1 + .../apl/id/cert/CertKeyDirs.java | 21 +++++++++--------- .../apl/id/handler/CertKeyHolder.java | 21 ------------------ .../apl/id/handler/IdValidator.java | 3 +++ .../apl/id/handler/IdValidatorImpl.java | 22 +++++++++++++++++-- ...IdHandler.java => ThisActorIdHandler.java} | 4 ++-- ...rImpl.java => ThisActorIdHandlerImpl.java} | 4 ++-- 8 files changed, 43 insertions(+), 37 deletions(-) delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java rename apl-id/src/main/java/com/apollocurrency/apl/id/handler/{ThisNodeIdHandler.java => ThisActorIdHandler.java} (82%) rename apl-id/src/main/java/com/apollocurrency/apl/id/handler/{ThisNodeIdHandlerImpl.java => ThisActorIdHandlerImpl.java} (92%) diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java index 2719b7b6c0..e41bec8ab1 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java @@ -176,4 +176,8 @@ public boolean isSelfSigned(){ //TODO: implement return true; } + + public boolean isSignedBy(X509Certificate signerCert) { + return verify(signerCert); + } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java index c2efaab07b..5fcd2013b7 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java @@ -12,6 +12,7 @@ /** * Base class for certificate and CSR + * Also holds private key of certificate * * @author alukin@gmail.com */ diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java index 244c26fb0d..9225ab0e13 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java @@ -16,15 +16,16 @@ import java.util.TreeMap; /** - * Holder of available cerificates placed in map with ID as a key + * Handler of certificate, CSR and key names and directories placed in map with ID as a key * * @author alukin@gmail.com */ public class CertKeyDirs { - public static final String PVT_SEARCH_PATH = "/../private/"; + public static final String PVT_SEARCH_PATH = "private/"; private static final Logger log = LoggerFactory.getLogger(CertKeyDirs.class); private final Map> certMap = new TreeMap<>(); - + public static final String[] sfxes = {"_pvtkey", "_req", "_cert", "_selfcert", "_csr"}; + public static String rmSuffixes(String fn) { String name = new String(fn); String ext = ""; @@ -91,27 +92,27 @@ public void readCertDirectory(String path, boolean loadPrivateKey) { File[] filesList = dir.listFiles(); for (File f : filesList) { if (f.isFile() && f.canRead()) { - ApolloCertificate vc = null; + ApolloCertificate ac = null; try { - vc = ApolloCertificate.loadPEMFromPath(f.getAbsolutePath()); + ac = ApolloCertificate.loadPEMFromPath(f.getAbsolutePath()); } catch (IOException ex) { //impossible here } catch (ApolloCertificateException ex) { log.error("Certificate load exception wilr loading " + f.getAbsolutePath(), ex); } - if (vc != null) { - put(vc.getApolloId(), vc); + if (ac != null) { + put(ac.getApolloId(), ac); if (loadPrivateKey) { String parent = f.getParent(); String fn = f.getName(); PrivateKey pk = null; pk = readPvtKey(parent + "/" + pvtKeyFileName(fn)); - if (pk == null) {//no key in the same dir, try ../private + if (pk == null) {//no key in the same dir, try "private/" pk = readPvtKey(parent + PVT_SEARCH_PATH + pvtKeyFileName(fn)); } if (pk != null) { - if (vc.checkKeys(pk)) { - vc.setPrivateKey(pk); + if (ac.checkKeys(pk)) { + ac.setPrivateKey(pk); } else { log.error("Private key file does not correspond to certificate: {}" + f.getAbsolutePath()); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java deleted file mode 100644 index b49463fad4..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/CertKeyHolder.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.id.handler; - -import com.apollocurrency.apl.id.cert.ApolloCertificate; -import java.security.PrivateKey; -/** - * - * @author alukion@gmail.com - */ -public class CertKeyHolder { - private final ApolloCertificate cert; - private final PrivateKey privateKey; - - public CertKeyHolder(ApolloCertificate cert, PrivateKey privateKey) { - this.cert = cert; - this.privateKey = privateKey; - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java index a159a1f0c8..49938b4546 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java @@ -5,12 +5,15 @@ package com.apollocurrency.apl.id.handler; import com.apollocurrency.apl.id.cert.ApolloCertificate; +import java.security.cert.X509Certificate; + /** * * @author alukin@gmail.com */ public interface IdValidator { + void addTrustedSignerCert(X509Certificate cert); boolean isSelfSigned(ApolloCertificate cert); boolean isTrusted(ApolloCertificate cert); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java index 69028a7269..ec98e9bd84 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java @@ -4,13 +4,19 @@ package com.apollocurrency.apl.id.handler; import com.apollocurrency.apl.id.cert.ApolloCertificate; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; + /** * * @author alukin@gmail.com */ public class IdValidatorImpl implements IdValidator{ - + + private final List trustedSigners = new ArrayList<>(); + @Override public boolean isSelfSigned(ApolloCertificate cert) { return false; @@ -18,7 +24,19 @@ public boolean isSelfSigned(ApolloCertificate cert) { @Override public boolean isTrusted(ApolloCertificate cert) { - return true; + boolean res = false; + for(X509Certificate signerCert: trustedSigners){ + res = cert.isSignedBy(signerCert); + if(res){ + break; + } + } + return res; + } + + @Override + public void addTrustedSignerCert(X509Certificate cert) { + trustedSigners.add(cert); } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java similarity index 82% rename from apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java index 4255543b31..641d8ec013 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandler.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java @@ -10,9 +10,9 @@ * Handles operations with X509 certificate and private key of this node * @author alukin@gmail.com */ -public interface ThisNodeIdHandler { +public interface ThisActorIdHandler { BigInteger getApolloId(); ApolloCertificate getCertificate(); byte[] sign(byte[] message); - CertKeyHolder generateSelfSignedCert(); + ApolloCertificate generateSelfSignedCert(); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java similarity index 92% rename from apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java index 2adaa97c2b..800feb462c 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisNodeIdHandlerImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java @@ -17,7 +17,7 @@ * @author alukin@gmail.com */ @Slf4j -public class ThisNodeIdHandlerImpl implements ThisNodeIdHandler { +public class ThisActorIdHandlerImpl implements ThisActorIdHandler { BigInteger myApolloId; KeyPair myKeys; ApolloCertificate myCert; @@ -48,7 +48,7 @@ public byte[] sign(byte[] message) { } @Override - public CertKeyHolder generateSelfSignedCert() { + public ApolloCertificate generateSelfSignedCert() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } From a4a9ea1c2ca8a90a50babad190fe7abe64b02592 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 4 Sep 2020 14:52:23 +0300 Subject: [PATCH 10/42] Better class names --- .../cert/{ApolloCSR.java => CSRHelper.java} | 74 +++++++++---------- .../apl/id/cert/CertAttributes.java | 6 +- ...icateException.java => CertException.java} | 4 +- ...ApolloCertificate.java => CertHelper.java} | 20 ++--- .../apl/id/cert/CertKeyDirs.java | 14 ++-- .../apl/id/handler/IdValidator.java | 5 +- .../apl/id/handler/IdValidatorImpl.java | 10 ++- .../apl/id/handler/ThisActorIdHandler.java | 6 +- .../id/handler/ThisActorIdHandlerImpl.java | 8 +- .../apl/id/cert/ApolloCertificateTest.java | 6 +- 10 files changed, 77 insertions(+), 76 deletions(-) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{ApolloCSR.java => CSRHelper.java} (79%) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{ApolloCertificateException.java => CertException.java} (53%) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{ApolloCertificate.java => CertHelper.java} (85%) diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java similarity index 79% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java index 23b89e1dfc..bc9e5d257b 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCSR.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java @@ -29,36 +29,36 @@ * * @author alukin@gmail.com */ -public class ApolloCSR extends CertBase { +public class CSRHelper extends CertBase { - private static final Logger log = LoggerFactory.getLogger(ApolloCSR.class); - private final CertificateRequestData certData = new CertificateRequestData(CertificateRequestData.CSRType.HOST); + private static final Logger log = LoggerFactory.getLogger(CSRHelper.class); + private final CertificateRequestData csrData = new CertificateRequestData(CertificateRequestData.CSRType.HOST); private String challengePassword = ""; private BigInteger apolloID; private AuthorityID apolloAuthID; private final KeyWriter kw; - public ApolloCSR() { + public CSRHelper() { apolloID = new BigInteger(128, new SecureRandom()); apolloAuthID = new AuthorityID(); kw = factory.getKeyWriter(); } - public static ApolloCSR loadCSR(String path) { + public static CSRHelper loadCSR(String path) { PKCS10CertificationRequest cr; - ApolloCSR res = null; + CSRHelper res = null; try (FileReader fr = new FileReader(path)) { PEMParser parser = new PEMParser(fr); cr = (PKCS10CertificationRequest) parser.readObject(); - res = ApolloCSR.fromPKCS10(cr); + res = CSRHelper.fromPKCS10(cr); } catch (IOException ex) { log.error("Can not read PKCS#10 file: " + path, ex); } return res; } - public static ApolloCSR fromPKCS10(PKCS10CertificationRequest cr) { - ApolloCSR res = new ApolloCSR(); + public static CSRHelper fromPKCS10(PKCS10CertificationRequest cr) { + CSRHelper res = new CSRHelper(); try { CertAttributes va = new CertAttributes(); va.setSubject(cr.getSubject()); @@ -76,14 +76,14 @@ public static ApolloCSR fromPKCS10(PKCS10CertificationRequest cr) { JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); res.pubKey = converter.getPublicKey(pkInfo); - } catch (ApolloCertificateException | IOException ex) { + } catch (CertException | IOException ex) { log.error("Error reading public key frpm PKSC#10", ex); } return res; } - public static ApolloCSR fromCertificate(ApolloCertificate cert) { - ApolloCSR res = new ApolloCSR(); + public static CSRHelper fromCertificate(CertHelper cert) { + CSRHelper res = new CSRHelper(); res.setApolloAuthorityID(cert.getAuthorityId().getAuthorityID()); BigInteger vid = cert.getApolloId(); if (vid == null || vid == BigInteger.ZERO) { @@ -135,7 +135,7 @@ public BigInteger getApolloID() { public void setApolloID(BigInteger id) { apolloID = id; - certData.setSubjectAttribute("UID", apolloID.toString(16)); + csrData.setSubjectAttribute("UID", apolloID.toString(16)); } public AuthorityID getApolloAuthorityID() { @@ -144,7 +144,7 @@ public AuthorityID getApolloAuthorityID() { public void setApolloAuthorityID(BigInteger id) { apolloAuthID = new AuthorityID(id); - certData.setSubjectAttribute("businessCategory", apolloAuthID.getAuthorityID().toString(16)); + csrData.setSubjectAttribute("businessCategory", apolloAuthID.getAuthorityID().toString(16)); } public AuthorityID getAuthID() { @@ -153,11 +153,11 @@ public AuthorityID getAuthID() { public void setAuthID(AuthorityID authID) { this.apolloAuthID = authID; - certData.setSubjectAttribute("businessCategory", authID.getAuthorityID().toString(16)); + csrData.setSubjectAttribute("businessCategory", authID.getAuthorityID().toString(16)); } public String getCN() { - String res = certData.getSubjectAttribute("CN"); + String res = csrData.getSubjectAttribute("CN"); if (res == null) { res = ""; } @@ -165,11 +165,11 @@ public String getCN() { } public void setCN(String cn) { - certData.setSubjectAttribute("CN", cn); + csrData.setSubjectAttribute("CN", cn); } public String getEmial() { - String res = certData.getSubjectAttribute("emailAddress"); + String res = csrData.getSubjectAttribute("emailAddress"); if (res == null) { res = ""; } @@ -177,17 +177,17 @@ public String getEmial() { } public void setEmail(String email) { - certData.setSubjectAttribute("emailAddress", email); + csrData.setSubjectAttribute("emailAddress", email); } public String getIP() { - return certData.getExtendedAttribute("subjaltnames.ipaddress"); + return csrData.getExtendedAttribute("subjaltnames.ipaddress"); } public void setIP(String ip) { if (ip != null && !ip.isEmpty()) { if (isValidIPAddresList(ip)) { - certData.setExtendedAttribute("subjaltnames.ipaddress", ip); + csrData.setExtendedAttribute("subjaltnames.ipaddress", ip); } else { throw new IllegalArgumentException("Invalid IP4 or IP6 addres: " + ip); } @@ -195,13 +195,13 @@ public void setIP(String ip) { } public String getDNSNames() { - return certData.getExtendedAttribute("subjaltnames.dnsname"); + return csrData.getExtendedAttribute("subjaltnames.dnsname"); } public void setDNSNames(String n) { if (n != null && !n.isEmpty()) { if (isVaidDNSNameList(n)) { - certData.setExtendedAttribute("subjaltnames.dnsname", n); + csrData.setExtendedAttribute("subjaltnames.dnsname", n); } else { throw new IllegalArgumentException("Invalid DNS name: " + n); } @@ -209,43 +209,43 @@ public void setDNSNames(String n) { } public String getOrgUnit() { - return certData.getSubjectAttribute("OU"); + return csrData.getSubjectAttribute("OU"); } public void setOrgUnit(String ou) { - certData.setSubjectAttribute("OU", ou); + csrData.setSubjectAttribute("OU", ou); } public String getOrg() { - return certData.getSubjectAttribute("O"); + return csrData.getSubjectAttribute("O"); } public void setOrg(String o) { - certData.setSubjectAttribute("O", o); + csrData.setSubjectAttribute("O", o); } public String getCountry() { - return certData.getSubjectAttribute("C"); + return csrData.getSubjectAttribute("C"); } public void setCountry(String c) { - certData.setSubjectAttribute("C", c); + csrData.setSubjectAttribute("C", c); } public String getState() { - return certData.getSubjectAttribute("ST"); + return csrData.getSubjectAttribute("ST"); } public void setState(String c) { - certData.setSubjectAttribute("ST", c); + csrData.setSubjectAttribute("ST", c); } public String getCity() { - return certData.getSubjectAttribute("L"); + return csrData.getSubjectAttribute("L"); } public void setCity(String c) { - certData.setSubjectAttribute("L", c); + csrData.setSubjectAttribute("L", c); } public String getChallengePassword() { @@ -259,13 +259,13 @@ public void setChallengePassword(String challengePassword) { public String getPemPKCS10() { String pem = ""; try { - certData.processCertData(false); + csrData.processCertData(false); if (pvtKey == null) { newKeyPair(); } KeyPair kp = new KeyPair(pubKey, pvtKey); X509CertOperations certOps = factory.getX509CertOperations(); - PKCS10CertificationRequest cr = certOps.createX509CertificateRequest(kp, certData, false, challengePassword); + PKCS10CertificationRequest cr = certOps.createX509CertificateRequest(kp, csrData, false, challengePassword); pem = kw.getCertificateRequestPEM(cr); } catch (IOException ex) { log.error("Can not generate PKSC10 CSR", ex); @@ -288,13 +288,13 @@ public String getPrivateKeyPEM() { public String getSelfSignedX509PEM() { String pem = ""; try { - certData.processCertData(true); + csrData.processCertData(true); if (pvtKey == null) { newKeyPair(); } KeyPair kp = new KeyPair(pubKey, pvtKey); X509CertOperations certOps = factory.getX509CertOperations(); - X509Certificate cert = certOps.createSelfSignedX509v3(kp, certData); + X509Certificate cert = certOps.createSelfSignedX509v3(kp, csrData); pem = kw.getX509CertificatePEM(cert); } catch (CryptoNotValidException | IOException ex) { log.error("Can not generate self-signed PEM", ex); diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java index 8ba21151df..d1eefde902 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java @@ -31,12 +31,12 @@ public void setAttributes(Attribute[] aa) { } - public void setSubject(X500Name sn) throws ApolloCertificateException { + public void setSubject(X500Name sn) throws CertException { String name = sn.toString(); setSubjectStr(name); } - public void setSubjectStr(String name) throws ApolloCertificateException { + public void setSubjectStr(String name) throws CertException { String[] names = name.split(","); try { for (String name1 : names) { @@ -65,7 +65,7 @@ public void setSubjectStr(String name) throws ApolloCertificateException { } } } catch (NumberFormatException ex) { - throw new ApolloCertificateException(ex.getMessage()); + throw new CertException(ex.getMessage()); } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java similarity index 53% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java index f0b86b37d3..7535a93d4c 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificateException.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java @@ -3,9 +3,9 @@ /** * @author alukin@gmail.com */ -public class ApolloCertificateException extends RuntimeException { +public class CertException extends RuntimeException { - ApolloCertificateException(String message) { + CertException(String message) { throw new RuntimeException(message); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java similarity index 85% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java index e41bec8ab1..329a664ef4 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ApolloCertificate.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java @@ -28,17 +28,17 @@ * * @author alukin@gmail.com */ -public class ApolloCertificate extends CertBase { +public class CertHelper extends CertBase { - private static final Logger log = LoggerFactory.getLogger(ApolloCertificate.class); + private static final Logger log = LoggerFactory.getLogger(CertHelper.class); private final X509Certificate certificate; private final CertAttributes cert_attr; private final CertAttributes issuer_attr; - public ApolloCertificate(X509Certificate certificate) throws ApolloCertificateException { + public CertHelper(X509Certificate certificate) throws CertException { if (certificate == null) { - throw new ApolloCertificateException("Null certificate"); + throw new CertException("Null certificate"); } this.certificate = certificate; pubKey = certificate.getPublicKey(); @@ -48,18 +48,18 @@ public ApolloCertificate(X509Certificate certificate) throws ApolloCertificateEx issuer_attr.setSubjectStr(certificate.getIssuerX500Principal().toString()); } - public static ApolloCertificate loadPEMFromPath(String path) throws ApolloCertificateException, IOException { - ApolloCertificate res = null; + public static CertHelper loadPEMFromPath(String path) throws CertException, IOException { + CertHelper res = null; try (FileInputStream fis = new FileInputStream(path)) { - res = ApolloCertificate.loadPEMFromStream(fis); + res = CertHelper.loadPEMFromStream(fis); } return res; } - public static ApolloCertificate loadPEMFromStream(InputStream is) throws IOException, ApolloCertificateException { + public static CertHelper loadPEMFromStream(InputStream is) throws IOException, CertException { KeyReader kr = new KeyReaderImpl(); X509Certificate cert = kr.readX509CertPEMorDER(is); - ApolloCertificate ac = new ApolloCertificate(cert); + CertHelper ac = new CertHelper(cert); return ac; } @@ -135,7 +135,7 @@ public String getPEM() { try { res = kw.getX509CertificatePEM(certificate); } catch (IOException ex) { - java.util.logging.Logger.getLogger(ApolloCertificate.class.getName()).log(Level.SEVERE, null, ex); + java.util.logging.Logger.getLogger(CertHelper.class.getName()).log(Level.SEVERE, null, ex); } return res; } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java index 9225ab0e13..7b97318c4f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java @@ -23,7 +23,7 @@ public class CertKeyDirs { public static final String PVT_SEARCH_PATH = "private/"; private static final Logger log = LoggerFactory.getLogger(CertKeyDirs.class); - private final Map> certMap = new TreeMap<>(); + private final Map> certMap = new TreeMap<>(); public static final String[] sfxes = {"_pvtkey", "_req", "_cert", "_selfcert", "_csr"}; public static String rmSuffixes(String fn) { @@ -69,12 +69,12 @@ public static String csrFileName(String fn) { return name + suffix + ".pem"; } - public List getCert(BigInteger id) { + public List getCert(BigInteger id) { return certMap.get(id); } - public void put(BigInteger id, ApolloCertificate cert) { - List cl = certMap.get(id); + public void put(BigInteger id, CertHelper cert) { + List cl = certMap.get(id); if (cl == null) { cl = new ArrayList<>(); } @@ -92,12 +92,12 @@ public void readCertDirectory(String path, boolean loadPrivateKey) { File[] filesList = dir.listFiles(); for (File f : filesList) { if (f.isFile() && f.canRead()) { - ApolloCertificate ac = null; + CertHelper ac = null; try { - ac = ApolloCertificate.loadPEMFromPath(f.getAbsolutePath()); + ac = CertHelper.loadPEMFromPath(f.getAbsolutePath()); } catch (IOException ex) { //impossible here - } catch (ApolloCertificateException ex) { + } catch (CertException ex) { log.error("Certificate load exception wilr loading " + f.getAbsolutePath(), ex); } if (ac != null) { diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java index 49938b4546..a1b4b4cb0d 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java @@ -4,7 +4,6 @@ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.ApolloCertificate; import java.security.cert.X509Certificate; @@ -14,6 +13,6 @@ */ public interface IdValidator { void addTrustedSignerCert(X509Certificate cert); - boolean isSelfSigned(ApolloCertificate cert); - boolean isTrusted(ApolloCertificate cert); + boolean isSelfSigned(X509Certificate cert); + boolean isTrusted(X509Certificate cert); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java index ec98e9bd84..57eb18d065 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java @@ -3,7 +3,7 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.CertHelper; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; @@ -18,15 +18,17 @@ public class IdValidatorImpl implements IdValidator{ private final List trustedSigners = new ArrayList<>(); @Override - public boolean isSelfSigned(ApolloCertificate cert) { + public boolean isSelfSigned(X509Certificate cert) { return false; } + @Override - public boolean isTrusted(ApolloCertificate cert) { + public boolean isTrusted(X509Certificate cert) { boolean res = false; + CertHelper ac = new CertHelper(cert); for(X509Certificate signerCert: trustedSigners){ - res = cert.isSignedBy(signerCert); + res = ac.isSignedBy(signerCert); if(res){ break; } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java index 641d8ec013..6d7e1b880f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java @@ -3,7 +3,7 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.CertHelper; import java.math.BigInteger; /** @@ -12,7 +12,7 @@ */ public interface ThisActorIdHandler { BigInteger getApolloId(); - ApolloCertificate getCertificate(); + CertHelper getCertificate(); byte[] sign(byte[] message); - ApolloCertificate generateSelfSignedCert(); + CertHelper generateSelfSignedCert(); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java index 800feb462c..9fa7b892cb 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java @@ -3,7 +3,7 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.CertHelper; import io.firstbridge.cryptolib.AsymKeysHolder; import io.firstbridge.cryptolib.CryptoFactory; import io.firstbridge.cryptolib.CryptoNotValidException; @@ -20,7 +20,7 @@ public class ThisActorIdHandlerImpl implements ThisActorIdHandler { BigInteger myApolloId; KeyPair myKeys; - ApolloCertificate myCert; + CertHelper myCert; CryptoFactory cryptoFactory; @Override @@ -29,7 +29,7 @@ public BigInteger getApolloId() { } @Override - public ApolloCertificate getCertificate() { + public CertHelper getCertificate() { return myCert; } @@ -48,7 +48,7 @@ public byte[] sign(byte[] message) { } @Override - public ApolloCertificate generateSelfSignedCert() { + public CertHelper generateSelfSignedCert() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } diff --git a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java index a7d5c03019..2f6b7f5b06 100644 --- a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java +++ b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java @@ -21,7 +21,7 @@ public class ApolloCertificateTest { private static final CryptoParams params = CryptoConfig.createDefaultParams(); private static final org.slf4j.Logger log = LoggerFactory.getLogger(ApolloCertificateTest.class); - static ApolloCertificate acert; + static CertHelper acert; public ApolloCertificateTest() { } @@ -29,10 +29,10 @@ public ApolloCertificateTest() { @BeforeAll public static void setUpClass() { try (InputStream is = ApolloCertificateTest.class.getClassLoader().getResourceAsStream("test_cert.pem")) { - acert = ApolloCertificate.loadPEMFromStream(is); + acert = CertHelper.loadPEMFromStream(is); } catch (IOException ex) { log.error("Can not load test certificate ", ex); - } catch (ApolloCertificateException ex) { + } catch (CertException ex) { log.error("can not parse test certificate", ex); } } From 790d806fa5d07edd7d0cbc86915b0668696be64b Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 4 Sep 2020 15:26:09 +0300 Subject: [PATCH 11/42] Better class and method names --- .../apl/id/cert/AuthorityID.java | 12 ++--- .../apollocurrency/apl/id/cert/CSRHelper.java | 48 +++++++++---------- ...tificateTest.java => CertificateTest.java} | 11 ++--- 3 files changed, 33 insertions(+), 38 deletions(-) rename apl-id/src/test/java/com/apollocurrency/apl/id/cert/{ApolloCertificateTest.java => CertificateTest.java} (92%) diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java index c7d651c7ff..1405a7a810 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java @@ -8,7 +8,7 @@ import java.util.Arrays; /** - * Apollo AUthority ID is set of bits that classifies Apollo crypto actors and + * AUthority ID is set of bits that classifies crypto actors and * actor's capabilities. * Bytes meaning. Les's number each of 16 bytes as following: * 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 @@ -78,7 +78,7 @@ public BigInteger getAuthorityID() { * * @return 2 bytes of ActorType wrapped to 4 bytes of int */ - public int getActorType() { + public int getActorTypeAsInt() { int res = authorityID[0] << 8 | authorityID[1]; return res; } @@ -101,8 +101,8 @@ public void setActorType(int at) { * * @return ActorType and ActorSubType wrapped in ActorType class */ - public ActorType getApolloActorType() { - return new ActorType(getActorType()); + public ActorType getActorType() { + return new ActorType(getActorTypeAsInt()); } /** @@ -111,8 +111,8 @@ public ActorType getApolloActorType() { * * @param vat ActorType class hat wraps those 2 bytes */ - public void setApolloActorType(ActorType vat) { - setActorType(vat.getValue()); + public void setActorType(ActorType vat) { + AuthorityID.this.setActorType(vat.getValue()); } /** diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java index bc9e5d257b..1a21d8b93d 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java @@ -25,7 +25,7 @@ import java.security.cert.X509Certificate; /** - * Certificate signing request with Apollo-specific attributes + * Certificate signing request with additional identity-specific attributes * * @author alukin@gmail.com */ @@ -34,13 +34,13 @@ public class CSRHelper extends CertBase { private static final Logger log = LoggerFactory.getLogger(CSRHelper.class); private final CertificateRequestData csrData = new CertificateRequestData(CertificateRequestData.CSRType.HOST); private String challengePassword = ""; - private BigInteger apolloID; - private AuthorityID apolloAuthID; + private BigInteger actorID; + private AuthorityID authorityID; private final KeyWriter kw; public CSRHelper() { - apolloID = new BigInteger(128, new SecureRandom()); - apolloAuthID = new AuthorityID(); + actorID = new BigInteger(128, new SecureRandom()); + authorityID = new AuthorityID(); kw = factory.getKeyWriter(); } @@ -64,8 +64,8 @@ public static CSRHelper fromPKCS10(PKCS10CertificationRequest cr) { va.setSubject(cr.getSubject()); va.setAttributes(cr.getAttributes()); res.setCN(va.getCn()); - res.setAuthID(va.getAuthorityId()); - res.setApolloID(va.getApolloId()); + res.setAuthorityId(va.getAuthorityId()); + res.setActorId(va.getApolloId()); res.setCountry(va.getCountry()); res.setState(va.getState()); res.setCity(va.getCity()); @@ -84,12 +84,12 @@ public static CSRHelper fromPKCS10(PKCS10CertificationRequest cr) { public static CSRHelper fromCertificate(CertHelper cert) { CSRHelper res = new CSRHelper(); - res.setApolloAuthorityID(cert.getAuthorityId().getAuthorityID()); + res.setAuthorityId(cert.getAuthorityId().getAuthorityID()); BigInteger vid = cert.getApolloId(); if (vid == null || vid == BigInteger.ZERO) { vid = new BigInteger(128, new SecureRandom()); } - res.setApolloID(vid); + res.setActorId(vid); res.setCN(cert.getCN()); res.setEmail(cert.getEmail()); res.setOrg(cert.getOrganization()); @@ -129,30 +129,26 @@ public static boolean isVaidDNSNameList(String nameList) { return res; } - public BigInteger getApolloID() { - return apolloID; + public BigInteger getActorId() { + return actorID; } - public void setApolloID(BigInteger id) { - apolloID = id; - csrData.setSubjectAttribute("UID", apolloID.toString(16)); + public void setActorId(BigInteger id) { + actorID = id; + csrData.setSubjectAttribute("UID", actorID.toString(16)); } - public AuthorityID getApolloAuthorityID() { - return apolloAuthID; + public AuthorityID getAuthorityId() { + return authorityID; } - public void setApolloAuthorityID(BigInteger id) { - apolloAuthID = new AuthorityID(id); - csrData.setSubjectAttribute("businessCategory", apolloAuthID.getAuthorityID().toString(16)); + public void setAuthorityId(BigInteger id) { + authorityID = new AuthorityID(id); + csrData.setSubjectAttribute("businessCategory", authorityID.getAuthorityID().toString(16)); } - public AuthorityID getAuthID() { - return apolloAuthID; - } - - public void setAuthID(AuthorityID authID) { - this.apolloAuthID = authID; + public void setAuthorityId(AuthorityID authID) { + this.authorityID = authID; csrData.setSubjectAttribute("businessCategory", authID.getAuthorityID().toString(16)); } @@ -306,7 +302,7 @@ public String getSelfSignedX509PEM() { public String toString() { String res = "X.509 Certificate:\n"; res += "CN=" + getCN() + "\n" - + "ApolloID=" + getApolloID().toString(16) + "\n"; + + "ActorID=" + getActorId().toString(16) + "\n"; res += "emailAddress=" + getEmial() + "\n"; res += "Country=" + getCountry() + " State/Province=" + getState() + " City=" + getCity(); diff --git a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java similarity index 92% rename from apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java rename to apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java index 2f6b7f5b06..7d2d5b4b82 100644 --- a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/ApolloCertificateTest.java +++ b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java @@ -17,18 +17,17 @@ /** * @author alukin@gmail.com */ -public class ApolloCertificateTest { +public class CertificateTest { - private static final CryptoParams params = CryptoConfig.createDefaultParams(); - private static final org.slf4j.Logger log = LoggerFactory.getLogger(ApolloCertificateTest.class); + private static final org.slf4j.Logger log = LoggerFactory.getLogger(CertificateTest.class); static CertHelper acert; - public ApolloCertificateTest() { + public CertificateTest() { } @BeforeAll public static void setUpClass() { - try (InputStream is = ApolloCertificateTest.class.getClassLoader().getResourceAsStream("test_cert.pem")) { + try (InputStream is = CertificateTest.class.getClassLoader().getResourceAsStream("test_cert.pem")) { acert = CertHelper.loadPEMFromStream(is); } catch (IOException ex) { log.error("Can not load test certificate ", ex); @@ -43,7 +42,7 @@ public static void setUpClass() { @Test public void testGetAuthorityId() { AuthorityID result = acert.getAuthorityId(); - assertEquals(5139, result.getActorType()); + assertEquals(5139, result.getActorTypeAsInt()); } /** From 90b5ec80e53b0e16498469f41983cedb5d1a3e62 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 4 Sep 2020 16:33:42 +0300 Subject: [PATCH 12/42] Id handler injected in peer http server --- .../apl/core/peer/PeerHttpServer.java | 13 ++++++++- .../aplwallet/apl/core/peer/PeersService.java | 4 +++ .../messages/update/CertificateLoader.java | 14 +++++----- .../update/CertificateMemoryStore.java | 10 +++---- .../apl/id/cert/AuthorityID.java | 27 ++++++++++++++++--- .../apl/id/cert/CertHelper.java | 4 +-- .../apl/id/handler/ThisActorIdHandler.java | 4 +-- .../id/handler/ThisActorIdHandlerImpl.java | 4 +-- .../apl/id/cert/CertificateTest.java | 4 +-- 9 files changed, 60 insertions(+), 24 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java index 39a9772d36..a2206863ce 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java @@ -3,6 +3,7 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; +import com.apollocurrency.apl.id.handler.ThisActorIdHandler; import com.apollocurrency.aplwallet.apl.core.app.runnable.TaskDispatchManager; import com.apollocurrency.aplwallet.apl.core.http.JettyConnectorCreator; import com.apollocurrency.aplwallet.apl.crypto.Convert; @@ -32,6 +33,7 @@ import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; import static org.slf4j.LoggerFactory.getLogger; @@ -62,9 +64,17 @@ public class PeerHttpServer { private PeerServlet peerServlet; private TaskDispatchManager taskDispatchManager; private List p2pPortHolders = new ArrayList<>(); + @Getter + private ThisActorIdHandler myIdHandler; @Inject - public PeerHttpServer(PropertiesHolder propertiesHolder, UPnP upnp, JettyConnectorCreator conCreator, TaskDispatchManager taskDispatchManager) { + public PeerHttpServer( + PropertiesHolder propertiesHolder, UPnP upnp, + JettyConnectorCreator conCreator, + TaskDispatchManager taskDispatchManager, + ThisActorIdHandler myIdHandler + ) + { this.upnp = upnp; this.taskDispatchManager = taskDispatchManager; shareMyAddress = propertiesHolder.getBooleanProperty("apl.shareMyAddress") && !propertiesHolder.isOffline(); @@ -76,6 +86,7 @@ public PeerHttpServer(PropertiesHolder propertiesHolder, UPnP upnp, JettyConnect if (platform.length() > MAX_PLATFORM_LENGTH) { platform = platform.substring(0, MAX_PLATFORM_LENGTH); } + this.myIdHandler=myIdHandler; myPlatform = platform; enablePeerUPnP = propertiesHolder.getBooleanProperty("apl.enablePeerUPnP"); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index d0a586af25..667b7bdf17 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -19,6 +19,7 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; +import com.apollocurrency.apl.id.handler.ThisActorIdHandler; import com.apollocurrency.aplwallet.api.p2p.PeerInfo; import com.apollocurrency.aplwallet.apl.core.app.runnable.TaskDispatchManager; import com.apollocurrency.aplwallet.apl.core.app.runnable.limiter.TimeLimiterService; @@ -75,6 +76,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; +import org.eclipse.jetty.client.HttpSender; @Singleton public class PeersService { @@ -402,6 +404,8 @@ private void fillMyPeerInfo() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); + ThisActorIdHandler myId = peerHttpServer.getMyIdHandler(); + pi.setX509_cert(myId.getCertHelper().getCertPEM()); myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); myPI = pi; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java index 39a09085b6..90dd3b9c00 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; import com.apollocurrency.aplwallet.apl.util.Version; -import com.apollocurrency.apl.id.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.CertHelper; import lombok.extern.slf4j.Slf4j; import java.io.IOException; @@ -32,9 +32,9 @@ public CertificateLoader(Class tClass, Version appVersion) { this.version = appVersion; } - public List loadAll() throws IOException { + public List loadAll() throws IOException { Path rootPath = Paths.get(loadClass.getProtectionDomain().getCodeSource().getLocation().getPath()); - List certs = new ArrayList<>(); + List certs = new ArrayList<>(); Path fsPath = null; if (rootPath.toUri().getScheme().equals("jar")) { fsPath = rootPath; @@ -53,13 +53,13 @@ public List loadAll() throws IOException { return certs; } - private List readAll(Path path) throws IOException { - List certs = new ArrayList<>(); + private List readAll(Path path) throws IOException { + List certs = new ArrayList<>(); Files.walkFileTree(path.resolve("certs"), new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { try { - ApolloCertificate cert = ApolloCertificate.loadPEMFromPath(file.toAbsolutePath().toString()); + CertHelper cert = CertHelper.loadPEMFromPath(file.toAbsolutePath().toString()); certs.add(cert); } catch (Exception e) { @@ -71,7 +71,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO return certs; } - private List readAllFromFs(Path path) throws IOException { + private List readAllFromFs(Path path) throws IOException { try (FileSystem fileSystem = FileSystems.newFileSystem(path, ClassLoader.getSystemClassLoader())) { return readAll(fileSystem.getPath("/")); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java index 290a0dd53d..e3e87da188 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; import com.apollocurrency.aplwallet.apl.core.config.Property; -import com.apollocurrency.apl.id.cert.ApolloCertificate; +import com.apollocurrency.apl.id.cert.CertHelper; import io.firstbridge.cryptolib.CryptoFactory; import java.io.IOException; import lombok.extern.slf4j.Slf4j; @@ -24,7 +24,7 @@ public class CertificateMemoryStore { private CertificateLoader loader; - private Map certificates = new HashMap<>(); + private Map certificates = new HashMap<>(); private final URL caCertUrl; @Inject @@ -36,7 +36,7 @@ public CertificateMemoryStore(@Property("updater.ca.cert-url") String caCertUrl, @PostConstruct void init() { - List all = null; + List all = null; try { all = loader.loadAll(); } catch (Exception e) { @@ -49,7 +49,7 @@ void init() { log.debug("Error readX509 CertPEMorDER", e); } if (all != null) { - for (ApolloCertificate apolloCertificate : all) { + for (CertHelper apolloCertificate : all) { if (rootCert != null && !apolloCertificate.verify(rootCert)) { throw new IllegalStateException("Certificate is not valid, ca signature verification failed for " + apolloCertificate); } @@ -61,7 +61,7 @@ void init() { } } - public ApolloCertificate getBySn(BigInteger sn) { + public CertHelper getBySn(BigInteger sn) { return certificates.get(sn); } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java index 1405a7a810..be873b65c1 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java @@ -6,6 +6,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.Arrays; +import java.util.UUID; /** * AUthority ID is set of bits that classifies crypto actors and @@ -201,14 +202,34 @@ public Long getSuplementalCode() { return res; } - public void setSuplementalCode(long oc) { - ByteBuffer bb = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putLong(oc); + public void setSuplementalCode(long sc) { + ByteBuffer bb = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putLong(sc); authorityID[12] = bb.get(4); authorityID[13] = bb.get(5); authorityID[14] = bb.get(6); authorityID[15] = bb.get(7); } - + + /** + * Gets network Id declared in certificate's filed AuthorityID + * All authorization bits of certificate could be bound to one network only + * So part of AuthorityID of any trusted certificate id 128-bit long network Id + * @return Network ID as UUID + */ + public byte[] getNetId(){ + //TODO: implement + return null; + } + + /** + * Sets network Id declared in certificate's filed AuthorityID + * All authorization bits of certificate could be bound to one network only + * So part of AuthorityID of any trusted certificate id 128-bit long network Id + */ + public void setNetId(byte[] id){ + //TODO: implement + } + @Override public boolean equals(Object obj) { if (obj == null) { diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java index 329a664ef4..7b40bb3f0c 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java @@ -116,7 +116,7 @@ public String getEmail() { @Override public String toString() { - String res = "Apollo X.509 Certificate:\n"; + String res = "X.509 Certificate:\n"; res += "CN=" + cert_attr.getCn() + "\n" + "ApolloID=" + getApolloId().toString(16) + "\n"; @@ -129,7 +129,7 @@ public String toString() { return res; } - public String getPEM() { + public String getCertPEM() { KeyWriter kw = new KeyWriterImpl(); String res=""; try { diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java index 6d7e1b880f..64b6d1bb7e 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java @@ -11,8 +11,8 @@ * @author alukin@gmail.com */ public interface ThisActorIdHandler { - BigInteger getApolloId(); - CertHelper getCertificate(); + BigInteger getActorId(); + CertHelper getCertHelper(); byte[] sign(byte[] message); CertHelper generateSelfSignedCert(); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java index 9fa7b892cb..b8212e432f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java @@ -24,12 +24,12 @@ public class ThisActorIdHandlerImpl implements ThisActorIdHandler { CryptoFactory cryptoFactory; @Override - public BigInteger getApolloId() { + public BigInteger getActorId() { return myApolloId; } @Override - public CertHelper getCertificate() { + public CertHelper getCertHelper() { return myCert; } diff --git a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java index 7d2d5b4b82..d4b7c26ff3 100644 --- a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java +++ b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java @@ -145,11 +145,11 @@ public void testGetEmail() { } /** - * Test of getPEM method, of class ApolloCertificate. + * Test of getCertPEM method, of class ApolloCertificate. */ @Test public void testGetPEM() { - String result = acert.getPEM(); + String result = acert.getCertPEM(); assertEquals(true, result.startsWith("-----BEGIN CERTIFICATE----")); } From c8ec12ebcd9b850250c502301f318a4f1b65e64d Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 7 Sep 2020 15:42:32 +0300 Subject: [PATCH 13/42] better structure of identity handling --- .../apl/core/peer/PeerHttpServer.java | 14 ++--- .../aplwallet/apl/core/peer/PeersService.java | 14 +++-- .../apl/core/peer/id/IdentityService.java | 21 +++++++ .../apl/core/peer/id/IdentityServiceImpl.java | 54 ++++++++++++++++++ .../messages/update/CertificateLoader.java | 15 ++--- .../update/CertificateMemoryStore.java | 10 ++-- .../apl/id/cert/CertAttributes.java | 2 +- ...rtKeyDirs.java => CertKeyPersistence.java} | 55 +++++++++++++++---- .../id/cert/{CSRHelper.java => ExtCSR.java} | 38 ++++++------- .../apl/id/cert/ExtCSRFactory.java | 9 +++ .../id/cert/{CertHelper.java => ExtCert.java} | 39 +++++-------- .../apl/id/handler/IdValidatorImpl.java | 7 ++- .../apl/id/handler/ThisActorIdHandler.java | 9 ++- .../id/handler/ThisActorIdHandlerImpl.java | 40 ++++++++++++-- .../apl/id/cert/CertificateTest.java | 6 +- 15 files changed, 235 insertions(+), 98 deletions(-) create mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java create mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{CertKeyDirs.java => CertKeyPersistence.java} (71%) rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{CSRHelper.java => ExtCSR.java} (90%) create mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java rename apl-id/src/main/java/com/apollocurrency/apl/id/cert/{CertHelper.java => ExtCert.java} (79%) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java index a2206863ce..2032d761a6 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java @@ -59,20 +59,18 @@ public class PeerHttpServer { private final int idleTimeout; boolean shareMyAddress = false; boolean enablePeerUPnP; - private int myPeerServerPort; + private final int myPeerServerPort; private PeerAddress myExtAddress; private PeerServlet peerServlet; - private TaskDispatchManager taskDispatchManager; - private List p2pPortHolders = new ArrayList<>(); - @Getter - private ThisActorIdHandler myIdHandler; + private final TaskDispatchManager taskDispatchManager; + private final List p2pPortHolders = new ArrayList<>(); + @Inject public PeerHttpServer( PropertiesHolder propertiesHolder, UPnP upnp, JettyConnectorCreator conCreator, - TaskDispatchManager taskDispatchManager, - ThisActorIdHandler myIdHandler + TaskDispatchManager taskDispatchManager ) { this.upnp = upnp; @@ -86,7 +84,7 @@ public PeerHttpServer( if (platform.length() > MAX_PLATFORM_LENGTH) { platform = platform.substring(0, MAX_PLATFORM_LENGTH); } - this.myIdHandler=myIdHandler; + myPlatform = platform; enablePeerUPnP = propertiesHolder.getBooleanProperty("apl.enablePeerUPnP"); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 667b7bdf17..01046ead9c 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -28,6 +28,7 @@ import com.apollocurrency.aplwallet.apl.core.entity.blockchain.Transaction; import com.apollocurrency.aplwallet.apl.core.http.API; import com.apollocurrency.aplwallet.apl.core.http.APIEnum; +import com.apollocurrency.aplwallet.apl.core.peer.id.IdentityService; import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import com.apollocurrency.aplwallet.apl.core.service.blockchain.BlockSerializer; import com.apollocurrency.aplwallet.apl.core.service.blockchain.Blockchain; @@ -158,13 +159,15 @@ public class PeersService { private BlockchainProcessor blockchainProcessor; private volatile TimeService timeService; private final BlockSerializer blockSerializer; - + private IdentityService identityService; + @Inject public PeersService(PropertiesHolder propertiesHolder, BlockchainConfig blockchainConfig, Blockchain blockchain, TimeService timeService, TaskDispatchManager taskDispatchManager, PeerHttpServer peerHttpServer, TimeLimiterService timeLimiterService, AccountService accountService, TransactionSerializer serializer, - BlockSerializer blockSerializer) { + BlockSerializer blockSerializer, + IdentityService identityService) { this.propertiesHolder = propertiesHolder; this.blockchainConfig = blockchainConfig; this.blockchain = blockchain; @@ -174,7 +177,8 @@ public PeersService(PropertiesHolder propertiesHolder, BlockchainConfig blockcha this.timeLimiterService = timeLimiterService; this.accountService = accountService; this.blockSerializer = blockSerializer; - + this.identityService = identityService; + isLightClient = propertiesHolder.isLightClient(); this.serializer = serializer; } @@ -285,7 +289,7 @@ public void init() { }), AccountEventType.BALANCE);*/ configureBackgroundTasks(); - + identityService.loadAll(); peerHttpServer.start(); } @@ -404,7 +408,7 @@ private void fillMyPeerInfo() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); - ThisActorIdHandler myId = peerHttpServer.getMyIdHandler(); + ThisActorIdHandler myId = identityService.getThisNodeIdHandler(); pi.setX509_cert(myId.getCertHelper().getCertPEM()); myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java new file mode 100644 index 0000000000..40cb9dd325 --- /dev/null +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2018-2020. Apollo Foundation. + */ +package com.apollocurrency.aplwallet.apl.core.peer.id; + +import com.apollocurrency.apl.id.handler.IdValidator; +import com.apollocurrency.apl.id.handler.ThisActorIdHandler; + +/** + * Service that handles identity of peers using X.509 certificates od nodes + * @author alukin@gmail.com + */ +public interface IdentityService { + + ThisActorIdHandler getThisNodeIdHandler(); + IdValidator getPeerIdValidator(); + /** + * Load all available certificates and keys from defined directories/resources + */ + void loadAll(); +} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java new file mode 100644 index 0000000000..9b644e3d40 --- /dev/null +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018-2020. Apollo Foundation. + */ +package com.apollocurrency.aplwallet.apl.core.peer.id; + +import com.apollocurrency.apl.id.handler.IdValidator; +import com.apollocurrency.apl.id.handler.IdValidatorImpl; +import com.apollocurrency.apl.id.handler.ThisActorIdHandler; +import com.apollocurrency.apl.id.handler.ThisActorIdHandlerImpl; +import com.apollocurrency.aplwallet.apl.util.env.dirprovider.ConfigDirProvider; +import java.io.File; +import javax.inject.Inject; + +/** + * Identity service implementation + * + * @author alukin@gmail.com + */ +public class IdentityServiceImpl implements IdentityService { + + private final ThisActorIdHandler thisNodeIdHandler; + private final IdValidator peerIdValidator; + private final ConfigDirProvider dirProvider; + + @Inject + public IdentityServiceImpl(ConfigDirProvider dirProvider) { + this.thisNodeIdHandler = new ThisActorIdHandlerImpl(); + this.peerIdValidator = new IdValidatorImpl(); + this.dirProvider = dirProvider; + } + + @Override + public ThisActorIdHandler getThisNodeIdHandler() { + return thisNodeIdHandler; + } + + @Override + public IdValidator getPeerIdValidator() { + return peerIdValidator; + } + + @Override + public void loadAll() { + String confName = dirProvider.getConfigName(); + String[] confLocations = {dirProvider.getInstallationConfigLocation(), + dirProvider.getSysConfigLocation(), + dirProvider.getUserConfigLocation()}; + for (String loc : confLocations) { + String path = loc + File.separator + confName; + System.out.println("========= " + path); + } + } + +} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java index 90dd3b9c00..4965b0fdd0 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java @@ -1,7 +1,8 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; +import com.apollocurrency.apl.id.cert.CertKeyPersistence; import com.apollocurrency.aplwallet.apl.util.Version; -import com.apollocurrency.apl.id.cert.CertHelper; +import com.apollocurrency.apl.id.cert.ExtCert; import lombok.extern.slf4j.Slf4j; import java.io.IOException; @@ -32,9 +33,9 @@ public CertificateLoader(Class tClass, Version appVersion) { this.version = appVersion; } - public List loadAll() throws IOException { + public List loadAll() throws IOException { Path rootPath = Paths.get(loadClass.getProtectionDomain().getCodeSource().getLocation().getPath()); - List certs = new ArrayList<>(); + List certs = new ArrayList<>(); Path fsPath = null; if (rootPath.toUri().getScheme().equals("jar")) { fsPath = rootPath; @@ -53,13 +54,13 @@ public List loadAll() throws IOException { return certs; } - private List readAll(Path path) throws IOException { - List certs = new ArrayList<>(); + private List readAll(Path path) throws IOException { + List certs = new ArrayList<>(); Files.walkFileTree(path.resolve("certs"), new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { try { - CertHelper cert = CertHelper.loadPEMFromPath(file.toAbsolutePath().toString()); + ExtCert cert = CertKeyPersistence.loadPEMFromPath(file.toAbsolutePath()); certs.add(cert); } catch (Exception e) { @@ -71,7 +72,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO return certs; } - private List readAllFromFs(Path path) throws IOException { + private List readAllFromFs(Path path) throws IOException { try (FileSystem fileSystem = FileSystems.newFileSystem(path, ClassLoader.getSystemClassLoader())) { return readAll(fileSystem.getPath("/")); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java index e3e87da188..274d5a84e3 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; import com.apollocurrency.aplwallet.apl.core.config.Property; -import com.apollocurrency.apl.id.cert.CertHelper; +import com.apollocurrency.apl.id.cert.ExtCert; import io.firstbridge.cryptolib.CryptoFactory; import java.io.IOException; import lombok.extern.slf4j.Slf4j; @@ -24,7 +24,7 @@ public class CertificateMemoryStore { private CertificateLoader loader; - private Map certificates = new HashMap<>(); + private Map certificates = new HashMap<>(); private final URL caCertUrl; @Inject @@ -36,7 +36,7 @@ public CertificateMemoryStore(@Property("updater.ca.cert-url") String caCertUrl, @PostConstruct void init() { - List all = null; + List all = null; try { all = loader.loadAll(); } catch (Exception e) { @@ -49,7 +49,7 @@ void init() { log.debug("Error readX509 CertPEMorDER", e); } if (all != null) { - for (CertHelper apolloCertificate : all) { + for (ExtCert apolloCertificate : all) { if (rootCert != null && !apolloCertificate.verify(rootCert)) { throw new IllegalStateException("Certificate is not valid, ca signature verification failed for " + apolloCertificate); } @@ -61,7 +61,7 @@ void init() { } } - public CertHelper getBySn(BigInteger sn) { + public ExtCert getBySn(BigInteger sn) { return certificates.get(sn); } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java index d1eefde902..79aff3eda5 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java @@ -69,7 +69,7 @@ public void setSubjectStr(String name) throws CertException { } } - public BigInteger getApolloId() { + public BigInteger getActorId() { return apolloId; } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java similarity index 71% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java index 7b97318c4f..04f1824774 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyDirs.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java @@ -7,23 +7,29 @@ import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.math.BigInteger; +import java.nio.file.Path; import java.security.PrivateKey; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.bouncycastle.openssl.PEMParser; +import org.bouncycastle.pkcs.PKCS10CertificationRequest; /** - * Handler of certificate, CSR and key names and directories placed in map with ID as a key + * Handler of certificate, ExtCSR and key names and directories placed in map with ID as a key * * @author alukin@gmail.com */ -public class CertKeyDirs { +public class CertKeyPersistence { public static final String PVT_SEARCH_PATH = "private/"; - private static final Logger log = LoggerFactory.getLogger(CertKeyDirs.class); - private final Map> certMap = new TreeMap<>(); + private static final Logger log = LoggerFactory.getLogger(CertKeyPersistence.class); + private final Map> certMap = new TreeMap<>(); public static final String[] sfxes = {"_pvtkey", "_req", "_cert", "_selfcert", "_csr"}; public static String rmSuffixes(String fn) { @@ -69,12 +75,12 @@ public static String csrFileName(String fn) { return name + suffix + ".pem"; } - public List getCert(BigInteger id) { + public List getCert(BigInteger id) { return certMap.get(id); } - public void put(BigInteger id, CertHelper cert) { - List cl = certMap.get(id); + public void put(BigInteger id, ExtCert cert) { + List cl = certMap.get(id); if (cl == null) { cl = new ArrayList<>(); } @@ -92,16 +98,16 @@ public void readCertDirectory(String path, boolean loadPrivateKey) { File[] filesList = dir.listFiles(); for (File f : filesList) { if (f.isFile() && f.canRead()) { - CertHelper ac = null; + ExtCert ac = null; try { - ac = CertHelper.loadPEMFromPath(f.getAbsolutePath()); + ac = loadPEMFromPath(f.toPath()); } catch (IOException ex) { //impossible here } catch (CertException ex) { log.error("Certificate load exception wilr loading " + f.getAbsolutePath(), ex); } if (ac != null) { - put(ac.getApolloId(), ac); + put(ac.getActorId(), ac); if (loadPrivateKey) { String parent = f.getParent(); String fn = f.getName(); @@ -138,4 +144,33 @@ public PrivateKey readPvtKey(String filePath) { } return res; } + + public static ExtCert loadPEMFromPath(Path path) throws CertException, IOException { + ExtCert res = null; + try (FileInputStream fis = new FileInputStream(path.toString())) { + res = loadPEMFromStream(fis); + } + return res; + } + + public static ExtCert loadPEMFromStream(InputStream is) throws IOException, CertException { + KeyReader kr = new KeyReaderImpl(); + X509Certificate cert = kr.readX509CertPEMorDER(is); + ExtCert ac = new ExtCert(cert); + //try to load corresponding key + return ac; + } + + public static ExtCSR loadCSR(String path) { + PKCS10CertificationRequest cr; + ExtCSR res = null; + try (FileReader fr = new FileReader(path)) { + PEMParser parser = new PEMParser(fr); + cr = (PKCS10CertificationRequest) parser.readObject(); + res = ExtCSR.fromPKCS10(cr); + } catch (IOException ex) { + log.error("Can not read PKCS#10 file: " + path, ex); + } + return res; + } } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java similarity index 90% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java index 1a21d8b93d..0a446c388b 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CSRHelper.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java @@ -23,49 +23,43 @@ import java.security.KeyPair; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import java.util.Properties; /** * Certificate signing request with additional identity-specific attributes * * @author alukin@gmail.com */ -public class CSRHelper extends CertBase { +public class ExtCSR extends CertBase { - private static final Logger log = LoggerFactory.getLogger(CSRHelper.class); + private static final Logger log = LoggerFactory.getLogger(ExtCSR.class); private final CertificateRequestData csrData = new CertificateRequestData(CertificateRequestData.CSRType.HOST); private String challengePassword = ""; private BigInteger actorID; private AuthorityID authorityID; private final KeyWriter kw; - public CSRHelper() { + public ExtCSR() { actorID = new BigInteger(128, new SecureRandom()); authorityID = new AuthorityID(); kw = factory.getKeyWriter(); } - - public static CSRHelper loadCSR(String path) { - PKCS10CertificationRequest cr; - CSRHelper res = null; - try (FileReader fr = new FileReader(path)) { - PEMParser parser = new PEMParser(fr); - cr = (PKCS10CertificationRequest) parser.readObject(); - res = CSRHelper.fromPKCS10(cr); - } catch (IOException ex) { - log.error("Can not read PKCS#10 file: " + path, ex); - } + + public static ExtCSR newHostCSR(Properties prop){ + ExtCSR res = new ExtCSR(); + //TODO: implement return res; } - public static CSRHelper fromPKCS10(PKCS10CertificationRequest cr) { - CSRHelper res = new CSRHelper(); + public static ExtCSR fromPKCS10(PKCS10CertificationRequest cr) { + ExtCSR res = new ExtCSR(); try { CertAttributes va = new CertAttributes(); va.setSubject(cr.getSubject()); va.setAttributes(cr.getAttributes()); res.setCN(va.getCn()); res.setAuthorityId(va.getAuthorityId()); - res.setActorId(va.getApolloId()); + res.setActorId(va.getActorId()); res.setCountry(va.getCountry()); res.setState(va.getState()); res.setCity(va.getCity()); @@ -82,10 +76,10 @@ public static CSRHelper fromPKCS10(PKCS10CertificationRequest cr) { return res; } - public static CSRHelper fromCertificate(CertHelper cert) { - CSRHelper res = new CSRHelper(); + public static ExtCSR fromCertificate(ExtCert cert) { + ExtCSR res = new ExtCSR(); res.setAuthorityId(cert.getAuthorityId().getAuthorityID()); - BigInteger vid = cert.getApolloId(); + BigInteger vid = cert.getActorId(); if (vid == null || vid == BigInteger.ZERO) { vid = new BigInteger(128, new SecureRandom()); } @@ -116,7 +110,7 @@ public static boolean isValidIPAddresList(String ipList) { return res; } - public static boolean isVaidDNSNameList(String nameList) { + public static boolean isValidDNSNameList(String nameList) { boolean res = true; String[] names = nameList.split(","); String pattern = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$"; @@ -196,7 +190,7 @@ public String getDNSNames() { public void setDNSNames(String n) { if (n != null && !n.isEmpty()) { - if (isVaidDNSNameList(n)) { + if (isValidDNSNameList(n)) { csrData.setExtendedAttribute("subjaltnames.dnsname", n); } else { throw new IllegalArgumentException("Invalid DNS name: " + n); diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java new file mode 100644 index 0000000000..989a15f9f9 --- /dev/null +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java @@ -0,0 +1,9 @@ +package com.apollocurrency.apl.id.cert; + +/** + * Factory for PKCS#10 CSR generation + * @author alukin@gmail.com + */ +public class ExtCSRFactory { + +} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java similarity index 79% rename from apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java index 7b40bb3f0c..93afad01a2 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertHelper.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java @@ -1,16 +1,12 @@ package com.apollocurrency.apl.id.cert; import com.apollocurrency.apl.id.utils.StringList; -import io.firstbridge.cryptolib.KeyReader; import io.firstbridge.cryptolib.KeyWriter; -import io.firstbridge.cryptolib.impl.KeyReaderImpl; import io.firstbridge.cryptolib.impl.KeyWriterImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.math.BigInteger; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; @@ -28,15 +24,18 @@ * * @author alukin@gmail.com */ -public class CertHelper extends CertBase { +public class ExtCert extends CertBase { - private static final Logger log = LoggerFactory.getLogger(CertHelper.class); + private static final Logger log = LoggerFactory.getLogger(ExtCert.class); private final X509Certificate certificate; private final CertAttributes cert_attr; private final CertAttributes issuer_attr; - public CertHelper(X509Certificate certificate) throws CertException { + + + + public ExtCert(X509Certificate certificate) throws CertException { if (certificate == null) { throw new CertException("Null certificate"); } @@ -48,23 +47,10 @@ public CertHelper(X509Certificate certificate) throws CertException { issuer_attr.setSubjectStr(certificate.getIssuerX500Principal().toString()); } - public static CertHelper loadPEMFromPath(String path) throws CertException, IOException { - CertHelper res = null; - try (FileInputStream fis = new FileInputStream(path)) { - res = CertHelper.loadPEMFromStream(fis); - } - return res; - } - - public static CertHelper loadPEMFromStream(InputStream is) throws IOException, CertException { - KeyReader kr = new KeyReaderImpl(); - X509Certificate cert = kr.readX509CertPEMorDER(is); - CertHelper ac = new CertHelper(cert); - return ac; - } - - public BigInteger getApolloId() { - return cert_attr.getApolloId(); + + + public BigInteger getActorId() { + return cert_attr.getActorId(); } public AuthorityID getAuthorityId() { @@ -118,7 +104,7 @@ public String getEmail() { public String toString() { String res = "X.509 Certificate:\n"; res += "CN=" + cert_attr.getCn() + "\n" - + "ApolloID=" + getApolloId().toString(16) + "\n"; + + "ApolloID=" + getActorId().toString(16) + "\n"; res += "emailAddress=" + getEmail() + "\n"; res += "Country=" + getCountry() + " State/Province=" + getStateOrProvince() @@ -135,7 +121,7 @@ public String getCertPEM() { try { res = kw.getX509CertificatePEM(certificate); } catch (IOException ex) { - java.util.logging.Logger.getLogger(CertHelper.class.getName()).log(Level.SEVERE, null, ex); + java.util.logging.Logger.getLogger(ExtCert.class.getName()).log(Level.SEVERE, null, ex); } return res; } @@ -180,4 +166,5 @@ public boolean isSelfSigned(){ public boolean isSignedBy(X509Certificate signerCert) { return verify(signerCert); } + } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java index 57eb18d065..11988ad86f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java @@ -3,7 +3,7 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.CertHelper; +import com.apollocurrency.apl.id.cert.ExtCert; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; @@ -17,6 +17,9 @@ public class IdValidatorImpl implements IdValidator{ private final List trustedSigners = new ArrayList<>(); + public IdValidatorImpl() { + } + @Override public boolean isSelfSigned(X509Certificate cert) { return false; @@ -26,7 +29,7 @@ public boolean isSelfSigned(X509Certificate cert) { @Override public boolean isTrusted(X509Certificate cert) { boolean res = false; - CertHelper ac = new CertHelper(cert); + ExtCert ac = new ExtCert(cert); for(X509Certificate signerCert: trustedSigners){ res = ac.isSignedBy(signerCert); if(res){ diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java index 64b6d1bb7e..15cf67002f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java @@ -3,8 +3,9 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.CertHelper; +import com.apollocurrency.apl.id.cert.ExtCert; import java.math.BigInteger; +import java.nio.file.Path; /** * Handles operations with X509 certificate and private key of this node @@ -12,7 +13,9 @@ */ public interface ThisActorIdHandler { BigInteger getActorId(); - CertHelper getCertHelper(); + ExtCert getCertHelper(); byte[] sign(byte[] message); - CertHelper generateSelfSignedCert(); + void generateSelfSignedCert(); + boolean loadCertAndKey(Path baseDir); + boolean saveAll(Path baseDir); } diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java index b8212e432f..3ecf14232f 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java @@ -3,13 +3,19 @@ */ package com.apollocurrency.apl.id.handler; -import com.apollocurrency.apl.id.cert.CertHelper; +import com.apollocurrency.apl.id.cert.ExtCSR; +import com.apollocurrency.apl.id.cert.CertException; +import com.apollocurrency.apl.id.cert.CertKeyPersistence; +import com.apollocurrency.apl.id.cert.ExtCert; import io.firstbridge.cryptolib.AsymKeysHolder; import io.firstbridge.cryptolib.CryptoFactory; import io.firstbridge.cryptolib.CryptoNotValidException; import io.firstbridge.cryptolib.CryptoSignature; +import java.io.IOException; import java.math.BigInteger; +import java.nio.file.Path; import java.security.KeyPair; +import java.util.Properties; import lombok.extern.slf4j.Slf4j; /** @@ -20,7 +26,7 @@ public class ThisActorIdHandlerImpl implements ThisActorIdHandler { BigInteger myApolloId; KeyPair myKeys; - CertHelper myCert; + ExtCert myCert; CryptoFactory cryptoFactory; @Override @@ -29,7 +35,7 @@ public BigInteger getActorId() { } @Override - public CertHelper getCertHelper() { + public ExtCert getCertHelper() { return myCert; } @@ -48,8 +54,32 @@ public byte[] sign(byte[] message) { } @Override - public CertHelper generateSelfSignedCert() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void generateSelfSignedCert() { + Properties prop = new Properties(); + ExtCSR csr = new ExtCSR(); + // csr. + } + + @Override + public boolean loadCertAndKey(Path baseDir) { + boolean res = false; + try { + myCert = CertKeyPersistence.loadPEMFromPath(baseDir); + res=true; + } catch (CertException ex) { + } catch (IOException ex) { + } + if(myCert==null){ + generateSelfSignedCert(); + } + return res; + } + + @Override + public boolean saveAll(Path baseDir) { + boolean res=false; + //TODO: implement + return res; } diff --git a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java index d4b7c26ff3..abe10eeeb2 100644 --- a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java +++ b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java @@ -1,7 +1,5 @@ package com.apollocurrency.apl.id.cert; -import io.firstbridge.cryptolib.CryptoConfig; -import io.firstbridge.cryptolib.CryptoParams; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.slf4j.LoggerFactory; @@ -20,7 +18,7 @@ public class CertificateTest { private static final org.slf4j.Logger log = LoggerFactory.getLogger(CertificateTest.class); - static CertHelper acert; + static ExtCert acert; public CertificateTest() { } @@ -28,7 +26,7 @@ public CertificateTest() { @BeforeAll public static void setUpClass() { try (InputStream is = CertificateTest.class.getClassLoader().getResourceAsStream("test_cert.pem")) { - acert = CertHelper.loadPEMFromStream(is); + acert = CertKeyPersistence.loadPEMFromStream(is); } catch (IOException ex) { log.error("Can not load test certificate ", ex); } catch (CertException ex) { From cd1bc66a0d74a6411746afdca4df76e00a74009f Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 8 Sep 2020 10:11:38 +0300 Subject: [PATCH 14/42] Certificate - related code moved to security package of core --- .../apollocurrency/aplwallet/apl/core/peer/PeersService.java | 2 +- .../messages/update => security}/CertificateLoader.java | 2 +- .../messages/update => security}/CertificateLoaderProducer.java | 2 +- .../messages/update => security}/CertificateMemoryStore.java | 2 +- .../apl/{core/peer => security}/id/IdentityService.java | 2 +- .../apl/{core/peer => security}/id/IdentityServiceImpl.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/{core/transaction/messages/update => security}/CertificateLoader.java (97%) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/{core/transaction/messages/update => security}/CertificateLoaderProducer.java (81%) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/{core/transaction/messages/update => security}/CertificateMemoryStore.java (96%) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/{core/peer => security}/id/IdentityService.java (90%) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/{core/peer => security}/id/IdentityServiceImpl.java (96%) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 01046ead9c..06fe774f6b 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -28,7 +28,7 @@ import com.apollocurrency.aplwallet.apl.core.entity.blockchain.Transaction; import com.apollocurrency.aplwallet.apl.core.http.API; import com.apollocurrency.aplwallet.apl.core.http.APIEnum; -import com.apollocurrency.aplwallet.apl.core.peer.id.IdentityService; +import com.apollocurrency.aplwallet.apl.security.id.IdentityService; import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import com.apollocurrency.aplwallet.apl.core.service.blockchain.BlockSerializer; import com.apollocurrency.aplwallet.apl.core.service.blockchain.Blockchain; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java similarity index 97% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java index 4965b0fdd0..94af811a7d 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoader.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; +package com.apollocurrency.aplwallet.apl.security; import com.apollocurrency.apl.id.cert.CertKeyPersistence; import com.apollocurrency.aplwallet.apl.util.Version; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoaderProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java similarity index 81% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoaderProducer.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java index 9b05955e74..8700faa49a 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateLoaderProducer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; +package com.apollocurrency.aplwallet.apl.security; import com.apollocurrency.aplwallet.apl.util.Constants; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java similarity index 96% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java index 274d5a84e3..7405c776a8 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/messages/update/CertificateMemoryStore.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java @@ -1,4 +1,4 @@ -package com.apollocurrency.aplwallet.apl.core.transaction.messages.update; +package com.apollocurrency.aplwallet.apl.security; import com.apollocurrency.aplwallet.apl.core.config.Property; import com.apollocurrency.apl.id.cert.ExtCert; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java similarity index 90% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java index 40cb9dd325..73566c0f0f 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java @@ -1,7 +1,7 @@ /* * Copyright (c) 2018-2020. Apollo Foundation. */ -package com.apollocurrency.aplwallet.apl.core.peer.id; +package com.apollocurrency.aplwallet.apl.security.id; import com.apollocurrency.apl.id.handler.IdValidator; import com.apollocurrency.apl.id.handler.ThisActorIdHandler; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java similarity index 96% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index 9b644e3d40..641ff6ecba 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -1,7 +1,7 @@ /* * Copyright (c) 2018-2020. Apollo Foundation. */ -package com.apollocurrency.aplwallet.apl.core.peer.id; +package com.apollocurrency.aplwallet.apl.security.id; import com.apollocurrency.apl.id.handler.IdValidator; import com.apollocurrency.apl.id.handler.IdValidatorImpl; From ac805cdf3ef6f977f1c2ac165d73881bf68fa7c5 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 21 Sep 2020 12:37:32 +0300 Subject: [PATCH 15/42] Merge branch 'develop' into feature/APL-1676-node-id --- .../aplwallet/apl/core/transaction/TransactionValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java index dcb0d3794d..23a0d584a2 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java @@ -112,7 +112,7 @@ public void validate(Transaction transaction) throws AplException.ValidationExce throw new AplException.NotValidException("Transactions of this type must have a valid recipient"); } - if (!AntifraudValidator.validate( + if (!antifraudValidator.validate( blockchain.getHeight(), blockchainConfig.getChain().getChainId(), transaction.getSenderId(), From 118f747cee547c33e9179bea572149a2f87f8822 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 22 Sep 2020 16:44:41 +0300 Subject: [PATCH 16/42] Moving all certificate-related stuff to the library --- .../publickey/PublicKeyTableProducer.java | 2 +- .../{ => id}/CertificateLoaderProducer.java | 5 +- apl-id/pom.xml | 170 ++++++++++-------- .../apollocurrency/apl/id/cert/ExtCSR.java | 2 - .../apollocurrency/apl/id/cert/ExtCert.java | 2 + .../apl/id/utils}/CertificateLoader.java | 13 +- .../apl/id/utils}/CertificateMemoryStore.java | 29 ++- 7 files changed, 116 insertions(+), 107 deletions(-) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/{ => id}/CertificateLoaderProducer.java (70%) rename {apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security => apl-id/src/main/java/com/apollocurrency/apl/id/utils}/CertificateLoader.java (92%) rename {apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security => apl-id/src/main/java/com/apollocurrency/apl/id/utils}/CertificateMemoryStore.java (55%) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/state/publickey/PublicKeyTableProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/state/publickey/PublicKeyTableProducer.java index c3fe7e962b..6d5cbdc424 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/state/publickey/PublicKeyTableProducer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/state/publickey/PublicKeyTableProducer.java @@ -83,7 +83,7 @@ private void init() { @Named("publicKeyTable") public EntityDbTableInterface getPublicKeyTable() { if (isCacheEnabled()) { - return new CachedTable<>(publicKeyCache, publicKeyTable); + return new CachedTable<>(publicKeyCache, publicKeyTable); } else { return publicKeyTable; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java similarity index 70% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java index 8700faa49a..83e1d32491 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoaderProducer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java @@ -1,5 +1,6 @@ -package com.apollocurrency.aplwallet.apl.security; +package com.apollocurrency.aplwallet.apl.security.id; +import com.apollocurrency.apl.id.utils.CertificateLoader; import com.apollocurrency.aplwallet.apl.util.Constants; import javax.enterprise.inject.Produces; @@ -10,6 +11,6 @@ public class CertificateLoaderProducer { @Produces @Singleton public CertificateLoader loader() { - return new CertificateLoader(this.getClass(), Constants.VERSION); + return new CertificateLoader(this.getClass(), Constants.VERSION.toString()); } } diff --git a/apl-id/pom.xml b/apl-id/pom.xml index 1c06030acd..16fa6d6d78 100644 --- a/apl-id/pom.xml +++ b/apl-id/pom.xml @@ -9,83 +9,97 @@ apl-id jar - - io.firstbridge - cryptolib - - - org.slf4j - slf4j-log4j12 - - - org.junit - junit-bom - - - - - org.bouncycastle - bcprov-jdk15on - - - org.bouncycastle - bcpkix-jdk15on - jar - - - org.slf4j - slf4j-api - - - org.projectlombok - lombok - provided - - - - org.junit.platform - junit-platform-engine - test - - - org.junit.platform - junit-platform-commons - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.jboss.weld - weld-junit5 - test - - - org.mockito - mockito-core - test - - - org.mockito - mockito-junit-jupiter - test - - - org.codehaus.janino - janino - test - - - ch.qos.logback - logback-classic - test - + + io.firstbridge + cryptolib + + + org.slf4j + slf4j-log4j12 + + + org.junit + junit-bom + + + + + org.bouncycastle + bcprov-jdk15on + + + org.bouncycastle + bcpkix-jdk15on + jar + + + org.slf4j + slf4j-api + + + org.projectlombok + lombok + provided + + + + javax.enterprise + cdi-api + 2.0 + provided + + + javax.annotation + javax.annotation-api + 1.3.2 + provided + + + + + org.junit.platform + junit-platform-engine + test + + + org.junit.platform + junit-platform-commons + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.jboss.weld + weld-junit5 + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.codehaus.janino + janino + test + + + ch.qos.logback + logback-classic + test + \ No newline at end of file diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java index 0a446c388b..15dcf4288d 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java @@ -10,14 +10,12 @@ import io.firstbridge.cryptolib.csr.CertificateRequestData; import io.firstbridge.cryptolib.csr.X509CertOperations; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.bouncycastle.util.IPAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileReader; import java.io.IOException; import java.math.BigInteger; import java.security.KeyPair; diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java index 93afad01a2..706e744dbb 100644 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java @@ -17,6 +17,7 @@ import java.util.Date; import java.util.List; import java.util.logging.Level; +import lombok.Getter; /** * Represents X.509 certificate with Apollo-specific attributes and signed by @@ -28,6 +29,7 @@ public class ExtCert extends CertBase { private static final Logger log = LoggerFactory.getLogger(ExtCert.class); + @Getter private final X509Certificate certificate; private final CertAttributes cert_attr; private final CertAttributes issuer_attr; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java similarity index 92% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java index 94af811a7d..afa358d838 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateLoader.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java @@ -1,7 +1,6 @@ -package com.apollocurrency.aplwallet.apl.security; +package com.apollocurrency.apl.id.utils; import com.apollocurrency.apl.id.cert.CertKeyPersistence; -import com.apollocurrency.aplwallet.apl.util.Version; import com.apollocurrency.apl.id.cert.ExtCert; import lombok.extern.slf4j.Slf4j; @@ -26,13 +25,17 @@ @Slf4j public class CertificateLoader { private final Class loadClass; - private final Version version; + private final String version; - public CertificateLoader(Class tClass, Version appVersion) { + public CertificateLoader(Class tClass, String appVersion) { this.loadClass = tClass; this.version = appVersion; } - + + public ExtCert getCaCert(){ + //TODO: implement + return null; + } public List loadAll() throws IOException { Path rootPath = Paths.get(loadClass.getProtectionDomain().getCodeSource().getLocation().getPath()); List certs = new ArrayList<>(); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java similarity index 55% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java rename to apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java index 7405c776a8..dfefc4a4d3 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/CertificateMemoryStore.java +++ b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java @@ -1,8 +1,6 @@ -package com.apollocurrency.aplwallet.apl.security; +package com.apollocurrency.apl.id.utils; -import com.apollocurrency.aplwallet.apl.core.config.Property; import com.apollocurrency.apl.id.cert.ExtCert; -import io.firstbridge.cryptolib.CryptoFactory; import java.io.IOException; import lombok.extern.slf4j.Slf4j; @@ -11,8 +9,6 @@ import javax.inject.Singleton; import java.math.BigInteger; import java.net.MalformedURLException; -import java.net.URL; -import java.security.cert.X509Certificate; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -23,15 +19,12 @@ @Singleton public class CertificateMemoryStore { - private CertificateLoader loader; - private Map certificates = new HashMap<>(); - private final URL caCertUrl; + private final CertificateLoader loader; + private final Map certificates = new HashMap<>(); @Inject - public CertificateMemoryStore(@Property("updater.ca.cert-url") String caCertUrl, CertificateLoader loader) throws MalformedURLException { + public CertificateMemoryStore(CertificateLoader loader) throws MalformedURLException { this.loader = Objects.requireNonNull(loader); - String notNullCertUrl = Objects.requireNonNull(caCertUrl); - this.caCertUrl = new URL(notNullCertUrl); } @PostConstruct @@ -39,24 +32,22 @@ void init() { List all = null; try { all = loader.loadAll(); - } catch (Exception e) { + } catch (IOException e) { log.debug("Error loading all certificates !", e); } - X509Certificate rootCert = null; - try { - rootCert = CryptoFactory.newInstance().getKeyReader().readX509CertPEMorDER(caCertUrl.openStream()); - } catch (IOException e) { - log.debug("Error readX509 CertPEMorDER", e); + ExtCert rootCert = loader.getCaCert(); + if(rootCert==null){ + throw new IllegalStateException("CA Certificate is not loaded!"); } if (all != null) { for (ExtCert apolloCertificate : all) { - if (rootCert != null && !apolloCertificate.verify(rootCert)) { + if (!apolloCertificate.verify(rootCert.getCertificate())) { throw new IllegalStateException("Certificate is not valid, ca signature verification failed for " + apolloCertificate); } if (apolloCertificate.isValid(new Date())) { throw new IllegalStateException("Certificate is out of valid time range: " + apolloCertificate); } - certificates.put(apolloCertificate.getSerial(), apolloCertificate); + certificates.put(apolloCertificate.getActorId(), apolloCertificate); } } } From 5fa75e4b38af4caca416f35ca26ec2f30e6eae37 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 23 Sep 2020 10:42:02 +0300 Subject: [PATCH 17/42] X.509 identity handling is in separate llibrary --- apl-core/pom.xml | 5 + apl-id/pom.xml | 105 ------ .../apollocurrency/apl/id/cert/ActorType.java | 94 ------ .../apl/id/cert/AuthorityID.java | 266 --------------- .../apl/id/cert/CertAttributes.java | 148 --------- .../apollocurrency/apl/id/cert/CertBase.java | 53 --- .../apl/id/cert/CertException.java | 12 - .../apl/id/cert/CertKeyPersistence.java | 176 ---------- .../apollocurrency/apl/id/cert/ExtCSR.java | 314 ------------------ .../apl/id/cert/ExtCSRFactory.java | 9 - .../apollocurrency/apl/id/cert/ExtCert.java | 172 ---------- .../apl/id/cert/TrustAllSSLProvider.java | 69 ---- .../apl/id/handler/IdValidator.java | 18 - .../apl/id/handler/IdValidatorImpl.java | 47 --- .../apl/id/handler/ThisActorIdHandler.java | 21 -- .../id/handler/ThisActorIdHandlerImpl.java | 86 ----- .../apl/id/utils/CertificateLoader.java | 83 ----- .../apl/id/utils/CertificateMemoryStore.java | 58 ---- .../apl/id/utils/StringList.java | 30 -- .../apl/id/cert/CertificateTest.java | 182 ---------- apl-id/src/test/resources/test_cert.pem | 23 -- .../src/test/resources/test_cert_pvtkey.pem | 8 - pom.xml | 1 - 23 files changed, 5 insertions(+), 1975 deletions(-) delete mode 100644 apl-id/pom.xml delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java delete mode 100644 apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java delete mode 100644 apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java delete mode 100644 apl-id/src/test/resources/test_cert.pem delete mode 100644 apl-id/src/test/resources/test_cert_pvtkey.pem diff --git a/apl-core/pom.xml b/apl-core/pom.xml index bc2ca0584e..d0527c09d4 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -36,6 +36,11 @@ + + io.firstbridge + fb-identity + 1.0.0 + ch.qos.logback logback-classic diff --git a/apl-id/pom.xml b/apl-id/pom.xml deleted file mode 100644 index 16fa6d6d78..0000000000 --- a/apl-id/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - 4.0.0 - - com.apollocurrency - apollo-blockchain - 1.46.2 - - apl-id - jar - - - io.firstbridge - cryptolib - - - org.slf4j - slf4j-log4j12 - - - org.junit - junit-bom - - - - - org.bouncycastle - bcprov-jdk15on - - - org.bouncycastle - bcpkix-jdk15on - jar - - - org.slf4j - slf4j-api - - - org.projectlombok - lombok - provided - - - - javax.enterprise - cdi-api - 2.0 - provided - - - javax.annotation - javax.annotation-api - 1.3.2 - provided - - - - - org.junit.platform - junit-platform-engine - test - - - org.junit.platform - junit-platform-commons - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.jboss.weld - weld-junit5 - test - - - org.mockito - mockito-core - test - - - org.mockito - mockito-junit-jupiter - test - - - org.codehaus.janino - janino - test - - - ch.qos.logback - logback-classic - test - - - \ No newline at end of file diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java deleted file mode 100644 index 65a10fd79e..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ActorType.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2018-2020. Apollo Foundation. - */ -package com.apollocurrency.apl.id.cert; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; - -/** - * @author alukin@gmail.com - */ -public class ActorType { - //actor types - public static final int NODE = 1; - public static final int SERVICE = 2; - public static final int PERSON = 3; - //actor sub-types for NODE - public static final int NODE_REGULAR = 0; - public static final int NODE_ARCHIVE = 1; - public static final int NODE_CERTIFIED_STORAGE = 2; - public static final int NODE_REGULAR_STORAGE = 3; - //actor sub-types for services - public static final int SERVICE_NONE = 0; - public static final int SERVICE_EXCHANE = 1; - public static final int SERVICE_WEBSITE = 2; - public static final int SERVICE_CDN = 3; - //actor sub-types for PERSON - public static final int PERSON_UNKNOWN = 0; - public static final int PERSON_DEVELOPER = 16; - public static final int PERSON_RELESE_ENG = 17; - public static final int PERSON_QUALITY_ASSURANCE = 18; - public static final int PERSON_DEV_MANAGEMENT = 19; - public static final int PERSON_DEVOPS = 20; - public static final int PERSON_MARKETING = 21; - - private int[] at = {0, 0}; - - public ActorType(int atype) { - ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(atype); - at[0] = bb.get(2); - at[1] = bb.get(3); - } - - public ActorType() { - } - - public Integer getValue() { - return at[0] << 8 | at[1]; - } - - public Integer getType() { - return at[0]; - } - - public void setType(int t) { - at[0] = t & 0xFF; - } - - public Integer getSubType() { - return at[1]; - } - - public void setSubType(int t) { - at[1] = t & 0xFF; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (!ActorType.class.isAssignableFrom(obj.getClass())) { - return false; - } - - final ActorType other = (ActorType) obj; - if ((this.at == null) ? (other.at != null) : !Arrays.equals(this.at, other.at)) { - return false; - } - - return true; - } - - @Override - //generated by IDE - public int hashCode() { - int hash = 3; - hash = 43 * hash + Arrays.hashCode(this.at); - return hash; - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java deleted file mode 100644 index be873b65c1..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/AuthorityID.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import org.bouncycastle.util.encoders.Hex; - -import java.math.BigInteger; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.UUID; - -/** - * AUthority ID is set of bits that classifies crypto actors and - * actor's capabilities. - * Bytes meaning. Les's number each of 16 bytes as following: - * 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 - * So bytes assigned to: - * 00 01 - actor type (00) and subtype (01), @see ActorType - * 02 03 - region code, not used yet - * 04 05 - business code, not used yet - * 06 07 - authority code, planned for usage together with business code for delegation tree - * 08 09 10 11 - operation code, planned for usage as operations permission mask - * 12 13 14 15 - supplemental code, reserved for future use - * - * @author alukin@gmail.com - */ -public class AuthorityID { - /** - * Length of AuthorityID in bytes - */ - public static final int LENGHT = 16; //16 bytes, 128 bit - - - private byte[] authorityID; - - public AuthorityID() { - setup(); - } - - public AuthorityID(BigInteger authID) { - setup(); - byte[] a = authID.toByteArray(); - int idx_dst = authorityID.length - 1; - int idx_src = a.length - 1; - while (idx_dst >= 0 && idx_src >= 0) { - authorityID[idx_dst] = a[idx_src]; - idx_src--; - idx_dst--; - } - } - - public AuthorityID(byte[] a) { - setup(); - int idx_dst = authorityID.length - 1; - int idx_src = a.length - 1; - while (idx_dst >= 0 && idx_src >= 0) { - authorityID[idx_dst] = a[idx_src]; - idx_src--; - idx_dst--; - } - } - - private void setup() { - authorityID = new byte[LENGHT]; - byte zero = 0; - Arrays.fill(authorityID, zero); - } - - public byte[] get() { - return authorityID; - } - - public BigInteger getAuthorityID() { - return new BigInteger(authorityID); - } - - /** - * ActorType and ActorSubType are first 2 most significant bytes of - * AuthorityID respectively - * - * @return 2 bytes of ActorType wrapped to 4 bytes of int - */ - public int getActorTypeAsInt() { - int res = authorityID[0] << 8 | authorityID[1]; - return res; - } - - /** - * Sets ActorType and ActorSubType as first 2 most significant bytes of - * AuthorityID respectively - * - * @param at 2 bytes wrapped in 2 least significant bytes of int - */ - public void setActorType(int at) { - ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(at); - authorityID[0] = bb.get(2); - authorityID[1] = bb.get(3); - } - - /** - * ActorType and ActorSubType are first 2 most significant bytes of - * AuthorityID respectively - * - * @return ActorType and ActorSubType wrapped in ActorType class - */ - public ActorType getActorType() { - return new ActorType(getActorTypeAsInt()); - } - - /** - * Sets ActorType and ActorSubType as first 2 most significant bytes of - * uthorityID respectively - * - * @param vat ActorType class hat wraps those 2 bytes - */ - public void setActorType(ActorType vat) { - AuthorityID.this.setActorType(vat.getValue()); - } - - /** - * RegionCode is 2nd and 3rd most significant bytes of AuthorityID - * - * @return 2 bytes of RegionCode wrapped to 2 least significant bytes of int - */ - public Integer getRegionCode() { - int res = authorityID[2] << 8 | authorityID[3]; - return res; - } - - /** - * RegionCode is 2nd and 3rd most significant bytes of AuthorityID - * - * @param rc 2 bytes of RegionCode wrapped to 2 least significant bytes of - * int - */ - public void setRegionCode(int rc) { - ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(rc); - authorityID[2] = bb.get(2); - authorityID[3] = bb.get(3); - } - - /** - * BusinessCode is 4th and 5th most significant bytes of AuthorityID - * - * @return 2 bytes of BusinessCode wrapped to 2 least significant bytes of - * int - */ - public Integer getBusinessCode() { - int res = authorityID[4] << 8 | authorityID[5]; - return res; - } - - /** - * BusinessCode is 4th and 5th most significant bytes of AuthorityID - * - * @param bc 2 bytes of BusinessCode wrapped to 2 least significant bytes of - * int - */ - public void setBusinessCode(int bc) { - ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(bc); - authorityID[4] = bb.get(2); - authorityID[5] = bb.get(3); - } - - /** - * AuthorityCode is 6th and 7th most significant bytes of AuthorityID - * - * @return 2 bytes of AuthorityCode wrapped to 2 least significant bytes of - * int - */ - public Integer getAuthorityCode() { - int res = authorityID[6] << 8 | authorityID[7]; - return res; - } - - /** - * AuthorityCode is 6th and 7th most significant bytes of AuthorityID - * - * @param bc 2 bytes of AuthorityCode wrapped to 2 least significant bytes - * of int - */ - public void setAuthorityCode(int bc) { - ByteBuffer bb = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN).putInt(bc); - authorityID[6] = bb.get(2); - authorityID[7] = bb.get(3); - } - - public long getOperationCode() { - long res = authorityID[8] << 24 | authorityID[9] << 16 | authorityID[10] << 8 | authorityID[11]; - return res; - } - - public void setOperationCode(long oc) { - ByteBuffer bb = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putLong(oc); - authorityID[8] = bb.get(4); - authorityID[9] = bb.get(5); - authorityID[10] = bb.get(6); - authorityID[11] = bb.get(7); - } - - public Long getSuplementalCode() { - long res = authorityID[12] << 24 | authorityID[13] << 16 | authorityID[14] << 8 | authorityID[15]; - return res; - } - - public void setSuplementalCode(long sc) { - ByteBuffer bb = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN).putLong(sc); - authorityID[12] = bb.get(4); - authorityID[13] = bb.get(5); - authorityID[14] = bb.get(6); - authorityID[15] = bb.get(7); - } - - /** - * Gets network Id declared in certificate's filed AuthorityID - * All authorization bits of certificate could be bound to one network only - * So part of AuthorityID of any trusted certificate id 128-bit long network Id - * @return Network ID as UUID - */ - public byte[] getNetId(){ - //TODO: implement - return null; - } - - /** - * Sets network Id declared in certificate's filed AuthorityID - * All authorization bits of certificate could be bound to one network only - * So part of AuthorityID of any trusted certificate id 128-bit long network Id - */ - public void setNetId(byte[] id){ - //TODO: implement - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (!AuthorityID.class.isAssignableFrom(obj.getClass())) { - return false; - } - - final AuthorityID other = (AuthorityID) obj; - if ((this.authorityID == null) ? (other.authorityID != null) : !Arrays.equals(this.authorityID, other.authorityID)) { - return false; - } - - return true; - } - - @Override - //generated by IDE - public int hashCode() { - int hash = 5; - hash = 89 * hash + Arrays.hashCode(this.authorityID); - return hash; - } - - - - @Override - public String toString() { - return "AuthorityID{" + "authorityID=" + Hex.toHexString(authorityID) + '}'; - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java deleted file mode 100644 index 79aff3eda5..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertAttributes.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import org.bouncycastle.asn1.pkcs.Attribute; -import org.bouncycastle.asn1.x500.X500Name; - -import java.math.BigInteger; -import java.util.List; - -/** - * PKCS#10 and X.509 attribute parser - * - * @author alukin@gmail.com - */ -public class CertAttributes { - - private BigInteger apolloId = BigInteger.ZERO; - private AuthorityID apolloAuthorityId = new AuthorityID(); - private String cn = ""; - private String o = ""; - private String ou = ""; - private String country = ""; - private String state = ""; - private String city = ""; - private String eMail = ""; - private List ipAddList = null; - - public CertAttributes() { - } - - public void setAttributes(Attribute[] aa) { - - } - - public void setSubject(X500Name sn) throws CertException { - String name = sn.toString(); - setSubjectStr(name); - } - - public void setSubjectStr(String name) throws CertException { - String[] names = name.split(","); - try { - for (String name1 : names) { - String[] nvs = name1.split("="); - String an = nvs[0].trim(); - String av = nvs.length > 1 ? nvs[1].trim() : ""; - if (an.equalsIgnoreCase("CN")) { - cn = av; - } else if (an.equalsIgnoreCase("O")) { - o = av; - } else if (an.equalsIgnoreCase("OU")) { - ou = av; - } else if (an.equalsIgnoreCase("C")) { - country = av; - } else if (an.equalsIgnoreCase("ST")) { - state = av; - } else if (an.equalsIgnoreCase("L")) { - city = av; - } else if (an.equalsIgnoreCase("EMAILADDRESS")) { - eMail = av; - } else if (an.trim().equalsIgnoreCase("UID")) { - apolloId = new BigInteger(av, 16); - } else if (an.equalsIgnoreCase("businessCategory") - || an.equalsIgnoreCase("OID.2.5.4.15")) { - apolloAuthorityId = new AuthorityID(new BigInteger(av, 16)); - } - } - } catch (NumberFormatException ex) { - throw new CertException(ex.getMessage()); - } - } - - public BigInteger getActorId() { - return apolloId; - } - - public void setApolloId(BigInteger id) { - this.apolloId = id; - } - - public AuthorityID getAuthorityId() { - return apolloAuthorityId; - } - - public void setAuthorityId(AuthorityID authorityId) { - this.apolloAuthorityId = authorityId; - } - - public String getCn() { - return cn; - } - - public void setCn(String cn) { - this.cn = cn; - } - - public String getO() { - return o; - } - - public void setO(String o) { - this.o = o; - } - - public String getOu() { - return ou; - } - - public void setOu(String ou) { - this.ou = ou; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public String geteMail() { - return eMail; - } - - public void seteMail(String eMail) { - this.eMail = eMail; - } - - List IpAddresses() { - return ipAddList; - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java deleted file mode 100644 index 5fcd2013b7..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertBase.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import io.firstbridge.cryptolib.AsymCryptor; -import io.firstbridge.cryptolib.AsymKeysHolder; -import io.firstbridge.cryptolib.CryptoConfig; -import io.firstbridge.cryptolib.CryptoFactory; -import io.firstbridge.cryptolib.CryptoNotValidException; -import io.firstbridge.cryptolib.CryptoParams; - -import java.security.PrivateKey; -import java.security.PublicKey; - -/** - * Base class for certificate and CSR - * Also holds private key of certificate - * - * @author alukin@gmail.com - */ -public class CertBase { - - protected PublicKey pubKey = null; - protected PrivateKey pvtKey = null; - protected CryptoParams params = CryptoConfig.createDefaultParams(); - protected CryptoFactory factory = CryptoFactory.newInstance(params); - - public boolean checkKeys(PrivateKey pvtk) { - boolean res = false; - try { - String test = "Lazy Fox jumps ofver snoopy dog"; - AsymCryptor ac = factory.getAsymCryptor(); - AsymKeysHolder kn = new AsymKeysHolder(pubKey, pvtk, pubKey); - ac.setKeys(kn); - byte[] enc = ac.encrypt(test.getBytes()); - byte[] dec = ac.decrypt(enc); - String test_res = new String(dec); - res = test.compareTo(test_res) == 0; - } catch (CryptoNotValidException ex) { - } - return res; - } - - public PublicKey getPublicKey() { - return pubKey; - } - - public PrivateKey getPrivateKey() { - return pvtKey; - } - - public void setPrivateKey(PrivateKey pvtKey) { - this.pvtKey = pvtKey; - } -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java deleted file mode 100644 index 7535a93d4c..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertException.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -/** - * @author alukin@gmail.com - */ -public class CertException extends RuntimeException { - - CertException(String message) { - throw new RuntimeException(message); - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java deleted file mode 100644 index 04f1824774..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/CertKeyPersistence.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import io.firstbridge.cryptolib.KeyReader; -import io.firstbridge.cryptolib.impl.KeyReaderImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; -import java.nio.file.Path; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.bouncycastle.openssl.PEMParser; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; - -/** - * Handler of certificate, ExtCSR and key names and directories placed in map with ID as a key - * - * @author alukin@gmail.com - */ -public class CertKeyPersistence { - public static final String PVT_SEARCH_PATH = "private/"; - private static final Logger log = LoggerFactory.getLogger(CertKeyPersistence.class); - private final Map> certMap = new TreeMap<>(); - public static final String[] sfxes = {"_pvtkey", "_req", "_cert", "_selfcert", "_csr"}; - - public static String rmSuffixes(String fn) { - String name = new String(fn); - String ext = ""; - int last_dot = fn.lastIndexOf("."); - if (last_dot >= 0) { - ext = fn.substring(last_dot + 1); - name = fn.substring(0, last_dot); - } - - String[] sfxes = {"_pvtkey", "_req", "_cert", "_selfcert", "_csr"}; - for (String s : sfxes) { - int idx = name.indexOf(s); - if (idx >= 0) { - name = name.substring(0, idx); - } - } - return name; - } - - public static String pvtKeyFileName(String fn) { - String suffix = "_pvtkey"; - String name = rmSuffixes(fn); - return name + suffix + ".pem"; - } - - public static String selfSignedFileName(String fn) { - String suffix = "_selfcert"; - String name = rmSuffixes(fn); - return name + suffix + ".pem"; - } - - public static String certFileName(String fn) { - String suffix = "_cert"; - String name = rmSuffixes(fn); - return name + suffix + ".pem"; - } - - public static String csrFileName(String fn) { - String suffix = "_csr"; - String name = rmSuffixes(fn); - return name + suffix + ".pem"; - } - - public List getCert(BigInteger id) { - return certMap.get(id); - } - - public void put(BigInteger id, ExtCert cert) { - List cl = certMap.get(id); - if (cl == null) { - cl = new ArrayList<>(); - } - cl.add(cert); - certMap.put(id, cl); - } - - public int size() { - return certMap.size(); - } - - public void readCertDirectory(String path, boolean loadPrivateKey) { - File dir = new File(path); - if (dir.exists() && dir.isDirectory()) { - File[] filesList = dir.listFiles(); - for (File f : filesList) { - if (f.isFile() && f.canRead()) { - ExtCert ac = null; - try { - ac = loadPEMFromPath(f.toPath()); - } catch (IOException ex) { - //impossible here - } catch (CertException ex) { - log.error("Certificate load exception wilr loading " + f.getAbsolutePath(), ex); - } - if (ac != null) { - put(ac.getActorId(), ac); - if (loadPrivateKey) { - String parent = f.getParent(); - String fn = f.getName(); - PrivateKey pk = null; - pk = readPvtKey(parent + "/" + pvtKeyFileName(fn)); - if (pk == null) {//no key in the same dir, try "private/" - pk = readPvtKey(parent + PVT_SEARCH_PATH + pvtKeyFileName(fn)); - } - if (pk != null) { - if (ac.checkKeys(pk)) { - ac.setPrivateKey(pk); - } else { - log.error("Private key file does not correspond to certificate: {}" + f.getAbsolutePath()); - } - } else { - log.error("Private key file not foud for certificate: {}", f.getAbsolutePath()); - } - } - } - } - } - } else { - log.error("Can not read certificates.Directory: {} does not exist!", path); - } - } - - public PrivateKey readPvtKey(String filePath) { - KeyReader kr = new KeyReaderImpl(); - PrivateKey res = null; - try (FileInputStream fis = new FileInputStream(filePath)) { - res = kr.readPrivateKeyPEM(fis); - } catch (IOException ex) { - log.trace("Can not read private key: {}", filePath); - } - return res; - } - - public static ExtCert loadPEMFromPath(Path path) throws CertException, IOException { - ExtCert res = null; - try (FileInputStream fis = new FileInputStream(path.toString())) { - res = loadPEMFromStream(fis); - } - return res; - } - - public static ExtCert loadPEMFromStream(InputStream is) throws IOException, CertException { - KeyReader kr = new KeyReaderImpl(); - X509Certificate cert = kr.readX509CertPEMorDER(is); - ExtCert ac = new ExtCert(cert); - //try to load corresponding key - return ac; - } - - public static ExtCSR loadCSR(String path) { - PKCS10CertificationRequest cr; - ExtCSR res = null; - try (FileReader fr = new FileReader(path)) { - PEMParser parser = new PEMParser(fr); - cr = (PKCS10CertificationRequest) parser.readObject(); - res = ExtCSR.fromPKCS10(cr); - } catch (IOException ex) { - log.error("Can not read PKCS#10 file: " + path, ex); - } - return res; - } -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java deleted file mode 100644 index 15dcf4288d..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSR.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2018-2020. Apollo Foundation. - */ -package com.apollocurrency.apl.id.cert; - -import com.apollocurrency.apl.id.utils.StringList; -import io.firstbridge.cryptolib.CryptoNotValidException; -import io.firstbridge.cryptolib.KeyGenerator; -import io.firstbridge.cryptolib.KeyWriter; -import io.firstbridge.cryptolib.csr.CertificateRequestData; -import io.firstbridge.cryptolib.csr.X509CertOperations; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.bouncycastle.util.IPAddress; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.KeyPair; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.Properties; - -/** - * Certificate signing request with additional identity-specific attributes - * - * @author alukin@gmail.com - */ -public class ExtCSR extends CertBase { - - private static final Logger log = LoggerFactory.getLogger(ExtCSR.class); - private final CertificateRequestData csrData = new CertificateRequestData(CertificateRequestData.CSRType.HOST); - private String challengePassword = ""; - private BigInteger actorID; - private AuthorityID authorityID; - private final KeyWriter kw; - - public ExtCSR() { - actorID = new BigInteger(128, new SecureRandom()); - authorityID = new AuthorityID(); - kw = factory.getKeyWriter(); - } - - public static ExtCSR newHostCSR(Properties prop){ - ExtCSR res = new ExtCSR(); - //TODO: implement - return res; - } - - public static ExtCSR fromPKCS10(PKCS10CertificationRequest cr) { - ExtCSR res = new ExtCSR(); - try { - CertAttributes va = new CertAttributes(); - va.setSubject(cr.getSubject()); - va.setAttributes(cr.getAttributes()); - res.setCN(va.getCn()); - res.setAuthorityId(va.getAuthorityId()); - res.setActorId(va.getActorId()); - res.setCountry(va.getCountry()); - res.setState(va.getState()); - res.setCity(va.getCity()); - res.setOrg(va.getO()); - res.setOrgUnit(va.getOu()); - - SubjectPublicKeyInfo pkInfo = cr.getSubjectPublicKeyInfo(); - JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); - res.pubKey = converter.getPublicKey(pkInfo); - - } catch (CertException | IOException ex) { - log.error("Error reading public key frpm PKSC#10", ex); - } - return res; - } - - public static ExtCSR fromCertificate(ExtCert cert) { - ExtCSR res = new ExtCSR(); - res.setAuthorityId(cert.getAuthorityId().getAuthorityID()); - BigInteger vid = cert.getActorId(); - if (vid == null || vid == BigInteger.ZERO) { - vid = new BigInteger(128, new SecureRandom()); - } - res.setActorId(vid); - res.setCN(cert.getCN()); - res.setEmail(cert.getEmail()); - res.setOrg(cert.getOrganization()); - res.setOrgUnit(cert.getOrganizationUnit()); - res.setCountry(cert.getCountry()); - res.setState(cert.getStateOrProvince()); - res.setCity(cert.getCity()); - res.setIP(StringList.fromList(cert.getIPAddresses())); - res.setDNSNames(StringList.fromList(cert.getDNSNames())); - res.pubKey = cert.getPublicKey(); - res.pvtKey = cert.getPrivateKey(); - return res; - } - - public static boolean isValidIPAddresList(String ipList) { - boolean res = true; - String[] addr = ipList.split(","); - for (String a : addr) { - res = IPAddress.isValid(a) || IPAddress.isValidWithNetMask(a); - if (!res) { - break; - } - } - return res; - } - - public static boolean isValidDNSNameList(String nameList) { - boolean res = true; - String[] names = nameList.split(","); - String pattern = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$"; - for (String n : names) { - res = n.matches(pattern); - if (!res) { - break; - } - } - return res; - } - - public BigInteger getActorId() { - return actorID; - } - - public void setActorId(BigInteger id) { - actorID = id; - csrData.setSubjectAttribute("UID", actorID.toString(16)); - } - - public AuthorityID getAuthorityId() { - return authorityID; - } - - public void setAuthorityId(BigInteger id) { - authorityID = new AuthorityID(id); - csrData.setSubjectAttribute("businessCategory", authorityID.getAuthorityID().toString(16)); - } - - public void setAuthorityId(AuthorityID authID) { - this.authorityID = authID; - csrData.setSubjectAttribute("businessCategory", authID.getAuthorityID().toString(16)); - } - - public String getCN() { - String res = csrData.getSubjectAttribute("CN"); - if (res == null) { - res = ""; - } - return res; - } - - public void setCN(String cn) { - csrData.setSubjectAttribute("CN", cn); - } - - public String getEmial() { - String res = csrData.getSubjectAttribute("emailAddress"); - if (res == null) { - res = ""; - } - return res; - } - - public void setEmail(String email) { - csrData.setSubjectAttribute("emailAddress", email); - } - - public String getIP() { - return csrData.getExtendedAttribute("subjaltnames.ipaddress"); - } - - public void setIP(String ip) { - if (ip != null && !ip.isEmpty()) { - if (isValidIPAddresList(ip)) { - csrData.setExtendedAttribute("subjaltnames.ipaddress", ip); - } else { - throw new IllegalArgumentException("Invalid IP4 or IP6 addres: " + ip); - } - } - } - - public String getDNSNames() { - return csrData.getExtendedAttribute("subjaltnames.dnsname"); - } - - public void setDNSNames(String n) { - if (n != null && !n.isEmpty()) { - if (isValidDNSNameList(n)) { - csrData.setExtendedAttribute("subjaltnames.dnsname", n); - } else { - throw new IllegalArgumentException("Invalid DNS name: " + n); - } - } - } - - public String getOrgUnit() { - return csrData.getSubjectAttribute("OU"); - } - - public void setOrgUnit(String ou) { - csrData.setSubjectAttribute("OU", ou); - } - - public String getOrg() { - return csrData.getSubjectAttribute("O"); - } - - public void setOrg(String o) { - csrData.setSubjectAttribute("O", o); - } - - public String getCountry() { - return csrData.getSubjectAttribute("C"); - } - - public void setCountry(String c) { - csrData.setSubjectAttribute("C", c); - } - - public String getState() { - return csrData.getSubjectAttribute("ST"); - } - - public void setState(String c) { - csrData.setSubjectAttribute("ST", c); - } - - public String getCity() { - return csrData.getSubjectAttribute("L"); - } - - public void setCity(String c) { - csrData.setSubjectAttribute("L", c); - } - - public String getChallengePassword() { - return challengePassword; - } - - public void setChallengePassword(String challengePassword) { - this.challengePassword = challengePassword; - } - - public String getPemPKCS10() { - String pem = ""; - try { - csrData.processCertData(false); - if (pvtKey == null) { - newKeyPair(); - } - KeyPair kp = new KeyPair(pubKey, pvtKey); - X509CertOperations certOps = factory.getX509CertOperations(); - PKCS10CertificationRequest cr = certOps.createX509CertificateRequest(kp, csrData, false, challengePassword); - pem = kw.getCertificateRequestPEM(cr); - } catch (IOException ex) { - log.error("Can not generate PKSC10 CSR", ex); - } catch (CryptoNotValidException ex) { - log.error("Can not generate PKSC10 CSR, Invalid data", ex); - } - return pem; - } - - public String getPrivateKeyPEM() { - String pem = ""; - try { - pem = kw.getPvtKeyPEM(pvtKey); - } catch (IOException ex) { - log.error("Can not get PEM of private key", ex); - } - return pem; - } - - public String getSelfSignedX509PEM() { - String pem = ""; - try { - csrData.processCertData(true); - if (pvtKey == null) { - newKeyPair(); - } - KeyPair kp = new KeyPair(pubKey, pvtKey); - X509CertOperations certOps = factory.getX509CertOperations(); - X509Certificate cert = certOps.createSelfSignedX509v3(kp, csrData); - pem = kw.getX509CertificatePEM(cert); - } catch (CryptoNotValidException | IOException ex) { - log.error("Can not generate self-signed PEM", ex); - } - return pem; - } - - @Override - public String toString() { - String res = "X.509 Certificate:\n"; - res += "CN=" + getCN() + "\n" - + "ActorID=" + getActorId().toString(16) + "\n"; - res += "emailAddress=" + getEmial() + "\n"; - res += "Country=" + getCountry() + " State/Province=" + getState() - + " City=" + getCity(); - res += "Organization=" + getOrg() + " Org. Unit=" + getOrgUnit() + "\n"; - res += "IP address=" + getIP() + "\n"; - res += "DNS names=" + getDNSNames() + "\n"; - return res; - } - - private void newKeyPair() { - KeyGenerator kg = factory.getKeyGenerator(); - KeyPair kp = kg.generateKeys(); - pubKey = kp.getPublic(); - pvtKey = kp.getPrivate(); - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java deleted file mode 100644 index 989a15f9f9..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCSRFactory.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -/** - * Factory for PKCS#10 CSR generation - * @author alukin@gmail.com - */ -public class ExtCSRFactory { - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java deleted file mode 100644 index 706e744dbb..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/ExtCert.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import com.apollocurrency.apl.id.utils.StringList; -import io.firstbridge.cryptolib.KeyWriter; -import io.firstbridge.cryptolib.impl.KeyWriterImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.SignatureException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.Date; -import java.util.List; -import java.util.logging.Level; -import lombok.Getter; - -/** - * Represents X.509 certificate with Apollo-specific attributes and signed by - * Apollo CA or self-signed - * - * @author alukin@gmail.com - */ -public class ExtCert extends CertBase { - - private static final Logger log = LoggerFactory.getLogger(ExtCert.class); - - @Getter - private final X509Certificate certificate; - private final CertAttributes cert_attr; - private final CertAttributes issuer_attr; - - - - - public ExtCert(X509Certificate certificate) throws CertException { - if (certificate == null) { - throw new CertException("Null certificate"); - } - this.certificate = certificate; - pubKey = certificate.getPublicKey(); - cert_attr = new CertAttributes(); - issuer_attr = new CertAttributes(); - cert_attr.setSubjectStr(certificate.getSubjectX500Principal().toString()); - issuer_attr.setSubjectStr(certificate.getIssuerX500Principal().toString()); - } - - - - public BigInteger getActorId() { - return cert_attr.getActorId(); - } - - public AuthorityID getAuthorityId() { - return cert_attr.getAuthorityId(); - } - - - public String getCN() { - return cert_attr.getCn(); - } - - public String getOrganization() { - return cert_attr.getO(); - } - - public String getOrganizationUnit() { - return cert_attr.getOu(); - } - - public String getCountry() { - return cert_attr.getCountry(); - } - - public String getCity() { - return cert_attr.getCity(); - } - - public String getCertificatePurpose() { - return "Node"; - //TODO: implement recognitioin from extended attributes - } - - public List getIPAddresses() { - return cert_attr.IpAddresses(); - } - - public List getDNSNames() { - return null; - //TODO: implement - } - - public String getStateOrProvince() { - return null; - } - - public String getEmail() { - return cert_attr.geteMail(); - } - - @Override - public String toString() { - String res = "X.509 Certificate:\n"; - res += "CN=" + cert_attr.getCn() + "\n" - + "ApolloID=" + getActorId().toString(16) + "\n"; - - res += "emailAddress=" + getEmail() + "\n"; - res += "Country=" + getCountry() + " State/Province=" + getStateOrProvince() - + " City=" + getCity(); - res += "Organization=" + getOrganization() + " Org. Unit=" + getOrganizationUnit() + "\n"; - res += "IP address=" + StringList.fromList(getIPAddresses()) + "\n"; - res += "DNS names=" + StringList.fromList(getDNSNames()) + "\n"; - return res; - } - - public String getCertPEM() { - KeyWriter kw = new KeyWriterImpl(); - String res=""; - try { - res = kw.getX509CertificatePEM(certificate); - } catch (IOException ex) { - java.util.logging.Logger.getLogger(ExtCert.class.getName()).log(Level.SEVERE, null, ex); - } - return res; - } - - public boolean isValid(Date date) { - boolean dateOK = false; - Date start = certificate.getNotBefore(); - Date end = certificate.getNotAfter(); - if (date != null && start != null && end != null) { - if (date.after(start) && date.before(end)) { - dateOK = true; - } else { - dateOK = false; - } - } - //TODO: implement more checks - return dateOK; - } - - public BigInteger getSerial() { - return certificate.getSerialNumber(); - } - - public CertAttributes getIssuerAttrinutes() { - return issuer_attr; - } - - public boolean verify(X509Certificate certificate) { - try { - this.certificate.verify(certificate.getPublicKey()); - } catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | NoSuchProviderException | SignatureException e) { - return false; - } - return true; - } - - public boolean isSelfSigned(){ - //TODO: implement - return true; - } - - public boolean isSignedBy(X509Certificate signerCert) { - return verify(signerCert); - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java b/apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java deleted file mode 100644 index 763f1caa90..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/cert/TrustAllSSLProvider.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2013-2016 The Nxt Core Developers. - * Copyright © 2016-2018 Jelurida IP B.V. - * - * See the LICENSE.txt file at the top-level directory of this distribution - * for licensing information. - * - * Unless otherwise agreed in a custom licensing agreement with Jelurida B.V., - * no part of the Nxt software, including this file, may be copied, modified, - * propagated, or distributed except according to the terms contained in the - * LICENSE.txt file. - * - * Removal or modification of this copyright notice is prohibited. - * - */ - -package com.apollocurrency.apl.id.cert; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; - -public class TrustAllSSLProvider { - - // Verify-all name verifier - private final static HostnameVerifier hostNameVerifier = (hostname, session) -> true; - - // Trust-all socket factory - private static final SSLSocketFactory sslSocketFactory; - - static { - TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(X509Certificate[] certs, String authType) { - } - - public void checkServerTrusted(X509Certificate[] certs, String authType) { - } - }}; - SSLContext sc; - try { - sc = SSLContext.getInstance("TLS"); - } catch (NoSuchAlgorithmException e) { - throw new IllegalStateException(e); - } - try { - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - } catch (KeyManagementException e) { - throw new IllegalStateException(e); - } - sslSocketFactory = sc.getSocketFactory(); - } - - public static HostnameVerifier getHostNameVerifier() { - return hostNameVerifier; - } - - public static SSLSocketFactory getSslSocketFactory() { - return sslSocketFactory; - } -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java deleted file mode 100644 index a1b4b4cb0d..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidator.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ - -package com.apollocurrency.apl.id.handler; - -import java.security.cert.X509Certificate; - - -/** - * - * @author alukin@gmail.com - */ -public interface IdValidator { - void addTrustedSignerCert(X509Certificate cert); - boolean isSelfSigned(X509Certificate cert); - boolean isTrusted(X509Certificate cert); -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java deleted file mode 100644 index 11988ad86f..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/IdValidatorImpl.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.id.handler; - -import com.apollocurrency.apl.id.cert.ExtCert; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; - - -/** - * - * @author alukin@gmail.com - */ -public class IdValidatorImpl implements IdValidator{ - - private final List trustedSigners = new ArrayList<>(); - - public IdValidatorImpl() { - } - - @Override - public boolean isSelfSigned(X509Certificate cert) { - return false; - } - - - @Override - public boolean isTrusted(X509Certificate cert) { - boolean res = false; - ExtCert ac = new ExtCert(cert); - for(X509Certificate signerCert: trustedSigners){ - res = ac.isSignedBy(signerCert); - if(res){ - break; - } - } - return res; - } - - @Override - public void addTrustedSignerCert(X509Certificate cert) { - trustedSigners.add(cert); - } - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java deleted file mode 100644 index 15cf67002f..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.id.handler; - -import com.apollocurrency.apl.id.cert.ExtCert; -import java.math.BigInteger; -import java.nio.file.Path; - -/** - * Handles operations with X509 certificate and private key of this node - * @author alukin@gmail.com - */ -public interface ThisActorIdHandler { - BigInteger getActorId(); - ExtCert getCertHelper(); - byte[] sign(byte[] message); - void generateSelfSignedCert(); - boolean loadCertAndKey(Path baseDir); - boolean saveAll(Path baseDir); -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java b/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java deleted file mode 100644 index 3ecf14232f..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/handler/ThisActorIdHandlerImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.id.handler; - -import com.apollocurrency.apl.id.cert.ExtCSR; -import com.apollocurrency.apl.id.cert.CertException; -import com.apollocurrency.apl.id.cert.CertKeyPersistence; -import com.apollocurrency.apl.id.cert.ExtCert; -import io.firstbridge.cryptolib.AsymKeysHolder; -import io.firstbridge.cryptolib.CryptoFactory; -import io.firstbridge.cryptolib.CryptoNotValidException; -import io.firstbridge.cryptolib.CryptoSignature; -import java.io.IOException; -import java.math.BigInteger; -import java.nio.file.Path; -import java.security.KeyPair; -import java.util.Properties; -import lombok.extern.slf4j.Slf4j; - -/** - * - * @author alukin@gmail.com - */ -@Slf4j -public class ThisActorIdHandlerImpl implements ThisActorIdHandler { - BigInteger myApolloId; - KeyPair myKeys; - ExtCert myCert; - CryptoFactory cryptoFactory; - - @Override - public BigInteger getActorId() { - return myApolloId; - } - - @Override - public ExtCert getCertHelper() { - return myCert; - } - - @Override - public byte[] sign(byte[] message) { - byte[] res = null; - CryptoSignature signer = cryptoFactory.getCryptoSiganture(); - AsymKeysHolder kh = new AsymKeysHolder(myKeys.getPublic(), myKeys.getPrivate(), null); - signer.setKeys(kh); - try { - res = signer.sign(message); - } catch (CryptoNotValidException ex) { - log.error("Can not sign message with my node private key", ex); - } - return res; - } - - @Override - public void generateSelfSignedCert() { - Properties prop = new Properties(); - ExtCSR csr = new ExtCSR(); - // csr. - } - - @Override - public boolean loadCertAndKey(Path baseDir) { - boolean res = false; - try { - myCert = CertKeyPersistence.loadPEMFromPath(baseDir); - res=true; - } catch (CertException ex) { - } catch (IOException ex) { - } - if(myCert==null){ - generateSelfSignedCert(); - } - return res; - } - - @Override - public boolean saveAll(Path baseDir) { - boolean res=false; - //TODO: implement - return res; - } - - -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java deleted file mode 100644 index afa358d838..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateLoader.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.apollocurrency.apl.id.utils; - -import com.apollocurrency.apl.id.cert.CertKeyPersistence; -import com.apollocurrency.apl.id.cert.ExtCert; -import lombok.extern.slf4j.Slf4j; - -import java.io.IOException; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.List; - - -/** - * Temporal class to load certs from filesystem for {@link com.apollocurrency.aplwallet.apl.core.transaction.types.update.UpdateV2TransactionType} transaction - * Should be removed, when p2p message exchange protocol will be implemented - * Moved from UpdaterV2 impl - */ -@Slf4j -public class CertificateLoader { - private final Class loadClass; - private final String version; - - public CertificateLoader(Class tClass, String appVersion) { - this.loadClass = tClass; - this.version = appVersion; - } - - public ExtCert getCaCert(){ - //TODO: implement - return null; - } - public List loadAll() throws IOException { - Path rootPath = Paths.get(loadClass.getProtectionDomain().getCodeSource().getLocation().getPath()); - List certs = new ArrayList<>(); - Path fsPath = null; - if (rootPath.toUri().getScheme().equals("jar")) { - fsPath = rootPath; - } else if (Files.isRegularFile(rootPath)) { - String certsZipPath = "certs" + "-" + version + ".zip"; - fsPath = rootPath.getParent().resolve(certsZipPath); - } - if (fsPath != null) { - certs.addAll(readAllFromFs(fsPath)); - } else if (Files.isDirectory(rootPath)) { //classes - certs.addAll(readAll(rootPath)); - } else { - throw new RuntimeException("Unable to read certs from " + rootPath.toAbsolutePath()); - } - log.info("path {}, was read {} certs", rootPath.toAbsolutePath(), certs.size()); - return certs; - } - - private List readAll(Path path) throws IOException { - List certs = new ArrayList<>(); - Files.walkFileTree(path.resolve("certs"), new SimpleFileVisitor<>() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - try { - ExtCert cert = CertKeyPersistence.loadPEMFromPath(file.toAbsolutePath()); - certs.add(cert); - } - catch (Exception e) { - log.error("Unable to load certificate from " + file, e); - } - return super.visitFile(file, attrs); - } - }); - return certs; - } - - private List readAllFromFs(Path path) throws IOException { - try (FileSystem fileSystem = FileSystems.newFileSystem(path, ClassLoader.getSystemClassLoader())) { - return readAll(fileSystem.getPath("/")); - } - } -} \ No newline at end of file diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java deleted file mode 100644 index dfefc4a4d3..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/CertificateMemoryStore.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.apollocurrency.apl.id.utils; - -import com.apollocurrency.apl.id.cert.ExtCert; -import java.io.IOException; -import lombok.extern.slf4j.Slf4j; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.math.BigInteger; -import java.net.MalformedURLException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@Slf4j -@Singleton -public class CertificateMemoryStore { - - private final CertificateLoader loader; - private final Map certificates = new HashMap<>(); - - @Inject - public CertificateMemoryStore(CertificateLoader loader) throws MalformedURLException { - this.loader = Objects.requireNonNull(loader); - } - - @PostConstruct - void init() { - List all = null; - try { - all = loader.loadAll(); - } catch (IOException e) { - log.debug("Error loading all certificates !", e); - } - ExtCert rootCert = loader.getCaCert(); - if(rootCert==null){ - throw new IllegalStateException("CA Certificate is not loaded!"); - } - if (all != null) { - for (ExtCert apolloCertificate : all) { - if (!apolloCertificate.verify(rootCert.getCertificate())) { - throw new IllegalStateException("Certificate is not valid, ca signature verification failed for " + apolloCertificate); - } - if (apolloCertificate.isValid(new Date())) { - throw new IllegalStateException("Certificate is out of valid time range: " + apolloCertificate); - } - certificates.put(apolloCertificate.getActorId(), apolloCertificate); - } - } - } - - public ExtCert getBySn(BigInteger sn) { - return certificates.get(sn); - } -} diff --git a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java b/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java deleted file mode 100644 index 51fd48c47a..0000000000 --- a/apl-id/src/main/java/com/apollocurrency/apl/id/utils/StringList.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.apollocurrency.apl.id.utils; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author al - */ -public class StringList { - public static String fromList(List sl) { - String res = ""; - for (int i = 0; i < sl.size(); i++) { - String semicolon = i < sl.size() - 1 ? ";" : ""; - res += sl.get(i) + semicolon; - } - return res; - } - - public static List fromString(String l) { - List res = new ArrayList<>(); - String[] ll = l.split(";"); - for (String s : ll) { - if (!s.isEmpty()) { - res.add(s); - } - } - return res; - } -} diff --git a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java b/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java deleted file mode 100644 index abe10eeeb2..0000000000 --- a/apl-id/src/test/java/com/apollocurrency/apl/id/cert/CertificateTest.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.apollocurrency.apl.id.cert; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; -import java.util.Date; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * @author alukin@gmail.com - */ -public class CertificateTest { - - private static final org.slf4j.Logger log = LoggerFactory.getLogger(CertificateTest.class); - static ExtCert acert; - - public CertificateTest() { - } - - @BeforeAll - public static void setUpClass() { - try (InputStream is = CertificateTest.class.getClassLoader().getResourceAsStream("test_cert.pem")) { - acert = CertKeyPersistence.loadPEMFromStream(is); - } catch (IOException ex) { - log.error("Can not load test certificate ", ex); - } catch (CertException ex) { - log.error("can not parse test certificate", ex); - } - } - - /** - * Test of getAuthorityId method, of class ApolloCertificate. - */ - @Test - public void testGetAuthorityId() { - AuthorityID result = acert.getAuthorityId(); - assertEquals(5139, result.getActorTypeAsInt()); - } - - /** - * Test of getCN method, of class ApolloCertificate. - */ - @Test - public void testGetCN() { - String result = acert.getCN(); - assertEquals("al.cn.ua", result); - } - - /** - * Test of getOrganization method, of class ApolloCertificate. - */ - @Test - public void testGetOrganization() { - String expResult = "FirstBridge"; - String result = acert.getOrganization(); - assertEquals(expResult, result); - } - - /** - * Test of getOrganizationUnit method, of class ApolloCertificate. - */ - @Test - public void testGetOrganizationUnit() { - String expResult = "FB-cn"; - String result = acert.getOrganizationUnit(); - assertEquals(expResult, result); - } - - /** - * Test of getCountry method, of class ApolloCertificate. - */ - @Test - public void testGetCountry() { - String expResult = "UA"; - String result = acert.getCountry(); - assertEquals(expResult, result); - } - - /** - * Test of getCity method, of class ApolloCertificate. - */ - @Test - public void testGetCity() { - String expResult = "Chernigiv"; - String result = acert.getCity(); - assertEquals(expResult, result); - } - - /** - * Test of getCertificatePurpose method, of class ApolloCertificate. - */ - @Test - public void testGetCertificatePurpose() { - String expResult = "Node"; - String result = acert.getCertificatePurpose(); - assertEquals(expResult, result); - } - - /** - * Test of getIPAddresses method, of class ApolloCertificate. - */ - @Test - public void testGetIPAddresses() { - List expResult = null; - List result = acert.getIPAddresses(); - assertEquals(expResult, result); - } - - /** - * Test of getDNSNames method, of class ApolloCertificate. - */ - @Test - public void testGetDNSNames() { - List expResult = null; - List result = acert.getDNSNames(); - assertEquals(expResult, result); - } - - /** - * Test of getStateOrProvince method, of class ApolloCertificate. - */ - @Test - public void testGetStateOrProvince() { - String expResult = null; - String result = acert.getStateOrProvince(); - assertEquals(expResult, result); - } - - /** - * Test of getEmail method, of class ApolloCertificate. - */ - @Test - public void testGetEmail() { - String expResult = "alukin@gmail.com"; - String result = acert.getEmail(); - assertEquals(expResult, result); - } - - /** - * Test of getCertPEM method, of class ApolloCertificate. - */ - @Test - public void testGetPEM() { - String result = acert.getCertPEM(); - assertEquals(true, result.startsWith("-----BEGIN CERTIFICATE----")); - } - - /** - * Test of isValid method, of class ApolloCertificate. - */ - @Test - public void testIsValid() { - Date date = null; - boolean expResult = false; - boolean result = acert.isValid(date); - assertEquals(expResult, result); - } - - /** - * Test of getSerial method, of class ApolloCertificate. - */ - @Test - public void testGetSerial() { - BigInteger result = acert.getSerial(); - BigInteger expResult = BigInteger.valueOf(1582313240538L); - assertEquals(expResult, result); - } - - @Test - public void testGetIssuerAttributes() { - CertAttributes cert_attr = acert.getIssuerAttrinutes(); - assertEquals("al.cn.ua", cert_attr.getCn()); - assertEquals("FirstBridge", cert_attr.getO()); - } - -} diff --git a/apl-id/src/test/resources/test_cert.pem b/apl-id/src/test/resources/test_cert.pem deleted file mode 100644 index 3e67d7af97..0000000000 --- a/apl-id/src/test/resources/test_cert.pem +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID5TCCA0agAwIBAgIGAXBpN/faMAoGCCqGSM49BAMEMIIBBDERMA8GA1UEAwwI -YWwuY24udWExEjAQBgNVBAcMCUNoZXJuaWdpdjEUMBIGA1UECgwLRmlyc3RCcmlk -Z2UxLzAtBgoJkiaJk/IsZAEBDB8wMDAyZGEwZTMyZTA3YjYxYzlmMDI1MWZlNjI3 -YTljMSkwJwYDVQQFEyAwMDAxZjFmY2Y4MmQxMzJmOWJiMDE4Y2E2NzM4YTE5ZjEO -MAwGA1UECwwFRkItY24xHzAdBgkqhkiG9w0BCQEWEGFsdWtpbkBnbWFpbC5jb20x -CzAJBgNVBAYTAlVBMSswKQYDVQQPDCIxNTE0MTMxMjExMTAwOTA4MDYwNzA2MDUw -NDAzMDIwMTAwMB4XDTIwMDIyMDE5MjcyMFoXDTIwMDIwNjAzNDUzMVowggEEMREw -DwYDVQQDDAhhbC5jbi51YTESMBAGA1UEBwwJQ2hlcm5pZ2l2MRQwEgYDVQQKDAtG -aXJzdEJyaWRnZTEvMC0GCgmSJomT8ixkAQEMHzAwMDJkYTBlMzJlMDdiNjFjOWYw -MjUxZmU2MjdhOWMxKTAnBgNVBAUTIDAwMDFmMWZjZjgyZDEzMmY5YmIwMThjYTY3 -MzhhMTlmMQ4wDAYDVQQLDAVGQi1jbjEfMB0GCSqGSIb3DQEJARYQYWx1a2luQGdt -YWlsLmNvbTELMAkGA1UEBhMCVUExKzApBgNVBA8MIjE1MTQxMzEyMTExMDA5MDgw -NjA3MDYwNTA0MDMwMjAxMDAwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYABAHDReX2 -jACnMlMwzEfrIqCD4UGRVJwQ3fi0UzayDAmWjrZ0pXqmcvI0DVBZfYHVJOhuD4za -bk8rusgKGESMqPDJjAH4Tq66MCk7eMpmiDlUg3nzBZ/IX57Iihph0vwyf+cc4SUC -H/9b1pUUL2XR6Ibhf6d91HunEIecbEv0AL4QvdjFJqNdMFswDgYDVR0PAQH/BAQD -AgSQMCoGA1UdJQEB/wQgMB4GCCsGAQUFBwMDBggrBgEFBQcDCAYIKwYBBQUHAwQw -DwYDVR0TAQH/BAUwAwEB/zAMBgNVHREBAf8EAjAAMAoGCCqGSM49BAMEA4GMADCB -iAJCALefzX2CR1Xog4sfb+6W5yNw9W/81uvFARF7dD0lE/eQVM+0vz/Fq74GGzao -bpsSO4YzEG0GGYFmotaPMQKnCoxaAkIBkGiNy4vggD47S+fEHNrUDrqiAFuTg3LW -Vl2S882/PjG9J0HSWv2d53xqOGDxR/RV6LjLrVxbSI9P49YNbGtpRLw= ------END CERTIFICATE----- diff --git a/apl-id/src/test/resources/test_cert_pvtkey.pem b/apl-id/src/test/resources/test_cert_pvtkey.pem deleted file mode 100644 index 422f918ec1..0000000000 --- a/apl-id/src/test/resources/test_cert_pvtkey.pem +++ /dev/null @@ -1,8 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIH3AgEAMBAGByqGSM49AgEGBSuBBAAjBIHfMIHcAgEBBEIBwfyQxUSPOpP/hno2 -GS9e+yJFCcGUCpTNMHlQQbOKgwOspAiRSSNt1jzoRW6j0Fo++Z04wSrFWJA0wsvH -6XU3khugBwYFK4EEACOhgYkDgYYABAHDReX2jACnMlMwzEfrIqCD4UGRVJwQ3fi0 -UzayDAmWjrZ0pXqmcvI0DVBZfYHVJOhuD4zabk8rusgKGESMqPDJjAH4Tq66MCk7 -eMpmiDlUg3nzBZ/IX57Iihph0vwyf+cc4SUCH/9b1pUUL2XR6Ibhf6d91HunEIec -bEv0AL4QvdjFJg== ------END PRIVATE KEY----- diff --git a/pom.xml b/pom.xml index 99e332d92b..b4f035bedb 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,6 @@ apl-bom apl-conf apl-exec - apl-id apl-comm From e850bf6f2cfab7cf3b7dd16ec0f737ad9695c38d Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 23 Sep 2020 13:11:18 +0300 Subject: [PATCH 18/42] Object communication library now is separate project --- apl-comm/pom.xml | 59 ---- .../apl/comm/sv/client/ConnectionStatus.java | 17 - .../apl/comm/sv/client/MessageDispatcher.java | 55 --- .../sv/client/ResponseTimeoutException.java | 14 - .../apl/comm/sv/client/SubscribePath.java | 21 -- .../SubscribePathAnnotationProcessor.java | 58 ---- .../apl/comm/sv/client/SvBusService.java | 42 --- .../apl/comm/sv/client/SvRequestHandler.java | 25 -- .../comm/sv/client/impl/HandlerRecord.java | 23 -- .../sv/client/impl/MessageDispatcherImpl.java | 318 ------------------ .../client/impl/MessageSendingException.java | 7 - .../sv/client/impl/PathParamProcessor.java | 129 ------- .../sv/client/impl/PathSpecification.java | 85 ----- .../comm/sv/client/impl/ResponseLatch.java | 63 ---- .../apl/comm/sv/client/impl/SvBusClient.java | 235 ------------- .../comm/sv/client/impl/SvBusServiceImpl.java | 98 ------ .../apl/comm/sv/client/impl/SvSessions.java | 90 ----- .../apl/comm/sv/msg/SvBusErrorCodes.java | 22 -- .../apl/comm/sv/msg/SvBusHello.java | 21 -- .../apl/comm/sv/msg/SvBusMessage.java | 22 -- .../apl/comm/sv/msg/SvBusRequest.java | 34 -- .../apl/comm/sv/msg/SvBusResponse.java | 36 -- .../apl/comm/sv/msg/SvBusStatus.java | 24 -- .../apl/comm/sv/msg/SvChannelHeader.java | 42 --- .../apl/comm/sv/msg/SvChannelMessage.java | 22 -- .../apl/comm/sv/msg/SvCommandRequest.java | 19 -- .../apl/comm/sv/msg/SvCommandResponse.java | 24 -- .../apl/comm/sv/msg/UpdateMessage.java | 18 - .../apl/comm/sv/ws/WSClient.java | 54 --- .../apl/comm/sv/ws/WSListener.java | 38 --- .../apl/comm/PathSpecificationTest.java | 82 ----- apl-core/pom.xml | 6 + pom.xml | 1 - 33 files changed, 6 insertions(+), 1798 deletions(-) delete mode 100644 apl-comm/pom.xml delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java delete mode 100644 apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java delete mode 100644 apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java diff --git a/apl-comm/pom.xml b/apl-comm/pom.xml deleted file mode 100644 index ba798deea7..0000000000 --- a/apl-comm/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - - com.apollocurrency - apollo-blockchain - 1.46.1 - - apl-comm - jar - - - org.projectlombok - lombok - provided - - - ch.qos.logback - logback-classic - - - org.slf4j - slf4j-api - - - com.fasterxml.jackson.datatype - jackson-datatype-json-org - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-annotations - - - - org.junit.platform - junit-platform-engine - test - - - org.junit.platform - junit-platform-commons - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - \ No newline at end of file diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java deleted file mode 100644 index 4b5c997507..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ConnectionStatus.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -/** - * Sv connection status - * - * @author alukin@gmail.com - */ -public enum ConnectionStatus { - NOT_CONNECTD, - CONNECTING, - CONNECTED, - DISCONNECTED, - ERROR -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java deleted file mode 100644 index fe656334ae..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/MessageDispatcher.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; - -/** - * Public interface to message dispatcher. Though dispatcher is a core of - * messaging subsystem, this interface contains registration of processing - * routines only. - * - * @author alukin@gmail.com - */ -public interface MessageDispatcher { - - /** - * path to error handler. If not handler is not defined, default logging - * handler is used - */ - String ERROR_PATH = "/error"; - - /** - * Register handler for incoming messages - * - * @param pathSpec path specification as for JAX-RX REST services - * @param rqMapping mapping class for request - * @param respMapping mapping class for response - * @param handler handler routine - */ - void registerRqHandler(String pathSpec, Class rqMapping, Class respMapping, SvRequestHandler handler); - - /** - * Register response mapping class for specified path - * @param pathSpec path for which given response class should be mapped - * @param respClass class to which response for given path should be mapped - */ - void registerResponseMapping(String pathSpec, Class respClass); - - /** - * Register response mapping class for specifed path, which is parametrized by another class - * @param pathSpec path for which given response mapping is intended - * @param responseClass base parametrized mapping class - * @param paramClass parameter class for base class - */ - void registerParametrizedResponseMapping(String pathSpec, Class responseClass, Class paramClass); - - /** - * Unregister handler for incoming messages - * - * @param pathSpec exactly as in registration call - */ - void unregisterRqHandler(String pathSpec); -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java deleted file mode 100644 index 9c9efa9194..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/ResponseTimeoutException.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.apollocurrency.apl.comm.sv.client; - -/** - * Represent exception occurred during sending request, when sender did not receive response for some amount of time - */ -public class ResponseTimeoutException extends RuntimeException{ - public ResponseTimeoutException(String message) { - super(message); - } - - public ResponseTimeoutException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java deleted file mode 100644 index f896588311..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePath.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation to authomtical registration of incomig message handler - * - * @author alukin@gmail.com - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.METHOD) -public @interface SubscribePath { - - public String value() default "/*"; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java deleted file mode 100644 index c14c586cfe..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SubscribePathAnnotationProcessor.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -import java.util.LinkedHashSet; -import java.util.Set; -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.Filer; -import javax.annotation.processing.Messager; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; -import javax.tools.Diagnostic; - -/** - * Attention! Not complete, annotations do not work yet - * - * @author alukin@gmail.com - */ -public class SubscribePathAnnotationProcessor extends AbstractProcessor { - - private Messager messager; - private Types typesUtil; - private Elements elementsUtil; - private Filer filer; - - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - typesUtil = processingEnv.getTypeUtils(); - elementsUtil = processingEnv.getElementUtils(); - filer = processingEnv.getFiler(); - } - - @Override - public boolean process(Set arg0, RoundEnvironment arg1) { - messager.printMessage(Diagnostic.Kind.WARNING, "========== processing subscribePath ============"); - return true; - } - - @Override - public Set getSupportedAnnotationTypes() { - Set annotations = new LinkedHashSet<>(); - annotations.add(SubscribePath.class.getCanonicalName()); - return annotations; - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); - } - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java deleted file mode 100644 index d094113cfe..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvBusService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -import com.apollocurrency.apl.comm.sv.msg.SvBusHello; -import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -/** - * Supervisor bus service, top part of communication API - * - * @author alukin@gmailcom - */ -public interface SvBusService { - - void addConnection(URI uri, boolean isDefault); - - void addResponseMapping(String path, Class tClass); - - void addParametrizedResponseMapping(String path, Class tClass, Class paramClass); - - Map getConnections(); - - MessageDispatcher getDispatcher(); - - T sendSync(SvBusRequest rq, String path, URI addr); - - CompletableFuture sendAsync(SvBusRequest msg, String path, URI addr); - - ConnectionStatus getConnectionStaus(URI uri); - - void shutdown(); - - void setMyInfo(SvBusHello info); - - URI getMyAddress(); -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java deleted file mode 100644 index 61aef2ab74..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/SvRequestHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client; - -import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; -import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; - -/** - * incoming message (request) handler prototype - * - * @author alukin@gmail.com - */ -public interface SvRequestHandler { - - /** - * handle command synchronously - * - * @param request - * @param header - * @return some reply message - */ - public SvBusResponse handleRequest(SvBusRequest request, SvChannelHeader header); -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java deleted file mode 100644 index 9b69ceeace..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/HandlerRecord.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; -import com.fasterxml.jackson.databind.JavaType; -import java.util.HashMap; -import java.util.Map; - -/** - * Record to save handler data and mappings - * - * @author alukin@gmail.com - */ -public class HandlerRecord { - - public String pathSpec; - public SvRequestHandler handler; - public JavaType respMapping; - public JavaType rqMapping; - public Map pathParams = new HashMap<>(); -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java deleted file mode 100644 index 7848af4660..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageDispatcherImpl.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; -import com.apollocurrency.apl.comm.sv.client.ResponseTimeoutException; -import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; -import com.apollocurrency.apl.comm.sv.msg.SvBusStatus; -import com.apollocurrency.apl.comm.sv.msg.SvBusErrorCodes; -import com.apollocurrency.apl.comm.sv.msg.SvBusHello; -import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; -import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; -import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; -import com.apollocurrency.apl.comm.sv.msg.SvChannelMessage; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonNode; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import java.net.SocketTimeoutException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Deque; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Implementation of MessageDispoatcher. Actually it is the core of messaging - * system that performs message passing from remote side to processing routines - * and back - * - * @author alukin@gmail.com - */ -@Slf4j -public class MessageDispatcherImpl implements MessageDispatcher { - - public static long RESPONSE_WAIT_TIMEOUT_MS = 500L; // TODO need to make it configurable - public static final int SAY_HELLO_ATTEMPTS = 5; - private final SvSessions connections; - private final PathParamProcessor pathMatcher; - private final Deque outgoingQueue = new LinkedList<>(); - private SvBusHello hello; - @Getter - private URI myAddress = null; - //TODO - // Which thread pool to use here with response wait latches? - ExecutorService executor = Executors.newCachedThreadPool(); - private final Map waiting = new ConcurrentHashMap<>(); - - public MessageDispatcherImpl() { - pathMatcher = new PathParamProcessor(); - connections = new SvSessions(this); - registerRqHandler("/hello", SvBusRequest.class, SvBusResponse.class, (req, header)-> { - log.info("Hello received from {}" + header.from); - return new SvBusResponse(new SvBusStatus(0, "Hello OK")); - }); - registerResponseMapping("/hello", SvBusResponse.class); - } - - public Map getConnections() { - return connections.getAll(); - } - - /** - * - * @return request handler that matches path specification - */ - private HandlerRecord findRqByPath(String path) { - HandlerRecord handlerRec = pathMatcher.findAndParse(path); - return handlerRec; - } - - @Override - public void registerRqHandler(String pathSpec, Class rqMapping, Class respMapping, SvRequestHandler handler) { - pathMatcher.registerRqHandler(pathSpec, rqMapping, respMapping, handler); - } - - @Override - public void registerResponseMapping(String pathSpec, Class respClass) { - pathMatcher.registerResponseMapping(pathSpec, respClass, null); - } - - @Override - public void registerParametrizedResponseMapping(String pathSpec, Class responseClass, Class paramClass) { - pathMatcher.registerResponseMapping(pathSpec, responseClass, paramClass); - } - - @Override - public void unregisterRqHandler(String pathSpec) { - pathMatcher.remove(pathSpec); - } - - long nextMessageId() { - return Math.round(Math.random() * (Long.MAX_VALUE - 1)); - } - - boolean isMyAddress(String to) throws URISyntaxException { - return myAddress.equals(new URI(to)); - } - - public SvBusResponse errornousRequestsHandler(JsonNode rqBody, SvChannelHeader rqHeader, int code, String errorInfo) { - SvBusStatus error = new SvBusStatus(code, errorInfo + " Request path: " + rqHeader.path); - SvBusResponse resp = new SvBusResponse(error); - - return resp; - } - - void addConnection(URI uri, boolean isDefault) { - SvBusClient client = new SvBusClient(uri, this); - connections.put(uri, client, isDefault); - client.connect(); - } - - private T getResponse(Long rqId) throws SocketTimeoutException { - T res = null; - ResponseLatch l = waiting.get(rqId); - if (l != null) { - res = l.get(RESPONSE_WAIT_TIMEOUT_MS); - } - return res; - } - - /** - * Send message to the specified address and wait for response - * @param rq message payload - * @param path url path to which request will be sent. For url 'ws://127.0.0.1:8080/path/to/resource' path is 'path/to/resource' - * @param addr network address which recipient's websocket server listen to. Example: 'ws://127.0.0.1:8080' - * @param type of returned response - * @return received response for sent message - * @throws ResponseTimeoutException when recipient did not respond to sent message in {@link MessageDispatcherImpl#RESPONSE_WAIT_TIMEOUT_MS} ms - * @throws MessageSendingException when response or message payload could not be serialized/deserialized - */ - public T sendSync(SvBusMessage rq, String path, URI addr) { - SvBusClient client = connections.get(addr); - if (client == null) { - client = connections.getDefault().getValue(); - } - SvChannelHeader header = new SvChannelHeader(); - header.from = myAddress.toString(); - header.to = addr.toString(); - header.path = path; - header.messageId = nextMessageId(); - SvChannelMessage env = new SvChannelMessage(); - env.header = header; - env.body = rq; - try { - if (!client.sendMessage(env)) { - outgoingQueue.addLast(env); - } - waiting.put(header.messageId, new ResponseLatch()); - try { - return getResponse(header.messageId); - } catch (SocketTimeoutException e) { - throw new ResponseTimeoutException("Unable to get response after waiting for " + RESPONSE_WAIT_TIMEOUT_MS + " ms", e); - } - } catch (JsonProcessingException ex) { - throw new MessageSendingException("Can not map response to JSON", ex); - } - } - - public CompletableFuture sendAsync(SvBusRequest rq, String path, URI addr) { - CompletableFuture res = CompletableFuture.supplyAsync(() -> sendSync(rq, path, addr), executor); - return res; - } - - void sendHello(URI addr) { - sendSync(hello, "/hello", addr); - } - - void replyTo(SvChannelHeader rqHeader, SvBusMessage m) { - SvChannelHeader header = new SvChannelHeader(); - header.from = myAddress.toString(); - header.to = rqHeader.from; - //TODO: etire path or prefix only without path parameters? - header.path = rqHeader.path; - header.inResponseTo = rqHeader.messageId; - header.messageId = nextMessageId(); - SvBusClient client = connections.get(URI.create(header.to)); - if (client == null) { - client = connections.getDefault().getValue(); - } - SvChannelMessage env = new SvChannelMessage(); - env.body = m; - env.header = header; - try { - if (!client.sendMessage(env)) { - outgoingQueue.addLast(env); - } - } catch (JsonProcessingException ex) { - log.error("Can not map response to JSON"); - } - } - - void handleResponse(JsonNode body, SvChannelHeader header) { - ResponseLatch rl = waiting.get(header.inResponseTo); - if (rl == null) { - log.warn("Got responce that is not in waiting map. Header: {}", header); - } else { - JavaType responseType = pathMatcher.findResponseMappingClass(header.path); - if (responseType == null) { // Maybe set here error response to unlock latch? - if (header.path.equals(MessageDispatcher.ERROR_PATH)) { - log.error("Error reply without destination path: Header: {}, Body: {}", header, body); - } else { - log.error("No response mapper found for path: {}", header.path); - } - } else { - SvBusResponse response = pathMatcher.convertResponse(body, responseType); - rl.setResponse(response); - } - } - } - - void handleRequest(JsonNode body, SvChannelHeader header) { - HandlerRecord handlerRec = findRqByPath(header.path); - SvBusResponse response; - if (handlerRec != null) { - SvBusRequest rq = pathMatcher.convertRequest(body, handlerRec); - try { - response = handlerRec.handler.handleRequest(rq, header); - } catch (Exception e) { - log.error("Error in handler method for path {}", handlerRec.pathSpec, e); - response = errornousRequestsHandler(body, header, SvBusErrorCodes.PROCESSING_ERROR, e.getMessage()); - } - replyTo(header, response); - } else { - response = errornousRequestsHandler(body, header, SvBusErrorCodes.NO_HANDLER, "No handler registered."); - replyTo(header, response); - } - } - - void handleIncoming(SvChannelHeader header, JsonNode body) { - try { - if (!isMyAddress(header.to)) { - int res = routeMessage(header, body); - } else { - //TODO maybe better to encapsulate such logic inside header? - if (header.inResponseTo != null) { //this is response - handleResponse(body, header); - } else { - handleRequest(body, header); - } - } - } catch (URISyntaxException e) { - replyTo(header, new SvBusResponse(new SvBusStatus(1, "Incorrect target uri: " + header.to))); - } - } - - void onConnectionUp(URI uri) { - - SvBusClient client = connections.get(uri); - //should never happend - if (client == null) { - log.error("Connection {} was not added", uri); - return; - } - List toRemove = new ArrayList<>(); - trySayHello(uri); - boolean def = connections.isDefault(uri); - for (SvChannelMessage m : outgoingQueue) { - if (def || m.header.to.equals(uri.toString())) { - try { - if (client.sendMessage(m)) { - toRemove.add(m); - } - } catch (JsonProcessingException ex) { - log.error("Can not map message to JSON"); - } - } - } - - outgoingQueue.removeAll(toRemove); - } - - private void trySayHello(URI uri) { - int attempts = SAY_HELLO_ATTEMPTS; - while (true) { - attempts--; - try { - sendHello(uri); - break; - } catch (ResponseTimeoutException e) { - if (attempts == 0) { - throw new MessageSendingException("Unable to send hello to " + uri + " due to response timeout", e); - } - try { - Thread.sleep(500); - } catch (InterruptedException ex) { - } - } - } - } - - void shutdown() { - executor.shutdown(); - connections.close(); - } - - void setMyInfo(SvBusHello info) { - hello = info; - myAddress = URI.create(info.clientAddr); - } - - private int routeMessage(SvChannelHeader header, JsonNode body) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java deleted file mode 100644 index 175bf4f9f3..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/MessageSendingException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.apollocurrency.apl.comm.sv.client.impl; - -public class MessageSendingException extends RuntimeException { - public MessageSendingException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java deleted file mode 100644 index 46dc3d6dd2..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathParamProcessor.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.SvRequestHandler; -import com.apollocurrency.apl.comm.sv.msg.SvBusMessage; -import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * JAX-RS -like path specifications processor - * - * @author alukin@gmail.com - */ -@Slf4j -public class PathParamProcessor { - - private final Map rqHandlers = new ConcurrentHashMap<>(); - private final Map responseMappingClasses = new ConcurrentHashMap<>(); - @Getter - private final ObjectMapper mapper; - - public PathParamProcessor() { - //init mapper - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - } - - boolean canDistinguish(String pathSpec) { - return true; - } - - public boolean registerRqHandler(String pathSpec, Class rqMapping, Class respMapping, SvRequestHandler handler) { - boolean res = false; - PathSpecification spec = PathSpecification.fromSpecString(pathSpec); - if (findHandler(spec.prefix) != null) { - log.error("Request handler for path specification with prefix {} is already registered", spec.prefix); - } else { - res = true; - HandlerRecord hrec = new HandlerRecord(); - hrec.pathSpec = pathSpec; - hrec.handler = handler; - hrec.rqMapping = mapper.constructType(rqMapping); - hrec.respMapping = mapper.constructType(respMapping); - rqHandlers.putIfAbsent(spec, hrec); - } - return res; - } - - public boolean registerResponseMapping(String pathSpec, Class respMapping, Class parametrizedClass) { - PathSpecification spec = PathSpecification.fromSpecString(pathSpec); - boolean alreadyExist = findResponseMappingClass(spec.prefix) != null; - if (alreadyExist) { - log.error("Response class for path specification with prefix {} is already registered", spec.prefix); - } else { - JavaType typeToRegister; - if (parametrizedClass != null) { - typeToRegister = mapper.getTypeFactory().constructParametricType(respMapping, parametrizedClass); - } else { - typeToRegister = mapper.constructType(respMapping); - } - responseMappingClasses.put(spec, typeToRegister); - } - return alreadyExist; - } - - public HandlerRecord findAndParse(String path) { - HandlerRecord res = null; - for (PathSpecification ps : rqHandlers.keySet()) { - if (ps.matches(path)) { - res = rqHandlers.get(ps); - res.pathParams.clear(); - res.pathParams.putAll(ps.parseParams(path)); - break; - } - } - return res; - } - - void remove(String pathSpec) { - for (PathSpecification ps : rqHandlers.keySet()) { - if (ps.pathSpec.equals(pathSpec)) { - rqHandlers.remove(ps); - break; - } - } - } - - public SvBusRequest convertRequest(JsonNode body, HandlerRecord hr) { - SvBusRequest res = mapper.convertValue(body, hr.rqMapping); - return res; - } - - public HandlerRecord findHandler(String path) { - return findOneBySpec(path, rqHandlers); - } - public JavaType findResponseMappingClass(String path) { - JavaType oneBySpec = findOneBySpec(path, responseMappingClasses); - return oneBySpec; - } - - private T findOneBySpec(String path, Map map) { - for (PathSpecification ps : map.keySet()) { - if (ps.matches(path)) { - return map.get(ps); - } - } - return null; - } - - public T convertResponse(JsonNode body, JavaType responseClass) { - T res = mapper.convertValue(body, responseClass); - return res; - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java deleted file mode 100644 index c2b8be969f..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/PathSpecification.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import lombok.extern.slf4j.Slf4j; - -/** - * Path specification as in JAX-RS example: /messages/{id}/{code} All values are - * handled as strings, it is up to processing code how to convert it - * - * @author alukin@gmail.com - */ -@Slf4j -public class PathSpecification { - - public String prefix; - public List paramNames = new ArrayList<>(); - public String pathSpec; - - public PathSpecification() { - } - - public static PathSpecification fromSpecString(String pathSpec) { - PathSpecification res = new PathSpecification(); - res.pathSpec = pathSpec; - String[] elements = pathSpec.split("/"); - int bracePos = pathSpec.indexOf("{"); - if (bracePos > 0) { - res.prefix = pathSpec.substring(0, bracePos - 1); - for (String element : elements) { - if (element.startsWith("{")) { - if (element.endsWith("}")) { - res.paramNames.add(element.substring(1, element.length() - 1)); - } else { //TODO consider throwing exception here - log.error("Missing brace in path element {} of path sepce: {}", element, pathSpec); - res.paramNames.add(element.substring(1, element.length())); - } - } - } - } else { - res.prefix = pathSpec; - } - - return res; - } - - public boolean matches(String path) { - boolean res = false; - int len = prefix.length(); - if (path.length() >= len) { - String matching = path.substring(0, len); - if (matching.equals(prefix)) { - res = true; - } - } - return res; - } - - public Map parseParams(String path) { - Map res = new HashMap<>(); - String params = path.substring(prefix.length()); - if (!params.isEmpty()) { - String[] elements = params.split("/"); - //first element after split() may be "" - int start = 0; - if (elements.length > 0) { - if (elements[0].isEmpty()) { - start = 1; - } - } - for (int i = start; i < elements.length; i++) { - if (i >= paramNames.size() + start) { - break; - } - res.put(paramNames.get(i - start), elements[i]); - } - } - return res; - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java deleted file mode 100644 index 074742ed83..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/ResponseLatch.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; -import lombok.extern.slf4j.Slf4j; - -import java.net.SocketTimeoutException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -/** - * Latch to response waiting - * - * @author alukin@gmail.com - */ -@Slf4j -public class ResponseLatch { - - /** - * time to live of entry. Entry should de deleted if it is older - */ - public static long WSW_TTL_MS = 60000; //1 minute - private final CountDownLatch latch = new CountDownLatch(1); - private final long createTime = System.currentTimeMillis(); - /** - * Response message - */ - private volatile SvBusResponse response; - - /** - * Wait for the response - *

- * The caller must hold the lock for the request condition - * - * @param timeoutMs Wait timeout - * @return Response message - * @throws java.net.SocketTimeoutException - */ - public T get(long timeoutMs) throws SocketTimeoutException { - try { - if (!latch.await(timeoutMs, TimeUnit.MILLISECONDS)) { - throw new SocketTimeoutException("WebSocket response wait timeout (" + timeoutMs + "ms) exceeded"); - } - } catch (InterruptedException ex) { - log.debug("Interruptrd exception while waiting for response", ex); - Thread.currentThread().interrupt(); - } - return (T) response; - } - - public void setResponse(T response) { - this.response = response; - latch.countDown(); - } - - public boolean isOld() { - long now = System.currentTimeMillis(); - boolean res = (now - createTime) > WSW_TTL_MS; - return res; - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java deleted file mode 100644 index 8563a863f4..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusClient.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; -import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; -import com.apollocurrency.apl.comm.sv.msg.SvBusStatus; -import com.apollocurrency.apl.comm.sv.msg.SvBusErrorCodes; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; -import com.apollocurrency.apl.comm.sv.msg.SvChannelHeader; -import com.apollocurrency.apl.comm.sv.msg.SvChannelMessage; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -import java.io.Closeable; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.WebSocket; -import java.net.http.WebSocket.Listener; -import java.nio.ByteBuffer; -import java.util.Date; -import java.util.concurrent.CompletionException; -import java.util.concurrent.CompletionStage; - -/** - * Client of Apollo Supervisor or similar service with the same protocol. - * - * @author alukin@gmail.com - */ -@Slf4j -public class SvBusClient implements Listener, Closeable { - - private ConnectionStatus state = ConnectionStatus.NOT_CONNECTD; - private WebSocket webSocket; - @Getter - private final URI serverURI; - private final HttpClient httpClient; - - private PathParamProcessor pathProcessor; - private final MessageDispatcherImpl dispatcher; - - public SvBusClient(URI serverURI, MessageDispatcher dispatcher) { - this.pathProcessor = new PathParamProcessor(); - this.dispatcher = (MessageDispatcherImpl) dispatcher; - this.serverURI = serverURI; - httpClient = HttpClient.newHttpClient(); - - } - - public boolean isConnected() { - return state == ConnectionStatus.CONNECTED; - } - - public ConnectionStatus getState() { - return state; - } - - private void setState(ConnectionStatus cs) { - state = cs; - } - - /** - * Connect to given by constructor URI - * - * @return true if connected - */ - public boolean connect() { - boolean res; - setState(ConnectionStatus.CONNECTING); - try { - webSocket = httpClient.newWebSocketBuilder() - .buildAsync(serverURI, this) - .join(); - res = !webSocket.isInputClosed(); - if (res) { - dispatcher.onConnectionUp(serverURI); - } - } catch (CompletionException ex) { - setState(ConnectionStatus.ERROR); - log.info("Can not connect to {}", serverURI); - res = false; - } catch (Exception e) { - res = false; - setState(ConnectionStatus.ERROR); - log.error("Unknown error occurred during connection to " + serverURI, e); - } - return res; - } - - public WebSocket getWebSocket() { - return webSocket; - } - - public boolean sendMessage(SvChannelMessage envelope) throws JsonProcessingException { - boolean res = false; - //TODO: binary mode with binary header - envelope.header.from_timestamp = new Date(); - ObjectMapper mapper = pathProcessor.getMapper(); - String msg = mapper.writeValueAsString(envelope); - if (webSocket != null) { - webSocket.sendText(msg, true); - //TODO may be join() ? - res = true; - } else { - log.error("Websocket is not connected error"); - } - return res; - } - - public void sendError(int code, String message, SvChannelHeader rqheader) { - SvBusStatus error = new SvBusStatus(code, message); - SvBusResponse resp = new SvBusResponse(error); - SvChannelHeader hdr = new SvChannelHeader(); - hdr.from = dispatcher.getMyAddress().toString(); - if (rqheader != null) { - hdr.to = rqheader.from; - hdr.path = rqheader.path; - hdr.inResponseTo = hdr.messageId; - } else { - hdr.to = serverURI.toString(); - hdr.path = MessageDispatcher.ERROR_PATH; - hdr.inResponseTo = 0L; - } - hdr.from_timestamp = new Date(); - hdr.messageId = dispatcher.nextMessageId(); - SvChannelMessage msg = new SvChannelMessage(hdr, resp); - try { //trying my besr, no result check - sendMessage(msg); - } catch (JsonProcessingException ex) { - } - } - -// should be common for binary and text mode - private void processIncoming(CharSequence data, boolean bin) { - try { - ObjectMapper mapper = pathProcessor.getMapper(); - JsonNode env_node = mapper.readTree(data.toString()); - JsonNode header_node = env_node.findValue("header"); - if (header_node == null) { - sendError(SvBusErrorCodes.INVALID_HEADER, "no header node in JSON", null); - log.error("No header in incoming message"); - return; - } - SvChannelHeader header = mapper.treeToValue(header_node, SvChannelHeader.class); - if (header == null) { - log.error("Can not parse header. Message: {}", data); - sendError(SvBusErrorCodes.INVALID_HEADER, "Invalid header node in JSON", null); - return; - } - JsonNode body = env_node.findValue("body"); // same as above, i think that better to add validation for npes to guarantee message correct format - if (body == null) { - log.warn("No body node in JSON"); - } - dispatcher.handleIncoming(header, body); - } catch (JsonProcessingException ex) { - sendError(SvBusErrorCodes.INVALID_MESSAGE, "Invalud JSON message: " + ex.getMessage(), null); - log.error("JSON processing error. Message: {}", data, ex); - } - } - - //TODO: implement - private SvChannelMessage decodeBinary(ByteBuffer data) { - log.error("Binary mode is not implemented yet"); - return null; - } - - //TODO: implement - private ByteBuffer encodeBinary(SvChannelMessage data) { - log.error("Binary mode is not implemented yet"); - return null; - } - - @Override - public CompletionStage onText(WebSocket webSocket, CharSequence data, boolean last) { - - log.debug("onText: {}", data); - processIncoming(data, false); - return Listener.super.onText(webSocket, data, last); - } - - @Override - public void onOpen(WebSocket webSocket) { - setState(ConnectionStatus.CONNECTED); - Listener.super.onOpen(webSocket); - } - - @Override - public CompletionStage onClose(WebSocket webSocket, int statusCode, - String reason) { - log.debug("onClose: {} {}", statusCode, reason); - setState(ConnectionStatus.DISCONNECTED); - return Listener.super.onClose(webSocket, statusCode, reason); - } - - @Override - public void onError(WebSocket webSocket, Throwable error) { - setState(state.ERROR); //TODO maybe save or print error stacktrace - log.debug("Error: ", error); - Listener.super.onError(webSocket, error); - } - - @Override - public CompletionStage onPong(WebSocket webSocket, ByteBuffer message) { - log.debug("onPong: "); - return Listener.super.onPong(webSocket, message); - } - - @Override - public CompletionStage onPing(WebSocket webSocket, ByteBuffer message) { - log.debug("onPing: "); - return Listener.super.onPing(webSocket, message); - } - - @Override - public CompletionStage onBinary(WebSocket webSocket, ByteBuffer data, boolean last) { - - // processIncoming(webSocket, decodeBinary(data), true); - return Listener.super.onBinary(webSocket, data, last); - } - - @Override - public void close() { - if (webSocket != null) { - webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"); - } - } - - void sendText(CharSequence value) { - webSocket.sendText(value, true); - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java deleted file mode 100644 index dd8f47b38a..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvBusServiceImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; -import com.apollocurrency.apl.comm.sv.client.MessageDispatcher; -import com.apollocurrency.apl.comm.sv.client.SvBusService; -import com.apollocurrency.apl.comm.sv.msg.SvBusHello; -import com.apollocurrency.apl.comm.sv.msg.SvBusRequest; -import com.apollocurrency.apl.comm.sv.msg.SvBusResponse; - -import java.net.URI; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -/** - * Implementation of bus service - * - * @author alukin@gmail.com - */ -public class SvBusServiceImpl implements SvBusService { - - private final MessageDispatcherImpl dispatcher; - - public SvBusServiceImpl() { - SvBusHello hello = new SvBusHello(); - hello.clientPID = ProcessHandle.current().pid(); - hello.clientExePath = ""; - hello.clientInfo = "SvClient"; - dispatcher = new MessageDispatcherImpl(); - } - - @Override - public void addConnection(URI uri, boolean isDefault) { - dispatcher.addConnection(uri, isDefault); - } - - @Override - public void addResponseMapping(String path, Class tClass) { - dispatcher.registerResponseMapping(path, tClass); - } - - @Override - public void addParametrizedResponseMapping(String path, Class tClass, Class paramClass) { - dispatcher.registerParametrizedResponseMapping(path, tClass, paramClass); - } - - @Override - public Map getConnections() { - Map clients = dispatcher.getConnections(); - Map statuses = new HashMap<>(); - for (URI key : clients.keySet()) { - statuses.put(key, clients.get(key).getState()); - } - return statuses; - } - - @Override - public MessageDispatcher getDispatcher() { - return dispatcher; - } - - @Override - public T sendSync(SvBusRequest rq, String path, URI addr) { - T resp = dispatcher.sendSync(rq, path, addr); - return resp; - } - - @Override - public CompletableFuture sendAsync(SvBusRequest msg, String path, URI addr) { - return dispatcher.sendAsync(msg, path, addr); - } - - @Override - public ConnectionStatus getConnectionStaus(URI uri) { - Map statuses = getConnections(); - ConnectionStatus res = statuses.get(uri); - return res; - } - - @Override - public void shutdown() { - dispatcher.shutdown(); - } - - @Override - public URI getMyAddress() { - return dispatcher.getMyAddress(); - } - - @Override - public void setMyInfo(SvBusHello info) { - dispatcher.setMyInfo(info); - } - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java deleted file mode 100644 index 4a5cefc945..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/client/impl/SvSessions.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.client.impl; - -import com.apollocurrency.apl.comm.sv.client.ConnectionStatus; -import lombok.extern.slf4j.Slf4j; - -import java.net.URI; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Set of all connections inited - * - * @author alukin@gmail.com - */ -@Slf4j -public class SvSessions { - - private final Map connections = new ConcurrentHashMap<>(); - private final Timer timer; - public static final long CONNECT_INTERVAL_MS = 5000; - private Map.Entry defaultConnection; - private final MessageDispatcherImpl dispatecher; - - public SvSessions(MessageDispatcherImpl dispatecher) { - this.dispatecher = dispatecher; - //init connection restore timer task - //TODO: use our thread pool manager maybe - //TODO: ScheduledThreadPoolExecutor is preferred to Timer, better to use it - timer = new Timer("SypervisorConnectionChekcer", true); - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - for (URI key : connections.keySet()) { - SvBusClient client = connections.get(key); - if (!client.isConnected() && client.getState() != ConnectionStatus.CONNECTING) { - boolean res = client.connect(); - log.debug("Connection attempt to URI {} result: {}, state: {}", key, res, - client.getState() - ); - if (res) { - dispatecher.onConnectionUp(key); - } - } - } - } - - }, 0, CONNECT_INTERVAL_MS); - } - - public Map getAll() { - return connections; - } - - void put(URI uri, SvBusClient client, boolean isDefault) { - boolean setDefault = false; - //first one is default even if isDefault is false - if (connections.isEmpty()) { - setDefault = true; - } - connections.putIfAbsent(uri, client); - if (setDefault || isDefault) { - defaultConnection = connections.entrySet().iterator().next(); - } - } - - boolean isDefault(URI addr) { - return defaultConnection != null && defaultConnection.getKey().equals(addr); - } - - SvBusClient get(URI addr) { - return connections.get(addr); - } - - Map.Entry getDefault() { - return defaultConnection; - } - - void close() { - timer.cancel(); - connections.values().forEach(c -> { - c.close(); - }); - } - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java deleted file mode 100644 index 99a75571c6..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusErrorCodes.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -/** - * Error codes for communication channel - * - * @author alukin@gmail.com - */ -public class SvBusErrorCodes { - - public static final int OK = 0; - public static final int NOT_CONNECTED = 1; - public static final int NO_ROUTE = 2; - public static final int NO_HANDLER = 3; - public static final int PROCESSING_ERROR = 4; - public static final int INVALID_HEADER = 5; - public static final int INVALID_MESSAGE = 6; - public static final int INVALID_BODY = 7; - public static final int RESPONSE_TIMEOUT = 8; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java deleted file mode 100644 index edc0a48e9c..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusHello.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; - -/** - * Hello message to be sent by any client on connection. It is needed to say - * server client's address in header and other info - * - * @author alukin@gmail.con - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SvBusHello extends SvBusRequest { - - public Long clientPID; - public String clientExePath; - public String clientAddr; - public String clientInfo; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java deleted file mode 100644 index 4cd0a15800..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusMessage.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.Setter; - -/** - * Simple message on bus - * - * @author alukin@gmail.com - */ -@JsonInclude(Include.NON_NULL) -@Getter -@Setter -public class SvBusMessage { - - private String message; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java deleted file mode 100644 index faf42c6db7..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.HashMap; -import java.util.Map; - -/** - * Request (incoming message) in SV channel - * - * @author alukin@gmail.com - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SvBusRequest extends SvBusMessage { - - private final Map parameters = new HashMap<>(); - - public SvBusRequest(Map parameters) { - this.parameters.putAll(parameters); - } - - public SvBusRequest() {} - - public void add(T t, V v) { - parameters.put(t.toString(), v.toString()); - } - - public String get(String param) { - return parameters.get(param); - } - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java deleted file mode 100644 index ea9ab2b48a..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - * This class represents REST response in the channel - * - * @author alukin@gmail.com - */ -@EqualsAndHashCode(callSuper = true) -@JsonInclude(Include.NON_NULL) -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SvBusResponse extends SvBusMessage { - - /** - * Error code, 0 or null means success - */ - private SvBusStatus status; - - - @JsonIgnore - public boolean isSuccessful() { - return status == null || status.getCode() == 0; - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java deleted file mode 100644 index 9a52443192..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvBusStatus.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Status message body on the bus - * - * @author alukin@gmail.com - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SvBusStatus { - - private Integer code = 0; - private String description = "OK"; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java deleted file mode 100644 index 5e4edf2613..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelHeader.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.Date; - -/** - * This class represents "envelope" header format for all messages going trough - * messaging systems of Apollo Supervisor Null fields ignored on serializing. - * - * @author alukinb@gmail.conm - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SvChannelHeader { - - /** - * Each message has random unique ID - */ - public Long messageId; - /** - * If message is not request but response it should have this set to message - * Id of request. If it is null, message is request or just message that - * does not require response. - */ - public Long inResponseTo; - /** - * Often we have to route request to some REST API or use publish/subscribe - * magic for messages. Type of request or message going to this path is - * fixed and we interpret it inside of appropriate processing routine. with - * path parameters and request parameters - */ - public String path; - - public String from; - public String to; - public String routedBy; - public Date from_timestamp; - public Date route_timestamp; - -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java deleted file mode 100644 index 8ded29538a..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvChannelMessage.java +++ /dev/null @@ -1,22 +0,0 @@ - -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; - -/** - * This class represents "envelope" message format for all - * messages going trough messaging systems of Apollo Supervisor - * Null fields ignored on serializing. - * @author alukinb@gmail.conm - */ -@NoArgsConstructor -@AllArgsConstructor -public class SvChannelMessage { - public SvChannelHeader header = new SvChannelHeader(); - public Object body; -} - diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java deleted file mode 100644 index f62137db94..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.HashMap; - -/** - * This class represents command request to supervisor - * - * @author alukin@gmail.com - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SvCommandRequest extends SvBusRequest { - - public String cmd; - public HashMap params = new HashMap<>(); -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java deleted file mode 100644 index 5b9aa47d95..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/SvCommandResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.ArrayList; -import java.util.List; - -/** - * Responce to incoming command message - * - * @author alukin@gmail.com - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class SvCommandResponse extends SvBusResponse { - - public List out = new ArrayList<>(); - public List err = new ArrayList<>(); - - public SvCommandResponse(SvBusStatus error) { - super(error); - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java deleted file mode 100644 index 33f81fe6ae..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/msg/UpdateMessage.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright © 2020 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.msg; - -import com.fasterxml.jackson.annotation.JsonInclude; - -/** - * Update indication message TODO: adapt it for uptater2 - * - * @author alukin@gmail.com - */ -@JsonInclude(JsonInclude.Include.NON_NULL) -public class UpdateMessage extends SvBusMessage { - - public String version; - public Integer priority; -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java deleted file mode 100644 index 16a37e52b3..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSClient.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2018 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.ws; - -import java.io.Closeable; -import java.net.URI; -import java.net.http.HttpClient; -import java.net.http.WebSocket; -import java.net.http.WebSocket.Listener; - -/** - * JDK-11 and above WebSocket client without any external dependencies - * - * @author alukin@gmail.com - */ -public class WSClient implements Closeable { - - private Listener wsListener; - private HttpClient client; - private WebSocket webSocket; - - public WebSocket getWebSocket() { - return webSocket; - } - - public WSClient(Listener wsListener) { - this.wsListener = wsListener; - client = HttpClient.newHttpClient(); - } - - /** - * Connect to given URI - * - * @param uri Example: "wss://localhost:8443/wsEndpoint" - * @return true if connected - */ - public boolean connect(String uri) { - boolean res = false; - webSocket = client.newWebSocketBuilder() - .buildAsync(URI.create(uri), wsListener) - .join(); - return !webSocket.isInputClosed(); - } - - public void sendText(String text) { - webSocket.sendText(text, true); - } - - @Override - public void close() { - webSocket.sendClose(WebSocket.NORMAL_CLOSURE, "ok"); - } -} diff --git a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java b/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java deleted file mode 100644 index a971c63297..0000000000 --- a/apl-comm/src/main/java/com/apollocurrency/apl/comm/sv/ws/WSListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2018 Apollo Foundation - */ -package com.apollocurrency.apl.comm.sv.ws; - -import java.net.http.WebSocket; -import java.net.http.WebSocket.Listener; -import java.util.concurrent.CompletionStage; - -/** - * Simple web socket listener to work with Apl Supervisor protocol - * - * @author alukin@gmail.com - */ -public class WSListener implements Listener { - - @Override - public CompletionStage onText(WebSocket webSocket, - CharSequence data, boolean last) { - - System.out.println("onText: " + data); - - return Listener.super.onText(webSocket, data, last); - } - - @Override - public void onOpen(WebSocket webSocket) { - System.out.println("onOpen"); - Listener.super.onOpen(webSocket); - } - - @Override - public CompletionStage onClose(WebSocket webSocket, int statusCode, - String reason) { - System.out.println("onClose: " + statusCode + " " + reason); - return Listener.super.onClose(webSocket, statusCode, reason); - } -} diff --git a/apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java b/apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java deleted file mode 100644 index 9bd305e01b..0000000000 --- a/apl-comm/src/test/java/com/apollocurrency/apl/comm/PathSpecificationTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.apollocurrency.apl.comm; - -import com.apollocurrency.apl.comm.sv.client.impl.PathSpecification; -import java.util.Map; -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - -/** - * - * @author al - */ -public class PathSpecificationTest { - - public PathSpecificationTest() { - } - - - /** - * Test of fromSpecString method, of class PathSpecification. - */ - @Test - public void testFromSpecString() { - String pathSpec1 = "/test/one/{param1}/{param2}"; - PathSpecification result1 = PathSpecification.fromSpecString(pathSpec1); - - assertEquals("/test/one", result1.prefix); - assertEquals("param1", result1.paramNames.get(0)); - assertEquals("param2", result1.paramNames.get(1)); - - String pathSpec2 = "/test/two/one"; - PathSpecification result2 = PathSpecification.fromSpecString(pathSpec2); - - assertEquals("/test/two/one", result2.prefix); - assertEquals(0, result2.paramNames.size()); - - String pathSpec3 = "/test/one/{param1/{param2}"; - PathSpecification result3 = PathSpecification.fromSpecString(pathSpec3); - - assertEquals("/test/one", result3.prefix); - assertEquals("param1", result3.paramNames.get(0)); - assertEquals("param2", result3.paramNames.get(1)); - } - - /** - * Test of matches method, of class PathSpecification. - */ - @Test - public void testMatches() { - String pathSpec = "/test/one/{param1}/{param2}"; - PathSpecification ps = PathSpecification.fromSpecString(pathSpec); - boolean result1 = ps.matches("/test/one/1"); - assertEquals(true,result1); - boolean result2 = ps.matches("/test/one/1/2/3"); - assertEquals(true,result2); - } - - /** - * Test of parseParams method, of class PathSpecification. - */ - @Test - public void testParseParams() { - String pathSpec = "/test/one/{param1}/{param2}"; - PathSpecification ps = PathSpecification.fromSpecString(pathSpec); - Map params = ps.parseParams("/test/one/1"); - assertEquals("1", params.get("param1")); - assertEquals(null, params.get("param2")); - - Map params1 = ps.parseParams("/test/one/1/2"); - assertEquals("1", params1.get("param1")); - assertEquals("2", params1.get("param2")); - - Map params2 = ps.parseParams("test/one/1/2"); - assertEquals("1", params1.get("param1")); - assertEquals("2", params1.get("param2")); - } - -} diff --git a/apl-core/pom.xml b/apl-core/pom.xml index d0527c09d4..ebc640a0b5 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -41,6 +41,12 @@ fb-identity 1.0.0 + + io.firstbridge + fb-comm + 1.0.0 + + ch.qos.logback logback-classic diff --git a/pom.xml b/pom.xml index b4f035bedb..5027aa71f2 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,6 @@ apl-bom apl-conf apl-exec - apl-comm From 476ff3ae41ed535233f4a8e6bb3e8c44d91ffc66 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 23 Sep 2020 13:23:14 +0300 Subject: [PATCH 19/42] Verions of fb-comm and fp-identity from apl-bom-ext 1.0.3 --- apl-core/pom.xml | 2 -- pom.xml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apl-core/pom.xml b/apl-core/pom.xml index ebc640a0b5..dc24f153b4 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -39,12 +39,10 @@ io.firstbridge fb-identity - 1.0.0 io.firstbridge fb-comm - 1.0.0 diff --git a/pom.xml b/pom.xml index 5027aa71f2..88b4a77e9c 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ 1.0.10 - 1.0.2 + 1.0.3 ApolloWallet/apollo-blockchain 1.9.1 From 7388f86197a8d3bbf606dc63a3efdb5baa0f251a Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 23 Sep 2020 16:13:27 +0300 Subject: [PATCH 20/42] compiation fix --- .../aplwallet/apl/security/id/CertificateLoaderProducer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java index 83e1d32491..977b439a36 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java @@ -1,7 +1,7 @@ package com.apollocurrency.aplwallet.apl.security.id; -import com.apollocurrency.apl.id.utils.CertificateLoader; import com.apollocurrency.aplwallet.apl.util.Constants; +import io.firstbridge.identity.utils.CertificateLoader; import javax.enterprise.inject.Produces; import javax.inject.Singleton; From a6fdd24e9880de89578ac07b90243f005cb9f73e Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Thu, 24 Sep 2020 17:40:43 +0300 Subject: [PATCH 21/42] Fix of compilation with new libs --- apl-core/pom.xml | 5 ----- .../aplwallet/apl/core/peer/PeerHttpServer.java | 1 - .../aplwallet/apl/core/peer/PeersService.java | 2 +- .../aplwallet/apl/security/id/IdentityService.java | 5 +++-- .../aplwallet/apl/security/id/IdentityServiceImpl.java | 10 ++++++---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apl-core/pom.xml b/apl-core/pom.xml index dc24f153b4..ab4d8a3bda 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -19,11 +19,6 @@ apl-utils ${project.version} - - com.apollocurrency - apl-id - ${project.version} - com.apollocurrency apl-api diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java index 2032d761a6..13dd60aa87 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerHttpServer.java @@ -3,7 +3,6 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; -import com.apollocurrency.apl.id.handler.ThisActorIdHandler; import com.apollocurrency.aplwallet.apl.core.app.runnable.TaskDispatchManager; import com.apollocurrency.aplwallet.apl.core.http.JettyConnectorCreator; import com.apollocurrency.aplwallet.apl.crypto.Convert; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 959cee8ad0..749711da66 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -19,7 +19,6 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; -import com.apollocurrency.apl.id.handler.ThisActorIdHandler; import com.apollocurrency.aplwallet.api.dto.TransactionDTO; import com.apollocurrency.aplwallet.api.p2p.PeerInfo; import com.apollocurrency.aplwallet.api.p2p.request.BaseP2PRequest; @@ -57,6 +56,7 @@ import com.apollocurrency.aplwallet.apl.util.task.Tasks; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; +import io.firstbridge.identity.handler.ThisActorIdHandler; import lombok.Getter; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java index 73566c0f0f..b35d630ca4 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java @@ -3,8 +3,9 @@ */ package com.apollocurrency.aplwallet.apl.security.id; -import com.apollocurrency.apl.id.handler.IdValidator; -import com.apollocurrency.apl.id.handler.ThisActorIdHandler; +import io.firstbridge.identity.handler.IdValidator; +import io.firstbridge.identity.handler.ThisActorIdHandler; + /** * Service that handles identity of peers using X.509 certificates od nodes diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index 641ff6ecba..efe7f94e23 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -3,11 +3,13 @@ */ package com.apollocurrency.aplwallet.apl.security.id; -import com.apollocurrency.apl.id.handler.IdValidator; -import com.apollocurrency.apl.id.handler.IdValidatorImpl; -import com.apollocurrency.apl.id.handler.ThisActorIdHandler; -import com.apollocurrency.apl.id.handler.ThisActorIdHandlerImpl; + + import com.apollocurrency.aplwallet.apl.util.env.dirprovider.ConfigDirProvider; +import io.firstbridge.identity.handler.IdValidator; +import io.firstbridge.identity.handler.IdValidatorImpl; +import io.firstbridge.identity.handler.ThisActorIdHandler; +import io.firstbridge.identity.handler.ThisActorIdHandlerImpl; import java.io.File; import javax.inject.Inject; From e188e00b76d426e130bdcaab22c804b522080e47 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 29 Sep 2020 13:17:40 +0300 Subject: [PATCH 22/42] PeerDao and PeerEntry update for ID support --- .../PeerDb.java => dao/appdata/PeerDao.java} | 77 ++++++------------- .../aplwallet/apl/core/db/AplDbVersion.java | 5 +- .../apl/core/entity/appdata/BlockIndex.java | 3 + .../apl/core/entity/appdata/PeerEntity.java | 39 ++++++++++ .../apl/core/peer/GetMorePeersThread.java | 25 +++--- .../aplwallet/apl/core/peer/Peer.java | 11 ++- .../aplwallet/apl/core/peer/PeerImpl.java | 25 ++++-- .../apl/core/peer/PeerLoaderThread.java | 21 ++--- .../aplwallet/apl/core/peer/PeersService.java | 20 +++-- .../apl/core/peer/endpoint/GetInfo.java | 7 +- .../apl/testutil/EntityProducer.java | 17 ++-- 11 files changed, 152 insertions(+), 98 deletions(-) rename apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/{peer/PeerDb.java => dao/appdata/PeerDao.java} (69%) create mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerDb.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java similarity index 69% rename from apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerDb.java rename to apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java index ed4ae55305..026b536be7 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerDb.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java @@ -18,9 +18,11 @@ * Copyright © 2018 Apollo Foundation */ -package com.apollocurrency.aplwallet.apl.core.peer; +package com.apollocurrency.aplwallet.apl.core.dao.appdata; import com.apollocurrency.aplwallet.apl.core.dao.TransactionalDataSource; +import com.apollocurrency.aplwallet.apl.core.entity.appdata.PeerEntity; +import com.apollocurrency.aplwallet.apl.core.peer.Peer; import com.apollocurrency.aplwallet.apl.core.service.appdata.DatabaseManager; import com.apollocurrency.aplwallet.apl.util.annotation.DatabaseSpecificDml; import com.apollocurrency.aplwallet.apl.util.annotation.DmlMarker; @@ -36,23 +38,30 @@ import java.util.List; @Singleton -public class PeerDb { +public class PeerDao { private static DatabaseManager databaseManager; @Inject - public PeerDb(DatabaseManager databaseManagerParam) { + public PeerDao(DatabaseManager databaseManagerParam) { databaseManager = databaseManagerParam; } - static List loadPeers() { - List peers = new ArrayList<>(); + public List loadPeers() { + List peers = new ArrayList<>(); TransactionalDataSource dataSource = databaseManager.getDataSource(); try (Connection con = dataSource.getConnection(); PreparedStatement pstmt = con.prepareStatement("SELECT * FROM peer"); ResultSet rs = pstmt.executeQuery()) { while (rs.next()) { - peers.add(new Entry(rs.getString("address"), rs.getLong("services"), rs.getInt("last_updated"))); + peers.add(new PeerEntity( + rs.getString("address"), + rs.getLong("services"), + rs.getInt("last_updated"), + rs.getString("x509pem"), + rs.getString("ip_and_port") + ) + ); } } catch (SQLException e) { throw new RuntimeException(e.toString(), e); @@ -60,7 +69,7 @@ static List loadPeers() { return peers; } - public static void deletePeer(Entry peer) { + public void deletePeer(PeerEntity peer) { TransactionalDataSource dataSource = databaseManager.getDataSource(); try (Connection con = dataSource.getConnection()) { PreparedStatement pstmt = con.prepareStatement("DELETE FROM peer WHERE address = ?"); @@ -71,11 +80,11 @@ public static void deletePeer(Entry peer) { } } - static void deletePeers(Collection peers) { + public void deletePeers(Collection peers) { TransactionalDataSource dataSource = databaseManager.getDataSource(); try (Connection con = dataSource.getConnection(); PreparedStatement pstmt = con.prepareStatement("DELETE FROM peer WHERE address = ?")) { - for (Entry peer : peers) { + for (PeerEntity peer : peers) { pstmt.setString(1, peer.getAddress()); pstmt.executeUpdate(); } @@ -84,14 +93,14 @@ static void deletePeers(Collection peers) { } } - static void updatePeers(Collection peers) { + public void updatePeers(Collection peers) { TransactionalDataSource dataSource = databaseManager.getDataSource(); dataSource.begin(); try (Connection con = dataSource.getConnection(); @DatabaseSpecificDml(DmlMarker.MERGE) PreparedStatement pstmt = con.prepareStatement("MERGE INTO peer " - + "(address, services, last_updated) KEY(address) VALUES(?, ?, ?)")) { - for (Entry peer : peers) { + + "(address, services, last_updated, x509pem, ip_and_port) KEY(address) VALUES(?, ?, ?, ?, ?)")) { + for (PeerEntity peer : peers) { pstmt.setString(1, peer.getAddress()); pstmt.setLong(2, peer.getServices()); pstmt.setInt(3, peer.getLastUpdated()); @@ -104,7 +113,7 @@ static void updatePeers(Collection peers) { } } - static void updatePeer(PeerImpl peer) { + public void updatePeer(Peer peer) { TransactionalDataSource dataSource = databaseManager.getDataSource(); dataSource.begin(); try (Connection con = dataSource.getConnection(); @@ -122,46 +131,4 @@ static void updatePeer(PeerImpl peer) { } } - static class Entry { - private final String address; - private final long services; - private final int lastUpdated; - - Entry(String address, long services, int lastUpdated) { - this.address = address; - this.services = services; - this.lastUpdated = lastUpdated; - } - - public String getAddress() { - return address; - } - - public long getServices() { - return services; - } - - public int getLastUpdated() { - return lastUpdated; - } - - @Override - public int hashCode() { - return address.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return (obj != null && (obj instanceof Entry) && address.equals(((Entry) obj).address)); - } - - @Override - public String toString() { - return "PeerEntry{" + - "address='" + address + '\'' + - ", services=" + services + - ", lastUpdated=" + lastUpdated + - '}'; - } - } } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java index a23b9d21e3..67e6e28a10 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java @@ -901,7 +901,10 @@ protected int update(int nextUpdate) { case 352: apply("ALTER TABLE transaction ALTER COLUMN signature VARBINARY NULL DEFAULT NULL"); case 353: - return 353; + apply("ALTER TABLE peer ADD COLUMN x509pem TEXT NULL DEFAULT NULL"); + apply("ALTER TABLE peer ADD COLUMN ip_and_port VARCHAR NULL DEFAULT NULL"); + case 354: + return 354; default: throw new RuntimeException("Blockchain database inconsistent with code, at update " + nextUpdate + ", probably trying to run older code on newer database"); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java index 58ac0438dc..b2a2df7742 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java @@ -1,3 +1,6 @@ +/* + * Copyright © 2019-2020 Apollo Foundation + */ package com.apollocurrency.aplwallet.apl.core.entity.appdata; import lombok.AllArgsConstructor; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java new file mode 100644 index 0000000000..3251ce6ec4 --- /dev/null +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2019-2020 Apollo Foundation + */ +package com.apollocurrency.aplwallet.apl.core.entity.appdata; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * DB record of known peer + * + * @author alukin@gmail.com + */ +@Data +@AllArgsConstructor +public class PeerEntity { + + /** + * In previous version address is public IP, but now it could be IP:port or + * 256 bit identity in hexadecimal form + */ + private String address; + /** + * Services of node + */ + private long services; + /** + * time of last update in seconds + */ + private int lastUpdated; + /** + * X.509 certificate of node in PEM format + */ + private String x509pem; + /** + * Last seen on IP and port (IPv4 or IPv6) + */ + private String ipAndPort; +} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java index 1454097001..4a24543a33 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java @@ -3,9 +3,11 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; +import com.apollocurrency.aplwallet.apl.core.dao.appdata.PeerDao; import com.apollocurrency.aplwallet.api.p2p.request.AddPeersRequest; import com.apollocurrency.aplwallet.api.p2p.request.GetPeersRequest; import com.apollocurrency.aplwallet.api.p2p.respons.GetPeersResponse; +import com.apollocurrency.aplwallet.apl.core.entity.appdata.PeerEntity; import com.apollocurrency.aplwallet.apl.core.peer.parser.GetPeersResponseParser; import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import org.slf4j.Logger; @@ -28,11 +30,12 @@ class GetMorePeersThread implements Runnable { private final PeersService peersService; private final GetPeersRequest getPeersRequest; private volatile boolean updatedPeer; - + private PeerDao peerDao; public GetMorePeersThread(TimeService timeService, PeersService peersService) { this.timeService = timeService; this.peersService = peersService; + this.peerDao = peersService.getPeerDao(); getPeersRequest = new GetPeersRequest(peersService.blockchainConfig.getChain().getChainId()); } @@ -74,7 +77,7 @@ public void run() { } } } - if (PeersService.savePeers && updatedPeer) { + if (peersService.savePeers && updatedPeer) { updateSavedPeers(); updatedPeer = false; } @@ -114,14 +117,14 @@ private void updateSavedPeers() { // // Load the current database entries and map announced address to database entry // - List oldPeers = PeerDb.loadPeers(); - Map oldMap = new HashMap<>(oldPeers.size()); + List oldPeers = peerDao.loadPeers(); + Map oldMap = new HashMap<>(oldPeers.size()); oldPeers.forEach((entry) -> oldMap.put(entry.getAddress(), entry)); // // Create the current peer map (note that there can be duplicate peer entries with // the same announced address) // - Map currentPeers = new HashMap<>(); + Map currentPeers = new HashMap<>(); UUID chainId = peersService.blockchainConfig.getChain().getChainId(); peersService.getPeers( peer -> peer.getAnnouncedAddress() != null @@ -129,20 +132,20 @@ private void updateSavedPeers() { && chainId.equals(peer.getChainId()) && now - peer.getLastUpdated() < 7 * 24 * 3600 ).forEach((peer) -> { - currentPeers.put(peer.getAnnouncedAddress(), new PeerDb.Entry(peer.getAnnouncedAddress(), peer.getServices(), peer.getLastUpdated())); + currentPeers.put(peer.getIdentity(), new PeerEntity(peer.getAnnouncedAddress(), peer.getServices(), peer.getLastUpdated(),peer.getX509pem(),peer.getHostWithPort())); }); // // Build toDelete and toUpdate lists // - List toDelete = new ArrayList<>(oldPeers.size()); + List toDelete = new ArrayList<>(oldPeers.size()); oldPeers.forEach((entry) -> { if (currentPeers.get(entry.getAddress()) == null) { toDelete.add(entry); } }); - List toUpdate = new ArrayList<>(currentPeers.size()); + List toUpdate = new ArrayList<>(currentPeers.size()); currentPeers.values().forEach((entry) -> { - PeerDb.Entry oldEntry = oldMap.get(entry.getAddress()); + PeerEntity oldEntry = oldMap.get(entry.getAddress()); if (oldEntry == null || entry.getLastUpdated() - oldEntry.getLastUpdated() > 24 * 3600) { toUpdate.add(entry); } @@ -158,8 +161,8 @@ private void updateSavedPeers() { // try { - PeerDb.deletePeers(toDelete); - PeerDb.updatePeers(toUpdate); + peerDao.deletePeers(toDelete); + peerDao.updatePeers(toUpdate); } catch (Exception e) { throw e; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java index 527323ba1c..ee9c72b8fe 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java @@ -31,6 +31,13 @@ import java.util.UUID; public interface Peer extends Comparable { + /** + * ID of peer. It is UID field of X.509 certificate + * To keep a temporary compatibility with old peers, + * it could be announced address with port + * @return + */ + String getIdentity(); boolean providesService(Service service); @@ -116,8 +123,6 @@ public interface Peer extends Comparable { T send(BaseP2PRequest request, JsonReqRespParser parser) throws PeerNotConnectedException; - boolean isTrusted(); - PeerTrustLevel getTrustLevel(); long getServices(); @@ -131,6 +136,8 @@ public interface Peer extends Comparable { void setServices(long code); void setLastUpdated(int time); + + String getX509pem(); enum Service { HALLMARK(1), // Hallmarked node diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 42ebc2b8a1..60fda6fc2a 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -42,6 +42,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; import com.google.common.util.concurrent.TimeLimiter; +import io.firstbridge.identity.cert.ExtCert; import lombok.Getter; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; @@ -104,7 +105,8 @@ public final class PeerImpl implements Peer { private TimeService timeService; @Getter private volatile int failedConnectAttempts = 0; - + private String peerId; + PeerImpl(PeerAddress addrByFact, PeerAddress announcedAddress, BlockchainConfig blockchainConfig, @@ -921,11 +923,6 @@ public String toString() { '}'; } - @Override - public boolean isTrusted() { - return getTrustLevel().getCode() > PeerTrustLevel.REGISTERED.getCode(); - } - @Override public PeerTrustLevel getTrustLevel() { //TODO implement using Apollo ID @@ -978,4 +975,20 @@ public boolean processError(JSONObject message) { } } + @Override + public String getX509pem() { + return pi.getX509_cert(); + } + + @Override + public String getIdentity() { + String res; + if (peerId!=null){ + res = peerId; + }else{ + res = getAnnouncedAddress(); // host with port? + } + return res; + } + } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java index e06454bec3..5cf324bdfb 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java @@ -3,11 +3,12 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; +import com.apollocurrency.aplwallet.apl.core.dao.appdata.PeerDao; +import com.apollocurrency.aplwallet.apl.core.entity.appdata.PeerEntity; import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.enterprise.inject.spi.CDI; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,37 +21,39 @@ class PeerLoaderThread implements Runnable { private static final Logger LOG = LoggerFactory.getLogger(PeerLoaderThread.class); private final List defaultPeers; private final List> unresolvedPeers; - private final Set entries = new HashSet<>(); + private final Set entries = new HashSet<>(); private final TimeService timeService; private final PeersService peersService; - private PeerDb peerDb; + private PeerDao peerDao; public PeerLoaderThread(List defaultPeers, List> unresolvedPeers, TimeService timeService, PeersService peersService) { this.defaultPeers = defaultPeers; this.unresolvedPeers = unresolvedPeers; this.timeService = timeService; - this.peersService = peersService; + this.peersService = peersService; } @Override public void run() { LOG.trace("'Peer loader': thread starting..."); - if (peerDb == null) { - peerDb = CDI.current().select(PeerDb.class).get(); + if (peerDao == null) { + peerDao = peersService.getPeerDao(); } final int now = timeService.getEpochTime(); + //TODO: add enties after connection established and x.509 is known peersService.wellKnownPeers.forEach((address) -> { PeerAddress pa = new PeerAddress(address); - entries.add(new PeerDb.Entry(pa.getAddrWithPort(), 0, now)); + entries.add(new PeerEntity(pa.getAddrWithPort(), 0, now,null,pa.getAddrWithPort())); }); + //TODO: re-define default peers if (peersService.usePeersDb) { LOG.debug("'Peer loader': Loading 'well known' peers from the database..."); defaultPeers.forEach((address) -> { PeerAddress pa = new PeerAddress(address); - entries.add(new PeerDb.Entry(pa.getAddrWithPort(), 0, now)); + entries.add(new PeerEntity(pa.getAddrWithPort(), 0, now, null, pa.getAddrWithPort())); }); if (peersService.savePeers) { - List dbPeers = peerDb.loadPeers(); + List dbPeers = peerDao.loadPeers(); dbPeers.forEach((entry) -> { if (!entries.add(entry)) { // Database entries override entries from chains.json diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 749711da66..e630adcd20 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -19,6 +19,7 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; +import com.apollocurrency.aplwallet.apl.core.dao.appdata.PeerDao; import com.apollocurrency.aplwallet.api.dto.TransactionDTO; import com.apollocurrency.aplwallet.api.p2p.PeerInfo; import com.apollocurrency.aplwallet.api.p2p.request.BaseP2PRequest; @@ -27,6 +28,7 @@ import com.apollocurrency.aplwallet.apl.core.app.runnable.TaskDispatchManager; import com.apollocurrency.aplwallet.apl.core.app.runnable.limiter.TimeLimiterService; import com.apollocurrency.aplwallet.apl.core.chainid.BlockchainConfig; +import com.apollocurrency.aplwallet.apl.core.entity.appdata.PeerEntity; import com.apollocurrency.aplwallet.apl.core.entity.blockchain.Block; import com.apollocurrency.aplwallet.apl.core.entity.blockchain.Transaction; import com.apollocurrency.aplwallet.apl.core.http.API; @@ -96,7 +98,7 @@ public class PeersService { private static final Version MAX_VERSION = Constants.VERSION; private static final int sendTransactionsBatchSize = 100; private final static String BACKGROUND_SERVICE_NAME = "PeersService"; - public static int DEFAULT_CONNECT_TIMEOUT = 2000; //2s default websocket connect timeout + public static final int DEFAULT_CONNECT_TIMEOUT = 2000; //2s default websocket connect timeout public static int connectTimeout = DEFAULT_CONNECT_TIMEOUT; public static boolean getMorePeers; //TODO: hardcode in Constants and use from there @@ -117,8 +119,8 @@ public class PeersService { static boolean isGzipEnabled; static int minNumberOfKnownPeers; static boolean enableHallmarkProtection; - static boolean usePeersDb; - static boolean savePeers; + boolean usePeersDb; + boolean savePeers; static boolean cjdnsOnly; private static String myHallmark; private static int maxNumberOfInboundConnections; @@ -168,13 +170,15 @@ public class PeersService { private final TransactionConverter transactionConverter; private final BlockConverter blockConverter; - + @Getter + private final PeerDao peerDao; @Inject public PeersService(PropertiesHolder propertiesHolder, BlockchainConfig blockchainConfig, Blockchain blockchain, TimeService timeService, TaskDispatchManager taskDispatchManager, PeerHttpServer peerHttpServer, TimeLimiterService timeLimiterService, AccountService accountService, IdentityService identityService, + PeerDao peerDao, TransactionSerializer transactionSerializer, BlockSerializer blockSerializer, TransactionConverter transactionConverter, @@ -191,7 +195,7 @@ public PeersService(PropertiesHolder propertiesHolder, BlockchainConfig blockcha this.blockSerializer = blockSerializer; this.identityService = identityService; - + this.peerDao = peerDao; this.transactionConverter = transactionConverter; this.blockConverter = blockConverter; @@ -291,7 +295,7 @@ public void init() { addListener(peer -> peersExecutorService.submit(() -> { if (peer.getAnnouncedAddress() != null && !peer.isBlacklisted()) { try { - PeerDb.updatePeer((PeerImpl) peer); + peerDao.updatePeer(peer); } catch (RuntimeException e) { LOG.error("Unable to update peer database", e); } @@ -710,8 +714,8 @@ void cleanupPeers(Peer peer) { public Peer removePeer(Peer peer) { Peer p = null; if (peer.getAnnouncedAddress() != null) { - PeerDb.Entry entry = new PeerDb.Entry(peer.getAnnouncedAddress(), 0, 0); - PeerDb.deletePeer(entry); + PeerEntity entry = new PeerEntity(peer.getIdentity(), 0, 0,null,peer.getHostWithPort()); + peerDao.deletePeer(entry); if (connectablePeers.containsKey(peer.getAnnouncedAddress())) { p = connectablePeers.remove(peer.getAnnouncedAddress()); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java index f97ad7a7db..1d0c835570 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java @@ -63,12 +63,17 @@ public final class GetInfo extends PeerRequestHandler { public GetInfo(TimeService timeService) { this.timeService = timeService; } - + + private void processPeerIdentity(PeerInfo pi){ + + } + @Override public JSONStreamAware processRequest(JSONObject req, Peer peer) { PeerImpl peerImpl = (PeerImpl) peer; PeerInfo pi = mapper.convertValue(req, PeerInfo.class); log.trace("GetInfo - PeerInfo from request = {}", pi); + processPeerIdentity(pi); peerImpl.setLastUpdated(timeService.getEpochTime()); long origServices = peerImpl.getServices(); String servicesString = pi.getServices(); diff --git a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java index 895834c877..fc91f7c751 100644 --- a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java +++ b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java @@ -32,6 +32,18 @@ public static Peer createPeer(final String host, final String announcedAddress, final PeerState state = active ? PeerState.CONNECTED : PeerState.NON_CONNECTED; Peer peer = new Peer() { + + @Override + public String getIdentity() { + return getHostWithPort(); + } + + @Override + public String getX509pem() { + return null; + } + + @Override public int compareTo(Peer o) { return 0; @@ -227,11 +239,6 @@ public String getHostWithPort() { return null; } - @Override - public boolean isTrusted() { - return false; - } - @Override public PeerTrustLevel getTrustLevel() { return PeerTrustLevel.NOT_TRUSTED; From b7604e6da314d9ec74d57d7256de85ab8b216e4b Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 29 Sep 2020 17:46:22 +0300 Subject: [PATCH 23/42] PeerImpl add identity processing and some cleanup --- .../aplwallet/apl/core/peer/PeerImpl.java | 157 +++++++++--------- .../apl/core/peer/endpoint/GetInfo.java | 9 +- 2 files changed, 77 insertions(+), 89 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 60fda6fc2a..5aa07faba0 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -42,7 +42,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; import com.google.common.util.concurrent.TimeLimiter; +import io.firstbridge.identity.cert.ActorType; +import io.firstbridge.identity.cert.CertException; +import io.firstbridge.identity.cert.CertKeyPersistence; import io.firstbridge.identity.cert.ExtCert; +import io.firstbridge.identity.utils.Hex; +import java.io.ByteArrayInputStream; import lombok.Getter; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; @@ -51,10 +56,12 @@ import org.slf4j.Logger; import java.io.IOException; +import java.io.InputStream; import java.io.StringWriter; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.channels.ClosedChannelException; +import java.security.cert.X509Certificate; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; @@ -67,12 +74,13 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import lombok.Setter; import static org.slf4j.LoggerFactory.getLogger; public final class PeerImpl implements Peer { private static final Logger LOG = getLogger(PeerImpl.class); - + @Getter private final String host; private final Object servicesMonitor = new Object(); private final ReadWriteLock stateLock = new ReentrantReadWriteLock(); @@ -82,31 +90,42 @@ public final class PeerImpl implements Peer { private final Blockchain blockchain; private final PeersService peers; private final AccountService accountService; + @Getter private final PeerInfo pi = new PeerInfo(); //Jackson JSON private final ObjectMapper mapper = new ObjectMapper(); @Getter private final Peer2PeerTransport p2pTransport; + @Getter private volatile int port; + @Getter private Hallmark hallmark; private EnumSet disabledAPIs; + @Getter private Version version; private volatile boolean isOldVersion; private volatile long adjustedWeight; private volatile int blacklistingTime; - private volatile String blacklistingCause; + @Getter + private volatile String blacklistingCause = "unknown"; + @Getter private PeerState state; + @Getter @Setter private volatile int lastUpdated; + @Getter private volatile int lastConnectAttempt; private volatile long hallmarkBalance = -1; private volatile int hallmarkBalanceHeight; private volatile long services; + @Getter private BlockchainState blockchainState; private TimeService timeService; @Getter private volatile int failedConnectAttempts = 0; private String peerId; - + @Getter + private PeerTrustLevel trustLevel = PeerTrustLevel.NOT_TRUSTED; + PeerImpl(PeerAddress addrByFact, PeerAddress announcedAddress, BlockchainConfig blockchainConfig, @@ -142,21 +161,12 @@ public final class PeerImpl implements Peer { this.accountService = accountService; } - @Override - public String getHost() { - return host; - } - @Override public String getHostWithPort() { PeerAddress pa = new PeerAddress(port, host); return pa.getAddrWithPort(); } - @Override - public PeerState getState() { - return state; - } private void setState(PeerState newState) { // if we are even not connected and some routine say to disconnect @@ -196,11 +206,6 @@ public long getUploadedVolume() { return p2pTransport.getUploadedVolume(); } - @Override - public Version getVersion() { - return version; - } - public void setVersion(Version version) { boolean versionChanged = version == null || !version.equals(this.version); this.version = version; @@ -307,10 +312,6 @@ public void setApiServerIdleTimeout(Integer apiServerIdleTimeout) { pi.setApiServerIdleTimeout(apiServerIdleTimeout); } - @Override - public BlockchainState getBlockchainState() { - return blockchainState; - } public void setBlockchainState(Integer blockchainStateInt) { if (blockchainStateInt >= 0 && blockchainStateInt < BlockchainState.values().length) { @@ -347,15 +348,6 @@ void setAnnouncedAddress(String announcedAddress) { this.port = pa.getPort(); } - @Override - public int getPort() { - return port; - } - - @Override - public Hallmark getHallmark() { - return hallmark; - } private void setHallmark(Hallmark hallmark) { this.hallmark = hallmark; @@ -450,16 +442,6 @@ public void remove() { peers.notifyListeners(this, PeersService.Event.REMOVE); } - @Override - public int getLastUpdated() { - return lastUpdated; - } - - @Override - public void setLastUpdated(int lastUpdated) { - this.lastUpdated = lastUpdated; - } - @Override public boolean isInbound() { return pi.getAnnouncedAddress() == null; @@ -480,16 +462,6 @@ public boolean isOutboundSocket() { return p2pTransport.isOutbound(); } - @Override - public String getBlacklistingCause() { - return blacklistingCause == null ? "unknown" : blacklistingCause; - } - - @Override - public int getLastConnectAttempt() { - return lastConnectAttempt; - } - @Override public long getLastActivityTime() { return p2pTransport.getLastActivity(); @@ -667,6 +639,7 @@ public synchronized boolean handshake() { setPlatform(newPi.getPlatform()); setShareAddress(newPi.getShareAddress()); + setX509pem(newPi.getX509_cert()); if (!PeersService.ignorePeerAnnouncedAddress) { if (newPi.getAnnouncedAddress() != null && newPi.getShareAddress()) { @@ -896,38 +869,6 @@ public StringBuilder getPeerApiUri() { return uri; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PeerImpl peer = (PeerImpl) o; - return port == peer.port && - Objects.equals(host, peer.host) && - Objects.equals(pi.getAnnouncedAddress(), peer.getAnnouncedAddress()); - } - - @Override - public int hashCode() { - return Objects.hash(host, pi.getAnnouncedAddress(), port); - } - - @Override - public String toString() { - return "Peer{" + - "state=" + getState() + - ", announcedAddress='" + pi.getAnnouncedAddress() + '\'' + - ", services=" + services + - ", host='" + host + '\'' + - ", application ='" + getApplication() + '\'' + - ", version='" + version + '\'' + - '}'; - } - - @Override - public PeerTrustLevel getTrustLevel() { - //TODO implement using Apollo ID - return PeerTrustLevel.NOT_TRUSTED; - } /** * process error from transport and application level @@ -974,12 +915,35 @@ public boolean processError(JSONObject message) { return true; } } - + +//--------- X.509 certificates related methods @Override public String getX509pem() { return pi.getX509_cert(); } + public void setX509pem(String pem) { + if (pem == null || pem.isEmpty()){ + return; + } + InputStream is = new ByteArrayInputStream(pem.getBytes()); + ExtCert xc=null; + X509Certificate caCert = null; + try { + xc = CertKeyPersistence.loadPEMFromStream(is); + if (xc.isSelfSigned()){ + trustLevel = PeerTrustLevel.REGISTERED; + }else if(xc.isSignedBy(caCert)){ + trustLevel = PeerTrustLevel.TRUSTED; + if( (xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) !=0 ){ + trustLevel = PeerTrustLevel.SYSTEM_TRUSTED; + } + } + peerId=Hex.encode(xc.getActorId()); + } catch (IOException | CertException ex) { + } + } + @Override public String getIdentity() { String res; @@ -990,5 +954,32 @@ public String getIdentity() { } return res; } + +//----------- overwitten methods of Object + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PeerImpl peer = (PeerImpl) o; + return port == peer.port && + Objects.equals(host, peer.host) && + Objects.equals(pi.getAnnouncedAddress(), peer.getAnnouncedAddress()); + } + + @Override + public int hashCode() { + return Objects.hash(host, pi.getAnnouncedAddress(), port); + } + @Override + public String toString() { + return "Peer{" + + "state=" + getState() + + ", announcedAddress='" + pi.getAnnouncedAddress() + '\'' + + ", services=" + services + + ", host='" + host + '\'' + + ", application ='" + getApplication() + '\'' + + ", version='" + version + '\'' + + '}'; + } } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java index 1d0c835570..65ea8d98d3 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java @@ -63,17 +63,15 @@ public final class GetInfo extends PeerRequestHandler { public GetInfo(TimeService timeService) { this.timeService = timeService; } - - private void processPeerIdentity(PeerInfo pi){ - - } + @Override public JSONStreamAware processRequest(JSONObject req, Peer peer) { PeerImpl peerImpl = (PeerImpl) peer; PeerInfo pi = mapper.convertValue(req, PeerInfo.class); log.trace("GetInfo - PeerInfo from request = {}", pi); - processPeerIdentity(pi); + + peerImpl.setX509pem(pi.getX509_cert()); peerImpl.setLastUpdated(timeService.getEpochTime()); long origServices = peerImpl.getServices(); String servicesString = pi.getServices(); @@ -96,7 +94,6 @@ public JSONStreamAware processRequest(JSONObject req, Peer peer) { } if (!announcedAddress.equals(peerImpl.getAnnouncedAddress())) { log.trace("GetInfo: peer " + peer.getHost() + " changed announced address from " + peer.getAnnouncedAddress() + " to " + announcedAddress); - int oldPort = peerImpl.getPort(); lookupPeersService().setAnnouncedAddress(peerImpl, announcedAddress); } } else { From 9f6e0ad188d7d660f7cdfc65bc521aad9117aa3d Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 30 Sep 2020 14:46:10 +0300 Subject: [PATCH 24/42] Fix of DB version update --- .../apollocurrency/aplwallet/apl/core/db/AplDbVersion.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java index 67e6e28a10..f4c7599a05 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java @@ -901,8 +901,8 @@ protected int update(int nextUpdate) { case 352: apply("ALTER TABLE transaction ALTER COLUMN signature VARBINARY NULL DEFAULT NULL"); case 353: - apply("ALTER TABLE peer ADD COLUMN x509pem TEXT NULL DEFAULT NULL"); - apply("ALTER TABLE peer ADD COLUMN ip_and_port VARCHAR NULL DEFAULT NULL"); + apply("ALTER TABLE peer ADD COLUMN x509pem TEXT NULL DEFAULT NULL;" + + "ALTER TABLE peer ADD COLUMN ip_and_port VARCHAR NULL DEFAULT NULL"); case 354: return 354; default: From 5e7b8cb13793f5d116e3d7fb2172239f5dd0bb8e Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 30 Sep 2020 15:47:05 +0300 Subject: [PATCH 25/42] DBMigrationExecutorTest disabled, see comments --- .../com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java | 2 +- .../apl/core/migrator/db/DbMigrationExecutorTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java index f4c7599a05..20ff9bee57 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/db/AplDbVersion.java @@ -901,7 +901,7 @@ protected int update(int nextUpdate) { case 352: apply("ALTER TABLE transaction ALTER COLUMN signature VARBINARY NULL DEFAULT NULL"); case 353: - apply("ALTER TABLE peer ADD COLUMN x509pem TEXT NULL DEFAULT NULL;" + + apply("ALTER TABLE peer ADD COLUMN x509pem TEXT NULL DEFAULT NULL; " + "ALTER TABLE peer ADD COLUMN ip_and_port VARCHAR NULL DEFAULT NULL"); case 354: return 354; diff --git a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/core/migrator/db/DbMigrationExecutorTest.java b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/core/migrator/db/DbMigrationExecutorTest.java index 8a3939dd2e..9e62438c5b 100644 --- a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/core/migrator/db/DbMigrationExecutorTest.java +++ b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/core/migrator/db/DbMigrationExecutorTest.java @@ -57,9 +57,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.Properties; +import org.junit.jupiter.api.Disabled; import static org.mockito.Mockito.mock; +@Disabled + //this test is disabled because DB migration will be replaced with FlyWay or other tool @EnableWeld public class DbMigrationExecutorTest { From 5676e67588476883f2628f692a21bf7bc30ea5c1 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 2 Oct 2020 16:54:09 +0300 Subject: [PATCH 26/42] P2P code cleanup before big changes with ID handling --- .../aplwallet/apl/core/http/JSONData.java | 4 ++-- .../aplwallet/apl/core/peer/Peer.java | 8 +++---- .../aplwallet/apl/core/peer/PeerAddress.java | 21 ++++++++++++++----- .../aplwallet/apl/core/peer/PeerImpl.java | 15 +++---------- .../aplwallet/apl/core/peer/PeersService.java | 20 +++++++++++------- .../core/rest/converter/PeerConverter.java | 4 ++-- .../apl/testutil/EntityProducer.java | 12 +++-------- 7 files changed, 41 insertions(+), 43 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/JSONData.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/JSONData.java index 12c7277564..48cf473ed9 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/JSONData.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/JSONData.java @@ -707,8 +707,8 @@ public static JSONObject peer(Peer peer) { json.put("lastUpdated", peer.getLastUpdated()); json.put("lastConnectAttempt", peer.getLastConnectAttempt()); json.put("inbound", peer.isInbound()); - json.put("inboundWebSocket", peer.isInboundSocket()); - json.put("outboundWebSocket", peer.isOutboundSocket()); + json.put("inboundWebSocket", peer.isInbound()); + json.put("outboundWebSocket", peer.isOutbound()); if (peer.isBlacklisted()) { json.put("blacklistingCause", peer.getBlacklistingCause()); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java index ee9c72b8fe..c7cc5d5bb5 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java @@ -50,7 +50,9 @@ public interface Peer extends Comparable { String getHostWithPort(); String getAnnouncedAddress(); - + + void setAnnouncedAddress(String addr); + PeerState getState(); Version getVersion(); @@ -101,10 +103,6 @@ public interface Peer extends Comparable { boolean isOutbound(); - boolean isInboundSocket(); - - boolean isOutboundSocket(); - boolean isOpenAPI(); boolean isApiConnectable(); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerAddress.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerAddress.java index 0831ee10f4..56727b8779 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerAddress.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerAddress.java @@ -115,7 +115,21 @@ public boolean isLocal() { || ipAddress.isLinkLocalAddress()); return res; } - + + public boolean isPublic(){ + boolean not_public = + ipAddress.isLinkLocalAddress() + || ipAddress.isLoopbackAddress() + || ipAddress.isSiteLocalAddress() // 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 + || ipAddress.isAnyLocalAddress() + || ipAddress.isMulticastAddress(); + return ! not_public; + } + + public boolean isValid() { + return valid; + } + @Override public int compareTo(Object t) { int res = -1; @@ -131,13 +145,10 @@ public int compareTo(Object t) { return res; } - public boolean isValid() { - return valid; - } + @Override public String toString() { return "host:" + ipAddress + " name:" + hostName + " port: " + port; } - } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 5aa07faba0..aa4fe78dcb 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -339,7 +339,8 @@ public String getAnnouncedAddress() { * * @param announcedAddress address with port optionally */ - void setAnnouncedAddress(String announcedAddress) { + @Override + public void setAnnouncedAddress(String announcedAddress) { if (announcedAddress != null && announcedAddress.length() > PeersService.MAX_ANNOUNCED_ADDRESS_LENGTH) { throw new IllegalArgumentException("Announced address too long: " + announcedAddress.length()); } @@ -444,21 +445,11 @@ public void remove() { @Override public boolean isInbound() { - return pi.getAnnouncedAddress() == null; - } - - @Override - public boolean isOutbound() { - return pi.getAnnouncedAddress() != null; - } - - @Override - public boolean isInboundSocket() { return p2pTransport.isInbound(); } @Override - public boolean isOutboundSocket() { + public boolean isOutbound() { return p2pTransport.isOutbound(); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 13c76c747b..3acf5a3f35 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -650,13 +650,14 @@ public Peer findOrCreatePeer(PeerAddress actualAddr, final String announcedAddre return peer; } - public void setAnnouncedAddress(PeerImpl peer, String newAnnouncedAddress) { + public boolean setAnnouncedAddress(Peer peer, String newAnnouncedAddress) { if (StringUtils.isBlank(newAnnouncedAddress)) { LOG.debug("newAnnouncedAddress is empty for host: {}, ignoring", peer.getHostWithPort()); } PeerAddress newPa = resolveAnnouncedAddress(newAnnouncedAddress); - if (newPa == null) { - return; + if (newPa == null || !newPa.isPublic()) { + log.debug("Peer {} announced wrong or not public address: {}", peer.getHostWithPort(), newAnnouncedAddress); + return false; } String oldAnnouncedAddr = peer.getAnnouncedAddress(); Peer oldPeer = null; @@ -668,17 +669,20 @@ public void setAnnouncedAddress(PeerImpl peer, String newAnnouncedAddress) { if (newPa.compareTo(oldPa) != 0) { LOG.debug("Removing old announced address {} for peer {}:{}", oldPa, oldPeer.getHost(), oldPeer.getPort()); - peer.setAnnouncedAddress(newAnnouncedAddress); + peer.setAnnouncedAddress(newPa.getAddrWithPort()); oldPeer = removePeer(oldPeer); if (oldPeer != null) { notifyListeners(oldPeer, Event.REMOVE); } } } + return true; } - public boolean addPeer(Peer peer, String newAnnouncedAddress) { - setAnnouncedAddress((PeerImpl) peer, newAnnouncedAddress.toLowerCase()); + public boolean addPeer(Peer peer, String announcedAddress) { + if(setAnnouncedAddress(peer, announcedAddress.toLowerCase())){ + return false; + } return addPeer(peer); } @@ -686,7 +690,7 @@ public boolean addPeer(Peer peer) { if (peer != null && peer.getAnnouncedAddress() != null) { // put new or replace previous - connectablePeers.put(peer.getAnnouncedAddress(), (PeerImpl) peer); + connectablePeers.put(peer.getAnnouncedAddress(), peer); listeners.notify(peer, Event.NEW_PEER); return true; } @@ -740,7 +744,7 @@ public boolean connectPeer(Peer peer) { res = ((PeerImpl) peer).handshake(); } if (res) { - connectablePeers.putIfAbsent(peer.getHostWithPort(), (PeerImpl) peer); + connectablePeers.putIfAbsent(peer.getHostWithPort(), peer); } return res; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/rest/converter/PeerConverter.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/rest/converter/PeerConverter.java index 8b91cb3685..2f53e88d5b 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/rest/converter/PeerConverter.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/rest/converter/PeerConverter.java @@ -39,8 +39,8 @@ public PeerDTO apply(Peer peer) { dto.setLastUpdated(peer.getLastUpdated()); dto.setLastConnectAttempt(peer.getLastConnectAttempt()); dto.setInbound(peer.isInbound()); - dto.setInboundWebSocket(peer.isInboundSocket()); - dto.setOutboundWebSocket(peer.isOutboundSocket()); + dto.setInboundWebSocket(peer.isInbound()); + dto.setOutboundWebSocket(peer.isOutbound()); if (peer.isBlacklisted()) { dto.setBlacklistingCause(peer.getBlacklistingCause()); } diff --git a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java index fc91f7c751..1b1f68d6f0 100644 --- a/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java +++ b/apl-core/src/test/java/com/apollocurrency/aplwallet/apl/testutil/EntityProducer.java @@ -278,17 +278,11 @@ public void setServices(long code) { public void setLastUpdated(int time) { } - - @Override - public boolean isInboundSocket() { - return false; - } - + @Override - public boolean isOutboundSocket() { - return false; + public void setAnnouncedAddress(String addr){ + } - }; return peer; } From 23aca7e02b67a26dc19075e22ba2d8a63d2819ec Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Thu, 8 Oct 2020 11:42:58 +0300 Subject: [PATCH 27/42] using fb-identity 1.0.1 --- .../apollocurrency/aplwallet/apl/core/peer/PeersService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 3acf5a3f35..71eb13e437 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -433,7 +433,7 @@ private void fillMyPeerInfo() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); ThisActorIdHandler myId = identityService.getThisNodeIdHandler(); - pi.setX509_cert(myId.getCertHelper().getCertPEM()); + pi.setX509_cert(myId.getExtCert().getCertPEM()); myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); myPI = pi; From 601b5575d9b5bdc7ac3702780eabf925e43f46c6 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 3 Nov 2020 16:40:23 +0200 Subject: [PATCH 28/42] fix to fit new fb-identity interface --- .../apollocurrency/aplwallet/apl/core/peer/PeersService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 442e9f6e47..069062b9e0 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -430,7 +430,7 @@ private void fillMyPeerInfo() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); ThisActorIdHandler myId = identityService.getThisNodeIdHandler(); - pi.setX509_cert(myId.getExtCert().getCertPEM()); + pi.setX509_cert(myId.getCertHelper().getCertPEM()); myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); myPI = pi; From f2ebd80a2e188433759a9245d7c5a590c7c98bb3 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 26 Mar 2021 12:01:23 +0200 Subject: [PATCH 29/42] NodeId implementation is almost complete --- .../aplwallet/apl/core/peer/PeersService.java | 18 +-- .../id/CertificateLoaderProducer.java | 17 --- .../apl/security/id/IdentityService.java | 28 +++- .../apl/security/id/IdentityServiceImpl.java | 124 ++++++++++++++++-- 4 files changed, 145 insertions(+), 42 deletions(-) delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index d05259e04d..bbdb7bdec7 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -289,7 +289,15 @@ public void init() { if (useProxy) { LOG.info("Using a proxy, will not create outbound websockets."); } - + + if(!identityService.loadMyIdentity()){ + log.error("Can not load or generate this node identity certificate or key"); + } + + if(!identityService.loadTrusterCaCerts()){ + log.error("Can not load trusted CA certificates, node ID verification is impossible"); + } + fillMyPeerInfo(); addListener(peer -> peersExecutorService.submit(() -> { @@ -302,15 +310,7 @@ public void init() { } }), PeersService.Event.CHANGED_SERVICES); - // moved to Weld Event - /* Account.addListener(account -> connectablePeers.values().forEach(peer -> { - if (peer.getHallmark() != null && peer.getHallmark().getAccountId() == account.getId()) { - listeners.notify(peer, Event.WEIGHT); - } - }), AccountEventType.BALANCE);*/ - configureBackgroundTasks(); - identityService.loadAll(); peerHttpServer.start(); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java deleted file mode 100644 index e1ad59d369..0000000000 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/CertificateLoaderProducer.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.apollocurrency.aplwallet.apl.security.id; - -import com.apollocurrency.aplwallet.apl.util.Constants; -import io.firstbridge.identity.handler.CertificateLoader; -import io.firstbridge.identity.handler.CertificateLoaderImpl; - -import javax.enterprise.inject.Produces; -import javax.inject.Singleton; - -@Singleton -public class CertificateLoaderProducer { - @Produces - @Singleton - public CertificateLoader loader() { - return new CertificateLoaderImpl();//this.getClass(), Constants.VERSION.toString()); - } -} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java index b35d630ca4..dfa80f1bfd 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java @@ -12,11 +12,33 @@ * @author alukin@gmail.com */ public interface IdentityService { - + + /** + * Handler for this node ID + * @return inited instance of ThisActorIdHandler + */ ThisActorIdHandler getThisNodeIdHandler(); + + /** + * Inied with set of trusted CA certifiates IdValidator instance + * @return Inied IdValidator instance + */ IdValidator getPeerIdValidator(); + + /** + * Load this node certificates and keys from defined directories; + * Fails if certificate already exists but private key could not be loaded + * If certificate/private key parit does not exist, self-signed ceretificate is generated. + * @return true if key/certificate pair is loaded or generated and saved. + * false if certificate exists but corresponding private key could not be loaded + * or generated cert and key could not be saved. + */ + boolean loadMyIdentity(); + /** - * Load all available certificates and keys from defined directories/resources + * Load set of trusted CA public certificates + * @return */ - void loadAll(); + boolean loadTrusterCaCerts(); + } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index efe7f94e23..d3bbd13727 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -6,29 +6,60 @@ import com.apollocurrency.aplwallet.apl.util.env.dirprovider.ConfigDirProvider; +import io.firstbridge.cryptolib.CryptoFactory; +import io.firstbridge.cryptolib.KeyWriter; +import io.firstbridge.identity.cert.ActorType; +import io.firstbridge.identity.cert.AuthorityID; +import io.firstbridge.identity.cert.CertAndKey; +import io.firstbridge.identity.cert.ExtCSR; +import io.firstbridge.identity.cert.ExtCert; +import io.firstbridge.identity.handler.CertificateLoader; +import io.firstbridge.identity.handler.CertificateLoaderImpl; import io.firstbridge.identity.handler.IdValidator; import io.firstbridge.identity.handler.IdValidatorImpl; +import io.firstbridge.identity.handler.PrivateKeyLoader; +import io.firstbridge.identity.handler.PrivateKeyLoaderImpl; import io.firstbridge.identity.handler.ThisActorIdHandler; import io.firstbridge.identity.handler.ThisActorIdHandlerImpl; -import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.security.PrivateKey; +import java.security.SecureRandom; +import java.util.List; import javax.inject.Inject; +import lombok.extern.slf4j.Slf4j; /** * Identity service implementation * * @author alukin@gmail.com */ +@Slf4j public class IdentityServiceImpl implements IdentityService { - private final ThisActorIdHandler thisNodeIdHandler; + private ThisActorIdHandler thisNodeIdHandler; private final IdValidator peerIdValidator; + public Path myCertPath; + public Path myKeyPath; + public Path apolloCaPath; + private final ConfigDirProvider dirProvider; - + @Inject public IdentityServiceImpl(ConfigDirProvider dirProvider) { - this.thisNodeIdHandler = new ThisActorIdHandlerImpl(); + this.dirProvider=dirProvider; this.peerIdValidator = new IdValidatorImpl(); - this.dirProvider = dirProvider; + myCertPath = Path.of(dirProvider.getUserConfigLocation()) + .resolve("certificates") + .resolve(dirProvider.getChainIdPart()) + .resolve("this_node.crt"); + myKeyPath = Path.of(dirProvider.getUserConfigLocation()) + .resolve("keys") + .resolve(dirProvider.getChainIdPart()) + .resolve("this_node.key"); + apolloCaPath = Path.of(dirProvider.getInstallationConfigLocation()) + .resolve("CA-certs"); + } @Override @@ -42,15 +73,82 @@ public IdValidator getPeerIdValidator() { } @Override - public void loadAll() { - String confName = dirProvider.getConfigName(); - String[] confLocations = {dirProvider.getInstallationConfigLocation(), - dirProvider.getSysConfigLocation(), - dirProvider.getUserConfigLocation()}; - for (String loc : confLocations) { - String path = loc + File.separator + confName; - System.out.println("========= " + path); + public boolean loadMyIdentity() { + boolean res = true; + CertificateLoader cl = new CertificateLoaderImpl(); + ExtCert myCert = cl.loadCert(myCertPath); + PrivateKey privKey = null; + if(myCert!=null){ + PrivateKeyLoader pkl = new PrivateKeyLoaderImpl(); + privKey = pkl.loadAndCheckPrivateKey(myKeyPath, myCert, null); + if(privKey==null){ + return false; + } + thisNodeIdHandler = new ThisActorIdHandlerImpl(myCert, privKey); + }else{ //we do not have node certificate yet, have to generate it + thisNodeIdHandler = new ThisActorIdHandlerImpl(); + CertAndKey certAndKey = thisNodeIdHandler.generateSelfSignedCert(fillCertProperties()); + + KeyWriter kw = CryptoFactory.newInstance().getKeyWriter(); + + try { + kw.writePvtKeyPEM(myKeyPath.toString(), certAndKey.getPvtKey()); + kw.writeX509CertificatePEM(myCertPath.toString(), certAndKey.getCert()); + } catch (IOException ex) { + log.error("Can not wirite generated node keys"); + res=false; + } + + } + + return res; + } + + /** + * Fill the fields of X.509 certificate actually + * with some "placeholders" and generated NodeID + * @return filled CSR ready to sifn or self-sign + */ + private ExtCSR fillCertProperties() { + //generate random 256-bit NodeID + byte[] nodeId = new byte[32]; + SecureRandom sr = new SecureRandom(); + sr.nextBytes(nodeId); + ExtCSR csr = new ExtCSR(); + + csr.setActorId(nodeId); + + AuthorityID authId = new AuthorityID(); + authId.setActorType(ActorType.NODE); + authId.setNetId(dirProvider.getChainId()); + authId.setAuthorityCode(0); + authId.setBusinessCode(0); + + csr.setAuthorityId(authId); + String email = csr.getActorIdAsHex()+"@apollowallet.org"; + csr.setCN(email); + csr.setOrg("Apollo blockchain"); + csr.setOrgUnit("Apollo-nodes"); + csr.setCity("Anywhere"); + csr.setCountry("US"); + csr.setEmail(email); + csr.setIP("127.0.0.1"); + csr.setDNSNames(csr.getActorIdAsHex()+".apollowallet.org"); + + return csr; + } + + @Override + public boolean loadTrusterCaCerts() { + CertificateLoader cl = new CertificateLoaderImpl(); + List calist = cl.loadCertsFromDir(apolloCaPath); + if(calist.isEmpty()){ + return false; } + calist.forEach(cert -> { + peerIdValidator.addTrustedSignerCert(cert.getCertificate()); + }); + return true; } } From f41a9f23563bcab288b9cd04efc5c70c529be1d7 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 26 Mar 2021 16:18:18 +0200 Subject: [PATCH 30/42] PeerID feature implemented --- .../aplwallet/api/p2p/PeerInfo.java | 11 +++++- .../aplwallet/apl/core/peer/Peer.java | 2 - .../aplwallet/apl/core/peer/PeerImpl.java | 38 +++++++++++++------ .../aplwallet/apl/core/peer/PeersService.java | 35 ++++++++++++----- 4 files changed, 62 insertions(+), 24 deletions(-) diff --git a/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java b/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java index 5d6b7c1771..49a89373df 100644 --- a/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java +++ b/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java @@ -167,11 +167,18 @@ public class PeerInfo extends BaseP2PResponse { /** * PEM-encoded X.509 Certificate of host as String, including * BEGIN-CETIFICATE and END-CERTIFICATE marks. Certificate - * should be verified and used for private key cryptography. Certificate - * also contains some important attributes, that is used widely in communications. + * should be verified. CA-signed certificate should be verified using CA x.509 cert. + * Self-signed certificate should be verified by checking signature of "blockTime" field + * with proposed self-signed certificate to ensure private key ownership. * New! */ private String X509_cert; + /** + * HEX string represenataion of the signature of blockTime (as 4 bytes in netowk order). + * Signature algorithm is the default for given public key type of X.509 certiificate, + * for more information please see fb-cryptoo library documentation + */ + private String blockTimeSigantureHex; /** * blacklist cause */ diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java index db4be94e1d..f6e0d27db4 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java @@ -33,8 +33,6 @@ public interface Peer extends Comparable { /** * ID of peer. It is UID field of X.509 certificate - * To keep a temporary compatibility with old peers, - * it could be announced address with port * @return */ String getIdentity(); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 3a9b9c287f..3fbcb634a8 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -34,6 +34,7 @@ import com.apollocurrency.aplwallet.apl.core.service.blockchain.BlockchainProcessor; import com.apollocurrency.aplwallet.apl.core.service.state.account.AccountService; import com.apollocurrency.aplwallet.apl.crypto.Convert; +import com.apollocurrency.aplwallet.apl.security.id.IdentityService; import com.apollocurrency.aplwallet.apl.util.Constants; import com.apollocurrency.aplwallet.apl.util.StringUtils; import com.apollocurrency.aplwallet.apl.util.Version; @@ -47,6 +48,7 @@ import io.firstbridge.identity.cert.CertException; import io.firstbridge.identity.cert.CertKeyPersistence; import io.firstbridge.identity.cert.ExtCert; +import io.firstbridge.identity.handler.IdValidator; import io.firstbridge.identity.utils.Hex; import java.io.ByteArrayInputStream; import lombok.Getter; @@ -61,6 +63,7 @@ import java.io.StringWriter; import java.net.InetAddress; import java.net.UnknownHostException; +import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.security.cert.X509Certificate; import java.sql.SQLException; @@ -134,7 +137,7 @@ public final class PeerImpl implements Peer { @Getter private PeerTrustLevel trustLevel = PeerTrustLevel.NOT_TRUSTED; private volatile ThreadPoolExecutor asyncExecutor; - + private final IdentityService identityService; PeerImpl(PeerAddress addrByFact, PeerAddress announcedAddress, BlockchainConfig blockchainConfig, @@ -143,7 +146,8 @@ public final class PeerImpl implements Peer { PeerServlet peerServlet, PeersService peers, TimeLimiter timeLimiter, - AccountService accountService + AccountService accountService, + IdentityService identityService ) { //TODO: remove Json.org entirely from P2P mapper.registerModule(new JsonOrgModule()); @@ -168,6 +172,7 @@ public final class PeerImpl implements Peer { this.p2pTransport = new Peer2PeerTransport(this, peerServlet, timeLimiter); state = PeerState.NON_CONNECTED; // set this peer its' initial state this.accountService = accountService; + this.identityService = identityService; } private void initAsyncExecutor() { @@ -991,21 +996,32 @@ public void setX509pem(String pem) { if (pem == null || pem.isEmpty()){ return; } - InputStream is = new ByteArrayInputStream(pem.getBytes()); - ExtCert xc=null; - X509Certificate caCert = null; try { - xc = CertKeyPersistence.loadCertPEMFromStream(is); - if (xc.isSelfSigned()){ - trustLevel = PeerTrustLevel.REGISTERED; - }else if(xc.isSignedBy(caCert)){ + ExtCert xc = CertKeyPersistence.loadCertPEMFromStream(new ByteArrayInputStream(pem.getBytes())); + IdValidator idValidator = identityService.getPeerIdValidator(); + if(xc.isSelfSigned()){ + //we should verify private key ownership by checking the signature of timestamp + ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); + bb.putInt(pi.getBlockTime()); + byte[] data = bb.array(); + byte[] signature = Hex.decode(pi.getBlockTimeSigantureHex()); + if(identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(),data,signature)){ + peerId=Hex.encode(xc.getActorId()); + trustLevel = PeerTrustLevel.REGISTERED; + }else{ + log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}"+getHostWithPort()); + } + }else if (idValidator.isTrusted(xc.getCertificate())) { trustLevel = PeerTrustLevel.TRUSTED; if( (xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) !=0 ){ trustLevel = PeerTrustLevel.SYSTEM_TRUSTED; } + peerId=Hex.encode(xc.getActorId()); + }else{ + log.debug("Can not determine trust level of peer certificate, signed by unknown CA for peer: {}",getHostWithPort()); } - peerId=Hex.encode(xc.getActorId()); } catch (IOException | CertException ex) { + log.debug("Can not read certificate of peer: {}", getHostWithPort()); } } @@ -1015,7 +1031,7 @@ public String getIdentity() { if (peerId!=null){ res = peerId; }else{ - res = getAnnouncedAddress(); // host with port? + res = ""; } return res; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index bbdb7bdec7..670624a8a8 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -57,7 +57,10 @@ import com.apollocurrency.aplwallet.apl.util.task.Tasks; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; +import io.firstbridge.identity.cert.ExtCert; import io.firstbridge.identity.handler.ThisActorIdHandler; +import io.firstbridge.identity.utils.Hex; +import java.nio.ByteBuffer; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.json.simple.JSONObject; @@ -130,7 +133,6 @@ public class PeersService { private static int pushThreshold; private static int pullThreshold; private static int sendToPeersLimit; - private static volatile JSONObject myPeerInfo; public final ExecutorService peersExecutorService = new QueuedThreadPool(2, 15, "PeersExecutorService"); public final boolean isLightClient; @Getter @@ -298,7 +300,9 @@ public void init() { log.error("Can not load trusted CA certificates, node ID verification is impossible"); } - fillMyPeerInfo(); + //NodeID feature + identityService.loadMyIdentity(); + identityService.loadTrusterCaCerts(); addListener(peer -> peersExecutorService.submit(() -> { if (peer.getAnnouncedAddress() != null && !peer.isBlacklisted()) { @@ -354,8 +358,8 @@ private void configureBackgroundTasks() { } } - private void fillMyPeerInfo() { - myPeerInfo = new JSONObject(); + private JSONObject fillMyPeerInfo() { + JSONObject myPeerInfo = new JSONObject(); PeerInfo pi = new PeerInfo(); LOG.debug("Start filling 'MyPeerInfo'..."); List servicesList = new ArrayList<>(); @@ -429,12 +433,24 @@ private void fillMyPeerInfo() { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JsonOrgModule()); - ThisActorIdHandler myId = identityService.getThisNodeIdHandler(); - pi.setX509_cert(myId.getExtCert().getCertPEM()); + + + ExtCert myId = identityService.getThisNodeIdHandler().getExtCert(); + if(myId!=null){ + pi.setX509_cert(myId.getCertPEM()); + } +//NodeId feature + pi.setBlockTime(timeService.getEpochTime()); + ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); + bb.putInt(pi.getBlockTime()); + byte[] signature = identityService.getThisNodeIdHandler().sign(bb.array()); + pi.setBlockTimeSigantureHex(Hex.encode(signature)); + myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); myPI = pi; LOG.debug("Finished filling 'MyPeerInfo'"); + return myPeerInfo; } public PeerInfo getMyPeerInfo() { @@ -637,7 +653,7 @@ public Peer findOrCreatePeer(PeerAddress actualAddr, final String announcedAddre //if it is not resolvable PeerAddress apa = resolveAnnouncedAddress(announcedAddress); peer = new PeerImpl(actualAddr, apa, blockchainConfig, blockchain, timeService, peerHttpServer.getPeerServlet(), - this, timeLimiterService.acquireLimiter("P2PTransport"), accountService); + this, timeLimiterService.acquireLimiter("P2PTransport"), accountService, identityService); listeners.notify(peer, Event.NEW_PEER); if (apa != null) { connectablePeers.put(apa.getAddrWithPort(), peer); @@ -930,9 +946,10 @@ private void checkBlockchainState() { : (blockchain.getLastBlock().getBaseTarget() / blockchainConfig.getCurrentConfig().getInitialBaseTarget() > 10) ? BlockchainState.FORK : BlockchainState.UP_TO_DATE; - if (state != currentBlockchainState) { - JSONObject json = new JSONObject(myPeerInfo); + if (state != currentBlockchainState) { + JSONObject json = new JSONObject(fillMyPeerInfo()); json.put("blockchainState", state.ordinal()); + myPeerInfoResponse = JSON.prepare(json); json.put("requestType", "getInfo"); myPeerInfoRequest = JSON.prepareRequest(json); From 6bf2a1d72c2b91caee7d5f95f3d4a8d28d8af4ae Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 26 Mar 2021 16:27:09 +0200 Subject: [PATCH 31/42] logs on PeerInfo set to trace --- .../apollocurrency/aplwallet/apl/core/peer/PeersService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 670624a8a8..55af2d0b2c 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -447,9 +447,9 @@ private JSONObject fillMyPeerInfo() { pi.setBlockTimeSigantureHex(Hex.encode(signature)); myPeerInfo = mapper.convertValue(pi, JSONObject.class); - LOG.debug("My peer info:\n" + myPeerInfo.toJSONString()); + LOG.trace("My peer info:\n" + myPeerInfo.toJSONString()); myPI = pi; - LOG.debug("Finished filling 'MyPeerInfo'"); + LOG.trace("Finished filling 'MyPeerInfo'"); return myPeerInfo; } From 3dc81e4641db1685e345a005482fb1c83c3e35af Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Fri, 26 Mar 2021 17:09:49 +0200 Subject: [PATCH 32/42] better processing of incoming certificates --- .../aplwallet/apl/core/peer/PeerImpl.java | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 3fbcb634a8..3ad0f25f8e 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -993,32 +993,39 @@ public String getX509pem() { } public void setX509pem(String pem) { - if (pem == null || pem.isEmpty()){ + if (pem == null || pem.isEmpty()) { return; } try { ExtCert xc = CertKeyPersistence.loadCertPEMFromStream(new ByteArrayInputStream(pem.getBytes())); + if (xc == null) { + log.debug("Error reading certificate of peer: {}", getHostWithPort()); + return; + } + + //we should verify private key ownership by checking the signature of timestamp + ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); + bb.putInt(pi.getBlockTime()); + byte[] data = bb.array(); + byte[] signature = Hex.decode(pi.getBlockTimeSigantureHex()); + + boolean isSignatureValid = identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(), data, signature); + //TODO A.B: to avoid replay attacks, time should be checked also + if (!isSignatureValid) { + log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}" + getHostWithPort()); + return; + } + peerId = Hex.encode(xc.getActorId()); IdValidator idValidator = identityService.getPeerIdValidator(); - if(xc.isSelfSigned()){ - //we should verify private key ownership by checking the signature of timestamp - ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); - bb.putInt(pi.getBlockTime()); - byte[] data = bb.array(); - byte[] signature = Hex.decode(pi.getBlockTimeSigantureHex()); - if(identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(),data,signature)){ - peerId=Hex.encode(xc.getActorId()); - trustLevel = PeerTrustLevel.REGISTERED; - }else{ - log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}"+getHostWithPort()); - } - }else if (idValidator.isTrusted(xc.getCertificate())) { + if (xc.isSelfSigned()) { + trustLevel = PeerTrustLevel.REGISTERED; + } else if (idValidator.isTrusted(xc.getCertificate())) { trustLevel = PeerTrustLevel.TRUSTED; - if( (xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) !=0 ){ + if ((xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) != 0) { trustLevel = PeerTrustLevel.SYSTEM_TRUSTED; } - peerId=Hex.encode(xc.getActorId()); - }else{ - log.debug("Can not determine trust level of peer certificate, signed by unknown CA for peer: {}",getHostWithPort()); + } else { + log.debug("Can not determine trust level of peer certificate, signed by unknown CA for peer: {}", getHostWithPort()); } } catch (IOException | CertException ex) { log.debug("Can not read certificate of peer: {}", getHostWithPort()); From 5eb5a6e39b997168562078be1ce8509cf0355514 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 29 Mar 2021 11:14:33 +0300 Subject: [PATCH 33/42] ApolloWallet root certificate added; better impl of private key ownership prove --- .../aplwallet/api/p2p/PeerInfo.java | 7 ++- .../aplwallet/apl/core/peer/Peer.java | 4 ++ .../aplwallet/apl/core/peer/PeerImpl.java | 50 +++++++++++-------- .../aplwallet/apl/core/peer/PeersService.java | 6 +-- .../apl/core/peer/endpoint/GetInfo.java | 2 +- conf/CA-certs/ApolloWallet-root.crt | 30 +++++++++++ 6 files changed, 73 insertions(+), 26 deletions(-) create mode 100644 conf/CA-certs/ApolloWallet-root.crt diff --git a/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java b/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java index 49a89373df..8c492757e3 100644 --- a/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java +++ b/apl-api/src/main/java/com/apollocurrency/aplwallet/api/p2p/PeerInfo.java @@ -173,12 +173,17 @@ public class PeerInfo extends BaseP2PResponse { * New! */ private String X509_cert; + /** + * Epoch time of the node. Needed to approve private key ownership and make + * replay attacks less possible + */ + private Integer epochTime; /** * HEX string represenataion of the signature of blockTime (as 4 bytes in netowk order). * Signature algorithm is the default for given public key type of X.509 certiificate, * for more information please see fb-cryptoo library documentation */ - private String blockTimeSigantureHex; + private String epochTimeSigantureHex; /** * blacklist cause */ diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java index f6e0d27db4..b3a255e88c 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java @@ -31,6 +31,10 @@ import java.util.UUID; public interface Peer extends Comparable { + /** max time difference allowed between this and remote node to + * check siganture of epoch time + */ + public static final int MAX_TIME_DIFF = 2; /** * ID of peer. It is UID field of X.509 certificate * @return diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 3fbcb634a8..4bc73d6726 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -61,6 +61,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import static java.lang.Math.abs; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; @@ -707,7 +708,7 @@ public synchronized boolean handshake() { setPlatform(newPi.getPlatform()); setShareAddress(newPi.getShareAddress()); - setX509pem(newPi.getX509_cert()); + setX509pem(newPi); if (!PeersService.ignorePeerAnnouncedAddress) { if (newPi.getAnnouncedAddress() != null && newPi.getShareAddress()) { @@ -992,33 +993,40 @@ public String getX509pem() { return pi.getX509_cert(); } - public void setX509pem(String pem) { - if (pem == null || pem.isEmpty()){ + public void setX509pem(PeerInfo pi) { + String pem = pi.getX509_cert(); + if (pem == null || pem.isEmpty()) { return; } try { ExtCert xc = CertKeyPersistence.loadCertPEMFromStream(new ByteArrayInputStream(pem.getBytes())); IdValidator idValidator = identityService.getPeerIdValidator(); - if(xc.isSelfSigned()){ - //we should verify private key ownership by checking the signature of timestamp - ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); - bb.putInt(pi.getBlockTime()); - byte[] data = bb.array(); - byte[] signature = Hex.decode(pi.getBlockTimeSigantureHex()); - if(identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(),data,signature)){ - peerId=Hex.encode(xc.getActorId()); - trustLevel = PeerTrustLevel.REGISTERED; - }else{ - log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}"+getHostWithPort()); - } - }else if (idValidator.isTrusted(xc.getCertificate())) { + //we should verify private key ownership by checking the signature of timestamp + ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); + bb.putInt(pi.getBlockTime()); + byte[] data = bb.array(); + byte[] signature = Hex.decode(pi.getEpochTimeSigantureHex()); + boolean signatureValid = identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(), data, signature); + boolean timeDiffValid = abs(timeService.getEpochTime() - pi.getEpochTime()) <= MAX_TIME_DIFF; + if (!timeDiffValid) { + log.warn("Time difference exceeds max allowed value for node {}", getHostWithPort()); + return; + } + if (signatureValid) { + log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}" + getHostWithPort()); + return; + } + peerId = Hex.encode(xc.getActorId()); + + if (xc.isSelfSigned()) { + trustLevel = PeerTrustLevel.REGISTERED; + } else if (idValidator.isTrusted(xc.getCertificate())) { trustLevel = PeerTrustLevel.TRUSTED; - if( (xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) !=0 ){ + if ((xc.getAuthorityId().getActorType().getType() & ActorType.NODE_CERTIFIED_STORAGE) != 0) { trustLevel = PeerTrustLevel.SYSTEM_TRUSTED; } - peerId=Hex.encode(xc.getActorId()); - }else{ - log.debug("Can not determine trust level of peer certificate, signed by unknown CA for peer: {}",getHostWithPort()); + } else { + log.debug("Can not determine trust level of peer certificate, signed by unknown CA for peer: {}", getHostWithPort()); } } catch (IOException | CertException ex) { log.debug("Can not read certificate of peer: {}", getHostWithPort()); @@ -1031,7 +1039,7 @@ public String getIdentity() { if (peerId!=null){ res = peerId; }else{ - res = ""; + res = getHostWithPort(); } return res; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 55af2d0b2c..d932b4dc66 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -440,11 +440,11 @@ private JSONObject fillMyPeerInfo() { pi.setX509_cert(myId.getCertPEM()); } //NodeId feature - pi.setBlockTime(timeService.getEpochTime()); + pi.setEpochTime(timeService.getEpochTime()); ByteBuffer bb = ByteBuffer.allocate(Integer.SIZE); - bb.putInt(pi.getBlockTime()); + bb.putInt(pi.getEpochTime()); byte[] signature = identityService.getThisNodeIdHandler().sign(bb.array()); - pi.setBlockTimeSigantureHex(Hex.encode(signature)); + pi.setEpochTimeSigantureHex(Hex.encode(signature)); myPeerInfo = mapper.convertValue(pi, JSONObject.class); LOG.trace("My peer info:\n" + myPeerInfo.toJSONString()); diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java index 39f3a66c98..5f3d297445 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java @@ -75,7 +75,7 @@ public JSONStreamAware processRequest(JSONObject req, Peer peer) { PeerInfo pi = mapper.convertValue(req, PeerInfo.class); log.trace("GetInfo - PeerInfo from request = {}", pi); - peerImpl.setX509pem(pi.getX509_cert()); + peerImpl.setX509pem(pi); peerImpl.setLastUpdated(timeService.getEpochTime()); long origServices = peerImpl.getServices(); String servicesString = pi.getServices(); diff --git a/conf/CA-certs/ApolloWallet-root.crt b/conf/CA-certs/ApolloWallet-root.crt new file mode 100644 index 0000000000..ba321bdbd4 --- /dev/null +++ b/conf/CA-certs/ApolloWallet-root.crt @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFMjCCBJOgAwIBAgIIEL8TEjSqgtkwCgYIKoZIzj0EAwQwggFCMQswCQYDVQQG +EwJVUzELMAkGA1UECBMCTUkxFTATBgNVBAcTDE1vdW50IFZlcm5vbjEZMBcGA1UE +ChMQQXBvbGxvV2FsbGV0Lm9yZzENMAsGA1UECxMEQ2VydDEeMBwGA1UEAxMVUm9v +dC5BcG9sbG93YWxsZXQub3JnMSQwIgYJKoZIhvcNAQkBFhVjZXJ0QGFwb2xsb3dh +bGxldC5vcmcxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJNSTEVMBMGA1UEBxMMTW91 +bnQgVmVybm9uMRkwFwYDVQQKExBBcG9sbG9XYWxsZXQub3JnMQ0wCwYDVQQLEwRD +ZXJ0MR4wHAYDVQQDExVSb290LkFwb2xsb1dhbGxldC5vcmcxJDAiBgkqhkiG9w0B +CQEWFWNlcnRAYXBvbGxvd2FsbGV0Lm9yZzAeFw0yMDA5MDUxODI2MDBaFw00MDA5 +MDUxODI2MDBaMIIBQjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAk1JMRUwEwYDVQQH +EwxNb3VudCBWZXJub24xGTAXBgNVBAoTEEFwb2xsb1dhbGxldC5vcmcxDTALBgNV +BAsTBENlcnQxHjAcBgNVBAMTFVJvb3QuQXBvbGxvd2FsbGV0Lm9yZzEkMCIGCSqG +SIb3DQEJARYVY2VydEBhcG9sbG93YWxsZXQub3JnMQswCQYDVQQGEwJVUzELMAkG +A1UECBMCTUkxFTATBgNVBAcTDE1vdW50IFZlcm5vbjEZMBcGA1UEChMQQXBvbGxv +V2FsbGV0Lm9yZzENMAsGA1UECxMEQ2VydDEeMBwGA1UEAxMVUm9vdC5BcG9sbG9X +YWxsZXQub3JnMSQwIgYJKoZIhvcNAQkBFhVjZXJ0QGFwb2xsb3dhbGxldC5vcmcw +gZswEAYHKoZIzj0CAQYFK4EEACMDgYYABAAVG2rKuZhN4YkbUcg910pXCjxEBtVQ +5XzcI4fnLDRm0BV1Lea8iwj8spY+V4SEtwbzV3yYfNt6SUiQuaXB9JER1QEgikea +01J6vrooEesu9iIf30UV1+s6bcQ8eqMZRjqyP/0PpRyJhswoSCosJlo9Cb9rzOQg +p1G0A+UVpxLpWRbm+qOCASowggEmMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE +FN25ljt/mV1xBsZpFuKyBHUKFNnPMB8GA1UdIwQYMBaAFN25ljt/mV1xBsZpFuKy +BHUKFNnPMA4GA1UdDwEB/wQEAwIBBjAgBgNVHSUBAf8EFjAUBggrBgEFBQcDAwYI +KwYBBQUHAwkwIAYDVR0RBBkwF4IVUm9vdC5BcG9sbG93YWxsZXQub3JnMCUGA1Ud +EgQeMByCGlJvb3QuY2VydC5BcG9sbG93YWxsZXQub3JnMCUGA1UdHwQeMBwwGqAY +oBaCFGNybC5hcG9sbG93YWxsZXQub3JnMBEGCWCGSAGG+EIBAQQEAwIABzAeBglg +hkgBhvhCAQ0EERYPeGNhIGNlcnRpZmljYXRlMAoGCCqGSM49BAMEA4GMADCBiAJC +ATllB6P+gtdryutXwe5yKVvGwJyFZ++M4P0s/lhBcRJPX1ESEnGN6U/XBssaDFR6 +l07jGJxutBY+Tt5s81H7sxD+AkIBEk0Y/UfUqJor3WHc/D5TNkChfvppgh8PCZyT +3E3o8Gw1/64nDAUyNoUzoElTDfFei8KkC+bA+zjx1MQicGM7ZAY= +-----END CERTIFICATE----- From 09d5b4c6252a603478bac86deb5835087c7fdf2c Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 29 Mar 2021 11:37:37 +0300 Subject: [PATCH 34/42] better method naming --- .../com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 671855a220..5c7837d02d 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -1012,7 +1012,9 @@ public void setX509pem(PeerInfo pi) { bb.putInt(pi.getBlockTime()); byte[] data = bb.array(); byte[] signature = Hex.decode(pi.getEpochTimeSigantureHex()); - boolean signatureValid = identityService.getPeerIdValidator().verifySelfSigned(xc.getCertificate(), data, signature); + + boolean signatureValid = identityService.getPeerIdValidator().verifySignedData(xc.getCertificate(), data, signature); + boolean timeDiffValid = abs(timeService.getEpochTime() - pi.getEpochTime()) <= MAX_TIME_DIFF; if (!timeDiffValid) { @@ -1026,7 +1028,6 @@ public void setX509pem(PeerInfo pi) { peerId = Hex.encode(xc.getActorId()); if (xc.isSelfSigned()) { - trustLevel = PeerTrustLevel.REGISTERED; } else if (idValidator.isTrusted(xc.getCertificate())) { trustLevel = PeerTrustLevel.TRUSTED; From 0c1718659a909b033a8210706c97d12b831a320c Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Mon, 29 Mar 2021 18:02:36 +0300 Subject: [PATCH 35/42] beans.xml added to modules --- apl-api/src/main/resources/META-INF/beans.xml | 14 ++++++++++++++ apl-api2/src/main/resources/META-INF/beans.xml | 1 + apl-core/src/main/resources/META-INF/beans.xml | 1 + .../src/main/resources/META-INF/beans.xml | 14 ++++++++++++++ apl-dex/src/main/resources/META-INF/beans.xml | 11 ++++++++++- .../apollocurrency/aplwallet/apl/exec/Apollo.java | 2 +- apl-updater/src/main/resources/META-INF/beans.xml | 1 + apl-utils/src/main/resources/META-INF/beans.xml | 14 ++++++++++++++ .../src/main/resources/META-INF/beans.xml | 11 ++++++++++- 9 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 apl-api/src/main/resources/META-INF/beans.xml create mode 100644 apl-db-updater/src/main/resources/META-INF/beans.xml diff --git a/apl-api/src/main/resources/META-INF/beans.xml b/apl-api/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000..0178091e87 --- /dev/null +++ b/apl-api/src/main/resources/META-INF/beans.xml @@ -0,0 +1,14 @@ + + + + org.jboss.weld.environment.se.threading.RunnableDecorator + + + + + + \ No newline at end of file diff --git a/apl-api2/src/main/resources/META-INF/beans.xml b/apl-api2/src/main/resources/META-INF/beans.xml index e290abbacc..0178091e87 100644 --- a/apl-api2/src/main/resources/META-INF/beans.xml +++ b/apl-api2/src/main/resources/META-INF/beans.xml @@ -9,5 +9,6 @@ + \ No newline at end of file diff --git a/apl-core/src/main/resources/META-INF/beans.xml b/apl-core/src/main/resources/META-INF/beans.xml index e290abbacc..0178091e87 100644 --- a/apl-core/src/main/resources/META-INF/beans.xml +++ b/apl-core/src/main/resources/META-INF/beans.xml @@ -9,5 +9,6 @@ + \ No newline at end of file diff --git a/apl-db-updater/src/main/resources/META-INF/beans.xml b/apl-db-updater/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000000..0178091e87 --- /dev/null +++ b/apl-db-updater/src/main/resources/META-INF/beans.xml @@ -0,0 +1,14 @@ + + + + org.jboss.weld.environment.se.threading.RunnableDecorator + + + + + + \ No newline at end of file diff --git a/apl-dex/src/main/resources/META-INF/beans.xml b/apl-dex/src/main/resources/META-INF/beans.xml index 542bd53ab6..0178091e87 100644 --- a/apl-dex/src/main/resources/META-INF/beans.xml +++ b/apl-dex/src/main/resources/META-INF/beans.xml @@ -1,5 +1,14 @@ \ No newline at end of file + version="1.1" bean-discovery-mode="all"> + + org.jboss.weld.environment.se.threading.RunnableDecorator + + + + + + \ No newline at end of file diff --git a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java index 9a0db26e03..fc5970751c 100644 --- a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java +++ b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java @@ -349,7 +349,7 @@ public static void main(String[] argv) { // Enable for development only, see http://weld.cdi-spec.org/news/2015/11/10/weld-probe-jmx/ // run with ./bin/apl-run-jmx.sh // - // aplContainerBuilder.devMode(); + aplContainerBuilder.devMode(); // //!!!!!!!!!!!!!!! diff --git a/apl-updater/src/main/resources/META-INF/beans.xml b/apl-updater/src/main/resources/META-INF/beans.xml index e290abbacc..0178091e87 100644 --- a/apl-updater/src/main/resources/META-INF/beans.xml +++ b/apl-updater/src/main/resources/META-INF/beans.xml @@ -9,5 +9,6 @@ + \ No newline at end of file diff --git a/apl-utils/src/main/resources/META-INF/beans.xml b/apl-utils/src/main/resources/META-INF/beans.xml index e69de29bb2..0178091e87 100644 --- a/apl-utils/src/main/resources/META-INF/beans.xml +++ b/apl-utils/src/main/resources/META-INF/beans.xml @@ -0,0 +1,14 @@ + + + + org.jboss.weld.environment.se.threading.RunnableDecorator + + + + + + \ No newline at end of file diff --git a/apl-vault-wallet/src/main/resources/META-INF/beans.xml b/apl-vault-wallet/src/main/resources/META-INF/beans.xml index 542bd53ab6..0178091e87 100644 --- a/apl-vault-wallet/src/main/resources/META-INF/beans.xml +++ b/apl-vault-wallet/src/main/resources/META-INF/beans.xml @@ -1,5 +1,14 @@ \ No newline at end of file + version="1.1" bean-discovery-mode="all"> + + org.jboss.weld.environment.se.threading.RunnableDecorator + + + + + + \ No newline at end of file From 2b9c56317e59c1ea7830ceab10eae46dbfe938b5 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Tue, 30 Mar 2021 11:13:49 +0300 Subject: [PATCH 36/42] fix of application start; code cleanup --- .../apl/core/peer/GetMorePeersThread.java | 26 +------------------ .../apl/core/peer/PeerLoaderThread.java | 18 +------------ .../apl/security/id/IdentityServiceImpl.java | 2 ++ .../aplwallet/apl/exec/Apollo.java | 1 - .../apl/util/cdi/AplContainerBuilder.java | 3 ++- .../dirprovider/DefaultConfigDirProvider.java | 5 +++- 6 files changed, 10 insertions(+), 45 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java index af4802a686..32f5ee3795 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/GetMorePeersThread.java @@ -32,26 +32,12 @@ class GetMorePeersThread implements Runnable { private final PeersService peersService; private final GetPeersRequest getPeersRequest; private volatile boolean updatedPeer; -//<<<<<<< HEAD - private PeerDao peerDao; -//======= -// private final PeerDb peerDb; -// -//>>>>>>> develop + private final PeerDao peerDao; public GetMorePeersThread(TimeService timeService, PeersService peersService) { this.timeService = timeService; this.peersService = peersService; -//<<<<<<< HEAD this.peerDao = peersService.getPeerDao(); -//======= -// this.peerDb = peersService.getPeerDb(); -// if (this.peerDb == null) { -// String error = "ERROR, the peerDb instance was not initialized inside peerService"; -// log.error(error); -// throw new RuntimeException(error); -// } -//>>>>>>> develop getPeersRequest = new GetPeersRequest(peersService.blockchainConfig.getChain().getChainId()); } @@ -133,13 +119,8 @@ private void updateSavedPeers() { // // Load the current database entries and map announced address to database entry // -//<<<<<<< HEAD List oldPeers = peerDao.loadPeers(); Map oldMap = new HashMap<>(oldPeers.size()); -//======= -// List oldPeers = this.peerDb.loadPeers(); -// Map oldMap = new HashMap<>(oldPeers.size()); -//>>>>>>> develop oldPeers.forEach((entry) -> oldMap.put(entry.getAddress(), entry)); // // Create the current peer map (note that there can be duplicate peer entries with @@ -182,13 +163,8 @@ private void updateSavedPeers() { // try { -//<<<<<<< HEAD peerDao.deletePeers(toDelete); peerDao.updatePeers(toUpdate); -//======= -// this.peerDb.deletePeers(toDelete); -// this.peerDb.updatePeers(toUpdate); -//>>>>>>> develop } catch (Exception e) { throw e; } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java index 5ba6551fd9..ca982fde6a 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerLoaderThread.java @@ -26,11 +26,8 @@ class PeerLoaderThread implements Runnable { private final Set entries = new HashSet<>(); private final TimeService timeService; private final PeersService peersService; -//<<<<<<< HEAD - private PeerDao peerDao; -//======= -// private final PeerDb peerDb; + private PeerDao peerDao; public PeerLoaderThread(List defaultPeers, List> unresolvedPeers, @@ -39,27 +36,14 @@ public PeerLoaderThread(List defaultPeers, this.defaultPeers = defaultPeers; this.unresolvedPeers = unresolvedPeers; this.timeService = timeService; -//<<<<<<< HEAD this.peersService = peersService; -//======= -// this.peersService = peersService; -// this.peerDb = peersService.getPeerDb(); -//>>>>>>> develop } @Override public void run() { LOG.trace("'Peer loader': thread starting..."); -//<<<<<<< HEAD if (peerDao == null) { peerDao = peersService.getPeerDao(); -//======= -// if (this.peerDb == null) { -//// peerDb = CDI.current().select(PeerDb.class).get(); -// String error = "ERROR, the peerDb instance was not initialized inside peerService"; -// log.error(error); -// throw new RuntimeException(error); -//>>>>>>> develop } final int now = timeService.getEpochTime(); //TODO: add enties after connection established and x.509 is known diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index d3bbd13727..bc6260a0f9 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -92,7 +92,9 @@ public boolean loadMyIdentity() { KeyWriter kw = CryptoFactory.newInstance().getKeyWriter(); try { + myKeyPath.getParent().toFile().mkdirs(); kw.writePvtKeyPEM(myKeyPath.toString(), certAndKey.getPvtKey()); + myCertPath.getParent().toFile().mkdirs(); kw.writeX509CertificatePEM(myCertPath.toString(), certAndKey.getCert()); } catch (IOException ex) { log.error("Can not wirite generated node keys"); diff --git a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java index fc5970751c..ade77bde29 100644 --- a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java +++ b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java @@ -343,7 +343,6 @@ public static void main(String[] argv) { // See https://docs.jboss.org/cdi/spec/2.0.EDR2/cdi-spec.html#se_bootstrap for more details // we already have it in beans.xml in core .annotatedDiscoveryMode(); - //!!!!!!!!!!!!!! //TODO: turn it on periodically in development process to check CDI errors // Enable for development only, see http://weld.cdi-spec.org/news/2015/11/10/weld-probe-jmx/ diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java index a11a231036..187686c54f 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java @@ -95,12 +95,13 @@ public AplContainer build() { if (devMode) { weld.enableDevMode(); + //it helps to localize problems! + weld.disableIsolation(); } if (concurrentDeploymentDisabled) { weld.property(ConfigurationKey.CONCURRENT_DEPLOYMENT.get(), "false"); } - WeldContainer newContainer = weld.initialize(); if (newContainer.isUnsatisfied()) { diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java index 51c4004865..f77aaafe75 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java @@ -150,6 +150,9 @@ public void setChainID(UUID newID) { @Override public String getChainIdPart() { - return partialUuid; + if(partialUuid==null || partialUuid.isEmpty()){ + partialUuid = chainUuid.toString().substring(0,6); + } + return partialUuid; } } From b8004607d1ca4d498f97aa53fbc926c954f7e698 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 31 Mar 2021 11:49:41 +0300 Subject: [PATCH 37/42] Debug in progress --- .../aplwallet/apl/core/peer/PeerImpl.java | 2 -- .../aplwallet/apl/core/peer/PeersService.java | 16 +++++++--------- .../apl/security/id/IdentityServiceImpl.java | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index 5c7837d02d..b7a4debea4 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -59,14 +59,12 @@ import org.json.simple.parser.ParseException; import java.io.IOException; -import java.io.InputStream; import java.io.StringWriter; import static java.lang.Math.abs; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; -import java.security.cert.X509Certificate; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index d932b4dc66..047b97c209 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -58,7 +58,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; import io.firstbridge.identity.cert.ExtCert; -import io.firstbridge.identity.handler.ThisActorIdHandler; import io.firstbridge.identity.utils.Hex; import java.nio.ByteBuffer; import lombok.Getter; @@ -171,6 +170,8 @@ public class PeersService { private final PeerDao peerDao; private final TransactionConverter transactionConverter; private final BlockConverter blockConverter; + private ObjectMapper mapper; + // private final ExecutorService txSendingDispatcher; @Inject @@ -205,6 +206,10 @@ public PeersService(PropertiesHolder propertiesHolder, this.sendingService = new TimeTraceDecoratedThreadPoolExecutor(10, asyncTxSendingPoolSize, 10_000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(1000), new NamedThreadFactory("PeersSendingService")); isLightClient = propertiesHolder.isLightClient(); + //configure object mapper for PeerInfo + mapper = new ObjectMapper(); + mapper.registerModule(new JsonOrgModule()); + } private BlockchainProcessor lookupBlockchainProcessor() { @@ -292,6 +297,7 @@ public void init() { LOG.info("Using a proxy, will not create outbound websockets."); } + //NodeID feature if(!identityService.loadMyIdentity()){ log.error("Can not load or generate this node identity certificate or key"); } @@ -300,10 +306,6 @@ public void init() { log.error("Can not load trusted CA certificates, node ID verification is impossible"); } - //NodeID feature - identityService.loadMyIdentity(); - identityService.loadTrusterCaCerts(); - addListener(peer -> peersExecutorService.submit(() -> { if (peer.getAnnouncedAddress() != null && !peer.isBlacklisted()) { try { @@ -430,10 +432,6 @@ private JSONObject fillMyPeerInfo() { } pi.setServices(Long.toUnsignedString(services)); myServices = Collections.unmodifiableList(servicesList); - - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModule(new JsonOrgModule()); - ExtCert myId = identityService.getThisNodeIdHandler().getExtCert(); if(myId!=null){ diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index bc6260a0f9..646f6154fc 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -58,6 +58,7 @@ public IdentityServiceImpl(ConfigDirProvider dirProvider) { .resolve(dirProvider.getChainIdPart()) .resolve("this_node.key"); apolloCaPath = Path.of(dirProvider.getInstallationConfigLocation()) + .resolve("conf") .resolve("CA-certs"); } From 63ecc5462c5b79d5d4ed84ef13bd5739892b1d1f Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Wed, 31 Mar 2021 17:57:01 +0300 Subject: [PATCH 38/42] debug mode is off; Node ID Feature is ready --- .../main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java index ade77bde29..fe7d4ea503 100644 --- a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java +++ b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java @@ -348,7 +348,7 @@ public static void main(String[] argv) { // Enable for development only, see http://weld.cdi-spec.org/news/2015/11/10/weld-probe-jmx/ // run with ./bin/apl-run-jmx.sh // - aplContainerBuilder.devMode(); + // aplContainerBuilder.devMode(); // //!!!!!!!!!!!!!!! From 1f0b9d0db20a3440f14e6a12a65bcad63b37dd9f Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Thu, 1 Apr 2021 10:06:10 +0300 Subject: [PATCH 39/42] fix of NPE in transaction validation --- .../aplwallet/apl/core/transaction/TransactionValidator.java | 3 ++- .../aplwallet/apl/security/id/IdentityService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java index 819ef7a36f..9136a8b068 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java @@ -266,7 +266,8 @@ void validateFee(Account account, Transaction transaction, int blockchainHeight) if (transaction.referencedTransactionFullHash() != null) { feeATM = Math.addExact(feeATM, blockchainConfig.getUnconfirmedPoolDepositAtm()); } - if (account.getUnconfirmedBalanceATM() < feeATM) { + //TODO: A.B. check it + if (account == null || account.getUnconfirmedBalanceATM() < feeATM) { throw new AplException.NotCurrentlyValidException("Account balance " + account.getUnconfirmedBalanceATM() + " is not enough to pay tx fee " + feeATM); } } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java index dfa80f1bfd..9911830f3a 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020. Apollo Foundation. + * Copyright (c) 2018-2021. Apollo Foundation. */ package com.apollocurrency.aplwallet.apl.security.id; From 6b932c4adff97bc704ba2c7c10c965282a3f09f9 Mon Sep 17 00:00:00 2001 From: Oleksiy Lukin Date: Thu, 1 Apr 2021 10:21:04 +0300 Subject: [PATCH 40/42] fix of NPE in transaction validation --- .gitignore | 1 + .../aplwallet/apl/core/transaction/TransactionValidator.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6265dce3f2..1d3a9c60d6 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ nbactions.xml **/swagger-codegen-cli-*.jar **/.swagger-codegen /apl-api2/src/gen/ +/apollo-mariadb diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java index 9136a8b068..ba2985ec77 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java @@ -267,7 +267,10 @@ void validateFee(Account account, Transaction transaction, int blockchainHeight) feeATM = Math.addExact(feeATM, blockchainConfig.getUnconfirmedPoolDepositAtm()); } //TODO: A.B. check it - if (account == null || account.getUnconfirmedBalanceATM() < feeATM) { + if (account == null){ + throw new AplException.NotCurrentlyValidException("Account for TX does not exist yet. TX: "+transaction.getStringId()); + } + if(account.getUnconfirmedBalanceATM() < feeATM){ throw new AplException.NotCurrentlyValidException("Account balance " + account.getUnconfirmedBalanceATM() + " is not enough to pay tx fee " + feeATM); } } From 8b639056bbefe452eb76cfa24e87e3786943af92 Mon Sep 17 00:00:00 2001 From: Andrew Boyarsky Date: Thu, 13 May 2021 19:21:16 +0300 Subject: [PATCH 41/42] Add apl-bom-ext proper version, move fb-identity version declaration to the apl-bom-ext, fix copyrights/typos/docs/logs --- apl-core/pom.xml | 4 +- .../apl/core/dao/appdata/PeerDao.java | 8 ++-- .../apl/core/entity/appdata/BlockIndex.java | 2 +- .../apl/core/entity/appdata/PeerEntity.java | 2 +- .../aplwallet/apl/core/peer/Peer.java | 13 +++--- .../aplwallet/apl/core/peer/PeerImpl.java | 26 ++++++----- .../aplwallet/apl/core/peer/PeersService.java | 8 ++-- .../apl/core/peer/endpoint/GetInfo.java | 17 +++----- .../apl/security/id/IdentityService.java | 19 ++++---- .../apl/security/id/IdentityServiceImpl.java | 43 ++++++++++--------- pom.xml | 2 +- 11 files changed, 69 insertions(+), 75 deletions(-) diff --git a/apl-core/pom.xml b/apl-core/pom.xml index f50c059340..8008404027 100644 --- a/apl-core/pom.xml +++ b/apl-core/pom.xml @@ -38,10 +38,8 @@ io.firstbridge fb-identity - 1.0.1 - jar - + ch.qos.logback logback-classic diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java index 5ec537a17f..ab44fc7e92 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/dao/appdata/PeerDao.java @@ -15,7 +15,7 @@ */ /* - * Copyright © 2018 Apollo Foundation + * Copyright © 2018-2021 Apollo Foundation */ package com.apollocurrency.aplwallet.apl.core.dao.appdata; @@ -57,9 +57,9 @@ public List loadPeers() { ResultSet rs = pstmt.executeQuery()) { while (rs.next()) { peers.add(new PeerEntity( - rs.getString("address"), - rs.getLong("services"), - rs.getInt("last_updated"), + rs.getString("address"), + rs.getLong("services"), + rs.getInt("last_updated"), rs.getString("x509pem"), rs.getString("ip_and_port") ) diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java index b2a2df7742..1474aa8f16 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/BlockIndex.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019-2020 Apollo Foundation + * Copyright © 2019-2021 Apollo Foundation */ package com.apollocurrency.aplwallet.apl.core.entity.appdata; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java index 3251ce6ec4..b6cb6abf2d 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/entity/appdata/PeerEntity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019-2020 Apollo Foundation + * Copyright © 2019-2021 Apollo Foundation */ package com.apollocurrency.aplwallet.apl.core.entity.appdata; diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java index b3a255e88c..88161fad52 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/Peer.java @@ -15,7 +15,7 @@ */ /* - * Copyright © 2018 Apollo Foundation + * Copyright © 2018-2021 Apollo Foundation */ package com.apollocurrency.aplwallet.apl.core.peer; @@ -34,10 +34,9 @@ public interface Peer extends Comparable { /** max time difference allowed between this and remote node to * check siganture of epoch time */ - public static final int MAX_TIME_DIFF = 2; + int MAX_TIME_DIFF = 2; /** - * ID of peer. It is UID field of X.509 certificate - * @return + * @return ID of peer. It is UID field of X.509 certificate */ String getIdentity(); @@ -52,9 +51,9 @@ public interface Peer extends Comparable { String getHostWithPort(); String getAnnouncedAddress(); - + void setAnnouncedAddress(String addr); - + PeerState getState(); Version getVersion(); @@ -138,7 +137,7 @@ public interface Peer extends Comparable { void setServices(long code); void setLastUpdated(int time); - + String getX509pem(); enum Service { diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java index b7a4debea4..feef91f226 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeerImpl.java @@ -50,17 +50,17 @@ import io.firstbridge.identity.cert.ExtCert; import io.firstbridge.identity.handler.IdValidator; import io.firstbridge.identity.utils.Hex; -import java.io.ByteArrayInputStream; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; import org.json.simple.JSONValue; import org.json.simple.parser.ParseException; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringWriter; -import static java.lang.Math.abs; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; @@ -80,14 +80,12 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import lombok.Setter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import static java.lang.Math.abs; @Slf4j public final class PeerImpl implements Peer { - private static final Logger LOG = LoggerFactory.getLogger(PeerImpl.class); @Getter public static final String CAN_NOT_DESERIALIZE_REQUEST_MSG = "Can not deserialize request"; @@ -984,7 +982,7 @@ public boolean processError(JSONObject message) { return true; } } - + //--------- X.509 certificates related methods @Override public String getX509pem() { @@ -1010,20 +1008,20 @@ public void setX509pem(PeerInfo pi) { bb.putInt(pi.getBlockTime()); byte[] data = bb.array(); byte[] signature = Hex.decode(pi.getEpochTimeSigantureHex()); - + boolean signatureValid = identityService.getPeerIdValidator().verifySignedData(xc.getCertificate(), data, signature); - + boolean timeDiffValid = abs(timeService.getEpochTime() - pi.getEpochTime()) <= MAX_TIME_DIFF; - + if (!timeDiffValid) { log.warn("Time difference exceeds max allowed value for node {}", getHostWithPort()); return; } if (signatureValid) { - log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}" + getHostWithPort()); + log.debug("Ignoring self-signed certificate because timestamp signature is wrong for peer: {}", getHostWithPort()); return; } - + peerId = Hex.encode(xc.getActorId()); if (xc.isSelfSigned()) { trustLevel = PeerTrustLevel.REGISTERED; @@ -1039,7 +1037,7 @@ public void setX509pem(PeerInfo pi) { log.debug("Can not read certificate of peer: {}", getHostWithPort()); } } - + @Override public String getIdentity() { String res; @@ -1050,7 +1048,7 @@ public String getIdentity() { } return res; } - + //----------- overwitten methods of Object @Override public boolean equals(Object o) { diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java index 7170632e50..1581ee220e 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/PeersService.java @@ -19,7 +19,6 @@ */ package com.apollocurrency.aplwallet.apl.core.peer; -import com.apollocurrency.aplwallet.apl.core.dao.appdata.PeerDao; import com.apollocurrency.aplwallet.api.dto.UnconfirmedTransactionDTO; import com.apollocurrency.aplwallet.api.p2p.PeerInfo; import com.apollocurrency.aplwallet.api.p2p.request.BaseP2PRequest; @@ -29,10 +28,10 @@ import com.apollocurrency.aplwallet.apl.core.blockchain.Block; import com.apollocurrency.aplwallet.apl.core.blockchain.Transaction; import com.apollocurrency.aplwallet.apl.core.chainid.BlockchainConfig; +import com.apollocurrency.aplwallet.apl.core.dao.appdata.PeerDao; import com.apollocurrency.aplwallet.apl.core.entity.appdata.PeerEntity; import com.apollocurrency.aplwallet.apl.core.http.API; import com.apollocurrency.aplwallet.apl.core.http.APIEnum; -import com.apollocurrency.aplwallet.apl.security.id.IdentityService; import com.apollocurrency.aplwallet.apl.core.rest.converter.BlockConverter; import com.apollocurrency.aplwallet.apl.core.rest.converter.UnconfirmedTransactionConverter; import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; @@ -40,6 +39,7 @@ import com.apollocurrency.aplwallet.apl.core.service.blockchain.BlockchainProcessor; import com.apollocurrency.aplwallet.apl.core.service.state.account.AccountService; import com.apollocurrency.aplwallet.apl.crypto.Convert; +import com.apollocurrency.aplwallet.apl.security.id.IdentityService; import com.apollocurrency.aplwallet.apl.util.Constants; import com.apollocurrency.aplwallet.apl.util.Filter; import com.apollocurrency.aplwallet.apl.util.JSON; @@ -59,7 +59,6 @@ import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule; import io.firstbridge.identity.cert.ExtCert; import io.firstbridge.identity.utils.Hex; -import java.nio.ByteBuffer; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.json.simple.JSONObject; @@ -70,6 +69,7 @@ import javax.enterprise.inject.spi.CDI; import javax.inject.Inject; import javax.inject.Singleton; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -304,7 +304,7 @@ public void init() { log.error("Can not load or generate this node identity certificate or key"); } - if(!identityService.loadTrusterCaCerts()){ + if(!identityService.loadTrustedCaCerts()){ log.error("Can not load trusted CA certificates, node ID verification is impossible"); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java index 5f3d297445..4a9541c64f 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/peer/endpoint/GetInfo.java @@ -21,28 +21,25 @@ package com.apollocurrency.aplwallet.apl.core.peer.endpoint; import com.apollocurrency.aplwallet.api.p2p.PeerInfo; -import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import com.apollocurrency.aplwallet.apl.core.peer.Peer; import com.apollocurrency.aplwallet.apl.core.peer.PeerImpl; import com.apollocurrency.aplwallet.apl.core.peer.PeersService; +import com.apollocurrency.aplwallet.apl.core.service.appdata.TimeService; import com.apollocurrency.aplwallet.apl.crypto.Convert; import com.apollocurrency.aplwallet.apl.util.JSON; import com.apollocurrency.aplwallet.apl.util.Version; +import lombok.extern.slf4j.Slf4j; import org.json.simple.JSONObject; import org.json.simple.JSONStreamAware; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Singleton; import java.io.IOException; import java.io.StringWriter; -import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j public class GetInfo extends PeerRequestHandler { - private static final Logger log = LoggerFactory.getLogger(GetInfo.class); private static final JSONStreamAware INVALID_ANNOUNCED_ADDRESS; private static final JSONStreamAware INVALID_APPLICATION; private static final JSONStreamAware INVALID_CHAINID; @@ -68,13 +65,13 @@ public GetInfo(TimeService timeService) { this.timeService = timeService; } - + @Override public JSONStreamAware processRequest(JSONObject req, Peer peer) { PeerImpl peerImpl = (PeerImpl) peer; PeerInfo pi = mapper.convertValue(req, PeerInfo.class); log.trace("GetInfo - PeerInfo from request = {}", pi); - + peerImpl.setX509pem(pi); peerImpl.setLastUpdated(timeService.getEpochTime()); long origServices = peerImpl.getServices(); @@ -88,16 +85,16 @@ public JSONStreamAware processRequest(JSONObject req, Peer peer) { announcedAddress = announcedAddress.toLowerCase(); if (announcedAddress != null) { if (!peerImpl.verifyAnnouncedAddress(announcedAddress)) { - log.trace("GetInfo: ignoring invalid announced address for " + peerImpl.getHostWithPort()); + log.trace("GetInfo: ignoring invalid announced address for {}", peerImpl.getHostWithPort()); if (!peerImpl.verifyAnnouncedAddress(peerImpl.getAnnouncedAddress())) { - log.trace("GetInfo: old announced address for " + peerImpl.getHostWithPort()+ " no longer valid"); + log.trace("GetInfo: old announced address for {} no longer valid", peerImpl.getHostWithPort()); lookupPeersService().setAnnouncedAddress(peerImpl, null); } peer.deactivate("Invalid announced address: " + announcedAddress); return INVALID_ANNOUNCED_ADDRESS; } if (!announcedAddress.equals(peerImpl.getAnnouncedAddress())) { - log.trace("GetInfo: peer " + peer.getHost() + " changed announced address from " + peer.getAnnouncedAddress() + " to " + announcedAddress); + log.trace("GetInfo: peer {} changed announced address from {} to {}", peer.getHost(), peer.getAnnouncedAddress(), announcedAddress); lookupPeersService().setAnnouncedAddress(peerImpl, announcedAddress); } } else { diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java index 9911830f3a..9cf7a4291e 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityService.java @@ -12,33 +12,32 @@ * @author alukin@gmail.com */ public interface IdentityService { - + /** * Handler for this node ID * @return inited instance of ThisActorIdHandler */ ThisActorIdHandler getThisNodeIdHandler(); - + /** - * Inied with set of trusted CA certifiates IdValidator instance + * Inied with set of trusted CA certificates IdValidator instance * @return Inied IdValidator instance */ IdValidator getPeerIdValidator(); - + /** * Load this node certificates and keys from defined directories; * Fails if certificate already exists but private key could not be loaded - * If certificate/private key parit does not exist, self-signed ceretificate is generated. + * If certificate/private key pair does not exist, self-signed certificate is generated. * @return true if key/certificate pair is loaded or generated and saved. - * false if certificate exists but corresponding private key could not be loaded + * false if certificate exists but corresponding private key could not be loaded * or generated cert and key could not be saved. */ boolean loadMyIdentity(); - + /** * Load set of trusted CA public certificates - * @return */ - boolean loadTrusterCaCerts(); - + boolean loadTrustedCaCerts(); + } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java index 646f6154fc..41988aee4f 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/security/id/IdentityServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020. Apollo Foundation. + * Copyright (c) 2018-2021. Apollo Foundation. */ package com.apollocurrency.aplwallet.apl.security.id; @@ -21,13 +21,15 @@ import io.firstbridge.identity.handler.PrivateKeyLoaderImpl; import io.firstbridge.identity.handler.ThisActorIdHandler; import io.firstbridge.identity.handler.ThisActorIdHandlerImpl; +import lombok.extern.slf4j.Slf4j; + +import javax.inject.Inject; +import javax.inject.Singleton; import java.io.IOException; import java.nio.file.Path; import java.security.PrivateKey; import java.security.SecureRandom; import java.util.List; -import javax.inject.Inject; -import lombok.extern.slf4j.Slf4j; /** * Identity service implementation @@ -35,6 +37,7 @@ * @author alukin@gmail.com */ @Slf4j +@Singleton public class IdentityServiceImpl implements IdentityService { private ThisActorIdHandler thisNodeIdHandler; @@ -42,9 +45,9 @@ public class IdentityServiceImpl implements IdentityService { public Path myCertPath; public Path myKeyPath; public Path apolloCaPath; - + private final ConfigDirProvider dirProvider; - + @Inject public IdentityServiceImpl(ConfigDirProvider dirProvider) { this.dirProvider=dirProvider; @@ -60,7 +63,7 @@ public IdentityServiceImpl(ConfigDirProvider dirProvider) { apolloCaPath = Path.of(dirProvider.getInstallationConfigLocation()) .resolve("conf") .resolve("CA-certs"); - + } @Override @@ -76,7 +79,7 @@ public IdValidator getPeerIdValidator() { @Override public boolean loadMyIdentity() { boolean res = true; - CertificateLoader cl = new CertificateLoaderImpl(); + CertificateLoader cl = new CertificateLoaderImpl(); ExtCert myCert = cl.loadCert(myCertPath); PrivateKey privKey = null; if(myCert!=null){ @@ -89,9 +92,9 @@ public boolean loadMyIdentity() { }else{ //we do not have node certificate yet, have to generate it thisNodeIdHandler = new ThisActorIdHandlerImpl(); CertAndKey certAndKey = thisNodeIdHandler.generateSelfSignedCert(fillCertProperties()); - + KeyWriter kw = CryptoFactory.newInstance().getKeyWriter(); - + try { myKeyPath.getParent().toFile().mkdirs(); kw.writePvtKeyPEM(myKeyPath.toString(), certAndKey.getPvtKey()); @@ -101,16 +104,16 @@ public boolean loadMyIdentity() { log.error("Can not wirite generated node keys"); res=false; } - + } - + return res; } - + /** * Fill the fields of X.509 certificate actually * with some "placeholders" and generated NodeID - * @return filled CSR ready to sifn or self-sign + * @return filled CSR ready to sign or self-sign */ private ExtCSR fillCertProperties() { //generate random 256-bit NodeID @@ -118,15 +121,15 @@ private ExtCSR fillCertProperties() { SecureRandom sr = new SecureRandom(); sr.nextBytes(nodeId); ExtCSR csr = new ExtCSR(); - + csr.setActorId(nodeId); - + AuthorityID authId = new AuthorityID(); authId.setActorType(ActorType.NODE); authId.setNetId(dirProvider.getChainId()); authId.setAuthorityCode(0); authId.setBusinessCode(0); - + csr.setAuthorityId(authId); String email = csr.getActorIdAsHex()+"@apollowallet.org"; csr.setCN(email); @@ -142,13 +145,13 @@ private ExtCSR fillCertProperties() { } @Override - public boolean loadTrusterCaCerts() { + public boolean loadTrustedCaCerts() { CertificateLoader cl = new CertificateLoaderImpl(); - List calist = cl.loadCertsFromDir(apolloCaPath); - if(calist.isEmpty()){ + List caList = cl.loadCertsFromDir(apolloCaPath); + if(caList.isEmpty()){ return false; } - calist.forEach(cert -> { + caList.forEach(cert -> { peerIdValidator.addTrustedSignerCert(cert.getCertificate()); }); return true; diff --git a/pom.xml b/pom.xml index 0c5b1d9ea3..c091322c4c 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 1.1.3 - 1.0.7 + 1.0.6 ApolloWallet/apollo-blockchain 1.9.1 From a0af29f7bba9a115e33a0b4e34371ee1b9e076f5 Mon Sep 17 00:00:00 2001 From: Andrew Boyarsky Date: Fri, 14 May 2021 14:49:28 +0300 Subject: [PATCH 42/42] Revert validation formatting, bump apl-bom-ext version (merged pr), make DefaultConfigDirProvider thread safe, remove unused beans.xml for non-weld modules, make apl-utils weld-independent --- apl-api/src/main/resources/META-INF/beans.xml | 14 -------- .../apl/core/app/AplCoreRuntime.java | 4 +-- .../apl/core/app/ResourceLocatorProducer.java | 24 ++++++++++++++ .../aplwallet/apl/core/config/DaoConfig.java | 13 +++++--- .../core/http/ElGamalEncryptorProducer.java | 33 +++++++++++++++++++ .../apl/core/monetary/MSExchangeSell.java | 0 .../apl/core/monetary/MonetarySystem.java | 0 .../transaction/TransactionValidator.java | 11 ++----- .../src/main/resources/META-INF/beans.xml | 14 -------- .../aplwallet/apl/exec/Apollo.java | 2 ++ .../apl/util/cdi/AplContainerBuilder.java | 12 +++++++ .../cdi/transaction/JdbiHandleFactory.java | 3 -- .../JdbiTransactionalInterceptor.java | 2 ++ .../util/env/config/UserResourceLocator.java | 2 -- .../dirprovider/DefaultConfigDirProvider.java | 22 ++++++------- .../apl/util/service/ElGamalEncryptor.java | 7 ---- .../src/main/resources/META-INF/beans.xml | 14 -------- pom.xml | 2 +- 18 files changed, 97 insertions(+), 82 deletions(-) delete mode 100644 apl-api/src/main/resources/META-INF/beans.xml create mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/ResourceLocatorProducer.java create mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/ElGamalEncryptorProducer.java delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MSExchangeSell.java delete mode 100644 apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MonetarySystem.java delete mode 100644 apl-db-updater/src/main/resources/META-INF/beans.xml delete mode 100644 apl-utils/src/main/resources/META-INF/beans.xml diff --git a/apl-api/src/main/resources/META-INF/beans.xml b/apl-api/src/main/resources/META-INF/beans.xml deleted file mode 100644 index 0178091e87..0000000000 --- a/apl-api/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.jboss.weld.environment.se.threading.RunnableDecorator - - - - - - \ No newline at end of file diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/AplCoreRuntime.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/AplCoreRuntime.java index a9d4c36463..d43055031e 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/AplCoreRuntime.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/AplCoreRuntime.java @@ -65,11 +65,11 @@ public DbConfig getDbConfig() { return dbConfig; } - @Produces @ApplicationScoped + @Produces @Singleton public DirProvider getDirProvider() { return dirProvider; } - @Produces @ApplicationScoped + @Produces @Singleton public ConfigDirProvider configDirProvider() { return ConfigDirProviderFactory.getConfigDirProvider(); } diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/ResourceLocatorProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/ResourceLocatorProducer.java new file mode 100644 index 0000000000..7107c09e74 --- /dev/null +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/app/ResourceLocatorProducer.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2018-2021 Apollo Foundation + */ + +package com.apollocurrency.aplwallet.apl.core.app; + +import com.apollocurrency.aplwallet.apl.util.env.config.ResourceLocator; +import com.apollocurrency.aplwallet.apl.util.env.config.UserResourceLocator; +import com.apollocurrency.aplwallet.apl.util.env.dirprovider.ConfigDirProvider; + +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class ResourceLocatorProducer { + @Inject + ConfigDirProvider configDirProvider; + + @Produces + public ResourceLocator locator() { + return new UserResourceLocator(configDirProvider); + } +} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/config/DaoConfig.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/config/DaoConfig.java index 9b5960e121..8c1a66f7a6 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/config/DaoConfig.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/config/DaoConfig.java @@ -18,7 +18,6 @@ import com.apollocurrency.aplwallet.apl.util.cdi.transaction.JdbiTransactionalSqlObjectDaoProxyInvocationHandler; import javax.enterprise.inject.Produces; -import javax.inject.Inject; import javax.inject.Singleton; /** @@ -28,11 +27,15 @@ @SuppressWarnings("unused") public class DaoConfig { - private JdbiHandleFactory jdbiHandleFactory; + private final JdbiHandleFactory jdbiHandleFactory; - @Inject - public void setJdbiHandleFactory(JdbiHandleFactory jdbiHandleFactory) { - this.jdbiHandleFactory = jdbiHandleFactory; + public DaoConfig() { + this.jdbiHandleFactory = new JdbiHandleFactory(); + } + + @Produces + public JdbiHandleFactory handleFactory() { + return jdbiHandleFactory; } @Produces diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/ElGamalEncryptorProducer.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/ElGamalEncryptorProducer.java new file mode 100644 index 0000000000..e064774a68 --- /dev/null +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/http/ElGamalEncryptorProducer.java @@ -0,0 +1,33 @@ +/* + * Copyright © 2018-2021 Apollo Foundation + */ + +package com.apollocurrency.aplwallet.apl.core.http; + +import com.apollocurrency.aplwallet.apl.util.service.ElGamalEncryptor; +import com.apollocurrency.aplwallet.apl.util.service.TaskDispatchManager; + +import javax.annotation.PostConstruct; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class ElGamalEncryptorProducer { + private final ElGamalEncryptor elGamalEncryptor; + + @Inject + public ElGamalEncryptorProducer(TaskDispatchManager dispatchManager) { + this.elGamalEncryptor = new ElGamalEncryptor(dispatchManager); + } + + @PostConstruct + public void init() { + elGamalEncryptor.init(); + } + + @Produces + public ElGamalEncryptor getElGamalEncryptor() { + return elGamalEncryptor; + } +} diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MSExchangeSell.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MSExchangeSell.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MonetarySystem.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/monetary/MonetarySystem.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java index 1d64ce558d..2b8aab96df 100644 --- a/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java +++ b/apl-core/src/main/java/com/apollocurrency/aplwallet/apl/core/transaction/TransactionValidator.java @@ -131,15 +131,8 @@ public void validateLightly(Transaction transaction) throws AplException.Validat public void validateFully(Transaction transaction) throws AplException.ValidationException { validateLightlyWithoutAppendices(transaction); - if (!antifraudValidator.validate( - blockchain.getHeight(), - blockchainConfig.getChain().getChainId(), - transaction.getSenderId(), - transaction.getRecipientId()) - ) - { - throw new AplException.NotValidException("Incorrect Passphrase"); - } + if (!antifraudValidator.validate(blockchain.getHeight(), blockchainConfig.getChain().getChainId(), transaction.getSenderId(), + transaction.getRecipientId())) throw new AplException.NotValidException("Incorrect Passphrase"); Account sender = accountService.getAccount(transaction.getSenderId()); if (sender != null && sender.isChild()) { diff --git a/apl-db-updater/src/main/resources/META-INF/beans.xml b/apl-db-updater/src/main/resources/META-INF/beans.xml deleted file mode 100644 index 0178091e87..0000000000 --- a/apl-db-updater/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.jboss.weld.environment.se.threading.RunnableDecorator - - - - - - \ No newline at end of file diff --git a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java index 4b951dd8f2..4f04e3e187 100644 --- a/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java +++ b/apl-exec/src/main/java/com/apollocurrency/aplwallet/apl/exec/Apollo.java @@ -18,6 +18,7 @@ import com.apollocurrency.aplwallet.apl.util.StringUtils; import com.apollocurrency.aplwallet.apl.util.cdi.AplContainer; import com.apollocurrency.aplwallet.apl.util.cdi.AplContainerBuilder; +import com.apollocurrency.aplwallet.apl.util.cdi.transaction.JdbiTransactionalInterceptor; import com.apollocurrency.aplwallet.apl.util.env.EnvironmentVariables; import com.apollocurrency.aplwallet.apl.util.env.PosixExitCodes; import com.apollocurrency.aplwallet.apl.util.env.RuntimeEnvironment; @@ -339,6 +340,7 @@ public static void main(String[] argv) { //Configure CDI Container builder and start CDI container. From now all things must go CDI way AplContainerBuilder aplContainerBuilder = AplContainer.builder().containerId("MAIN-APL-CDI") + .beanClasses(JdbiTransactionalInterceptor.class) // do not use recursive scan because it violates the restriction to // deploy one bean for all deployment archives // Recursive scan will trigger base synthetic archive to load JdbiTransactionalInterceptor, which was already loaded by apl-core archive diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java index 187686c54f..83a3018a6c 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/AplContainerBuilder.java @@ -8,7 +8,10 @@ import org.slf4j.LoggerFactory; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; /** @@ -27,6 +30,8 @@ public class AplContainerBuilder { private List> interceptors; + private Set> beanClasses = new HashSet<>(); + private boolean concurrentDeploymentDisabled = false; // private List> recursiveScanPackages; @@ -66,6 +71,12 @@ public AplContainerBuilder interceptors(Class... interceptors) { return this; } + public AplContainerBuilder beanClasses(Class... beanClasses) { + Objects.requireNonNull(beanClasses); + this.beanClasses.addAll(Arrays.asList(beanClasses)); + return this; + } + // public AplContainerBuilder recursiveScanPackages(Class... recursiveScanPackages) { // if (recursiveScanPackages != null && recursiveScanPackages.length > 0) { // this.recursiveScanPackages = Arrays.stream(recursiveScanPackages).collect(Collectors.toList()); @@ -92,6 +103,7 @@ public AplContainer build() { if (interceptors != null && !interceptors.isEmpty()) { interceptors.forEach(weld::addInterceptor); } + weld.addBeanClasses(beanClasses.toArray(new Class[0])); if (devMode) { weld.enableDevMode(); diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiHandleFactory.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiHandleFactory.java index 54dcf44cf8..53934557b7 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiHandleFactory.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiHandleFactory.java @@ -4,14 +4,11 @@ import org.jdbi.v3.core.Jdbi; import org.slf4j.Logger; -import javax.inject.Singleton; - import static org.slf4j.LoggerFactory.getLogger; /** * Holds opened connection {@link Handle} for current thread. */ -@Singleton public class JdbiHandleFactory { private static final Logger log = getLogger(JdbiHandleFactory.class); diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiTransactionalInterceptor.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiTransactionalInterceptor.java index 7067104d33..79e398fe40 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiTransactionalInterceptor.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/cdi/transaction/JdbiTransactionalInterceptor.java @@ -3,6 +3,7 @@ import com.apollocurrency.aplwallet.apl.util.cdi.Transactional; import org.slf4j.Logger; +import javax.annotation.Priority; import javax.inject.Inject; import javax.interceptor.AroundInvoke; import javax.interceptor.Interceptor; @@ -16,6 +17,7 @@ */ @Transactional @Interceptor +@Priority(100) public class JdbiTransactionalInterceptor { private static final Logger log = getLogger(JdbiHandleFactory.class); diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/config/UserResourceLocator.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/config/UserResourceLocator.java index 40247fb368..fe40c2996e 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/config/UserResourceLocator.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/config/UserResourceLocator.java @@ -8,7 +8,6 @@ import com.apollocurrency.aplwallet.apl.util.env.dirprovider.ConfigDirProvider; import lombok.extern.slf4j.Slf4j; -import javax.inject.Inject; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -25,7 +24,6 @@ public class UserResourceLocator implements ResourceLocator { private final ConfigDirProvider dirProvider; private final String configDir; - @Inject public UserResourceLocator(ConfigDirProvider dirProvider) { this.dirProvider = dirProvider; this.configDir = dirProvider.getConfigName(); diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java index f77aaafe75..bfca4672c2 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/env/dirprovider/DefaultConfigDirProvider.java @@ -33,11 +33,11 @@ public class DefaultConfigDirProvider implements ConfigDirProvider { "conf-tn3" //test net 3 }; - protected String applicationName; - protected String partialUuid; - protected UUID chainUuid; - protected boolean isService; - protected int netIndex; + protected final String applicationName; + protected volatile String partialUuid; + protected volatile UUID chainUuid; + protected final boolean isService; + protected final int netIndex; /** * Constructs config dir provider @@ -67,13 +67,13 @@ public DefaultConfigDirProvider(String applicationName, boolean isService, int n partialUuid = uuidOrPart; } } - + int netIdxToAssign; if (netIdx > CONF_DIRS.length - 1) { System.err.println("Net index " + netIdx + " is greater than last known."); - this.netIndex = CONF_DIRS.length - 1; + netIdxToAssign = CONF_DIRS.length - 1; System.err.println("Net index now is last one: " + netIdx); } else { - this.netIndex = netIdx; + netIdxToAssign = netIdx; } if (netIdx >= 0) { @@ -85,13 +85,13 @@ public DefaultConfigDirProvider(String applicationName, boolean isService, int n for (int i = 0; i < CHAIN_IDS.length; i++) { String id = CHAIN_IDS[i]; if (id.startsWith(uuidOrPart.toLowerCase())) { - this.netIndex = i; + netIdxToAssign = i; chainUuid = UUID.fromString(id); break; } } } - + this.netIndex = netIdxToAssign; } @Override @@ -153,6 +153,6 @@ public String getChainIdPart() { if(partialUuid==null || partialUuid.isEmpty()){ partialUuid = chainUuid.toString().substring(0,6); } - return partialUuid; + return partialUuid; } } diff --git a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/service/ElGamalEncryptor.java b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/service/ElGamalEncryptor.java index 582b6cf524..a167bb6466 100644 --- a/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/service/ElGamalEncryptor.java +++ b/apl-utils/src/main/java/com/apollocurrency/aplwallet/apl/util/service/ElGamalEncryptor.java @@ -8,14 +8,9 @@ import com.apollocurrency.aplwallet.apl.util.task.Task; import io.firstbridge.cryptolib.ElGamalKeyPair; -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Singleton; - /** * @author alukin@gmail.com */ -@Singleton public class ElGamalEncryptor { private byte[] privateKey; @@ -23,12 +18,10 @@ public class ElGamalEncryptor { private ElGamalKeyPair elGamalKeyPair; private final TaskDispatchManager taskDispatchManager; - @Inject public ElGamalEncryptor(TaskDispatchManager dispatchManager) { taskDispatchManager = dispatchManager; } - @PostConstruct public final void init() { taskDispatchManager.newBackgroundDispatcher("KeyGenerator") .schedule(Task.builder() diff --git a/apl-utils/src/main/resources/META-INF/beans.xml b/apl-utils/src/main/resources/META-INF/beans.xml deleted file mode 100644 index 0178091e87..0000000000 --- a/apl-utils/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - org.jboss.weld.environment.se.threading.RunnableDecorator - - - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index c091322c4c..0c5b1d9ea3 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 1.1.3 - 1.0.6 + 1.0.7 ApolloWallet/apollo-blockchain 1.9.1