Inspired from sun.security.ssl.SSLContextImpl#getDefaultKeyManager()
193083
private static synchronized KeyManager[] getDefaultKeyManager() throws KeyStoreException, NoSuchProviderException,
    IOException, CertificateException, NoSuchAlgorithmException, UnrecoverableKeyException {
    final String defaultKeyStore = System.getProperty("javax.net.ssl.keyStore", "");
    String defaultKeyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
    String defaultKeyStoreProvider = System.getProperty("javax.net.ssl.keyStoreProvider", "");

    logDebug("keyStore is : " + defaultKeyStore);
    logDebug("keyStore type is : " + defaultKeyStoreType);
    logDebug("keyStore provider is : " + defaultKeyStoreProvider);

    if (P11KEYSTORE.equals(defaultKeyStoreType) && !NONE.equals(defaultKeyStore)) {
      throw new IllegalArgumentException("if keyStoreType is " + P11KEYSTORE + ", then keyStore must be " + NONE);
    }

    KeyStore ks = null;
    String defaultKeyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword", "");
    char[] passwd = defaultKeyStorePassword.isEmpty() ? null : defaultKeyStorePassword.toCharArray();

    // Try to initialize key store.
    if (!defaultKeyStoreType.isEmpty()) {
      logDebug("init keystore");
      if (defaultKeyStoreProvider.isEmpty()) {
        ks = KeyStore.getInstance(defaultKeyStoreType);
      } else {
        ks = KeyStore.getInstance(defaultKeyStoreType, defaultKeyStoreProvider);
      }
      if (!defaultKeyStore.isEmpty() && !NONE.equals(defaultKeyStore)) {
        try (FileInputStream fs = new FileInputStream(defaultKeyStore)) {
          ks.load(fs, passwd);
        }
      } else {
        ks.load(null, passwd);
      }
    }

    // Try to initialize key manager.
    logDebug("init keymanager of type " + KeyManagerFactory.getDefaultAlgorithm());
    KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());

    if (P11KEYSTORE.equals(defaultKeyStoreType)) {
      // do not pass key passwd if using token
      kmf.init(ks, null);
    } else {
      kmf.init(ks, passwd);
    }

    return kmf.getKeyManagers();
  }
1194589
public static KeyStoreManager getKeyStoreManager(String hostname) throws Exception {
		File root = getKeyStoreRoot(hostname);

    	// create entry
    	KeyStoreManager keyStoreManager = new KeyStoreManager(root);
    	
    	// under the hood this will generate the cert if it doesn't exist
    	keyStoreManager.getCertificateByHostname(hostname);
    	
    	// use this since getCertificateByHostname always returns null, but hostname == alias for our purpose
    	X509Certificate cert = keyStoreManager.getCertificateByAlias(hostname);
    	try {
    		cert.checkValidity();
    	} catch (CertificateExpiredException cee) {
    		// if the cert is expired we should destroy it and recursively call this function
    		keyStoreManager = null;
    		FileUtils.deleteDirectory(root);
    		
    		return getKeyStoreManager(hostname);
    	}
    	
    	return keyStoreManager;
	}
875772
public CmsLoginManager getLoginManager() {

        if (m_loginManager == null) {
            // no login manager configured, create default
            m_loginManager = new CmsLoginManager(
                CmsLoginManager.DISABLE_MINUTES_DEFAULT,
                CmsLoginManager.MAX_BAD_ATTEMPTS_DEFAULT,
                CmsLoginManager.ENABLE_SECURITY_DEFAULT,
                null,
                null,
                null,
                null);
        }
        return m_loginManager;
    }
1278586
public static KeyManager[] getKeyManagers() throws InitializationException {
		String file = System.getProperty("javax.net.ssl.keyStore");
		String pass = System.getProperty("javax.net.ssl.keyStorePassword");

		if (file == null || pass == null) {
			throw new InitializationException("javax.net.ssl.keyStore / "
					+ "javax.net.ssl.keyStorePassword not set");
		}

		return getKeyManagers(file, pass);
	}
1172818
public String getDefaultScreenKeyArea()
    {
        for (int i = DBConstants.MAIN_KEY_AREA; i < this.getKeyAreaCount(); i++)
        {
            if (this.getKeyArea(i).getUniqueKeyCode() == DBConstants.NOT_UNIQUE)
                if (this.getKeyArea(i).getKeyField(DBConstants.MAIN_KEY_FIELD).getField(DBConstants.FILE_KEY_AREA) instanceof StringField)
                    return this.getKeyArea(i).getKeyName();
        }
        return null;      // Return the current key area
    }
554160
static final synchronized CryptoSuiteFactory getDefault() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {

        if (null == theFACTORY) {

            String cf = config.getDefaultCryptoSuiteFactory();
            if (null == cf || cf.isEmpty() || cf.equals(HLSDKJCryptoSuiteFactory.class.getName())) { // Use this class as the factory.

                theFACTORY = HLSDKJCryptoSuiteFactory.instance();

            } else {

                // Invoke static method instance on factory class specified by config properties.
                // In this case this class will no longer be used as the factory.

                Class<?> aClass = Class.forName(cf);

                Method method = aClass.getMethod("instance");
                Object theFACTORYObject = method.invoke(null);
                if (null == theFACTORYObject) {
                    throw new InstantiationException(String.format("Class specified by %s has instance method returning null.  Expected object implementing CryptoSuiteFactory interface.", cf));
                }

                if (!(theFACTORYObject instanceof CryptoSuiteFactory)) {

                    throw new InstantiationException(String.format("Class specified by %s has instance method returning a class %s which does not implement interface CryptoSuiteFactory ",
                            cf, theFACTORYObject.getClass().getName()));

                }

                theFACTORY = (CryptoSuiteFactory) theFACTORYObject;

            }
        }

        return theFACTORY;
    }
86717
@Override
	public CaseFormat getDefaultMapKeyCaseFormat() {
		return CaseFormat.valueOf(getDefaultProps().getOrDefault(PROPS_KEY_DEFAULT_MAP_KEY_CASE_FORMAT,
				CaseFormat.UPPER_SNAKE_CASE.toString()));
	}
896209
public function getDefaultPassword(): ?PasswordBroker
    {
        // By default, the Password Facade does not return the
        // any actual password broker, but rather an
        // instance of \Illuminate\Auth\Passwords\PasswordBrokerManager.
        // Therefore, we make sure only to obtain its
        // "default broker", to make sure that its only the guard
        // instance that we obtain.
        $manager = Password::getFacadeRoot();
        if (isset($manager)) {
            return $manager->broker();
        }
        return $manager;
    }
690877
public synchronized Properties getDefaultSystemProperties(boolean reinitialize) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "getDefaultSystemProperties");

        if (!reinitialize) {
            SSLConfig rc = sslConfigMap.get(Constants.DEFAULT_SYSTEM_ALIAS);
            if (null != rc) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    Tr.exit(tc, "getDefaultSystemProperties -> already present.");
                return rc;
            }
        }

        SSLConfig config = parseDefaultSecureSocketLayer();

        if (config != null && config.requiredPropertiesArePresent()) {
            config.setProperty(Constants.SSLPROP_ALIAS, Constants.DEFAULT_SYSTEM_ALIAS);
            config.setProperty(Constants.SSLPROP_CONFIGURL_LOADED_FROM, "System Properties");

            // in case the passwords are set encoded.
            config.decodePasswords();

            SSLConfig oldConfig = sslConfigMap.get(Constants.DEFAULT_SYSTEM_ALIAS);

            // if old SSLConfig does not exist for this alias, then just add it.
            if (oldConfig == null) {
                // loaded for the first time (new config added to file)
                addSSLConfigToMap(Constants.DEFAULT_SYSTEM_ALIAS, config);
            } else {
                if (!oldConfig.equals(config)) {
                    // remove old config
                    removeSSLConfigFromMap(Constants.DEFAULT_SYSTEM_ALIAS, oldConfig);

                    // add new config
                    addSSLConfigToMap(Constants.DEFAULT_SYSTEM_ALIAS, config);
                } else {
                    // do nothing
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(tc, "New SSL config equals old SSL config for alias: " + Constants.DEFAULT_SYSTEM_ALIAS);
                }
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(tc, "getDefaultSystemProperties -> found valid system properties");
            return config;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "getDefaultSystemProperties -> null");
        return null;
    }
1270003
public com.google.privacy.dlp.v2.DatastoreKeyOrBuilder getDatastoreKeyOrBuilder() {
    if (typeCase_ == 2) {
      return (com.google.privacy.dlp.v2.DatastoreKey) type_;
    }
    return com.google.privacy.dlp.v2.DatastoreKey.getDefaultInstance();
  }
924825
public static ULocale getDefault() {
        synchronized (ULocale.class) {
            if (defaultULocale == null) {
                // When Java's default locale has extensions (such as ja-JP-u-ca-japanese),
                // Locale -> ULocale mapping requires BCP47 keyword mapping data that is currently
                // stored in a resource bundle. However, UResourceBundle currently requires
                // non-null default ULocale. For now, this implementation returns ULocale.ROOT
                // to avoid the problem.

                // TODO: Consider moving BCP47 mapping data out of resource bundle later.

                return ULocale.ROOT;
            }
            Locale currentDefault = Locale.getDefault();
            if (!defaultLocale.equals(currentDefault)) {
                defaultLocale = currentDefault;
                defaultULocale = forLocale(currentDefault);

                if (!JDKLocaleHelper.hasLocaleCategories()) {
                    // Detected Java default Locale change.
                    // We need to update category defaults to match the
                    // Java 7's behavior on Java 6 or older environment.
                    for (Category cat : Category.values()) {
                        int idx = cat.ordinal();
                        defaultCategoryLocales[idx] = currentDefault;
                        defaultCategoryULocales[idx] = forLocale(currentDefault);
                    }
                }
            }
            return defaultULocale;
        }
    }
1338035
public static String getDefaultSSLServerSocketFactory() {
        if (defaultSSLServerSocketFactory == null) {
            defaultSSLServerSocketFactory = AccessController.doPrivileged(new PrivilegedAction<String>() {
                @Override
                public String run() {
                    return Security.getProperty("ssl.ServerSocketFactory.provider");
                }
            });
        }

        return defaultSSLServerSocketFactory;
    }
1347725
public SSLEngine get() {
    try {
      String pass = env.sslKeystorePassword();
      char[] password = pass == null || pass.isEmpty() ? null : pass.toCharArray();

      KeyStore ks = env.sslKeystore();
      if (ks == null) {
        ks = KeyStore.getInstance(KeyStore.getDefaultType());
        String ksFile = env.sslKeystoreFile();
        if (ksFile == null || ksFile.isEmpty()) {
          throw new IllegalArgumentException("Path to Keystore File must not be null or empty.");
        }
        ks.load(new FileInputStream(ksFile), password);
      }
      String defaultAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
      KeyManagerFactory kmf = KeyManagerFactory.getInstance(defaultAlgorithm);
      TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
      kmf.init(ks, password);
      tmf.init(ks);

      SSLContext ctx = SSLContext.getInstance("TLS");
      ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      SSLEngine engine = ctx.createSSLEngine();
      engine.setUseClientMode(true);
      return engine;
    } catch (Exception ex) {
      throw new SSLException("Could not create SSLEngine.", ex);
    }
  }
326855
public static KeyStroke getFindDefaultKeyStroke() {
        if (findDefaultKeyStroke == null) {
            findDefaultKeyStroke = View.getSingleton().getMenuShortcutKeyStroke(KeyEvent.VK_F, 0, false);
        }
        return findDefaultKeyStroke;
    }
123778
protected String getSigningKey() {
        if (extendedMetadata != null && extendedMetadata.getSigningKey() != null) {
            return extendedMetadata.getSigningKey();
        } else {
            return keyManager.getDefaultCredentialName();
        }
    }
693886
public String getDefaultSQL() {

        String ddl = null;

        ddl = defaultExpression == null ? null
                                        : defaultExpression.getSQL();

        return ddl;
    }
285108
private SSLConfig parseDefaultSecureSocketLayer() throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "parseDefaultSecureSocketLayer");

        SSLConfig sslprops = new SSLConfig();

        String defaultkeyManager = JSSEProviderFactory.getKeyManagerFactoryAlgorithm();
        if (defaultkeyManager != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Setting default KeyManager: " + defaultkeyManager);
            sslprops.setProperty(Constants.SSLPROP_KEY_MANAGER, defaultkeyManager);
        }

        // TRUST MANAGERS
        String defaultTrustManager = JSSEProviderFactory.getTrustManagerFactoryAlgorithm();
        if (defaultTrustManager != null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Setting default TrustManager: " + defaultTrustManager);
            sslprops.setProperty(Constants.SSLPROP_TRUST_MANAGER, defaultTrustManager);
        }

        // Obtain miscellaneous attributes from system properties
        String sslProtocol = getSystemProperty(Constants.SSLPROP_PROTOCOL);
        if (sslProtocol != null && !sslProtocol.equals(""))
            sslprops.setProperty(Constants.SSLPROP_PROTOCOL, sslProtocol);

        String contextProvider = getSystemProperty(Constants.SSLPROP_CONTEXT_PROVIDER);
        if (contextProvider != null && !contextProvider.equals("")) {
            // setting IBMJSSE2 since IBMJSSE and IBMJSSEFIPS is not supported any
            // longer
            if (contextProvider.equalsIgnoreCase(Constants.IBMJSSE_NAME) || contextProvider.equalsIgnoreCase(Constants.IBMJSSEFIPS_NAME)) {
                contextProvider = Constants.IBMJSSE2_NAME;
            }

            sslprops.setProperty(Constants.SSLPROP_CONTEXT_PROVIDER, contextProvider);
        }

        String clientAuthentication = getSystemProperty("com.ibm.CSI.performTLClientAuthenticationRequired");
        if (clientAuthentication != null && !clientAuthentication.equals(""))
            sslprops.setProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION, clientAuthentication);

        String clientAuthenticationSupported = getSystemProperty("com.ibm.CSI.performTLClientAuthenticationSupported");
        if (clientAuthenticationSupported != null && !clientAuthenticationSupported.equals(""))
            sslprops.setProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION_SUPPORTED, clientAuthenticationSupported);

        String securityLevel = getSystemProperty(Constants.SSLPROP_SECURITY_LEVEL);
        if (securityLevel != null && !securityLevel.equals(""))
            sslprops.setProperty(Constants.SSLPROP_SECURITY_LEVEL, securityLevel);

        String clientKeyAlias = getSystemProperty(Constants.SSLPROP_KEY_STORE_CLIENT_ALIAS);
        if (clientKeyAlias != null && !clientKeyAlias.equals(""))
            sslprops.setProperty(Constants.SSLPROP_KEY_STORE_CLIENT_ALIAS, clientKeyAlias);

        String serverKeyAlias = getSystemProperty(Constants.SSLPROP_KEY_STORE_SERVER_ALIAS);
        if (serverKeyAlias != null && 0 < serverKeyAlias.length())
            sslprops.setProperty(Constants.SSLPROP_KEY_STORE_SERVER_ALIAS, serverKeyAlias);

        String enabledCiphers = getSystemProperty(Constants.SSLPROP_ENABLED_CIPHERS);
        if (enabledCiphers != null && 0 < enabledCiphers.length()) {
            //Removing extra white space
            StringBuffer buf = new StringBuffer();
            String[] ciphers = enabledCiphers.split("\\s+");
            for (int i = 0; i < ciphers.length; i++) {
                buf.append(ciphers[i]);
                buf.append(" ");
            }
            enabledCiphers = buf.toString().trim();
            sslprops.setProperty(Constants.SSLPROP_ENABLED_CIPHERS, enabledCiphers);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "Saving SSLConfig." + sslprops.toString());

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "parseDefaultSecureSocketLayer");
        return sslprops;
    }