Search in sources :

Example 26 with Vector

use of java.util.Vector in project OpenAM by OpenRock.

the class SessionPLLSender method sendPLLRequest.

/**
     * Returns a Session Response object based on the XML document received from
     * remote Session Server. This is in response to a request that we send to
     * the session server.
     *
     * @param svcurl The URL of the Session Service.
     * @param sreq The Session Request XML document.
     * @return a Vector of responses from the remote server
     * @exception com.iplanet.dpro.session.SessionException if there was an error in sending the XML
     *            document or if the response has multiple components.
     */
public SessionResponse sendPLLRequest(URL svcurl, SessionRequest sreq) throws SessionException {
    try {
        String cookies = sessionCookies.getCookieName() + "=" + sreq.getSessionID();
        if (!SystemProperties.isServerMode()) {
            SessionID sessionID = new SessionID(sreq.getSessionID());
            cookies = cookies + ";" + sessionCookies.getLBCookie(sessionID);
        }
        final Request req = new Request(sreq.toXMLString());
        final RequestSet set = new RequestSet(SESSION_SERVICE);
        set.addRequest(req);
        final Vector responses = PLLClient.send(svcurl, cookies, set);
        if (responses.size() != 1) {
            throw new SessionException(SessionBundle.rbName, "unexpectedResponse", null);
        }
        final Response res = (Response) responses.elementAt(0);
        return SessionResponse.parseXML(res.getContent());
    } catch (Exception e) {
        throw new SessionException(e);
    }
}
Also used : Response(com.iplanet.services.comm.share.Response) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) RequestSet(com.iplanet.services.comm.share.RequestSet) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) Request(com.iplanet.services.comm.share.Request) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID) Vector(java.util.Vector) SessionException(com.iplanet.dpro.session.SessionException)

Example 27 with Vector

use of java.util.Vector in project OpenAM by OpenRock.

the class ResourceResultCache method sendPLLRequest.

/**
     * Return a PolicyService object based on the XML document received
     * from remote Policy Server. This is in response to a request that we
     * send to the Policy server.
     * @param policyServiceUrl The URL of the Policy Service
     * @param preq The SessionRequest XML document
     * @return PolicyService 
     * @exception SendRequestException is thrown if there was an error in
     * sending the XML document or PolicyException if there are any parsing
     * errors.     
     */
public static PolicyService sendPLLRequest(URL policyServiceUrl, PolicyRequest preq) throws SendRequestException, PolicyException {
    String lbcookie = null;
    try {
        lbcookie = getLBCookie(preq);
    } catch (Exception e) {
        throw new SendRequestException(e);
    }
    PolicyService policyService = new PolicyService();
    policyService.setMethodID(PolicyService.POLICY_REQUEST_ID);
    policyService.setPolicyRequest(preq);
    String xmlString = policyService.toXMLString();
    Request request = new Request(xmlString);
    RequestSet requestSet = new RequestSet(PolicyService.POLICY_SERVICE);
    requestSet.addRequest(request);
    if (debug.messageEnabled()) {
        debug.message("ResourceResultCache.sendPLLRequest:" + "sending PLL request to URL=" + policyServiceUrl + ":\nPLL message=" + xmlString);
    }
    Vector responses = PLLClient.send(policyServiceUrl, lbcookie, requestSet);
    Response response = (Response) responses.elementAt(0);
    PolicyService ps = PolicyService.parseXML(response.getContent());
    if (debug.messageEnabled()) {
        debug.message("ResourceResultCache.sendPLLRequest:" + "result=" + ps.toXMLString());
    }
    return ps;
}
Also used : SendRequestException(com.iplanet.services.comm.client.SendRequestException) AdvicesHandleableByAMResponse(com.sun.identity.policy.remote.AdvicesHandleableByAMResponse) PolicyResponse(com.sun.identity.policy.remote.PolicyResponse) Response(com.iplanet.services.comm.share.Response) RequestSet(com.iplanet.services.comm.share.RequestSet) PolicyService(com.sun.identity.policy.remote.PolicyService) PolicyListenerRequest(com.sun.identity.policy.remote.PolicyListenerRequest) Request(com.iplanet.services.comm.share.Request) ResourceResultRequest(com.sun.identity.policy.remote.ResourceResultRequest) RemoveListenerRequest(com.sun.identity.policy.remote.RemoveListenerRequest) AdvicesHandleableByAMRequest(com.sun.identity.policy.remote.AdvicesHandleableByAMRequest) PolicyRequest(com.sun.identity.policy.remote.PolicyRequest) Vector(java.util.Vector) JSONException(org.json.JSONException) PolicyException(com.sun.identity.policy.PolicyException) SendRequestException(com.iplanet.services.comm.client.SendRequestException) PolicyEvaluationException(com.sun.identity.policy.remote.PolicyEvaluationException) URLNotFoundException(com.iplanet.services.naming.URLNotFoundException) SSOException(com.iplanet.sso.SSOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AlreadyRegisteredException(com.iplanet.services.comm.client.AlreadyRegisteredException) IOException(java.io.IOException) SessionException(com.iplanet.dpro.session.SessionException)

Example 28 with Vector

use of java.util.Vector in project pcgen by PCGen.

the class NameGenPanel method loadGenderDD.

//	Load the gender drop dowd
private void loadGenderDD() {
    List<String> genders = getGenderCategoryNames();
    Vector<String> selectable = new Vector<>();
    String gender = (String) cbSex.getSelectedItem();
    //	Get the selected category name
    String category = (String) cbCategory.getSelectedItem();
    //	Get the set of rules for selected category
    List<RuleSet> categoryRules = categories.get(category);
    //	loop through the available genders
    for (String genderString : genders) {
        //	Get the list of rules for the current gender
        List<RuleSet> genderRules = categories.get("Sex: " + genderString);
        //	now loop through all the rules from the selected category
        for (RuleSet categoryRule : categoryRules) {
            //	we can stop processing the list once we find a match
            if (genderRules.contains(categoryRule)) {
                selectable.add(genderString);
                break;
            }
        }
    }
    //	Sort the genders
    Collections.sort(selectable);
    //	Create a new model for the combobox and set it
    cbSex.setModel(new DefaultComboBoxModel(selectable));
    if (gender != null && selectable.contains(gender)) {
        cbSex.setSelectedItem(gender);
    }
}
Also used : RuleSet(pcgen.core.doomsdaybook.RuleSet) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Vector(java.util.Vector)

Example 29 with Vector

use of java.util.Vector in project OpenAM by OpenRock.

the class PolicyUtils method removePolicyRules.

/**
     * Removes policy rules defined for a service.
     * All the policy rules defined for a service in the system 
     * are removed.
     * @param token session token of the user doing the operation
     * @param serviceName name of the service
     */
public static void removePolicyRules(SSOToken token, String serviceName) throws SSOException, AMException {
    try {
        AMStoreConnection dpStore = new AMStoreConnection(token);
        PolicyManager pm = new PolicyManager(token);
        String org = pm.getOrganizationDN();
        AMOrganization rootOrg = (AMOrganization) dpStore.getOrganization(org);
        String dn, policyName, ruleName;
        DN rootDN;
        DN tmpDN;
        Set policyNames;
        Policy p;
        Rule rule, ruleDeleted;
        Iterator iter, ruleItr, levelItr;
        Map policyDNs = new HashMap();
        Map levelDNs = new HashMap();
        TreeMap sortedDNs;
        rootDN = DN.valueOf(SMSEntry.getRootSuffix());
        Map avPair = new HashMap();
        Set value = new HashSet();
        value.add("iPlanetAMPolicyConfigService");
        avPair.put(AMConstants.SERVICE_STATUS_ATTRIBUTE, value);
        Set subOrgs = null;
        subOrgs = rootOrg.searchSubOrganizations("*", avPair, AMConstants.SCOPE_SUB);
        for (Iterator iterOrg = subOrgs.iterator(); iterOrg.hasNext(); ) {
            dn = (String) iterOrg.next();
            PolicyManager pmSubOrg = new PolicyManager(token, dn);
            policyNames = pmSubOrg.getPolicyNames();
            iter = policyNames.iterator();
            while (iter.hasNext()) {
                policyName = (String) iter.next();
                p = pmSubOrg.getPolicy(policyName);
                if (!p.isReferralPolicy()) {
                    ruleItr = p.getRuleNames().iterator();
                    while (ruleItr.hasNext()) {
                        ruleName = (String) ruleItr.next();
                        rule = p.getRule(ruleName);
                        if ((rule.getServiceTypeName()).equalsIgnoreCase(serviceName)) {
                            if (PolicyManager.debug.messageEnabled()) {
                                debug.message("PolicyUtils.removePolicyRules():" + "policy: " + policyName + ",rule: " + ruleName);
                            }
                            ruleDeleted = p.removeRule(ruleName);
                            if (ruleDeleted != null) {
                                pmSubOrg.replacePolicy(p);
                            }
                        }
                    }
                } else {
                    //store the policies corresponding to DNs 
                    if (policyDNs.containsKey(dn)) {
                        ((Vector) policyDNs.get(dn)).add(policyName);
                    } else {
                        Vector policies = new Vector();
                        policies.add(policyName);
                        policyDNs.put(dn, policies);
                    }
                    //store DNs corresponding to levels wrt root
                    tmpDN = DN.valueOf(dn);
                    String levelDiff = String.valueOf(rootDN.size() - tmpDN.size());
                    if (levelDNs.containsKey(levelDiff)) {
                        ((Vector) levelDNs.get(levelDiff)).add(dn);
                    } else {
                        Vector DNs = new Vector();
                        DNs.add(dn);
                        levelDNs.put(levelDiff, DNs);
                    }
                }
            }
        }
        sortedDNs = new TreeMap(levelDNs);
        levelItr = sortedDNs.keySet().iterator();
        while (levelItr.hasNext()) {
            String level = (String) levelItr.next();
            Vector vDNs = (Vector) sortedDNs.get(level);
            for (int i = 0; i < vDNs.size(); i++) {
                dn = (String) vDNs.get(i);
                PolicyManager pmRefOrg = new PolicyManager(token, dn);
                Vector vPolicies = (Vector) policyDNs.get(dn);
                for (int j = 0; j < vPolicies.size(); j++) {
                    policyName = (String) vPolicies.get(j);
                    p = pmRefOrg.getPolicy(policyName);
                    ruleItr = p.getRuleNames().iterator();
                    while (ruleItr.hasNext()) {
                        ruleName = (String) ruleItr.next();
                        rule = p.getRule(ruleName);
                        if ((rule.getServiceTypeName()).equalsIgnoreCase(serviceName)) {
                            if (debug.messageEnabled()) {
                                debug.message("PolicyUtils.removePolicyRules():" + "referral policy: " + policyName + ",rule: " + ruleName);
                            }
                            ruleDeleted = p.removeRule(ruleName);
                            if (ruleDeleted != null) {
                                pmRefOrg.replacePolicy(p);
                            }
                        }
                    }
                }
            }
        }
    } catch (PolicyException pe) {
        debug.error("PolicyUtils.removePolicyRules():", pe);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) RDN(org.forgerock.opendj.ldap.RDN) DN(org.forgerock.opendj.ldap.DN) TreeMap(java.util.TreeMap) AMStoreConnection(com.iplanet.am.sdk.AMStoreConnection) AMOrganization(com.iplanet.am.sdk.AMOrganization) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Vector(java.util.Vector) HashSet(java.util.HashSet)

Example 30 with Vector

use of java.util.Vector in project OpenAM by OpenRock.

the class WebtopParser method walkTree.

/**
     * Parses and processes a Node.
     *
     * @param nd The Node to parse.
     * @return the parsed object for the node.
     * @throws Exception if node cannot be parsed or <code>ParseOutput</code>
     *         object cannot be instantiated.
     */
ParseOutput walkTree(Node nd) throws Exception {
    Vector elements = new Vector();
    Vector retelements;
    String pcdata = null;
    Hashtable atts = new Hashtable();
    NamedNodeMap nd_map = nd.getAttributes();
    if (nd_map != null) {
        for (int i = 0; i < nd_map.getLength(); i++) {
            Node att = nd_map.item(i);
            atts.put(att.getNodeName(), att.getNodeValue());
        }
    }
    for (Node ch = nd.getFirstChild(); ch != null; ch = ch.getNextSibling()) {
        switch(ch.getNodeType()) {
            case Node.ELEMENT_NODE:
                elements.addElement(walkTree(ch));
                break;
            case Node.TEXT_NODE:
                String tmp = stripWhitespaces(ch.getNodeValue());
                if (tmp != null && tmp.length() != 0) {
                    pcdata = tmp;
                }
                break;
            default:
        }
    }
    // lookup hash
    String po_name = (String) elemmap.get(nd.getNodeName());
    ParseOutput po;
    if (po_name == null) {
        if (useGenericClass) {
            po = (ParseOutput) new GenericNode();
        } else {
            throw new Exception("No class registered for" + nd.getNodeName());
        }
    } else {
        try {
            po = (ParseOutput) Class.forName(po_name).newInstance();
        } catch (Exception ex) {
            StringBuilder buf = new StringBuilder();
            buf.append("Got Exception while creating class instance of ");
            buf.append(nd.getNodeName());
            buf.append(" :");
            buf.append(ex.toString());
            throw new Exception(buf.toString());
        }
    }
    po.process(nd.getNodeName(), elements, atts, pcdata);
    return po;
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Hashtable(java.util.Hashtable) Node(org.w3c.dom.Node) Vector(java.util.Vector) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

Vector (java.util.Vector)3045 IOException (java.io.IOException)239 ArrayList (java.util.ArrayList)224 Test (org.junit.Test)182 Enumeration (java.util.Enumeration)174 Iterator (java.util.Iterator)173 Hashtable (java.util.Hashtable)170 File (java.io.File)159 List (java.util.List)143 HashMap (java.util.HashMap)128 ResultSet (java.sql.ResultSet)122 SQLException (java.sql.SQLException)95 Collection (java.util.Collection)87 PreparedStatement (java.sql.PreparedStatement)79 StringTokenizer (java.util.StringTokenizer)79 Statement (java.sql.Statement)60 Fault (com.sun.ts.lib.harness.EETest.Fault)54 HashSet (java.util.HashSet)54 Expression (cbit.vcell.parser.Expression)52 Map (java.util.Map)50