Package org.apache.geronimo.util.asn1.x509

Examples of org.apache.geronimo.util.asn1.x509.X509DefaultEntryConverter


                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                // Set the subject and publickey values to be shown in subsequent screens
                response.setRenderParameter("subject", subject.toString());
                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
            }
            return CONFIRM_CERT_REQ_MODE+BEFORE_ACTION;
        } catch(Exception e) {
            errorMsg = e.toString();
View Full Code Here


                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                // Set the subject and publickey values to be displayed in subsequent screens
                response.setRenderParameter("subject", subject.toString());
                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
            }
            return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
        } catch(Exception e) {
            errorMsg = e.toString();
View Full Code Here

                response.setRenderParameter(INFO_MSG, "A certificate with the serial number '"+sNo+"' has already been issued. "
                        +"You may be seeing this message since you have clicked on 'Issue Certificate' button a second time.");
                return VIEW_CERT_MODE;
            }

            X509Name subject = null;
            PublicKey publickey = null;
            // Process the CSR text to get subject details
            String pkcs10certreq = null, certreq = null;
            String challenge = null;
            String requestId = request.getParameter("requestId");
            if(requestId != null && !requestId.equals("")) {
                // Certificate request is being processed using a previously stored request in CertificateRequestStore
                String certreqText = getCertificateRequestStore(request).getRequest(requestId);
                if(certreqText.startsWith(CaUtils.CERT_REQ_HEADER)) {
                    // A PKCS 10 Certificate Request
                    pkcs10certreq = certreqText;
                } else {
                    // Possibly a CSR received through web browser
                    certreq = certreqText;
                }
            } else {
                // No request id is found.  Get the PKCS10 request submitted through form input
                pkcs10certreq = request.getParameter("pkcs10certreq");
            }
           
            if(pkcs10certreq != null && !"".equals(pkcs10certreq)) {
                // Process PKCS 10 Certificate Request text to get Subject name and public-key
                Map certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
                subject = (X509Name) certReqMap.get(CaUtils.CERT_REQ_SUBJECT);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
            } else {
                // This is a custom request containing SPKAC and X509Name attributes received through web browser
                Properties csrProps = new Properties();
                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
                String spkac = csrProps.getProperty("SPKAC");
                String cn = csrProps.getProperty("CN");
                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
                challenge = (String) certReqMap.get(CaUtils.PKAC_CHALLENGE);
            }

            // Dates have already been validated in the previous screen
            String validFrom = request.getParameter("validFrom");
            String validTo = request.getParameter("validTo");
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            Date validFromDate = df.parse(validFrom);
            Date validToDate = df.parse(validTo);
            String algorithm = request.getParameter("algorithm");
            // Issue certificate
            ca.issueCertificate(new X500Principal(subject.getEncoded()), publickey, sNo, validFromDate, validToDate, algorithm);
            // Store the challenge phrase against the issued certificate serial number
            if(challenge != null && !challenge.equals("")) {
                getCertificateStore(request).setCertificateChallenge(sNo, challenge);
            }
           
View Full Code Here

          ret.add(attr);
        }
        value = CertTools.getPartFromDN(dirAttr, "placeOfBirth");
        if (!StringUtils.isEmpty(value)) {
          ASN1EncodableVector vec = new ASN1EncodableVector();
          X509DefaultEntryConverter conv = new X509DefaultEntryConverter();
          DERObject obj = conv.getConvertedValue(new DERObjectIdentifier(id_pda_placeOfBirth), value);
          vec.add(obj);
          attr = new Attribute(new DERObjectIdentifier(id_pda_placeOfBirth),new DERSet(vec));
          ret.add(attr);
        }       
        // dateOfBirth that is a GeneralizedTime
View Full Code Here

     *          the string will be added to the end positions of OID array.
     *
     * @return X509Name or null if input is null
     */
    public static X509Name stringToBcX509Name(String dn) {
      X509NameEntryConverter converter = new X509DefaultEntryConverter();
      return stringToBcX509Name(dn, converter, true);     
    }
View Full Code Here

    String dn3 = "cn=toto,cn=titi,dc=domain,dc=tld";
    String revdn3 = CertTools.reverseDN(dn3);
    assertEquals("dc=tld,dc=domain,cn=titi,cn=toto", revdn3);
   
        X509Name dn4 = CertTools.stringToBcX509Name(dn3, new X509DefaultEntryConverter(), true);
    assertEquals("CN=toto,CN=titi,DC=domain,DC=tld", dn4.toString());
        X509Name dn5 = CertTools.stringToBcX509Name(dn3, new X509DefaultEntryConverter(), false);
    assertEquals("DC=tld,DC=domain,CN=titi,CN=toto", dn5.toString());
    assertEquals("CN=toto,CN=titi,DC=domain,DC=tld", CertTools.stringToBCDNString(dn3));

    String dn6 = "dc=tld,dc=domain,cn=titi,cn=toto";
    String revdn6 = CertTools.reverseDN(dn6);
    assertEquals("cn=toto,cn=titi,dc=domain,dc=tld", revdn6);
    assertEquals("CN=toto,CN=titi,DC=domain,DC=tld", CertTools.stringToBCDNString(dn3));

        X509Name dn7 = CertTools.stringToBcX509Name(dn6, new X509DefaultEntryConverter(), true);
    assertEquals("CN=toto,CN=titi,DC=domain,DC=tld", dn7.toString());
        X509Name revdn7 = CertTools.stringToBcX509Name(dn6, new X509DefaultEntryConverter(), false);
    assertEquals("DC=tld,DC=domain,CN=titi,CN=toto", revdn7.toString());

    // Test the test strings from ECA-1699, to prove that we fixed this issue
        String dn8 = "dc=org,dc=foo,o=FOO,cn=FOO Root CA";
        String dn9 = "cn=FOO Root CA,o=FOO,dc=foo,dc=org";
    String revdn8 = CertTools.reverseDN(dn8);
    assertEquals("cn=FOO Root CA,o=FOO,dc=foo,dc=org", revdn8);
    String revdn9 = CertTools.reverseDN(dn9);
    assertEquals("dc=org,dc=foo,o=FOO,cn=FOO Root CA", revdn9);
        X509Name xdn8ldap = CertTools.stringToBcX509Name(dn8, new X509DefaultEntryConverter(), true);
        X509Name xdn8x500 = CertTools.stringToBcX509Name(dn8, new X509DefaultEntryConverter(), false);
    assertEquals("CN=FOO Root CA,O=FOO,DC=foo,DC=org", xdn8ldap.toString());
    assertEquals("DC=org,DC=foo,O=FOO,CN=FOO Root CA", xdn8x500.toString());
        X509Name xdn9ldap = CertTools.stringToBcX509Name(dn9, new X509DefaultEntryConverter(), true);
        X509Name xdn9x500 = CertTools.stringToBcX509Name(dn9, new X509DefaultEntryConverter(), false);
    assertEquals("CN=FOO Root CA,O=FOO,DC=foo,DC=org", xdn9ldap.toString());
    assertEquals("DC=org,DC=foo,O=FOO,CN=FOO Root CA", xdn9x500.toString());
    assertEquals("CN=FOO Root CA,O=FOO,DC=foo,DC=org", CertTools.stringToBCDNString(dn8));
    assertEquals("CN=FOO Root CA,O=FOO,DC=foo,DC=org", CertTools.stringToBCDNString(dn9));

    // Test reversing DNs with multiple OU
    String dn10 = "CN=something,OU=A,OU=B,O=someO,C=SE";
        X509Name x509dn10 = CertTools.stringToBcX509Name(dn10, new X509DefaultEntryConverter(), true);
        assertEquals("CN=something,OU=A,OU=B,O=someO,C=SE", x509dn10.toString());
    assertEquals("CN=something,OU=A,OU=B,O=someO,C=SE", CertTools.stringToBCDNString(dn10));

        // When we order forwards (LdapOrder) from the beginning, and request !LdapOrder, everything should be reversed
        X509Name ldapdn11 = CertTools.stringToBcX509Name(dn10, new X509DefaultEntryConverter(), false);
        assertEquals("C=SE,O=someO,OU=B,OU=A,CN=something", ldapdn11.toString());

        // When we order backwards (X.509, !LdapOrder) from the beginning, we should not reorder anything
    String dn11 = "C=SE,O=someO,OU=B,OU=A,CN=something";
    X509Name x509dn11 = CertTools.stringToBcX509Name(dn11, new X509DefaultEntryConverter(), false);
        assertEquals("C=SE,O=someO,OU=B,OU=A,CN=something", x509dn11.toString());
    assertEquals("CN=something,OU=A,OU=B,O=someO,C=SE", CertTools.stringToBCDNString(dn11));

    log.trace("<test09TestReverse()");
  }
View Full Code Here

      }
        X509NameEntryConverter converter = null;
        if (getUsePrintableStringSubjectDN()) {
          converter = new PrintableStringEntryConverter();
        } else {
          converter = new X509DefaultEntryConverter();
        }
        X509Name x509dn = CertTools.stringToBcX509Name(getSubjectDN(), converter, getUseLdapDNOrder());
        PKCS10CertificationRequest req;
    try {
      CATokenContainer catoken = getCAToken();
View Full Code Here

               
        X509NameEntryConverter converter = null;
        if (getUsePrintableStringSubjectDN()) {
          converter = new PrintableStringEntryConverter();
        } else {
          converter = new X509DefaultEntryConverter();
        }
        // Will we use LDAP DN order (CN first) or X500 DN order (CN last) for the subject DN
        boolean ldapdnorder = true;
        if ((getUseLdapDNOrder() == false) || (certProfile.getUseLdapDnOrder() == false)) {
          ldapdnorder = false;
View Full Code Here

          // (I don't think we can ever get here!!!)
            X509NameEntryConverter converter = null;
            if (getUsePrintableStringSubjectDN()) {
              converter = new PrintableStringEntryConverter();
            } else {
              converter = new X509DefaultEntryConverter();
            }

            X509Name caname = CertTools.stringToBcX509Name(getSubjectDN(), converter, getUseLdapDNOrder());
            crlgen.setIssuerDN(caname);
        } else {
View Full Code Here

                java.lang.reflect.Constructor<?> ctor = clzz.getConstructor(new Class[]{String.class});
                if (null != ctor) {
                    return (DERObject) ctor.newInstance(new Object[]{value});
                }
            }
            return new X509DefaultEntryConverter().getConvertedValue(oid, value);
        } catch (Exception e) {
            throw newX509NameError(getRuntime(), e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.util.asn1.x509.X509DefaultEntryConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.