Example usage for javax.xml.bind JAXBException getMessage

List of usage examples for javax.xml.bind JAXBException getMessage

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.silverpeas.publicationTemplate.PublicationTemplateImpl.java

/**
 * load a recordTemplate definition from xml file to java objects
 *
 * @param xmlFileName the xml file name that contains process model definition
 * @return a RecordTemplate object// w  ww . j a va2s .c  o  m
 */
public RecordTemplate loadRecordTemplate(String xmlFileName) throws PublicationTemplateException {
    if (!StringUtil.isDefined(xmlFileName)) {
        return null;
    }

    String filePath = PublicationTemplateManager.makePath(PublicationTemplateManager.templateDir, xmlFileName);

    try {
        Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
        GenericRecordTemplate recordTemplate = (GenericRecordTemplate) unmarshaller
                .unmarshal(new File(filePath));
        recordTemplate.setTemplateName(fileName.substring(0, fileName.lastIndexOf('.')));
        return recordTemplate;
    } catch (JAXBException e) {
        System.out.println("JAXB : " + e.getMessage());
        throw new PublicationTemplateException("PublicationTemplateImpl.loadRecordTemplate",
                "form.EX_ERR_CASTOR_LOAD_XML_MAPPING", "Publication Template FileName : " + xmlFileName, e);
    }

}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

@SuppressWarnings("unchecked")
private StorageInfo findStorageInfo(SignResponse signeResponse) {

    AnyType optionalOutputs = signeResponse.getOptionalOutputs();
    if (null == optionalOutputs) {
        return null;
    }/*w  ww .j  a va2 s. co  m*/
    List<Object> optionalOutputContent = optionalOutputs.getAny();
    for (Object optionalOutput : optionalOutputContent) {

        if (optionalOutput instanceof Element) {

            Element optionalOutputElement = (Element) optionalOutput;
            if (DSSConstants.ARTIFACT_NAMESPACE.equals(optionalOutputElement.getNamespaceURI())
                    && "StorageInfo".equals(optionalOutputElement.getLocalName())) {
                JAXBElement<StorageInfo> storageInfoElement;
                try {
                    storageInfoElement = (JAXBElement<StorageInfo>) this.artifactUnmarshaller
                            .unmarshal(optionalOutputElement);
                } catch (JAXBException e) {
                    throw new RuntimeException("JAXB error parsing storage info: " + e.getMessage(), e);
                }
                return storageInfoElement.getValue();
            }
        }
    }

    return null;
}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

@SuppressWarnings("unchecked")
private VerificationReportType findVerificationReport(ResponseBaseType responseBase) {

    AnyType optionalOutputs = responseBase.getOptionalOutputs();
    if (null == optionalOutputs) {
        return null;
    }// w w  w.  ja  va2  s  . c o  m
    List<Object> optionalOutputContent = optionalOutputs.getAny();
    for (Object optionalOutput : optionalOutputContent) {

        if (optionalOutput instanceof Element) {
            Element optionalOutputElement = (Element) optionalOutput;
            if (DSSConstants.VR_NAMESPACE.equals(optionalOutputElement.getNamespaceURI())
                    && "VerificationReport".equals(optionalOutputElement.getLocalName())) {
                JAXBElement<VerificationReportType> verificationReportElement;
                try {
                    verificationReportElement = (JAXBElement<VerificationReportType>) this.vrUnmarshaller
                            .unmarshal(optionalOutputElement);
                } catch (JAXBException e) {
                    throw new RuntimeException("JAXB error parsing verification report: " + e.getMessage(), e);
                }
                return verificationReportElement.getValue();
            }
        }
    }
    return null;
}

From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java

public <T> T fromElement(Object element, Class<T> type) throws SchemaException {

    if (element == null) {
        return null;
    }/*from   w  ww . j a v a  2s  .  c  o  m*/

    if (type.isAssignableFrom(element.getClass())) {
        return (T) element;
    }

    if (element instanceof JAXBElement) {
        if (((JAXBElement) element).getValue() == null) {
            return null;
        }
        if (type.isAssignableFrom(((JAXBElement) element).getValue().getClass())) {
            return (T) ((JAXBElement) element).getValue();
        }
    }

    if (element instanceof Element) {
        try {
            JAXBElement<T> unmarshalledElement = unmarshalElement((Element) element, type);
            return unmarshalledElement.getValue();
        } catch (JAXBException e) {
            throw new IllegalArgumentException("Unmarshall failed: " + e.getMessage(), e);
        }
    }

    throw new IllegalArgumentException("Unknown element type " + element.getClass().getName());
}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

private ResponseBaseType doVerification(byte[] documentData, String mimeType, boolean returnSignerIdentity,
        boolean returnVerificationReport, byte[] originalDocumentData) throws NotParseableXMLDocumentException {

    LOG.debug("verify");

    String requestId = "dss-verify-request-" + UUID.randomUUID().toString();
    VerifyRequest verifyRequest = this.dssObjectFactory.createVerifyRequest();
    verifyRequest.setRequestID(requestId);

    AnyType optionalInputs = this.dssObjectFactory.createAnyType();
    if (returnSignerIdentity) {
        JAXBElement<Object> returnSignerIdentityElement = this.dssObjectFactory
                .createReturnSignerIdentity(null);
        optionalInputs.getAny().add(returnSignerIdentityElement);
    }//from  w  w w.ja  v  a 2 s. c  om
    if (returnVerificationReport) {
        ReturnVerificationReport jaxbReturnVerificationReport = this.vrObjectFactory
                .createReturnVerificationReport();
        /*
         * No need to do this, as we're using SSL.
         */
        jaxbReturnVerificationReport.setIncludeVerifier(false);
        jaxbReturnVerificationReport.setIncludeCertificateValues(true);
        jaxbReturnVerificationReport.setReportDetailLevel(
                "urn:oasis:names:tc:dss-x:1.0:profiles:verificationreport:reportdetail:noDetails");

        Document document = this.documentBuilder.newDocument();
        Element newElement = document.createElement("newNode");
        try {
            this.vrMarshaller.marshal(jaxbReturnVerificationReport, newElement);
        } catch (JAXBException e) {
            throw new RuntimeException("JAXB error: " + e.getMessage(), e);
        }
        Element returnVerificationReportElement = (Element) newElement.getFirstChild();
        optionalInputs.getAny().add(returnVerificationReportElement);
    }
    if (null != originalDocumentData) {
        OriginalDocumentType originalDocument = this.originalDocumentObjectFactory.createOriginalDocumentType();
        InputDocuments inputDocuments = this.vrDssObjectFactory.createInputDocuments();
        List<Object> documents = inputDocuments.getDocumentOrTransformedDataOrDocumentHash();
        be.fedict.eid.dss.ws.profile.vr.jaxb.dss.DocumentType document = this.vrDssObjectFactory
                .createDocumentType();
        if (null == mimeType || "text/xml".equals(mimeType)) {
            document.setBase64XML(originalDocumentData);
        } else {
            be.fedict.eid.dss.ws.profile.vr.jaxb.dss.Base64Data base64Data = this.vrDssObjectFactory
                    .createBase64Data();
            base64Data.setValue(originalDocumentData);
            base64Data.setMimeType(mimeType);
            document.setBase64Data(base64Data);
        }
        documents.add(document);
        originalDocument.setInputDocuments(inputDocuments);

        Document domDocument = this.documentBuilder.newDocument();
        Element newElement = domDocument.createElement("newElement");
        try {
            this.originalDocumentMarshaller.marshal(
                    this.originalDocumentObjectFactory.createOriginalDocument(originalDocument), newElement);
        } catch (JAXBException e) {
            throw new RuntimeException("JAXB error: " + e.getMessage(), e);
        }

        optionalInputs.getAny().add((Element) newElement.getFirstChild());
    }

    if (!optionalInputs.getAny().isEmpty()) {
        verifyRequest.setOptionalInputs(optionalInputs);
    }

    verifyRequest.setInputDocuments(getInputDocuments(documentData, mimeType));

    // operate
    ResponseBaseType response = port.verify(verifyRequest);

    // check response
    checkResponse(response, requestId);

    return response;
}

From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java

private void printExtension(ExtensionType extension, Document document) throws DocumentException {

    List<Object> contentList = extension.getContent();
    for (Object content : contentList) {
        LOG.debug("extension content: " + content.getClass().getName());
        if (content instanceof JAXBElement<?>) {
            JAXBElement<?> element = (JAXBElement<?>) content;
            LOG.debug("QName: " + element.getName());
            if (true == ADDITIONAL_SERVICE_INFORMATION_QNAME.equals(element.getName())) {
                addTitle("Extension (critical: " + extension.isCritical() + ")", title3Font,
                        Paragraph.ALIGN_LEFT, 0, 0, document);
                addTitle("Additional service information", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document);
                AdditionalServiceInformationType additionalServiceInformation = (AdditionalServiceInformationType) element
                        .getValue();/* w  w  w . j  a v  a  2  s  . co m*/
                LOG.debug("information value: " + additionalServiceInformation.getInformationValue());
                NonEmptyMultiLangURIType multiLangUri = additionalServiceInformation.getURI();
                LOG.debug("URI : " + multiLangUri.getValue() + " (language: " + multiLangUri.getLang() + ")");
                document.add(new Paragraph(
                        multiLangUri.getValue().substring(
                                multiLangUri.getValue().indexOf("SvcInfoExt/") + "SvcInfoExt/".length()),
                        this.valueFont));
            } else {
                addTitle("Extension (critical: " + extension.isCritical() + ")", title3Font,
                        Paragraph.ALIGN_LEFT, 0, 0, document);
                addTitle("Qualifications", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document);

                LOG.debug("element namespace: " + element.getName());
                LOG.debug("element name: " + element.getScope());
                if ("http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#"
                        .equals(element.getName().getNamespaceURI())
                        && "Qualifications".equals(element.getName().getLocalPart())) {
                    QualificationsType qualifications = (QualificationsType) element.getValue();
                    List<QualificationElementType> qualificationElements = qualifications
                            .getQualificationElement();
                    for (QualificationElementType qualificationElement : qualificationElements) {
                        QualifiersType qualifiers = qualificationElement.getQualifiers();
                        List<QualifierType> qualifierList = qualifiers.getQualifier();
                        for (QualifierType qualifier : qualifierList) {
                            document.add(new Paragraph(
                                    "Qualifier: " + qualifier.getUri().substring(
                                            qualifier.getUri().indexOf("SvcInfoExt/") + "SvcInfoExt/".length()),
                                    this.valueFont));
                        }

                        CriteriaListType criteriaList = qualificationElement.getCriteriaList();
                        String description = criteriaList.getDescription();
                        if (null != description) {
                            document.add(new Paragraph("Criterial List Description", this.labelFont));
                            document.add(new Paragraph(description, this.valueFont));
                        }
                        document.add(new Paragraph("Assert: " + criteriaList.getAssert(), this.valueFont));
                        List<PoliciesListType> policySet = criteriaList.getPolicySet();
                        for (PoliciesListType policiesList : policySet) {
                            List<ObjectIdentifierType> oids = policiesList.getPolicyIdentifier();
                            for (ObjectIdentifierType oid : oids) {
                                document.add(new Paragraph("Policy OID: " + oid.getIdentifier().getValue(),
                                        this.valueFont));
                            }
                        }
                    }
                }

            }

        } else if (content instanceof Element) {
            addTitle("Qualifications", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document);
            Element element = (Element) content;
            LOG.debug("element namespace: " + element.getNamespaceURI());
            LOG.debug("element name: " + element.getLocalName());
            if ("http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#"
                    .equals(element.getNamespaceURI()) && "Qualifications".equals(element.getLocalName())) {
                try {
                    QualificationsType qualifications = unmarshallQualifications(element);
                    List<QualificationElementType> qualificationElements = qualifications
                            .getQualificationElement();
                    for (QualificationElementType qualificationElement : qualificationElements) {
                        QualifiersType qualifiers = qualificationElement.getQualifiers();
                        List<QualifierType> qualifierList = qualifiers.getQualifier();
                        for (QualifierType qualifier : qualifierList) {
                            document.add(new Paragraph(
                                    "Qualifier: " + qualifier.getUri().substring(
                                            qualifier.getUri().indexOf("SvcInfoExt/") + "SvcInfoExt/".length()),
                                    this.valueFont));
                        }

                        CriteriaListType criteriaList = qualificationElement.getCriteriaList();
                        String description = criteriaList.getDescription();
                        if (null != description) {
                            document.add(new Paragraph("Criterial List Description", this.labelFont));
                            document.add(new Paragraph(description, this.valueFont));
                        }
                        document.add(new Paragraph("Assert: " + criteriaList.getAssert(), this.valueFont));
                        List<PoliciesListType> policySet = criteriaList.getPolicySet();
                        for (PoliciesListType policiesList : policySet) {
                            List<ObjectIdentifierType> oids = policiesList.getPolicyIdentifier();
                            for (ObjectIdentifierType oid : oids) {
                                document.add(new Paragraph("Policy OID: " + oid.getIdentifier().getValue(),
                                        this.valueFont));
                            }
                        }
                    }
                } catch (JAXBException e) {
                    LOG.error("JAXB error: " + e.getMessage(), e);
                }
            }
        }
    }
}

From source file:be.fedict.eid.applet.service.signer.facets.XAdESXLSignatureFacet.java

public void postSign(Element signatureElement, List<X509Certificate> signingCertificateChain) {
    LOG.debug("XAdES-X-L post sign phase");
    for (X509Certificate xCert : signingCertificateChain) {
        LOG.debug("Cert chain: " + xCert.getSubjectX500Principal());
    }/*from  w w w .  j  a v  a 2 s. c  o m*/

    // check for XAdES-BES
    Element qualifyingPropertiesElement = (Element) findSingleNode(signatureElement,
            "ds:Object/xades:QualifyingProperties");
    if (null == qualifyingPropertiesElement) {
        throw new IllegalArgumentException("no XAdES-BES extension present");
    }

    // create basic XML container structure
    Document document = signatureElement.getOwnerDocument();
    String xadesNamespacePrefix;
    if (null != qualifyingPropertiesElement.getPrefix()) {
        xadesNamespacePrefix = qualifyingPropertiesElement.getPrefix() + ":";
    } else {
        xadesNamespacePrefix = "";
    }
    Element unsignedPropertiesElement = (Element) findSingleNode(qualifyingPropertiesElement,
            "xades:UnsignedProperties");
    if (null == unsignedPropertiesElement) {
        unsignedPropertiesElement = document.createElementNS(XADES_NAMESPACE,
                xadesNamespacePrefix + "UnsignedProperties");
        qualifyingPropertiesElement.appendChild(unsignedPropertiesElement);
    }
    Element unsignedSignaturePropertiesElement = (Element) findSingleNode(unsignedPropertiesElement,
            "xades:UnsignedSignatureProperties");
    if (null == unsignedSignaturePropertiesElement) {
        unsignedSignaturePropertiesElement = document.createElementNS(XADES_NAMESPACE,
                xadesNamespacePrefix + "UnsignedSignatureProperties");
        unsignedPropertiesElement.appendChild(unsignedSignaturePropertiesElement);
    }

    // create the XAdES-T time-stamp
    Node signatureValueNode = findSingleNode(signatureElement, "ds:SignatureValue");
    RevocationData tsaRevocationDataXadesT = new RevocationData();
    LOG.debug("creating XAdES-T time-stamp");
    XAdESTimeStampType signatureTimeStamp = createXAdESTimeStamp(Collections.singletonList(signatureValueNode),
            tsaRevocationDataXadesT, this.c14nAlgoId, this.timeStampService, this.objectFactory,
            this.xmldsigObjectFactory);

    // marshal the XAdES-T extension
    try {
        this.marshaller.marshal(this.objectFactory.createSignatureTimeStamp(signatureTimeStamp),
                unsignedSignaturePropertiesElement);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    // xadesv141::TimeStampValidationData
    if (tsaRevocationDataXadesT.hasRevocationDataEntries()) {
        ValidationDataType validationData = createValidationData(tsaRevocationDataXadesT);
        try {
            this.marshaller.marshal(this.xades141ObjectFactory.createTimeStampValidationData(validationData),
                    unsignedSignaturePropertiesElement);
        } catch (JAXBException e) {
            throw new RuntimeException("JAXB error: " + e.getMessage(), e);
        }
    }

    if (null == this.revocationDataService) {
        /*
         * Without revocation data service we cannot construct the XAdES-C
         * extension.
         */
        return;
    }

    // XAdES-C: complete certificate refs
    CompleteCertificateRefsType completeCertificateRefs = this.objectFactory
            .createCompleteCertificateRefsType();
    CertIDListType certIdList = this.objectFactory.createCertIDListType();
    completeCertificateRefs.setCertRefs(certIdList);
    List<CertIDType> certIds = certIdList.getCert();
    for (int certIdx = 1; certIdx < signingCertificateChain.size(); certIdx++) {
        /*
         * We skip the signing certificate itself according to section
         * 4.4.3.2 of the XAdES 1.4.1 specification.
         */
        X509Certificate certificate = signingCertificateChain.get(certIdx);
        CertIDType certId = XAdESSignatureFacet.getCertID(certificate, this.objectFactory,
                this.xmldsigObjectFactory, this.digestAlgorithm, false);
        certIds.add(certId);
    }

    // XAdES-C: complete revocation refs
    CompleteRevocationRefsType completeRevocationRefs = this.objectFactory.createCompleteRevocationRefsType();
    RevocationData revocationData = this.revocationDataService.getRevocationData(signingCertificateChain);
    if (revocationData.hasCRLs()) {
        CRLRefsType crlRefs = this.objectFactory.createCRLRefsType();
        completeRevocationRefs.setCRLRefs(crlRefs);
        List<CRLRefType> crlRefList = crlRefs.getCRLRef();

        List<byte[]> crls = revocationData.getCRLs();
        for (byte[] encodedCrl : crls) {
            CRLRefType crlRef = this.objectFactory.createCRLRefType();
            crlRefList.add(crlRef);
            X509CRL crl;
            try {
                crl = (X509CRL) this.certificateFactory.generateCRL(new ByteArrayInputStream(encodedCrl));
            } catch (CRLException e) {
                throw new RuntimeException("CRL parse error: " + e.getMessage(), e);
            }

            CRLIdentifierType crlIdentifier = this.objectFactory.createCRLIdentifierType();
            crlRef.setCRLIdentifier(crlIdentifier);
            String issuerName;
            try {
                issuerName = PrincipalUtil.getIssuerX509Principal(crl).getName().replace(",", ", ");
            } catch (CRLException e) {
                throw new RuntimeException("CRL encoding error: " + e.getMessage(), e);
            }
            crlIdentifier.setIssuer(issuerName);
            crlIdentifier.setIssueTime(this.datatypeFactory
                    .newXMLGregorianCalendar(new DateTime(crl.getThisUpdate()).toGregorianCalendar()));
            crlIdentifier.setNumber(getCrlNumber(crl));

            DigestAlgAndValueType digestAlgAndValue = XAdESSignatureFacet.getDigestAlgAndValue(encodedCrl,
                    this.objectFactory, this.xmldsigObjectFactory, this.digestAlgorithm);
            crlRef.setDigestAlgAndValue(digestAlgAndValue);
        }
    }
    if (revocationData.hasOCSPs()) {
        OCSPRefsType ocspRefs = this.objectFactory.createOCSPRefsType();
        completeRevocationRefs.setOCSPRefs(ocspRefs);
        List<OCSPRefType> ocspRefList = ocspRefs.getOCSPRef();
        List<byte[]> ocsps = revocationData.getOCSPs();
        for (byte[] ocsp : ocsps) {
            OCSPRefType ocspRef = this.objectFactory.createOCSPRefType();
            ocspRefList.add(ocspRef);

            DigestAlgAndValueType digestAlgAndValue = XAdESSignatureFacet.getDigestAlgAndValue(ocsp,
                    this.objectFactory, this.xmldsigObjectFactory, this.digestAlgorithm);
            ocspRef.setDigestAlgAndValue(digestAlgAndValue);

            OCSPIdentifierType ocspIdentifier = this.objectFactory.createOCSPIdentifierType();
            ocspRef.setOCSPIdentifier(ocspIdentifier);
            OCSPResp ocspResp;
            try {
                ocspResp = new OCSPResp(ocsp);
            } catch (IOException e) {
                throw new RuntimeException("OCSP decoding error: " + e.getMessage(), e);
            }
            Object ocspResponseObject;
            try {
                ocspResponseObject = ocspResp.getResponseObject();
            } catch (OCSPException e) {
                throw new RuntimeException("OCSP error: " + e.getMessage(), e);
            }
            BasicOCSPResp basicOcspResp = (BasicOCSPResp) ocspResponseObject;
            Date producedAt = basicOcspResp.getProducedAt();
            ocspIdentifier.setProducedAt(this.datatypeFactory
                    .newXMLGregorianCalendar(new DateTime(producedAt).toGregorianCalendar()));

            ResponderIDType responderId = this.objectFactory.createResponderIDType();
            ocspIdentifier.setResponderID(responderId);
            RespID respId = basicOcspResp.getResponderId();
            ResponderID ocspResponderId = respId.toASN1Object();
            DERTaggedObject derTaggedObject = (DERTaggedObject) ocspResponderId.toASN1Object();
            if (2 == derTaggedObject.getTagNo()) {
                ASN1OctetString keyHashOctetString = (ASN1OctetString) derTaggedObject.getObject();
                responderId.setByKey(keyHashOctetString.getOctets());
            } else {
                X509Name name = X509Name.getInstance(derTaggedObject.getObject());
                responderId.setByName(name.toString());
            }
        }
    }

    // marshal XAdES-C
    NodeList unsignedSignaturePropertiesNodeList = ((Element) qualifyingPropertiesElement)
            .getElementsByTagNameNS(XADES_NAMESPACE, "UnsignedSignatureProperties");
    Node unsignedSignaturePropertiesNode = unsignedSignaturePropertiesNodeList.item(0);
    try {
        this.marshaller.marshal(this.objectFactory.createCompleteCertificateRefs(completeCertificateRefs),
                unsignedSignaturePropertiesNode);
        this.marshaller.marshal(this.objectFactory.createCompleteRevocationRefs(completeRevocationRefs),
                unsignedSignaturePropertiesNode);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    // XAdES-X Type 1 timestamp
    List<Node> timeStampNodesXadesX1 = new LinkedList<Node>();
    timeStampNodesXadesX1.add(signatureValueNode);
    Node signatureTimeStampNode = findSingleNode(unsignedSignaturePropertiesNode, "xades:SignatureTimeStamp");
    timeStampNodesXadesX1.add(signatureTimeStampNode);
    Node completeCertificateRefsNode = findSingleNode(unsignedSignaturePropertiesNode,
            "xades:CompleteCertificateRefs");
    timeStampNodesXadesX1.add(completeCertificateRefsNode);
    Node completeRevocationRefsNode = findSingleNode(unsignedSignaturePropertiesNode,
            "xades:CompleteRevocationRefs");
    timeStampNodesXadesX1.add(completeRevocationRefsNode);

    RevocationData tsaRevocationDataXadesX1 = new RevocationData();
    LOG.debug("creating XAdES-X time-stamp");
    XAdESTimeStampType timeStampXadesX1 = createXAdESTimeStamp(timeStampNodesXadesX1, tsaRevocationDataXadesX1,
            this.c14nAlgoId, this.timeStampService, this.objectFactory, this.xmldsigObjectFactory);
    ValidationDataType timeStampXadesX1ValidationData;
    if (tsaRevocationDataXadesX1.hasRevocationDataEntries()) {
        timeStampXadesX1ValidationData = createValidationData(tsaRevocationDataXadesX1);
    } else {
        timeStampXadesX1ValidationData = null;
    }

    // marshal XAdES-X
    try {
        this.marshaller.marshal(this.objectFactory.createSigAndRefsTimeStamp(timeStampXadesX1),
                unsignedSignaturePropertiesNode);
        if (null != timeStampXadesX1ValidationData) {
            this.marshaller.marshal(
                    this.xades141ObjectFactory.createTimeStampValidationData(timeStampXadesX1ValidationData),
                    unsignedSignaturePropertiesNode);
        }
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    // XAdES-X-L
    CertificateValuesType certificateValues = this.objectFactory.createCertificateValuesType();
    List<Object> certificateValuesList = certificateValues.getEncapsulatedX509CertificateOrOtherCertificate();
    for (X509Certificate certificate : signingCertificateChain) {
        EncapsulatedPKIDataType encapsulatedPKIDataType = this.objectFactory.createEncapsulatedPKIDataType();
        try {
            encapsulatedPKIDataType.setValue(certificate.getEncoded());
        } catch (CertificateEncodingException e) {
            throw new RuntimeException("certificate encoding error: " + e.getMessage(), e);
        }
        certificateValuesList.add(encapsulatedPKIDataType);
    }
    RevocationValuesType revocationValues = createRevocationValues(revocationData);

    // marshal XAdES-X-L
    try {
        this.marshaller.marshal(this.objectFactory.createCertificateValues(certificateValues),
                unsignedSignaturePropertiesNode);
        this.marshaller.marshal(this.objectFactory.createRevocationValues(revocationValues),
                unsignedSignaturePropertiesNode);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }
}

From source file:edu.purdue.cybercenter.dm.service.TermService.java

public TermService() {
    try {/*from   ww w . ja va  2 s.c o  m*/
        context = JAXBContext.newInstance(Term.class);
    } catch (JAXBException ex) {
        throw new RuntimeException("failed to instantiate unmarshaller for Term: " + ex.getMessage());
    }
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

private HDWorkload unmarshalWorkload(String xml) {
    HDWorkload ret = null;// ww w .j av  a 2s.  c o  m
    try {
        ret = JaxbUtil.unmarshall(xml, HDWorkload.class);
    } catch (JAXBException e) {
        JOptionPane.showMessageDialog(debuggerFrame, e.getMessage(), "Error unmarshalling xml",
                JOptionPane.ERROR_MESSAGE);
    }
    return ret;
}

From source file:it.okkam.rdf2okkam.ens.client.EnsClient.java

License:asdf

/**
 * // *********************** private *****************************
 *///from   w  w  w . java  2 s  .  c  o  m
private Entity getEntityImp(String oid, String authKey) throws OkkamClientException, OkkamCoreException {
    try {
        String serviceResult = proxy.getEntity(oid);
        // convert // xml // -> // Entity
        XMLEntityConverter converter = new XMLEntityConverter();
        Entity e = converter.xmlToEntity(serviceResult);
        return e;
    } catch (JAXBException exc) {
        log.error("Impossible to get the entity, convertion xml -> Entity exception, " + exc.getMessage());
        throw new OkkamClientException(
                "Impossible to get the entity, convertion xml -> Entity exception, " + exc.getMessage());
    } catch (Exception exc) {
        log.error("Impossible to get the entity, client exception, " + exc.getMessage());
        throw new OkkamClientException(exc.getMessage());
    } catch (Throwable t) {
        log.error("Impossible to get the entity, client exception, " + t.getMessage());
        throw new OkkamClientException(t.getMessage());
    }
}