use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class CoreTokenConfigService method initServiceConfig.
private synchronized void initServiceConfig() {
try {
SSOToken dsameUserToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceConfigManager mgr = new ServiceConfigManager(CoreTokenConstants.CORE_TOKEN_CONFIG_SERVICE_NAME, dsameUserToken);
ServiceConfig globalConf = mgr.getGlobalConfig(null);
if (globalConf != null) {
Map<String, Set<String>> map = globalConf.getAttributes();
if (map != null) {
Set<String> set = map.get(IMPL_CLASS_ATTR);
if ((set != null) && !set.isEmpty()) {
implClassName = set.iterator().next();
}
set = map.get(SEARCHABLE_ATTR);
Set<String> tmpSet = new HashSet<String>();
if ((set != null) && !set.isEmpty()) {
Iterator<String> it = set.iterator();
while (it.hasNext()) {
tmpSet.add(it.next().toLowerCase());
}
}
searchableAttrs = tmpSet;
set = map.get(CLEANUP_INTERVAL);
if ((set != null) && !set.isEmpty()) {
String tmp = set.iterator().next();
try {
cleanupInt = Integer.parseInt(tmp) * 1000;
} catch (NumberFormatException ne) {
CoreTokenUtils.debug.error("CoreTokenConfigService" + ".init. invalid interval : " + tmp, ne);
cleanupInt = DEFAULT_CLEANUP_INTERVAL;
}
}
set = map.get(TYPES_WITHOUT_ETAG_ENFORCE);
tmpSet = new HashSet<String>();
if ((set != null) && !set.isEmpty()) {
Iterator<String> it = set.iterator();
while (it.hasNext()) {
tmpSet.add(it.next().toLowerCase());
}
}
noETagEnfTypes = tmpSet;
}
}
if (CoreTokenUtils.debug.messageEnabled()) {
CoreTokenUtils.debug.message("CoreTokenConfigServcie.init: " + "searchable Attrs=" + searchableAttrs + "; token store impl class=" + implClassName + "; cleanup interval=" + cleanupInt + "; token types without ETag enforcement=" + noETagEnfTypes);
}
} catch (SMSException ex) {
CoreTokenUtils.debug.error("CoreTokenConfigService.init", ex);
} catch (SSOException ex) {
CoreTokenUtils.debug.error("CoreTokenConfigService.init", ex);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class IdRepoUtils method loadIdRepoSchema.
/**
* Loads schema to specified IdRepo.
*
* @param ssoToken single sign on token of authenticated user identity
* @param idRepoName IdRepo name
* @param realm the realm
* @param servletCtx the servlet context
*
* @throws IdRepoException If schema can't be loaded or there are
* repository related error conditions.
*/
public static void loadIdRepoSchema(SSOToken ssoToken, String idRepoName, String realm, ServletContext servletCtx) throws IdRepoException {
if (servletCtx == null) {
return;
}
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, ssoToken);
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realm, null);
ServiceConfig ss = cfg.getSubConfig(idRepoName);
if (ss == null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRepoUtils.loadIdRepoSchema: data store " + idRepoName + " for realm " + realm + " doesn't exist.");
}
Object[] args = { idRepoName, realm };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.PLUGIN_DOESNT_EXIST_FOR_REALM, args);
}
String idRepoType = ss.getSchemaID();
Map attrValues = ss.getAttributes();
String schemaFiles = getSchemaFiles(idRepoType);
if ((schemaFiles == null) || (schemaFiles.trim().length() == 0)) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRepoUtils.loadIdRepoSchema: data store " + idRepoName + " for realm " + realm + " doesn't have " + "schema files.");
}
return;
}
StringTokenizer st = new StringTokenizer(schemaFiles);
while (st.hasMoreTokens()) {
String schemaFile = st.nextToken();
tagSwapAndImportSchema(schemaFile, attrValues, servletCtx, idRepoType);
}
} catch (SMSException smsex) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRepoUtils.loadIdRepoSchema:", smsex);
}
Object[] args = { idRepoName, realm };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_READ_PLUGIN_FOR_REALM, args);
} catch (SSOException ssoex) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRepoUtils.loadIdRepoSchema:", ssoex);
}
Object[] args = { idRepoName, realm };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_READ_PLUGING_FOR_REALM_SSOTOKEN_NOT_VALID, args);
} catch (Exception ex) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRepoUtils.loadIdRepoSchema:", ex);
}
Object[] args = { idRepoName, realm, ex.getMessage() };
throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.UNABLE_LOAD_SCHEMA_FOR_PLUGIN_FOR_REALM, args);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class IdRepoPluginsCache method initializeListeners.
protected void initializeListeners() {
synchronized (debug) {
if (!initializedListeners) {
// Add listeners to Service Schema and Config Managers
if (debug.messageEnabled()) {
debug.message("IdRepoPluginsCache.initializeListeners: " + "setting up ServiceListener");
}
SSOToken token = getAdminToken();
try {
// Initialize configuration objects
idRepoServiceConfigManager = new ServiceConfigManager(token, IdConstants.REPO_SERVICE, "1.0");
idRepoServiceConfigManager.addListener(this);
// Initialize schema objects
ServiceSchemaManager idRepoServiceSchemaManager = new ServiceSchemaManager(token, IdConstants.REPO_SERVICE, "1.0");
idRepoServiceSchemaManager.addListener(this);
// Get the version number
svcRevisionNumber = idRepoServiceSchemaManager.getRevisionNumber();
// Initialize listener for JAXRPCObject
IdRepoListener.addRemoteListener(new JAXRPCObjectImplEventListener());
initializedListeners = true;
} catch (SMSException smse) {
// Exceptions will be throws during install and config
// when these services will not be loaded
String installTime = SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
if (!installTime.equals("true")) {
debug.error("IdRepoPluginsCache.initializeListeners: " + "Unable to set up a service listener for IdRepo", smse);
}
} catch (SSOException ssoe) {
debug.error("IdRepoPluginsCache.initializeListeners: " + "Unable to set up a service listener for IdRepo.", ssoe);
}
}
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class AgentIdentityImpl method getAgentServiceConfig.
private ServiceConfig getAgentServiceConfig(SSOToken token) {
AMIdentity identity;
try {
identity = IdUtils.getIdentity(token);
} catch (IdRepoException | SSOException e) {
debug.error("Exception while obtaining identity corresponding to SSOToken: {}", e, e);
return null;
}
// before instantiating a ServiceConfigManager.
if (!IdType.AGENT.equals(identity.getType())) {
debug.message("Not an agent");
return null;
}
ServiceConfig agentService;
try {
agentService = new ServiceConfigManager(AGENT_SERVICE_NAME, getAdminToken()).getOrganizationConfig(identity.getRealm(), null);
} catch (Exception e) {
debug.error("Exception while obtaining base AgentService ServiceConfig instance: {}", e, e);
return null;
}
try {
return agentService.getSubConfig(identity.getName());
} catch (SSOException | SMSException e) {
// Should only enter this block if the return from getAdminToken is an invalid token
// or if an error occurs accessing LDAP.
debug.error("Exception while obtaining AgentService SubConfig {}: {}", identity.getName(), e, e);
return null;
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class UpgradeUtils method createOrganizationConfiguration.
/**
* Creates <code>OrganizationConfiguration</code> in a service.
*
* @param serviceName name of the service
* @param orgName name of the organization
* @param attrValues map of attribute names and their values. The
* key is the attribute name a string and the values is a Set
* of values.
*/
public static void createOrganizationConfiguration(String serviceName, String orgName, Map attrValues) {
String classMethod = "UpgradeUtils:createOrganizationConfiguration: ";
try {
ServiceConfigManager sm = getServiceConfigManager(serviceName);
sm.createOrganizationConfig(orgName, attrValues);
} catch (Exception e) {
debug.error(classMethod + "Error creating organization " + "configuration for " + serviceName, e);
}
}
Aggregations