use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class SCConfigModelImpl method getServiceNames.
private void getServiceNames() {
try {
ServiceManager sm = new ServiceManager(getUserSSOToken());
Set serviceNames = sm.getServiceNames();
Set authServices = AMAuthenticationManager.getAuthenticationServiceNames();
if (serviceNames != null) {
for (Iterator i = serviceNames.iterator(); i.hasNext(); ) {
String svcName = (String) i.next();
String sectionName = null;
try {
sectionName = rbServiceTable.getString(svcName);
} catch (MissingResourceException e) {
/*
* we want all authentication services to be displayed
* in the authentication section. The rest of the
* unknown services can be put into the global section.
*/
if (authServices.contains(svcName)) {
sectionName = SEC_AUTH;
} else {
sectionName = SEC_GLOBAL;
}
}
// hide section name with "."
if (!sectionName.equals(".")) {
List list = (List) mapSectionNameToServiceNames.get(sectionName);
if (list == null) {
list = new ArrayList(20);
mapSectionNameToServiceNames.put(sectionName, list);
}
list.add(svcName);
}
}
}
} catch (SSOException ssoe) {
debug.error("SCConfigModelImpl.getServiceNames", ssoe);
} catch (SMSException smse) {
debug.error("SCConfigModelImpl.getServiceNames", smse);
}
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class SmsRequestHandler method createServices.
/**
* Creates a {@link Router} for all the registered services, and then assigns that router to the instance so that
* it will be used for all future requests.
* @throws SMSException From downstream service manager layer.
* @throws SSOException From downstream service manager layer.
*/
private synchronized void createServices() throws SSOException, SMSException {
Map<String, Map<SmsRouteTree, Set<RouteMatcher<Request>>>> serviceRoutes = new HashMap<>();
ServiceManager sm = getServiceManager();
Set<String> serviceNames = sm.getServiceNames();
for (String serviceName : serviceNames) {
Map<SmsRouteTree, Set<RouteMatcher<Request>>> routes = addService(sm, serviceName, DEFAULT_VERSION);
if (routes != null) {
serviceRoutes.put(serviceName, routes);
}
}
if (schemaType == SchemaType.GLOBAL) {
addServersRoutes(sm, serviceRoutes);
}
this.serviceRoutes = serviceRoutes;
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class AMStoreConnection method getServiceHierarchy.
/**
* Returns the service hierarchy for all registered services.
*
* @return the service hierarchy for all registered services.
* @throws AMException
* if an error is encountered in retrieving the service
* hierarchy. The return value is a Set of strings in slash
* format.
*/
public Set getServiceHierarchy() throws AMException {
try {
Set retSet = new HashSet();
ServiceManager sm = new ServiceManager(token);
Set serviceNames = sm.getServiceNames();
Iterator itr = serviceNames.iterator();
while (itr.hasNext()) {
String st = (String) itr.next();
ServiceSchemaManager scm = new ServiceSchemaManager(st, token);
String sh = scm.getServiceHierarchy();
if ((sh != null) && (sh.length() != 0)) {
retSet.add(sh);
}
}
return retSet;
} catch (SSOException so) {
AMCommonUtils.debug.error("AMStoreConnection.getServiceNames(): ", so);
throw new AMException(AMSDKBundle.getString("902", locale), "902");
} catch (SMSException se) {
AMCommonUtils.debug.error("AMStoreConnection.getServiceNames(): ", se);
throw new AMException(AMSDKBundle.getString("905", locale), "905");
}
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class ImportServiceConfiguration method deleteOuServicesDescendents.
private void deleteOuServicesDescendents(SSOToken ssoToken, String ouServices) throws SSOException, SMSException {
CachedSubEntries smsEntry = CachedSubEntries.getInstance(ssoToken, ouServices);
Set children = smsEntry.searchSubOrgNames(ssoToken, "*", false);
for (Iterator i = children.iterator(); i.hasNext(); ) {
String child = (String) i.next();
child = "o=" + child + "," + ouServices;
SMSEntry s = new SMSEntry(ssoToken, child);
s.delete();
}
{
// hardcoding hidden realm, cannot find a better option.
SMSEntry s = new SMSEntry(ssoToken, "o=sunamhiddenrealmdelegationservicepermissions," + ouServices);
s.delete();
}
children = smsEntry.getSubEntries(ssoToken, "*");
for (Iterator i = children.iterator(); i.hasNext(); ) {
String child = (String) i.next();
child = "ou=" + child + "," + ouServices;
SMSEntry s = new SMSEntry(ssoToken, child);
s.delete();
}
ServiceManager mgr = new ServiceManager(ssoToken);
mgr.clearCache();
AMIdentityRepository.clearCache();
}
use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.
the class ImportServiceConfiguration method importData.
private void importData(String xmlFile, String encryptSecret, SSOToken ssoToken) throws CLIException, SSOException, SMSException, IOException {
// set the correct password encryption key.
// without doing so, the default encryption key will be used.
String encKey = getEncKey(xmlFile);
if (encKey != null) {
SystemProperties.initializeProperties(Constants.ENC_PWD_PROPERTY, encKey);
Crypt.reinitialize();
}
IOutput outputWriter = getOutputWriter();
FileInputStream fis = null;
try {
AMEncryption encryptObj = new JCEEncryption();
((ConfigurableKey) encryptObj).setPassword(encryptSecret);
ServiceManager ssm = new ServiceManager(ssoToken);
fis = new FileInputStream(xmlFile);
ssm.registerServices(fis, encryptObj);
InitializeSystem initSys = CommandManager.initSys;
String instanceName = initSys.getInstanceName();
String serverConfigXML = initSys.getServerConfigXML();
ServerConfiguration.setServerConfigXML(ssoToken, instanceName, serverConfigXML);
outputWriter.printlnMessage(getResourceString("import-service-configuration-succeeded"));
} catch (IOException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SMSException e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (Exception e) {
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ie) {
//ignore if file input stream cannot be closed.
}
}
}
}
Aggregations