use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class Policy method getReferredToOrganizations.
// public String getServiceTypeName() {
/* com.iplanet.am.admin.cli uses this method.
* Need to clean up cli not to use this
* method. Without this method build breaks - 03/05/02 */
// return null;
// }
/**
* Gets organizations referred to in this policy by OrgReferral(s)
* defined in this policy.
*
* @return names of organization (DNs) of organizations referred
* to in this policy via <code>OrgReferral</code>(s) defined in
* this policy.
* Please note that <code>PeerOrgReferral</code> and
* <code>SubOrgReferral</code> extend <code>OrgReferral</code>
* and hence qualify as OrgReferral.
* @exception PolicyException
*/
Set getReferredToOrganizations() throws PolicyException {
Set referredToOrgs = new HashSet();
Iterator referralNames = referrals.getReferralNames().iterator();
while (referralNames.hasNext()) {
String referralName = (String) referralNames.next();
Referral referral = (Referral) referrals.getReferral(referralName);
if (referral instanceof OrgReferral) {
Set values = referral.getValues();
if ((values != null) && (!values.isEmpty())) {
String orgName = (String) values.iterator().next();
referredToOrgs.add(orgName.toLowerCase());
}
}
}
return referredToOrgs;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PolicyOpViewBeanBase method populateReferralsTable.
protected void populateReferralsTable() throws AMConsoleException {
tblReferralsModel.clearAll();
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Set referralsNames = policy.getReferralNames();
if ((referralsNames != null) && !referralsNames.isEmpty()) {
PolicyModel model = (PolicyModel) getModel();
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Map localizedRflTypeNames = model.getActiveReferralTypes(realmName);
boolean firstEntry = true;
for (Iterator iter = referralsNames.iterator(); iter.hasNext(); ) {
if (firstEntry) {
firstEntry = false;
} else {
tblReferralsModel.appendRow();
}
try {
String name = (String) iter.next();
Referral referral = policy.getReferral(name);
tblReferralsModel.setValue(TBL_REFERRALS_DATA_NAME, name);
String rflTypeName = referral.getReferralTypeName();
String displayName = (String) localizedRflTypeNames.get(rflTypeName);
if (displayName == null) {
displayName = rflTypeName;
}
tblReferralsModel.setValue(TBL_REFERRALS_DATA_TYPE, displayName);
tblReferralsModel.setValue(TBL_REFERRALS_ACTION_HREF, stringToHex(name));
} catch (NameNotFoundException e) {
debug.warning("PolicyOpViewBeanBase.populateReferralsTable", e);
}
}
}
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class ReferralEditViewBean method handleButton1Request.
private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
Referral deleted = null;
String origName = (String) getPageSessionAttribute(EDIT_REFERRAL_NAME);
Policy policy = cachedPolicy.getPolicy();
try {
Referral referral = createReferral();
if (referral != null) {
String name = (String) propertySheetModel.getValue(REFERRAL_NAME);
if (origName.equals(name)) {
policy.replaceReferral(name, referral);
} else {
deleted = policy.removeReferral(origName);
policy.addReferral(name, referral);
}
deleted = null;
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.referral.updated");
cachedPolicy.setPolicyModified(true);
}
} catch (NameAlreadyExistsException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (InvalidNameException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (NameNotFoundException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
} finally {
if (deleted != null) {
try {
policy.addReferral(origName, deleted);
} catch (NameAlreadyExistsException e) {
debug.warning("ReferralEditViewBean.handleButton1Request", e);
} catch (InvalidNameException e) {
debug.warning("ReferralEditViewBean.handleButton1Request", e);
}
}
}
forwardTo();
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PolicyModelImpl method createReferral.
/**
* Returns a referral object.
*
* @param realmName Name of Realm.
* @param referralType Name of referral type.
* @param values Values of the referral.
* @return referral obejct.
* @throws AMConsoleException if referral cannot be created.
*/
public Referral createReferral(String realmName, String referralType, Set values) throws AMConsoleException {
Referral referral = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
referral = referralTypeMgr.getReferral(referralType);
referral.setValues(values);
}
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
}
return referral;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PolicyModelImpl method getDisplayNameForReferralValues.
/**
* Returns a map of values to localized label.
*
* @param realmName Name of realm.
* @param referralTypeName Name of referral Type.
* @param values Valid values.
* @return a map of values to localized label.
*/
public Map getDisplayNameForReferralValues(String realmName, String referralTypeName, Set values) {
Map map = null;
if ((values != null) && !values.isEmpty()) {
map = new HashMap(values.size() * 2);
Locale locale = getUserLocale();
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager mgr = policyMgr.getReferralTypeManager();
Referral referral = mgr.getReferral(referralTypeName);
for (Iterator i = values.iterator(); i.hasNext(); ) {
String v = (String) i.next();
map.put(v, referral.getDisplayNameForValue(v, locale));
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getDisplayNameForReferralValues", e);
}
}
return (map == null) ? Collections.EMPTY_MAP : map;
}
Aggregations