FileDocCategorySizeDatePackage
OIDDatabase.javaAPI DocAndroid 1.5 API5613Wed May 06 22:41:04 BST 2009org.apache.harmony.luni.util

OIDDatabase

public class OIDDatabase extends Object

Fields Summary
private static OIDDatabase
instance
private Set
oids
private Set
algorithms
Constructors Summary
private OIDDatabase()
Private constructor to enforce singleton pattern


               
      
        // First, encryption algorithms...

        // MD2withRSA
        DBEntry oid = new DBEntry("1.2.840.113549.1.1.2");
        DBEntry alg = new DBEntry("MD2withRSA");
        wireTogether(oid, alg);

        // MD5withRSA
        oid = new DBEntry("1.2.840.113549.1.1.4");
        alg = new DBEntry("MD5withRSA");
        wireTogether(oid, alg);

        // SHA1withRSA
        oid = new DBEntry("1.2.840.113549.1.1.5");
        alg = new DBEntry("SHA1withRSA");
        wireTogether(oid, alg);

        // SHA1withDSA
        oid = new DBEntry("1.2.840.10040.4.3");
        alg = new DBEntry("SHA1withDSA");
        wireTogether(oid, alg);

        // message digest algorithms

        // SHA and SHA-1
        oid = new DBEntry("1.3.14.3.2.26");
        alg = new DBEntry("SHA");
        DBEntry alg2 = new DBEntry("SHA-1");
        wireTogether(oid, alg);
        wireTogether(oid, alg2);

        // MD5
        oid = new DBEntry("1.2.840.113549.2.5");
        alg = new DBEntry("MD5");
        wireTogether(oid, alg);

        // key factories

        // RSA
        oid = new DBEntry("1.2.840.113549.1.1.1");
        alg = new DBEntry("RSA");
        wireTogether(oid, alg);

        // DSA
        oid = new DBEntry("1.2.840.10040.4.1");
        DBEntry oid2 = new DBEntry("1.3.14.3.2.12");
        alg = new DBEntry("DSA");
        wireTogether(oid, alg);
        wireTogether(oid2, alg);

        // DiffieHellman
        oid = new DBEntry("1.2.840.10046.2.1");
        alg = new DBEntry("DiffieHellman");
        wireTogether(oid, alg);
    
Methods Summary
public java.util.SetgetAllAlgorithmsForOID(java.lang.String oid)

        Set<String> result = null;
        Iterator<DBEntry> it = this.oids.iterator();
        result = getAllEquivalents(oid, it);
        if (result == null) {
            throw new IllegalArgumentException("Unknown OID : " + oid);
        }
        return result;
    
private java.util.SetgetAllEquivalents(java.lang.String value, java.util.Iterator it)

        Set<String> result = null;
        while (it.hasNext()) {
            DBEntry element = it.next();
            if (element.getValue().equals(value)) {
                Set<DBEntry> allMatchingDBEntries = element.getAllEquivalents();
                result = new HashSet<String>();
                Iterator<DBEntry> dbIt = allMatchingDBEntries.iterator();
                while (dbIt.hasNext()) {
                    DBEntry matchingEntry = dbIt.next();
                    result.add(matchingEntry.getValue());
                }
            }
        }
        return result;
    
public java.util.SetgetAllOIDsForAlgorithm(java.lang.String algorithm)

        Set<String> result = null;
        Iterator<DBEntry> it = this.algorithms.iterator();
        result = getAllEquivalents(algorithm, it);
        if (result == null) {
            throw new IllegalArgumentException("Unsupported algorithm : "
                    + algorithm);
        }
        return result;
    
public java.lang.StringgetFirstAlgorithmForOID(java.lang.String oid)

        String result = null;
        Iterator<String> it = this.getAllAlgorithmsForOID(oid).iterator();
        if (it.hasNext()) {
            result = (it.next());
        }
        return result;
    
public java.lang.StringgetFirstOIDForAlgorithm(java.lang.String algorithm)

        String result = null;
        Iterator<String> it = this.getAllOIDsForAlgorithm(algorithm).iterator();
        if (it.hasNext()) {
            result = (it.next());
        }
        return result;
    
public static org.apache.harmony.luni.util.OIDDatabasegetInstance()

        return instance;
    
private voidwireTogether(org.apache.harmony.luni.util.OIDDatabase$DBEntry oidValue, org.apache.harmony.luni.util.OIDDatabase$DBEntry algorithmValue)

        oids.add(oidValue);
        algorithms.add(algorithmValue);
        oidValue.addEquivalent(algorithmValue);
        algorithmValue.addEquivalent(oidValue);