use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PolicyModelImpl method getReferralViewBeanURL.
/**
* Returns properties view bean URL of a referral.
*
* @param realmName Name of realm.
* @param referralTypeName Name of Referral Type.
* @return properties view bean URL of a referral.
*/
public String getReferralViewBeanURL(String realmName, String referralTypeName) {
String url = null;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
Referral referral = referralTypeMgr.getReferral(referralTypeName);
url = referralTypeMgr.getViewBeanURL(referral);
}
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getReferralViewBeanURL", e);
}
return url;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PolicyModelImpl method getReferralSyntax.
/**
* Returns syntax for a referral.
*
* @param realmName Name of Realm.
* @param referralType Name of referral type.
* @return syntax for a referral.
*/
public Syntax getReferralSyntax(String realmName, String referralType) {
Syntax syntax = Syntax.NONE;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
Referral referral = referralTypeMgr.getReferral(referralType);
syntax = referral.getValueSyntax(getUserSSOToken());
}
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getReferralActionSchema", e);
}
return syntax;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PrivilegeUtils method referralPrivilegeToPolicy.
public static Policy referralPrivilegeToPolicy(String realm, ReferralPrivilege referralPrivilege) throws PolicyException, SSOException, EntitlementException {
Policy policy = new Policy(referralPrivilege.getName(), referralPrivilege.getDescription(), true);
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
javax.security.auth.Subject adminSubject = SubjectUtils.createSubject(adminToken);
PolicyManager pm = new PolicyManager(adminToken, realm);
ReferralTypeManager rm = pm.getReferralTypeManager();
policy.setCreatedBy(referralPrivilege.getCreatedBy());
policy.setCreationDate(referralPrivilege.getCreationDate());
policy.setLastModifiedBy(referralPrivilege.getLastModifiedBy());
policy.setLastModifiedDate(referralPrivilege.getLastModifiedDate());
int count = 1;
for (String r : referralPrivilege.getRealms()) {
Referral referral = rm.getReferral("SubOrgReferral");
Set<String> tmp = new HashSet<String>();
tmp.add(r);
referral.setValues(tmp);
policy.addReferral("referral" + count++, referral);
}
Map<String, Set<String>> map = referralPrivilege.getOriginalMapApplNameToResources();
count = 1;
String realmName = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
for (String appName : map.keySet()) {
Set<String> res = map.get(appName);
Application application = ApplicationManager.getApplication(PolicyConstants.SUPER_ADMIN_SUBJECT, realmName, appName);
if (application == null) {
Object[] params = { appName, realm };
throw new EntitlementException(105, params);
}
String serviceName = application.getApplicationType().getName();
for (String r : res) {
Rule rule = new Rule("rule" + count++, serviceName, r, Collections.EMPTY_MAP);
rule.setApplicationName(appName);
policy.addRule(rule);
}
}
return policy;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class PrivilegeUtils method getReferrals.
private static Set<String> getReferrals(Policy policy) throws NameNotFoundException {
Set<String> results = new HashSet<String>();
Set<String> names = policy.getReferralNames();
for (String name : names) {
Referral r = policy.getReferral(name);
Set<String> values = r.getValues();
for (String s : values) {
if (LDAPUtils.isDN(s)) {
results.add(DNMapper.orgNameToRealmName(s));
} else {
results.add(s);
}
}
}
return results;
}
use of com.sun.identity.policy.interfaces.Referral in project OpenAM by OpenRock.
the class ResourceIndexManager method addPolicyToResourceTree.
/**
* Adds a policy's relevant content to the resource tree.
*
* @param svtm service type manager
* @param token sso token
* @param policy the policy to be added
*
* @exception PolicyException if unable to get the policy services,
* and will contain the exception thrown by SMS.
* @exception SSOException single-sign-on token invalid or expired
*/
void addPolicyToResourceTree(ServiceTypeManager svtm, SSOToken token, Policy policy) throws PolicyException, SSOException {
Set ruleNames = policy.getRuleNames();
Iterator iter = ruleNames.iterator();
Set serviceNames = new HashSet();
while (iter.hasNext()) {
String ruleName = (String) iter.next();
Rule rule = policy.getRule(ruleName);
String serviceName = rule.getServiceTypeName();
serviceNames.add(serviceName);
ServiceType resourceType = svtm.getServiceType(serviceName);
addIndexEntry(resourceType, rule.getResourceName(), policy.getName());
}
iter = serviceNames.iterator();
while (iter.hasNext()) {
String serviceName = (String) iter.next();
saveResourceIndex(serviceName);
}
//Process Referrals
Referrals referrals = policy.getReferrals();
if (referrals != null) {
Set referralNames = referrals.getReferralNames();
if ((referralNames != null) && (!referralNames.isEmpty())) {
Iterator referralIter = referralNames.iterator();
while (referralIter.hasNext()) {
String referralName = (String) referralIter.next();
Referral referral = referrals.getReferral(referralName);
if (referral instanceof OrgReferral) {
Set values = referral.getValues();
if ((values != null) && (!values.isEmpty())) {
Iterator valueIter = values.iterator();
while (valueIter.hasNext()) {
Map servicePrefixMap = new HashMap();
String value = (String) valueIter.next();
PolicyManager pm = new PolicyManager(token, value);
ResourceManager rm = pm.getResourceManager();
Set ruleNames1 = policy.getRuleNames();
Iterator ruleIter = ruleNames1.iterator();
while (ruleIter.hasNext()) {
String ruleName1 = (String) ruleIter.next();
Rule rule1 = policy.getRule(ruleName1);
String resourceName = rule1.getResourceName();
if (resourceName != null) {
String service = rule1.getServiceTypeName();
Set resourceNames = (Set) servicePrefixMap.get(service);
if (resourceNames == null) {
resourceNames = new HashSet();
servicePrefixMap.put(service, resourceNames);
}
resourceNames.add(resourceName);
}
}
Iterator serviceIter = servicePrefixMap.keySet().iterator();
while (serviceIter.hasNext()) {
String service = (String) serviceIter.next();
Set resourceNames = (Set) servicePrefixMap.get(service);
rm.addResourcePrefixes(service, resourceNames);
}
}
//processed a referral value
}
}
}
}
}
}
Aggregations