3 Replies Latest reply on Mar 12, 2007 10:39 AM by jimknopf

    custom-authentication, how to do it

    jimknopf

      I know, that there are somewhere a Source, how to do my own User/Group/Membership authentication.
      But i can't find it (looked for an hour).

      Can some one give me an Source or a Example to do this plz?

        • 1. Re: custom-authentication, how to do it
          aleem

          i m also a newbee. I have done a simple authentication for users. There is a verify method implementation in IdentitySession class. This is my IdentitySession

          public Object verify(String userName, String pwd) {
          Object userId = null;
          System.out.println("#@#@##@userName="+userName+"Password="+pwd);
          Query query = session.createQuery(
          "select user.id " +
          "from org.jbpm.identity.User as user " +
          "where user.name = :userName " +
          " and user.password = :password");
          query.setString("userName", userName);
          query.setString("password", pwd);

          userId = (Long) query.uniqueResult();
          return userId;
          }


          Called this verify from the Userbean as

          public String login() {
          String reVal = null ;
          Session session = JbpmContext.getCurrentJbpmContext().getSession();
          IdentitySession identitySession = new IdentitySession(session);

          if ( identitySession.verify(userName, password) != null ) {
          reVal = "home";
          JbpmContext.getCurrentJbpmContext().setActorId(userName);
          }
          else
          {
          FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Authentication Failed."));
          reVal = logout();
          }
          return reVal ;
          }

          make appropriate changes in faces-config.xml

          call userBean.login on the commandbutton event in login.jsp.

          Hope that might help you ;)

          • 2. Re: custom-authentication, how to do it
            jimknopf

            Thanks for ur answer.
            But i didn't explaint me well (i think).

            I won't use the JBPM user and groups. I wan't to use my own user and group :).

            I found some Topics:
            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=91941
            and

            http://www.jboss.com/index.html?module=bb&op=viewtopic&t=68304

            and

            http://docs.jboss.org/jbpm/v3/userguide/taskmanagement.html (chapter 11.11)

            and

            http://kickjava.com/src/org.jbpm.identity.index.htm

            but stil, i don't know how to use my own User and Group Class.
            Maybe myUser extends User? But i don't have a password or email in my own users like they are in JBPM Users.

            • 3. Re: custom-authentication, how to do it
              jimknopf

              And, what is it i must write in "HERE IS WHAT YOU HAVE TO CHANGE":

              public class MyEAHandler extends ExpressionAssignmentHandler{
              
               protected ExpressionSession getExpressionSession() {
               JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
               if (jbpmContext==null) {
               throw new RuntimeException("no active JbpmContext for resolving assignment expression'"+expression+"'");
               }
               //HERE IS WHAT YOU HAVE TO CHANGE
               return new IdentitySession(jbpmContext.getSession());
               }
              
              }
              


              ... i think i missed something -.-