use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.
the class CryptoExtensions method setJCEProviderName.
/**
* Overrides the configured JCE crypto provider string. If the name is empty or null, the default string "BC" (BouncyCastle provider)
* is used.
* <P>
* The provider name may be a comma delimited list of provider strings. The first string in the list will be the default provider string
* and returned when using {@link #getJCEProviderName()}; however, the {@link #getJCEProviderNameForTypeAndAlgorithm(String, String)} will search
* through the provider string until a valid provider that supports the requested type and algorithm is found. In this case, the first matching
* provider string will be used.
* @param name The name of the JCE provider.
*/
public static void setJCEProviderName(String name) {
OptionsParameter param;
if (name == null || name.isEmpty())
param = new OptionsParameter(OptionsParameter.JCE_PROVIDER, DEFAULT_JCE_PROVIDER_STRING);
else
param = new OptionsParameter(OptionsParameter.JCE_PROVIDER, name);
OptionsManager.getInstance().setOptionsParameter(param);
}
use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.
the class CryptoExtensions method getJCEProviderName.
/**
* Gets the configured JCE crypto provider string for crypto operations. This is configured using the
* -Dorg.nhindirect.stagent.cryptography.JCEProviderName JVM parameters. If the parameter is not set or is empty,
* then the default string "BC" (BouncyCastle provider) is returned. By default the agent installs the BouncyCastle provider.
* @return The name of the JCE provider string.
*/
public static String getJCEProviderName() {
String retVal = "";
OptionsParameter param = OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER);
if (param == null || param.getParamValue() == null || param.getParamValue().isEmpty())
retVal = DEFAULT_JCE_PROVIDER_STRING;
else {
final String[] JCEString = param.getParamValue().split(",");
retVal = JCEString[0];
}
return retVal;
}
use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.
the class CryptoExtensions method getJCEProviderNameForTypeAndAlgorithm.
/**
* Gets the configured JCE crypto provider that supports the combination of the requested type and algorithm. If a custom set of
* providers has not been configured, this method will always return the default BouncyCatle provider string regardless if it matches
* the request type/algorithm pair.
* @param type The crypto type such as CertStore or CertPathValidator
* @param algorithm The algorithm such as PKIX or MAC.
* @return The name of the JCE provider string supporting the type/algorithm pair.
*/
public static String getJCEProviderNameForTypeAndAlgorithm(String type, String algorithm) {
String[] JCEString = null;
String retVal = "";
final OptionsParameter param = OptionsManager.getInstance().getParameter(OptionsParameter.JCE_PROVIDER);
if (param == null || param.getParamValue() == null || param.getParamValue().isEmpty())
JCEString = new String[] { DEFAULT_JCE_PROVIDER_STRING };
else {
final String configuredJCEString = param.getParamValue();
JCEString = configuredJCEString.split(",");
}
for (String provierString : JCEString) {
final Provider provider = Security.getProvider(provierString);
if (provider != null) {
if (provider.getService(type, algorithm) != null) {
retVal = provierString;
break;
}
}
}
return retVal;
}
use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.
the class CryptoExtensions method getJCESensitiveProviderName.
/**
* Gets the configured JCE sensitive crypto provider string for crypto operations that need access to sensitive cryptogrophy information
* such as secret and private keys. This is configured using the
* -Dorg.nhindirect.stagent.cryptography.JCESensitiveProviderName JVM parameters. If the parameter is not set or is empty,
* then the default string "BC" (BouncyCastle provider) is returned. By default the agent installs the BouncyCastle provider.
* @return The name of the JCE provider string.
*/
public static String getJCESensitiveProviderName() {
String retVal = "";
OptionsParameter param = OptionsManager.getInstance().getParameter(OptionsParameter.JCE_SENTITIVE_PROVIDER);
if (param == null || param.getParamValue() == null || param.getParamValue().isEmpty())
retVal = DEFAULT_SENSITIVE_JCE_PROVIDER_STRING;
else {
final String[] JCEString = param.getParamValue().split(",");
retVal = JCEString[0];
}
return retVal;
}
use of org.nhindirect.stagent.options.OptionsParameter in project nhin-d by DirectProject.
the class CRLRevocationManager_initCRLCacheLocationTest method setUp.
@Override
public void setUp() {
CryptoExtensions.registerJCEProviders();
CRLRevocationManager.initCRLCacheLocation();
CRLRevocationManager.getInstance().flush();
CRLRevocationManager.crlCacheLocation = null;
OptionsManager.getInstance().setOptionsParameter(new OptionsParameter(OptionsParameter.CRL_CACHE_LOCATION, ""));
}
Aggregations