Merge branch 'hotfix/porsche-test'

This commit is contained in:
Marc Mültin 2016-11-06 19:21:00 +09:00
commit c8c9fb21d6
6 changed files with 61 additions and 42 deletions

View File

@ -20,6 +20,7 @@ import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import org.eclipse.risev2g.shared.enumerations.GlobalValues;
import org.eclipse.risev2g.shared.misc.TimeRestrictions;
import org.eclipse.risev2g.shared.misc.V2GTPMessage;
import org.eclipse.risev2g.shared.utils.SecurityUtils;
@ -78,7 +79,9 @@ public class TLSClient extends StatefulTransportLayerClient {
GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString());
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
getLogger().debug("Creating socket to TLS server ...");
setTlsSocketToServer((SSLSocket) sslSocketFactory.createSocket(host, port));
getLogger().debug("TLS socket to server created");
setInStream(getTlsSocketToServer().getInputStream());
setOutStream(getTlsSocketToServer().getOutputStream());
@ -95,7 +98,17 @@ public class TLSClient extends StatefulTransportLayerClient {
String[] enabledProtocols = {"TLSv1.2"};
getTlsSocketToServer().setEnabledProtocols(enabledProtocols);
/*
* The communication session setup timeout needs to be set here in case there is any problem with the
* TLS handshake.
* The timeout value will be overwritten with every new message being sent
*/
getTlsSocketToServer().setSoTimeout(TimeRestrictions.V2G_EVCC_COMMUNICATION_SETUP_TIMEOUT);
getLogger().debug("Starting TLS handshake ...");
getTlsSocketToServer().startHandshake();
getLogger().debug("TLS handshake finished");
Certificate[] seccCertificates = getTlsSocketToServer().getSession().getPeerCertificates();
X509Certificate seccLeafCertificate = (X509Certificate) seccCertificates[0];
@ -116,6 +129,8 @@ public class TLSClient extends StatefulTransportLayerClient {
getLogger().error("TLS client connection failed (UnknownHostException)!", e);
} catch (SSLHandshakeException e) {
getLogger().error("TLS client connection failed (SSLHandshakeException)", e);
} catch (SocketTimeoutException e) {
getLogger().fatal("TLS client connection failed (SocketTimeoutException) due to session setup timeout", e);
} catch (IOException e) {
getLogger().error("TLS client connection failed (IOException)!", e);
} catch (NullPointerException e) {

View File

@ -123,6 +123,7 @@ public class V2GCommunicationSessionHandlerSECC implements Observer {
private void processSECCDiscoveryReq(DatagramPacket udpClientPacket) {
setV2gTpMessage(new V2GTPMessage(udpClientPacket.getData()));
try {
if (getMessageHandler().isV2GTPMessageValid(getV2gTpMessage()) &&
Arrays.equals(getV2gTpMessage().getPayloadType(), GlobalValues.V2GTP_PAYLOAD_TYPE_SDP_REQUEST_MESSAGE.getByteArrayValue())) {
@ -160,6 +161,9 @@ public class V2GCommunicationSessionHandlerSECC implements Observer {
} else {
getLogger().warn("Incoming DatagramPacket could not be identified as a SECCDiscoveryReq");
}
} catch (NullPointerException e) {
getLogger().error("NullPointerException occurred while processing SECCDiscoveryReq", e);
}
}
/**

View File

@ -27,7 +27,7 @@ public enum GlobalValues {
*/
PASSPHRASE_FOR_CERTIFICATES_AND_KEYS("123456"),
// Aliases for contract certificate chain and OEM provisioning certficiate chain
// Aliases for contract certificate chain and OEM provisioning certificate chain
ALIAS_CONTRACT_CERTIFICATE("contract_cert"),
ALIAS_OEM_PROV_CERTIFICATE("oem_prov_cert"),