use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SMServiceListener method registerForNotifications.
public void registerForNotifications() {
if (listenerId != null) {
// Listener already registered
return;
}
SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
// Try Delegation Service, present only in OpenSSO
// Since Delegation Service is being added only in OpenSSO
// check for its presence in root realm. If not present,
// it is an upgrade from AM 7.1 and use AuthService
ServiceConfigManager scm = null;
try {
scm = new ServiceConfigManager(DelegationManager.DELEGATION_SERVICE, token);
if (scm.getOrganizationConfig("/", null) == null) {
// Delegation Service does not exist for realm
// Default to auth service
scm = null;
}
} catch (SMSException smse) {
// Ignore exception and continue with Auth Service
}
if (scm == null) {
// Delegation Service not found, use Auth service
scm = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, token);
}
listenerId = scm.addListener(this);
} catch (SMSException ex) {
debug.error("Unable to register SMS notification for Delegation", ex);
} catch (SSOException ex) {
debug.error("Unable to register SMS notification for Delegation", ex);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SpecialRepo method getUserConfig.
private ServiceConfig getUserConfig() throws SMSException, SSOException {
if ((userConfigCache == null) || !userConfigCache.isValid()) {
if (scm == null) {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
scm = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
}
ServiceConfig globalConfig = scm.getGlobalConfig(null);
userConfigCache = globalConfig.getSubConfig("users");
}
return (userConfigCache);
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SpecialRepo method addListener.
/*
* (non-Javadoc)
*
* @see com.sun.identity.idm.IdRepo#addListener(com.iplanet.sso.SSOToken,
* com.iplanet.am.sdk.IdRepoListener)
*/
public int addListener(SSOToken token, IdRepoListener listener) throws IdRepoException, SSOException {
if (debug.messageEnabled()) {
debug.message(": SpecialRepo addListener");
}
repoListener = listener;
try {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
if (ssm == null) {
ssm = new ServiceSchemaManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
}
if (scm == null) {
scm = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
}
ssmListenerId = ssm.addListener(this);
scmListenerId = scm.addListener(this);
} catch (SMSException smse) {
debug.error("SpecialRepo.addListener: Unable to add listener to" + " SM Updates to special users will not reflect", smse);
}
return 0;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class STSInstanceConfigStoreBase method updateSTSInstance.
/**
* Updates attributes corresponding to the existing STS instance.
* @param stsInstanceId the identifier for the to-be-updated sts instance
* @param realm The realm in which the sts instance should be deployed
* @param instance The updated STSInstanceConfig subclass
* @throws STSPublishException if the SMS encounters a problem during persistence.
*/
@Override
public synchronized void updateSTSInstance(String stsInstanceId, String realm, T instance) throws STSPublishException {
/*
Model for code below taken from AuthPropertiesModelImpl#setValues
*/
ServiceConfig baseService;
try {
baseService = new ServiceConfigManager(serviceName, getAdminToken()).getOrganizationConfig(realm, null);
if (baseService != null) {
ServiceConfig serviceConfig = baseService.getSubConfig(stsInstanceId);
if (serviceConfig != null) {
serviceConfig.setAttributes(instanceConfigMarshaller.toMap(instance));
logger.debug(restOrSoap() + "sts instance " + stsInstanceId + " in realm " + realm + " updated in persistent store.");
} else {
throw new STSPublishException(ResourceException.NOT_FOUND, "Could not create ServiceConfig for realm " + realm + " in order to update " + restOrSoap() + " sts instance with id " + stsInstanceId);
}
} else {
throw new STSPublishException(ResourceException.NOT_FOUND, "Could not create ServiceConfigManager for realm " + realm + " in order to update " + restOrSoap() + " sts instance with id " + stsInstanceId);
}
} catch (SMSException | SSOException e) {
throw new STSPublishException(ResourceException.INTERNAL_ERROR, "Exception caught updating " + restOrSoap() + " sts instance with id " + stsInstanceId + " in realm " + realm + ". Exception: " + e, e);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class STSInstanceConfigStoreBase method getPublishedInstances.
@Override
@SuppressWarnings("unchecked")
public List<T> getPublishedInstances(String realm) throws STSPublishException {
List<T> instances = new ArrayList<>();
ServiceConfig baseService;
try {
baseService = new ServiceConfigManager(serviceName, getAdminToken()).getOrganizationConfig(realm, null);
} catch (SMSException | SSOException e) {
throw new STSPublishException(ResourceException.INTERNAL_ERROR, "Could not obtain ServiceConfig instance for realm " + realm + "." + restOrSoap() + " sts instances for this realm cannot be returned from getAllPublishedInstances(String realm). " + "Exception: " + e, e);
}
if (baseService != null) {
Set<String> subConfigNames;
try {
subConfigNames = baseService.getSubConfigNames();
} catch (SMSException e) {
throw new STSPublishException(ResourceException.INTERNAL_ERROR, "Could not get list of " + restOrSoap() + "sts instances in realm " + realm + ". Exception: " + e, e);
}
for (String stsInstanceId : subConfigNames) {
ServiceConfig instanceService;
try {
instanceService = baseService.getSubConfig(stsInstanceId);
} catch (SSOException | SMSException e) {
logger.error("Could not get " + restOrSoap() + " sts state for id " + stsInstanceId + " in realm " + realm + ". Exception: " + e);
continue;
}
if (instanceService != null) {
Map<String, Set<String>> instanceAttrs = instanceService.getAttributes();
try {
instances.add(instanceConfigMarshaller.fromMapAttributes(instanceAttrs));
} catch (STSPublishException e) {
logger.error("Exception caught in getAllPublishedInstances(String realm) marshalling attributes " + "corresponding to sts " + stsInstanceId + " in realm + " + realm + "; Exception: " + e, e);
}
} else {
logger.error("Could not obtain the " + restOrSoap() + " sts state for instance with id " + stsInstanceId + " in realm " + realm);
}
}
} else {
logger.error("Could not obtain ServiceConfig instance for realm " + realm + "." + restOrSoap() + " sts instances for this realm cannot be returned from getAllPublishedInstances.");
}
return instances;
}
Aggregations