Search in sources :

Example 96 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) SessionException(com.iplanet.dpro.session.SessionException) URL(java.net.URL) SSOException(com.iplanet.sso.SSOException) SessionException(com.iplanet.dpro.session.SessionException) HashSet(java.util.HashSet)

Example 97 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 98 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap)

Example 99 with StringTokenizer

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashSet(java.util.HashSet)

Example 100 with StringTokenizer

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);
    }
}
Also used : DelegationPrivilege(com.sun.identity.delegation.DelegationPrivilege) StringTokenizer(java.util.StringTokenizer) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) DelegationException(com.sun.identity.delegation.DelegationException) Rule(com.sun.identity.policy.Rule) Subject(com.sun.identity.policy.interfaces.Subject) DelegationPermission(com.sun.identity.delegation.DelegationPermission) DelegationException(com.sun.identity.delegation.DelegationException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) IdRepoException(com.sun.identity.idm.IdRepoException) HashSet(java.util.HashSet)

Aggregations

StringTokenizer (java.util.StringTokenizer)4881 ArrayList (java.util.ArrayList)1083 IOException (java.io.IOException)506 File (java.io.File)392 BufferedReader (java.io.BufferedReader)380 HashMap (java.util.HashMap)375 HashSet (java.util.HashSet)263 FileReader (java.io.FileReader)224 List (java.util.List)200 InputStreamReader (java.io.InputStreamReader)191 Map (java.util.Map)152 FileInputStream (java.io.FileInputStream)135 Iterator (java.util.Iterator)114 Set (java.util.Set)114 URL (java.net.URL)108 NoSuchElementException (java.util.NoSuchElementException)90 Properties (java.util.Properties)84 InputStream (java.io.InputStream)83 BufferedWriter (java.io.BufferedWriter)80 FileNotFoundException (java.io.FileNotFoundException)78