use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.
the class FederationViewBean method handleDeleteCOTButtonRequest.
public void handleDeleteCOTButtonRequest(RequestInvocationEvent event) throws ModelControlException {
CCActionTable tbl = (CCActionTable) getChild(COT_TABLE);
tbl.restoreStateData();
CCActionTableModel tableModel = (CCActionTableModel) propertySheetModel.getModel(COT_TABLE);
// get selected rows
Integer[] selected = tableModel.getSelectedRows();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
List list = (List) szCache.getSerializedObj();
FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
StringBuilder deletedNames = new StringBuilder();
StringBuilder cannotDeleteds = new StringBuilder();
// each COT is deleted separately as they can be in separate realms
for (int i = 0; i < selected.length; i++) {
String str = (String) list.get(selected[i].intValue());
int pipeIndex = str.indexOf(",");
String name = str.substring(0, pipeIndex);
String realm = str.substring(pipeIndex + 1);
try {
model.deleteAuthenticationDomain(realm, name);
if (deletedNames.length() > 0) {
deletedNames.append(", ");
}
deletedNames.append(name);
} catch (AMConsoleException e) {
if (cannotDeleteds.length() > 0) {
cannotDeleteds.append(", ");
}
cannotDeleteds.append(e.getMessage());
}
}
StringBuilder message = new StringBuilder();
if (deletedNames.length() > 0) {
Object[] params = { deletedNames };
message.append(MessageFormat.format(model.getLocalizedString("authDomain.message.deleted"), params));
}
if (cannotDeleteds.length() > 0) {
Object[] params = { cannotDeleteds };
message.append(MessageFormat.format(model.getLocalizedString("generic.error.message"), params));
}
if (message.length() > 0) {
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", message.toString());
}
forwardTo();
}
use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.
the class FederationViewBean method populateCOTTable.
private void populateCOTTable() {
tablePopulated = true;
FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
Set circleOfTrustDescriptors = model.getCircleOfTrustDescriptors();
CCActionTableModel tableModel = (CCActionTableModel) propertySheetModel.getModel(COT_TABLE);
tableModel.clearAll();
SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
if ((circleOfTrustDescriptors != null) && (!circleOfTrustDescriptors.isEmpty())) {
List cache = new ArrayList(circleOfTrustDescriptors.size());
boolean first = true;
for (Iterator iter = circleOfTrustDescriptors.iterator(); iter.hasNext(); ) {
if (first) {
first = false;
} else {
tableModel.appendRow();
}
CircleOfTrustDescriptor desc = (CircleOfTrustDescriptor) iter.next();
String name = desc.getCircleOfTrustName();
tableModel.setValue(COT_NAME_VALUE, name);
tableModel.setValue(COT_NAME_HREF, stringToHex(name));
// get entity/provider name
Set entitySet = desc.getTrustedProviders();
if ((entitySet != null) && (!entitySet.isEmpty())) {
Iterator it = entitySet.iterator();
StringBuffer sb = new StringBuffer();
Encoder encoder = ESAPI.encoder();
while (it.hasNext()) {
String entity = (String) it.next();
sb.append(encoder.encodeForHTML(entity)).append("<br>");
}
tableModel.setValue(COT_ENTITY_VALUE, sb.toString());
} else {
tableModel.setValue(COT_ENTITY_VALUE, "");
}
// get realm name
String realm = desc.getCircleOfTrustRealm();
tableModel.setValue(COT_REALM_VALUE, realm);
// get cot status
String status = desc.getCircleOfTrustStatus();
if ((status != null) && status.equals("active")) {
tableModel.setValue(COT_STATUS_VALUE, "label.active");
} else {
tableModel.setValue(COT_STATUS_VALUE, "label.inactive");
}
cache.add(name + "," + realm);
}
szCache.setValue((ArrayList) cache);
} else {
szCache.setValue(null);
}
}
use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.
the class CreateCOTViewBean method populateRealmData.
private void populateRealmData() {
FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
try {
Set realmNames = new TreeSet(model.getRealmNames("/", "*"));
CCDropDownMenu menu = (CCDropDownMenu) getChild(SINGLECHOICE_REALM_MENU);
OptionList list = new OptionList();
for (Iterator i = realmNames.iterator(); i.hasNext(); ) {
String name = (String) i.next();
list.add(getPath(name), name);
}
menu.setOptions(list);
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
}
use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.
the class CreateCOTViewBean method handleButton1Request.
/**
* Handles save button request.
* save
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
AMPropertySheet ps = (AMPropertySheet) getChild(PROPERTIES);
try {
Map values = ps.getAttributeValues(model.getDataMap(), false, model);
String name = (String) getDisplayFieldValue(model.TF_NAME);
if ((name == null) || (name.length() < 1)) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("authdomain.authentication.domain.name.missing.message"));
psModel.setErrorProperty("nameProperty", true);
forwardTo();
} else {
CCAddRemove addRemoveList = (CCAddRemove) getChild(ADD_REMOVE_PROVIDERS);
addRemoveList.restoreStateData();
CCAddRemoveModel addRemoveModel = (CCAddRemoveModel) addRemoveList.getModel();
Set providers = new HashSet(getSelectedValues(addRemoveModel));
model.createAuthenticationDomain(values, providers);
Object[] params = { name };
String message = MessageFormat.format(model.getLocalizedString("authentication.domain.create.message"), params);
setPageSessionAttribute(FederationViewBean.MESSAGE_TEXT, message);
backTrail();
FederationViewBean vb = (FederationViewBean) getViewBean(FederationViewBean.class);
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
}
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
}
use of com.sun.identity.console.federation.model.FSAuthDomainsModel in project OpenAM by OpenRock.
the class FSAuthDomainsEditViewBean method getBreadCrumbDisplayName.
protected String getBreadCrumbDisplayName() {
String name = (String) getPageSessionAttribute(FSAuthDomainsModel.TF_NAME);
String[] arg = { name };
FSAuthDomainsModel model = (FSAuthDomainsModel) getModel();
return MessageFormat.format(model.getLocalizedString("breadcrumbs.federation.authdomains.edit"), arg);
}
Aggregations