Addresses #3 "SignedInfo tag namespace issue":

A new check for the type SignedInfoType to get the correct namespace deals with this issue
Tested with updated keystores and certificates
This commit is contained in:
Marc Mültin 2015-12-14 17:09:14 +01:00
parent 91b153fb98
commit 72d0327a72
8 changed files with 10 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,14 +20,17 @@ import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.eclipse.risev2g.shared.enumerations.GlobalValues; import org.eclipse.risev2g.shared.enumerations.GlobalValues;
import org.eclipse.risev2g.shared.enumerations.V2GMessages; import org.eclipse.risev2g.shared.enumerations.V2GMessages;
import org.eclipse.risev2g.shared.v2gMessages.msgDef.EnergyTransferModeType; import org.eclipse.risev2g.shared.v2gMessages.msgDef.EnergyTransferModeType;
import org.eclipse.risev2g.shared.v2gMessages.msgDef.PaymentOptionType; import org.eclipse.risev2g.shared.v2gMessages.msgDef.PaymentOptionType;
import org.eclipse.risev2g.shared.v2gMessages.msgDef.SignedInfoType;
import org.eclipse.risev2g.shared.v2gMessages.msgDef.SupportedEnergyTransferModeType; import org.eclipse.risev2g.shared.v2gMessages.msgDef.SupportedEnergyTransferModeType;
@ -256,14 +259,18 @@ public final class MiscUtils {
* JAXBElement<SessionStopReqType>(new QName ... ) but this seems to work as well * JAXBElement<SessionStopReqType>(new QName ... ) but this seems to work as well
* (I don't know how to infer the type correctly) * (I don't know how to infer the type correctly)
* *
* @param messageOrField * @param messageOrField The message or field for which a digest is to be generated
* @return * @return
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public static JAXBElement getJaxbElement(Object messageOrField) { public static JAXBElement getJaxbElement(Object messageOrField) {
String messageName = messageOrField.getClass().getSimpleName().replace("Type", ""); String messageName = messageOrField.getClass().getSimpleName().replace("Type", "");
String namespace = "";
return new JAXBElement(new QName("urn:iso:15118:2:2013:MsgBody", messageName), if (messageOrField instanceof SignedInfoType) namespace = "http://www.w3.org/2000/09/xmldsig#";
else namespace = "urn:iso:15118:2:2013:MsgBody";
return new JAXBElement(new QName(namespace, messageName),
messageOrField.getClass(), messageOrField.getClass(),
messageOrField); messageOrField);
} }

View File

@ -263,7 +263,7 @@ public final class SecurityUtils {
} catch (InvalidKeyException | CertificateException | NoSuchAlgorithmException | } catch (InvalidKeyException | CertificateException | NoSuchAlgorithmException |
NoSuchProviderException | SignatureException e) { NoSuchProviderException | SignatureException e) {
getLogger().warn("Signature verification of certificate having distinguished name '" + getLogger().warn("Signature verification of certificate having distinguished name '" +
subject.getName() + "' with certificate having distinguished name '" + subject.getName() + "' with certificate having distinguished name (the issuer) '" +
issuerSubject.getName() + "' failed. Expected issuer has distinguished name '" + issuerSubject.getName() + "' failed. Expected issuer has distinguished name '" +
expectedIssuerSubject.getName() + "' (" + e.getClass().getSimpleName() + ")", e); expectedIssuerSubject.getName() + "' (" + e.getClass().getSimpleName() + ")", e);
} }