[jboss-cvs] jboss-seam/examples/security/src/org/jboss/seam/example/security ...

Shane Bryzak Shane_Bryzak at symantec.com
Tue Jul 25 02:56:16 EDT 2006


  User: sbryzak2
  Date: 06/07/25 02:56:16

  Added:       examples/security/src/org/jboss/seam/example/security     
                        LoginAction.java LoginLocal.java
                        ProtectedAction.java ProtectedLocal.java User.java
  Log:
  Added simple test app to debug security framework.. this will probably be expanded into numerous examples, one for each of the popular authentication methods
  
  Revision  Changes    Path
  1.1      date: 2006/07/25 06:56:16;  author: sbryzak2;  state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/LoginAction.java
  
  Index: LoginAction.java
  ===================================================================
  package org.jboss.seam.example.security;
  
  import org.jboss.seam.annotations.Name;
  import javax.ejb.Stateless;
  import org.jboss.seam.annotations.In;
  import org.jboss.seam.security.realm.Realm;
  import java.security.Principal;
  
  /**
   * Authenticates the user against the Realm.
   *
   * @author Shane Bryzak
   */
  @Stateless
  @Name("login")
  public class LoginAction implements LoginLocal
  {
    @In("org.jboss.seam.security.realm.Realm") Realm realm;
  
    @In User user;
  
    public String login()
    {
      System.out.println("login() called");
  
      try
      {
        Principal principal = realm.authenticate(user.getUsername(), user.getPassword());
        System.out.println("Got principal: " + principal);
        return "success";
      }
      catch (Exception ex)
      {
        return "login";
      }
    }
  }
  
  
  
  1.1      date: 2006/07/25 06:56:16;  author: sbryzak2;  state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/LoginLocal.java
  
  Index: LoginLocal.java
  ===================================================================
  package org.jboss.seam.example.security;
  
  /**
   *
   * @author Shane Bryzak
   */
  public interface LoginLocal
  {
    String login();
  }
  
  
  
  1.1      date: 2006/07/25 06:56:16;  author: sbryzak2;  state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/ProtectedAction.java
  
  Index: ProtectedAction.java
  ===================================================================
  package org.jboss.seam.example.security;
  
  import javax.annotation.security.RolesAllowed;
  import javax.ejb.Stateless;
  
  import org.jboss.seam.annotations.Name;
  import org.jboss.annotation.security.SecurityDomain;
  
  /**
   * <p>PROPRIETARY/CONFIDENTIAL Use of this product is subject to license terms.
   * Copyright (c) 2006 Symantec Corporation. All rights reserved.</p>
   *
   * @author Shane Bryzak
   * @version 1.0
   */
  @Stateless
  @Name("protectedAction")
  @SecurityDomain("securityexample")
  public class ProtectedAction implements ProtectedLocal
  {
    @RolesAllowed("admin")
    public String foo()
    {
      System.out.println("foo() called");
      return "success";
    }
  }
  
  
  
  1.1      date: 2006/07/25 06:56:16;  author: sbryzak2;  state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/ProtectedLocal.java
  
  Index: ProtectedLocal.java
  ===================================================================
  package org.jboss.seam.example.security;
  
  /**
   * <p>PROPRIETARY/CONFIDENTIAL Use of this product is subject to license terms.
   * Copyright (c) 2006 Symantec Corporation. All rights reserved.</p>
   *
   * @author Shane Bryzak
   * @version 1.0
   */
  public interface ProtectedLocal
  {
    String foo();
  }
  
  
  
  1.1      date: 2006/07/25 06:56:16;  author: sbryzak2;  state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/User.java
  
  Index: User.java
  ===================================================================
  package org.jboss.seam.example.security;
  
  import javax.persistence.Entity;
  import org.jboss.seam.annotations.Name;
  import javax.persistence.Id;
  
  /**
   * <p>PROPRIETARY/CONFIDENTIAL Use of this product is subject to license terms.
   * Copyright (c) 2006 Symantec Corporation. All rights reserved.</p>
   *
   * @author Shane Bryzak
   * @version 1.0
   */
  @Entity
  @Name("user")
  public class User
  {
    private Integer userId;
    private String username;
    private String password;
  
    public String getPassword()
    {
      return password;
    }
  
    public void setPassword(String password)
    {
      this.password = password;
    }
  
    public void setUsername(String username)
    {
      this.username = username;
    }
  
    @Id
    public void setUserId(Integer userId)
    {
      this.userId = userId;
    }
  
    public Integer getUserId()
    {
      return userId;
    }
  
    public String getUsername()
    {
      return username;
    }
  }
  
  
  



More information about the jboss-cvs-commits mailing list