Skip to content

Commit 6355a20

Browse files
author
Mathias Oben
committed
Initial implementation of models for 'Improved security for OCPP 1.6-J'
1 parent d633f87 commit 6355a20

File tree

42 files changed

+3791
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3791
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package eu.chargetime.ocpp.model.securityext;
2+
3+
/*
4+
ChargeTime.eu - Java-OCA-OCPP
5+
6+
MIT License
7+
8+
Copyright (C) 2022 Mathias Oben <[email protected]>
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
*/
28+
29+
import eu.chargetime.ocpp.model.Request;
30+
import eu.chargetime.ocpp.model.securityext.types.CertificateSignedStatusEnumType;
31+
import eu.chargetime.ocpp.utilities.MoreObjects;
32+
33+
import java.util.Objects;
34+
35+
public class CertificateSignedConfirmation implements Request {
36+
37+
private CertificateSignedStatusEnumType status;
38+
39+
/**
40+
* Handle required fields.
41+
*
42+
* @param status CertificateSignedStatusEnumType. See {@link #setStatus(CertificateSignedStatusEnumType)}
43+
*/
44+
public CertificateSignedConfirmation(CertificateSignedStatusEnumType status) {
45+
setStatus(status);
46+
}
47+
48+
/**
49+
* Returns whether certificate signing has been accepted, otherwise rejected.
50+
*
51+
* @return {@link CertificateSignedStatusEnumType}
52+
*/
53+
public CertificateSignedStatusEnumType getStatus() {
54+
return status;
55+
}
56+
57+
/**
58+
* Required. Returns whether certificate signing has been accepted, otherwise rejected.
59+
*
60+
* @param status {@link CertificateSignedStatusEnumType}
61+
*/
62+
public void setStatus(CertificateSignedStatusEnumType status) {
63+
this.status = status;
64+
}
65+
66+
@Override
67+
public boolean transactionRelated() {
68+
return false;
69+
}
70+
71+
@Override
72+
public boolean validate() {
73+
return status != null;
74+
}
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (this == o) return true;
79+
if (o == null || getClass() != o.getClass()) return false;
80+
CertificateSignedConfirmation that = (CertificateSignedConfirmation) o;
81+
return Objects.equals(status, that.status);
82+
}
83+
84+
@Override
85+
public int hashCode() {
86+
return Objects.hash(status);
87+
}
88+
89+
@Override
90+
public String toString() {
91+
return MoreObjects.toStringHelper(this)
92+
.add("status", status)
93+
.add("isValid", validate()).toString();
94+
}
95+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package eu.chargetime.ocpp.model.securityext;
2+
3+
/*
4+
ChargeTime.eu - Java-OCA-OCPP
5+
6+
MIT License
7+
8+
Copyright (C) 2022 Mathias Oben <[email protected]>
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
*/
28+
29+
import eu.chargetime.ocpp.model.Request;
30+
import eu.chargetime.ocpp.utilities.ModelUtil;
31+
import eu.chargetime.ocpp.utilities.MoreObjects;
32+
33+
import java.util.Objects;
34+
35+
public class CertificateSignedRequest implements Request {
36+
37+
private static final int STRING_10000_CHAR_MAX_LENGTH = 10000;
38+
39+
private String certificateChain;
40+
41+
/**
42+
* Handle required fields.
43+
*
44+
* @param certificateChain String. See {@link #setCertificateChain(String)}
45+
*/
46+
public CertificateSignedRequest(String certificateChain) {
47+
setCertificateChain(certificateChain);
48+
}
49+
50+
/**
51+
* The signed PEM encoded X.509 certificates. This can also contain the
52+
* necessary sub CA certificates. The maximum size of this field is limited by the
53+
* configuration key: CertificateSignedMaxSize.
54+
*
55+
* @return string[0..10000]
56+
*/
57+
public String getCertificateChain() {
58+
return certificateChain;
59+
}
60+
61+
/**
62+
* Required. The signed PEM encoded X.509 certificates. This can also contain the
63+
* necessary sub CA certificates. The maximum size of this field is limited by the
64+
* configuration key: CertificateSignedMaxSize.
65+
*
66+
* @param certificateChain string[0..10000]
67+
*/
68+
public void setCertificateChain(String certificateChain) {
69+
this.certificateChain = certificateChain;
70+
}
71+
72+
@Override
73+
public boolean transactionRelated() {
74+
return false;
75+
}
76+
77+
@Override
78+
public boolean validate() {
79+
return ModelUtil.validate(certificateChain, STRING_10000_CHAR_MAX_LENGTH);
80+
}
81+
82+
@Override
83+
public boolean equals(Object o) {
84+
if (this == o) return true;
85+
if (o == null || getClass() != o.getClass()) return false;
86+
CertificateSignedRequest that = (CertificateSignedRequest) o;
87+
return Objects.equals(certificateChain, that.certificateChain);
88+
}
89+
90+
@Override
91+
public int hashCode() {
92+
return Objects.hash(certificateChain);
93+
}
94+
95+
@Override
96+
public String toString() {
97+
return MoreObjects.toStringHelper(this)
98+
.add("certificateChain", certificateChain)
99+
.add("isValid", validate()).toString();
100+
}
101+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package eu.chargetime.ocpp.model.securityext;
2+
3+
/*
4+
ChargeTime.eu - Java-OCA-OCPP
5+
6+
MIT License
7+
8+
Copyright (C) 2022 Mathias Oben <[email protected]>
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
*/
28+
29+
import eu.chargetime.ocpp.model.Request;
30+
import eu.chargetime.ocpp.model.securityext.types.DeleteCertificateStatusEnumType;
31+
import eu.chargetime.ocpp.utilities.MoreObjects;
32+
33+
import java.util.Objects;
34+
35+
public class DeleteCertificateConfirmation implements Request {
36+
37+
private DeleteCertificateStatusEnumType status;
38+
39+
/**
40+
* Handle required fields.
41+
*
42+
* @param status DeleteCertificateStatusEnumType. See {@link #setStatus(DeleteCertificateStatusEnumType)}
43+
*/
44+
public DeleteCertificateConfirmation(DeleteCertificateStatusEnumType status) {
45+
setStatus(status);
46+
}
47+
48+
/**
49+
* Charge Point indicates if it can process the request.
50+
*
51+
* @return {@link DeleteCertificateStatusEnumType}
52+
*/
53+
public DeleteCertificateStatusEnumType getStatus() {
54+
return status;
55+
}
56+
57+
/**
58+
* Required. Charge Point indicates if it can process the request.
59+
*
60+
* @param status {@link DeleteCertificateStatusEnumType}
61+
*/
62+
public void setStatus(DeleteCertificateStatusEnumType status) {
63+
this.status = status;
64+
}
65+
66+
@Override
67+
public boolean transactionRelated() {
68+
return false;
69+
}
70+
71+
@Override
72+
public boolean validate() {
73+
return status != null;
74+
}
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (this == o) return true;
79+
if (o == null || getClass() != o.getClass()) return false;
80+
DeleteCertificateConfirmation that = (DeleteCertificateConfirmation) o;
81+
return Objects.equals(status, that.status);
82+
}
83+
84+
@Override
85+
public int hashCode() {
86+
return Objects.hash(status);
87+
}
88+
89+
@Override
90+
public String toString() {
91+
return MoreObjects.toStringHelper(this)
92+
.add("status", status)
93+
.add("isValid", validate()).toString();
94+
}
95+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package eu.chargetime.ocpp.model.securityext;
2+
3+
/*
4+
ChargeTime.eu - Java-OCA-OCPP
5+
6+
MIT License
7+
8+
Copyright (C) 2022 Mathias Oben <[email protected]>
9+
10+
Permission is hereby granted, free of charge, to any person obtaining a copy
11+
of this software and associated documentation files (the "Software"), to deal
12+
in the Software without restriction, including without limitation the rights
13+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14+
copies of the Software, and to permit persons to whom the Software is
15+
furnished to do so, subject to the following conditions:
16+
17+
The above copyright notice and this permission notice shall be included in all
18+
copies or substantial portions of the Software.
19+
20+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26+
SOFTWARE.
27+
*/
28+
29+
import eu.chargetime.ocpp.model.Request;
30+
import eu.chargetime.ocpp.model.securityext.types.CertificateHashDataType;
31+
import eu.chargetime.ocpp.utilities.MoreObjects;
32+
33+
import java.util.Objects;
34+
35+
public class DeleteCertificateRequest implements Request {
36+
37+
private CertificateHashDataType certificateHashData;
38+
39+
/**
40+
* Handle required fields.
41+
*
42+
* @param certificateHashData String. See {@link #setCertificateHashData(CertificateHashDataType)}
43+
*/
44+
public DeleteCertificateRequest(CertificateHashDataType certificateHashData) {
45+
setCertificateHashData(certificateHashData);
46+
}
47+
48+
/**
49+
* Indicates the certificate of which deletion is requested.
50+
*
51+
* @return {@link CertificateHashDataType}
52+
*/
53+
public CertificateHashDataType getCertificateHashData() {
54+
return certificateHashData;
55+
}
56+
57+
/**
58+
* Required. Indicates the certificate of which deletion is requested.
59+
*
60+
* @param certificateHashData {@link CertificateHashDataType}
61+
*/
62+
public void setCertificateHashData(CertificateHashDataType certificateHashData) {
63+
this.certificateHashData = certificateHashData;
64+
}
65+
66+
@Override
67+
public boolean transactionRelated() {
68+
return false;
69+
}
70+
71+
@Override
72+
public boolean validate() {
73+
return certificateHashData != null;
74+
}
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (this == o) return true;
79+
if (o == null || getClass() != o.getClass()) return false;
80+
DeleteCertificateRequest that = (DeleteCertificateRequest) o;
81+
return Objects.equals(certificateHashData, that.certificateHashData);
82+
}
83+
84+
@Override
85+
public int hashCode() {
86+
return Objects.hash(certificateHashData);
87+
}
88+
89+
@Override
90+
public String toString() {
91+
return MoreObjects.toStringHelper(this)
92+
.add("certificateHashData", certificateHashData)
93+
.add("isValid", validate()).toString();
94+
}
95+
}

0 commit comments

Comments
 (0)