Skip to main content

Programmatic Login - No Credential Exception

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
6 replies [Last post]
lhanusiak
Offline
Joined: 2011-04-04

I'm trying to develop both web and standalone client (java se) for bean deployed on glassfish v3.1. I web client (GWT) everything works perfect but in standalone client I'm receving following exception



2011-04-06 08:26:50 com.sun.appserv.security.AppservPasswordLoginModule extractCredentials
SEVERE: SEC1105: A PasswordCredential was required but not provided.
2011-04-06 08:26:50 com.sun.appserv.security.ProgrammaticLogin login
SEVERE: SEC9050: Programmatic login failed
com.sun.enterprise.security.auth.login.common.LoginException: javax.security.auth.login.LoginException: No credentials.
    at com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:889)
    at com.sun.enterprise.security.common.AppservAccessController.doPrivileged(AppservAccessController.java:61)
    at com.sun.enterprise.security.auth.login.LoginContextDriver.doClientLogin(LoginContextDriver.java:881)
    at com.sun.appserv.security.ProgrammaticLogin$1.run(ProgrammaticLogin.java:184)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:168)
    at com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:239)
    at com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:211)
    at ClientStarter.main(ClientStarter.java:27)
Caused by: javax.security.auth.login.LoginException: No credentials.
    at com.sun.appserv.security.AppservPasswordLoginModule.extractCredentials(AppservPasswordLoginModule.java:336)
    at com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:145)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at javax.security.auth.login.LoginContext.invoke(Unknown Source)
    at javax.security.auth.login.LoginContext.access$000(Unknown Source)
    at javax.security.auth.login.LoginContext$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.login.LoginContext.invokePriv(Unknown Source)
    at javax.security.auth.login.LoginContext.login(Unknown Source)
    at com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:887)
    ... 8 more

Moreover I'm receiving mentioned exception right after calling 'login' method from ProgrammaticLogin class.
Am I missing something? Any ideas on how to fix this problem, will be greatly appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kumar Jayanti Guest
Offline
Joined: 2011-04-02

For the appclient command line did you set
-Djava.security.auth.login.config=/lib/appclient/appclientlogin.conf

On 06-Apr-2011, at 12:04 PM, forums@java.net wrote:

> I'm trying to develop both web and standalone client (java se) for bean
> deployed on glassfish v3.1. I web client (GWT) everything works perfect but
> in standalone client I'm receving following exception


 2011-04-06
> 08:26:50 com.sun.appserv.security.AppservPasswordLoginModule
> extractCredentials SEVERE: SEC1105: A PasswordCredential was required but not
> provided. 2011-04-06 08:26:50 com.sun.appserv.security.ProgrammaticLogin
> login SEVERE: SEC9050: Programmatic login failed
> com.sun.enterprise.security.auth.login.common.LoginException:
> javax.security.auth.login.LoginException: No credentials. at
> com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:889)
> at
> com.sun.enterprise.security.common.AppservAccessController.doPrivileged(AppservAccessController.java:61)
> at
> com.sun.enterprise.security.auth.login.LoginContextDriver.doClientLogin(LoginContextDriver.java:881)
> at
> com.sun.appserv.security.ProgrammaticLogin$1.run(ProgrammaticLogin.java:184)
> at java.security.AccessController.doPrivileged(Native Method) at
> com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:168)
> at
> com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:239)
> at
> com.sun.appserv.security.ProgrammaticLogin.login(ProgrammaticLogin.java:211)
> at ClientStarter.main(ClientStarter.java:27) Caused by:
> javax.security.auth.login.LoginException: No credentials. at
> com.sun.appserv.security.AppservPasswordLoginModule.extractCredentials(AppservPasswordLoginModule.java:336)
> at
> com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:145)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
> java.lang.reflect.Method.invoke(Unknown Source) at
> javax.security.auth.login.LoginContext.invoke(Unknown Source) at
> javax.security.auth.login.LoginContext.access$000(Unknown Source) at
> javax.security.auth.login.LoginContext$4.run(Unknown Source) at
> java.security.AccessController.doPrivileged(Native Method) at
> javax.security.auth.login.LoginContext.invokePriv(Unknown Source) at
> javax.security.auth.login.LoginContext.login(Unknown Source) at
> com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:887)
> ... 8 more 
Moreover I'm receiving mentioned exception right after
> calling 'login' method from ProgrammaticLogin class. Am I missing something?
> Any ideas on how to fix this problem, will be greatly appreciated.
>
> --
>
> [Message sent by forum member 'lhanusiak']
>
> View Post: http://forums.java.net/node/789029
>
>

lhanusiak
Offline
Joined: 2011-04-04

Thank you for your answer. I'm using login.conf both in web in standalone mode, but I'm including it in my java code as shown below



System.setProperty("java.security.auth.login.config", "login.conf");

and content of my login.conf file



default {
    com.sun.enterprise.security.auth.login.LDAPLoginModule required;
}

In my opinion loading login.conf is not the problem in my case. However in my standalone application I was able to load only default realm and I have no clue why. In web mode everything works perfectly fine.

If you require more details, please see [link]http://www.java.net/forum/topic/glassfish/glassfish/gwt-development-mode-programmatic-login-problem[/link]

I will greatly appreciate any suggestion that you will come up with. I'm looking forward to hearing from you again soon.

Kumar Jayanti Guest
Offline
Joined: 2011-04-02

On 07-Apr-2011, at 1:56 AM, forums@java.net wrote:

> Thank you for your answer. I'm using login.conf both in web in standalone
> mode, but I'm including it in my java code as shown below
>
>


 System.setProperty("java.security.auth.login.config", "login.conf");
> 

> and content of my login.conf file
>
>

 default { com.sun.enterprise.security.auth.login.LDAPLoginModule
> required; } 

> In my opinion loading login.conf is not the problem in my case. However in my
> standalone application I was able to load only default realm and I have no
> clue why. In web mode everything works perfectly fine.
> If you require more details, please see
> [link]http://www.java.net/forum/topic/glassfish/glassfish/gwt-development-mode-programmatic-login-problem[/link]
> I will greatly appreciate any suggestion that you will come up with. I'm
> looking forward to hearing from you again soon.

Please use the login.conf file that i suggested, that will make sure the credentials are populated in the right place in case of appclient/standalone app. What does the Standalone app do after that, does it invoke an EJB or a WebService ?.

>
>
> --
>
> [Message sent by forum member 'lhanusiak']
>
> View Post: http://forums.java.net/node/789029
>
>

lhanusiak
Offline
Joined: 2011-04-04

I'm sorry for keeping you waiting so long. Indeed using glassfish version of appclientlogin.conf solved problem with 'No credential Exception', so big thanks for that.

After a few tests another problem came to my attention. I noticed that ProgrammaticLogin ignores provided realm name and uses glassfish default realm. I managed to switch bean realm using sun-ejb-jar.xml. I wonder if is there any simple way to dynamically switch realm from client code? Thank you for your help in advance.

Kumar Jayanti Guest
Offline
Joined: 2011-04-02

On 11-Apr-2011, at 11:46 AM, forums@java.net wrote:

> I'm sorry for keeping you waiting so long. Indeed using glassfish version of
> appclientlogin.conf solved problem with 'No credential Exception', so big
> thanks for that. After a few tests another problem came to my attention. I
> noticed that ProgrammaticLogin ignores provided realm name and uses glassfish
> default realm. I managed to switch bean realm using sun-ejb-jar.xml. I wonder
> if is there any simple way to dynamically switch realm from client code?

NO. It is generally not a good idea for the client to dictate which realm it wants to authenticate against. Instead the server should enforce the realm in which the client should be authenticated.

> Thank you for your help in advance.
>
> --
>
> [Message sent by forum member 'lhanusiak']
>
> View Post: http://forums.java.net/node/789029
>
>

lhanusiak
Offline
Joined: 2011-04-04

Thank you. Knowing this will make my work much eaiser. However, I ran into another problem. I moved my standalone client code into servlet running on non-javaee web container and added maven system dependecy to gf-client.jar. When I run my code, Programmatic Login causes following exception



[ERROR] java.lang.RuntimeException: Orb initialization erorr
[ERROR]     at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
[ERROR]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
[ERROR]     at pl.com.mcg.server.TestServiceImpl.login(TestServiceImpl.java:101)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR]     at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)
[ERROR]     at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[ERROR]     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[ERROR]     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
[ERROR]     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[ERROR]     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[ERROR]     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[ERROR]     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
[ERROR]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]     at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
[ERROR]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]     at org.mortbay.jetty.Server.handle(Server.java:324)
[ERROR]     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[ERROR]     at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
[ERROR]     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
[ERROR]     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
[ERROR]     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[ERROR]     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
[ERROR]     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] Caused by: java.lang.NullPointerException
[ERROR]     at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
[ERROR]     ... 35 more
[ERROR] javax.naming.NamingException: Lookup failed for 'pl.com.mcg.ejb.remote.AuthorizationServiceRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=127.0.0.1, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=127.0.0.1, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]]
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
[ERROR]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
[ERROR]     at pl.com.mcg.server.TestServiceImpl.login(TestServiceImpl.java:101)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR]     at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR]     at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:207)
[ERROR]     at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243)
[ERROR]     at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[ERROR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[ERROR]     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
[ERROR]     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
[ERROR]     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[ERROR]     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
[ERROR]     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
[ERROR]     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
[ERROR]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]     at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
[ERROR]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[ERROR]     at org.mortbay.jetty.Server.handle(Server.java:324)
[ERROR]     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
[ERROR]     at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
[ERROR]     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
[ERROR]     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
[ERROR]     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
[ERROR]     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
[ERROR]     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
[ERROR] Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=127.0.0.1, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.lang.RuntimeException: Orb initialization erorr]
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:352)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
[ERROR]     ... 30 more
[ERROR] Caused by: java.lang.RuntimeException: Orb initialization erorr
[ERROR]     at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:148)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
[ERROR]     at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
[ERROR]     ... 31 more
[ERROR] Caused by: java.lang.NullPointerException
[ERROR]     at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
[ERROR]     ... 35 more

Do you have any idea what this could be caused by?