Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import de.rwth.idsg.steve.service.WebUserService;
import de.rwth.idsg.steve.service.WebUsersService;
import de.rwth.idsg.steve.web.api.ApiControllerAdvice;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -52,7 +52,7 @@
@RequiredArgsConstructor
public class ApiAuthenticationManager implements AuthenticationManager, AuthenticationEntryPoint {

private final WebUserService webUserService;
private final WebUsersService webUsersService;
private final PasswordEncoder passwordEncoder;
private final ObjectMapper jacksonObjectMapper;

Expand All @@ -65,7 +65,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
throw new BadCredentialsException("Required parameters missing");
}

UserDetails userDetails = webUserService.loadUserByUsernameForApi(username);
UserDetails userDetails = webUsersService.loadUserByUsernameForApi(username);
if (!areValuesSet(userDetails)) {
throw new DisabledException("The user does not exist, exists but is disabled or has API access disabled.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class OcppConfiguration {
@Autowired private ocpp.cs._2015._10.CentralSystemService ocpp16Server;

@Autowired
@Qualifier("MessageHeaderInterceptor")
@Qualifier("messageHeaderInterceptor")
private PhaseInterceptor<Message> messageHeaderInterceptor;

@PostConstruct
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/de/rwth/idsg/steve/config/WebSocketConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
import de.rwth.idsg.steve.ocpp.ws.ocpp12.Ocpp12WebSocketEndpoint;
import de.rwth.idsg.steve.ocpp.ws.ocpp15.Ocpp15WebSocketEndpoint;
import de.rwth.idsg.steve.ocpp.ws.ocpp16.Ocpp16WebSocketEndpoint;
import de.rwth.idsg.steve.service.ChargePointHelperService;
import de.rwth.idsg.steve.service.ChargePointRegistrationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

/**
* @author Sevket Goekay <sevketgokay@gmail.com>
Expand All @@ -42,26 +41,27 @@
@EnableWebSocket
@Configuration
@Slf4j
@RequiredArgsConstructor
public class WebSocketConfiguration implements WebSocketConfigurer {

@Autowired private ChargePointHelperService chargePointHelperService;

@Autowired private Ocpp12WebSocketEndpoint ocpp12WebSocketEndpoint;
@Autowired private Ocpp15WebSocketEndpoint ocpp15WebSocketEndpoint;
@Autowired private Ocpp16WebSocketEndpoint ocpp16WebSocketEndpoint;

public static final String PATH_INFIX = "/websocket/CentralSystemService/";
public static final Duration PING_INTERVAL = Duration.ofMinutes(15);
public static final Duration IDLE_TIMEOUT = Duration.ofHours(2);
public static final int MAX_MSG_SIZE = 8_388_608; // 8 MB for max message size

private final ChargePointRegistrationService chargePointRegistrationService;

private final Ocpp12WebSocketEndpoint ocpp12WebSocketEndpoint;
private final Ocpp15WebSocketEndpoint ocpp15WebSocketEndpoint;
private final Ocpp16WebSocketEndpoint ocpp16WebSocketEndpoint;

@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {

OcppWebSocketHandshakeHandler handshakeHandler = new OcppWebSocketHandshakeHandler(
new DefaultHandshakeHandler(),
Lists.newArrayList(ocpp16WebSocketEndpoint, ocpp15WebSocketEndpoint, ocpp12WebSocketEndpoint),
chargePointHelperService
chargePointRegistrationService
);

registry.addHandler(handshakeHandler.getDummyWebSocketHandler(), PATH_INFIX + "*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import de.rwth.idsg.steve.ocpp.converter.Server12to15Impl;
import de.rwth.idsg.steve.ocpp.converter.Server15to16Impl;
import de.rwth.idsg.steve.service.CentralSystemService16_Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ocpp.cs._2010._08.AuthorizeRequest;
import ocpp.cs._2010._08.AuthorizeResponse;
Expand All @@ -44,7 +45,6 @@
import ocpp.cs._2010._08.StatusNotificationResponse;
import ocpp.cs._2010._08.StopTransactionRequest;
import ocpp.cs._2010._08.StopTransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jakarta.jws.WebService;
Expand All @@ -69,9 +69,10 @@
portName = "CentralSystemServiceSoap12",
targetNamespace = "urn://Ocpp/Cs/2010/08/",
endpointInterface = "ocpp.cs._2010._08.CentralSystemService")
@RequiredArgsConstructor
public class CentralSystemService12_SoapServer implements CentralSystemService {

@Autowired private CentralSystemService16_Service service;
private final CentralSystemService16_Service service;

public BootNotificationResponse bootNotificationWithTransport(BootNotificationRequest parameters,
String chargeBoxIdentity, OcppProtocol protocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.rwth.idsg.steve.ocpp.converter.Convert;
import de.rwth.idsg.steve.ocpp.converter.Server15to16Impl;
import de.rwth.idsg.steve.service.CentralSystemService16_Service;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ocpp.cs._2012._06.AuthorizeRequest;
import ocpp.cs._2012._06.AuthorizeResponse;
Expand Down Expand Up @@ -70,9 +71,10 @@
portName = "CentralSystemServiceSoap12",
targetNamespace = "urn://Ocpp/Cs/2012/06/",
endpointInterface = "ocpp.cs._2012._06.CentralSystemService")
@AllArgsConstructor
public class CentralSystemService15_SoapServer implements CentralSystemService {

@Autowired private CentralSystemService16_Service service;
private final CentralSystemService16_Service service;

public BootNotificationResponse bootNotificationWithTransport(BootNotificationRequest parameters,
String chargeBoxIdentity, OcppProtocol protocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import de.rwth.idsg.steve.ocpp.OcppProtocol;
import de.rwth.idsg.steve.ocpp.OcppVersion;
import de.rwth.idsg.steve.service.CentralSystemService16_Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import ocpp.cs._2015._10.AuthorizeRequest;
import ocpp.cs._2015._10.AuthorizeResponse;
Expand All @@ -43,7 +44,6 @@
import ocpp.cs._2015._10.StatusNotificationResponse;
import ocpp.cs._2015._10.StopTransactionRequest;
import ocpp.cs._2015._10.StopTransactionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jakarta.jws.WebService;
Expand All @@ -67,9 +67,10 @@
portName = "CentralSystemServiceSoap12",
targetNamespace = "urn://Ocpp/Cs/2015/10/",
endpointInterface = "ocpp.cs._2015._10.CentralSystemService")
@RequiredArgsConstructor
public class CentralSystemService16_SoapServer implements CentralSystemService {

@Autowired private CentralSystemService16_Service service;
private final CentralSystemService16_Service service;

public BootNotificationResponse bootNotificationWithTransport(BootNotificationRequest parameters,
String chargeBoxIdentity, OcppProtocol protocol) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import de.rwth.idsg.steve.ocpp.OcppProtocol;
import de.rwth.idsg.steve.repository.OcppServerRepository;
import de.rwth.idsg.steve.repository.impl.ChargePointRepositoryImpl;
import de.rwth.idsg.steve.service.ChargePointHelperService;
import de.rwth.idsg.steve.service.ChargePointRegistrationService;
import lombok.extern.slf4j.Slf4j;
import ocpp.cs._2015._10.RegistrationStatus;
import org.apache.cxf.binding.soap.Soap12;
Expand All @@ -37,7 +37,6 @@
import org.apache.cxf.ws.addressing.AddressingProperties;
import org.apache.cxf.ws.addressing.ContextUtils;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.xml.namespace.QName;
Expand All @@ -57,18 +56,25 @@
* @since 15.06.2015
*/
@Slf4j
@Component("MessageHeaderInterceptor")
@Component("messageHeaderInterceptor")
public class MessageHeaderInterceptor extends AbstractPhaseInterceptor<Message> {

@Autowired private OcppServerRepository ocppServerRepository;
@Autowired private ChargePointHelperService chargePointHelperService;
@Autowired private DelegatingTaskExecutor asyncTaskExecutor;

private static final String BOOT_OPERATION_NAME = "BootNotification";
private static final String CHARGEBOX_ID_HEADER = "ChargeBoxIdentity";

public MessageHeaderInterceptor() {
private final OcppServerRepository ocppServerRepository;
private final ChargePointRegistrationService chargePointRegistrationService;
private final DelegatingTaskExecutor asyncTaskExecutor;

public MessageHeaderInterceptor(
OcppServerRepository ocppServerRepository,
ChargePointRegistrationService chargePointRegistrationService,
DelegatingTaskExecutor asyncTaskExecutor
) {
super(Phase.PRE_INVOKE);
this.ocppServerRepository = ocppServerRepository;
this.chargePointRegistrationService = chargePointRegistrationService;
this.asyncTaskExecutor = asyncTaskExecutor;
}

@Override
Expand All @@ -82,7 +88,7 @@ public void handleMessage(Message message) throws Fault {
QName opName = message.getExchange().getBindingOperationInfo().getOperationInfo().getName();

if (!BOOT_OPERATION_NAME.equals(opName.getLocalPart())) {
Optional<RegistrationStatus> status = chargePointHelperService.getRegistrationStatus(chargeBoxId);
Optional<RegistrationStatus> status = chargePointRegistrationService.getRegistrationStatus(chargeBoxId);
boolean allow = status.isPresent() && status.get() != RegistrationStatus.REJECTED;
if (!allow) {
throw createAuthFault(opName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import de.rwth.idsg.steve.ocpp.Ocpp15AndAboveTask;
import de.rwth.idsg.steve.ocpp.OcppCallback;
import de.rwth.idsg.steve.service.OcppTagService;
import de.rwth.idsg.steve.service.OcppTagsService;
import de.rwth.idsg.steve.web.dto.ocpp.SendLocalListParams;
import de.rwth.idsg.steve.web.dto.ocpp.SendLocalListUpdateType;
import ocpp.cp._2015._10.AuthorizationData;
Expand All @@ -40,9 +40,9 @@ public class SendLocalListTask extends Ocpp15AndAboveTask<SendLocalListParams, S

private final ocpp.cp._2015._10.SendLocalListRequest request;

public SendLocalListTask(SendLocalListParams params, OcppTagService ocppTagService) {
public SendLocalListTask(SendLocalListParams params, OcppTagsService ocppTagsService) {
super(params);
this.request = createOcpp16Request(ocppTagService);
this.request = createOcpp16Request(ocppTagsService);
}

@Override
Expand Down Expand Up @@ -91,7 +91,7 @@ public AsyncHandler<ocpp.cp._2015._10.SendLocalListResponse> getOcpp16Handler(St
// Helpers
// -------------------------------------------------------------------------

private ocpp.cp._2015._10.SendLocalListRequest createOcpp16Request(OcppTagService ocppTagService) {
private ocpp.cp._2015._10.SendLocalListRequest createOcpp16Request(OcppTagsService ocppTagsService) {
// DIFFERENTIAL update
if (params.getUpdateType() == SendLocalListUpdateType.DIFFERENTIAL) {
List<ocpp.cp._2015._10.AuthorizationData> auths = new ArrayList<>();
Expand All @@ -102,7 +102,7 @@ private ocpp.cp._2015._10.SendLocalListRequest createOcpp16Request(OcppTagServic
}

// Step 2: For the idTags to be added or updated, insert them with their IdTagInfos
auths.addAll(ocppTagService.getAuthData(params.getAddUpdateList()));
auths.addAll(ocppTagsService.getAuthData(params.getAddUpdateList()));

return new ocpp.cp._2015._10.SendLocalListRequest()
.withListVersion(params.getListVersion())
Expand All @@ -114,7 +114,7 @@ private ocpp.cp._2015._10.SendLocalListRequest createOcpp16Request(OcppTagServic
List<AuthorizationData> values = Collections.emptyList();

if (Boolean.FALSE.equals(params.getSendEmptyListWhenFull())) {
values = ocppTagService.getAuthDataOfAllTags();
values = ocppTagsService.getAuthDataOfAllTags();
}

return new ocpp.cp._2015._10.SendLocalListRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import de.rwth.idsg.steve.repository.OcppServerRepository;
import de.rwth.idsg.steve.service.notification.OcppStationWebSocketConnected;
import de.rwth.idsg.steve.service.notification.OcppStationWebSocketDisconnected;
import lombok.RequiredArgsConstructor;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.socket.BinaryMessage;
import org.springframework.web.socket.CloseStatus;
Expand All @@ -53,12 +53,13 @@
* @author Sevket Goekay <sevketgokay@gmail.com>
* @since 17.03.2015
*/
@RequiredArgsConstructor
public abstract class AbstractWebSocketEndpoint extends ConcurrentWebSocketHandler implements SubProtocolCapable {

@Autowired private DelegatingTaskScheduler asyncTaskScheduler;
@Autowired private OcppServerRepository ocppServerRepository;
@Autowired private FutureResponseContextStore futureResponseContextStore;
@Autowired private ApplicationEventPublisher applicationEventPublisher;
private final DelegatingTaskScheduler asyncTaskScheduler;
private final OcppServerRepository ocppServerRepository;
private final FutureResponseContextStore futureResponseContextStore;
private final ApplicationEventPublisher applicationEventPublisher;

public static final String CHARGEBOX_ID_KEY = "CHARGEBOX_ID_KEY";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
*/
public abstract class ConcurrentWebSocketHandler implements WebSocketHandler {

private static final int sendTimeLimit = (int) TimeUnit.SECONDS.toMillis(10);
private static final int bufferSizeLimit = 5 * WebSocketConfiguration.MAX_MSG_SIZE;
private static final int SEND_TIME_LIMIT = (int) TimeUnit.SECONDS.toMillis(10);
private static final int BUFFER_SIZE_LIMIT = 5 * WebSocketConfiguration.MAX_MSG_SIZE;

private final Map<String, ConcurrentWebSocketSessionDecorator> sessions = new ConcurrentHashMap<>();

Expand All @@ -61,7 +61,7 @@
}

private ConcurrentWebSocketSessionDecorator internalGet(WebSocketSession session) {
return sessions.computeIfAbsent(session.getId(), s -> new ConcurrentWebSocketSessionDecorator(session, sendTimeLimit, bufferSizeLimit));
return sessions.computeIfAbsent(session.getId(), s -> new ConcurrentWebSocketSessionDecorator(session, SEND_TIME_LIMIT, BUFFER_SIZE_LIMIT));

Check failure on line 64 in src/main/java/de/rwth/idsg/steve/ocpp/ws/ConcurrentWebSocketHandler.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/main/java/de/rwth/idsg/steve/ocpp/ws/ConcurrentWebSocketHandler.java#L64 <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck>

Line is longer than 120 characters (found 148).
Raw output
/github/workspace/./src/main/java/de/rwth/idsg/steve/ocpp/ws/ConcurrentWebSocketHandler.java:64:0: error: Line is longer than 120 characters (found 148). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
}

// -------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
package de.rwth.idsg.steve.ocpp.ws;

import de.rwth.idsg.steve.config.WebSocketConfiguration;
import de.rwth.idsg.steve.service.ChargePointHelperService;
import de.rwth.idsg.steve.service.ChargePointRegistrationService;
import de.rwth.idsg.steve.web.validation.ChargeBoxIdValidator;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -53,7 +52,7 @@ public class OcppWebSocketHandshakeHandler implements HandshakeHandler {

private final DefaultHandshakeHandler delegate;
private final List<AbstractWebSocketEndpoint> endpoints;
private final ChargePointHelperService chargePointHelperService;
private final ChargePointRegistrationService chargePointRegistrationService;

/**
* We need some WebSocketHandler just for Spring to register it for the path. We will not use it for the actual
Expand All @@ -80,7 +79,7 @@ public boolean doHandshake(ServerHttpRequest request, ServerHttpResponse respons
return false;
}

Optional<RegistrationStatus> status = chargePointHelperService.getRegistrationStatus(chargeBoxId);
Optional<RegistrationStatus> status = chargePointRegistrationService.getRegistrationStatus(chargeBoxId);

// Allow connections, if station is in db (registration_status field from db does not matter)
boolean allowConnection = status.isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import de.rwth.idsg.ocpp.jaxb.RequestType;
import de.rwth.idsg.ocpp.jaxb.ResponseType;
import de.rwth.idsg.steve.config.DelegatingTaskScheduler;
import de.rwth.idsg.steve.ocpp.OcppProtocol;
import de.rwth.idsg.steve.ocpp.OcppVersion;
import de.rwth.idsg.steve.ocpp.soap.CentralSystemService12_SoapServer;
Expand All @@ -28,6 +29,7 @@
import de.rwth.idsg.steve.ocpp.ws.pipeline.AbstractCallHandler;
import de.rwth.idsg.steve.ocpp.ws.pipeline.Deserializer;
import de.rwth.idsg.steve.ocpp.ws.pipeline.IncomingPipeline;
import de.rwth.idsg.steve.repository.OcppServerRepository;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import ocpp.cs._2010._08.AuthorizeRequest;
Expand All @@ -39,7 +41,7 @@
import ocpp.cs._2010._08.StartTransactionRequest;
import ocpp.cs._2010._08.StatusNotificationRequest;
import ocpp.cs._2010._08.StopTransactionRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import jakarta.annotation.PostConstruct;
Expand All @@ -51,8 +53,18 @@
@Component
public class Ocpp12WebSocketEndpoint extends AbstractWebSocketEndpoint {

@Autowired private CentralSystemService12_SoapServer server;
@Autowired private FutureResponseContextStore futureResponseContextStore;
private final CentralSystemService12_SoapServer server;
private final FutureResponseContextStore futureResponseContextStore;

public Ocpp12WebSocketEndpoint(DelegatingTaskScheduler asyncTaskScheduler, OcppServerRepository ocppServerRepository,

Check failure on line 59 in src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp12/Ocpp12WebSocketEndpoint.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp12/Ocpp12WebSocketEndpoint.java#L59 <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck>

Line is longer than 120 characters (found 121).
Raw output
/github/workspace/./src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp12/Ocpp12WebSocketEndpoint.java:59:0: error: Line is longer than 120 characters (found 121). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
FutureResponseContextStore futureResponseContextStore,
ApplicationEventPublisher applicationEventPublisher,
CentralSystemService12_SoapServer server
) {
super(asyncTaskScheduler, ocppServerRepository, futureResponseContextStore, applicationEventPublisher);
this.server = server;
this.futureResponseContextStore = futureResponseContextStore;
}

@PostConstruct
public void init() {
Expand Down
Loading
Loading