List of usage examples for javax.xml.datatype DatatypeConstants FIELD_UNDEFINED
int FIELD_UNDEFINED
To view the source code for javax.xml.datatype DatatypeConstants FIELD_UNDEFINED.
Click Source Link
From source file:mx.bigdata.sat.cfdi.TFDv11.java
private TimbreFiscalDigital createStamp(UUID uuid, Date date, String PAC, String leyenda) throws DatatypeConfigurationException { ObjectFactory of = new ObjectFactory(); TimbreFiscalDigital tfds = of.createTimbreFiscalDigital(); tfds.setVersion("1.1"); tfds.setUUID(uuid.toString());// w w w . jav a2s.co m Calendar c = Calendar.getInstance(); c.setTime(date); tfds.setFechaTimbrado(DatatypeFactory.newInstance().newXMLGregorianCalendar(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND), DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED)); tfds.setRfcProvCertif(PAC); tfds.setLeyenda(leyenda); tfds.setSelloCFD(document.getSello()); BigInteger bi = cert.getSerialNumber(); tfds.setNoCertificadoSAT(new String(bi.toByteArray())); return tfds; }
From source file:fr.xebia.springframework.jms.support.converter.JaxbMessageConverterTest.java
@Test public void testToMessage() throws Exception { JaxbMessageConverter jaxbMessageConverter = createJaxbMessageConverter(Employee.class, Gender.class); Employee employee = new Employee(1, "Cyrille", "Le Clerc", Gender.MALE, DatatypeFactory.newInstance() .newXMLGregorianCalendarDate(1976, 01, 05, DatatypeConstants.FIELD_UNDEFINED)); TextMessage actualMessage = (TextMessage) jaxbMessageConverter.toMessage(employee, session); String actual = actualMessage.getText(); String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<Employee>" + "<id>1</id>" + "<lastName>Le Clerc</lastName>" + "<firstName>Cyrille</firstName>" + "<gender>MALE</gender>" + "<birthdate>1976-01-05</birthdate>" + "</Employee>"; Assert.assertEquals(expected, actual); }
From source file:mx.bigdata.sat.cfdi.TFDv11c33.java
private TimbreFiscalDigital createStamp(UUID uuid, Date date, String PAC, String leyenda) throws DatatypeConfigurationException { Calendar c = Calendar.getInstance(); c.setTime(date);/* w w w . ja va2s. com*/ ObjectFactory of = new ObjectFactory(); TimbreFiscalDigital tfds = of.createTimbreFiscalDigital(); tfds.setVersion("1.1"); tfds.setUUID(uuid.toString()); tfds.setFechaTimbrado(DatatypeFactory.newInstance().newXMLGregorianCalendar(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE), c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND), DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED)); tfds.setRfcProvCertif(PAC); tfds.setLeyenda(leyenda); tfds.setSelloCFD(document.getSello()); BigInteger bi = cert.getSerialNumber(); tfds.setNoCertificadoSAT(new String(bi.toByteArray())); return tfds; }
From source file:ca.phon.session.io.xml.v12.XMLSessionWriter_v12.java
/** * copy participant info/*from w w w.j a v a 2s. co m*/ */ private ParticipantType copyParticipant(ObjectFactory factory, Participant part) { final ParticipantType retVal = factory.createParticipantType(); if (part.getId() != null) retVal.setId(part.getId()); retVal.setName(part.getName()); final LocalDate bday = part.getBirthDate(); if (bday != null) { try { final DatatypeFactory df = DatatypeFactory.newInstance(); final XMLGregorianCalendar cal = df .newXMLGregorianCalendar(GregorianCalendar.from(bday.atStartOfDay(ZoneId.systemDefault()))); cal.setTimezone(DatatypeConstants.FIELD_UNDEFINED); retVal.setBirthday(cal); } catch (DatatypeConfigurationException e) { LOGGER.log(Level.WARNING, e.toString(), e); } } final Period age = part.getAge(null); if (age != null) { try { final DatatypeFactory df = DatatypeFactory.newInstance(); final Duration ageDuration = df.newDuration(true, age.getYears(), age.getMonths(), age.getDays(), 0, 0, 0); retVal.setAge(ageDuration); } catch (DatatypeConfigurationException e) { LOGGER.log(Level.WARNING, e.toString(), e); } } retVal.setEducation(part.getEducation()); retVal.setGroup(part.getGroup()); final String lang = part.getLanguage(); final String langs[] = (lang != null ? lang.split(",") : new String[0]); for (String l : langs) { retVal.getLanguage().add(StringUtils.strip(l)); } if (part.getSex() == Sex.MALE) retVal.setSex(SexType.MALE); else if (part.getSex() == Sex.FEMALE) retVal.setSex(SexType.FEMALE); ParticipantRole prole = part.getRole(); if (prole == null) prole = ParticipantRole.TARGET_CHILD; retVal.setRole(prole.toString()); // create ID based on role if possible if (retVal.getId() == null && prole != null) { if (prole == ParticipantRole.TARGET_CHILD) { retVal.setId("CHI"); } else if (prole == ParticipantRole.MOTHER) { retVal.setId("MOT"); } else if (prole == ParticipantRole.FATHER) { retVal.setId("FAT"); } else if (prole == ParticipantRole.INTERVIEWER) { retVal.setId("INT"); } else { retVal.setId("p" + (++pIdx)); } } retVal.setSES(part.getSES()); return retVal; }
From source file:no.uis.service.ws.studinfosolr.impl.StudinfoSolrServiceImpl.java
private XMLGregorianCalendar createXmlCalendar(Integer year, Integer month, Integer day) { int y = year != null ? year.intValue() : DatatypeConstants.FIELD_UNDEFINED; int m = month != null ? month.intValue() : DatatypeConstants.FIELD_UNDEFINED; int d = day != null ? day.intValue() : DatatypeConstants.FIELD_UNDEFINED; return getDatatypeFactory().newXMLGregorianCalendarDate(y, m, d, DatatypeConstants.FIELD_UNDEFINED); }
From source file:eu.europa.ec.markt.dss.signature.xades.XAdESProfileBES.java
protected QualifyingPropertiesType createXAdESQualifyingProperties(SignatureParameters params, String signedInfoId, List<Reference> documentReferences, Document document) { // QualifyingProperties QualifyingPropertiesType qualifyingProperties = xades13ObjectFactory.createQualifyingPropertiesType(); SignedPropertiesType signedProperties = xades13ObjectFactory.createSignedPropertiesType(); qualifyingProperties.setSignedProperties(signedProperties); signedProperties.setId(signedInfoId); SignedSignaturePropertiesType signedSignatureProperties = xades13ObjectFactory .createSignedSignaturePropertiesType(); signedProperties.setSignedSignatureProperties(signedSignatureProperties); // SigningTime GregorianCalendar signingTime = new GregorianCalendar(TimeZone.getTimeZone("Z")); signingTime.setTime(params.getSigningDate()); XMLGregorianCalendar xmlGregorianCalendar = getDataFactory().newXMLGregorianCalendar(signingTime); xmlGregorianCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED); signedSignatureProperties.setSigningTime(xmlGregorianCalendar); X509Certificate signingCertificate = params.getSigningCertificate(); CertIDType signingCertificateId = getCertID(signingCertificate); CertIDListType signingCertificates = xades13ObjectFactory.createCertIDListType(); signingCertificates.getCert().add(signingCertificateId); signedSignatureProperties.setSigningCertificate(signingCertificates); // DataObjectProperties SignedDataObjectPropertiesType dataObjectProperties = new SignedDataObjectPropertiesType(); Iterator<Reference> refIt = documentReferences.iterator(); Iterator<Document> docIt = documentIterator(document); while (refIt.hasNext() && docIt.hasNext()) { Reference ref = refIt.next(); Document doc = docIt.next(); if (ref.getId() != null && doc.getMimeType() != null) { DataObjectFormatType dataFormat = new DataObjectFormatType(); dataFormat.setObjectReference("#" + ref.getId()); dataFormat.setMimeType(doc.getMimeType().getCode()); dataObjectProperties.getDataObjectFormat().add(dataFormat); }/*from www .j a va2 s. c o m*/ } if (dataObjectProperties.getDataObjectFormat().size() > 0) { signedProperties.setSignedDataObjectProperties(dataObjectProperties); } // SignerRole if (params.getClaimedSignerRole() != null) { SignerRoleType signerRole = xades13ObjectFactory.createSignerRoleType(); ClaimedRolesListType claimedRoles = xades13ObjectFactory.createClaimedRolesListType(); /* * Add only one role */ AnyType role = xades13ObjectFactory.createAnyType(); role.getContent().add(params.getClaimedSignerRole()); claimedRoles.getClaimedRole().add(role); signerRole.setClaimedRoles(claimedRoles); signedSignatureProperties.setSignerRole(signerRole); } return qualifyingProperties; }
From source file:be.fedict.eid.applet.service.signer.facets.XAdESSignatureFacet.java
public void preSign(XMLSignatureFactory signatureFactory, Document document, String signatureId, List<X509Certificate> signingCertificateChain, List<Reference> references, List<XMLObject> objects) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { LOG.debug("preSign"); // QualifyingProperties QualifyingPropertiesType qualifyingProperties = this.xadesObjectFactory.createQualifyingPropertiesType(); qualifyingProperties.setTarget("#" + signatureId); // SignedProperties SignedPropertiesType signedProperties = this.xadesObjectFactory.createSignedPropertiesType(); String signedPropertiesId;/* w w w . jav a 2s . c om*/ if (null != this.idSignedProperties) { signedPropertiesId = this.idSignedProperties; } else { signedPropertiesId = signatureId + "-xades"; } signedProperties.setId(signedPropertiesId); qualifyingProperties.setSignedProperties(signedProperties); // SignedSignatureProperties SignedSignaturePropertiesType signedSignatureProperties = this.xadesObjectFactory .createSignedSignaturePropertiesType(); signedProperties.setSignedSignatureProperties(signedSignatureProperties); // SigningTime GregorianCalendar signingTime = new GregorianCalendar(TimeZone.getTimeZone("Z")); Date currentClockValue = this.clock.getTime(); signingTime.setTime(currentClockValue); XMLGregorianCalendar xmlGregorianCalendar = this.datatypeFactory.newXMLGregorianCalendar(signingTime); xmlGregorianCalendar.setMillisecond(DatatypeConstants.FIELD_UNDEFINED); signedSignatureProperties.setSigningTime(xmlGregorianCalendar); // SigningCertificate if (null == signingCertificateChain || signingCertificateChain.isEmpty()) { throw new RuntimeException("no signing certificate chain available"); } X509Certificate signingCertificate = signingCertificateChain.get(0); CertIDType signingCertificateId = getCertID(signingCertificate, this.xadesObjectFactory, this.xmldsigObjectFactory, this.digestAlgorithm, this.issuerNameNoReverseOrder); CertIDListType signingCertificates = this.xadesObjectFactory.createCertIDListType(); signingCertificates.getCert().add(signingCertificateId); signedSignatureProperties.setSigningCertificate(signingCertificates); // ClaimedRole if (null != this.role && false == this.role.isEmpty()) { SignerRoleType signerRole = this.xadesObjectFactory.createSignerRoleType(); signedSignatureProperties.setSignerRole(signerRole); ClaimedRolesListType claimedRolesList = this.xadesObjectFactory.createClaimedRolesListType(); signerRole.setClaimedRoles(claimedRolesList); AnyType claimedRole = this.xadesObjectFactory.createAnyType(); claimedRole.getContent().add(this.role); claimedRolesList.getClaimedRole().add(claimedRole); } // XAdES-EPES if (null != this.signaturePolicyService) { SignaturePolicyIdentifierType signaturePolicyIdentifier = this.xadesObjectFactory .createSignaturePolicyIdentifierType(); signedSignatureProperties.setSignaturePolicyIdentifier(signaturePolicyIdentifier); SignaturePolicyIdType signaturePolicyId = this.xadesObjectFactory.createSignaturePolicyIdType(); signaturePolicyIdentifier.setSignaturePolicyId(signaturePolicyId); ObjectIdentifierType objectIdentifier = this.xadesObjectFactory.createObjectIdentifierType(); signaturePolicyId.setSigPolicyId(objectIdentifier); IdentifierType identifier = this.xadesObjectFactory.createIdentifierType(); objectIdentifier.setIdentifier(identifier); identifier.setValue(this.signaturePolicyService.getSignaturePolicyIdentifier()); objectIdentifier.setDescription(this.signaturePolicyService.getSignaturePolicyDescription()); byte[] signaturePolicyDocumentData = this.signaturePolicyService.getSignaturePolicyDocument(); DigestAlgAndValueType sigPolicyHash = getDigestAlgAndValue(signaturePolicyDocumentData, this.xadesObjectFactory, this.xmldsigObjectFactory, this.digestAlgorithm); signaturePolicyId.setSigPolicyHash(sigPolicyHash); String signaturePolicyDownloadUrl = this.signaturePolicyService.getSignaturePolicyDownloadUrl(); if (null != signaturePolicyDownloadUrl) { SigPolicyQualifiersListType sigPolicyQualifiers = this.xadesObjectFactory .createSigPolicyQualifiersListType(); signaturePolicyId.setSigPolicyQualifiers(sigPolicyQualifiers); AnyType sigPolicyQualifier = this.xadesObjectFactory.createAnyType(); sigPolicyQualifiers.getSigPolicyQualifier().add(sigPolicyQualifier); JAXBElement<String> spUriElement = this.xadesObjectFactory.createSPURI(signaturePolicyDownloadUrl); sigPolicyQualifier.getContent().add(spUriElement); } } else if (this.signaturePolicyImplied) { SignaturePolicyIdentifierType signaturePolicyIdentifier = this.xadesObjectFactory .createSignaturePolicyIdentifierType(); signedSignatureProperties.setSignaturePolicyIdentifier(signaturePolicyIdentifier); signaturePolicyIdentifier.setSignaturePolicyImplied(""); } // DataObjectFormat if (false == this.dataObjectFormatMimeTypes.isEmpty()) { SignedDataObjectPropertiesType signedDataObjectProperties = this.xadesObjectFactory .createSignedDataObjectPropertiesType(); signedProperties.setSignedDataObjectProperties(signedDataObjectProperties); List<DataObjectFormatType> dataObjectFormats = signedDataObjectProperties.getDataObjectFormat(); for (Map.Entry<String, String> dataObjectFormatMimeType : this.dataObjectFormatMimeTypes.entrySet()) { DataObjectFormatType dataObjectFormat = this.xadesObjectFactory.createDataObjectFormatType(); dataObjectFormat.setObjectReference("#" + dataObjectFormatMimeType.getKey()); dataObjectFormat.setMimeType(dataObjectFormatMimeType.getValue()); dataObjectFormats.add(dataObjectFormat); } } // marshall XAdES QualifyingProperties Node qualifyingPropertiesNode = marshallQualifyingProperties(document, this.xadesObjectFactory, qualifyingProperties); // add XAdES ds:Object List<XMLStructure> xadesObjectContent = new LinkedList<XMLStructure>(); xadesObjectContent.add(new DOMStructure(qualifyingPropertiesNode)); XMLObject xadesObject = signatureFactory.newXMLObject(xadesObjectContent, null, null, null); objects.add(xadesObject); // add XAdES ds:Reference DigestMethod digestMethod = signatureFactory.newDigestMethod(digestAlgorithm.getXmlAlgoId(), null); List<Transform> transforms = new LinkedList<Transform>(); Transform exclusiveTransform = signatureFactory.newTransform(CanonicalizationMethod.INCLUSIVE, (TransformParameterSpec) null); transforms.add(exclusiveTransform); Reference reference = signatureFactory.newReference("#" + signedPropertiesId, digestMethod, transforms, XADES_TYPE, null); references.add(reference); }
From source file:gov.nih.nci.cabig.caaers.api.ResearchStaffMigratorServiceTest.java
private void modifyDates(gov.nih.nci.cabig.caaers.integration.schema.researchstaff.Staff staff) throws Exception { DatatypeFactory df = DatatypeFactory.newInstance(); Calendar gcNow = GregorianCalendar.getInstance(); int year = gcNow.get(Calendar.YEAR); int month = gcNow.get(Calendar.MONTH) + 1; int day = gcNow.get(Calendar.DAY_OF_MONTH); int tz = DatatypeConstants.FIELD_UNDEFINED; XMLGregorianCalendar currXmlCal = df.newXMLGregorianCalendarDate(year, month, day, tz); XMLGregorianCalendar furXmlCal = df.newXMLGregorianCalendarDate(year + 1, month, day, tz); List<ResearchStaffType> researchStaffList = staff.getResearchStaff(); List<SiteResearchStaffType> siteRsTypeList; List<SiteResearchStaffRoleType> siteRsRoleTypeList; for (ResearchStaffType researchStaffType : researchStaffList) { siteRsTypeList = researchStaffType.getSiteResearchStaffs().getSiteResearchStaff(); for (SiteResearchStaffType sRsType : siteRsTypeList) { siteRsRoleTypeList = sRsType.getSiteResearchStaffRoles().getSiteResearchStaffRole(); for (SiteResearchStaffRoleType sRsRoleType : siteRsRoleTypeList) { sRsRoleType.setStartDate(currXmlCal); sRsRoleType.setEndDate(furXmlCal); }//from w w w . j a va 2 s . c om } } }
From source file:be.fedict.eid.tsl.TrustServiceList.java
public void addXadesBes(XMLSignatureFactory signatureFactory, Document document, String signatureId, X509Certificate signingCertificate, List<Reference> references, List<XMLObject> objects) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { LOG.debug("preSign"); // QualifyingProperties QualifyingPropertiesType qualifyingProperties = this.xadesObjectFactory.createQualifyingPropertiesType(); qualifyingProperties.setTarget("#" + signatureId); // SignedProperties SignedPropertiesType signedProperties = this.xadesObjectFactory.createSignedPropertiesType(); String signedPropertiesId = signatureId + "-xades"; signedProperties.setId(signedPropertiesId); qualifyingProperties.setSignedProperties(signedProperties); // SignedSignatureProperties SignedSignaturePropertiesType signedSignatureProperties = this.xadesObjectFactory .createSignedSignaturePropertiesType(); signedProperties.setSignedSignatureProperties(signedSignatureProperties); // SigningTime GregorianCalendar signingTime = new GregorianCalendar(); signingTime.setTimeZone(TimeZone.getTimeZone("Z")); XMLGregorianCalendar xmlSigningTime = this.datatypeFactory.newXMLGregorianCalendar(signingTime); xmlSigningTime.setMillisecond(DatatypeConstants.FIELD_UNDEFINED); signedSignatureProperties.setSigningTime(xmlSigningTime); // SigningCertificate CertIDListType signingCertificates = this.xadesObjectFactory.createCertIDListType(); CertIDType signingCertificateId = this.xadesObjectFactory.createCertIDType(); X509IssuerSerialType issuerSerial = this.xmldsigObjectFactory.createX509IssuerSerialType(); issuerSerial.setX509IssuerName(signingCertificate.getIssuerX500Principal().toString()); issuerSerial.setX509SerialNumber(signingCertificate.getSerialNumber()); signingCertificateId.setIssuerSerial(issuerSerial); DigestAlgAndValueType certDigest = this.xadesObjectFactory.createDigestAlgAndValueType(); DigestMethodType jaxbDigestMethod = this.xmldsigObjectFactory.createDigestMethodType(); jaxbDigestMethod.setAlgorithm(DigestMethod.SHA256); certDigest.setDigestMethod(jaxbDigestMethod); MessageDigest messageDigest = MessageDigest.getInstance("SHA-256"); byte[] digestValue; try {//from w w w .j a v a 2 s.c o m digestValue = messageDigest.digest(signingCertificate.getEncoded()); } catch (CertificateEncodingException e) { throw new RuntimeException("certificate encoding error: " + e.getMessage(), e); } certDigest.setDigestValue(digestValue); signingCertificateId.setCertDigest(certDigest); signingCertificates.getCert().add(signingCertificateId); signedSignatureProperties.setSigningCertificate(signingCertificates); // marshall XAdES QualifyingProperties Node qualifyingPropertiesNode = marshallQualifyingProperties(document, qualifyingProperties); // add XAdES ds:Object List<XMLStructure> xadesObjectContent = new LinkedList<XMLStructure>(); xadesObjectContent.add(new DOMStructure(qualifyingPropertiesNode)); XMLObject xadesObject = signatureFactory.newXMLObject(xadesObjectContent, null, null, null); objects.add(xadesObject); // add XAdES ds:Reference DigestMethod digestMethod = signatureFactory.newDigestMethod(DigestMethod.SHA256, null); List<Transform> transforms = new LinkedList<Transform>(); Transform exclusiveTransform = signatureFactory.newTransform(CanonicalizationMethod.EXCLUSIVE, (TransformParameterSpec) null); transforms.add(exclusiveTransform); Reference reference = signatureFactory.newReference("#" + signedPropertiesId, digestMethod, transforms, XADES_TYPE, null); references.add(reference); }
From source file:com.ccserver.digital.service.LOSService.java
private XMLGregorianCalendar dateToXMLGregorianCalendar(Date date) { if (date == null) { return null; }/* w ww .ja va2s . c om*/ try { GregorianCalendar gregory = new GregorianCalendar(); gregory.setTime(date); return DatatypeFactory.newInstance() .newXMLGregorianCalendarDate(gregory.get(Calendar.YEAR), gregory.get(Calendar.MONTH) + 1, gregory.get(Calendar.DAY_OF_MONTH), DatatypeConstants.FIELD_UNDEFINED) .normalize(); } catch (DatatypeConfigurationException e) { logger.error(Utils.getErrorFormatLog("LOSService", "dateToXMLGregorianCalendar", "", "Can not convert from LocalDateTime to XMLGregorianCalenda", e.toString())); } return null; }