Changeset 238717d


Ignore:
Timestamp:
Mar 29, 2011 4:49:08 PM (8 years ago)
Author:
Ted Faber <faber@…>
Branches:
abac0-leak, abac0-mei, compt_changes, gec13, master, mei-id, mei-rt0-n, mei_rt0, mei_rt2, mei_rt2_fix_1, meiyap-rt1, meiyap1, rt2, tvf-new-xml
Children:
dc9ae96
Parents:
3d13073
Message:

Auto-load the BouncyCastle? provider. (Makes jnlp work)

Location:
java/net/deterlab/abac
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • java/net/deterlab/abac/Context.java

    r3d13073 r238717d  
    1414import org.bouncycastle.x509.*;
    1515import org.bouncycastle.openssl.*;
     16import org.bouncycastle.jce.provider.BouncyCastleProvider;
    1617
    1718/**
     
    4950    protected Map<String, String> keys;
    5051
     52    /** True once BouncyCastle has been loaded. */
     53    static boolean providerLoaded = false;
     54
     55    /**
     56     * Load the BouncyCastle provider, necessary for ABAC crypto (shouldn't
     57     * need to be called directly).  This is called from the Context static
     58     * constructor and static constructors in other ABAC classes that use
     59     * BouncyCastle crypto (which loads a Context, which calls it as well) to
     60     * make sure crypto is available. 
     61     */
     62    static void loadBouncyCastle() {
     63        if ( !providerLoaded ) {
     64            AccessController.doPrivileged(new PrivilegedAction<Object>() {
     65                public Object run() {
     66                    Security.addProvider(new BouncyCastleProvider());
     67                    return null;
     68                }
     69            });
     70            providerLoaded = true;
     71        }
     72    }
     73
     74    /** Load the BouncyCastle provider. */
     75    static { loadBouncyCastle(); };
     76
    5177    /**
    5278     * The result of a query on this context.  The credentials form a partial
     
    271297     * @return a boolean, true if the Identity is known.
    272298     */
    273     public boolean knowsIdentity(Identity i) { return m_identities.contains(i); }
     299    public boolean knowsIdentity(Identity i) { return m_identities.contains(i);}
    274300    /**
    275301     * Returns true if an Identity with the given string representation is
  • java/net/deterlab/abac/Credential.java

    re36ea1d r238717d  
    3737    /** The identity that issued the certificate */
    3838    protected Identity id;
     39
     40    /** Make sure BouncyCastle is loaded */
     41    static { Context.loadBouncyCastle(); }
    3942
    4043    /**
  • java/net/deterlab/abac/Identity.java

    re36ea1d r238717d  
    1414import org.bouncycastle.asn1.x509.*;
    1515import org.bouncycastle.x509.*;
    16 import org.bouncycastle.jce.provider.X509AttrCertParser;
    17 // import org.bouncycastle.jce.provider.X509CertificateObject;
    18 import org.bouncycastle.openssl.PEMReader;
    19 import org.bouncycastle.openssl.PEMWriter;
     16import org.bouncycastle.openssl.*;
     17
    2018
    2119/**
     
    3634    protected KeyPair kp;
    3735
     36    /** Make sure BouncyCastle is loaded */
     37    static { Context.loadBouncyCastle(); }
     38
    3839    /**
    3940     * Initialize from PEM cert in a reader.  Use a PEMReader to get
     
    126127        gen.setPublicKey(kp.getPublic());
    127128        gen.setSignatureAlgorithm("SHA256WithRSAEncryption");
    128         X509Certificate a = (X509Certificate) gen.generate(kp.getPrivate());
     129        X509Certificate a = (X509Certificate) gen.generate(kp.getPrivate(), "BC");
    129130        init(a);
    130131    }
  • java/net/deterlab/abac/Role.java

    r3b38c41 r238717d  
    22
    33import java.util.*;
    4 
    5 import org.bouncycastle.asn1.*;
    64
    75/**
Note: See TracChangeset for help on using the changeset viewer.