use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class SessionCondition method getValidValues.
/**
* Gets a set of valid values given the property name. This method
* is called if the property <code>Syntax</code> is either the
* <code>SINGLE_CHOICE</code> or <code>MULTIPLE_CHOICE</code>.
*
* @param property property name
* @return set of valid values for the property
*
* @exception PolicyException if unable to get the <code>Syntax</code>
*/
public Set getValidValues(String property) throws PolicyException {
if (property.equals(TERMINATE_SESSION)) {
// use OrderedSet to ensure the default is "false"
Set values = new OrderedSet();
values.add(SESSION_CONDITION_FALSE_VALUE);
values.add(SESSION_CONDITION_TRUE_VALUE);
return values;
}
return Collections.EMPTY_SET;
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class SMSEntry method parseResult.
// Parse the DNs and return as "/" seperated
protected static Set parseResult(Set resultSet, String dn, boolean includeThisDN) {
/*
* Search results based on scope 'SCOPE_SUB' returns all entries beneath
* the entry DN, and adding to the set. This piece of code iterates
* through the list, gets the suborganization names, replaces the
* namingattribute 'o' with '/' and reverses the result string to be
* displayed in the slash '/' seperated format. eg., Search for suborgs
* from 'o=coke' in o=fanta,o=pepsi,o=coke,ou=services,dc=iplanet,dc=com
* will return the following set: [pepsi, pepsi/fanta]
*/
Set answer = new OrderedSet();
if (resultSet != null) {
Iterator Iter = resultSet.iterator();
while (Iter.hasNext()) {
DN sdn = DN.valueOf((String) Iter.next());
String rfcDN = sdn.toString();
String rfcDNlc = sdn.toString().toLowerCase();
if (!rfcDNlc.equals(baseDN) && !rfcDNlc.startsWith(SUN_INTERNAL_REALM_PREFIX)) {
/*
* Need to include current DN for search operations.
* Required by AuthN to login to root organization
*/
if (rfcDNlc.equals(dn)) {
if (includeThisDN) {
answer.add(SLASH_STR);
}
continue;
}
/*
* To handle such a case. eg., ou=policy1,
* ou=Policies,ou=default,ou=OrganizationConfig,
* ou=1.0,ou=iPlanetAMPolicyService,ou=services,
* o=engg,o=coke,ou=services,dc=iplanet,dc=com in which case
* we return "/Coke/engg"
*/
String orgAttr = ServiceManager.isRealmEnabled() ? ORG_PLACEHOLDER_RDN : OrgConfigViaAMSDK.getNamingAttrForOrg() + EQUALS;
if (debug.messageEnabled()) {
debug.message("SMSEntry:parseResult:orgAttr " + orgAttr);
}
int i = rfcDNlc.indexOf(orgAttr.toLowerCase());
if (i > 0) {
rfcDN = rfcDN.substring(i);
}
if (debug.messageEnabled()) {
debug.message("SMSEntry:parseResult:DNName " + dn);
debug.message("SMSEntry:parseResult:RFCDN " + rfcDN);
}
int indx = rfcDNlc.indexOf(dn);
if (indx < 0) {
indx = rfcDNlc.lastIndexOf(baseDN);
}
String origStr = rfcDN.substring(0, indx - 1);
if (!ServiceManager.isRealmEnabled()) {
// Continue in the case of Containers in the node in
// legacy install.
// eg., o=coke,ou=ContainerOne,dc=planet,dc=com
ArrayList rdns = new ArrayList();
StringTokenizer strtok = new StringTokenizer(origStr, COMMA);
while (strtok.hasMoreElements()) {
String token = (String) strtok.nextToken().trim();
if (debug.messageEnabled()) {
debug.message("SMSEntry:parseResult().token " + token);
}
if (token != null && token.length() != 0) {
rdns.add(token);
}
}
int size = rdns.size();
Set dnKeyset = new HashSet();
for (int is = 0; is < size; is++) {
String[] strArr = DNMapper.splitString((String) rdns.get(is));
dnKeyset.add(strArr[0]);
}
String orgUnitAttr = OrgConfigViaAMSDK.getNamingAttrForOrgUnit();
if (dnKeyset.contains(orgUnitAttr)) {
if (debug.messageEnabled()) {
debug.message("SMSEntry.parseResult(): " + "Container node: " + origStr);
}
continue;
}
}
// If orgAttr is not null,replace with the org naming
// attribute which is defined for legacy mode.
// Replace orgAttr= to '/' and ',' to "" (or)
// Replace 'o=' to '/' and ',' to ""
origStr = DNMapper.replaceString(origStr, orgAttr, SLASH_STR);
if (debug.messageEnabled()) {
debug.message("SMSEntry:parseResult:origStr1 " + origStr);
}
origStr = DNMapper.replaceString(origStr, SMSEntry.COMMA, "");
if (debug.messageEnabled()) {
debug.message("SMSEntry:parseResult:origStr2 " + origStr);
}
// Logic here is to reverse the string from dn format to
// slash format.
String tmpStr = "";
StringBuilder sb = new StringBuilder();
while (origStr.length() != 0) {
int id = origStr.lastIndexOf(SLASH_STR);
if (id >= 0) {
sb.append(origStr.substring(id + 1)).append(SLASH_STR);
origStr = origStr.substring(0, id);
}
}
tmpStr = sb.toString();
/*
* To remove the ending slash '/'. eg., pepsi/fanta/ to be
* added as pepsi/fanta
*/
if (tmpStr != null && tmpStr.length() > 0) {
answer.add(tmpStr.substring(0, tmpStr.length() - 1));
}
}
}
}
return answer;
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class SMSEntry method searchSubOrgNames.
/**
* Returns the subOrgNames. Returns a set of suborganization names (rdns).
* The paramter <code>numOfEntries</code> identifies the number of entries
* to return, if <code>0</code> returns all the entries. The paramter
* <code>recursive</code> determines if to return one level of entries
* beneath the entryDN or all the entries till the leaf node.
*/
Set searchSubOrgNames(SSOToken token, String filter, int numOfEntries, boolean sortResults, boolean ascendingOrder, boolean recursive) throws SMSException, SSOException {
// permission is checked at the server.
if (backendProxyEnabled && !SMSJAXRPCObjectFlg) {
if (isAllowed(token, normalizedDN, readActionSet)) {
if (adminSSOToken == null) {
adminSSOToken = (SSOToken) AccessController.doPrivileged(com.sun.identity.security.AdminTokenAction.getInstance());
}
token = adminSSOToken;
}
} else if (!SMSJAXRPCObjectFlg) {
// Check for delegation permission throws exception if
// permission is denied
getDelegationPermission(token, normalizedDN, readActionSet);
}
Set resultSet = smsObject.searchSubOrgNames(token, dn, filter, numOfEntries, sortResults, ascendingOrder, recursive);
// Check for remote client using JAX-RPC
if (SMSJAXRPCObjectFlg) {
// parsing would be done at the server
return (resultSet);
}
// Server side. Check for read permissions
Set allowedSet = new OrderedSet();
for (Iterator items = resultSet.iterator(); items.hasNext(); ) {
String item = (String) items.next();
if (hasReadPermission(token, item)) {
allowedSet.add(item);
}
}
Set answer = parseResult(allowedSet, normalizedDN);
if (debug.messageEnabled()) {
debug.message("SMSEntry: Successfully obtained " + "suborganization names for : " + dn);
}
return (answer);
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class G11NCharsetAliasEditViewBean method beginDisplay.
public void beginDisplay(DisplayEvent event) throws ModelControlException {
super.beginDisplay(event);
if (populateValues) {
int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
Map mapAttrs = (Map) getPageSessionAttribute(SMG11NViewBean.PROPERTY_ATTRIBUTE);
OrderedSet set = (OrderedSet) mapAttrs.get(SMG11NModelImpl.ATTRIBUTE_NAME_CHARSET_ALIAS);
setValues((String) set.get(index));
}
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class G11NCharsetAliasEditViewBean method handleButton1Request.
protected void handleButton1Request(Map values) {
SMG11NViewBean vb = (SMG11NViewBean) getViewBean(SMG11NViewBean.class);
Map mapAttrs = (Map) getPageSessionAttribute(SMG11NViewBean.PROPERTY_ATTRIBUTE);
OrderedSet aliases = (OrderedSet) mapAttrs.get(SMG11NModelImpl.ATTRIBUTE_NAME_CHARSET_ALIAS);
int index = Integer.parseInt((String) getPageSessionAttribute(PGATTR_INDEX));
String val = CharsetAliasEntry.toString((String) values.get(ATTR_MIMENAME), (String) values.get(ATTR_JAVANAME));
aliases.set(index, val);
setPageSessionAttribute(SMG11NViewBean.PAGE_MODIFIED, "1");
passPgSessionMap(vb);
vb.forwardTo(getRequestContext());
}
Aggregations