use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class PolicyModelImpl method getSvcTypeNameToActionsMap.
private Map getSvcTypeNameToActionsMap(Policy policy, String realmName) {
if (mapSvcTypeNameToActions == null) {
try {
Set serviceTypeNames = getServiceTypeNames().keySet();
int sz = serviceTypeNames.size();
mapSvcTypeNameToActions = new HashMap(sz * 2);
mapSvcTypeNameToResBundle = new HashMap(sz * 2);
ServiceTypeManager mgr = getServiceTypeManager();
for (Iterator i = serviceTypeNames.iterator(); i.hasNext(); ) {
String serviceTypeName = (String) i.next();
ServiceType serviceType = mgr.getServiceType(serviceTypeName);
if (serviceType != null) {
ResourceBundle rb = getResourceBundle(serviceType, getUserLocale());
if (rb != null) {
mapSvcTypeNameToResBundle.put(serviceTypeName, rb);
Set as = getActionSchemas(serviceType);
filterActionSchemaWithI18nKey(as);
if ((as != null) && !as.isEmpty()) {
mapSvcTypeNameToActions.put(serviceTypeName, as);
if (requiresResourceName(policy, realmName, serviceTypeName, as, true)) {
requiredResourceNameService.add(serviceTypeName);
}
if (requiresResourceName(policy, realmName, serviceTypeName, as, false)) {
notRequiredResourceNameService.add(serviceTypeName);
}
}
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (SSOException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImppl.getSvcTypeNameToActionsMap", e);
}
}
return mapSvcTypeNameToActions;
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class PolicyModelImpl method getResponseProviderInstance.
private ResponseProvider getResponseProviderInstance(String realmName, String typeName) {
ResponseProvider provider = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ResponseProviderTypeManager mgr = policyMgr.getResponseProviderTypeManager();
provider = mgr.getResponseProvider(typeName);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getResponseProviderInstance", e);
}
return provider;
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class SelectRealmModelImpl method getRealmNames.
/**
* Returns realms that have names matching with a filter.
*
* @param base Base realm name for this search. null indicates root
* suffix.
* @param filter Filter string.
* @return realms that have names matching with a filter.
* @throws AMConsoleException if search fails.
*/
public Set getRealmNames(String base, String filter) throws AMConsoleException {
if ((base == null) || (base.length() == 0)) {
base = getStartDN();
}
String[] param = { base };
logEvent("ATTEMPT_GET_REALM_NAMES", param);
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), base);
logEvent("SUCCEED_GET_REALM_NAMES", param);
return PolicyModelImpl.appendBaseDN(base, orgMgr.getSubOrganizationNames(filter, true), filter, this);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { base, strError };
logEvent("SMS_EXCEPTION_GET_REALM_NAMES", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class SelectRealmModelImpl method getAuthenticationInstances.
/**
* Returns set of authentication instances.
*
* @param realmName Name of Realm.
* @return set of authentication instances.
* @throws AMConsoleException if authentication instances cannot be
* obtained.
*/
public Set getAuthenticationInstances(String realmName) throws AMConsoleException {
Set names = Collections.EMPTY_SET;
try {
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), realmName);
Set instances = mgr.getAuthenticationInstances();
if ((instances != null) && !instances.isEmpty()) {
names = new HashSet(instances.size());
for (Iterator i = instances.iterator(); i.hasNext(); ) {
names.add(((AMAuthenticationInstance) i.next()).getName());
}
}
} catch (AMConfigurationException e) {
throw new AMConsoleException(getErrorString(e));
}
return names;
}
use of com.sun.identity.console.base.model.AMConsoleException in project OpenAM by OpenRock.
the class PropertyXMLBuilder method getXML.
/**
* Returns a XML for displaying attribute in property sheet.
*
* @param readonly Set of readonly attributes.
* @param bPropertySheetElementNode true to include
* <code><propertysheet></code> tag.
* @throws SMSException if attribute schema cannot obtained.
* @throws SSOException if single sign on token is invalid.
* @throws AMConsoleException if there are no attribute to display.
* @return XML for displaying attribute in property sheet.
*/
public String getXML(Set readonly, boolean bPropertySheetElementNode) throws SMSException, SSOException, AMConsoleException {
StringBuffer xml = new StringBuffer(1000);
onBeforeBuildingXML(mapTypeToAttributeSchema);
if (bPropertySheetElementNode) {
xml.append(getXMLDefinitionHeader()).append(START_TAG);
}
if (supportSubConfig) {
String configTable = SUB_CONFIG_TABLE_XML;
configTable = tagSwap(configTable, SUB_CONFIG_TABLE_VIEW_BEAN, viewBeanName);
xml.append(configTable);
}
if (!supportSubConfig && hasNoAttributes()) {
throw new AMConsoleException(model.getLocalizedString("propertysheet.no.attributes.message"));
}
Set attributeSchema = (Set) mapTypeToAttributeSchema.get(NULL_TYPE);
if ((attributeSchema != null) && !attributeSchema.isEmpty()) {
String display = "blank.header";
SchemaType type = null;
if ((schemaTypes != null) && (schemaTypes.size() == 1)) {
Iterator<SchemaType> it = schemaTypes.iterator();
type = it.next();
}
if (getSectionsForType(type) == null) {
buildSchemaTypeXML(display, attributeSchema, xml, model, serviceBundle, readonly);
} else {
String label = "lbl" + display.replace('.', '_');
Object[] params = { label, display };
xml.append(MessageFormat.format(SECTION_START_TAG, params));
for (String section : sectionForType.get(type)) {
String sectionName = model.getLocalizedString("section.label." + serviceName + "." + type.getType() + "." + section);
buildSchemaTypeXML(sectionName, attributeSchema, xml, model, serviceBundle, readonly, sectionOrder.get(section));
}
xml.append(SECTION_END_TAG);
}
}
for (Iterator iter = orderDisplaySchemaType.iterator(); iter.hasNext(); ) {
SchemaType type = (SchemaType) iter.next();
attributeSchema = (Set) mapTypeToAttributeSchema.get(type);
if ((attributeSchema != null) && !attributeSchema.isEmpty()) {
String display = model.getLocalizedString((String) mapSchemaTypeToName.get(type));
if (getSectionsForType(type) == null) {
buildSchemaTypeXML(display, attributeSchema, xml, model, serviceBundle, readonly);
} else {
String label = "lbl" + display.replace('.', '_');
Object[] params = { label, display };
xml.append(MessageFormat.format(SECTION_START_TAG, params));
for (String section : sectionForType.get(type)) {
String sectionName = model.getLocalizedString("section.label." + serviceName + "." + type.getType() + "." + section);
buildSchemaTypeXML(sectionName, attributeSchema, xml, model, serviceBundle, readonly, sectionOrder.get(section));
}
xml.append(SECTION_END_TAG);
}
}
}
if (bPropertySheetElementNode) {
xml.append(END_TAG);
}
return xml.toString();
}
Aggregations