Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/clra/xml/security/DBAuthenticatedUser.java


1   /*
2    * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3    * Based on Apache Axis org.apache.axis.security.simple.DBAuthenticatedUser
4    * Distributed under the GPL license. See doc/COPYING.
5    * $RCSfile: DBAuthenticatedUser.java,v $
6    * $Date: 2003/03/05 02:59:31 $
7    * $Revision: 1.2 $
8    */
9   
10  package com.clra.xml.security;
11  
12  import com.clra.member.MemberRole;
13  import org.apache.axis.security.AuthenticatedUser;
14  
15  /**
16   * An implementation of AuthenticatedUser that caches a accountId as well
17   * as account roles. 
18   *
19   * @version $Revision: 1.2 $  ($Date: 2003/03/05 02:59:31 $)
20   * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
21   */
22  public class DBAuthenticatedUser implements AuthenticatedUser {
23  
24      private final Integer accountId;
25      private final String accountName;
26      private final MemberRole[] accountRoles;
27  
28      public DBAuthenticatedUser(
29          Integer accountId, String accountName, MemberRole[] accountRoles ) {
30          this.accountId = accountId;
31          this.accountName = accountName == null ? null : accountName.trim() ;
32          this.accountRoles = accountRoles;
33  
34          if ( accountId == null ) {
35              throw new IllegalArgumentException( "null account id" );
36          }
37          if ( accountName == null || accountName.trim().length() == 0 ) {
38              throw new IllegalArgumentException( "invalid account name" );
39          }
40          if ( accountRoles == null ) {
41              throw new IllegalArgumentException( "null account roles" );
42          }
43      }
44  
45      /**
46       * Return the user's name.
47       * @return a non-null, non-blank String.
48       */
49      public String getName() {
50          return accountName;
51      }
52  
53      /**
54       * Return the user's account id.
55       * @return a non-null Integer
56       */
57      public Integer getAccountId() {
58          return accountId;
59      }
60  
61      /**
62       * Same result as <code>getName()</code>. Provided for consistency
63       * with JavaBean spec.
64       */
65      public String getAccountName() {
66          return getName();
67      }
68      /**
69       * Return the user's roles.
70       * @return a non-null, but possibly empty MemberRole array
71       */
72      public MemberRole[] getAccountRoles() {
73          return accountRoles;
74      }
75  
76      public String toString() {
77        return accountName;
78      }
79  
80  } // DBAuthenticatedUser
81  
82  /*
83   * $Log: DBAuthenticatedUser.java,v $
84   * Revision 1.2  2003/03/05 02:59:31  rphall
85   * Overrode default method for toString()
86   *
87   * Revision 1.1  2003/03/05 01:21:03  rphall
88   * Added security to SOAP service
89   *
90   */
91