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);
}
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations