if(instance != null) { throw new AlreadyInitializedException(); } loadNativeLibraries(); if (values.ocspResponderURL != null) { if (values.ocspResponderCertNickname == null) { throw new GeneralSecurityException( "Must set ocspResponderCertNickname"); } } initializeAllNative2(values.configDir, values.certPrefix, values.keyPrefix, values.secmodName, values.readOnly, values.getManufacturerID(), values.getLibraryDescription(), values.getInternalTokenDescription(), values.getInternalKeyStorageTokenDescription(), values.getInternalSlotDescription(), values.getInternalKeyStorageSlotDescription(), values.getFIPSSlotDescription(), values.getFIPSKeyStorageSlotDescription(), values.ocspCheckingEnabled, values.ocspResponderURL, values.ocspResponderCertNickname, values.initializeJavaOnly );  instance = new CryptoManager(); instance.setPasswordCallback(values.passwordCallback); if( values.fipsMode != InitializationValues.FIPSMode.UNCHANGED) { if( enableFIPS(values.fipsMode == InitializationValues.FIPSMode.ENABLED) ) { instance.reloadModules(); } } if( values.removeSunProvider ) { java.security.Security.removeProvider("SUN"); } if( values.installJSSProvider ) {    JSSMessageDigestSpi mds = new JSSMessageDigestSpi.SHA1();  int position = java.security.Security.insertProviderAt( new JSSProvider(), 1); if(position==-1) { Debug.trace(Debug.ERROR, "Unable to install default provider"); } }
initialize( new InitializationValues(configDir) );
    public static synchronized void initialize( InitializationValues values )        throws        KeyDatabaseException,        CertDatabaseException,        AlreadyInitializedException,        GeneralSecurityException    {        if(instance != null) {            throw new AlreadyInitializedException();        }        loadNativeLibraries();        if (values.ocspResponderURL != null) {            if (values.ocspResponderCertNickname == null) {                throw new GeneralSecurityException(                    "Must set ocspResponderCertNickname");            }        }        initializeAllNative2(values.configDir,                            values.certPrefix,                            values.keyPrefix,                            values.secmodName,                            values.readOnly,                            values.getManufacturerID(),                            values.getLibraryDescription(),                            values.getInternalTokenDescription(),                            values.getInternalKeyStorageTokenDescription(),                            values.getInternalSlotDescription(),                            values.getInternalKeyStorageSlotDescription(),                            values.getFIPSSlotDescription(),                            values.getFIPSKeyStorageSlotDescription(),                            values.ocspCheckingEnabled,                            values.ocspResponderURL,                            values.ocspResponderCertNickname,                            values.initializeJavaOnly                            );        instance = new CryptoManager();        instance.setPasswordCallback(values.passwordCallback);        if( values.fipsMode != InitializationValues.FIPSMode.UNCHANGED) {            if( enableFIPS(values.fipsMode ==                    InitializationValues.FIPSMode.ENABLED) )            {                instance.reloadModules();            }        }        if( values.removeSunProvider ) {            java.security.Security.removeProvider("SUN");        }        if( values.installJSSProvider ) {            // Force class load before we install the provider. Otherwise we get            // an infinite loop as the Security manager tries to instantiate the            // digest to verify its own JAR file.            JSSMessageDigestSpi mds = new JSSMessageDigestSpi.SHA1();            int position = java.security.Security.insertProviderAt(                            new JSSProvider(), 1);            if(position==-1) {                Debug.trace(Debug.ERROR,                    "Unable to install default provider");            }        }    }