From 1bfa47c942022dbf4b294cdd494b728deb84298b Mon Sep 17 00:00:00 2001 From: gregor Date: Mon, 1 Dec 2003 09:29:01 +0000 Subject: Zwischenstand git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@65 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../moa/spss/slinterface/beans/ChecksInfoBean.java | 165 +++++++++++++++++++++ .../moa/spss/slinterface/beans/DataInfoBean.java | 25 ++++ .../moa/spss/slinterface/beans/SignerInfoBean.java | 127 ++++++++++++++++ 3 files changed, 317 insertions(+) create mode 100644 spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java create mode 100644 spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java create mode 100644 spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java (limited to 'spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans') diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java new file mode 100644 index 000000000..00c9fd517 --- /dev/null +++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/ChecksInfoBean.java @@ -0,0 +1,165 @@ +/* + * Created on 27.11.2003 + * + * (c) Stabsstelle IKT-Strategie des Bundes + */ +package at.gv.egovernment.moa.spss.slinterface.beans; + +import java.util.List; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.slinterface.Constants; +import at.gv.egovernment.moa.spss.slinterface.DOMUtils; + +/** + * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at) + */ +public class ChecksInfoBean +{ + private static final String SIG_CHECK_ELEM_ = "SignatureCheck"; + private static final String SIGMF_CHECK_ELEM_ = "SignatureManifestCheck"; + private static final String XMLDSIGMF_CHECK_ELEM_ = "XMLDSIGManifestCheck"; + private static final String CERT_CHECK_ELEM_ = "CertificateCheck"; + private static final String CODE_ELEM_ = "Code"; + private static final String INFO_ELEM_ = "Info"; + private static final String FAILEDREF_ELEM_ = "FailedReference"; + private static final String REFSIGREF_ELEM_ = "ReferringSigReference"; + + private Element sigCheckElem_; + private int sigCheckFaildRefCount_; + + private Element sigMFCheckElem_; + private int sigMFCheckFaildRefCount_; + + private List xmldsigMFCheckElems_; + private int xmldsigMFCheckCount_; + private int xmldsigMFCheckFaildRefCount_; + + private Element certCheckElem_; + + /** + * Creates a bean with information about the checks executed for the verified xml signature. + * + * @pre slResponseDoc has been validated. + */ + public ChecksInfoBean(Document slResponseDoc) + { + Element verifyXMLResponseElem = slResponseDoc.getDocumentElement(); + sigCheckElem_ = DOMUtils.getChildElem( + verifyXMLResponseElem, Constants.NSURI_SL_11_, SIG_CHECK_ELEM_); + sigMFCheckElem_ = DOMUtils.getChildElem( + verifyXMLResponseElem, Constants.NSURI_SL_11_, SIGMF_CHECK_ELEM_); + xmldsigMFCheckElems_ = DOMUtils.getChildElems( + verifyXMLResponseElem, Constants.NSURI_SL_11_, XMLDSIGMF_CHECK_ELEM_, false); + certCheckElem_ = DOMUtils.getChildElem( + verifyXMLResponseElem, Constants.NSURI_SL_11_, CERT_CHECK_ELEM_); + + sigCheckFaildRefCount_ = 0; + sigMFCheckFaildRefCount_ = 0; + xmldsigMFCheckFaildRefCount_ = 0; + xmldsigMFCheckCount_ = 0; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSigCheckCode() + { + return DOMUtils.getChildText(sigCheckElem_, Constants.NSURI_SL_11_, CODE_ELEM_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setSigCheckFailedRefCount(int count) + { + sigCheckFaildRefCount_ = count; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSigCheckFailedRef() + { + Element info = DOMUtils.getChildElem(sigCheckElem_, Constants.NSURI_SL_11_, INFO_ELEM_); + if (info == null) return null; + List failedRefElems = DOMUtils.getChildElems(info, Constants.NSURI_SL_11_, FAILEDREF_ELEM_, false); + if (failedRefElems == null || failedRefElems.size() <= sigCheckFaildRefCount_) return null; + return DOMUtils.getText((Element)failedRefElems.get(sigCheckFaildRefCount_)); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSigMFCheckCode() + { + return DOMUtils.getChildText(sigMFCheckElem_, Constants.NSURI_SL_11_, CODE_ELEM_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setSigMFCheckFailedRefCount(int count) + { + sigMFCheckFaildRefCount_ = count; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSigMFCheckFailedRef() + { + Element info = DOMUtils.getChildElem(sigMFCheckElem_, Constants.NSURI_SL_11_, INFO_ELEM_); + if (info == null) return null; + List failedRefElems = DOMUtils.getChildElems(info, Constants.NSURI_SL_11_, FAILEDREF_ELEM_, false); + if (failedRefElems == null || failedRefElems.size() <= sigMFCheckFaildRefCount_) return null; + return DOMUtils.getText((Element)failedRefElems.get(sigMFCheckFaildRefCount_)); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setXmldsigMFCheckCount(int count) + { + xmldsigMFCheckCount_ = count; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setXmldsigMFCheckFailedRefCount(int count) + { + xmldsigMFCheckFaildRefCount_ = count; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getXmldsigMFCheckCode() + { + Element xmldsigMFCheckElem = (Element)xmldsigMFCheckElems_.get(xmldsigMFCheckCount_); + return DOMUtils.getChildText(xmldsigMFCheckElem, Constants.NSURI_SL_11_, CODE_ELEM_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getXmldsigMFCheckFailedRef() + { + Element xmldsigMFCheckElem = (Element)xmldsigMFCheckElems_.get(xmldsigMFCheckCount_); + Element info = DOMUtils.getChildElem(xmldsigMFCheckElem, Constants.NSURI_SL_11_, INFO_ELEM_); + if (info == null) return null; + List failedRefElems = DOMUtils.getChildElems(info, Constants.NSURI_SL_11_, FAILEDREF_ELEM_, false); + if (failedRefElems == null || failedRefElems.size() <= xmldsigMFCheckFaildRefCount_) return null; + return DOMUtils.getText((Element)failedRefElems.get(xmldsigMFCheckFaildRefCount_)); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getXmldsigMFCheckReferringSigRef() + { + Element xmldsigMFCheckElem = (Element)xmldsigMFCheckElems_.get(xmldsigMFCheckCount_); + Element info = DOMUtils.getChildElem(xmldsigMFCheckElem, Constants.NSURI_SL_11_, INFO_ELEM_); + if (info == null) return null; + return DOMUtils.getChildText(info, Constants.NSURI_SL_11_, REFSIGREF_ELEM_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getCertCheckCode() + { + return DOMUtils.getChildText(certCheckElem_, Constants.NSURI_SL_10_, CODE_ELEM_); + } +} diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java new file mode 100644 index 000000000..1a64312d7 --- /dev/null +++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/DataInfoBean.java @@ -0,0 +1,25 @@ +/* + * Created on 27.11.2003 + * + * (c) Stabsstelle IKT-Strategie des Bundes + */ +package at.gv.egovernment.moa.spss.slinterface.beans; + +import org.w3c.dom.Document; + +/** + * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at) + */ +public class DataInfoBean +{ + + /** + * + */ + public DataInfoBean(Document slResponseDoc) + { + super(); + // TODO Auto-generated constructor stub + } + +} diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java new file mode 100644 index 000000000..2893b2ac3 --- /dev/null +++ b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/beans/SignerInfoBean.java @@ -0,0 +1,127 @@ +/* + * Created on 27.11.2003 + * + * (c) Stabsstelle IKT-Strategie des Bundes + */ +package at.gv.egovernment.moa.spss.slinterface.beans; + +import iaik.asn1.ObjectID; +import iaik.asn1.structures.Name; +import iaik.utils.RFC2253NameParser; +import iaik.utils.RFC2253NameParserException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import at.gv.egovernment.moa.spss.slinterface.Constants; +import at.gv.egovernment.moa.spss.slinterface.DOMUtils; + +/** + * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at) + */ +public class SignerInfoBean +{ + private static final String SIGNERINFO_ELEM_ = "SignerInfo"; + private static final String X509DATA_ELEM_ = "X509Data"; + private static final String X509SUBJNAME_ELEM_ = "X509SubjectName"; + private static final String X509ISSUERSERIAL_ELEM_ = "X509IssuerSerial"; + private static final String SERIAL_ELEM_ = "X509SerialNumber"; + private static final String ISSUER_ELEM_ = "X509IssuerName"; + private static final String QUALCERT_ELEM_ = "QualifiedCertificate"; + + private Element signerInfoElem_; + + private String subjectNameItemSel_; + private String issuerNameItemSel_; + + /* ---------------------------------------------------------------------------------------------------- */ + + public SignerInfoBean(Document slResponseDoc) + { + Element verifyXMLResponseElem = slResponseDoc.getDocumentElement(); + signerInfoElem_ = DOMUtils.getChildElem( + verifyXMLResponseElem, Constants.NSURI_SL_11_, SIGNERINFO_ELEM_); + + subjectNameItemSel_ = "2.5.4.3"; + issuerNameItemSel_ = "2.5.4.3"; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setSubjectNameItemSel(String selector) + { + subjectNameItemSel_ = selector; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSubjectNameItem() + { + Element x509DataElem = DOMUtils.getChildElem(signerInfoElem_, Constants.NSURI_DSIG_, X509DATA_ELEM_); + String subjectNameStr = DOMUtils.getChildText(x509DataElem, Constants.NSURI_DSIG_, X509SUBJNAME_ELEM_); + if (subjectNameStr == null) return null; + return getRDN(subjectNameStr, subjectNameItemSel_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getSerial() + { + Element x509DataElem = DOMUtils.getChildElem(signerInfoElem_, Constants.NSURI_DSIG_, X509DATA_ELEM_); + Element iSElem = DOMUtils.getChildElem(x509DataElem, Constants.NSURI_DSIG_, X509ISSUERSERIAL_ELEM_); + return DOMUtils.getChildText(iSElem, Constants.NSURI_DSIG_, SERIAL_ELEM_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public void setIssuerNameItemSel(String selector) + { + issuerNameItemSel_ = selector; + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public String getIssuerNameItem() + { + Element x509DataElem = DOMUtils.getChildElem(signerInfoElem_, Constants.NSURI_DSIG_, X509DATA_ELEM_); + Element iSElem = DOMUtils.getChildElem(x509DataElem, Constants.NSURI_DSIG_, X509ISSUERSERIAL_ELEM_); + String issuerNameStr = DOMUtils.getChildText(iSElem, Constants.NSURI_DSIG_, ISSUER_ELEM_); + if (issuerNameStr == null) return null; + return getRDN(issuerNameStr, issuerNameItemSel_); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + public boolean getIsQualified() + { + Element x509DataElem = DOMUtils.getChildElem(signerInfoElem_, Constants.NSURI_DSIG_, X509DATA_ELEM_); + Element qCElem = DOMUtils.getChildElem(x509DataElem, Constants.NSURI_SL_11_, QUALCERT_ELEM_); + return (qCElem != null); + } + + /* ---------------------------------------------------------------------------------------------------- */ + + private String getRDN(String nameStr, String oidStr) + { + try + { + RFC2253NameParser nameParser = new RFC2253NameParser(nameStr); + Name name = nameParser.parse(); + ObjectID oid = ObjectID.getObjectID(oidStr); + if (oid == null) return null; + String[] rdns = name.getRDNs(oid); + if (rdns == null) return null; + StringBuffer rdnsStr = new StringBuffer(); + for (int i = 0; i < rdns.length; i++) + { + if (i > 0) rdnsStr.append(", "); + rdnsStr.append(rdns[i]); + } + return rdnsStr.toString(); + } + catch (RFC2253NameParserException e) + { + return null; + } + } +} -- cgit v1.2.3