Skip to content

Commit 8f2ef21

Browse files
authored
Merge pull request #354 from ubitricity/add_SecurityError_CallError_response
Implement CALLERROR: SecurityError response
2 parents 00da479 + cac89cb commit 8f2ef21

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package eu.chargetime.ocpp;
2+
3+
/*
4+
ChargeTime.eu - Java-OCA-OCPP
5+
Copyright (C) 2024 Robert Schlabbach <[email protected]>
6+
7+
MIT License
8+
9+
Copyright (C) 2024 Robert Schlabbach
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a copy
12+
of this software and associated documentation files (the "Software"), to deal
13+
in the Software without restriction, including without limitation the rights
14+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
copies of the Software, and to permit persons to whom the Software is
16+
furnished to do so, subject to the following conditions:
17+
18+
The above copyright notice and this permission notice shall be included in all
19+
copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27+
SOFTWARE.
28+
*/
29+
30+
/** A security issue occurred */
31+
public class SecurityErrorException extends IllegalStateException {
32+
public SecurityErrorException(String s) {
33+
super(s);
34+
}
35+
}

ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ public synchronized void onCall(String id, String action, Object payload) {
228228
} catch (PropertyConstraintException ex) {
229229
logger.warn(ex.getMessage(), ex);
230230
communicator.sendCallError(id, action, "TypeConstraintViolation", ex.getMessage());
231+
} catch (SecurityErrorException ex) {
232+
logger.warn(ex.getMessage(), ex);
233+
communicator.sendCallError(id, action, "SecurityError", ex.getMessage());
231234
} catch (Exception ex) {
232235
logger.warn(UNABLE_TO_PROCESS, ex);
233236
communicator.sendCallError(id, action, isLegacyRPC() ? "FormationViolation" :

0 commit comments

Comments
 (0)