This discussion is archived
3 Replies Latest reply: Jul 13, 2012 4:37 AM by 607252 RSS

oracle.security.jps.service.login.LoginService NullPointerException issue

438661 Newbie
Currently Being Moderated
All,

Please let me know if there is a different forum to address this issue.
I am trying to use OPSS for authenticating users in weblogic. below is the code. When i run the code all i am getting is a Nullpointerexception without any detail. I am using Embedded LDAP that comes with weblogic. Any help with debugging this is much aprpeciated.

thanks in advance,
Prasad.

public Subject authenticate(final String username, final char[] password) throws Exception {
// TBD
String [] selectiveModules = new String [] {"idstore.ldap"};

CallbackHandler cbh = new CustomCallbackHandler(username, password);
Subject sub = new Subject();
LoginService ls = JpsServiceLocator.getServiceLocator().lookup(LoginService.class);
LoginContext context = ls.getLoginContext(sub, cbh, selectiveModules);
context.login();
Subject s = context.getSubject();
return s;
}

public static void main(String[] args) {
TestLoginService testLoginService = new TestLoginService();

try {
System.out.println("authenticated user subject = " +
testLoginService.authenticate("prasad", "welcome1".toCharArray()));
// System.out.println("asserted user subject = " + testLoginService.assertUser("testUser"));
} catch (Exception e) {
e.printStackTrace();
}



jps-config.xml
------------------
<?xml version = '1.0' encoding = 'Cp1252'?>
<jpsConfig xmlns="http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd">
<property value="doasprivileged" name="oracle.security.jps.jaas.mode"/>
<propertySets></propertySets>
<serviceProviders>
<serviceProvider type="IDENTITY_STORE" name="idstore.ldap.provider"
class="oracle.security.jps.internal.idstore.ldap.LdapIdentityStoreProvider">
<description>Prototype LDAP-based ID store</description>
</serviceProvider>
</serviceProviders>
<serviceInstances>
<serviceInstance name="idstore.ldap" provider="idstore.ldap.provider">
<property name="idstore.type" value="OID"/>
<property name="security.principal.alias" value="JPS"/>
<property name="security.principal.key" value="ldap.credential"/>
<property name="subscriber.name" value="ou=myrealm,dc=NSCDomain"/>
<property name="ldap.url" value="ldap://localhost:7001"/>
<property name="max.search.filter.length" value="500"/>
<property name="username.attr" value="cn"/>
<property name="groupname.attr" value="cn"/>
<extendedProperty>
<name>user.search.bases</name>
<values>
<value>ou=people,ou=myrealm,dc=NSCDomain</value>
</values>
</extendedProperty>
<extendedProperty>
<name>group.search.bases</name>
<values>
<value>cn=groups,ou=myrealm,dc=NSCDomain</value>
</values>
</extendedProperty>
</serviceInstance>
</serviceInstances>
<jpsContexts default="ldap_idstore">
<jpsContext name="default">
<serviceInstanceRef ref="idstore.ldap"/>
</jpsContext>
</jpsContexts>
</jpsConfig>

Edited by: Prasad on Jul 26, 2011 12:49 PM
  • 1. Re: oracle.security.jps.service.login.LoginService NullPointerException issue
    376398 Newbie
    Currently Being Moderated
    The OPSS LoginService is not supported inside an App Server/Java EE container. The valid use case for this API is in a Java SE client. See http://docs.oracle.com/cd/E21764_01/core.1111/e10043/devauthn.htm#CACEDIDJ
  • 2. Re: oracle.security.jps.service.login.LoginService NullPointerException issue
    607252 Newbie
    Currently Being Moderated
    I am also getting similar kind of error. Were you able to resolve this exception. My jps config entry looks like:
    <?xml version="1.0" encoding="UTF-8" standalone='yes'?>
    <jpsConfig
         xmlns="http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.oracle.com/oracleas/schema/11/jps-config-11_1.xsd"
         schema-major-version="11" schema-minor-version="1">

         <property value="doasprivileged" name="oracle.security.jps.jaas.mode"/>

         <serviceProviders>
              <serviceProvider type="IDENTITY_STORE" name="idstore.ldap.provider"
                   class="oracle.security.jps.internal.idstore.ldap.LdapIdentityStoreProvider">
                   <description>Prototype LDAP-based ID store</description>
              </serviceProvider>

              <serviceProvider type="LOGIN" name="jaas.login.provider"
                   class="oracle.security.jps.internal.login.jaas.JaasLoginServiceProvider">
                   <description>This is Jaas Login Service Provider and is used to
                        configure login module service instances</description>
              </serviceProvider>
         </serviceProviders>

         <serviceInstances>
              <serviceInstance name="idstore.ldap" provider="idstore.ldap.provider">
                   <property name="idstore.type" value="IPLANET" />
                   <property name="security.principal" value="cn=Directory Manager" />
                   <property name="security.credential" value="abcd1234" />
                   <property name="ldap.url" value="ldap://localhost:3839" />
                   <property name="max.search.filter.length" value="500" />
                   <extendedProperty>
                        <name>user.search.bases</name>
                        <values>
                             <value>dc=mycompany,dc=co,dc=in</value>
                        </values>
                   </extendedProperty>
                   <property name="username.attr" value="uid" />
                   <property name="user.login.attr" value="uid" />

              </serviceInstance>

              <!-- IdStoreLoginModuleName -->

              <serviceInstance name="idstore.loginmodule" provider="jaas.login.provider">
                   <description>Identity Store Login Module</description>
                   <property name="loginModuleClassName"
                        value="oracle.security.jps.internal.jaas.module.idstore.IdStoreLoginModule" />
                   <property name="jaas.login.controlFlag" value="REQUIRED" />
              </serviceInstance>




              <!-- <serviceInstance location="./bootstrap" provider="credstoressp" name="bootstrap.cred">
                   <property value="./bootstrap" name="location" /> </serviceInstance> -->
         </serviceInstances>

         <jpsContexts default="default">
              <!-- This is the default JPS context. All the mendatory services and Login
                   Modules must be configured in this default context -->
              <jpsContext name="ldap_idstore">
                   <serviceInstanceRef ref="idstore.ldap" />
              </jpsContext>

         `
              <!-- <jpsContext name="bootstrap_credstore_context"> <serviceInstanceRef
                   ref="bootstrap.cred" /> </jpsContext> -->

              <jpsContext name="SwingAppUsingOPSS">
                   <serviceInstanceRef ref="idstore.loginmodule" />
              </jpsContext>

         </jpsContexts>
    </jpsConfig>
  • 3. Re: oracle.security.jps.service.login.LoginService NullPointerException issue
    607252 Newbie
    Currently Being Moderated
    I am using java standalone application where i am trying to authenticate using LoginService and getting the Null Pointer Exception as LoginService object itself is coming as null. Any help regarding this would be useful.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points