use of com.iplanet.services.util.JCEEncryption in project OpenAM by OpenRock.
the class ImportServiceConfiguration method importData.
private void importData(String xmlFile, String encryptSecret, SSOToken ssoToken) throws CLIException, SSOException, SMSException, IOException {
// set the correct password encryption key.
// without doing so, the default encryption key will be used.
String encKey = getEncKey(xmlFile);
if (encKey != null) {
SystemProperties.initializeProperties(Constants.ENC_PWD_PROPERTY, encKey);
Crypt.reinitialize();
}
IOutput outputWriter = getOutputWriter();
FileInputStream fis = null;
try {
AMEncryption encryptObj = new JCEEncryption();
((ConfigurableKey) encryptObj).setPassword(encryptSecret);
ServiceManager ssm = new ServiceManager(ssoToken);
fis = new FileInputStream(xmlFile);
ssm.registerServices(fis, encryptObj);
InitializeSystem initSys = CommandManager.initSys;
String instanceName = initSys.getInstanceName();
String serverConfigXML = initSys.getServerConfigXML();
ServerConfiguration.setServerConfigXML(ssoToken, instanceName, serverConfigXML);
outputWriter.printlnMessage(getResourceString("import-service-configuration-succeeded"));
} catch (IOException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (Exception e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ie) {
//ignore if file input stream cannot be closed.
}
}
}
}
use of com.iplanet.services.util.JCEEncryption in project OpenAM by OpenRock.
the class JCECrypt method createInstance.
private static AMEncryption createInstance(String password) {
AMEncryption instance;
// Construct the encryptor class
String encClass = System.getProperty(ENCRYPTOR_CLASS_PROPERTY, DEFAULT_ENCRYPTOR_CLASS);
try {
instance = Class.forName(encClass).asSubclass(AMEncryption.class).newInstance();
} catch (Exception e) {
Debug debug = Debug.getInstance("amSDK");
debug.error("JCECrypt.createInstance Unable to get class instance: " + encClass + ", falling back to the" + " default implementation: " + DEFAULT_ENCRYPTOR_CLASS, e);
instance = new JCEEncryption();
}
try {
((ConfigurableKey) instance).setPassword(password);
} catch (Exception e) {
Debug debug = Debug.getInstance("amSDK");
if (debug != null) {
debug.error("JCECrypt.createInstance: failed to set password-based key", e);
}
}
return instance;
}
Aggregations