1 Reply Latest reply on Jun 22, 2011 7:19 AM by Vladimir Seprak

    configure seam security

    Vladimir Seprak Newbie

      Hello,


      I am trying to include seam security in my JEE6 app. running on jboss6.
      I have created authenticator:




      import javax.inject.Inject;
      
      
      import org.jboss.seam.security.Authenticator;
      import org.jboss.seam.security.BaseAuthenticator;
      import org.jboss.seam.security.Credentials;
      import org.picketlink.idm.impl.api.PasswordCredential;
      import org.picketlink.idm.impl.api.model.SimpleUser;
      
      @javax.inject.Named("authenticator")
      @javax.enterprise.context.RequestScoped
      public class SimpleAuthenticator extends BaseAuthenticator implements Authenticator {
      
         @Inject Credentials credentials;
      
         @Override
         public void authenticate() {
            if ("demo".equals(credentials.getUsername()) && 
                  credentials.getCredential() instanceof PasswordCredential &&
                  "demo".equals(((PasswordCredential) credentials.getCredential()).getValue()))  {
               setStatus(AuthenticationStatus.SUCCESS);
               setUser(new SimpleUser("demo"));
            }
      
         }
      
      }



      but when i try to authenticate I get the exception


      07:01:55,375 ERROR [org.jboss.seam.security.IdentityImpl] Login failed: java.lang.RuntimeException: java.lang.NullPointerException
              at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:329) [:3.0.0.Final]
              at org.jboss.seam.security.IdentityImpl.login(IdentityImpl.java:229) [:3.0.0.Final]
              at org.jboss.seam.security.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$JavaPrograms$jboss-6$0$0$Final$server$default$deploy$jeeffice-1$0-SNAPSHO
      T$war"-ManagedBean-class_org$jboss$seam$security$IdentityImpl_$$_WeldClientProxy.login(org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$JavaPrograms$jboss-6$
      0$0$Final$server$default$deploy$jeeffice-1$0-SNAPSHOT$war"-ManagedBean-class_org$jboss$seam$security$IdentityImpl_$$_WeldClientProxy.java) [:3.0.0.Final]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_16]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_16]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_16]
              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_16]
              at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [:6.0.0.Final]
              at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [:6.0.0.Final]
              at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
              at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
              at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43) [:6.0.0.Final]
              at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56) [:6.0.0.Final]
              at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:168) [:2.0.3-]
              at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:447) [:2.0.3-]
              at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) [:2.0.3-]
              at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) [:2.0.3-]
              at javax.faces.component.UICommand.broadcast(UICommand.java:311) [:2.0.3-]
              at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) [:2.0.3-]
              at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) [:2.0.3-]
              at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) [:2.0.3-]
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) [:2.0.3-]
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) [:2.0.3-]
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) [:2.0.3-]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
              at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.0.0.Final]
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.0.0.Final]
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]
              at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]
              at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]
              at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]
              at java.lang.Thread.run(Thread.java:619) [:1.6.0_16]
      Caused by: java.lang.NullPointerException
              at org.picketlink.idm.impl.api.session.IdentitySessionImpl.<init>(IdentitySessionImpl.java:138) [:1.5.0.Alpha02]
              at org.picketlink.idm.impl.api.IdentitySessionFactoryImpl.createIdentitySession(IdentitySessionFactoryImpl.java:114) [:1.5.0.Alpha02]
              at org.jboss.seam.security.management.picketlink.IdentitySessionProducer.createIdentitySession(IdentitySessionProducer.java:136) [:3.0.0.Final]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_16]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_16]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_16]
              at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_16]
              at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [:6.0.0.Final]
              at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [:6.0.0.Final]
              at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [:6.0.0.Final]
              at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [:6.0.0.Final]
              at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) [:6.0.0.Final]
              at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:169) [:6.0.0.Final]
              at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:149) [:6.0.0.Final]
              at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:361) [:6.0.0.Final]
              at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:121) [:6.0.0.Final]
              at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:99) [:6.0.0.Final]
              at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) [:6.0.0.Final]
              at org.jboss.weld.proxies.org$jboss$weld$beanProducerMethod-org$jboss$seam$security$management$picketlink$IdentitySessionProducermethod_createIdentitySe
      ssion()_$$_WeldClientProxy.getAttributesManager(org$jboss$weld$beanProducerMethod-org$jboss$seam$security$management$picketlink$IdentitySessionProducermethod_cr
      eateIdentitySession()_$$_WeldClientProxy.java)
              at org.jboss.seam.security.management.IdmAuthenticator.authenticate(IdmAuthenticator.java:44) [:3.0.0.Final]
              at org.jboss.seam.security.management.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$C:$JavaPrograms$jboss-6$0$0$Final$server$default$deploy$jeeffice-
      1$0-SNAPSHOT$war"-ManagedBean-class_org$jboss$seam$security$management$IdmAuthenticator_$$_WeldClientProxy.authenticate(org$jboss$weld$bean-jboss$classloader:id
      ="vfs:$$$C:$JavaPrograms$jboss-6$0$0$Final$server$default$deploy$jeeffice-1$0-SNAPSHOT$war"-ManagedBean-class_org$jboss$seam$security$management$IdmAuthenticato
      r_$$_WeldClientProxy.java) [:3.0.0.Final]
              at org.jboss.seam.security.IdentityImpl.authenticate(IdentityImpl.java:305) [:3.0.0.Final]
              ... 45 more





      It looks like my authenticator bean is not registered. Do I need to declare it in beans.xml?


      Thanx