Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
gary b
programmatically logged in
April 16, 2013 1:14 AM
Answer

gary b

Rank: Junior Member

Posts: 75

Join Date: February 2, 2013

Recent Posts

In my portal I have created a custom signup portlet, my requirement is onces user finished with account creation he should automatically logged in to portal and redirect to desired page.
I have implemented the method key :
1MethodKey key = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
2PortalClassInvoker.invoke(false, key, new Object[] { PortalUtil.getHttpServletRequest(actionRequest), PortalUtil.getHttpServletResponse(actionResponse), emailaddress, password, false, null});

but it is giving below error.
1Servlet.service() for servlet investor Servlet threw exception
2java.lang.NullPointerException
Apoorva Prakash
RE: progamittically logged in
April 15, 2013 8:13 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

Hi GArima,

I suggest you to go ahead with the following for login:

1LoginUtil.login(request, response, loginUser, password, false, CompanyConstants.AUTH_TYPE_EA);


HTH...

Thanks and Regards,
Apoorva Prakash
gary b
RE: progamittically logged in
April 15, 2013 10:57 PM
Answer

gary b

Rank: Junior Member

Posts: 75

Join Date: February 2, 2013

Recent Posts

Apoorva Prakash:
Hi GArima,

I suggest you to go ahead with the following for login:

1LoginUtil.login(request, response, loginUser, password, false, CompanyConstants.AUTH_TYPE_EA);


HTH...

Thanks and Regards,
Apoorva Prakash



Thanks Apoorva but we cant access LoginUti ldirectly in our custom portlets as this class exist in portal-impl.jar.
Chirag Patadia
RE: progamittically logged in
April 16, 2013 12:19 AM
Answer

Chirag Patadia

Rank: Junior Member

Posts: 29

Join Date: February 2, 2012

Recent Posts

Hi Garima,

Check below link which contains custom authentication logic, it might help to resolve your problem.

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Developing+a+Custom+Authentication+System

Best Regards,
Chirag Patadia.
gary b
RE: programmatically logged in
April 16, 2013 3:38 AM
Answer

gary b

Rank: Junior Member

Posts: 75

Join Date: February 2, 2013

Recent Posts

Hi,

I have resolved the
1Servlet.service() for servlet investor Servlet threw exception
error but now i am getting below exception.
I am getting proper userid, email address and password.
Error is on method getAuthenticatedUserId(request, login, password, authType) of LoginUtil.java.
Can some one tell me where I am going wrong.


  1com.liferay.portal.security.auth.AuthException
  2    at com.liferay.portlet.login.util.LoginUtil.getAuthenticatedUserId(LoginUtil.java:175)
  3    at com.liferay.portlet.login.util.LoginUtil.login(LoginUtil.java:245)
  4    at sun.reflect.GeneratedMethodAccessor997.invoke(Unknown Source)
  5    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  6    at java.lang.reflect.Method.invoke(Method.java:597)
  7    at com.liferay.portal.kernel.util.MethodHandler.invoke(MethodHandler.java:77)
  8    at com.liferay.portal.kernel.util.PortalClassInvoker.invoke(PortalClassInvoker.java:42)
  9    at com.leo.investor.portal.Investor.investorDetailSingupForm(Investor.java:285)
 10    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 11    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 12    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 13    at java.lang.reflect.Method.invoke(Method.java:597)
 14    at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:153)
 15    at com.liferay.util.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:250)
 16    at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:80)
 17    at com.liferay.util.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:220)
 18    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
 19    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
 20    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
 21    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 22    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 23    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 24    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 25    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
 26    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 27    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 28    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
 29    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
 30    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
 31    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:534)
 32    at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:579)
 33    at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:294)
 34    at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:944)
 35    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:688)
 36    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)
 37    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
 38    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
 39    at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:176)
 40    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
 41    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
 42    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
 43    at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:560)
 44    at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:537)
 45    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 46    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 47    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 48    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 49    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 50    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 51    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 52    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 53    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 54    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 55    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
 56    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 57    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 58    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 59    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
 60    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 61    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 62    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
 63    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
 64    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
 65    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
 66    at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:138)
 67    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 68    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 69    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 70    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
 71    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 72    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 73    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 74    at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:335)
 75    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 76    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 77    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 78    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 79    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 80    at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
 81    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 82    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 83    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 84    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 85    at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
 86    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 87    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 88    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 89    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 90    at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:241)
 91    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
 92    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
 93    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
 94    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 95    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 96    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
 97    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
 98    at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:246)
 99    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
100    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
101    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
102    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
103    at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
104    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
105    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
106    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
107    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
108    at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
109    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
110    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
111    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
112    at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
113    at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:216)
114    at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
115    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
116    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
117    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
118    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
119    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
120    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
121    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
122    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
123    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
124    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
125    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
126    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
127    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
128    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
129    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
130    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
131    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
132    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
133    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
134    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
135    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
136    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
137    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
138    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
139    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
140    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
141    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
142    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
143    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
144    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
145    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
146    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
147    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
148    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
149    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
150    at java.lang.Thread.run(Thread.java:619)
Apoorva Prakash
RE: progamittically logged in
April 16, 2013 3:44 AM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

garima bhandari:

Thanks Apoorva but we cant access LoginUti ldirectly in our custom portlets as this class exist in portal-impl.jar.


I've used this in EXT-plugin.
gary b
RE: programmatically logged in
April 16, 2013 4:03 AM
Answer

gary b

Rank: Junior Member

Posts: 75

Join Date: February 2, 2013

Recent Posts

Thanks Apporva but I am using a custom portlet for registration which store data in user_ and then in my custom table.
Plesae tell me if I create ext for this method
1LoginUtil.login(request, response, loginUser, password, false, CompanyConstants.AUTH_TYPE_EA);
how will I call it from my portlet.
Apoorva Prakash
RE: programmatically logged in
April 16, 2013 11:24 PM
Answer

Apoorva Prakash

Rank: Liferay Master

Posts: 659

Join Date: June 15, 2010

Recent Posts

garima bhandari:
Thanks Apporva but I am using a custom portlet for registration which store data in user_ and then in my custom table.
Plesae tell me if I create ext for this method
1LoginUtil.login(request, response, loginUser, password, false, CompanyConstants.AUTH_TYPE_EA);
how will I call it from my portlet.


Hello Garima,

You can try with the following way:

1MethodKey methodKey = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
2PortalClassInvoker.invoke(false, methodKey, new Object[] { PortalUtil.getHttpServletRequest(portletRequest), PortalUtil.getHttpServletResponse(portletResponse), username, password false, null});


HTH.

Thanks and Regards,
Apoorva Prakash
gary b
RE: programmatically logged in
May 2, 2013 2:10 AM
Answer

gary b

Rank: Junior Member

Posts: 75

Join Date: February 2, 2013

Recent Posts

Apoorva Prakash:
garima bhandari:
Thanks Apporva but I am using a custom portlet for registration which store data in user_ and then in my custom table.
Plesae tell me if I create ext for this method
1LoginUtil.login(request, response, loginUser, password, false, CompanyConstants.AUTH_TYPE_EA);
how will I call it from my portlet.


Hello Garima,

You can try with the following way:

1MethodKey methodKey = new MethodKey("com.liferay.portlet.login.util.LoginUtil", "login", HttpServletRequest.class, HttpServletResponse.class, String.class, String.class, boolean.class, String.class);
2PortalClassInvoker.invoke(false, methodKey, new Object[] { PortalUtil.getHttpServletRequest(portletRequest), PortalUtil.getHttpServletResponse(portletResponse), username, password false, null});


HTH.

Thanks and Regards,
Apoorva Prakash


Hi Apoorva,

I have already tried this.....You can see the same in my first post.. :-)