Exemplo n.º 1
0
        /// <summary>
        /// Get the PrivateKeyStorage from the tpm value in the configuration file if
        /// supplied. Otherwise, get the default for this platform.
        /// </summary>
        ///
        /// <param name="config">The configuration file to check.</param>
        /// <param name="canonicalTpmLocator"></param>
        /// <returns>A new PrivateKeyStorage.</returns>
        private static PrivateKeyStorage getDefaultPrivateKeyStorage(
				ConfigFile config, String[] canonicalTpmLocator)
        {
            String tpmLocator = config.get("tpm", "");

            if (tpmLocator.equals("")) {
                // Use the system default.
                if (System.Environment.GetEnvironmentVariable("os.name").equals("Mac OS X")) {
                    canonicalTpmLocator[0] = "tpm-osxkeychain:";
                    throw new SecurityException(
                            "OSXPrivateKeyStorage is not implemented yet. You must create an IdentityManager with a different PrivateKeyStorage.");
                } else {
                    canonicalTpmLocator[0] = "tpm-file:";
                    return new FilePrivateKeyStorage();
                }
            } else if (tpmLocator.equals("tpm-osxkeychain")) {
                canonicalTpmLocator[0] = "tpm-osxkeychain:";
                throw new SecurityException(
                        "OSXPrivateKeyStorage is not implemented yet. You must create an IdentityManager with a different PrivateKeyStorage.");
            } else if (tpmLocator.equals("tpm-file")) {
                // Don't support non-default locations for now.
                canonicalTpmLocator[0] = "tpm-file:";
                return new FilePrivateKeyStorage();
            } else
                throw new SecurityException("Invalid config file tpm value: "
                        + tpmLocator);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the IdentityStorage from the pib value in the configuration file if
        /// supplied. Otherwise, get the default for this platform.
        /// </summary>
        ///
        /// <param name="config">The configuration file to check.</param>
        /// <returns>A new IdentityStorage.</returns>
        private static IdentityStorage getDefaultIdentityStorage(ConfigFile config)
        {
            String pibLocator = config.get("pib", "");

            if (!pibLocator.equals("")) {
                // Don't support non-default locations for now.
                if (!pibLocator.equals("pib-sqlite3"))
                    throw new SecurityException("Invalid config file pib value: "
                            + pibLocator);
            }

            return new BasicIdentityStorage();
        }