File Source: User.java

         /* 
    P/P   *  Method: void readObject(ObjectInputStream)
          * 
          *  Preconditions:
          *    Param_1 != null
          * 
          *  Presumptions:
          *    init'ed(org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED)
          * 
          *  Postconditions:
          *    Param_0.pcDetachedState == org.apache.openjpa.enhance.PersistenceCapable.DESERIALIZED
          *    (soft) init'ed(Param_0.pcDetachedState)
          */
     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   *  contributor license agreements.  The ASF licenses this file to You
     4   * under the Apache License, Version 2.0 (the "License"); you may not
     5   * use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.  For additional information regarding
    15   * copyright in this work, please see the NOTICE file in the top level
    16   * directory of this distribution.
    17   */
    18  
    19  package org.apache.roller.weblogger.pojos;
    20  
    21  import java.io.Serializable;
    22  import java.util.ArrayList;
    23  import java.util.Date;
    24  import java.util.HashSet;
    25  import java.util.Iterator;
    26  import java.util.List;
    27  import java.util.Set;
    28  import org.apache.commons.lang.builder.EqualsBuilder;
    29  import org.apache.commons.lang.builder.HashCodeBuilder;
    30  import org.apache.roller.weblogger.WebloggerException;
    31  import org.apache.roller.weblogger.config.WebloggerConfig;
    32  import org.apache.roller.weblogger.business.Weblogger;
    33  import org.apache.roller.util.UUIDGenerator;
    34  import org.apache.roller.weblogger.util.Utilities;
    35  
    36  
    37  /**
    38   * User bean.
    39   *
    40   * @hibernate.cache usage="read-write"
    41   * @hibernate.class lazy="true" table="rolleruser"
    42   */
    43  public class User implements Serializable {
    44      
    45      public static final long serialVersionUID = -6354583200913127874L;
    46      
    47      private String  id = UUIDGenerator.generateUUID();
    48      private String  userName;
    49      private String  password;
    50      private String  screenName;
    51      private String  fullName;
    52      private String  emailAddress;
    53      private Date    dateCreated;
    54      private String  locale;
    55      private String  timeZone;
    56      private Boolean enabled = Boolean.TRUE;
    57      private String  activationCode;
    58      
    59      private Set roles = new HashSet();
    60      private List permissions = new ArrayList();
    61      
    62      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.pojos.User()
              * 
              *  Presumptions:
              *    init'ed(java.lang.Boolean.TRUE)
              * 
              *  Postconditions:
              *    this.enabled == java.lang.Boolean.TRUE
              *    (soft) init'ed(this.enabled)
              *    init'ed(this.id)
              *    this.permissions == &new ArrayList(User#2)
              *    this.roles == &new HashSet(User#1)
              *    new ArrayList(User#2) num objects == 1
              *    new HashSet(User#1) num objects == 1
              */
    63      public User() {
    64      }
    65      
    66      public User( String id, String userName,
    67              String password, String fullName,
    68              String emailAddress,
    69              String locale, String timeZone,
    70              Date dateCreated,
                     /* 
    P/P               *  Method: void org.apache.roller.weblogger.pojos.User(String, String, String, String, String, String, String, Date, Boolean)
                      * 
                      *  Preconditions:
                      *    dateCreated != null
                      * 
                      *  Presumptions:
                      *    init'ed(java.lang.Boolean.TRUE)
                      * 
                      *  Postconditions:
                      *    this.dateCreated != null
                      *    this.emailAddress == emailAddress
                      *    init'ed(this.emailAddress)
                      *    this.enabled == isEnabled
                      *    init'ed(this.enabled)
                      *    this.fullName == fullName
                      *    init'ed(this.fullName)
                      *    init'ed(this.id)
                      *    this.locale == locale
                      *    init'ed(this.locale)
                      *    ...
                      */
    71              Boolean isEnabled) {
    72          //this.id = id;
    73          this.userName = userName;
    74          this.password = password;
    75          this.fullName = fullName;
    76          this.emailAddress = emailAddress;
    77          this.dateCreated = (Date)dateCreated.clone();
    78          this.locale = locale;
    79          this.timeZone = timeZone;
    80          this.enabled = isEnabled;
    81      }
    82      
    83      
    84      /**
    85       * Id of the User.
    86       *
    87       * @hibernate.id column="id" generator-class="assigned"
    88       */
    89      public String getId() {
                 /* 
    P/P           *  Method: String pcgetId()
                  * 
                  *  Preconditions:
                  *    init'ed(this.id)
                  * 
                  *  Postconditions:
                  *    return_value == this.id
                  *    init'ed(return_value)
                  */
    90          return this.id;
    91      }
    92      
    93      public void setId( String id ) {
                 /* 
    P/P           *  Method: void pcsetId(String)
                  * 
                  *  Postconditions:
                  *    this.id == Param_1
                  *    init'ed(this.id)
                  */
    94          this.id = id;
    95      }
    96      
    97      
    98      /**
    99       * User name of the user.
   100       * @hibernate.property column="username" non-null="true" unique="true"
   101       */
   102      public String getUserName() {
                 /* 
    P/P           *  Method: String pcgetUserName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.userName)
                  * 
                  *  Postconditions:
                  *    return_value == this.userName
                  *    init'ed(return_value)
                  */
   103          return this.userName;
   104      }
   105      
   106      public void setUserName( String userName ) {
                 /* 
    P/P           *  Method: void pcsetUserName(String)
                  * 
                  *  Postconditions:
                  *    this.userName == Param_1
                  *    init'ed(this.userName)
                  */
   107          this.userName = userName;
   108      }
   109      
   110      /**
   111       * Get password.
   112       * If password encryption is enabled, will return encrypted password.
   113       *
   114       * @hibernate.property column="passphrase" non-null="true"
   115       */
   116      public String getPassword() {
                 /* 
    P/P           *  Method: String pcgetPassword()
                  * 
                  *  Preconditions:
                  *    init'ed(this.password)
                  * 
                  *  Postconditions:
                  *    return_value == this.password
                  *    init'ed(return_value)
                  */
   117          return this.password;
   118      }
   119      
   120      /**
   121       * Set password.
   122       * If password encryption is turned on, then pass in an encrypted password.
   123       */
   124      public void setPassword( String password ) {
                 /* 
    P/P           *  Method: void pcsetPassword(String)
                  * 
                  *  Postconditions:
                  *    this.password == Param_1
                  *    init'ed(this.password)
                  */
   125          this.password = password;
   126      }
   127      
   128      /**
   129       * Reset this user's password, handles encryption if configured.
   130       *
   131       * @param newPassword The new password to be set.
   132       */
   133      public void resetPassword(String newPassword) throws WebloggerException {
   134          
                 /* 
    P/P           *  Method: void resetPassword(String)
                  * 
                  *  Preconditions:
                  *    init'ed(this.pcStateManager)
                  *    (soft) init'ed(this.password)
                  *    (soft) pcInheritedFieldCount <= 232-8
                  * 
                  *  Postconditions:
                  *    init'ed(this.password)
                  * 
                  *  Test Vectors:
                  *    java.lang.Boolean:booleanValue(...)@137: {0}, {1}
                  */
   135          String encrypt = WebloggerConfig.getProperty("passwds.encryption.enabled");
   136          String algorithm = WebloggerConfig.getProperty("passwds.encryption.algorithm");
   137          if (new Boolean(encrypt).booleanValue()) {
   138              setPassword(Utilities.encodePassword(newPassword, algorithm));
   139          } else {
   140              setPassword(newPassword);
   141          }
   142      }
   143      
   144      
   145      /**
   146       * Screen name of the user.
   147       *
   148       * @hibernate.property column="screenname" non-null="true" unique="true"
   149       */
   150      public String getScreenName() {
                 /* 
    P/P           *  Method: String pcgetScreenName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.screenName)
                  * 
                  *  Postconditions:
                  *    return_value == this.screenName
                  *    init'ed(return_value)
                  */
   151          return this.screenName;
   152      }
   153      
   154      public void setScreenName( String screenName ) {
                 /* 
    P/P           *  Method: void pcsetScreenName(String)
                  * 
                  *  Postconditions:
                  *    this.screenName == Param_1
                  *    init'ed(this.screenName)
                  */
   155          this.screenName = screenName;
   156      }
   157      
   158      
   159      /**
   160       * Full name of the user.
   161       *
   162       * @hibernate.property column="fullname" non-null="true" unique="true"
   163       */
   164      public String getFullName() {
                 /* 
    P/P           *  Method: String pcgetFullName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.fullName)
                  * 
                  *  Postconditions:
                  *    return_value == this.fullName
                  *    init'ed(return_value)
                  */
   165          return this.fullName;
   166      }
   167      
   168      public void setFullName( String fullName ) {
                 /* 
    P/P           *  Method: void pcsetFullName(String)
                  * 
                  *  Postconditions:
                  *    this.fullName == Param_1
                  *    init'ed(this.fullName)
                  */
   169          this.fullName = fullName;
   170      }
   171      
   172      
   173      /**
   174       * E-mail address of the user.
   175       *
   176       * @hibernate.property column="emailaddress" non-null="true" unique="true"
   177       */
   178      public String getEmailAddress() {
                 /* 
    P/P           *  Method: String pcgetEmailAddress()
                  * 
                  *  Preconditions:
                  *    init'ed(this.emailAddress)
                  * 
                  *  Postconditions:
                  *    return_value == this.emailAddress
                  *    init'ed(return_value)
                  */
   179          return this.emailAddress;
   180      }
   181      
   182      public void setEmailAddress( String emailAddress ) {
                 /* 
    P/P           *  Method: void pcsetEmailAddress(String)
                  * 
                  *  Postconditions:
                  *    this.emailAddress == Param_1
                  *    init'ed(this.emailAddress)
                  */
   183          this.emailAddress = emailAddress;
   184      }
   185      
   186      
   187      /**
   188       * The date the user was created.
   189       *
   190       * @hibernate.property column="datecreated" non-null="true" unique="false"
   191       */
   192      public Date getDateCreated() {
                 /* 
    P/P           *  Method: Date pcgetDateCreated()
                  * 
                  *  Preconditions:
                  *    init'ed(this.dateCreated)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    this.dateCreated: Inverse{null}, Addr_Set{null}
                  */
   193          if (dateCreated == null) {
   194              return null;
   195          } else {
   196              return (Date)dateCreated.clone();
   197          }
   198      }
   199      
   200      public void setDateCreated(final Date date) {
                 /* 
    P/P           *  Method: void pcsetDateCreated(Date)
                  * 
                  *  Postconditions:
                  *    init'ed(this.dateCreated)
                  * 
                  *  Test Vectors:
                  *    Param_1: Addr_Set{null}, Inverse{null}
                  */
   201          if (date != null) {
   202              dateCreated = (Date)date.clone();
   203          } else {
   204              dateCreated = null;
   205          }
   206      }
   207      
   208      
   209      /**
   210       * Locale of the user.
   211       *
   212       * @hibernate.property column="locale" non-null="true" unique="false"
   213       */
   214      public String getLocale() {
                 /* 
    P/P           *  Method: String pcgetLocale()
                  * 
                  *  Preconditions:
                  *    init'ed(this.locale)
                  * 
                  *  Postconditions:
                  *    return_value == this.locale
                  *    init'ed(return_value)
                  */
   215          return this.locale;
   216      }
   217      
   218      public void setLocale(String locale) {
                 /* 
    P/P           *  Method: void pcsetLocale(String)
                  * 
                  *  Postconditions:
                  *    this.locale == Param_1
                  *    init'ed(this.locale)
                  */
   219          this.locale = locale;
   220      }
   221      
   222      
   223      /**
   224       * Timezone of the user.
   225       *
   226       * @hibernate.property column="timeZone" non-null="true" unique="false"
   227       */
   228      public String getTimeZone() {
                 /* 
    P/P           *  Method: String pcgetTimeZone()
                  * 
                  *  Preconditions:
                  *    init'ed(this.timeZone)
                  * 
                  *  Postconditions:
                  *    return_value == this.timeZone
                  *    init'ed(return_value)
                  */
   229          return this.timeZone;
   230      }
   231      
   232      public void setTimeZone(String timeZone) {
                 /* 
    P/P           *  Method: void pcsetTimeZone(String)
                  * 
                  *  Postconditions:
                  *    this.timeZone == Param_1
                  *    init'ed(this.timeZone)
                  */
   233          this.timeZone = timeZone;
   234      }
   235      
   236      
   237      /**
   238       * Is this user account enabled?  Disabled accounts cannot login.
   239       *
   240       * @hibernate.property column="isenabled" non-null="true" unique="false"
   241       */
   242      public Boolean getEnabled() {
                 /* 
    P/P           *  Method: Boolean pcgetEnabled()
                  * 
                  *  Preconditions:
                  *    init'ed(this.enabled)
                  * 
                  *  Postconditions:
                  *    return_value == this.enabled
                  *    init'ed(return_value)
                  */
   243          return this.enabled;
   244      }
   245      
   246      public void setEnabled(Boolean enabled) {
                 /* 
    P/P           *  Method: void pcsetEnabled(Boolean)
                  * 
                  *  Postconditions:
                  *    this.enabled == Param_1
                  *    init'ed(this.enabled)
                  */
   247          this.enabled = enabled;
   248      }
   249      
   250      
   251      /** 
   252       * Activation code.
   253       *
   254       * @hibernate.property column="activationcode" non-null="false"
   255       */
   256      public String getActivationCode() {
                 /* 
    P/P           *  Method: String pcgetActivationCode()
                  * 
                  *  Preconditions:
                  *    init'ed(this.activationCode)
                  * 
                  *  Postconditions:
                  *    return_value == this.activationCode
                  *    init'ed(return_value)
                  */
   257          return activationCode;
   258      }
   259      
   260      public void setActivationCode(String activationCode) {
                 /* 
    P/P           *  Method: void pcsetActivationCode(String)
                  * 
                  *  Postconditions:
                  *    this.activationCode == Param_1
                  *    init'ed(this.activationCode)
                  */
   261          this.activationCode = activationCode;
   262      }
   263      
   264      
   265      /**
   266       * List of weblog permissions for this user.
   267       *
   268       * @hibernate.bag lazy="true" inverse="true" cascade="none"
   269       * @hibernate.collection-key column="user_id"
   270       * @hibernate.collection-one-to-many
   271       *    class="org.apache.roller.weblogger.pojos.WeblogPermission"
   272       */
   273      public List getPermissions() {
                 /* 
    P/P           *  Method: List pcgetPermissions()
                  * 
                  *  Preconditions:
                  *    init'ed(this.permissions)
                  * 
                  *  Postconditions:
                  *    return_value == this.permissions
                  *    init'ed(return_value)
                  */
   274          return permissions;
   275      }
   276      
   277      public void setPermissions(List perms) {
                 /* 
    P/P           *  Method: void pcsetPermissions(List)
                  * 
                  *  Postconditions:
                  *    this.permissions == Param_1
                  *    init'ed(this.permissions)
                  */
   278          permissions = perms;
   279      }
   280      
   281      
   282      /**
   283       * The set of roles for this user.
   284       *
   285       * @hibernate.set lazy="true" inverse="true" cascade="all"
   286       * @hibernate.collection-key column="userid"
   287       * @hibernate.collection-one-to-many class="org.apache.roller.weblogger.pojos.UserRole"
   288       */
   289      public Set getRoles() {
                 /* 
    P/P           *  Method: Set pcgetRoles()
                  * 
                  *  Preconditions:
                  *    init'ed(this.roles)
                  * 
                  *  Postconditions:
                  *    return_value == this.roles
                  *    init'ed(return_value)
                  */
   290          return roles;
   291      }
   292      
   293      /**
   294       * this is private to force the use of grant/revokeRole() methods.
   295       */
   296      private void setRoles(Set roles) {
                 /* 
    P/P           *  Method: void pcsetRoles(Set)
                  * 
                  *  Postconditions:
                  *    this.roles == Param_1
                  *    init'ed(this.roles)
                  */
   297          this.roles = roles;
   298      }
   299      
   300      
   301      /**
   302       * Returns true if user has role specified.
   303       */
   304      public boolean hasRole(String roleName) {
                 /* 
    P/P           *  Method: bool hasRole(String)
                  * 
                  *  Preconditions:
                  *    init'ed(this.pcStateManager)
                  *    this.roles != null
                  *    (soft) org/apache/roller/weblogger/pojos/UserRole.pcInheritedFieldCount <= 232-2
                  *    (soft) pcInheritedFieldCount <= 232-10
                  * 
                  *  Presumptions:
                  *    java.util.Iterator:next(...)@307 != null
                  *    role.role@307 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@308: {0}, {1}
                  *    java.util.Iterator:hasNext(...)@306: {0}, {1}
                  */
   305          Iterator iter = getRoles().iterator();
   306          while (iter.hasNext()) {
   307              UserRole role = (UserRole) iter.next();
   308              if (role.getRole().equals(roleName)) {
   309                  return true;
   310              }
   311          }
   312          return false;
   313      }
   314      
   315      /**
   316       * Grant to user role specified by role name.
   317       */
   318      public void grantRole(String roleName) throws WebloggerException {
                 /* 
    P/P           *  Method: void grantRole(String)
                  * 
                  *  Preconditions:
                  *    (soft) org/apache/roller/weblogger/pojos/UserRole.pcInheritedFieldCount <= 232-3
                  *    (soft) pcInheritedFieldCount <= 232-13
                  *    (soft) init'ed(this.pcStateManager)
                  *    (soft) this.roles != null
                  *    (soft) init'ed(this.userName)
                  */
   319          if (!hasRole(roleName)) {
   320              UserRole role = new UserRole(null, this, roleName);
   321              getRoles().add(role);
   322              role.setUser(this);
   323          }
   324      }
   325      
   326      
   327      
   328      //------------------------------------------------------- Good citizenship
   329      
   330      public String toString() {
                 /* 
    P/P           *  Method: String toString()
                  * 
                  *  Preconditions:
                  *    init'ed(this.dateCreated)
                  *    init'ed(this.emailAddress)
                  *    init'ed(this.enabled)
                  *    init'ed(this.fullName)
                  *    init'ed(this.id)
                  *    init'ed(this.userName)
                  * 
                  *  Postconditions:
                  *    java.lang.StringBuffer:toString(...)._tainted == this.emailAddress._tainted | this.fullName._tainted | this.id._tainted | this.userName._tainted
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuffer:toString(...)
                  */
   331          StringBuffer buf = new StringBuffer();
   332          buf.append("{");
   333          buf.append(this.id);
   334          buf.append(", ").append(this.userName);
   335          buf.append(", ").append(this.fullName);
   336          buf.append(", ").append(this.emailAddress);
   337          buf.append(", ").append(this.dateCreated);
   338          buf.append(", ").append(this.enabled);
   339          buf.append("}");
   340          return buf.toString();
   341      }
   342      
   343      public boolean equals(Object other) {
                 /* 
    P/P           *  Method: bool equals(Object)
                  * 
                  *  Preconditions:
                  *    (soft) init'ed(other.pcStateManager)
                  *    (soft) init'ed(other.userName)
                  *    (soft) pcInheritedFieldCount <= 232-13
                  *    (soft) init'ed(this.pcStateManager)
                  *    (soft) init'ed(this.userName)
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.EqualsBuilder:append(...)@347 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    other == this: {0}, {1}
                  */
   344          if (other == this) return true;
   345          if (other instanceof User != true) return false;
   346          User o = (User)other;
   347          return new EqualsBuilder().append(getUserName(), o.getUserName()).isEquals();
   348      }
   349      
   350      public int hashCode() {
                 /* 
    P/P           *  Method: int hashCode()
                  * 
                  *  Preconditions:
                  *    init'ed(this.pcStateManager)
                  *    init'ed(this.userName)
                  *    (soft) pcInheritedFieldCount <= 232-13
                  * 
                  *  Presumptions:
                  *    org.apache.commons.lang.builder.HashCodeBuilder:append(...)@351 != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   351          return new HashCodeBuilder().append(getUserName()).toHashCode();
   352      }
   353      
   354  }
+  355  Other Messages








SofCheck Inspector Build Version : 2.18479
User.java 2009-Jan-02 14:24:58
User.class 2009-Sep-04 03:12:38