12 Replies Latest reply on Jul 19, 2007 12:06 PM by Monkey Den

    Identity not created

    Monkey Den Master

      I'm attempting to override Identity to add some logic specific to our application. Namely:

      We're are replacing an old application and need check the previous applications login cookie value when the Seam cookie isn't found.
      We need the getLoginFailedMessageSeverity() to return SEVERITY_ERROR instead of SEVERITY_INFO.
      And a couple other little things.

      But when I use @In Identity identity, elsewhere in my application, it's always null. What else do I need to do to get Seam to recognize it? Do I need to specify @AutoCreate? An instance() method in the subclass?

      @Name("org.jboss.seam.security.identity")
      @Scope(ScopeType.SESSION)
      @Intercept(InterceptionType.AFTER_RESTORE_VIEW)
      @Startup
      @Install(precedence=11) //Used 11 to override RuleBasedIdentity
      public class Identity extends org.jboss.seam.security.Identity {
      
       private static final LogProvider log = Logging.getLogProvider(Identity.class);
      
       @Override
       protected Severity getLoginFailedMessageSeverity() {
       return FacesMessage.SEVERITY_ERROR;
       }
      
       protected String getLegacyCookieName() {
       return "userCookie";
       }
      
       @Override
       protected Cookie getCookie() {
       FacesContext ctx = FacesContext.getCurrentInstance();
       if (ctx != null) {
       Cookie cookie = (Cookie) ctx.
       getExternalContext().getRequestCookieMap().get(getCookieName());
       return cookie != null ? cookie : getLegacyCookie();
       } else {
       return null;
       }
       }
      
       protected Cookie getLegacyCookie() {
       log.debug("NEM4 Cookie not found. Attempting to load legacy cookie.");
       FacesContext ctx = FacesContext.getCurrentInstance();
       return (Cookie) ctx.getExternalContext().getRequestCookieMap().get(getLegacyCookieName());
       }
      
       public void create() {
       super.create();
       log.debug("Creating custom Identity.");
       }
      
       @Override
       protected String getLoginFailedMessageKey() {
       log.debug("Retrieving login failed message.");
       return "login.error.userNamePassword";
       }
      }
      


      What am I doing wrong? Thanks