use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class AuthUtils method getZeroPageLoginConfig.
/**
* Gets the ZPL configuration for the given realm.
*
* @param realm the realm to get the ZPL configuration for. Not null.
* @return the ZPL configuration object. Never null.
* @throws SSOException if there is a problem authenticating the configuration lookup.
* @throws SMSException if there is a problem fetching the configuration data.
*/
public static ZeroPageLoginConfig getZeroPageLoginConfig(final String realm) throws SSOException, SMSException {
Reject.ifNull(realm);
final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
final ServiceConfigManager mgr = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, token);
final ServiceConfig serviceConfig = mgr.getOrganizationConfig(realm, null);
@SuppressWarnings("unchecked") final Map<String, Set<String>> configMap = serviceConfig.getAttributes();
return new ZeroPageLoginConfig(CollectionHelper.getBooleanMapAttr(configMap, Constants.ZERO_PAGE_LOGIN_ENABLED, false), configMap.get(Constants.ZERO_PAGE_LOGIN_WHITELIST), CollectionHelper.getBooleanMapAttr(configMap, Constants.ZERO_PAGE_LOGIN_ALLOW_MISSING_REFERER, true));
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class AllowedModulesChoiceValues method getChoiceValues.
/**
* Returns choice values from environment parameters
* @param envParams map of environment parameters
* @return choice values from environment parameters
*/
public Map getChoiceValues(Map envParams) {
// Get default choice values
getChoiceValues();
Set serviceNames = null;
String orgDN = null;
Map registeredServices = new HashMap();
if (envParams != null) {
orgDN = (String) envParams.get(Constants.ORGANIZATION_NAME);
}
if (orgDN == null || orgDN.length() == 0) {
orgDN = SMSEntry.getRootSuffix();
}
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
OrganizationConfigManager orgConfig = getOrgConfigManager(orgDN, adminToken);
serviceNames = orgConfig.getAssignedServices();
} catch (Exception e) {
// this Exception should have been (or will be) caught by the
// caller of of this plugin(console). it does not worth to
// duplicate log/debug here.
}
if (serviceNames != null) {
for (Iterator ite = choiceValues.keySet().iterator(); ite.hasNext(); ) {
String value = (String) ite.next();
if (serviceRegistered(value, serviceNames)) {
registeredServices.put(value, value);
} else {
String serviceName = AuthUtils.getModuleServiceName(value);
try {
new ServiceConfigManager(serviceName, adminToken);
} catch (SMSException e) {
// services don't have template.
registeredServices.put(value, value);
} catch (Exception e) {
// SSO, do nothing
}
}
}
}
return registeredServices;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class CommonUtils method populateManagedObjects.
protected static boolean populateManagedObjects() {
try {
ServiceConfigManager scm = new ServiceConfigManager("DAI", getInternalToken());
ServiceConfig gc = scm.getGlobalConfig(null);
Set managedObjects = gc.getSubConfigNames("*", "ManagedObjects");
if (managedObjects == null || managedObjects.isEmpty()) {
debug.message("CommonUtils.populateManagedObject " + "managedObjects=null");
return false;
// populateManagedObjectsWithDefaults();
}
Iterator mIter = managedObjects.iterator();
while (mIter.hasNext()) {
String mo = (String) mIter.next();
mo = mo.toLowerCase();
ServiceConfig sc = gc.getSubConfig(mo);
if (sc != null) {
Map attrs = sc.getAttributes();
Set ocSet = (Set) attrs.get("objectclass");
Set ctSet = (Set) attrs.get("creationtemplatename");
Set stSet = (Set) attrs.get("searchtemplatename");
Set typeSet = (Set) attrs.get("type");
Set stAttr = (Set) attrs.get("statusattribute");
String oc = getObjectClass(ocSet, mo);
String ct = getCreationTemplateName(ctSet, mo);
String st = getSearchTemplateName(stSet, mo);
String stAttrName = getStatusAttributeName(stAttr);
// Assumes a type is always defined in the config.
// TODO be careful with NPE here.
String typeS = (String) typeSet.iterator().next();
// int type = Integer.parseInt(typeS);
supportedTypes.put(mo, typeS);
supportedNames.put(typeS, mo);
if (oc != null) {
ObjectClassManager.objectClassMap.put(typeS, oc);
ObjectClassManager.objectTypeMap.put(oc, typeS);
}
if (st != null)
searchtemplateMap.put(typeS, st);
if (ct != null)
creationtemplateMap.put(typeS, ct);
if (stAttrName != null)
statusAttributeMap.put(typeS, stAttrName);
}
}
if (debug.messageEnabled()) {
debug.message("CreationTemplate MAP = " + creationtemplateMap.toString());
debug.message("SearchTemplate Map = " + searchtemplateMap.toString());
debug.message("ObjectClass-Type Map = " + ObjectClassManager.objectClassMap.toString());
debug.message("Type-ObjectClass MAP = " + ObjectClassManager.objectTypeMap.toString());
debug.message("Supported names-type = " + supportedTypes.toString());
debug.message("Status Attributes= " + statusAttributeMap.toString());
}
} catch (SMSException se) {
return false;
// populateManagedObjectsWithDefaults();
} catch (SSOException ssoe) {
return false;
// populateManagedObjectsWithDefaults();
}
return true;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class DeleteDataStores method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
List names = (List) rc.getOption(DatastoreOptions.DATASTORE_NAMES);
validateRealm(realm);
String[] params = { realm, names.toString() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_DATASTORES", params);
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminSSOToken);
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realm, null);
if (cfg != null) {
for (Iterator i = names.iterator(); i.hasNext(); ) {
cfg.removeSubConfig((String) i.next());
}
if (names.size() > 1) {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastores-succeeded"));
} else {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastore-succeeded"));
}
} else {
getOutputWriter().printlnMessage(getResourceString("datastore-delete-datastore-not-found"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_DATASTORES", params);
} catch (SMSException e) {
debugError("DeleteDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("DeleteDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class ListDataStores method handleRequest.
/**
* Handles request.
*
* @param rc Request Context.
* @throws CLIException if request cannot be processed.
*/
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
SSOToken adminSSOToken = getAdminSSOToken();
String realm = getStringOptionValue(IArgument.REALM_NAME);
validateRealm(realm);
String[] params = { realm };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_DATASTORES", params);
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminSSOToken);
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realm, null);
Set names = (cfg != null) ? cfg.getSubConfigNames() : Collections.EMPTY_SET;
if ((names != null) && !names.isEmpty()) {
getOutputWriter().printlnMessage(getResourceString("datastore-list-datastores-succeeded"));
for (Iterator i = names.iterator(); i.hasNext(); ) {
String name = (String) i.next();
getOutputWriter().printlnMessage(name);
}
} else {
getOutputWriter().printlnMessage(getResourceString("datastore-list-datastores-no-entries"));
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_DATASTORES", params);
} catch (SMSException e) {
debugError("ListDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
debugError("ListDataStores.handleRequest", e);
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_DATASTORES", params);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations