Package org.apache.harmony.security.x509

Examples of org.apache.harmony.security.x509.AlgorithmIdentifier


    public DSAPublicKeyImpl(X509EncodedKeySpec keySpec)
            throws InvalidKeySpecException {

        super("DSA"); //$NON-NLS-1$

        AlgorithmIdentifier ai;
        ThreeIntegerSequence threeInts = null;

        SubjectPublicKeyInfo subjectPublicKeyInfo = null;

        byte encoding[] = keySpec.getEncoded();

        String alg, algName;

        try {
            subjectPublicKeyInfo = (SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1
                    .decode(encoding);
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19A", e)); //$NON-NLS-1$
        }

        try {
            y = new BigInteger((byte[]) ASN1Integer.getInstance().decode(
                    subjectPublicKeyInfo.getSubjectPublicKey()));
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19B", e)); //$NON-NLS-1$
        }

        ai = subjectPublicKeyInfo.getAlgorithmIdentifier();

        try {
            threeInts = (ThreeIntegerSequence) ThreeIntegerSequence.ASN1
                    .decode(ai.getParameters());
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19B", e)); //$NON-NLS-1$
        }
        params = (DSAParams) (new DSAParameterSpec(new BigInteger(threeInts.p),
                new BigInteger(threeInts.q), new BigInteger(threeInts.g)));

        setEncoding(encoding);

        /*
         * the following code implements RI behavior
         */
        alg = ai.getAlgorithm();
        algName = AlgNameMapper.map2AlgName(alg);
        setAlgorithm(algName == null ? alg : algName);
    }
View Full Code Here


     * all functionality will be tested.
     * @return
     * @throws java.lang.Exception
     */
    protected void setUp() throws java.lang.Exception {
        AlgorithmIdentifier signature =
            new AlgorithmIdentifier(algOID, algParams);
        Name issuer = new Name(issuerName);
        Name subject = new Name(subjectName);
        Validity validity =
            new Validity(new Date(notBefore), new Date(notAfter));

View Full Code Here

     */
    public void testCertificate() throws Exception {
        // make the TBSCertificate for Certificate
        int version = 2; //v3
        BigInteger serialNumber = BigInteger.valueOf(555L);
        AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555"); // random value
        Name issuer = new Name("O=Certificate Issuer");
        Validity validity = new Validity(new Date(100000000), new Date(200000000));
        Name subject = new Name("O=Subject Organization");
        SubjectPublicKeyInfo subjectPublicKeyInfo =
            new SubjectPublicKeyInfo(new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
                    new byte[10]);
        boolean[]   issuerUniqueID  = new boolean[]
                    {true, false, true, false, true, false, true, false}; // random value
        boolean[]   subjectUniqueID = new boolean[]
                    {false, true, false, true, false, true, false, true}; // random value
View Full Code Here

     * CertificateList(TBSCertList tbsCertList, AlgorithmIdentifier
     * signatureAlgorithm, byte[] signatureValue) method testing.
     */
    public void testCertificateList() {
        try {
            AlgorithmIdentifier signature =
                new AlgorithmIdentifier(algOID, algParams);
            Name issuer = new Name(issuerName);
            TBSCertList tbscl =
                new TBSCertList(signature, issuer, thisUpdate);
            CertificateList cl =
                new CertificateList(tbscl, signature, new byte[] {0});
View Full Code Here

    private byte[] getCertEncoding(Name subject, GeneralNames subjectAltNames)
                                                        throws IOException {
        // make the TBSCertificate for Certificate
        int version = 2; //v3
        BigInteger serialNumber = BigInteger.valueOf(555L);
        AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555");
        Name issuer = new Name("O=Certificate Issuer");
        Validity validity = new Validity(new Date(100000000),
                                         new Date(200000000));
        SubjectPublicKeyInfo subjectPublicKeyInfo =
            new SubjectPublicKeyInfo(
                    new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
                                            new byte[10]);
        boolean[] issuerUniqueID  = new boolean[]
                    {true, false, true, false, true, false, true, false};
        boolean[] subjectUniqueID = new boolean[]
                    {false, true, false, true, false, true, false, true};
View Full Code Here

                    + " is not found in the environment.");
        }
        sigAlgName = sigAlgNameAndOID[0];
        String sigAlgOID = sigAlgNameAndOID[1];

        AlgorithmIdentifier algId = new AlgorithmIdentifier(sigAlgOID);

        // generate a distinguished name using the string
        Name subjectDName = null;
        Name issuerDName = null;
        try {
View Full Code Here

            signatureValue[20]++;
        } else {
            signatureValue = signatureValueBytes;
        }
       
        Certificate cert =
            new Certificate(tbsCertificate, signature, signatureValue);

        certEncoding = cert.getEncoded();

        cert = (Certificate) Certificate.ASN1.decode(certEncoding);
        certificate = new X509CertImpl(cert);
    }
View Full Code Here

        SubjectPublicKeyInfo subjectPublicKeyInfo = (SubjectPublicKeyInfo)
            SubjectPublicKeyInfo.ASN1.decode(publicKey.getEncoded());
        keyEncoding = subjectPublicKeyInfo.getEncoded();

        Extensions exts = new Extensions(Arrays.asList(extensions));
      
        TBSCertificate tbsCertificate =
            new TBSCertificate(version, serialNumber,
                signature, issuer, validity, subject, subjectPublicKeyInfo,
                issuerUniqueID, subjectUniqueID, exts);
View Full Code Here

                // make the names objects
                X500Principal subject = new X500Principal(variants[i][0]);
                Name subject_name = new Name(variants[i][0]);
                GeneralName alt_name = new GeneralName(4, variants[i][1]);
                // make the certificate to be checked
                GeneralNames alt_names_extension = new GeneralNames();
                alt_names_extension.addName(alt_name);
                TestCert certificate = new TestCert(alt_names_extension);
                certificate.setSubject(subject);
                certificate.setEncoding(getCertEncoding(subject_name,
                                                 alt_names_extension));
                // make the subtrees (part of name constraints)
View Full Code Here

        HashSet extKeyUsage = new HashSet(Arrays.asList(new String[] {
                "1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2", "1.3.6.1.5.5.7.3.3",
                "1.3.6.1.5.5.7.3.4", "1.3.6.1.5.5.7.3.8", "1.3.6.1.5.5.7.3.9",
                "1.3.6.1.5.5.7.3.5", "1.3.6.1.5.5.7.3.6", "1.3.6.1.5.5.7.3.7"}
        ));
        GeneralNames subjectAltNames = new GeneralNames(Arrays.asList(
            new GeneralName[] {
                new GeneralName(1, "rfc@822.Name"),
                new GeneralName(2, "dNSName"),
                new GeneralName(6, "http://uniform.Resource.Id"),
                new GeneralName(7, "1.1.1.1")
            }
        ));
        String[] policies = new String[] {
            "0.0.0.0.0.0",
            "1.1.1.1.1.1",
        };
        TestCert cert = new TestCert("certificate equality criteria");
       
        X509CertSelector selector = new X509CertSelector();
        selector.setCertificate(cert);
        selector.setSerialNumber(serial);
        selector.setIssuer(issuer);
        selector.setSubject(subject);
        selector.setSubjectKeyIdentifier(subject_auth_KeyID);
        selector.setAuthorityKeyIdentifier(subject_auth_KeyID);
        selector.setCertificateValid(certValid);
        selector.setPrivateKeyValid(privateKeyValid[1]);
        selector.setSubjectPublicKey(pkey);
        selector.setSubjectPublicKeyAlgID(pkAlgID);
        selector.setKeyUsage(keyUsage);
        selector.setExtendedKeyUsage(extKeyUsage);
        selector.setSubjectAlternativeNames(subjectAltNames.getPairsList());
        selector.setMatchAllSubjectAltNames(true);
        selector.setPolicy(new HashSet(Arrays.asList(policies)));

        assertNotNull("The result should not be null.",
                selector.toString());
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.x509.AlgorithmIdentifier

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.