diff --git a/OpenADRHTTPClient/pom.xml b/OpenADRHTTPClient/pom.xml index a6a5b0d9..ad20e693 100644 --- a/OpenADRHTTPClient/pom.xml +++ b/OpenADRHTTPClient/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRHTTPClient20a/pom.xml b/OpenADRHTTPClient20a/pom.xml index 7e4ce9cf..de97c51b 100644 --- a/OpenADRHTTPClient20a/pom.xml +++ b/OpenADRHTTPClient20a/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRHTTPClient20b/pom.xml b/OpenADRHTTPClient20b/pom.xml index ee566232..9303c557 100644 --- a/OpenADRHTTPClient20b/pom.xml +++ b/OpenADRHTTPClient20b/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRHTTPClient20b/src/main/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20b.java b/OpenADRHTTPClient20b/src/main/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20b.java index 901781f2..1e2c7db8 100644 --- a/OpenADRHTTPClient20b/src/main/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20b.java +++ b/OpenADRHTTPClient20b/src/main/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20b.java @@ -52,20 +52,24 @@ public class OadrHttpClient20b { private boolean validateXmlPayload = false; - public OadrHttpClient20b(OadrHttpClient client) throws JAXBException, OadrSecurityException { - this(client, null, null, null, null); + private boolean acceptUnsignedResponse = false; + + + public OadrHttpClient20b(OadrHttpClient client, Boolean acceptUnsignedResponse) throws JAXBException, OadrSecurityException { + this(client, null, null, null, null, acceptUnsignedResponse); } public OadrHttpClient20b(OadrHttpClient client, String privateKeyPath, String clientCertificatePath, - Long replayProtectAcceptedDelaySecond) throws JAXBException, OadrSecurityException { - this(client, privateKeyPath, clientCertificatePath, replayProtectAcceptedDelaySecond, null); + Long replayProtectAcceptedDelaySecond, Boolean acceptUnsignedResponse) throws JAXBException, OadrSecurityException { + this(client, privateKeyPath, clientCertificatePath, replayProtectAcceptedDelaySecond, null, acceptUnsignedResponse); } public OadrHttpClient20b(OadrHttpClient client, String privateKeyPath, String clientCertificatePath, - Long replayProtectAcceptedDelaySecond, Boolean validateXmlPayload) + Long replayProtectAcceptedDelaySecond, Boolean validateXmlPayload, Boolean acceptUnsignedResponse) throws JAXBException, OadrSecurityException { this.jaxbContext = Oadr20bJAXBContext.getInstance("src/test/resources/oadr20b_schema/"); this.client = client; + this.acceptUnsignedResponse = acceptUnsignedResponse; if (privateKeyPath != null && clientCertificatePath != null) { this.privateKey = OadrPKISecurity.parsePrivateKey(privateKeyPath); @@ -125,6 +129,7 @@ public > O post(String host, String path, HttpClient StringEntity stringEntity = new StringEntity(marshal); post.setEntity(stringEntity); + post.setHeader("content-type", "application/xml"); HttpResponse response = client.execute(post, host, Oadr20bUrlPath.OADR_BASE_PATH + path, context); // if request did not result in 200 http code throw exception @@ -132,14 +137,16 @@ public > O post(String host, String path, HttpClient EntityUtils.consumeQuietly(response.getEntity()); throw new Oadr20bHttpLayerException(response.getStatusLine().getStatusCode(), String.valueOf(response.getStatusLine().getStatusCode())); - } + } - // if request was a success, validate xml signature if required and then - // unmarshall response - if (isXmlSignatureEnabled()) { + // if request was a success, validate xml signature if required and then + // unmarshall response + if (isXmlSignatureEnabled()) { String entity = EntityUtils.toString(response.getEntity(), "UTF-8"); OadrPayload unmarshal = jaxbContext.unmarshal(entity, OadrPayload.class, validateXmlPayload); - this.validate(entity, unmarshal); + if(unmarshal.getSignature() == null && !acceptUnsignedResponse) { + this.validate(entity, unmarshal); + } EntityUtils.consumeQuietly(response.getEntity()); if (Object.class.equals(responseKlass)) { Object signedObjectFromOadrPayload = Oadr20bFactory.getSignedObjectFromOadrPayload(unmarshal); @@ -166,6 +173,9 @@ private String sign(Object object) throws Oadr20bXMLSignatureException { private void validate(String raw, OadrPayload payload) throws Oadr20bXMLSignatureValidationException { long nowDate = System.currentTimeMillis(); + if(payload.getSignature() == null) { + throw new Oadr20bXMLSignatureValidationException("Signature is not provided and unsigned repsonse is not accepted."); + } OadrXMLSignatureHandler.validate(raw, payload, nowDate, replayProtectAcceptedDelaySecond * 1000L); } diff --git a/OpenADRHTTPClient20b/src/test/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20bTest.java b/OpenADRHTTPClient20b/src/test/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20bTest.java index 0f1015a2..b97de757 100644 --- a/OpenADRHTTPClient20b/src/test/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20bTest.java +++ b/OpenADRHTTPClient20b/src/test/java/com/avob/openadr/client/http/oadr20b/OadrHttpClient20bTest.java @@ -132,7 +132,7 @@ public void givenValidUnsignedPost_DoNotRaiseException() throws ClientProtocolEx HttpResponse response = this.createHttpResponse(scOk, marshal); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); OadrResponseType post = client.post(Oadr20bFactory.createOadrDistributeEvent(mockDistributeEvent), @@ -157,7 +157,7 @@ public void givenNotSignedResponse_RaiseException() throws ClientProtocolExcepti when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); String certPath = "src/test/resources/cert/test"; - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, certPath + ".key", certPath + ".crt", 1200L); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, certPath + ".key", certPath + ".crt", 1200L, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); boolean exception = false; @@ -181,7 +181,7 @@ public void givenHttpError_RaiseException() throws ClientProtocolException, IOEx HttpResponse response = this.createHttpResponse(HttpStatus.SC_FORBIDDEN, ""); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); @@ -211,7 +211,7 @@ public void givenApplicationError_DoNotRaiseException() throws ClientProtocolExc HttpResponse response = this.createHttpResponse(HttpStatus.SC_OK, marshal); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); @@ -236,7 +236,7 @@ public void givenUnmarshallingRequest_RaiseException() throws ClientProtocolExce HttpResponse response = this.createHttpResponse(scOk, marshal); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, null, null, null, true); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, null, null, null, true, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); mockDistributeEvent.setVtnID(null); @@ -264,7 +264,7 @@ public void givenUnmarshallingResponse_RaiseException() throws ClientProtocolExc HttpResponse response = this.createHttpResponse(scOk, marshal); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); @@ -295,7 +295,7 @@ public void responseNotSignedErrorPostTest() throws ClientProtocolException, IOE String keyFile = CERT_FOLDER_PATH + "test.key"; String certFile = CERT_FOLDER_PATH + "test.crt"; - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, keyFile, certFile, 1200L); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, keyFile, certFile, 1200L, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); mockDistributeEvent.setVtnID("vtnId"); @@ -337,7 +337,7 @@ public void givenValidReponse_DoNotRaiseException() throws ClientProtocolExcepti HttpResponse response = this.createHttpResponse(scOk, sign); when(oadrHttpClient.execute(Matchers.anyObject(), any(), any(), any())).thenReturn(response); - OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, keyFile, certFile, 1200L); + OadrHttpClient20b client = new OadrHttpClient20b(oadrHttpClient, keyFile, certFile, 1200L, false); OadrDistributeEventType mockDistributeEvent = this.createOadrDistributeEvent(); mockDistributeEvent.setVtnID("vtnId"); diff --git a/OpenADRModel20a/pom.xml b/OpenADRModel20a/pom.xml index ba1a3277..70495294 100644 --- a/OpenADRModel20a/pom.xml +++ b/OpenADRModel20a/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRModel20b/pom.xml b/OpenADRModel20b/pom.xml index 8197ba3e..0082aace 100644 --- a/OpenADRModel20b/pom.xml +++ b/OpenADRModel20b/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRModel20b/src/main/java/com/avob/openadr/model/oadr20b/exception/Oadr20bHttpLayerException.java b/OpenADRModel20b/src/main/java/com/avob/openadr/model/oadr20b/exception/Oadr20bHttpLayerException.java index c1002992..a0b8a58c 100644 --- a/OpenADRModel20b/src/main/java/com/avob/openadr/model/oadr20b/exception/Oadr20bHttpLayerException.java +++ b/OpenADRModel20b/src/main/java/com/avob/openadr/model/oadr20b/exception/Oadr20bHttpLayerException.java @@ -11,6 +11,7 @@ public class Oadr20bHttpLayerException extends Exception { private String errorMessage; public Oadr20bHttpLayerException(int errorCode, String errorMessage) { + super(String.format("error-code:%s error-message:%s", errorCode, errorMessage)); this.setErrorMessage(errorMessage); this.setErrorCode(errorCode); } @@ -31,4 +32,11 @@ private void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } + @Override + public String toString() { + return "Oadr20bHttpLayerException [errorCode=" + errorCode + ", errorMessage=" + errorMessage + "]"; + } + + + } diff --git a/OpenADRSecurity/pom.xml b/OpenADRSecurity/pom.xml index 857fa961..5b403bb3 100644 --- a/OpenADRSecurity/pom.xml +++ b/OpenADRSecurity/pom.xml @@ -9,7 +9,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRSecurity/src/main/java/com/avob/openadr/security/OadrPKISecurity.java b/OpenADRSecurity/src/main/java/com/avob/openadr/security/OadrPKISecurity.java index 1a987663..70b6d2fc 100644 --- a/OpenADRSecurity/src/main/java/com/avob/openadr/security/OadrPKISecurity.java +++ b/OpenADRSecurity/src/main/java/com/avob/openadr/security/OadrPKISecurity.java @@ -47,6 +47,7 @@ import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter; import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; import org.bouncycastle.crypto.util.PrivateKeyFactory; +import org.bouncycastle.openssl.PEMKeyPair; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.bouncycastle.operator.ContentSigner; @@ -101,6 +102,9 @@ public static PrivateKey parsePrivateKey(FileReader fileReader) throws OadrSecur Object readObject; try { readObject = parsePem(fileReader); + if (readObject instanceof PEMKeyPair) { + readObject = ((PEMKeyPair) readObject).getPrivateKeyInfo(); + } if (readObject instanceof PrivateKeyInfo) { PrivateKeyInfo privateKeyInfo = (PrivateKeyInfo) readObject; return new JcaPEMKeyConverter().setProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()) diff --git a/OpenADRServerVEN20b/pom.xml b/OpenADRServerVEN20b/pom.xml index 10749fdd..d5eca304 100644 --- a/OpenADRServerVEN20b/pom.xml +++ b/OpenADRServerVEN20b/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity @@ -84,11 +84,11 @@ - - - org.springframework.boot - spring-boot-maven-plugin - + + + + + org.jacoco jacoco-maven-plugin diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/MultiVtnConfig.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/MultiVtnConfig.java index dadaf090..108a14f3 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/MultiVtnConfig.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/MultiVtnConfig.java @@ -100,9 +100,9 @@ private void configureClient(VtnSessionConfiguration session) client = new OadrHttpVenClient20b( new OadrHttpClient20b(builder.build(), session.getVenSessionConfig().getVenPrivateKeyPath(), session.getVenSessionConfig().getVenCertificatePath(), - session.getVenSessionConfig().getReplayProtectAcceptedDelaySecond())); + session.getVenSessionConfig().getReplayProtectAcceptedDelaySecond(), venConfig.getAcceptUnsignedResponse())); } else { - client = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build())); + client = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build(), venConfig.getAcceptUnsignedResponse())); } getMultiHttpClientConfig().put(session.getVtnId(), client); diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VEN20bApplicationStartupConf.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VEN20bApplicationStartupConf.java index 50275002..d4996dd1 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VEN20bApplicationStartupConf.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VEN20bApplicationStartupConf.java @@ -49,7 +49,7 @@ public class VEN20bApplicationStartupConf implements Oadr20bVENEiRegisterPartySe private MultiVtnConfig multiVtnConfig; @Resource - private Oadr20bVENEiReportService reportService; + private Oadr20bVENEiReportService oadrReportService; @Resource private Oadr20bVENEiRegisterPartyService oadr20bVENEiRegisterPartyService; @@ -103,7 +103,7 @@ private void initReport(VtnSessionConfiguration vtnConfiguration) throws XmppStr // send VEN RegisterReport to VTN String requestId = "0"; String reportRequestId = "0"; - OadrRegisterReportType payload = reportService.selfOadrRegisterReport(requestId, venConfig.getVenId(), + OadrRegisterReportType payload = oadrReportService.selfOadrRegisterReport(requestId, venConfig.getVenId(), reportRequestId); multiVtnConfig.oadrRegisterReport(vtnConfiguration, payload); diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VenConfig.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VenConfig.java index 9096e08a..e696cb66 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VenConfig.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/VenConfig.java @@ -41,6 +41,9 @@ public class VenConfig { @Value("${oadr.venUrl:#{null}}") private String venUrl; + @Value("${oadr.acceptUnsignedResponse:false}") + private Boolean acceptUnsignedResponse; + @Value("#{'${oadr.security.vtn.trustcertificate}'.split(',')}") private List trustCertificates; @@ -96,6 +99,7 @@ public VenConfig(VenConfig clone) { this.venUrl = clone.getVenUrl(); this.xmlSignature = clone.getXmlSignature(); this.validateOadrPayloadAgainstXsdFilePath = clone.getValidateOadrPayloadAgainstXsdFilePath(); + this.acceptUnsignedResponse = clone.getAcceptUnsignedResponse(); } @PostConstruct @@ -146,6 +150,10 @@ public Boolean getXmlSignature() { return xmlSignature; } + public Boolean getAcceptUnsignedResponse() { + return acceptUnsignedResponse; + } + public Boolean getPullModel() { return pullModel; } diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/controller/Oadr20bVENEiReportController.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/controller/Oadr20bVENEiReportController.java index bdd7682a..bad62e2d 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/controller/Oadr20bVENEiReportController.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/controller/Oadr20bVENEiReportController.java @@ -28,7 +28,7 @@ public class Oadr20bVENEiReportController { @Resource - private Oadr20bVENEiReportService reportService; + private Oadr20bVENEiReportService oadrReportService; @RequestMapping(value = Oadr20bUrlPath.EI_REPORT_SERVICE, method = RequestMethod.POST) @ResponseBody @@ -36,7 +36,7 @@ public String request(@RequestBody String payload, Principal principal) throws Oadr20bMarshalException, Oadr20bUnmarshalException, Oadr20bApplicationLayerException, Oadr20bXMLSignatureValidationException, Oadr20bXMLSignatureException, OadrSecurityException { - return reportService.request(principal.getName(), payload); + return oadrReportService.request(principal.getName(), payload); } } diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiEventService.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiEventService.java index f73611e0..13ae6d67 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiEventService.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiEventService.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; @@ -48,6 +49,8 @@ import com.avob.openadr.server.oadr20b.ven.MultiVtnConfig; import com.avob.openadr.server.oadr20b.ven.VtnSessionConfiguration; import com.avob.openadr.server.oadr20b.ven.exception.Oadr20bDistributeEventApplicationLayerException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; @Service public class Oadr20bVENEiEventService { @@ -127,6 +130,17 @@ public void run() { listener -> listener.onLastIntervalEnd(vtnConfiguration, event, eiEventSignalType, intervalType)); } } + + public static String toJson(final Object object) { + if(Objects.isNull(object)) { + return null; + } + try { + return new ObjectMapper().writeValueAsString(object); + } catch (JsonProcessingException e) { + return object.toString(); + } + } private static class OadrCreatedEventTask implements Runnable { @@ -154,9 +168,11 @@ public void run() { try { if (httpClient != null) { + LOGGER.info("post oadr created event: {}", toJson(payload)); OadrResponseType response = httpClient.oadrCreatedEvent(payload); String responseCode = response.getEiResponse().getResponseCode(); + LOGGER.info("response to oadr created event: {}", toJson(response.getEiResponse())); if (HttpStatus.OK_200 != Integer.valueOf(responseCode)) { LOGGER.error("Fail oadrCreatedEvent: " + responseCode @@ -290,7 +306,12 @@ private Optional processOadrEvent(VtnSessionConfiguration vtnConf doNeedResponse = true; if (listeners != null) { listeners.forEach(listener -> listener.onCreateEvent(vtnConfiguration, event)); - applyOadrEventScheduling(vtnConfiguration, event); + try { + applyOadrEventScheduling(vtnConfiguration, event); + } catch (Exception e) { + // TODO just catching everything here an skip might not be the best solution + LOGGER.warn("apply oadr event scheduling failed", e); + } } } if (isUpdatedEvent(vtnConfiguration, requestId, event)) { @@ -298,7 +319,12 @@ private Optional processOadrEvent(VtnSessionConfiguration vtnConf if (listeners != null) { listeners.forEach(listener -> listener.onUpdateEvent(vtnConfiguration, event)); cancelScheduledTask(vtnConfiguration, event.getEiEvent().getEventDescriptor().getEventID()); - applyOadrEventScheduling(vtnConfiguration, event); + try { + applyOadrEventScheduling(vtnConfiguration, event); + } catch (Exception e) { + // TODO just catching everything here an skip might not be the best solution + LOGGER.warn("apply oadr event scheduling failed", e); + } } } diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiRegisterPartyService.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiRegisterPartyService.java index 7fb269b8..9498b6c2 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiRegisterPartyService.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/service/Oadr20bVENEiRegisterPartyService.java @@ -32,7 +32,6 @@ import com.avob.openadr.model.oadr20b.oadr.OadrCreatePartyRegistrationType; import com.avob.openadr.model.oadr20b.oadr.OadrCreatedPartyRegistrationType; import com.avob.openadr.model.oadr20b.oadr.OadrPayload; -import com.avob.openadr.model.oadr20b.oadr.OadrQueryRegistrationType; import com.avob.openadr.model.oadr20b.oadr.OadrRequestReregistrationType; import com.avob.openadr.model.oadr20b.oadr.OadrResponseType; import com.avob.openadr.model.oadr20b.oadr.OadrTransportType; @@ -114,18 +113,28 @@ public void reinitRegistration(VtnSessionConfiguration vtnConfiguration) { public void initRegistration(VtnSessionConfiguration vtnConfiguration) { String requestId = "0"; - OadrQueryRegistrationType queryRegistration = Oadr20bEiRegisterPartyBuilders - .newOadr20bQueryRegistrationBuilder(requestId) - - .withSchemaVersion(SchemaVersionEnumeratedType.OADR_20B.value()).build(); + /** + * TODO skip query of registration for now + */ + /* + OadrQueryRegistrationType queryRegistration = Oadr20bEiRegisterPartyBuilders + .newOadr20bQueryRegistrationBuilder(requestId) + + .withSchemaVersion(SchemaVersionEnumeratedType.OADR_20B.value()).build(); + */ + OadrCreatePartyRegistrationType createPartyRegistration = Oadr20bEiRegisterPartyBuilders + .newOadr20bCreatePartyRegistrationBuilder(requestId, venConfig.getVenId(), SchemaVersionEnumeratedType.OADR_20B.value()) + .withOadrTransportName(OadrTransportType.SIMPLE_HTTP) + + .withOadrVenName(venConfig.getVenName()).withSchemaVersion(SchemaVersionEnumeratedType.OADR_20B.value()).build(); try { if (vtnConfiguration.getVtnUrl() != null) { OadrCreatedPartyRegistrationType oadrQueryRegistrationType = multiVtnConfig - .getMultiHttpClientConfig(vtnConfiguration).oadrQueryRegistrationType(queryRegistration); + .getMultiHttpClientConfig(vtnConfiguration).oadrCreatePartyRegistration(createPartyRegistration); this.oadrCreatedPartyRegistration(vtnConfiguration, oadrQueryRegistrationType); } else { - multiVtnConfig.getMultiXmppClientConfig(vtnConfiguration).oadrQueryRegistrationType(queryRegistration); + multiVtnConfig.getMultiXmppClientConfig(vtnConfiguration).oadrCreatePartyRegistration(createPartyRegistration); } } catch (Oadr20bException | Oadr20bHttpLayerException | Oadr20bXMLSignatureException diff --git a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/xmpp/XmppVenListener.java b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/xmpp/XmppVenListener.java index 4aba1890..4cb6a49c 100644 --- a/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/xmpp/XmppVenListener.java +++ b/OpenADRServerVEN20b/src/main/java/com/avob/openadr/server/oadr20b/ven/xmpp/XmppVenListener.java @@ -60,7 +60,7 @@ public class XmppVenListener implements StanzaListener { private Oadr20bVENEiRegisterPartyService oadr20bVENEiRegisterPartyService; @Resource - private Oadr20bVENEiReportService reportService; + private Oadr20bVENEiReportService oadrReportService; private void failIfPayloadNeedToBeSigned(VtnSessionConfiguration multiConfig) throws Oadr20bApplicationLayerException { @@ -128,7 +128,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt || oadrPayload.getOadrSignedObject().getOadrRegisterReport() != null || oadrPayload.getOadrSignedObject().getOadrCancelReport() != null) { - Object handle = reportService.handle(multiConfig, oadrPayload); + Object handle = oadrReportService.handle(multiConfig, oadrPayload); response = payloadHandler.payloadToString(multiConfig, handle, true); multiXmppClientConfig.sendReportMessage(response); @@ -188,7 +188,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt LOGGER.info(username + " - OadrCancelReport"); - Object handle = reportService.oadrCancelReport(multiConfig, oadrCancelReportType); + Object handle = oadrReportService.oadrCancelReport(multiConfig, oadrCancelReportType); response = payloadHandler.payloadToString(multiConfig, handle, false); multiXmppClientConfig.sendReportMessage(response); @@ -199,7 +199,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt LOGGER.info(username + " - OadrCreateReport"); - Object handle = reportService.oadrCreateReport(multiConfig, oadrCreateReportType); + Object handle = oadrReportService.oadrCreateReport(multiConfig, oadrCreateReportType); response = payloadHandler.payloadToString(multiConfig, handle, false); multiXmppClientConfig.sendReportMessage(response); @@ -210,7 +210,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt LOGGER.info(username + " - OadrCreatedReport"); - reportService.oadrCreatedReport(multiConfig, oadrCreatedReportType); + oadrReportService.oadrCreatedReport(multiConfig, oadrCreatedReportType); } else if (unmarshal instanceof OadrRegisterReportType) { @@ -218,7 +218,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt LOGGER.info(username + " - OadrRegisterReport"); - Object handle = reportService.oadrRegisterReport(multiConfig, oadrRegisterReportType); + Object handle = oadrReportService.oadrRegisterReport(multiConfig, oadrRegisterReportType); response = payloadHandler.payloadToString(multiConfig, handle, false); multiXmppClientConfig.sendReportMessage(response); @@ -229,7 +229,7 @@ public void processStanza(Stanza packet) throws NotConnectedException, Interrupt LOGGER.info(username + " - OadrUpdateReport"); - Object handle = reportService.oadrUpdateReport(multiConfig, oadrUpdateReportType); + Object handle = oadrReportService.oadrUpdateReport(multiConfig, oadrUpdateReportType); response = payloadHandler.payloadToString(multiConfig, handle, false); multiXmppClientConfig.sendReportMessage(response); diff --git a/OpenADRServerVEN20b/src/main/resources/log4j2.xml b/OpenADRServerVEN20b/src/main/resources/log4j2.xml index d02f1bf6..44a6ef7b 100644 --- a/OpenADRServerVEN20b/src/main/resources/log4j2.xml +++ b/OpenADRServerVEN20b/src/main/resources/log4j2.xml @@ -12,7 +12,7 @@ - + diff --git a/OpenADRServerVTN20a/pom.xml b/OpenADRServerVTN20a/pom.xml index 8933d920..8106188d 100644 --- a/OpenADRServerVTN20a/pom.xml +++ b/OpenADRServerVTN20a/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRServerVTN20b/pom.xml b/OpenADRServerVTN20b/pom.xml index f144fc26..d50a56e4 100644 --- a/OpenADRServerVTN20b/pom.xml +++ b/OpenADRServerVTN20b/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRServerVTN20b/src/main/java/com/avob/openadr/server/oadr20b/vtn/service/push/Oadr20bPushService.java b/OpenADRServerVTN20b/src/main/java/com/avob/openadr/server/oadr20b/vtn/service/push/Oadr20bPushService.java index f547f91b..535c81a1 100644 --- a/OpenADRServerVTN20b/src/main/java/com/avob/openadr/server/oadr20b/vtn/service/push/Oadr20bPushService.java +++ b/OpenADRServerVTN20b/src/main/java/com/avob/openadr/server/oadr20b/vtn/service/push/Oadr20bPushService.java @@ -99,10 +99,10 @@ public void init() { builder.enableHttp(true); } - setOadrHttpVtnClient20b(new OadrHttpVtnClient20b(new OadrHttpClient20b(builder.build()))); + setOadrHttpVtnClient20b(new OadrHttpVtnClient20b(new OadrHttpClient20b(builder.build(), false))); setSecuredOadrHttpVtnClient20b(new OadrHttpVtnClient20b(new OadrHttpClient20b(builder.build(), - vtnConfig.getKey(), vtnConfig.getCert(), vtnConfig.getReplayProtectAcceptedDelaySecond()))); + vtnConfig.getKey(), vtnConfig.getCert(), vtnConfig.getReplayProtectAcceptedDelaySecond(), false))); } catch (OadrSecurityException e) { throw new Oadr20bInitializationException(e); diff --git a/OpenADRServerVTN20b/src/test/java/com/avob/openadr/server/oadr20b/vtn/controller/Oadr20bVTNSecurityTest.java b/OpenADRServerVTN20b/src/test/java/com/avob/openadr/server/oadr20b/vtn/controller/Oadr20bVTNSecurityTest.java index a73319c3..ab041b18 100644 --- a/OpenADRServerVTN20b/src/test/java/com/avob/openadr/server/oadr20b/vtn/controller/Oadr20bVTNSecurityTest.java +++ b/OpenADRServerVTN20b/src/test/java/com/avob/openadr/server/oadr20b/vtn/controller/Oadr20bVTNSecurityTest.java @@ -172,7 +172,7 @@ public void testX509() throws Oadr20bException, OadrSecurityException, JAXBExcep .withProtocol(Oadr20bSecurity.getProtocols(), Oadr20bSecurity.getCiphers()) .withX509Authentication(rsaPrivateKeyPemFilePath, rsaClientCertPemFilePath); - OadrHttpVenClient20b x509HttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build())); + OadrHttpVenClient20b x509HttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build(), false)); String username = fingerprint; Ven ven = venService.prepare(username); @@ -192,7 +192,7 @@ public void testX509() throws Oadr20bException, OadrSecurityException, JAXBExcep .withProtocol(Oadr20bSecurity.getProtocols(), Oadr20bSecurity.getCiphers()) .withX509Authentication(eccPrivateKeyPemFilePath, eccClientCertPemFilePath); - x509HttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build())); + x509HttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build(), false)); username = fingerprint; ven = venService.prepare(username); @@ -218,7 +218,7 @@ public void testDigest() throws Oadr20bException, OadrSecurityException, JAXBExc .withProtocol(Oadr20bSecurity.getProtocols(), Oadr20bSecurity.getCiphers()) .withDefaultDigestAuthentication(eiEventEndpointUrl, realm, key, username, "securityVen1"); - OadrHttpVenClient20b digestHttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build())); + OadrHttpVenClient20b digestHttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build(), false)); Ven ven = venService.prepare(username, "securityVen1"); ven.setRegistrationId(username); @@ -240,7 +240,7 @@ public void testBasic() throws Oadr20bMarshalException, Exception { .withProtocol(Oadr20bSecurity.getProtocols(), Oadr20bSecurity.getCiphers()) .withDefaultBasicAuthentication(eiEventEndpointUrl, venUsername, "securityVen1"); - OadrHttpVenClient20b venBasicHttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build())); + OadrHttpVenClient20b venBasicHttpClient = new OadrHttpVenClient20b(new OadrHttpClient20b(builder.build(), false)); VenMarketContext marketContext = venMarketContextService.prepare(new VenMarketContextDto(MARKET_CONTEXT_NAME)); venMarketContextService.save(marketContext); diff --git a/OpenADRServerVTNCommon/pom.xml b/OpenADRServerVTNCommon/pom.xml index 8c451c97..99d759e2 100644 --- a/OpenADRServerVTNCommon/pom.xml +++ b/OpenADRServerVTNCommon/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity diff --git a/OpenADRXMPPClient/pom.xml b/OpenADRXMPPClient/pom.xml index f001e310..032479b3 100644 --- a/OpenADRXMPPClient/pom.xml +++ b/OpenADRXMPPClient/pom.xml @@ -8,7 +8,7 @@ com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity ../ diff --git a/pom.xml b/pom.xml index 74c83951..493b3753 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.avob.openadr OpenADR - 0.1.0-SNAPSHOT + 0.1.0-bitinity OpenADR OpenADR VEN/VTN implementation pom @@ -19,7 +19,7 @@ UTF-8 UTF-8 1.8 - 0.1.0-SNAPSHOT + 0.1.0-bitinity 5.7.0 4.3.4 3.1.1 @@ -48,6 +48,18 @@ + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + org.apache.maven.plugins maven-compiler-plugin