use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ImportBulkFederationData method handleIDFFRequest.
private void handleIDFFRequest(Map nameIds) throws CLIException {
for (Iterator i = nameIds.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String userId = (String) e.getKey();
String nameId = (String) e.getValue();
idffFederateUser(userId, nameId);
}
IOutput outputWriter = getOutputWriter();
outputWriter.printlnMessage(getResourceString("import-bulk-federation-data-succeeded"));
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class ImportBulkFederationData method handleSAML2Request.
private void handleSAML2Request(Map nameIds) throws CLIException {
for (Iterator i = nameIds.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String userId = (String) e.getKey();
String nameId = (String) e.getValue();
saml2FederateUser(userId, nameId);
}
IOutput outputWriter = getOutputWriter();
outputWriter.printlnMessage(getResourceString("import-bulk-federation-data-succeeded"));
}
use of com.sun.identity.cli.IOutput 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.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class AddSubConfiguration method addSubConfigToRealm.
private void addSubConfigToRealm(String realmName, String serviceName, String subConfigName, String subConfigId, Map attrValues, int priority) throws CLIException {
SSOToken adminSSOToken = getAdminSSOToken();
IOutput outputWriter = getOutputWriter();
String[] params = { realmName, subConfigName, serviceName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_CONFIGURATION_TO_REALM", params);
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
ServiceConfig sc = scm.getOrganizationConfig(realmName, null);
if (sc == null) {
sc = scm.createOrganizationConfig(realmName, null);
}
addSubConfig(sc, subConfigName, subConfigId, attrValues, priority);
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_CONFIGURATION_TO_REALM", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-sub-configuration-to-realm-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
debugError("AddSubConfiguration.addSubConfigToRealm", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
debugError("AddSubConfiguration.addSubConfigToRealm", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cli.IOutput in project OpenAM by OpenRock.
the class AddSubSchema method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
String fileName = getStringOptionValue(ARGUMENT_FILENAME);
if (subSchemaName == null) {
subSchemaName = "/";
}
IOutput outputWriter = getOutputWriter();
String[] params = { serviceName, schemaType, subSchemaName };
ServiceSchema ss = getServiceSchema();
CommandManager mgr = getCommandManager();
String url = mgr.getWebEnabledURL();
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_SCHEMA", params);
try {
if ((url != null) && (url.length() > 0)) {
ss.addSubSchema(new ByteArrayInputStream(fileName.getBytes()));
} else {
ss.addSubSchema(new FileInputStream(fileName));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_SCHEMA", params);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-subschema-succeed"), (Object[]) params));
} catch (SSOException e) {
String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
debugError("AddSubSchema.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
debugError("AddSubSchema.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
String[] args = { serviceName, schemaType, subSchemaName, e.getMessage() };
debugError("AddSubSchema.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_SCHEMA", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations