use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class ConfigMonitoring method getMonServiceAttrs.
private int getMonServiceAttrs() {
String classMethod = "ConfigMonitoring.getMonServiceAttrs: ";
try {
ServiceSchemaManager schemaManager = new ServiceSchemaManager("iPlanetAMMonitoringService", ssoToken);
ServiceSchema smsMonSchema = schemaManager.getGlobalSchema();
Map monAttrs = smsMonSchema.getAttributeDefaults();
boolean monEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-enabled")).booleanValue();
if (!monEna) {
if (debug.warningEnabled()) {
debug.warning(classMethod + "monitoring is disabled");
}
return -1;
}
boolean httpEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-http-enabled")).booleanValue();
int httpPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-http-port"));
String authFilePath = CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-authfile-path");
int rmiPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-rmi-port"));
boolean rmiEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-rmi-enabled")).booleanValue();
int snmpPort = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-snmp-port"));
boolean snmpEna = Boolean.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-snmp-enabled")).booleanValue();
int policyWindow = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-policy-window"));
int sessionWindow = Integer.valueOf(CollectionHelper.getMapAttr(monAttrs, "iplanet-am-monitoring-session-window"));
if (debug.messageEnabled()) {
debug.message(classMethod + "\n" + " monitoring enabled = " + monEna + "\n" + " monitoring auth filepath = " + authFilePath + "\n" + " httpPort = " + httpPort + "\n" + " httpPort enabled = " + httpEna + "\n" + " rmiPort = " + rmiPort + "\n" + " rmiPort enabled = " + rmiEna + "\n" + " snmpPort = " + snmpPort + "\n" + " snmpPort enabled = " + snmpEna + "\n" + " policy eval window size = " + policyWindow + "\n" + " session eval window size = " + sessionWindow + "\n");
}
SSOServerMonConfig sMonInfo = new SSOServerMonConfig.SSOServerMonInfoBuilder(monEna).htmlPort(httpPort).htmlAuthFile(authFilePath).snmpPort(snmpPort).rmiPort(rmiPort).monHtmlEnabled(httpEna).monRmiEnabled(rmiEna).monSnmpEnabled(snmpEna).policyWindowSize(policyWindow).sessionWindowSize(sessionWindow).build();
int i = Agent.startAgent(sMonInfo);
if (i != 0) {
if (debug.warningEnabled()) {
debug.warning(classMethod + "Monitoring Agent not started (" + i + ")");
}
return (i);
}
} catch (Exception ex) {
debug.error(classMethod + "error reading Monitoring attributes: ", ex);
return (Agent.MON_READATTRS_PROBLEM);
}
return 0;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class DisplayOptionsUtils method getServiceConfiguration.
/**
* Returns a map of attribute name to its values of a service configuration.
*/
private static Map getServiceConfiguration(SSOToken ssoToken, String serviceName, SchemaType type) throws SMSException, SSOException {
Map attrMap = Collections.EMPTY_MAP;
if (type != SchemaType.POLICY) {
ServiceSchemaManager scm = new ServiceSchemaManager(serviceName, ssoToken);
attrMap = scm.getSchema(type).getAttributeDefaults();
}
return attrMap;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class PropertiesFinder method getProperty.
public static String getProperty(String propertyName, AttributeStruct ast) {
String value = null;
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(ast.serviceName, adminToken);
if (ssm.getRevisionNumber() >= ast.revisionNumber) {
ServiceSchema ss = ssm.getGlobalSchema();
if (ss != null) {
AttributeSchema as = ss.getAttributeSchema(ast.attributeName);
if (as != null) {
Set values = as.getDefaultValues();
if ((values != null) && !values.isEmpty()) {
value = (String) values.iterator().next();
}
}
}
}
} catch (SSOException ex) {
// ignore: Service may not be present.
} catch (SMSException ex) {
// ignore: Service may not be present.
}
return value;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class PossibleLocales method getChoiceValues.
/**
* Returns a map of locales to its localized name.
*
* @return a map of locales to its localized name.
*/
public Map getChoiceValues() {
Map map = new HashMap();
/*
* provides a blank value because preferred locale attribute value can
* be blanked.
*/
map.put("", "-");
ServiceSchemaManager mgr = getG11NServiceSchemaManager();
Set values = DEFAULT_LOCALES;
if (mgr != null) {
AttributeSchema attributeSchema = getLocaleCharsetMappingAttributeSchema(mgr);
if (attributeSchema != null) {
values = attributeSchema.getDefaultValues();
}
}
if ((values != null) && !values.isEmpty()) {
for (Iterator iter = values.iterator(); iter.hasNext(); ) {
String locale = parseLocaleCharsetValue((String) iter.next());
if ((locale != null) && (locale.length() > 0)) {
map.put(locale, locale);
}
}
}
return map;
}
use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.
the class ShowConfigurations method handleRequest.
/**
* Services a Commandline Request.
*
* @param rc Request Context.
* @throws CLIException if the request cannot serviced.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SHOW_ENTITLEMENT_SVC", null);
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(EntitlementService.SERVICE_NAME, getAdminSSOToken());
ServiceSchema gss = ssm.getGlobalSchema();
Map<String, Set<String>> defaults = gss.getAttributeDefaults();
getOutputWriter().printlnMessage(FormatUtils.printAttributeValues(getResourceString("get-attr-values-of-entitlement-service"), defaults));
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_SHOW_ENTITLEMENT_SVC", null);
} catch (SMSException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_SHOW_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (SSOException e) {
String[] paramExs = { e.getMessage() };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_SHOW_ENTITLEMENT_SVC", paramExs);
throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
Aggregations