use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AccessControlModelImpl method getServiceNames.
private Set getServiceNames() {
if (serviceNames == null) {
SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceManager sm = new ServiceManager(adminSSOToken);
serviceNames = sm.getServiceNames();
} catch (SSOException e) {
AMModelBase.debug.error("AccessControlModelImpl.getServiceNames", e);
} catch (SMSException e) {
AMModelBase.debug.error("AccessControlModelImpl.getServiceNames", e);
}
}
return serviceNames;
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AddAMSDKIdRepoPlugin method loadDAIService.
private String loadDAIService() throws SMSException, SSOException, CLIException, IOException {
SSOToken adminSSOToken = getAdminSSOToken();
// Load DAI service, if not already loaded
String xmlData = null;
ServiceManager sm = new ServiceManager(adminSSOToken);
if (!sm.getServiceNames().contains("DAI")) {
xmlData = getResourceContent("ums.xml");
// Tag swap: @USER_NAMING_ATTR & @ORG_NAMING_ATTR
xmlData = xmlData.replaceAll("@USER_NAMING_ATTR@", namingAttr);
xmlData = xmlData.replaceAll("@ORG_NAMING_ATTR@", orgAttr);
registerService(xmlData, adminSSOToken);
}
return xmlData;
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AddAMSDKIdRepoPlugin method registerService.
private void registerService(String xml, SSOToken adminSSOToken) throws SSOException, SMSException, IOException {
ServiceManager serviceManager = new ServiceManager(adminSSOToken);
InputStream serviceStream = null;
try {
serviceStream = (InputStream) new ByteArrayInputStream(xml.getBytes());
serviceManager.registerServices(serviceStream);
} finally {
if (serviceStream != null) {
serviceStream.close();
}
}
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AddPluginSchema 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();
SSOToken adminSSOToken = getAdminSSOToken();
String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
String interfaceName = getStringOptionValue(ARGUMENT_INTERFACE_NAME);
String pluginName = getStringOptionValue(ARGUMENT_PLUGIN_NAME);
String i18nKey = getStringOptionValue(ARGUMENT_I18N_KEY);
String i18nName = getStringOptionValue(ARGUMENT_I18N_NAME);
String className = getStringOptionValue(ARGUMENT_CLASS_NAME);
ServiceManager sm = null;
try {
sm = new ServiceManager(adminSSOToken);
} catch (SMSException smse) {
throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException ssoe) {
throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
IOutput outputWriter = getOutputWriter();
try {
String[] params = { serviceName, interfaceName, pluginName, i18nKey, i18nName, className };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_PLUGIN_SCHEMA", params);
Document pluginDoc = createPluginSchemaXML(serviceName, interfaceName, pluginName, i18nKey, i18nName, className);
if (pluginDoc != null) {
sm.addPluginSchema(pluginDoc);
String[] params2 = { serviceName, pluginName };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_PLUGIN_SCHEMA", params2);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-succeed"), (Object[]) params));
} else {
String[] args = { serviceName, pluginName, "Null XML Document" };
debugError("AddPluginSchema.handleRequest:: Null XML Document");
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
throw new CLIException("Null XML Document", ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
} catch (SSOException ssoe) {
String[] args = { serviceName, pluginName, ssoe.getMessage() };
debugError("AddPluginSchema.handleRequest", ssoe);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
throw new CLIException(ssoe, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException smse) {
String[] args = { serviceName, pluginName, smse.getMessage() };
debugError("AddPluginSchema.handleRequest", smse);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_PLUGIN_SCHEMA", args);
outputWriter.printlnMessage(MessageFormat.format(getResourceString("add-plugin-schema-failed"), (Object[]) args));
throw new CLIException(smse, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class DefaultDebugRecorder method exportConfigExport.
/**
* Export the OpenAM config export
*/
private void exportConfigExport() {
if (currentRecord.getRecordProperties().isConfigExportEnabled()) {
SSOToken adminSSOToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceManager sm = new ServiceManager(adminSSOToken);
AMEncryption encryptObj = new JCEEncryption();
((ConfigurableKey) encryptObj).setPassword(currentRecord.getRecordProperties().getConfigExportPassword());
String resultXML = sm.toXML(encryptObj);
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_UID);
String xmlName = RecordConstants.OPENAM_CONFIG_EXPORT_FILE_NAME.replace("$DATE$", dateFormat.format(new Date()));
File file = new File(currentRecord.getFolderPath() + File.separator + xmlName);
PrintWriter printWriter = new PrintWriter(new FileWriter(file, false), true);
printWriter.println(resultXML);
printWriter.flush();
} catch (Exception e) {
debug.error("Can't export OpenAM configuration", e);
}
}
}
Aggregations