Search in sources :

Example 1 with NamingResponse

use of com.iplanet.services.naming.share.NamingResponse in project OpenAM by OpenRock.

the class NamingService method processRequest.

private Response processRequest(Request req) {
    String content = req.getContent();
    NamingRequest nreq = NamingRequest.parseXML(content);
    NamingResponse nres = new NamingResponse(nreq.getRequestID());
    // get the version from nreq and check old
    float reqVersion = Float.valueOf(nreq.getRequestVersion()).floatValue();
    boolean limitNametable = (reqVersion > 1.0);
    // get the sesisonId from nreq
    String sessionId = nreq.getSessionId();
    try {
        if (sessionId == null) {
            nres.setNamingTable(NamingService.getNamingTable(limitNametable));
        } else {
            Hashtable tempHash = new Hashtable();
            tempHash = transferTable(NamingService.getNamingTable(limitNametable));
            Hashtable replacedTable = null;
            URL url = usePreferredNamingURL(nreq, reqVersion);
            if (url != null) {
                String uri = (reqVersion < 3.0) ? SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR) : WebtopNaming.getURI(url);
                if (uri.equals(Constants.EMPTY)) {
                    uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
                    if (namingDebug.messageEnabled()) {
                        namingDebug.message("uri is blank; adding " + uri);
                    }
                }
                replacedTable = replaceTable(tempHash, url.getProtocol(), url.getHost(), Integer.toString(url.getPort()), uri);
            } else {
                replacedTable = replaceTable(tempHash, sessionId);
            }
            if (replacedTable == null) {
                nres.setException("SessionID ---" + sessionId + "---is Invalid");
            } else {
                nres.setNamingTable(replacedTable);
            }
            nres.setAttribute(Constants.NAMING_AM_LB_COOKIE, sessionCookies.getLBCookie(sessionId));
        }
    } catch (Exception e) {
        String errorMsg = "Failed to process naming request";
        namingDebug.error(errorMsg, e);
        if (e.getMessage() != null) {
            errorMsg = e.getMessage();
        }
        nres.setException(errorMsg);
    }
    // %uri with the actual value
    if (reqVersion < 3.0) {
        String uri = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
        if (!uri.startsWith("/")) {
            uri = "/" + uri;
        }
        nres.replaceURI(uri);
    }
    return new Response(nres.toXMLString());
}
Also used : NamingResponse(com.iplanet.services.naming.share.NamingResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(com.iplanet.services.comm.share.Response) NamingRequest(com.iplanet.services.naming.share.NamingRequest) Hashtable(java.util.Hashtable) NamingResponse(com.iplanet.services.naming.share.NamingResponse) URL(java.net.URL) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) SMSException(com.sun.identity.sm.SMSException) MalformedURLException(java.net.MalformedURLException) SSOException(com.iplanet.sso.SSOException)

Example 2 with NamingResponse

use of com.iplanet.services.naming.share.NamingResponse in project OpenAM by OpenRock.

the class WebtopNaming method getNamingTable.

private static Hashtable getNamingTable(URL nameurl) throws Exception {
    Hashtable nametbl = null;
    NamingRequest nrequest = new NamingRequest(NamingRequest.reqVersion);
    Request request = new Request(nrequest.toXMLString());
    RequestSet set = new RequestSet(NAMING_SERVICE);
    set.addRequest(request);
    Vector responses = null;
    try {
        responses = PLLClient.send(nameurl, set);
        if (responses.size() != 1) {
            throw new Exception(NamingBundle.getString("unexpectedResponse"));
        }
        Response res = (Response) responses.elementAt(0);
        NamingResponse nres = NamingResponse.parseXML(res.getContent());
        if (nres.getException() != null) {
            throw new Exception(nres.getException());
        }
        nametbl = nres.getNamingTable();
    } catch (SendRequestException sre) {
        debug.error("Naming service connection failed for " + nameurl, sre);
    } catch (Exception e) {
        debug.error("getNamingTable: ", e);
    }
    return nametbl;
}
Also used : NamingResponse(com.iplanet.services.naming.share.NamingResponse) Response(com.iplanet.services.comm.share.Response) SendRequestException(com.iplanet.services.comm.client.SendRequestException) NamingRequest(com.iplanet.services.naming.share.NamingRequest) RequestSet(com.iplanet.services.comm.share.RequestSet) Hashtable(java.util.Hashtable) Request(com.iplanet.services.comm.share.Request) NamingRequest(com.iplanet.services.naming.share.NamingRequest) NamingResponse(com.iplanet.services.naming.share.NamingResponse) Vector(java.util.Vector) SendRequestException(com.iplanet.services.comm.client.SendRequestException) MalformedURLException(java.net.MalformedURLException)

Aggregations

Response (com.iplanet.services.comm.share.Response)2 NamingRequest (com.iplanet.services.naming.share.NamingRequest)2 NamingResponse (com.iplanet.services.naming.share.NamingResponse)2 MalformedURLException (java.net.MalformedURLException)2 Hashtable (java.util.Hashtable)2 SendRequestException (com.iplanet.services.comm.client.SendRequestException)1 Request (com.iplanet.services.comm.share.Request)1 RequestSet (com.iplanet.services.comm.share.RequestSet)1 ServerEntryNotFoundException (com.iplanet.services.naming.ServerEntryNotFoundException)1 SSOException (com.iplanet.sso.SSOException)1 SMSException (com.sun.identity.sm.SMSException)1 URL (java.net.URL)1 Vector (java.util.Vector)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1