Example usage for javax.xml.bind JAXBElement getName

List of usage examples for javax.xml.bind JAXBElement getName

Introduction

In this page you can find the example usage for javax.xml.bind JAXBElement getName.

Prototype

public QName getName() 

Source Link

Document

Returns the xml element tag name.

Usage

From source file:com.netflix.imfutility.cpl._2016.Cpl2016ContextBuilderStrategy.java

@Override
protected void buildFromCpl() {
    // 1. get a composition edit rate (it's used if no specific edit rate is specified for a segment).
    this.compositionEditRate = ConversionHelper.parseEditRate(cpl2016.getEditRate());

    // 2. go through all segments and all sequences and build segment, sequence and resource contexts.
    for (SegmentType segment : cpl2016.getSegmentList().getSegment()) {
        this.currentSegmentUuid = SegmentUUID.create(segment.getId());

        contextProvider.getSegmentContext().initSegment(currentSegmentUuid);

        for (Object anySeqJaxb : segment.getSequenceList().getAny()) {
            if (!(anySeqJaxb instanceof JAXBElement)) {
                throw new ConversionException(
                        String.format("Could not understand a sequence '%s'", anySeqJaxb.toString()));
            }//  w  ww. ja v  a  2s.  c o  m

            JAXBElement jaxbElement = (JAXBElement) (anySeqJaxb);
            Object anySeq = jaxbElement.getValue();

            SequenceTypeCpl currentSequenceTypeCpl = SequenceTypeCpl
                    .fromName(jaxbElement.getName().getLocalPart());
            if ((currentSequenceTypeCpl != null) && (anySeq instanceof SequenceType)) {
                this.currentSequence = (SequenceType) anySeq;
                this.currentSequenceType = currentSequenceTypeCpl.toSequenceType();
                this.currentSequenceUuid = SequenceUUID.create(currentSequence.getTrackId());
                processSequence();
            }
        }
    }
}

From source file:com.evolveum.midpoint.repo.common.expression.Expression.java

private ExpressionEvaluator<V, D> createEvaluator(Collection<JAXBElement<?>> evaluatorElements,
        ExpressionFactory factory, String contextDescription, Task task, OperationResult result)
        throws SchemaException, ObjectNotFoundException {
    if (evaluatorElements.isEmpty()) {
        throw new SchemaException("Empty evaluator list in " + contextDescription);
    }//from   ww w . j a v  a2  s .co m
    JAXBElement<?> fistEvaluatorElement = evaluatorElements.iterator().next();
    ExpressionEvaluatorFactory evaluatorFactory = factory.getEvaluatorFactory(fistEvaluatorElement.getName());
    if (evaluatorFactory == null) {
        throw new SchemaException("Unknown expression evaluator element " + fistEvaluatorElement.getName()
                + " in " + contextDescription);
    }
    return evaluatorFactory.createEvaluator(evaluatorElements, outputDefinition, factory, contextDescription,
            task, result);
}

From source file:be.agiv.security.client.IPSTSClient.java

private SecurityToken getSecurityToken(String username, String password, X509Certificate certificate,
        PrivateKey privateKey) {//from   w w  w . j av a2s .  c  o m
    RequestSecurityTokenType requestSecurityToken = this.objectFactory.createRequestSecurityTokenType();
    List<Object> requestSecurityTokenContent = requestSecurityToken.getAny();
    requestSecurityTokenContent.add(this.objectFactory.createRequestType(WSConstants.ISSUE_REQUEST_TYPE));

    EntropyType entropy = this.objectFactory.createEntropyType();
    requestSecurityTokenContent.add(this.objectFactory.createEntropy(entropy));
    BinarySecretType binarySecret = this.objectFactory.createBinarySecretType();
    entropy.getAny().add(this.objectFactory.createBinarySecret(binarySecret));
    binarySecret.setType(WSConstants.SECRET_TYPE_NONCE);

    requestSecurityTokenContent.add(this.objectFactory.createKeyType(WSConstants.KEY_TYPE_SYMMETRIC));

    requestSecurityTokenContent.add(this.objectFactory.createKeySize(256L));

    if (null == this.wsTrustHandler.getSecondaryParameters()) {
        requestSecurityTokenContent
                .add(this.objectFactory.createKeyWrapAlgorithm(WSConstants.KEY_WRAP_ALGO_RSA_OAEP_MGF1P));

        requestSecurityTokenContent.add(this.objectFactory.createEncryptWith(WSConstants.ENC_ALGO_AES256_CBC));

        requestSecurityTokenContent.add(this.objectFactory.createSignWith(WSConstants.SIGN_ALGO_HMAC_SHA1));

        requestSecurityTokenContent
                .add(this.objectFactory.createCanonicalizationAlgorithm(WSConstants.C14N_ALGO_EXC));

        requestSecurityTokenContent
                .add(this.objectFactory.createEncryptionAlgorithm(WSConstants.ENC_ALGO_AES256_CBC));
    }

    AppliesTo appliesTo = this.policyObjectFactory.createAppliesTo();
    EndpointReferenceType endpointReference = this.addrObjectFactory.createEndpointReferenceType();
    AttributedURIType address = this.addrObjectFactory.createAttributedURIType();
    address.setValue(this.realm);
    endpointReference.setAddress(address);
    appliesTo.getAny().add(this.addrObjectFactory.createEndpointReference(endpointReference));
    requestSecurityTokenContent.add(appliesTo);

    requestSecurityTokenContent
            .add(this.objectFactory.createComputedKeyAlgorithm(WSConstants.COMP_KEY_ALGO_PSHA1));

    byte[] entropyData = new byte[256 / 8];
    // entropy = keysize / 8
    this.secureRandom.setSeed(System.currentTimeMillis());
    this.secureRandom.nextBytes(entropyData);
    binarySecret.setValue(entropyData);

    BindingProvider bindingProvider = (BindingProvider) this.port;
    if (null != username) {
        this.wsSecurityHandler.setCredentials(username, password);
    } else if (null != certificate) {
        this.wsSecurityHandler.setCredentials(privateKey, certificate);
    }
    this.wsAddressingHandler.setAddressing(WSConstants.WS_TRUST_ISSUE_ACTION, this.location);

    RequestSecurityTokenResponseCollectionType requestSecurityTokenResponseCollection = this.port
            .requestSecurityToken(requestSecurityToken);

    SecurityToken securityToken = new SecurityToken();

    List<RequestSecurityTokenResponseType> requestSecurityTokenResponseList = requestSecurityTokenResponseCollection
            .getRequestSecurityTokenResponse();
    RequestSecurityTokenResponseType requestSecurityTokenResponse = requestSecurityTokenResponseList.get(0);
    List<Object> requestSecurityTokenResponseContent = requestSecurityTokenResponse.getAny();
    for (Object contentObject : requestSecurityTokenResponseContent) {
        LOG.debug("content object: " + contentObject.getClass().getName());
        if (contentObject instanceof Element) {
            Element contentElement = (Element) contentObject;
            LOG.debug("element name: " + contentElement.getLocalName());
        }
        if (contentObject instanceof JAXBElement) {
            JAXBElement jaxbElement = (JAXBElement) contentObject;
            QName qname = jaxbElement.getName();
            LOG.debug("qname: " + qname);
            if (WSConstants.ENTROPY_QNAME.equals(qname)) {
                LOG.debug("trust:Entropy");
                EntropyType serverEntropy = (EntropyType) jaxbElement.getValue();
                List<Object> entropyContent = serverEntropy.getAny();
                for (Object entropyObject : entropyContent) {
                    if (entropyObject instanceof JAXBElement) {
                        JAXBElement entropyElement = (JAXBElement) entropyObject;
                        if (WSConstants.BINARY_SECRET_QNAME.equals(entropyElement.getName())) {
                            BinarySecretType serverBinarySecret = (BinarySecretType) entropyElement.getValue();
                            byte[] serverSecret = serverBinarySecret.getValue();
                            P_SHA1 p_SHA1 = new P_SHA1();
                            byte[] key;
                            try {
                                key = p_SHA1.createKey(entropyData, serverSecret, 0, 256 / 8);
                            } catch (ConversationException e) {
                                LOG.error(e);
                                return null;
                            }
                            LOG.debug("client secret size: " + entropyData.length);
                            LOG.debug("server secret size: " + serverSecret.length);
                            LOG.debug("key size: " + key.length);
                            securityToken.setKey(key);
                        }
                    }
                }
            } else if (WSConstants.LIFETIME_QNAME.equals(qname)) {
                LOG.debug("trust:Lifetime");
                LifetimeType lifetime = (LifetimeType) jaxbElement.getValue();
                String createdValue = lifetime.getCreated().getValue();
                DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTimeParser();
                DateTime created = dateTimeFormatter.parseDateTime(createdValue);
                securityToken.setCreated(created.toDate());
                String expiresString = lifetime.getExpires().getValue();
                DateTime expires = dateTimeFormatter.parseDateTime(expiresString);
                securityToken.setExpires(expires.toDate());
            } else if (WSConstants.REQUESTED_ATTACHED_REFERENCE_QNAME.equals(qname)) {
                RequestedReferenceType requestedReference = (RequestedReferenceType) jaxbElement.getValue();
                SecurityTokenReferenceType securityTokenReference = requestedReference
                        .getSecurityTokenReference();
                List<Object> securityTokenReferenceContent = securityTokenReference.getAny();
                for (Object securityTokenReferenceObject : securityTokenReferenceContent) {
                    LOG.debug("SecurityTokenReference object: "
                            + securityTokenReferenceObject.getClass().getName());
                    if (securityTokenReferenceObject instanceof JAXBElement) {
                        JAXBElement securityTokenReferenceElement = (JAXBElement) securityTokenReferenceObject;
                        LOG.debug("SecurityTokenReference element: " + securityTokenReferenceElement.getName());
                        if (securityTokenReferenceElement.getName().equals(WSConstants.KEY_IDENTIFIER_QNAME)) {
                            KeyIdentifierType keyIdentifier = (KeyIdentifierType) securityTokenReferenceElement
                                    .getValue();
                            String attachedReference = keyIdentifier.getValue();
                            securityToken.setAttachedReference(attachedReference);
                        }

                    }
                }
            } else if (WSConstants.REQUESTED_UNATTACHED_REFERENCE_QNAME.equals(qname)) {
                RequestedReferenceType requestedReference = (RequestedReferenceType) jaxbElement.getValue();
                SecurityTokenReferenceType securityTokenReference = requestedReference
                        .getSecurityTokenReference();
                List<Object> securityTokenReferenceContent = securityTokenReference.getAny();
                for (Object securityTokenReferenceObject : securityTokenReferenceContent) {
                    LOG.debug("SecurityTokenReference object: "
                            + securityTokenReferenceObject.getClass().getName());
                    if (securityTokenReferenceObject instanceof JAXBElement) {
                        JAXBElement securityTokenReferenceElement = (JAXBElement) securityTokenReferenceObject;
                        LOG.debug("SecurityTokenReference element: " + securityTokenReferenceElement.getName());
                        if (securityTokenReferenceElement.getName().equals(WSConstants.KEY_IDENTIFIER_QNAME)) {
                            KeyIdentifierType keyIdentifier = (KeyIdentifierType) securityTokenReferenceElement
                                    .getValue();
                            String unattachedReference = keyIdentifier.getValue();
                            securityToken.setUnattachedReference(unattachedReference);
                        }

                    }
                }
            }
        }
    }

    Element requestedSecurityToken = this.wsTrustHandler.getRequestedSecurityToken();
    securityToken.setToken(requestedSecurityToken);
    securityToken.setRealm(this.realm);
    securityToken.setStsLocation(this.location);

    return securityToken;
}

From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java

private static String getOrig(PolyStringType polyStringType) {
    if (polyStringType == null) {
        return null;
    }//from w ww. jav  a  2 s.c o  m
    StringBuilder sb = new StringBuilder();
    for (Object o : polyStringType.getContent()) {
        if (o instanceof String) {
            sb.append(o);
        } else if (o instanceof Element) {
            Element e = (Element) o;
            if ("orig".equals(e.getLocalName())) {
                return e.getTextContent();
            }
        } else if (o instanceof JAXBElement) {
            JAXBElement je = (JAXBElement) o;
            if ("orig".equals(je.getName().getLocalPart())) {
                return (String) je.getValue();
            }
        }
    }
    return sb.toString();
}

From source file:eu.europa.esig.dss.tsl.service.TSLParser.java

private void fillPointerTerritoryAndMimeType(OtherTSLPointerType otherTSLPointerType, TSLPointer pointer) {
    List<Serializable> textualInformationOrOtherInformation = otherTSLPointerType.getAdditionalInformation()
            .getTextualInformationOrOtherInformation();
    if (CollectionUtils.isNotEmpty(textualInformationOrOtherInformation)) {
        Map<String, String> properties = new HashMap<String, String>();
        for (Serializable serializable : textualInformationOrOtherInformation) {
            if (serializable instanceof AnyType) {
                AnyType anyInfo = (AnyType) serializable;
                for (Object content : anyInfo.getContent()) {
                    if (content instanceof JAXBElement) {
                        @SuppressWarnings("rawtypes")
                        JAXBElement jaxbElement = (JAXBElement) content;
                        properties.put(jaxbElement.getName().toString(), jaxbElement.getValue().toString());
                    } else if (content instanceof Element) {
                        Element element = (Element) content;
                        properties.put("{" + element.getNamespaceURI() + "}" + element.getLocalName(),
                                element.getTextContent());
                    }/*from   w  ww  .j av a  2s.c om*/
                }
            }
        }
        pointer.setMimeType(properties.get("{http://uri.etsi.org/02231/v2/additionaltypes#}MimeType"));
        pointer.setTerritory(properties.get("{http://uri.etsi.org/02231/v2#}SchemeTerritory"));
    }
}

From source file:eu.europa.ec.markt.dss.report.Tsl2PdfExporter.java

private void printExtension(ExtensionType extension, Document document) throws DocumentException {
    addTitle("Extension (critical: " + extension.isCritical() + ")", title3Font, Paragraph.ALIGN_LEFT, 0, 0,
            document);/*from w ww . j  a  va  2  s. c om*/
    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 (false == ADDITIONAL_SERVICE_INFORMATION_QNAME.equals(element.getName())) {
                continue;
            }
            addTitle("Additional service information", title4Font, Paragraph.ALIGN_LEFT, 0, 0, document);
            AdditionalServiceInformationType additionalServiceInformation = (AdditionalServiceInformationType) element
                    .getValue();
            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 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:net.sf.jabref.importer.fileformat.MedlineImporter.java

private void addPagination(HashMap<String, String> fields, Pagination pagination) {
    String startPage = "";
    String endPage = "";
    for (JAXBElement<String> element : pagination.getContent()) {
        if ("MedlinePgn".equals(element.getName().getLocalPart())) {
            putIfValueNotNull(fields, "pages", fixPageRange(element.getValue()));
        } else if ("StartPage".equals(element.getName().getLocalPart())) {
            //it could happen, that the article has only a start page
            startPage = element.getValue() + endPage;
            putIfValueNotNull(fields, "pages", startPage);
        } else if ("EndPage".equals(element.getName().getLocalPart())) {
            endPage = element.getValue();
            //but it should not happen, that a endpage appears without startpage
            fields.put("pages", fixPageRange(startPage + "-" + endPage));
        }/*from w ww  .  j a va2s  .  c om*/
    }
}

From source file:be.fedict.trust.xkms2.XKMSPortImpl.java

public ValidateResultType validate(ValidateRequestType body) {
    LOG.debug("validate");

    List<X509Certificate> certificateChain = new LinkedList<X509Certificate>();
    String trustDomain = null;/*from w  w  w .j a v a  2 s  . c o  m*/
    boolean returnRevocationData = false;
    Date validationDate = null;
    List<byte[]> ocspResponses = new LinkedList<byte[]>();
    List<byte[]> crls = new LinkedList<byte[]>();
    byte[] timestampToken = null;
    List<byte[]> attributeCertificates = new LinkedList<byte[]>();

    /*
     * Get certification chain from QueryKeyBinding
     */
    QueryKeyBindingType queryKeyBinding = body.getQueryKeyBinding();
    KeyInfoType keyInfo = queryKeyBinding.getKeyInfo();
    List<Object> keyInfoContent = keyInfo.getContent();
    for (Object keyInfoObject : keyInfoContent) {
        JAXBElement<?> keyInfoElement = (JAXBElement<?>) keyInfoObject;
        Object elementValue = keyInfoElement.getValue();
        if (elementValue instanceof X509DataType) {
            X509DataType x509Data = (X509DataType) elementValue;
            List<Object> x509DataContent = x509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName();
            for (Object x509DataObject : x509DataContent) {
                if (!(x509DataObject instanceof JAXBElement)) {
                    continue;
                }
                JAXBElement<?> x509DataElement = (JAXBElement<?>) x509DataObject;
                if (!X509_CERT_QNAME.equals(x509DataElement.getName())) {
                    continue;
                }
                byte[] x509DataValue = (byte[]) x509DataElement.getValue();
                try {
                    X509Certificate certificate = getCertificate(x509DataValue);
                    certificateChain.add(certificate);
                } catch (CertificateException e) {
                    return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
                }
            }
        }
    }

    /*
     * Get optional trust domain name from UseKeyWith
     */
    if (body.getQueryKeyBinding().getUseKeyWith().size() > 0) {
        for (UseKeyWithType useKeyWith : body.getQueryKeyBinding().getUseKeyWith()) {
            if (useKeyWith.getApplication().equals(XKMSConstants.TRUST_DOMAIN_APPLICATION_URI)) {
                trustDomain = useKeyWith.getIdentifier();
                LOG.debug("validate against trust domain " + trustDomain);
            }
        }
    }

    /*
     * Get optional returning of used revocation data from RespondWith
     */
    if (body.getRespondWith().contains(XKMSConstants.RETURN_REVOCATION_DATA_URI)) {
        LOG.debug("will return used revocation data...");
        returnRevocationData = true;
    }

    /*
     * Get optional validation date from TimeInstant field for historical
     * validation
     */
    if (null != body.getQueryKeyBinding().getTimeInstant()) {
        validationDate = getDate(body.getQueryKeyBinding().getTimeInstant().getTime());
    }

    /*
     * Check for message extensions, these can be:
     * 
     * RevocatioDataMessageExtension: historical validation, contains to be
     * used OCSP/CRL data
     * 
     * TSAMessageExtension: TSA validation, contains encoded XAdES timestamp
     * token
     * 
     * AttributeCertificateMessageExtension: Attribute certificate
     * validation, contains XAdES CertifiedRole element containing the
     * encoded Attribute certificate
     */
    for (MessageExtensionAbstractType messageExtension : body.getMessageExtension()) {

        if (messageExtension instanceof RevocationDataMessageExtensionType) {

            RevocationDataMessageExtensionType revocationDataMessageExtension = (RevocationDataMessageExtensionType) messageExtension;
            parseRevocationDataExtension(revocationDataMessageExtension, ocspResponses, crls);

        } else if (messageExtension instanceof TSAMessageExtensionType) {

            TSAMessageExtensionType tsaMessageExtension = (TSAMessageExtensionType) messageExtension;
            timestampToken = parseTSAExtension(tsaMessageExtension);

        } else if (messageExtension instanceof AttributeCertificateMessageExtensionType) {

            AttributeCertificateMessageExtensionType attributeCertificateMessageExtension = (AttributeCertificateMessageExtensionType) messageExtension;
            parseAttributeCertificateExtension(attributeCertificateMessageExtension, attributeCertificates);

        } else {
            LOG.error("invalid message extension: " + messageExtension.getClass().toString());
            return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
        }
    }

    /*
     * Check gathered data
     */
    if (null != validationDate && ocspResponses.isEmpty() && crls.isEmpty()) {

        LOG.error("Historical validation requested but no revocation data provided");
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);

    } else if (null != timestampToken && !certificateChain.isEmpty()) {

        LOG.error("Cannot both add a timestamp token and a seperate certificate chain");
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } else if (!attributeCertificates.isEmpty() && certificateChain.isEmpty()) {

        LOG.error("No certificate chain provided for the attribute certificates");
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);

    } else if (body.getMessageExtension().size() > 1) {

        LOG.error("Only 1 message extension at a time is supported");
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    }

    /*
     * Validate!
     */
    ValidationResult validationResult;
    try {
        if (null != timestampToken) {
            validationResult = this.trustService.validateTimestamp(trustDomain, timestampToken,
                    returnRevocationData);
        } else if (!attributeCertificates.isEmpty()) {
            validationResult = this.trustService.validateAttributeCertificates(trustDomain,
                    attributeCertificates, certificateChain, returnRevocationData);
        } else if (null == validationDate) {
            validationResult = this.trustService.validate(trustDomain, certificateChain, returnRevocationData);
        } else {
            validationResult = this.trustService.validate(trustDomain, certificateChain, validationDate,
                    ocspResponses, crls);
        }
    } catch (TrustDomainNotFoundException e) {
        LOG.error("invalid trust domain");
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.TRUST_DOMAIN_NOT_FOUND);
    } catch (CRLException e) {
        LOG.error("CRLException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (IOException e) {
        LOG.error("IOException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (CertificateException e) {
        LOG.error("CertificateException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (NoSuchProviderException e) {
        LOG.error("NoSuchProviderException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (TSPException e) {
        LOG.error("TSPException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (CMSException e) {
        LOG.error("CMSException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (NoSuchAlgorithmException e) {
        LOG.error("NoSuchAlgorithmException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    } catch (CertStoreException e) {
        LOG.error("CertStoreException: " + e.getMessage(), e);
        return createResultResponse(ResultMajorCode.SENDER, ResultMinorCode.MESSAGE_NOT_SUPPORTED);
    }

    /*
     * Create validation result response
     */
    ValidateResultType validateResult = createResultResponse(ResultMajorCode.SUCCESS, null);

    ObjectFactory objectFactory = new ObjectFactory();
    List<KeyBindingType> keyBindings = validateResult.getKeyBinding();
    KeyBindingType keyBinding = objectFactory.createKeyBindingType();
    keyBindings.add(keyBinding);
    StatusType status = objectFactory.createStatusType();
    keyBinding.setStatus(status);
    String statusValue;
    if (validationResult.isValid()) {
        statusValue = XKMSConstants.KEY_BINDING_STATUS_VALID_URI;
    } else {
        statusValue = XKMSConstants.KEY_BINDING_STATUS_INVALID_URI;
    }
    status.setStatusValue(statusValue);

    /*
     * Add InvalidReason URI's
     */
    if (!validationResult.isValid()) {
        switch (validationResult.getReason()) {
        case INVALID_TRUST: {
            status.getInvalidReason().add(XKMSConstants.KEY_BINDING_REASON_ISSUER_TRUST_URI);
            break;
        }
        case INVALID_REVOCATION_STATUS: {
            status.getInvalidReason().add(XKMSConstants.KEY_BINDING_REASON_REVOCATION_STATUS_URI);
            break;
        }
        case INVALID_SIGNATURE: {
            status.getInvalidReason().add(XKMSConstants.KEY_BINDING_REASON_SIGNATURE_URI);
            break;
        }
        case INVALID_VALIDITY_INTERVAL: {
            status.getInvalidReason().add(XKMSConstants.KEY_BINDING_REASON_VALIDITY_INTERVAL_URI);
            break;
        }
        }
    }

    /*
     * Add used revocation data if requested
     */
    if (returnRevocationData) {
        addRevocationData(validateResult, validationResult.getRevocationData());
    }

    return validateResult;
}

From source file:net.sf.jabref.logic.importer.fileformat.MedlineImporter.java

private void addPagination(Map<String, String> fields, Pagination pagination) {
    String startPage = "";
    String endPage = "";
    for (JAXBElement<String> element : pagination.getContent()) {
        if ("MedlinePgn".equals(element.getName().getLocalPart())) {
            putIfValueNotNull(fields, FieldName.PAGES, fixPageRange(element.getValue()));
        } else if ("StartPage".equals(element.getName().getLocalPart())) {
            //it could happen, that the article has only a start page
            startPage = element.getValue() + endPage;
            putIfValueNotNull(fields, FieldName.PAGES, startPage);
        } else if ("EndPage".equals(element.getName().getLocalPart())) {
            endPage = element.getValue();
            //but it should not happen, that a endpage appears without startpage
            fields.put(FieldName.PAGES, fixPageRange(startPage + "-" + endPage));
        }/*  ww w  .j a  v  a2s  . com*/
    }
}

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

public void addOIDForQCSSCDStatusAsInCert(String oid, String description) {
    TSPServiceInformationType tspServiceInformation = this.tspService.getServiceInformation();
    ExtensionsListType extensionsList = tspServiceInformation.getServiceInformationExtensions();
    if (null == extensionsList) {
        extensionsList = this.objectFactory.createExtensionsListType();
        tspServiceInformation.setServiceInformationExtensions(extensionsList);
    }/*from  w  ww  . ja  v a  2  s.  co m*/
    List<ExtensionType> extensions = extensionsList.getExtension();
    for (ExtensionType extension : extensions) {
        if (false == extension.isCritical()) {
            continue;
        }
        List<Object> extensionContent = extension.getContent();
        for (Object extensionObject : extensionContent) {
            JAXBElement<?> extensionElement = (JAXBElement<?>) extensionObject;
            QName extensionName = extensionElement.getName();
            LOG.debug("extension name: " + extensionName);
            if (qualifiersName.equals(extensionName)) {
                LOG.debug("extension found");
                QualificationsType qualifications = (QualificationsType) extensionElement.getValue();
                List<QualificationElementType> qualificationElements = qualifications.getQualificationElement();
                for (QualificationElementType qualificationElement : qualificationElements) {
                    QualifiersType qualifiers = qualificationElement.getQualifiers();
                    List<QualifierType> qualifierList = qualifiers.getQualifier();
                    boolean qcSscdStatusAsInCertQualifier = false;
                    for (QualifierType qualifier : qualifierList) {
                        if (QC_SSCD_STATUS_AS_IN_CERT_QUALIFIER_URI.equals(qualifier.getUri())) {
                            qcSscdStatusAsInCertQualifier = true;
                        }
                    }
                    if (qcSscdStatusAsInCertQualifier) {
                        CriteriaListType criteriaList = qualificationElement.getCriteriaList();
                        List<PoliciesListType> policySet = criteriaList.getPolicySet();

                        PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType();
                        policySet.add(policiesList);

                        ObjectIdentifierType objectIdentifier = this.xadesObjectFactory
                                .createObjectIdentifierType();
                        IdentifierType identifier = this.xadesObjectFactory.createIdentifierType();
                        identifier.setValue(oid);
                        objectIdentifier.setIdentifier(identifier);
                        if (null != description) {
                            objectIdentifier.setDescription(description);
                        }
                        policiesList.getPolicyIdentifier().add(objectIdentifier);
                        return;
                    }
                }
            }
        }
    }
    ExtensionType extension = this.objectFactory.createExtensionType();
    extension.setCritical(true);
    extensions.add(extension);

    QualificationsType qualifications = this.eccObjectFactory.createQualificationsType();
    extension.getContent().add(this.eccObjectFactory.createQualifications(qualifications));
    List<QualificationElementType> qualificationElements = qualifications.getQualificationElement();

    QualificationElementType qualificationElement = this.eccObjectFactory.createQualificationElementType();
    qualificationElements.add(qualificationElement);

    QualifiersType qualifiers = this.eccObjectFactory.createQualifiersType();
    List<QualifierType> qualifierList = qualifiers.getQualifier();
    QualifierType qcSscdStatusInCertqualifier = this.eccObjectFactory.createQualifierType();
    qualifierList.add(qcSscdStatusInCertqualifier);
    qcSscdStatusInCertqualifier.setUri(QC_SSCD_STATUS_AS_IN_CERT_QUALIFIER_URI);
    qualificationElement.setQualifiers(qualifiers);

    CriteriaListType criteriaList = this.eccObjectFactory.createCriteriaListType();
    qualificationElement.setCriteriaList(criteriaList);
    criteriaList.setAssert("atLeastOne");

    List<PoliciesListType> policySet = criteriaList.getPolicySet();
    PoliciesListType policiesList = this.eccObjectFactory.createPoliciesListType();
    policySet.add(policiesList);
    ObjectIdentifierType objectIdentifier = this.xadesObjectFactory.createObjectIdentifierType();
    IdentifierType identifier = this.xadesObjectFactory.createIdentifierType();
    identifier.setValue(oid);
    objectIdentifier.setDescription(description);
    objectIdentifier.setIdentifier(identifier);
    policiesList.getPolicyIdentifier().add(objectIdentifier);

}