01: /*
02: * Created by IntelliJ IDEA.
03: * User: sanjib.ghosh@sun.com
04: * Date: Jan 29, 2002
05: * Time: $TME$
06: */
07: package com.sun.portal.rproxy.configservlet.server;
08:
09: import java.rmi.RemoteException;
10: import java.security.AccessController;
11: import java.util.HashMap;
12: import java.util.Map;
13:
14: import com.iplanet.am.util.AdminUtils;
15: import com.iplanet.sso.SSOException;
16: import com.iplanet.sso.SSOToken;
17: import com.iplanet.sso.SSOTokenManager;
18: import com.sun.identity.security.AdminTokenAction;
19: import com.sun.identity.sm.SMSException;
20: import com.sun.identity.sm.ServiceConfig;
21: import com.sun.identity.sm.ServiceConfigManager;
22: import com.sun.identity.sm.ServiceNotFoundException;
23: import com.sun.portal.rproxy.configservlet.GatewayRequest;
24: import com.sun.portal.rproxy.configservlet.Request;
25: import com.sun.portal.rproxy.configservlet.Response;
26: import com.sun.portal.rproxy.configservlet.ServiceHandler;
27:
28: public class GatewayServiceHandler implements ServiceHandler {
29:
30: private static final String RETRIEVE_INSTANCE = "retrieveInstance";
31:
32: public static final String SERVICE_NAME = "srapGatewayService";
33:
34: private static final String SUB_SCHEMA_NAME = "Gateway-Profiles";
35:
36: public Response handleRequest(Request request)
37: throws RemoteException {
38:
39: String requestType = request.getRequestType();
40: if (RETRIEVE_INSTANCE.equals(requestType)) {
41: Map returnedObject = executeRetrieveInstance(request);
42: return new Response(request.getServiceName(), request
43: .getRequestType(), returnedObject);
44: }
45: return new Response(request.getServiceName(), request
46: .getRequestType(), new RemoteException(
47: "Not able to find the method to execute"));
48: }
49:
50: private static Map executeRetrieveInstance(Request request)
51: throws RemoteException {
52:
53: try {
54: GatewayRequest gatewayRequest = (GatewayRequest) request;
55: String instanceName = gatewayRequest.getInstanceName();
56:
57: ServiceConfigManager configManager = new ServiceConfigManager(
58: SERVICE_NAME, getSSOToken(request));
59: /*
60: * ServiceConfig config =
61: * configManager.getObjectConfig(SUB_SCHEMA_NAME,
62: * ServiceConfigManager.Type.GLOBAL, null );
63: */
64:
65: ServiceConfig __config = configManager
66: .getGlobalConfig(null);
67: ServiceConfig config = __config
68: .getSubConfig(SUB_SCHEMA_NAME);
69:
70: ServiceConfig config2 = config.getSubConfig(instanceName);
71: return (null != config2) ? config2.getAttributes()
72: : new HashMap();
73: } catch (ServiceNotFoundException snfe) {
74: throw new RemoteException(
75: "service Not Found!!!, load service", snfe);
76: } catch (SMSException smse) {
77: throw new RemoteException(
78: "SMSException in retrieveing gateway config", smse);
79: } catch (SSOException smse) {
80: throw new RemoteException(
81: "SSOException in retrieveing gateway config", smse);
82: }
83:
84: }
85:
86: private static SSOToken getSSOToken(Request request)
87: throws RemoteException {
88:
89: String password = new String(AdminUtils.getAdminPassword());
90: return (SSOToken) AccessController
91: .doPrivileged(AdminTokenAction.getInstance());
92: /*
93: * return tokenManager.createSSOToken(new java.security.Principal() {
94: * public String getName() { return AdminUtils.getAdminDN(); } },
95: * password);
96: */// Removal of SSOToken deprecated API's CR #6273654
97: }
98:
99: }
|