Topic
  • 33 replies
  • Latest Post - ‏2015-05-08T18:20:17Z by nitin_Rujusoft
luwt
luwt
87 Posts

Pinned topic How to auto login with service account

‏2013-09-19T03:22:38Z |

is there a way to create an auto-login desktop using service account? so when user access normal desktop, they will need to login, but access this "Auto-login" desktop, they don't need to login.

if it is possible, where should i store the user id and password? As ICN use lots of javascript, need to find a way to prevent end user see the password from the javascript call, any ideas?

 

 

  • damorris
    damorris
    794 Posts

    Re: How to auto login with service account

    ‏2013-09-19T12:31:55Z  

    What repository are you trying to connect to in the desktop?

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-09-19T21:54:12Z  
    • damorris
    • ‏2013-09-19T12:31:55Z

    What repository are you trying to connect to in the desktop?

    FileNet P8 5.1.

  • damorris
    damorris
    794 Posts

    Re: How to auto login with service account

    ‏2013-09-20T15:06:27Z  
    • luwt
    • ‏2013-09-19T21:54:12Z

    FileNet P8 5.1.

    This isn't something supported out-of-the-box.  It might be possible to do it with a plugin but I'm not a 100% sure on that point.  I'll see if someone can confirm.

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-09-20T16:45:00Z  
    • damorris
    • ‏2013-09-20T15:06:27Z

    This isn't something supported out-of-the-box.  It might be possible to do it with a plugin but I'm not a 100% sure on that point.  I'll see if someone can confirm.

    Thanks. I understand this is not out-of-the-box.  I digged on the javascript source code and WEB-INF/struts-config.xml files, I found it is possible to create my own login script and backend services same as

    <action path="/p8/logon"type="com.ibm.ecm.struts.actions.p8.P8LogonAction" />

    But the question is how and where to configure to let the desktop call this new javascript unless I create a totally seperate web apps or another instance of ICN with my custom code, but that make it complicate when we need to upgrade ICN with new versions.

     

     

     

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-09-24T17:33:33Z  
    • luwt
    • ‏2013-09-20T16:45:00Z

    Thanks. I understand this is not out-of-the-box.  I digged on the javascript source code and WEB-INF/struts-config.xml files, I found it is possible to create my own login script and backend services same as

    <action path="/p8/logon"type="com.ibm.ecm.struts.actions.p8.P8LogonAction" />

    But the question is how and where to configure to let the desktop call this new javascript unless I create a totally seperate web apps or another instance of ICN with my custom code, but that make it complicate when we need to upgrade ICN with new versions.

     

     

     

    An ICN plugin is not a modification of struts-config.  It doesn't rely on struts.  (We are keeping struts internal to ICN and it may someday go away.)  Instead, it is a mechanism defined by ICN itself.  There are a set of Java classes (in navigatorAPI.jar) that can be extended to implement various functions like new actions, menus, features, viewers, and back-end services.  There is also the capability to pre and post-process any of the existing backend services.  These are call request and response filters and they are similar to servlet filters.  With a request filter on /p8/logon you should be able to test the desktop and add the password in so the user doesn't need to.

    But I'm not sure that is the behavior you're looking for.  You probably want to skip the login panel completely.   That might be possible but is much more complicated.  The first non-resource request that is sent to the backend is the /getDesktop.  There is a list of servers in the JSON response that corresponds to each repository defined on the desktop.  By modifying that JSON with a response filter a property, connected, can be added.  If the connected property is added with a value of true, then ICN will consider the server to already be connected and not show logon.  (You can see this if you look at the response to getDesktop if you refresh the browser after having previous logged in).

    So with that change the client would not show a login panel.  That's great, but in reality the user is not logged on, so the first p8 specific request will fail.  To keep that from happening, a silent login would need to happen during the getDesktop response filter.  This means invoking /p8/login from within the filter.   I'm pretty sure that is possible to do with J2EE or WAS API's

  • bemorris
    bemorris
    149 Posts

    Re: How to auto login with service account

    ‏2013-09-24T18:00:30Z  
    • BJOwings
    • ‏2013-09-24T17:33:33Z

    An ICN plugin is not a modification of struts-config.  It doesn't rely on struts.  (We are keeping struts internal to ICN and it may someday go away.)  Instead, it is a mechanism defined by ICN itself.  There are a set of Java classes (in navigatorAPI.jar) that can be extended to implement various functions like new actions, menus, features, viewers, and back-end services.  There is also the capability to pre and post-process any of the existing backend services.  These are call request and response filters and they are similar to servlet filters.  With a request filter on /p8/logon you should be able to test the desktop and add the password in so the user doesn't need to.

    But I'm not sure that is the behavior you're looking for.  You probably want to skip the login panel completely.   That might be possible but is much more complicated.  The first non-resource request that is sent to the backend is the /getDesktop.  There is a list of servers in the JSON response that corresponds to each repository defined on the desktop.  By modifying that JSON with a response filter a property, connected, can be added.  If the connected property is added with a value of true, then ICN will consider the server to already be connected and not show logon.  (You can see this if you look at the response to getDesktop if you refresh the browser after having previous logged in).

    So with that change the client would not show a login panel.  That's great, but in reality the user is not logged on, so the first p8 specific request will fail.  To keep that from happening, a silent login would need to happen during the getDesktop response filter.  This means invoking /p8/login from within the filter.   I'm pretty sure that is possible to do with J2EE or WAS API's

    Why would you want an auto-login to P8?

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-09-24T19:17:17Z  
    • BJOwings
    • ‏2013-09-24T17:33:33Z

    An ICN plugin is not a modification of struts-config.  It doesn't rely on struts.  (We are keeping struts internal to ICN and it may someday go away.)  Instead, it is a mechanism defined by ICN itself.  There are a set of Java classes (in navigatorAPI.jar) that can be extended to implement various functions like new actions, menus, features, viewers, and back-end services.  There is also the capability to pre and post-process any of the existing backend services.  These are call request and response filters and they are similar to servlet filters.  With a request filter on /p8/logon you should be able to test the desktop and add the password in so the user doesn't need to.

    But I'm not sure that is the behavior you're looking for.  You probably want to skip the login panel completely.   That might be possible but is much more complicated.  The first non-resource request that is sent to the backend is the /getDesktop.  There is a list of servers in the JSON response that corresponds to each repository defined on the desktop.  By modifying that JSON with a response filter a property, connected, can be added.  If the connected property is added with a value of true, then ICN will consider the server to already be connected and not show logon.  (You can see this if you look at the response to getDesktop if you refresh the browser after having previous logged in).

    So with that change the client would not show a login panel.  That's great, but in reality the user is not logged on, so the first p8 specific request will fail.  To keep that from happening, a silent login would need to happen during the getDesktop response filter.  This means invoking /p8/login from within the filter.   I'm pretty sure that is possible to do with J2EE or WAS API's

    Thanks so much. I want to completely skip login page, I think filter is what I need to look at, but how and where to configure the customized filter class? I seems can't find it anywhere in documentation or redbook. I guess filter is global change, can't be apply to certain desktop unless the filter check the desktop name or url?

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-09-24T19:47:55Z  
    • bemorris
    • ‏2013-09-24T18:00:30Z

    Why would you want an auto-login to P8?

    There are business cases we need to use a service account for certain read-only documents set, we create customized web apps before for this kinds of requirement, but since ICN have more richer features and extensible, we're trying to find out if it is possible to avoid create a seperate web apps.

     

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-09-25T16:38:56Z  
    • luwt
    • ‏2013-09-24T19:17:17Z

    Thanks so much. I want to completely skip login page, I think filter is what I need to look at, but how and where to configure the customized filter class? I seems can't find it anywhere in documentation or redbook. I guess filter is global change, can't be apply to certain desktop unless the filter check the desktop name or url?

    Response filters are implemented as part of an ICN plugin.  The sample plugin that comes with ICN (in the install directory under samples/samplePlugin) has some examples of response filters.  In particular, you can look at SamplePluginResponseFilter in the samplePlugin/src directory.  That sample is a response filter for search.  Your's would be a response filter for /getDesktop but it is similar structure. The jsonResponse is what you'd need to modify (using com.ibm.json classes).

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-09-26T01:35:27Z  
    • BJOwings
    • ‏2013-09-25T16:38:56Z

    Response filters are implemented as part of an ICN plugin.  The sample plugin that comes with ICN (in the install directory under samples/samplePlugin) has some examples of response filters.  In particular, you can look at SamplePluginResponseFilter in the samplePlugin/src directory.  That sample is a response filter for search.  Your's would be a response filter for /getDesktop but it is similar structure. The jsonResponse is what you'd need to modify (using com.ibm.json classes).

    Thanks again. I understand I can write a response filter, but how to make /getDesktop to use this filter?

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-09-26T16:14:12Z  
    • luwt
    • ‏2013-09-26T01:35:27Z

    Thanks again. I understand I can write a response filter, but how to make /getDesktop to use this filter?

    It should be clearer after looking at the sample plugin for a while.  A response filter implements the method getFilteredServices which indicates the service or services that the filter is to be invoked on.  For the SamplePluginResponseFilter, it looks like:

    public String[] getFilteredServices() {
      return new String[] { "/p8/search", "/cm/search", "/cmis/search", "/p8/openFolder", "/cm/openFolder", "/cmis/openFolder" };
    }
     
    Your filter would have a getFilteredService that looks like:

    public String[] getFilteredServices() {
      return new String[] { "/getDesktop" };
    }
     
  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-10-03T20:21:36Z  
    • BJOwings
    • ‏2013-09-26T16:14:12Z

    It should be clearer after looking at the sample plugin for a while.  A response filter implements the method getFilteredServices which indicates the service or services that the filter is to be invoked on.  For the SamplePluginResponseFilter, it looks like:

    public String[] getFilteredServices() {
      return new String[] { "/p8/search", "/cm/search", "/cmis/search", "/p8/openFolder", "/cm/openFolder", "/cmis/openFolder" };
    }
     
    Your filter would have a getFilteredService that looks like:

    public String[] getFilteredServices() {
      return new String[] { "/getDesktop" };
    }
     

    Hi BJOwings,

    I managed to set the "connected" value to "true" for both desktop object and each repository object in json response "servers" and did a p8logon call, it by pass the login page completely, that's good.  However, when I click the "browser" icon, it show's login page with "Your session expired. Log in again".

    any ideas? Do I need to set anything based on p8logon response?

    I am using ICN 2.0.2

    Thanks

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-10-04T03:35:35Z  
    • luwt
    • ‏2013-10-03T20:21:36Z

    Hi BJOwings,

    I managed to set the "connected" value to "true" for both desktop object and each repository object in json response "servers" and did a p8logon call, it by pass the login page completely, that's good.  However, when I click the "browser" icon, it show's login page with "Your session expired. Log in again".

    any ideas? Do I need to set anything based on p8logon response?

    I am using ICN 2.0.2

    Thanks

    That's good, you're past step 1.  Step 2 is to keep the requests from failing by actually having logged in silently in the response filter.  You can achieve this by invoking /p8/logon using JEE API's.  I'd suggest trying to use  request.getRequestDispatcher("/p8/logon").include().  For the parameters to include you'll need to subclass HttpServletRequestWrapper (wrapping the original request) and HttpServletResponse.

    It is the implementation of HttpServletRequestWrapper subclass that provide the /p8/logon with the repositoryId, userid and password parameters.   The custom HttpServletResponse class will receive the JSON response and any errors. 

    So this step is more complicated, but the JEE API is well documented and you might find other resources describing how to invoke a servlet from a servlet.

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-10-04T17:07:19Z  
    • BJOwings
    • ‏2013-10-04T03:35:35Z

    That's good, you're past step 1.  Step 2 is to keep the requests from failing by actually having logged in silently in the response filter.  You can achieve this by invoking /p8/logon using JEE API's.  I'd suggest trying to use  request.getRequestDispatcher("/p8/logon").include().  For the parameters to include you'll need to subclass HttpServletRequestWrapper (wrapping the original request) and HttpServletResponse.

    It is the implementation of HttpServletRequestWrapper subclass that provide the /p8/logon with the repositoryId, userid and password parameters.   The custom HttpServletResponse class will receive the JSON response and any errors. 

    So this step is more complicated, but the JEE API is well documented and you might find other resources describing how to invoke a servlet from a servlet.

    Thanks.  I was using new URL() to send a request but I guess then it lost the context.
     

    create wrapper for HttpServletRequestWrapper is doable as there are "request" object from filter() interface, but from where we can get the HttpServletResponse object in the context?

    my understanding, we can't create our own response objects out of it; the server creates instances of it and makes them available to your application.

    Or anything I was missing?

     

     

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-10-07T23:30:15Z  
    • luwt
    • ‏2013-10-04T17:07:19Z

    Thanks.  I was using new URL() to send a request but I guess then it lost the context.
     

    create wrapper for HttpServletRequestWrapper is doable as there are "request" object from filter() interface, but from where we can get the HttpServletResponse object in the context?

    my understanding, we can't create our own response objects out of it; the server creates instances of it and makes them available to your application.

    Or anything I was missing?

     

     

    You can make an implementation of the HttpServletResponse interface, which means an implementation of the ServletResponse super-interface as well.   That will require an implementation of a ServletOutputStream.  So, two classes to implement, but it is possible to do without requiring the original HttpServletResponse.

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-10-23T22:40:20Z  
    • BJOwings
    • ‏2013-10-07T23:30:15Z

    You can make an implementation of the HttpServletResponse interface, which means an implementation of the ServletResponse super-interface as well.   That will require an implementation of a ServletOutputStream.  So, two classes to implement, but it is possible to do without requiring the original HttpServletResponse.

    Hi BJOwings,

    I am stuck again :-(.   I implement both HttpServletRequestWrapper and HttpServletResponse, but now request.getRequestDispatcher("/p8/logon").include()  give me another error like "need a P8LogonMediator, but mediator in the request is a DesktopsMediator".  so far I can't find a way to create P8LogonMediator object as it require Structs messageResources object, I am not sure where I can get it.

    any suggestion?

     

     

  • BJOwings
    BJOwings
    185 Posts

    Re: How to auto login with service account

    ‏2013-10-25T20:51:36Z  
    • luwt
    • ‏2013-10-23T22:40:20Z

    Hi BJOwings,

    I am stuck again :-(.   I implement both HttpServletRequestWrapper and HttpServletResponse, but now request.getRequestDispatcher("/p8/logon").include()  give me another error like "need a P8LogonMediator, but mediator in the request is a DesktopsMediator".  so far I can't find a way to create P8LogonMediator object as it require Structs messageResources object, I am not sure where I can get it.

    any suggestion?

     

     

    I think there is a request attribute that is getting in the way (having been set earlier).  You'll need to implement HttpServletRequestWrapper.getAttribute and HttpServletRequestWrapper.setAttribute to get and set attributes (probably into local hashmap) rather than delegating to the wrapped request.

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2013-10-31T16:46:12Z  
    • BJOwings
    • ‏2013-10-25T20:51:36Z

    I think there is a request attribute that is getting in the way (having been set earlier).  You'll need to implement HttpServletRequestWrapper.getAttribute and HttpServletRequestWrapper.setAttribute to get and set attributes (probably into local hashmap) rather than delegating to the wrapped request.

    Thanks BJOwings.

    i set "mediator" attribute to null in the request and now I can get login response json successfully.  Now the question is how to merge the two json: one from login, the other from previous getDesktop together. I tried to copy all objects from getDesktop jsonResponse to login response and set back, but get below errors:

    "A connection to the web client cannot be established by using the following URL: ..

    This error can be caused by a configuration problem on the web application server or by a problem with the web client.

    Try to log in again. If the problem persists, report this error to your system administrator.

    The following error was returned: {}&&{"passwordRulesURL":"","connected":"true","userid":"ecmceadmin","navigatorBuild":"icn202.333","uiLabels":[{"id":"app_class_label","localeData":{"id":"app_class_label"},"labelData":{"id":"app_class_label"},"labelKey":"class_label","type":"application"},
    ......................"

    Not sure where is the ".." from?  I printed out all attributes from original request, don't see anything useful.

    Thanks again

  • fkiebel
    fkiebel
    1 Post

    Re: How to auto login with service account

    ‏2014-09-10T14:32:21Z  

    Hi all,

    Dear luvwt, have you achieved your objective on this topic ? I will be very interesting in the result and the way you use to achieve this. Can you share it please ?

    Thanks a lot.

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2014-09-16T21:18:10Z  
    • fkiebel
    • ‏2014-09-10T14:32:21Z

    Hi all,

    Dear luvwt, have you achieved your objective on this topic ? I will be very interesting in the result and the way you use to achieve this. Can you share it please ?

    Thanks a lot.

    I got it work via java servlet filter with http request wrapper. the wrapper send request to /p8/logon and then redirect to the original ICN url. I tried a few ways using ICN filter, but could not figure it out.

  • nitin_Rujusoft
    nitin_Rujusoft
    9 Posts

    Re: How to auto login with service account

    ‏2015-03-25T20:21:56Z  
    • luwt
    • ‏2014-09-16T21:18:10Z

    I got it work via java servlet filter with http request wrapper. the wrapper send request to /p8/logon and then redirect to the original ICN url. I tried a few ways using ICN filter, but could not figure it out.

    Hello luwt -

    Can you provide some more details (or sample code) as how you have achieved this? It will be very helpful. Thanks!

    - N

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2015-04-24T00:11:19Z  

    Hello luwt -

    Can you provide some more details (or sample code) as how you have achieved this? It will be very helpful. Thanks!

    - N

    here are some sample code for the java servlet filter, be aware new ICN patches could break this approach!

    private void doBeforeProcessing(RequestWrapper request, ResponseWrapper response)
                throws IOException, ServletException {
            if (debug) {
                log("AutoLoginFilter:DoBeforeProcessing");
            }
     
            if (request.getParameter("desktop").equalsIgnoreCase("test1")) {
             request.setParameter("resositoryId", new String[] {"yourrepository"});
             request.setParameter("userid", new String[] {"user1"});
             request.setParameter("password", new String[] {"Password"});
             request.getRequestDispatcher("/logon.do").include(request, response);
            }
     
        }
     public void doFilter(ServletRequest request, ServletResponse response,
                FilterChain chain)
                throws IOException, ServletException {
            
            if (debug) {
                log("AutoLoginFilter:doFilter()");
            }
     
            RequestWrapper wrappedRequest = new RequestWrapper((HttpServletRequest) request);
            ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response);
            
            doBeforeProcessing(wrappedRequest, wrappedResponse);
            
            Throwable problem = null;
            
            try {
                chain.doFilter(wrappedRequest, wrappedResponse);
            } catch (Throwable t) {

           t.printStackTrace();

           }

    class RequestWrapper extends HttpServletRequestWrapper {
            
            public RequestWrapper(HttpServletRequest request) {
                super(request);
            }
            // You might, for example, wish to add a setParameter() method. To do this
            // you must also override the getParameter, getParameterValues, getParameterMap,
            // and getParameterNames methods.
            protected Hashtable localParams = null;
            
            public void setParameter(String name, String[] values) {
                if (debug) {
                    System.out.println("AutoLoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = " + localParams);
                }
                
                if (localParams == null) {
                    localParams = new Hashtable();
                    // Copy the parameters from the underlying request.
                    Map wrappedParams = getRequest().getParameterMap();
                    Set keySet = wrappedParams.keySet();
                    for (Iterator it = keySet.iterator(); it.hasNext();) {
                        Object key = it.next();
                        Object value = wrappedParams.get(key);
                        localParams.put(key, value);
                    }
                }
                localParams.put(name, values);
            }
            
            @Override
            public String getParameter(String name) {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameter(" + name + ") localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameter(name);
                }
                Object val = localParams.get(name);
                if (val instanceof String) {
                    return (String) val;
                }
                if (val instanceof String[]) {
                    String[] values = (String[]) val;
                    return values[0];
                }
                return (val == null ? null : val.toString());
            }
            
            @Override
            public String[] getParameterValues(String name) {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterValues(" + name + ") localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterValues(name);
                }
                return (String[]) localParams.get(name);
            }
            
            @Override
            public Enumeration getParameterNames() {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterNames() localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterNames();
                }
                return localParams.keys();
            }        
            
            @Override
            public Map getParameterMap() {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterMap() localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterMap();
                }
                return localParams;
            }
        }
     

     

     

     

    Updated on 2015-04-24T00:12:32Z at 2015-04-24T00:12:32Z by luwt
  • nitin_Rujusoft
    nitin_Rujusoft
    9 Posts

    Re: How to auto login with service account

    ‏2015-04-27T18:35:46Z  
    • luwt
    • ‏2015-04-24T00:11:19Z

    here are some sample code for the java servlet filter, be aware new ICN patches could break this approach!

    private void doBeforeProcessing(RequestWrapper request, ResponseWrapper response)
                throws IOException, ServletException {
            if (debug) {
                log("AutoLoginFilter:DoBeforeProcessing");
            }
     
            if (request.getParameter("desktop").equalsIgnoreCase("test1")) {
             request.setParameter("resositoryId", new String[] {"yourrepository"});
             request.setParameter("userid", new String[] {"user1"});
             request.setParameter("password", new String[] {"Password"});
             request.getRequestDispatcher("/logon.do").include(request, response);
            }
     
        }
     public void doFilter(ServletRequest request, ServletResponse response,
                FilterChain chain)
                throws IOException, ServletException {
            
            if (debug) {
                log("AutoLoginFilter:doFilter()");
            }
     
            RequestWrapper wrappedRequest = new RequestWrapper((HttpServletRequest) request);
            ResponseWrapper wrappedResponse = new ResponseWrapper((HttpServletResponse) response);
            
            doBeforeProcessing(wrappedRequest, wrappedResponse);
            
            Throwable problem = null;
            
            try {
                chain.doFilter(wrappedRequest, wrappedResponse);
            } catch (Throwable t) {

           t.printStackTrace();

           }

    class RequestWrapper extends HttpServletRequestWrapper {
            
            public RequestWrapper(HttpServletRequest request) {
                super(request);
            }
            // You might, for example, wish to add a setParameter() method. To do this
            // you must also override the getParameter, getParameterValues, getParameterMap,
            // and getParameterNames methods.
            protected Hashtable localParams = null;
            
            public void setParameter(String name, String[] values) {
                if (debug) {
                    System.out.println("AutoLoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = " + localParams);
                }
                
                if (localParams == null) {
                    localParams = new Hashtable();
                    // Copy the parameters from the underlying request.
                    Map wrappedParams = getRequest().getParameterMap();
                    Set keySet = wrappedParams.keySet();
                    for (Iterator it = keySet.iterator(); it.hasNext();) {
                        Object key = it.next();
                        Object value = wrappedParams.get(key);
                        localParams.put(key, value);
                    }
                }
                localParams.put(name, values);
            }
            
            @Override
            public String getParameter(String name) {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameter(" + name + ") localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameter(name);
                }
                Object val = localParams.get(name);
                if (val instanceof String) {
                    return (String) val;
                }
                if (val instanceof String[]) {
                    String[] values = (String[]) val;
                    return values[0];
                }
                return (val == null ? null : val.toString());
            }
            
            @Override
            public String[] getParameterValues(String name) {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterValues(" + name + ") localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterValues(name);
                }
                return (String[]) localParams.get(name);
            }
            
            @Override
            public Enumeration getParameterNames() {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterNames() localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterNames();
                }
                return localParams.keys();
            }        
            
            @Override
            public Map getParameterMap() {
                if (debug) {
                    System.out.println("AutoLoginFilter::getParameterMap() localParams = " + localParams);
                }
                if (localParams == null) {
                    return getRequest().getParameterMap();
                }
                return localParams;
            }
        }
     

     

     

     

    Hello luwt -

    Thanks for code snippet. Still some things are not clear to me. Have you implemented in custom servlet outside navigator context? How you are sending request to /p8/logon and then redirect to the original ICN url? Some more details will be very helpful. Also can you share your web.xml and how call trace happens?

    - N

  • luwt
    luwt
    87 Posts

    Re: How to auto login with service account

    ‏2015-04-28T22:53:01Z  

    Hello luwt -

    Thanks for code snippet. Still some things are not clear to me. Have you implemented in custom servlet outside navigator context? How you are sending request to /p8/logon and then redirect to the original ICN url? Some more details will be very helpful. Also can you share your web.xml and how call trace happens?

    - N

    the servlet filter is inside navigator, so you need to modify navigator web.xml. 

     

      <filter>
            <filter-name>AutoLoginFilter</filter-name>
            <filter-class>AutoLoginRequestFilter</filter-class>
         </filter>
     
         <filter-mapping>
            <filter-name>AutoLoginFilter</filter-name>
            <url-pattern>/jaxrs/getDesktop</url-pattern>
            <dispatcher>REQUEST</dispatcher>
         </filter-mapping>
     

     

    btw, one typo in above code, it should be 

    request.getRequestDispatcher("/jaxrs/logon").include(request, response); instead of 

    request.getRequestDispatcher("/logon.do").include(request, response);

     

    Updated on 2015-04-28T22:58:23Z at 2015-04-28T22:58:23Z by luwt