This project has retired. For details please refer to its
Attic page.
UDDISecurityService xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juddi.v3.client.transport.wrapper;
18
19 import java.util.HashMap;
20
21 import org.apache.juddi.v3.client.ClassUtil;
22 import org.apache.juddi.v3.client.config.UDDIClient;
23 import org.apache.juddi.v3.client.config.UDDIClientContainer;
24 import org.apache.juddi.v3.client.transport.Transport;
25 import org.uddi.api_v3.DiscardAuthToken;
26 import org.uddi.api_v3.GetAuthToken;
27 import org.uddi.v3_service.UDDISecurityPortType;
28 import org.w3c.dom.Element;
29 import org.w3c.dom.Node;
30
31
32
33
34
35 public class UDDISecurityService {
36
37 private final static String DEFAULT_NODE_NAME = "default";
38
39 private String clientName = null;
40 private String nodeName = null;
41
42 private HashMap<String, Handler> operations = null;
43
44 public UDDISecurityService() {
45 super();
46 clientName = System.getProperty("org.apache.juddi.v3.client.name");
47 nodeName = System.getProperty("org.apache.juddi.v3.client.node.name",DEFAULT_NODE_NAME);
48 operations = new HashMap<String, Handler>();
49 operations.put("get_authToken", new Handler("getAuthToken", GetAuthToken.class));
50 operations.put("discard_authToken", new Handler("discardAuthToken", DiscardAuthToken.class));
51 }
52
53
54
55
56 public void validateRequest(String operation)
57 throws UnsupportedOperationException
58 {
59 if ((operation == null) || (operation.trim().length() == 0))
60 throw new UnsupportedOperationException("operation " + operation + " not supported");
61 }
62
63 public Node secure(Element uddiReq) throws Exception {
64 return secure(uddiReq, nodeName, clientName);
65 }
66
67 public Node secure(Element uddiReq, String nodeName, String clientName) throws Exception
68 {
69 UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
70 String clazz = client.getClientConfig().getUDDINode(nodeName).getProxyTransport();
71 Class<?> transportClass = ClassUtil.forName(clazz, this.getClass());
72 Transport transport = (Transport) transportClass.getConstructor(String.class, String.class).newInstance(clientName, nodeName);
73 UDDISecurityPortType security = transport.getUDDISecurityService();
74
75
76 RequestHandler requestHandler = new RequestHandler();
77 requestHandler.setPortType(security);
78
79 String operation = requestHandler.getOperation(uddiReq);
80 Handler opHandler = operations.get(operation);
81 if (opHandler == null) {
82 throw new IllegalArgumentException("Operation not found: " + operation);
83 }
84
85 requestHandler.setMethodName(opHandler.getMethodName());
86 requestHandler.setOperationClass(opHandler.getParameter());
87
88 @SuppressWarnings("unused")
89 String version = requestHandler.getVersion(uddiReq, operation);
90 validateRequest(operation);
91 return requestHandler.invoke(uddiReq);
92 }
93 }