Share authentication customization

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member

Share authentication customization

Hello, 
I Was looking at your Profile on alfresco community and i found that you are an Expert i'm Honored to Learn from you , So I'm Trying to, Override the login Mechanism as this post 
Share authentication customization 
but i had a Problem It's Telling Me in Share logs : 
-------------------------------------------------------------------------------------------
2018-02-11 11:47:47,900 ERROR [org.alfresco.web.site] [http-apr-8080-exec-2] org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerExceptionjava.lang.NullPointerException
-------------------------------------------------------------------------------------------
what i did is :
                    ♦ Create a custom-slingshot-application-context.xml
                    ♦ Over-ride the Mapping Via /dologin/**=myloginContoller
                    ♦ adding this  : <bean id="myloginController"                  class="com.alfresco.ElitLoginController"/>
                   ♦ in my class i just created one Method that only takes Request and Response and log them


Thank you .

Edit by Axel Faust‌: This question was originally posted as a comment to this 5 year old thread. I have split it into its own question due to the extreme age of the original thread.

5 Replies
Highlighted
Master

Re: Share authentication customization

Without knowing the source of your custom ElitLoginController it is impossible to determine where that NullPointerException originates. But generally that exception is an indicator of a basic coding mistake. If you can provide either the source or a link to a public repository where it is managed, I might have a look. Also, there typically should be some sort of stack trace in any error message highlighting the origin (i.e. "Caused by" segment) - can you provide a more extensive log?

I generally advise everyone to prefer creating a new question instead of replying to one that has been inactive / closed for more than a year. That way, other people are much more likely to see it and respond, so you don't necessarily have to wait for me to notice...

Highlighted
Active Member

Re: Share authentication customization

Thank you this my login controller looks like :

------------------------------------------------------------------------

package com.alfresco;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class ElitLoginController{

    private Logger logger = LoggerFactory.getLogger(ElitLoginController.class);



    protected void onSuccess(HttpServletRequest request, HttpServletResponse response) throws Exception
    {
//        this.beforeLoginSuccess(request, response);
        logger.info("larbi is doing it");
        logger.info("Request is {}",request);
        logger.info("Response is {}",response);

//      super.onSuccess(request, response);
    }



}

--------------------------------------------------------------
Highlighted
Active Member

Re: Share authentication customization

share.log :

[org.alfresco.web.config.packaging.ModulePackageManager] [localhost-startStop-1] Found 2 module package(s)
[org.alfresco.web.config.packaging.ModulePackageManager] [localhost-startStop-1] Alfresco / Google Docs Share Module, 3.0.4, The Share side artifacts of the Alfresco / Google Docs Integration.
Share AMP project, 1.0-SNAPSHOT, Manages the lifecycle of the Share AMP (Alfresco Module Package)

[org.springframework.extensions.webscripts.TemplateProcessorRegistry] [localhost-startStop-1] Registered template processor freemarker for extension ftl
[org.springframework.extensions.webscripts.ScriptProcessorRegistry] [localhost-startStop-1] Registered script processor javascript for extension js
[org.springframework.extensions.webscripts.TemplateProcessorRegistry] [localhost-startStop-1] Registered template processor freemarker for extension ftl
[org.springframework.extensions.webscripts.ScriptProcessorRegistry] [localhost-startStop-1] Registered script processor javascript for extension js
[org.springframework.extensions.webscripts.DeclarativeRegistry] [localhost-startStop-1] Registered 394 Web Scripts (+0 failed), 412 URLs
[org.springframework.extensions.webscripts.DeclarativeRegistry] [localhost-startStop-1] Registered 8 Package Description Documents (+0 failed)
[org.springframework.extensions.webscripts.DeclarativeRegistry] [localhost-startStop-1] Registered 0 Schema Description Documents (+0 failed)
[org.springframework.extensions.webscripts.AbstractRuntimeContainer] [localhost-startStop-1] Initialised Surf Container Web Script Container (in 2782.788ms)
[org.springframework.extensions.webscripts.TemplateProcessorRegistry] [localhost-startStop-1] Registered template processor freemarker for extension ftl
[org.springframework.extensions.webscripts.ScriptProcessorRegistry] [localhost-startStop-1] Registered script processor javascript for extension js
[org.alfresco.web.site] [http-apr-8080-exec-2] org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
java.lang.NullPointerException
at org.springframework.extensions.surf.mvc.PageViewResolver.canHandle(PageViewResolver.java:91)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:395)
at org.springframework.extensions.webscripts.servlet.mvc.AbstractWebScriptViewResolver.resolveViewName(AbstractWebScriptViewResolver.java:64)
at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1255)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1196)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1001)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.extensions.webscripts.servlet.SecurityHeadersFilter.doFilter(SecurityHeadersFilter.java:177)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.extensions.webscripts.servlet.CSRFFilter.doFilter(CSRFFilter.java:322)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:474)
at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:443)
at org.springframework.extensions.webscripts.servlet.BeanProxyFilter.doFilter(BeanProxyFilter.java:80)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

Highlighted
Master

Re: Share authentication customization

Thanks... with the additional log output, specifically the lines

java.lang.NullPointerException
at org.springframework.extensions.surf.mvc.PageViewResolver.canHandle(PageViewResolver.java:91)

the cause of the issue becomes clear. The class ThreadLocalRequestContext is used to hold the current request in a static ThreadLocal, and for some reason there currently is no context set. The PageViewResolver accesses that context without doing a null-check first. The question now is: Why is that context not set (yet)? The code you provided did not provide any insight - in fact, it is too trivial to actually be compatible / useable as a login controller.

Speaking from experience customising the Share authentication, you rarely need a custom login controller. Since Share always talks to a backend via a so-called connector, and that this connector also handles authentication handshakes, it should be sufficient to add custom connector instead of overriding the entire login controller. Of course this is assuming your customisation is aimed at customising the authentication against an Alfresco Repository backend. Or are you trying to integrate with some other type of backend?

Highlighted
Active Member

Re: Share authentication customization

Thank you for your Reply

So what i need to do is adding some function that test if a user tries to login 3 times if it fail i want to disable his account using cmSmiley Tongueersion