use of java.util.StringTokenizer in project OpenAM by OpenRock.
the class SessionUtils method getTrustedSourceList.
/* build the trust source set*/
private static Set getTrustedSourceList() throws SessionException {
Set result = new HashSet();
try {
String rawList = SystemProperties.get(Constants.TRUSTED_SOURCE_LIST);
if (rawList != null) {
StringTokenizer stk = new StringTokenizer(rawList, ",");
while (stk.hasMoreTokens()) {
result.add(InetAddress.getByName(stk.nextToken()));
}
} else {
// use platform server list as a default fallback
Set<String> psl = WebtopNaming.getPlatformServerList();
if (psl == null) {
throw new SessionException(SessionBundle.rbName, "emptyTrustedSourceList", null);
}
for (String e : psl) {
try {
URL url = new URL(e);
result.add(InetAddress.getByName(url.getHost()));
} catch (Exception ex) {
debug.error("SessionUtils.getTrustedSourceList : " + "Validating Host exception", ex);
}
}
}
} catch (Exception e) {
throw new SessionException(e);
}
return result;
}
use of java.util.StringTokenizer in project OpenAM by OpenRock.
the class FSServiceUtils method parseAttributeConfig.
/**
* Parses the attribute map configuration and returns as java
* <code>java.util.Map</code>.
* @param list attribute configuration.
* @return configured attribute mapping with key as the SAML
* attribute and the value being the local attribute.
*/
public static Map parseAttributeConfig(List list) {
Map map = new HashMap();
if (list == null || list.isEmpty()) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSServiceUtils.parseAttributeConfig: " + "Input put list is empty");
}
return map;
}
Iterator iter = list.iterator();
while (iter.hasNext()) {
String entry = (String) iter.next();
if (entry.indexOf("=") != -1) {
StringTokenizer st = new StringTokenizer(entry, "=");
map.put(st.nextToken(), st.nextToken());
}
}
return map;
}
use of java.util.StringTokenizer in project OpenAM by OpenRock.
the class ServerUpgrade method populateUpgradeHelpers.
protected static void populateUpgradeHelpers() {
Map<String, UpgradeHelper> values = new HashMap<String, UpgradeHelper>();
String attrValues = res.getString(ATTR_UPGRADE_HELPER);
if (attrValues != null) {
StringTokenizer st = new StringTokenizer(attrValues, Constants.COMMA);
while (st.hasMoreTokens()) {
String serviceHelper = st.nextToken();
if (serviceHelper != null) {
if (serviceHelper.indexOf(Constants.EQUALS) == -1) {
// bad formatting
continue;
}
String serviceName = serviceHelper.substring(0, serviceHelper.indexOf(Constants.EQUALS));
String helperClass = serviceHelper.substring(serviceHelper.indexOf(Constants.EQUALS) + 1);
UpgradeHelper helper = null;
try {
helper = (UpgradeHelper) Class.forName(helperClass).newInstance();
values.put(serviceName, helper);
} catch (Exception ex) {
UpgradeUtils.debug.error("Unable to load helper class: " + helperClass, ex);
initializationException = new UpgradeException("Unable to load helper class: " + helperClass + ex.getMessage());
}
}
}
}
if (UpgradeUtils.debug.messageEnabled()) {
UpgradeUtils.debug.message("Helper classes: " + values);
}
serviceHelpers = values;
}
use of java.util.StringTokenizer in project OpenAM by OpenRock.
the class ServerUpgrade method getServicesToDelete.
public static Set<String> getServicesToDelete() throws UpgradeException {
assertInitialized();
Set<String> values = new HashSet<String>();
if (!res.containsKey(SERVICES_TO_DELETE)) {
throw new UpgradeException("Unable to find " + SERVICES_TO_DELETE + " in " + SERVER_UPGRADE);
}
String attrValues = res.getString(SERVICES_TO_DELETE);
if (attrValues != null) {
StringTokenizer st = new StringTokenizer(attrValues, ",");
while (st.hasMoreTokens()) {
values.add(st.nextToken());
}
}
return values;
}
use of java.util.StringTokenizer in project OpenAM by OpenRock.
the class DelegationPolicyImpl method policyToPrivilege.
/**
* Converts a policy to a delegation privilege.
* @param policy policy to be converted
* @return priv <code>DelegationPrivilege</code> represting policy.
*/
private DelegationPrivilege policyToPrivilege(Policy policy) throws DelegationException {
String pname = null;
Set permissions = new HashSet();
Set svalues = new HashSet();
if (policy == null) {
return null;
}
try {
// get policy name, which is the privilege name as well
pname = policy.getName();
// get privilege subjects
Set snames = policy.getSubjectNames();
if ((snames != null) && (!snames.isEmpty())) {
if (snames.contains(DELEGATION_AUTHN_USERS)) {
svalues.add(AUTHN_USERS_ID);
}
if (snames.contains(DELEGATION_SUBJECT)) {
Subject subject = policy.getSubject(DELEGATION_SUBJECT);
Set values = subject.getValues();
if (values != null) {
svalues.addAll(values);
}
}
}
if (DelegationManager.debug.messageEnabled()) {
DelegationManager.debug.message("SubjectValues=" + svalues);
}
String realmName = null;
String serviceName = null;
String version = null;
String configType = null;
String subconfigName = null;
String resource = null;
Set actions = null;
Set ruleNames = policy.getRuleNames();
if ((ruleNames != null) && (!ruleNames.isEmpty())) {
Iterator rit = ruleNames.iterator();
while (rit.hasNext()) {
String ruleName = (String) rit.next();
// now try to get resource and action names
Rule rule = policy.getRule(ruleName);
String service = rule.getServiceTypeName();
if (service.equalsIgnoreCase(DelegationManager.DELEGATION_SERVICE)) {
resource = rule.getResourceName();
actions = rule.getActionNames();
// required to construct a delegation permission
if (resource.startsWith(PREFIX)) {
String suffix = resource.substring(PREFIX.length());
if (suffix != null) {
StringTokenizer st = new StringTokenizer(suffix, DELIMITER);
realmName = st.nextToken();
if (st.hasMoreTokens()) {
serviceName = st.nextToken();
if (st.hasMoreTokens()) {
version = st.nextToken();
if (st.hasMoreTokens()) {
configType = st.nextToken();
if (st.hasMoreTokens()) {
subconfigName = st.nextToken();
while (st.hasMoreTokens()) {
subconfigName += DELIMITER + st.nextToken();
}
}
}
}
}
}
}
if (DelegationManager.debug.messageEnabled()) {
DelegationManager.debug.message("DelegationPolicyImpl.policyToPrivilege(): " + "create DelegationPermission object with: " + "realm=" + realmName + "; service=" + serviceName + "; version=" + version + "; configType=" + configType + "; subconfig=" + subconfigName + "; actions=" + actions);
}
DelegationPermission dp = new DelegationPermission(realmName, serviceName, version, configType, subconfigName, actions, null);
permissions.add(dp);
}
}
}
return new DelegationPrivilege(pname, permissions, svalues);
} catch (Exception e) {
throw new DelegationException(e);
}
}
Aggregations