use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class SpecialRepo method updateServiceConfiguration.
private void updateServiceConfiguration(String urlAccessAgentCryptPwd) throws IdRepoException, SSOException {
if (urlAccessAgentCryptPwd != null) {
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
Set<String> set = new HashSet<String>();
set.add(urlAccessAgentCryptPwd);
map.put(Constants.AM_SERVICES_SECRET, set);
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
String instance = SystemProperties.getServerInstanceName();
try {
ServerConfiguration.setServerInstance(adminToken, instance, map);
} catch (SMSException e) {
debug.error("SpecialRepo.updateServiceConfiguration", e);
Object[] args = { NAME, IdOperation.EDIT.getName() };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
} catch (IOException e) {
debug.error("SpecialRepo.updateServiceConfiguration", e);
Object[] args = { NAME, IdOperation.EDIT.getName() };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
} catch (ConfigurationException e) {
debug.error("SpecialRepo.updateServiceConfiguration", e);
Object[] args = { NAME, IdOperation.EDIT.getName() };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_SYNC_URL_ACCESS_AGENT, args);
} catch (UnknownPropertyNameException e) {
// never happen
}
}
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method createServer.
/**
* Creates a server.
*
* @param name Name of Server.
* @throws AMConsoleException if error occurs when creating server.
*/
public void createServer(String name) throws AMConsoleException {
SSOToken ssoToken = getUserSSOToken();
String[] param = { name };
logEvent("ATTEMPT_CREATE_SERVER", param);
try {
String svrConfigXML = ServerConfiguration.getServerConfigXML(ssoToken, SystemProperties.getServerInstanceName());
ServerConfiguration.createServerInstance(ssoToken, name, Collections.EMPTY_MAP, svrConfigXML);
logEvent("SUCCEED_CREATE_SERVER", param);
} catch (UnknownPropertyNameException e) {
// this will not happen because we do not set any property during
// creation.
} catch (SSOException e) {
String[] params = { name, e.getMessage() };
logEvent("SSO_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
} catch (ConfigurationException e) {
String[] params = { name, e.getMessage() };
logEvent("CONFIGURATION_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { name, e.getMessage() };
logEvent("SMS_EXCEPTION_CREATE_SITE", params);
throw new AMConsoleException(getErrorString(e));
} catch (IOException e) {
String[] params = { name, e.getMessage() };
logEvent("IO_EXCEPTION_CREATE_SERVER", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class ServerSiteModelImpl method updateServerConfigInheritance.
/**
* Updates server property inheritance settings.
*
* @param serverName Name of server.
* @param toInherit Properties to inherit.
* @param notToInherit Properties not to inherit.
* @throws AMConsoleException if server profile cannot be updated.
*/
public void updateServerConfigInheritance(String serverName, Set toInherit, Set notToInherit) throws AMConsoleException {
String[] param = { serverName };
logEvent("ATTEMPT_MODIFY_SERVER_INHERITANCE", param);
try {
SSOToken ssoToken = getUserSSOToken();
Map defaultValues = ServerConfiguration.getDefaults(ssoToken);
Map svrProperties = ServerConfiguration.getServerInstance(ssoToken, serverName);
if ((toInherit != null) && !toInherit.isEmpty()) {
Set toRemove = new HashSet();
for (Iterator i = toInherit.iterator(); i.hasNext(); ) {
String name = (String) i.next();
if (svrProperties.containsKey(name)) {
toRemove.add(name);
}
}
if (!toRemove.isEmpty()) {
ServerConfiguration.removeServerConfiguration(ssoToken, serverName, toRemove);
}
}
if ((notToInherit != null) && !notToInherit.isEmpty()) {
Map toAdd = new HashMap();
for (Iterator i = notToInherit.iterator(); i.hasNext(); ) {
String name = (String) i.next();
if (!svrProperties.containsKey(name)) {
toAdd.put(name, defaultValues.get(name));
}
}
if (!toAdd.isEmpty()) {
try {
ServerConfiguration.setServerInstance(ssoToken, serverName, toAdd);
} catch (UnknownPropertyNameException ex) {
// ignore, this cannot happen because default values
// would have all valid property names
}
}
}
logEvent("SUCCEED_MODIFY_SERVER_INHERITANCE", param);
} catch (ConfigurationException e) {
String[] params = { serverName, e.getMessage() };
logEvent("CONFIGURATION_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (IOException e) {
String[] params = { serverName, e.getMessage() };
logEvent("IO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SMSException e) {
String[] params = { serverName, e.getMessage() };
logEvent("SMS_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
String[] params = { serverName, e.getMessage() };
logEvent("SSO_EXCEPTION_MODIFY_SERVER_INHERITANCE", params);
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.common.configuration.UnknownPropertyNameException in project OpenAM by OpenRock.
the class UpdateServerConfig 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();
IOutput outputWriter = getOutputWriter();
String serverName = getStringOptionValue(IArgument.SERVER_NAME);
String datafile = getStringOptionValue(IArgument.DATA_FILE);
List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
if ((datafile == null) && (attrValues == null)) {
throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
}
Map attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
encryptPasswordAttributes(attributeValues);
String[] params = { serverName };
try {
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_SERVER_CONFIG", params);
if (serverName.equals(DEFAULT_SVR_CONFIG)) {
try {
ServerConfiguration.setServerInstance(adminSSOToken, ServerConfiguration.DEFAULT_SERVER_CONFIG, attributeValues);
} catch (UnknownPropertyNameException ex) {
outputWriter.printlnMessage(ex.getL10NMessage(getCommandManager().getLocale()));
outputWriter.printlnMessage("");
}
outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-succeeded"), (Object[]) params));
} else {
if (ServerConfiguration.isServerInstanceExist(adminSSOToken, serverName)) {
try {
ServerConfiguration.setServerInstance(adminSSOToken, serverName, attributeValues);
} catch (UnknownPropertyNameException ex) {
outputWriter.printlnMessage(getResourceString("update-server-config-unknown"));
outputWriter.printlnMessage("");
}
outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-succeeded"), (Object[]) params));
} else {
outputWriter.printlnMessage(MessageFormat.format(getResourceString("update-server-config-does-not-exists"), (Object[]) params));
}
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_UPDATE_SERVER_CONFIG", params);
} catch (ConfigurationException e) {
String[] args = { serverName, e.getMessage() };
debugError("UpdateServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (IOException e) {
String[] args = { serverName, e.getMessage() };
debugError("UpdateServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] args = { serverName, e.getMessage() };
debugError("UpdateServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
String[] args = { serverName, e.getMessage() };
debugError("UpdateServerConfig.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_SERVER_CONFIG", args);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations