use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PolicyModelImpl method getActiveReferralTypes.
/**
* Returns a map of active referral types for a realm to its display name.
*
* @param realmName Name of Realm.
* @return a map of active referral types for a realm to its display name.
*/
public Map getActiveReferralTypes(String realmName) {
Map referralTypes = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
if (referralTypeMgr != null) {
Set types = referralTypeMgr.getSelectedReferralTypeNames();
referralTypes = new HashMap(types.size() * 2);
for (Iterator iter = types.iterator(); iter.hasNext(); ) {
String rName = (String) iter.next();
Referral referral = referralTypeMgr.getReferral(rName);
if (referral != null) {
Syntax syntax = referral.getValueSyntax(getUserSSOToken());
if (!syntax.equals(Syntax.NONE)) {
referralTypes.put(rName, referralTypeMgr.getDisplayName(rName));
}
}
}
}
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
}
return (referralTypes == null) ? Collections.EMPTY_MAP : referralTypes;
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class PrivilegeUtils method pavToPrav.
static Map<String, Boolean> pavToPrav(Map actionValues, String serviceName) throws PolicyException, SSOException {
if (actionValues == null) {
return null;
}
ServiceType serviceType = null;
if (serviceName != null) {
try {
serviceType = svcTypeManager.getServiceType(serviceName);
} catch (NameNotFoundException e) {
//ignore
}
}
Map av = new HashMap();
Set keySet = (Set) actionValues.keySet();
for (Object actionObj : keySet) {
String action = (String) actionObj;
Set values = (Set) actionValues.get(action);
if ((values == null) || values.isEmpty()) {
av.put(action, Boolean.FALSE);
} else {
if (serviceType != null) {
try {
ActionSchema as = serviceType.getActionSchema(action);
if (as.getSyntax().equals(AttributeSchema.Syntax.BOOLEAN)) {
String trueValue = as.getTrueValue();
if (values.contains(trueValue)) {
av.put(action, Boolean.TRUE);
} else {
av.put(action, Boolean.FALSE);
}
} else {
// Append action value to action name
String value = values.iterator().next().toString();
av.put(action + "_" + value, Boolean.TRUE);
}
} catch (InvalidNameException e) {
av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
}
} else {
av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
}
}
}
return av;
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class MigrateValidGotoSetting method initialize.
@Override
public void initialize() throws UpgradeException {
try {
final PolicyManager pm = new PolicyManager(getAdminToken(), HIDDEN_REALM);
if (pm.getPolicyNames(DELEGATION_POLICY_NAME).isEmpty()) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Unable to find the delegation policy in the hidden realm, looking for existing goto" + " domain values.");
}
//The delegation policy is not defined yet in the configuration, we need to migrate the goto domains.
final ServiceConfigManager scm = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, getAdminToken());
for (final String realm : getRealmNames()) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Looking for valid goto URLs in realm " + realm);
}
final ServiceConfig organizationConfig = scm.getOrganizationConfig(realm, null);
final Map<String, Set<String>> attrs = organizationConfig.getAttributesWithoutDefaults();
final Set<String> validDomains = attrs.get(LEGACY_GOTO_DOMAINS_SETTING);
if (validDomains != null && !validDomains.isEmpty()) {
changes.put(realm, validDomains);
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message("Found the following existing goto URL domains in realms: " + changes);
}
} else {
delegationPolicyFound = true;
}
} catch (final NameNotFoundException nnfe) {
throw new UpgradeException("Unable to find hidden realm", nnfe);
} catch (final PolicyException pe) {
throw new UpgradeException("Unexpected error occurred while retrieving policies from the hidden realm", pe);
} catch (final SMSException smse) {
throw new UpgradeException("An error occurred while checking for old valid goto domains", smse);
} catch (final SSOException ssoe) {
throw new UpgradeException("An error occurred while checking for old valid goto domains", ssoe);
}
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class IdentitySubjectEditViewBean method getDefaultValues.
protected Set getDefaultValues(IdentitySubjectModel model) {
Set values = null;
String subjectName = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_NAME);
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
Subject subject = policy.getSubject(subjectName);
values = subject.getValues();
} catch (NameNotFoundException e) {
debug.warning("IdentitySubjectEditViewBean.getDefaultValues", e);
} catch (AMConsoleException e) {
debug.warning("IdentitySubjectEditViewBean.getDefaultValues", e);
}
return (values != null) ? values : Collections.EMPTY_SET;
}
use of com.sun.identity.policy.NameNotFoundException in project OpenAM by OpenRock.
the class ConditionEditViewBean method getDefaultValues.
protected Map getDefaultValues() {
Map values = null;
try {
CachedPolicy cachedPolicy = getCachedPolicy();
Policy policy = cachedPolicy.getPolicy();
String conditionName = (String) getPageSessionAttribute(ConditionOpViewBeanBase.PG_SESSION_CONDITION_NAME);
Condition condition = policy.getCondition(conditionName);
values = condition.getProperties();
} catch (NameNotFoundException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
} catch (AMConsoleException e) {
debug.warning("ConditionEditViewBean.getDefaultValues", e);
}
return values;
}
Aggregations