Example usage for org.joda.time DateTime DateTime

List of usage examples for org.joda.time DateTime DateTime

Introduction

In this page you can find the example usage for org.joda.time DateTime DateTime.

Prototype

public DateTime(int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute,
        int millisOfSecond, Chronology chronology) 

Source Link

Document

Constructs an instance from datetime field values using the specified chronology.

Usage

From source file:arjdbc.util.DateTimeUtils.java

License:Open Source License

@SuppressWarnings("deprecation")
public static IRubyObject newTime(final ThreadContext context, final Time time) {
    //if ( time == null ) return context.nil;
    final int hours = time.getHours();
    final int minutes = time.getMinutes();
    final int seconds = time.getSeconds();
    //final int offset = time.getTimezoneOffset();

    final DateTime dateTime;
    if (isDefaultTimeZoneUTC(context)) {
        dateTime = new DateTime(2000, 1, 1, hours, minutes, seconds, 0, DateTimeZone.UTC);
    } else {/*from  w  w  w.  j  av a2 s.  c  o m*/
        dateTime = new DateTime(2000, 1, 1, hours, minutes, seconds, 0);
    }
    return RubyTime.newTime(context.runtime, dateTime);
}

From source file:arjdbc.util.DateTimeUtils.java

License:Open Source License

@SuppressWarnings("deprecation")
public static IRubyObject newTime(final ThreadContext context, final Timestamp timestamp) {
    //if ( time == null ) return context.nil;

    final int year = timestamp.getYear() + 1900;
    final int month = timestamp.getMonth() + 1;
    final int day = timestamp.getDate();
    final int hours = timestamp.getHours();
    final int minutes = timestamp.getMinutes();
    final int seconds = timestamp.getSeconds();
    final int nanos = timestamp.getNanos(); // max 999-999-999

    final DateTime dateTime;
    if (isDefaultTimeZoneUTC(context)) {
        dateTime = new DateTime(year, month, day, hours, minutes, seconds, 0, DateTimeZone.UTC);
    } else {//from ww w.  ja v a  2  s .com
        dateTime = new DateTime(year, month, day, hours, minutes, seconds, 0);
    }
    return RubyTime.newTime(context.runtime, dateTime, nanos);
}

From source file:arjdbc.util.DateTimeUtils.java

License:Open Source License

public static RubyTime parseDateTime(final ThreadContext context, final String str)
        throws IllegalArgumentException {

    boolean hasDate = false;
    int year = 2000;
    int month = 1;
    int day = 1;/*www  . j a  v a 2s  .c  o m*/
    boolean hasTime = false;
    int minute = 0;
    int hour = 0;
    int second = 0;
    int millis = 0;
    long nanos = 0;

    DateTimeZone zone = null;
    boolean bcEra = false;

    // We try to parse these fields in order; all are optional
    // (but some combinations don't make sense, e.g. if you have
    //  both date and time then they must be whitespace-separated).
    // At least one of date and time must be present.

    //   leading whitespace
    //   yyyy-mm-dd
    //   whitespace
    //   hh:mm:ss
    //   whitespace
    //   timezone in one of the formats:  +hh, -hh, +hh:mm, -hh:mm
    //   whitespace
    //   if date is present, an era specifier: AD or BC
    //   trailing whitespace

    final int len = str.length();

    int start = nonSpaceIndex(str, 0, len); // Skip leading whitespace
    int end = nonDigitIndex(str, start, len);

    // Possibly read date.
    if (end < len && str.charAt(end) == '-') {
        hasDate = true;

        // year
        year = extractIntValue(str, start, end);
        start = end + 1; // Skip '-'

        // month
        end = nonDigitIndex(str, start, len);
        month = extractIntValue(str, start, end);

        char sep = str.charAt(end);
        if (sep != '-') {
            throw new IllegalArgumentException("expected date to be dash-separated, got '" + sep + "'");
        }

        start = end + 1; // Skip '-'

        // day of month
        end = nonDigitIndex(str, start, len);
        day = extractIntValue(str, start, end);

        start = nonSpaceIndex(str, end, len); // Skip trailing whitespace
    }

    // Possibly read time.
    if (start < len && Character.isDigit(str.charAt(start))) {
        hasTime = true;

        // hours
        end = nonDigitIndex(str, start, len);
        hour = extractIntValue(str, start, end);

        //sep = str.charAt(end);
        //if ( sep != ':' ) {
        //    throw new IllegalArgumentException("expected time to be colon-separated, got '" + sep + "'");
        //}

        start = end + 1; // Skip ':'

        // minutes
        end = nonDigitIndex(str, start, len);
        minute = extractIntValue(str, start, end);

        //sep = str.charAt(end);
        //if ( sep != ':' ) {
        //    throw new IllegalArgumentException("expected time to be colon-separated, got '" + sep + "'");
        //}

        start = end + 1; // Skip ':'

        // seconds
        end = nonDigitIndex(str, start, len);
        second = extractIntValue(str, start, end);
        start = end;

        // Fractional seconds.
        if (start < len && str.charAt(start) == '.') {
            end = nonDigitIndex(str, start + 1, len); // Skip '.'
            int numlen = end - (start + 1);
            if (numlen <= 3) {
                millis = extractIntValue(str, start + 1, end);
                for (; numlen < 3; ++numlen)
                    millis *= 10;
            } else {
                nanos = extractIntValue(str, start + 1, end);
                for (; numlen < 9; ++numlen)
                    nanos *= 10;
            }

            start = end;
        }

        start = nonSpaceIndex(str, start, len); // Skip trailing whitespace
    }

    // Possibly read timezone.
    char sep = start < len ? str.charAt(start) : '\0';
    if (sep == '+' || sep == '-') {
        int zoneSign = (sep == '-') ? -1 : 1;
        int hoursOffset, minutesOffset, secondsOffset;

        end = nonDigitIndex(str, start + 1, len); // Skip +/-
        hoursOffset = extractIntValue(str, start + 1, end);
        start = end;

        if (start < len && str.charAt(start) == ':') {
            end = nonDigitIndex(str, start + 1, len); // Skip ':'
            minutesOffset = extractIntValue(str, start + 1, end);
            start = end;
        } else {
            minutesOffset = 0;
        }

        secondsOffset = 0;
        if (start < len && str.charAt(start) == ':') {
            end = nonDigitIndex(str, start + 1, len); // Skip ':'
            secondsOffset = extractIntValue(str, start + 1, end);
            start = end;
        }

        // Setting offset does not seem to work correctly in all
        // cases.. So get a fresh calendar for a synthetic timezone
        // instead

        int offset = zoneSign * hoursOffset * 60;
        if (offset < 0) {
            offset = offset - Math.abs(minutesOffset);
        } else {
            offset = offset + minutesOffset;
        }
        offset = (offset * 60 + secondsOffset) * 1000;
        zone = DateTimeZone.forOffsetMillis(offset);

        start = nonSpaceIndex(str, start, len); // Skip trailing whitespace
    }

    if (hasDate && start < len) {
        final char e1 = str.charAt(start);
        if (e1 == 'A' && str.charAt(start + 1) == 'D') {
            bcEra = false;
            start += 2;
        } else if (e1 == 'B' && str.charAt(start + 1) == 'C') {
            bcEra = true;
            start += 2;
        }
    }

    if (start < len) {
        throw new IllegalArgumentException(
                "trailing junk: '" + str.substring(start, len - start) + "' on '" + str + "'");
    }
    if (!hasTime && !hasDate) {
        throw new IllegalArgumentException("'" + str + "' has neither date nor time");
    }

    if (bcEra)
        year = -1 * year;

    if (zone == null) {
        zone = isDefaultTimeZoneUTC(context) ? DateTimeZone.UTC : DateTimeZone.getDefault();
    }

    DateTime dateTime = new DateTime(year, month, day, hour, minute, second, millis, zone);
    return RubyTime.newTime(context.runtime, dateTime, nanos);
}

From source file:be.fedict.eid.idp.common.saml2.Saml2Util.java

License:Open Source License

@SuppressWarnings("unchecked")
private static Attribute getAttribute(String attributeName, GregorianCalendar attributeValue) {

    Attribute attribute = buildXMLObject(Attribute.class, Attribute.DEFAULT_ELEMENT_NAME);
    attribute.setName(attributeName);/*w w w .j  a v a2s  .c om*/

    XMLObjectBuilder<XSDateTime> builder = Configuration.getBuilderFactory().getBuilder(XSDateTime.TYPE_NAME);
    XSDateTime xmlAttributeValue = builder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME,
            XSDateTime.TYPE_NAME);

    // convert to Zulu timezone
    int day = attributeValue.get(Calendar.DAY_OF_MONTH);
    int month = attributeValue.get(Calendar.MONTH);
    int year = attributeValue.get(Calendar.YEAR);
    LOG.debug("day: " + day + " month: " + month + " year: " + year);
    DateTime zulu = new DateTime(year, month + 1, day, 0, 0, 0, 0, ISOChronology.getInstanceUTC());
    xmlAttributeValue.setValue(zulu);
    attribute.getAttributeValues().add(xmlAttributeValue);

    LOG.debug("XmlAttributeValue: " + xmlAttributeValue.getValue());

    return attribute;
}

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

License:Open Source License

/**
 * Creates a new instance of a trust service list for Belgium according to
 * the given time frame./*from  www  . ja  v a2  s .  c  o  m*/
 * 
 * @param year
 *            the year for which the TSL should be valid.
 * @param trimester
 *            the trimester for which the TSL should be valid.
 * @return the trust service list object.
 */
public static TrustServiceList newInstance(int year, Trimester trimester) {
    if (2010 != year && 2011 != year && 2012 != year && 2013 != year && 2014 != year && 2015 != year) {
        throw new IllegalArgumentException(
                "cannot create a TSL for year (NEW): " + year + " trimester " + trimester);
    }

    BigInteger tslSequenceNumber;
    DateTime listIssueDateTime;
    Document euTSLDocument;
    X509Certificate euSSLCertificate = null;

    // setup
    TrustServiceList trustServiceList = TrustServiceListFactory.newInstance();
    setupTSL(trustServiceList);

    // trust service provider list: certipost
    LOG.debug("Create TSP: Certipost");
    TrustServiceProvider certipostTrustServiceProvider = createTSP_certipost();
    LOG.debug("Add TSP_certipost to Trustlist");
    trustServiceList.addTrustServiceProvider(certipostTrustServiceProvider);

    // Certipost trust services: Root CA and Root CA2
    LOG.debug("Add Trustservice BRCA1 to TSP_Certipost");
    certipostTrustServiceProvider.addTrustService(createTSPService_BRCA1());
    LOG.debug("Add Trustservice BRCA2 to TSP_Certipost");
    certipostTrustServiceProvider.addTrustService(createTSPService_BRCA2());

    if (2010 == year) {
        switch (trimester) {
        case FIRST:
            tslSequenceNumber = BigInteger.valueOf(1);
            listIssueDateTime = new DateTime(2010, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp.xml");
            break;
        case SECOND:
            tslSequenceNumber = BigInteger.valueOf(2);
            listIssueDateTime = new DateTime(2010, 5, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            break;
        case THIRD:
            tslSequenceNumber = BigInteger.valueOf(3);
            listIssueDateTime = new DateTime(2010, 9, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            break;
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else if (2011 == year) {
        // year == 2011
        switch (trimester) {
        case FIRST:
            tslSequenceNumber = BigInteger.valueOf(4);
            listIssueDateTime = new DateTime(2011, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");
            break;
        case SECOND:
            tslSequenceNumber = BigInteger.valueOf(5);
            listIssueDateTime = new DateTime(2011, 5, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");
            break;
        case THIRD:
            tslSequenceNumber = BigInteger.valueOf(6);
            listIssueDateTime = new DateTime(2011, 9, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");
            break;
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else if (2012 == year) {
        // year == 2012
        switch (trimester) {
        case FIRST:
            tslSequenceNumber = BigInteger.valueOf(7);
            listIssueDateTime = new DateTime(2012, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-2.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");
            break;
        case SECOND: {
            tslSequenceNumber = BigInteger.valueOf(8);
            listIssueDateTime = new DateTime(2012, 5, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);
            break;
        }
        case THIRD: {
            tslSequenceNumber = BigInteger.valueOf(9);
            listIssueDateTime = new DateTime(2012, 9, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);
            break;
        }
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else if (2013 == year) {
        switch (trimester) {
        case FIRST: {
            tslSequenceNumber = BigInteger.valueOf(10);
            listIssueDateTime = new DateTime(2013, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);
            break;
        }
        case SECOND: {
            tslSequenceNumber = BigInteger.valueOf(11);
            listIssueDateTime = new DateTime(2013, 5, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.der");

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);
            break;
        }
        case THIRD: {
            tslSequenceNumber = BigInteger.valueOf(12);
            listIssueDateTime = new DateTime(2013, 9, 1, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());

            break;
        }
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else if (2014 == year) {
        switch (trimester) {
        case FIRST: {
            tslSequenceNumber = BigInteger.valueOf(16);
            listIssueDateTime = new DateTime(2014, 2, 14, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());
            break;
        }
        case SECOND: {
            tslSequenceNumber = BigInteger.valueOf(17);
            listIssueDateTime = new DateTime(2014, 6, 20, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());
            break;
        }
        case THIRD: {
            tslSequenceNumber = BigInteger.valueOf(19);
            listIssueDateTime = new DateTime(2014, 10, 9, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());

            //Quovadis
            LOG.debug("Create TSP Qua Vadis");
            TrustServiceProvider quovadisTrustServiceProvider = createTSP_Quovadis();
            LOG.debug("Add TSP_QuoVadis to Trustlist");
            trustServiceList.addTrustServiceProvider(quovadisTrustServiceProvider);
            LOG.debug("Add QuoVadis BE PKI CertificationAuthority");
            quovadisTrustServiceProvider
                    .addTrustService(createTSPService_QuoVadisBEPKICertificationAuthority());

            break;
        }
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else if (2015 == year) {
        switch (trimester) {
        case FIRST: {
            tslSequenceNumber = BigInteger.valueOf(20);
            listIssueDateTime = new DateTime(2015, 2, 19, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());

            //Quovadis
            LOG.debug("Create TSP Qua Vadis");
            TrustServiceProvider quovadisTrustServiceProvider = createTSP_Quovadis();
            LOG.debug("Add TSP_QuoVadis to Trustlist");
            trustServiceList.addTrustServiceProvider(quovadisTrustServiceProvider);
            LOG.debug("Add QuoVadis BE PKI CertificationAuthority");
            quovadisTrustServiceProvider
                    .addTrustService(createTSPService_QuoVadisBEPKICertificationAuthority());

            break;
        }
        case SECOND: {
            tslSequenceNumber = BigInteger.valueOf(21);
            listIssueDateTime = new DateTime(2015, 6, 25, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());

            //Quovadis
            LOG.debug("Create TSP Qua Vadis");
            TrustServiceProvider quovadisTrustServiceProvider = createTSP_Quovadis();
            LOG.debug("Add TSP_QuoVadis to Trustlist");
            trustServiceList.addTrustServiceProvider(quovadisTrustServiceProvider);
            LOG.debug("Add QuoVadis BE PKI CertificationAuthority");
            quovadisTrustServiceProvider
                    .addTrustService(createTSPService_QuoVadisBEPKICertificationAuthority());

            break;
        }
        case THIRD: {
            tslSequenceNumber = BigInteger.valueOf(22);
            listIssueDateTime = new DateTime(2015, 11, 5, 0, 0, 0, 0, DateTimeZone.UTC);
            euTSLDocument = loadDocumentFromResource("eu/tl-mp-33.xml");
            euSSLCertificate = loadCertificateFromResource("eu/ec.europa.eu.2013-2015.der");

            // BRCA 3 en BRCA 4
            LOG.debug("Add Trustservice BRCA3 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA3());
            LOG.debug("Add Trustservice BRCA4 to TSP_Certipost");
            certipostTrustServiceProvider.addTrustService(createTSPService_BRCA4());

            createTSPService_AdditionelServices_Certipost(certipostTrustServiceProvider);

            // SWIFT
            LOG.debug("Create TSP: Swift");
            TrustServiceProvider swiftTrustServiceProvider = createTSP_swift();
            LOG.debug("Add TSP_swift to Trustlist");
            trustServiceList.addTrustServiceProvider(swiftTrustServiceProvider);
            LOG.debug("Add Trustservice SwiftNetPKI to TSP_Swift");
            swiftTrustServiceProvider.addTrustService(createTSPService_SWIFTNetPKI());

            //Quovadis
            LOG.debug("Create TSP Qua Vadis");
            TrustServiceProvider quovadisTrustServiceProvider = createTSP_Quovadis();
            LOG.debug("Add TSP_QuoVadis to Trustlist");
            trustServiceList.addTrustServiceProvider(quovadisTrustServiceProvider);
            LOG.debug("Add QuoVadis BE PKI CertificationAuthority");
            quovadisTrustServiceProvider
                    .addTrustService(createTSPService_QuoVadisBEPKICertificationAuthority());

            break;
        }
        default:
            throw new IllegalArgumentException(trimester.toString());
        }
    } else {
        throw new IllegalArgumentException("unsupported year");
    }

    //set sequencenumber
    trustServiceList.setTSLSequenceNumber(tslSequenceNumber);
    //set issuedate
    trustServiceList.setListIssueDateTime(listIssueDateTime);
    // next update
    int operationalOverlapWeeks = 2;
    DateTime nextUpdateDateTime = listIssueDateTime.plusMonths(12 / 3).plusWeeks(operationalOverlapWeeks);
    trustServiceList.setNextUpdate(nextUpdateDateTime);

    trustServiceList.addOtherTSLPointer(
            "https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl-hr.pdf",
            "application/pdf", "http://uri.etsi.org/TrstSvc/TrustedList/TSLType/EUlistofthelists", "EU",
            "European Commission", "http://uri.etsi.org/TrstSvc/TrustedList/schemerules/EUlistofthelists",
            Locale.ENGLISH, euSSLCertificate);

    TrustServiceList euTSL;
    try {
        euTSL = TrustServiceListFactory.newInstance(euTSLDocument);
    } catch (IOException e) {
        throw new RuntimeException("could not load EU trust list: " + e.getMessage(), e);
    }
    X509Certificate euCertificate = euTSL.verifySignature();
    LOG.debug("EU certificate: " + euCertificate);

    trustServiceList.addOtherTSLPointer(
            "https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl-mp.xml",
            "application/vnd.etsi.tsl+xml", "http://uri.etsi.org/TrstSvc/TrustedList/TSLType/EUlistofthelists",
            "EU", "European Commission", "http://uri.etsi.org/TrstSvc/TrustedList/schemerules/EUlistofthelists",
            Locale.ENGLISH, euCertificate);

    /*
    Collections.sort(certipostTrustServiceProvider.getTrustServices(),new TrustServiceComparer());
    Collections.sort(trustServiceList.getTrustServiceProviders(), new TrustServiceProviderComparer());
    */
    return trustServiceList;
}

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

License:Open Source License

private static TrustService createTSPService_SWIFTNetPKI() {
    X509Certificate swiftRootCertificate = loadCertificateFromResource("eu/be/swift/swiftnet_root.pem");
    TrustService swiftTrustService = TrustServiceListFactory.createTrustService(
            "SWIFTNet PKI Certification Authority", TrustService.SERVICE_TYPE_IDENTIFIER_CA_QC_URI,
            TrustService.SERVICE_STATUS_UNDER_SUPERVISION,
            new DateTime(2013, 5, 15, 0, 0, 0, 0, DateTimeZone.UTC), swiftRootCertificate);
    swiftTrustService.addOIDForQCForLegalPerson("1.3.21.6.3.10.200.3", true);
    return swiftTrustService;
}

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

License:Open Source License

private static TrustService createTSPService_QuoVadisBEPKICertificationAuthority() {
    X509Certificate quoVadisCertificate = loadCertificateFromResource("eu/be/quovadis/qvbecag1.cer");
    TrustService quoaVadisTrustService = TrustServiceListFactory.createTrustService(
            "QuoVadis BE PKI Certification Authority", TrustService.SERVICE_TYPE_IDENTIFIER_CA_QC_URI,
            TrustService.SERVICE_STATUS_UNDER_SUPERVISION,
            new DateTime(2014, 5, 20, 0, 0, 0, 0, DateTimeZone.UTC), quoVadisCertificate);

    return quoaVadisTrustService;

}