Example usage for java.text DateFormat getDateTimeInstance

List of usage examples for java.text DateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateTimeInstance.

Prototype

public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale aLocale) 

Source Link

Document

Gets the date/time formatter with the given formatting styles for the given locale.

Usage

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

private void dto2Components() {
    try {//from   w  ww. ja va  2 s.c  o m
        JCRDocDto dataJCR = DelegateFactory.getInstance().getJCRDocDelegate().getData(jcrDocDto);
        if (dataJCR != null) {
            jcrDocDto = dataJCR;
        }
    } catch (Throwable t) {
    }
    if (jcrDocDto.getbData() != null) {
        if (file == null) {
            try {
                file = File.createTempFile(jcrDocDto.getsFilename(), jcrDocDto.getsMIME());
                FileOutputStream fosFileGetter = new FileOutputStream(file);
                fosFileGetter.write(jcrDocDto.getbData());
                fosFileGetter.close();
            } catch (Exception e) {
            }
        }
    }
    PersonalDto anlegerDto = null;
    try {
        anlegerDto = DelegateFactory.getInstance().getPersonalDelegate()
                .personalFindByPrimaryKey(new Integer((int) jcrDocDto.getlAnleger()));
    } catch (Throwable e1) {

    }
    if (anlegerDto == null) {
        wtfAnleger.setText("");
    } else {
        wtfAnleger.setText(anlegerDto.getCKurzzeichen());
    }
    try {
        if (jcrDocDto.getlPartner() != null) {
            partnerDto = DelegateFactory.getInstance().getPartnerDelegate()
                    .partnerFindByPrimaryKey(jcrDocDto.getlPartner().intValue());
        }
    } catch (ExceptionLP e) {
        // e.printStackTrace();
    }
    if (partnerDto != null) {
        wtfPartner.setText(partnerDto.formatFixTitelName1Name2());
    } else {
        wtfPartner.setText("");
    }
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY);
    wdfZeitpunkt.setText(df.format(new Timestamp(jcrDocDto.getlZeitpunkt())));
    wtfBelegnummer.setText(jcrDocDto.getsBelegnummer());
    wtfSchlagworte.setText(jcrDocDto.getsSchlagworte());
    wtfName.setText(jcrDocDto.getsName());
    wtfFilename.setText(jcrDocDto.getsFilename());
    wtfTable.setText(
            (jcrDocDto.getsTable() == null || jcrDocDto.getsTable().isEmpty()) ? " " : jcrDocDto.getsTable());
    wtfRow.setText(jcrDocDto.getsRow());
    wtfMIME.setText(jcrDocDto.getsMIME());
    wcbVersteckt.setSelected(jcrDocDto.getbVersteckt());
    if (jcrDocDto.getlSicherheitsstufe() == JCRDocFac.SECURITY_ARCHIV) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_ARCHIV);
    }
    wcbSicherheitsstufe.setSelectedItem(jcrDocDto.getlSicherheitsstufe());
    if (JCRDocFac.DEFAULT_ARCHIV_BELEGART.equals(jcrDocDto.getsBelegart())) {
        wcbBelegart.addItem(JCRDocFac.DEFAULT_ARCHIV_BELEGART);
    }
    wcbBelegart.setSelectedItem(jcrDocDto.getsBelegart());
    wcbGruppierung.setSelectedItem(jcrDocDto.getsGruppierung());
    try {
        if (".JPG".equals(jcrDocDto.getsMIME().toUpperCase())
                || ".JPEG".equals(jcrDocDto.getsMIME().toUpperCase())) {
            wmcMedia.setMimeType(MediaFac.DATENFORMAT_MIMETYPE_IMAGE_JPEG);
            wmcMedia.setOMedia(Helper.getBytesFromFile(file));
        } else if (".JRPRINT".equals(jcrDocDto.getsMIME().toUpperCase())) {
            wmcMedia.setMimeType(MediaFac.DATENFORMAT_MIMETYPE_APP_JASPER);
            wmcMedia.setOMedia(Helper.getBytesFromFile(file));
        } else {
            wmcMedia.setMimeType(null);
        }
    } catch (Throwable e) {
    }
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generate a certificate without an email but with S/MIME extended key usage
 * /*www  . j  a  v a 2 s . c  o m*/
 * @throws Exception
 */
private void generateCertificateNoEmail() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPrivateKey = "30820277020100300d06092a864886f70d0101010500048202613082025d"
            + "0201000281810086246af6ba05ff48133e66771615a3e70742ff52d60db8"
            + "a4d808e73369d0c689fc21a2691ee7297311ad840fb7be841d813991f84e"
            + "9590f20a6e4d284d4d3775e646d7aed3a7142159281c9d0171bb98c1a659"
            + "b930f1e158df079136804d89864c0484e4f15482fa4c3b64c3ac58091dc4"
            + "83766b0283c2bd7c8ad12aa19c3b45020301000102818018291f0ae95e83"
            + "285c2ef50da5f0a7e0c8b20c82c3031daab32e8755ff4d17356b3033ac73"
            + "60775abe685e4ce66f6e24524e28386d0f0b584d00a8ed055f4f09ad206d"
            + "22f72a9b8b7724a43b42f0239c44e9db007652d1abf59e9d51731fda6153"
            + "3dd996c06af7761326ac57645be68f3ccc8a665aca9efc37d781c058e98f"
            + "51024100e294e1a1ddc5dbb20d09ef2113a1ddd864c444191c1b51917b69"
            + "fb9718fe6adb5bd29e9603c63d189ee79e194fa9c1484f9a5792f9a29b49"
            + "44f5efc403cd4fbb024100978f09d7c6a74c9a446510f203996b253df437"
            + "94c66e76209570ee5de5c33ee9cc09b75d06543d5b8127b7c9511253bcbf"
            + "2c74c0270c24ca36494954b02870ff024050a19eb1d594059c951b45e7c5"
            + "6ec2ddb0ee4f358855086ff7353dfd053df494df56526d1c26bdb3374941"
            + "6fcc73a27eb3253fa8e40143b58d3edff6274c36e502410088b05dfd38d2"
            + "3c5949e428f34ce1ba6bbd439c3956f9db1a2a0dcf3dea723c349a6c0cef"
            + "1e3d2d957097c4bf119a48e18b3dea123f65496d02a6f8372425653b0241"
            + "00bf58e07f459aa53487e6fb3b40caf2055e181c8505d2deb29cffffbde3"
            + "aeb5ccd0f2c353b47fe53cd3b488be85acaf55956a678ff6e37cca327f1b" + "b82044be77";

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810086"
            + "246af6ba05ff48133e66771615a3e70742ff52d60db8a4d808e73369d0c6"
            + "89fc21a2691ee7297311ad840fb7be841d813991f84e9590f20a6e4d284d"
            + "4d3775e646d7aed3a7142159281c9d0171bb98c1a659b930f1e158df0791"
            + "36804d89864c0484e4f15482fa4c3b64c3ac58091dc483766b0283c2bd7c" + "8ad12aa19c3b450203010001";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    subjectBuilder.setCommonName("No email");
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    X500Principal subject = subjectBuilder.buildPrincipal();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fce43c64c3a7547678e8f0b67559", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:39:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("noEmail", privateKey, null, chain);
}

From source file:org.inheritsource.service.processengine.ActivitiEngineService.java

public List<CommentFeedItem> getProcessInstanceCommentFeedByActivity(String taskId, Locale locale) {
    List<CommentFeedItem> commentFeedItems = new ArrayList<CommentFeedItem>();
    CommentFeedItem cFItem = null;// ww w .  ja  va 2 s .c  om
    Task task = null;
    HistoricTaskInstance historicTask = null;
    String processDefinitionUuid = null;
    String activityDefinitionUuid = null;
    String processInstanceId = null;
    String setActivityLabel = null;
    String processLabel = null;

    try {
        List<Comment> comments = engine.getTaskService().getTaskComments(taskId);

        if (comments != null && comments.size() > 0) {

            // Assume task is present first
            task = engine.getTaskService().createTaskQuery().taskId(taskId).singleResult();

            if (task != null) {
                processDefinitionUuid = task.getProcessDefinitionId();
                activityDefinitionUuid = task.getTaskDefinitionKey();
                processInstanceId = task.getProcessInstanceId();
                setActivityLabel = task.getName();
                processLabel = coordinatriceFacade.getStartFormLabel(task.getProcessInstanceId(), locale);
            } else {
                historicTask = engine.getHistoryService().createHistoricTaskInstanceQuery().taskId(taskId)
                        .singleResult();

                if (historicTask != null) {
                    processDefinitionUuid = historicTask.getProcessDefinitionId();
                    activityDefinitionUuid = historicTask.getTaskDefinitionKey();
                    processInstanceId = historicTask.getProcessInstanceId();
                    setActivityLabel = historicTask.getName();
                    processLabel = coordinatriceFacade.getStartFormLabel(historicTask.getProcessInstanceId(),
                            locale);
                } else {
                    processDefinitionUuid = "";
                    activityDefinitionUuid = "";
                    processInstanceId = "";
                    setActivityLabel = "";
                    processLabel = "";
                }
            }

            for (Comment comment : comments) {

                DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT,
                        locale);
                cFItem = new CommentFeedItem();

                cFItem.setProcessDefinitionUuid(processDefinitionUuid);
                cFItem.setProcessInstanceUuid(processInstanceId);
                cFItem.setProcessLabel(processLabel);
                cFItem.setActivityDefinitionUuid(activityDefinitionUuid);
                cFItem.setActivityInstanceUuid(comment.getTaskId());
                cFItem.setActivityLabel(setActivityLabel);
                cFItem.setTimestamp(comment.getTime());
                cFItem.setTimeStampStr(formatter.format(comment.getTime()));
                cFItem.setMessage(comment.getFullMessage());
                cFItem.setUser(userId2UserInfo(comment.getUserId()));

                commentFeedItems.add(cFItem);
            }
        }
    } catch (Exception e) {
        log.error("Unable to getProcessInstanceCommentFeedByActivity with taskId: " + taskId);
        commentFeedItems = new ArrayList<CommentFeedItem>();
    }
    return commentFeedItems;
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

protected void eventActionUpdate(ActionEvent aE, boolean bNeedNoUpdateI) throws Throwable {
    bNewNode = false;//from  w w  w.  jav a 2 s  .  c  o m

    enableToolsPanelButtons(true, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD, BUTTON_SCAN);
    enableToolsPanelButtons(false, PanelBasis.ACTION_NEW, PanelBasis.ACTION_UPDATE);

    if (jcrDocDto.getlSicherheitsstufe() == JCRDocFac.SECURITY_ARCHIV) {
        wtfSchlagworte.setEditable(true);
        if (LPMain.getInstance().isLPAdmin()) {
            wcbSicherheitsstufe.setEnabled(true);
        }
    } else {
        enableAllComponents(this, true);
    }
    tree.setEnabled(false);
    wcbVersteckteAnzeigen.setEnabled(false);
    wtfName.setEditable(false);
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY);
    wdfZeitpunkt.setText(df.format(new Timestamp(System.currentTimeMillis())));
    wtfAnleger.setText(personalDto.getCKurzzeichen());
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generate a certificate with email in subject but not in AltNames
 * //from  ww w .  j  a va 2  s .c  o  m
 * @throws Exception
 */
private void generateCertificateEmailInSubjectNotInAltNames() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPrivateKey = "30820276020100300d06092a864886f70d0101010500048202603082025c"
            + "02010002818100d101622e0d0d3edb037b595281d54029fb4d5c0bc2025f"
            + "d378f7098b6cdf3a90450978cac7b699ab1457c361384d38278f62a2a3a0"
            + "42988d7ce079170c942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb"
            + "47f926034bfe312353893499bcb6eb6f9aa6e8b203768c93579c93e3234c"
            + "0a345dcfa5e0a3434a205f87dc6ec50203010001028180423a7d00f8b3cc"
            + "ca1bd5575d94b49d6b702d7850657ed91caac5252a202ab0650ceb4e727b"
            + "4c7a6f42b7f8ba72dbcd4283e60e81690411512c53f92afb9a6d2e4fd74d"
            + "bc4c34b73575e60b4e656f23f730a08436fb32bd89c44f120a73757e8fde"
            + "63a12fd9e7860406604acbf006fd235573be8bfb4ffcb3e55f2785cbb009"
            + "a1024100f90a4dbd692dd5948472e5d589fe52c58f85e5ec778ab22cf965"
            + "557e6ad46e08ff8e532e800fe58643c1eae5ef8c3bf1e3f746c0e51f8f97"
            + "4bfeed4dcdd89d69024100d6d8a918fffc750e02ecd443139515ce624e68"
            + "24b808f244e0aabcf00f5323fb0dfe54ffa56b1fcd5b90f6ddff639fea7b"
            + "0843debed0088a0f7dd42cb8802efd024075b569091dad8c45a654a84d45"
            + "ebef3371a2d809ec76a1c0a02045487b35eccc53fdf15309347a47fbbeac"
            + "4801f146640e5bd2155a3690a7f2438be63a6528010240772d644fcbe03d"
            + "0672b4f0e1ec80ecc1b96288fea55fc11458141e0e8451b849d16f5db31a"
            + "0d9c6c8bf894187d4cc42e8be4ffd115c3cc98d9131199651725f9024100"
            + "c74bca53cdd2650796285a3cd9ad48f25e9308532fa3ce3f366abe2a9e5c"
            + "b55dc7a1a7c9d6d30070eeb1584505e493a39515a3e306ed8299ccfcbc02" + "32984aef";

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100d1"
            + "01622e0d0d3edb037b595281d54029fb4d5c0bc2025fd378f7098b6cdf3a"
            + "90450978cac7b699ab1457c361384d38278f62a2a3a042988d7ce079170c"
            + "942ee8b6cbbf2cd2f85be52bd686f4b0d344c24d6acb47f926034bfe3123"
            + "53893499bcb6eb6f9aa6e8b203768c93579c93e3234c0a345dcfa5e0a343" + "4a205f87dc6ec50203010001";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    String email = "test@example.com";

    subjectBuilder.setCommonName("Email in Subject not in AltNames");
    subjectBuilder.setEmail(email);
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    X500Principal subject = subjectBuilder.buildPrincipal();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fceb7f46b98775dbb8287965f838", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:40:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("emailInSubjectNotInAltNames", privateKey, null, chain);
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generate a certificate with email in AltNames but not in subject
 * /*from   w w w .  j  a  v  a  2 s.c om*/
 * @throws Exception
 */
private void generateCertificateEmailInAltNamesNotInSubject() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810088"
            + "350aa5de312b8d6d2bcb1845ae426b52f53bed933d05c1914753651911dd"
            + "2f2e449e5ebf0a9708d16bbf7ad3ff7e56bf149e26eb37112e1d92989884"
            + "ec3f9c27d4a37efe804a55e97e3ec62aa30610952b3f60f8a3f7516cf00b"
            + "1bc1d3a75f5d4f5834962d091c5676f5ecd6a12ac4e4fbb6069048684696" + "bfbf72483feb210203010001";

    String encodedPrivateKey = "30820275020100300d06092a864886f70d01010105000482025f3082025b"
            + "0201000281810088350aa5de312b8d6d2bcb1845ae426b52f53bed933d05"
            + "c1914753651911dd2f2e449e5ebf0a9708d16bbf7ad3ff7e56bf149e26eb"
            + "37112e1d92989884ec3f9c27d4a37efe804a55e97e3ec62aa30610952b3f"
            + "60f8a3f7516cf00b1bc1d3a75f5d4f5834962d091c5676f5ecd6a12ac4e4"
            + "fbb6069048684696bfbf72483feb2102030100010281802a20257be93d51"
            + "d7fab4b9aa771a8f063c710628d309e376db64b0e12aa0c0c4afcd9f2174"
            + "7a64fde02f2fd8602abbbb3e7bb4f21a7b3c8003bb6c2077b3cd741b4b83"
            + "37c1330742875962dc56a91ecd9b6ccbc54d9c86ac7533dae9d3b792844a"
            + "2135e35b7ce2720f4d2fc25e2013aaadecd35a93d74a08921f1d4991023b"
            + "05024100e5b57d7eeeef447c9ca66643f8b38d743a2e1247e0b2bbe6925f"
            + "1a6166c580d10d87dff02a15ffc963e0f192ea060862e4ad3d1a6afbd280"
            + "3e5b409ea283119b02410097cbef487d4309e5646303b1c75e88db469c8a"
            + "653f93eac9713d570fad45b85f583c2c0314f3a290e6cc8a5cce2ca60ad5"
            + "4ea549779c829429f1645530dc6ff302402daac0314d052a636fad312590"
            + "3afa034251c8769bb84cdcd0fab13eedf493e07bc52883118ae018449002"
            + "d6c749bdbf136151858001625ef686a3b925ebd2c30240698a333e55494d"
            + "121eeff0dba460880add576da9e3c07657c4d1ff3c391ee687f413320e9a"
            + "7ca2a4d8b391e7e0b98e60adda567574226f6f9091f34e8000641d024031"
            + "7135e36f1533cffe338cbd103f44cc8ca257a27682c41b50f5458f7d0fde"
            + "7fe60171fc6718614fca2a756648fe87c9b2551d54cf4162035d59e7730f" + "a0783d";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    String email = "test@example.com";

    subjectBuilder.setCommonName("Email in DN not in AltNames");
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("Amsterdam");
    subjectBuilder.setState("NH");

    AltNamesBuilder altNamesBuider = new AltNamesBuilder();
    altNamesBuider.setRFC822Names(email);

    X500Principal subject = subjectBuilder.buildPrincipal();
    GeneralNames altNames = altNamesBuider.buildAltNames();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fceeccd07fe8929f68cc6b359a5a", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:41:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setAltNames(altNames, true);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(new Date(), 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("emailInAltNamesNotInSubject", privateKey, null, chain);
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

public void setDefaultsForNew() throws Throwable {
    wtfAnleger.setText(personalDto.getCKurzzeichen());
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMANY);
    wdfZeitpunkt.setText(df.format(new Timestamp(System.currentTimeMillis())));
    wtfFilename.setText(file.getName());
    wtfMIME.setText(Helper.getMime(file.getName()));
    wcbVersteckt.setSelected(false);/*from  w w  w.  j  a  va2 s. c o m*/
    if (bHatStufe3) {
        wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_HIGH);
    } else if (bHatStufe2) {
        wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_MEDIUM);
    } else if (bHatStufe1) {
        wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_LOW);
    } else if (bHatStufe0) {
        wcbSicherheitsstufe.setSelectedItem(JCRDocFac.SECURITY_NONE);
    }
    wcbSicherheitsstufe.removeItem(JCRDocFac.SECURITY_ARCHIV);
    wcbBelegart.removeItem(JCRDocFac.DEFAULT_ARCHIV_BELEGART);
    wtfBelegnummer.setText(tree.getLastSelectedPathComponent().toString());
    wtfTable.setText(sTable);
    wtfRow.setText(sRow);
    wtfPartner.setText(partnerDto.formatFixTitelName1Name2());

}

From source file:com.clustercontrol.jobmanagement.factory.SelectJob.java

/**
 * ???????//from ww  w. j  a v  a  2s .co  m
 *
 * @param sessionId ID
 * @param jobId ID
 * @param jobunitId ID
 * @param destFacilityId ?ID
 * @param destFacilityName ???
 * @param checksum ?
 * @param locale 
 * @return 
 * @throws JobInfoNotFound
 */
private String getFileJobDetailMessage(String sessionId, String jobunitId, String jobId, String destFacilityId,
        String destFacilityName, boolean checksum, Locale locale) throws JobInfoNotFound {

    final String START = "_START";
    final String END = "_END";
    final String FILE = "_FILE";
    final String RTN = "\n";

    StringBuilder message = new StringBuilder();

    if (sessionId == null || sessionId.length() == 0 || jobId == null || jobId.length() == 0) {
        return message.toString();
    }

    // UTILIUPDT_S??
    if (CreateHulftJob.isHulftMode()) {
        try {
            JobSessionJobEntity job = QueryUtil.getJobSessionJobPK(sessionId, jobunitId, jobId);
            JobSessionJobEntity jobUtliupdtS = QueryUtil.getJobSessionJobPK(sessionId, jobunitId,
                    job.getParentJobId() + CreateHulftJob.UTILIUPDT_S);
            if (jobUtliupdtS.getEndDate() != null) {
                if (jobUtliupdtS.getEndStatus() == null
                        || jobUtliupdtS.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : jobUtliupdtS.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                }
            }
        } catch (JobInfoNotFound e) {
            m_log.debug("getFileJobDetailMessage() : " + e.getMessage());
        } catch (InvalidRole e) {
            m_log.info("getFileJobDetailMessage() : " + e.getMessage());
        }
    }

    //ID?
    Collection<JobSessionJobEntity> collection = QueryUtil.getChildJobSessionJobOrderByStartDate(sessionId,
            jobunitId, jobId);
    if (collection == null) {
        JobInfoNotFound je = new JobInfoNotFound("JobSessionJobEntity.findByStartDate"
                + ", [sessionId, parentJobId] = " + "[" + sessionId + ", " + jobId + "]");
        m_log.info("getFileJobDetailMessage() : " + je.getClass().getSimpleName() + ", " + je.getMessage());
        je.setSessionId(sessionId);
        je.setParentJobId(jobId);
        throw je;
    }

    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, locale);
    dateFormat.setTimeZone(HinemosTime.getTimeZone());
    HashMap<String, String> jobIdMap = new HashMap<String, String>();

    for (JobSessionJobEntity childSessionJob : collection) {
        JobInfoEntity childJob = childSessionJob.getJobInfoEntity();
        String childJobId = childSessionJob.getId().getJobId();

        if (childJobId.indexOf(CreateFileJob.GET_KEY) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.GET_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (childSessionJob.getEndStatus() == null
                            || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL)) {
                for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                    String nodeMessage = node.getMessage();
                    if (nodeMessage != null && nodeMessage.length() > 0) {
                        message.append(nodeMessage);
                        message.append(RTN);
                    }
                }
                jobIdMap.put(fileJobId, END);
            }

        } else if (childJobId.indexOf(CreateFileJob.ADD_KEY) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.ADD_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateFileJob.GET_CHECKSUM) != -1) {
            //"_GET_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.GET_CHECKSUM, "");
            jobIdMap.put(fileJobId + FILE, childJob.getArgument());
            //????
            if (childSessionJob.getStartDate() != null) {
                String dateString = dateFormat.format(childSessionJob.getStartDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                message.append(MessageConstant.MESSAGE_STARTED_TO_TRANSFER_FILE.getMessage(args));
                message.append(RTN);
                jobIdMap.put(fileJobId, START);
            }
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    String dateString = dateFormat.format(childSessionJob.getEndDate());
                    String file = childJob.getArgument();
                    String[] args = { dateString, file, destFacilityName };
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateFileJob.FORWARD) != -1) {
            //"_FORWARD"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.FORWARD, "");
            //????
            if (childSessionJob.getStartDate() != null && !checksum) {
                String dateString = dateFormat.format(childSessionJob.getStartDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                message.append(MessageConstant.MESSAGE_STARTED_TO_TRANSFER_FILE.getMessage(args));
                message.append(RTN);
                jobIdMap.put(fileJobId, START);
            }
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                String dateString = dateFormat.format(childSessionJob.getEndDate());
                String file = childJob.getArgument();
                String[] args = { dateString, file, destFacilityName };
                if (childSessionJob.getEndStatus() != null
                        && childSessionJob.getEndStatus() == EndStatusConstant.TYPE_NORMAL) {
                    if (!checksum) {
                        message.append(MessageConstant.MESSAGE_FINISHED_TRANSFERRING_FILE.getMessage(args));
                        message.append(RTN);
                        jobIdMap.put(fileJobId, END);
                    }
                } else {
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        m_log.debug(node.getId().getJobId());
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }
            if (!checksum) {
                jobIdMap.remove(fileJobId);
                jobIdMap.remove(fileJobId + FILE);
            }

        } else if (childJobId.indexOf(CreateFileJob.CHECK_CHECKSUM) != -1) {
            //"_CHECK_CHECKSUM"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.CHECK_CHECKSUM, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                String dateString = dateFormat.format(childSessionJob.getEndDate());
                String file = jobIdMap.get(fileJobId + FILE);
                String[] args = { dateString, file, destFacilityName };
                if (childSessionJob.getEndStatus() != null
                        && childSessionJob.getEndStatus() == EndStatusConstant.TYPE_NORMAL) {
                    message.append(MessageConstant.MESSAGE_FINISHED_TRANSFERRING_FILE.getMessage(args));
                    message.append(RTN);
                } else {
                    message.append(MessageConstant.MESSAGE_FAILED_TO_TRANSFER_FILE.getMessage(args));
                    message.append(RTN);
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        m_log.debug(node.getId().getJobId());
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }
            jobIdMap.remove(fileJobId);
            jobIdMap.remove(fileJobId + FILE);

        } else if (childJobId.indexOf(CreateFileJob.DEL_KEY) != -1) {
            //"_DEL_KEY"??ID?
            String fileJobId = childJobId.replaceAll(CreateFileJob.DEL_KEY, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_R) != -1) {
            //"_UTILIUPDT_R"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_R, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_H_SND) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_H_SND, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTILIUPDT_H_RCV) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTILIUPDT_H_RCV, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.UTLSEND) != -1) {
            //"_UTLSEND"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.UTLSEND, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                if (childSessionJob.getEndStatus() == null
                        || childSessionJob.getEndStatus() != EndStatusConstant.TYPE_NORMAL) {
                    for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                        String nodeMessage = node.getMessage();
                        if (nodeMessage != null && nodeMessage.length() > 0) {
                            message.append(nodeMessage);
                            message.append(RTN);
                        }
                    }
                    jobIdMap.put(fileJobId, END);
                }
            }

        } else if (childJobId.indexOf(CreateHulftJob.HULOPLCMD) != -1) {
            //"_HULOPLCMD"??ID?
            String fileJobId = childJobId.replaceAll(CreateHulftJob.HULOPLCMD, "");
            //????
            if (childSessionJob.getStartDate() != null && childSessionJob.getEndDate() != null
                    && (jobIdMap.get(fileJobId) == null || !jobIdMap.get(fileJobId).equals(END))) {
                // HULOPLCMD??????????????
                for (JobSessionNodeEntity node : childSessionJob.getJobSessionNodeEntities()) {
                    String nodeMessage = node.getMessage();
                    if (nodeMessage != null && nodeMessage.length() > 0) {
                        message.append(nodeMessage);
                        message.append(RTN);
                    }
                }
                jobIdMap.put(fileJobId, END);
            }
        }

        m_log.debug("getFileJobDetailMessage() : jobid=" + childJobId + ", message=" + message);
    }

    if (message.length() > 0) {
        message.setLength(message.length() - 1);
    }

    return message.toString();
}

From source file:org.gvnix.web.screen.roo.addon.SeleniumServicesImpl.java

/**
 * Get test value for a field./*from w  w  w.  j  a v  a2 s  .c  o m*/
 * 
 * @param field Field to auto generate a value
 * @param random Should be the initialized value generated randomly ?
 * @return Field test value
 */
private String convertToInitializer(FieldMetadata field, boolean random) {

    String initializer = " ";

    short index = 1;
    if (random) {
        index = (short) RANDOM_GENERATOR.nextInt();
    }

    AnnotationMetadata min = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
            new JavaType("javax.validation.constraints.Min"));
    if (min != null) {
        AnnotationAttributeValue<?> value = min.getAttribute(new JavaSymbolName("value"));
        if (value != null) {
            index = Short.valueOf(value.getValue().toString());
        }
    }
    if (field.getFieldName().getSymbolName().contains("email")
            || field.getFieldName().getSymbolName().contains("Email")) {
        initializer = "some@email.com";
    } else if (field.getFieldType().equals(JavaType.STRING)) {
        initializer = "some" + field.getFieldName().getSymbolNameCapitalisedFirstLetter() + index;
    } else if (field.getFieldType().equals(new JavaType(Date.class.getName()))
            || field.getFieldType().equals(new JavaType(Calendar.class.getName()))) {
        Calendar cal = Calendar.getInstance();
        AnnotationMetadata dateTimeFormat = null;
        String style = null;
        if (null != (dateTimeFormat = MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("org.springframework.format.annotation.DateTimeFormat")))) {
            AnnotationAttributeValue<?> value = dateTimeFormat.getAttribute(new JavaSymbolName("style"));
            if (value != null) {
                style = value.getValue().toString();
            }
        }
        if (null != MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("javax.validation.constraints.Past"))) {
            cal.add(Calendar.YEAR, -1);
            cal.add(Calendar.MONTH, -1);
            cal.add(Calendar.DAY_OF_MONTH, -1);
        } else if (null != MemberFindingUtils.getAnnotationOfType(field.getAnnotations(),
                new JavaType("javax.validation.constraints.Future"))) {
            cal.add(Calendar.YEAR, +1);
            cal.add(Calendar.MONTH, +1);
            cal.add(Calendar.DAY_OF_MONTH, +1);
        }
        if (style != null) {
            if (style.startsWith("-")) {
                initializer = ((SimpleDateFormat) DateFormat
                        .getTimeInstance(DateTime.parseDateFormat(style.charAt(1)), Locale.getDefault()))
                                .format(cal.getTime());
            } else if (style.endsWith("-")) {
                initializer = ((SimpleDateFormat) DateFormat
                        .getDateInstance(DateTime.parseDateFormat(style.charAt(0)), Locale.getDefault()))
                                .format(cal.getTime());
            } else {
                initializer = ((SimpleDateFormat) DateFormat.getDateTimeInstance(
                        DateTime.parseDateFormat(style.charAt(0)), DateTime.parseDateFormat(style.charAt(1)),
                        Locale.getDefault())).format(cal.getTime());
            }
        } else {
            initializer = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()))
                    .format(cal.getTime());
        }

    } else if (field.getFieldType().equals(JavaType.BOOLEAN_OBJECT)
            || field.getFieldType().equals(JavaType.BOOLEAN_PRIMITIVE)) {
        initializer = Boolean.FALSE.toString();
    } else if (field.getFieldType().equals(JavaType.INT_OBJECT)
            || field.getFieldType().equals(JavaType.INT_PRIMITIVE)) {
        initializer = Integer.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.DOUBLE_OBJECT)
            || field.getFieldType().equals(JavaType.DOUBLE_PRIMITIVE)) {
        initializer = Double.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.FLOAT_OBJECT)
            || field.getFieldType().equals(JavaType.FLOAT_PRIMITIVE)) {
        initializer = Float.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.LONG_OBJECT)
            || field.getFieldType().equals(JavaType.LONG_PRIMITIVE)) {
        initializer = Long.valueOf(index).toString();
    } else if (field.getFieldType().equals(JavaType.SHORT_OBJECT)
            || field.getFieldType().equals(JavaType.SHORT_PRIMITIVE)) {
        initializer = Short.valueOf(index).toString();
    } else if (field.getFieldType().equals(new JavaType("java.math.BigDecimal"))) {
        initializer = BigDecimal.valueOf(index).toString();
    }
    return initializer;
}

From source file:mitm.common.security.certificate.GenerateTestCertificates.java

/**
 * Generates a certificate with javascript in the certificate fields to test XSS injections.
 * /*from  w ww  . j  a  v  a2s . c  o m*/
 * @throws Exception
 */
private void generateCertificateXSS() throws Exception {
    X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder();

    String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d0030818902818100ab"
            + "c1cb1ce9ac2acef6ab4c6c6cfe38840f25095652038529aa34e21c36b1b9"
            + "833c8f91b34c97a803af002ed9dd6d79fc23d5e5190180a9235e61ec596d"
            + "b084ac78aef9f65e182977e918b9b8aa423c707bd4189e44eb9dfb68d585"
            + "a828ea6b16b22f382e6084140bde8a65391894b32cbd13d3b49a6a72adeb" + "49472da5995dc70203010001";

    String encodedPrivateKey = "30820278020100300d06092a864886f70d0101010500048202623082025e"
            + "02010002818100abc1cb1ce9ac2acef6ab4c6c6cfe38840f250956520385"
            + "29aa34e21c36b1b9833c8f91b34c97a803af002ed9dd6d79fc23d5e51901"
            + "80a9235e61ec596db084ac78aef9f65e182977e918b9b8aa423c707bd418"
            + "9e44eb9dfb68d585a828ea6b16b22f382e6084140bde8a65391894b32cbd"
            + "13d3b49a6a72adeb49472da5995dc702030100010281810084959e52fd56"
            + "b7dcf7b117d782f363711db7bb53750fde95611c5d86e5f99f78dd20fe99"
            + "e80011e4760cb01de1be06b24a7f6cd036c6b8c9e2abb8a4f7f59113c67c"
            + "d06b3a642d67e3a4035a8cfccf0992184451adfcfccd3157e5a2f79ee0f1"
            + "8659c6ee801c5c081876cbd2db6390b3102b656adf7e249889ee108a4fb6"
            + "23f1024100d3beeecb8841cef45343138df276eb30293489ed74855dae41"
            + "c7b713dee7e6b4a8904fc24cab09e313f9968b4db6988fc5530da7b0f1b8"
            + "e71dfe26c09aed79f5024100cfa75532fa6fb39ae86dd8f05effdf9862e3"
            + "4ad51d71a9c6f15e6ec0d5618e7dcab1cbe93e5991fed42f913faca7d115"
            + "7fdcc255b6fec086070f04a736a7374b024100a619635693471421c2629e"
            + "a73da89d2b0557aa4e7395de7bc02bfae80276251a5814040ce57951e328"
            + "1b2445982b81175e719d078b1cc2afc16e4955d2f23035024100ca854b6d"
            + "dd9c0592062fe40d82c9909bc18e25d4b5d3be1e7e177872ef69271c7e0c"
            + "6b703ed402b482e32588f16df6583e8ce2a7d042a327d4488c643cc45703"
            + "02404b3b36fd231a6eab54303121dad4a66d732cc2d7d72b4a76108e2fc6"
            + "e1ee0080dd9733046009f19a96885cdad46bcd0a1ca1f62ce7eed073ca41" + "320fa140753f";

    PrivateKey privateKey = decodePrivateKey(encodedPrivateKey);
    PublicKey publicKey = decodePublicKey(encodedPublicKey);

    X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder();

    String email = "<script>alert('test')</script>";

    subjectBuilder.setCommonName("<script>alert('test')</script>");
    subjectBuilder.setEmail(email);
    subjectBuilder.setCountryCode("NL");
    subjectBuilder.setLocality("<script>alert('test')</script>");
    subjectBuilder.setState("<script>alert('test')</script>");

    AltNamesBuilder altNamesBuider = new AltNamesBuilder();
    altNamesBuider.setRFC822Names(email);

    X500Principal subject = subjectBuilder.buildPrincipal();
    GeneralNames altNames = altNamesBuider.buildAltNames();

    Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>();

    keyUsage.add(KeyUsageType.DIGITALSIGNATURE);
    keyUsage.add(KeyUsageType.KEYENCIPHERMENT);
    keyUsage.add(KeyUsageType.NONREPUDIATION);

    Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>();

    extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH);
    extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION);

    BigInteger serialNumber = new BigInteger("115fd003be5a87522cb76cfab2ec85f", 16);

    Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK)
            .parse("21-Nov-2007 11:45:35");

    certificateBuilder.setSubject(subject);
    certificateBuilder.setAltNames(altNames, true);
    certificateBuilder.setKeyUsage(keyUsage, true);
    certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, false);
    certificateBuilder.setNotBefore(DateUtils.addDays(now, -20));
    certificateBuilder.setNotAfter(DateUtils.addYears(now, 20));
    certificateBuilder.setPublicKey(publicKey);
    certificateBuilder.setSerialNumber(serialNumber);
    certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption");
    certificateBuilder.addSubjectKeyIdentifier(true);

    X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate);

    assertNotNull(certificate);

    certificates.add(certificate);

    Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate };

    keyStore.setKeyEntry("certificateXSS", privateKey, null, chain);
}