Search in sources :

Example 11 with Referral

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Referral(com.sun.identity.policy.interfaces.Referral) OrgReferral(com.sun.identity.policy.plugins.OrgReferral) Iterator(java.util.Iterator) OrgReferral(com.sun.identity.policy.plugins.OrgReferral) HashSet(java.util.HashSet)

Example 12 with Referral

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);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with Referral

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();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 14 with Referral

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;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with 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;
}
Also used : Locale(java.util.Locale) ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) HashMap(java.util.HashMap) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Referral (com.sun.identity.policy.interfaces.Referral)23 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)10 Set (java.util.Set)10 OrgReferral (com.sun.identity.policy.plugins.OrgReferral)8 HashSet (java.util.HashSet)8 Iterator (java.util.Iterator)8 PolicyManager (com.sun.identity.policy.PolicyManager)7 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)7 Policy (com.sun.identity.policy.Policy)6 PolicyException (com.sun.identity.policy.PolicyException)6 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 SSOException (com.iplanet.sso.SSOException)4 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)3 InvalidNameException (com.sun.identity.policy.InvalidNameException)2 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)2 Syntax (com.sun.identity.policy.Syntax)2 SSOToken (com.iplanet.sso.SSOToken)1