Coverage report

  %line %branch
org.apache.turbine.services.security.torque.TorqueUser
49% 
91% 

 1  
 package org.apache.turbine.services.security.torque;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2004 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import java.io.ByteArrayOutputStream;
 20  
 import java.io.PrintWriter;
 21  
 
 22  
 import java.sql.Connection;
 23  
 
 24  
 import java.util.Date;
 25  
 import java.util.Hashtable;
 26  
 
 27  
 import javax.servlet.http.HttpSessionBindingEvent;
 28  
 
 29  
 import org.apache.commons.logging.Log;
 30  
 import org.apache.commons.logging.LogFactory;
 31  
 import org.apache.torque.om.Persistent;
 32  
 
 33  
 import org.apache.turbine.om.security.User;
 34  
 import org.apache.turbine.services.security.TurbineSecurity;
 35  
 import org.apache.turbine.util.ObjectUtils;
 36  
 import org.apache.turbine.util.security.TurbineSecurityException;
 37  
 
 38  
 /**
 39  
  * This is the User class used by the TorqueSecurity Service. It decouples
 40  
  * all the database peer access from the actual Peer object
 41  
  *
 42  
  * @author <a href="mailto:josh@stonecottage.com">Josh Lucas</a>
 43  
  * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
 44  
  * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
 45  
  * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
 46  
  * @author <a href="mailto:cberry@gluecode.com">Craig D. Berry</a>
 47  
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
 48  
  * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
 49  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 50  
  * @version $Id: TorqueUser.java,v 1.7.2.3 2004/05/20 03:06:50 seade Exp $
 51  
  */
 52  
 
 53  
 public class TorqueUser
 54  
     extends TorqueObject
 55  
     implements User,
 56  
                Persistent
 57  
 {
 58  16
     private static Log log = LogFactory.getLog(TorqueUser.class);
 59  
     
 60  
     /** The date on which the user last accessed the application. */
 61  155
     private Date lastAccessDate = null;
 62  
 
 63  
     /** This is data that will survive a servlet engine restart. */
 64  155
     private Hashtable permStorage = null;
 65  
 
 66  
     /** This is data that will not survive a servlet engine restart. */
 67  155
     private Hashtable tempStorage = null;
 68  
 
 69  
     /**
 70  
      * Constructor.
 71  
      * Create a new User and set the createDate.
 72  
      */
 73  
     public TorqueUser()
 74  
     {
 75  12
         super();
 76  12
         setCreateDate(new Date());
 77  12
         tempStorage = new Hashtable(10);
 78  12
         setHasLoggedIn(Boolean.FALSE);
 79  12
     }
 80  
 
 81  
     /**
 82  
      * This Constructor is used when the UserPeerManager
 83  
      * has retrieved a list of Database Objects from the peer and
 84  
      * must 'wrap' them into TorqueRole Objects. You should not use it directly!
 85  
      *
 86  
      * @param obj An Object from the peer
 87  
      */
 88  
     public TorqueUser(Persistent obj)
 89  
     {
 90  143
         super(obj);
 91  
 
 92  
         // Do not set creation date. This is only called on retrieval from
 93  
         // storage!
 94  
 
 95  143
         tempStorage = new Hashtable(10);
 96  143
         setHasLoggedIn(Boolean.FALSE);
 97  143
     }
 98  
 
 99  
     /**
 100  
      * Returns the underlying Object for the Peer
 101  
      *
 102  
      * Used in the UserPeerManager when building a new Criteria.
 103  
      *
 104  
      * @return The underlying persistent object
 105  
      *
 106  
      */
 107  
 
 108  
     public Persistent getPersistentObj()
 109  
     {
 110  207
         if (obj == null)
 111  
         {
 112  12
             obj = UserPeerManager.newPersistentInstance();
 113  
         }
 114  207
         return obj;
 115  
     }
 116  
 
 117  
     /**
 118  
      * Stores the object in the database.  If the object is new,
 119  
      * it inserts it; otherwise an update is performed.
 120  
      *
 121  
      * @param torqueName The name under which the object should be stored.
 122  
      *
 123  
      * @exception Exception This method might throw an exceptions
 124  
      */
 125  
     public void save(String torqueName)
 126  
             throws Exception
 127  
     {
 128  0
         setObjectdata(ObjectUtils.serializeHashtable(getPermStorage()));
 129  0
         super.save(torqueName);
 130  0
     }
 131  
 
 132  
     /**
 133  
      * Stores the object in the database.  If the object is new,
 134  
      * it inserts it; otherwise an update is performed.  This method
 135  
      * is meant to be used as part of a transaction, otherwise use
 136  
      * the save() method and the connection details will be handled
 137  
      * internally
 138  
      *
 139  
      * @param con A Connection object to save the object
 140  
      *
 141  
      * @exception Exception This method might throw an exceptions
 142  
      */
 143  
     public void save(Connection con)
 144  
         throws Exception
 145  
     {
 146  0
         setObjectdata(ObjectUtils.serializeHashtable(getPermStorage()));
 147  0
         super.save(con);
 148  0
     }
 149  
 
 150  
     /**
 151  
      * Makes changes made to the User attributes permanent.
 152  
      *
 153  
      * @throws TurbineSecurityException if there is a problem while
 154  
      *  saving data.
 155  
      */
 156  
     public void save()
 157  
         throws TurbineSecurityException
 158  
     {
 159  
         //
 160  
         // This is inconsistent with all the other security classes
 161  
         // because it calls save() on the underlying object directly.
 162  
         // But the UserManager calls ((Persistent)user).save()
 163  
         // so if we do TurbineSecurity.saveUser(this) here, we get
 164  
         // a nice endless loop. :-(
 165  
         //
 166  
         // Users seem to be a special kind of security objects...
 167  
         //
 168  
 
 169  
         try
 170  
         {
 171  11
             setObjectdata(ObjectUtils.serializeHashtable(getPermStorage()));
 172  11
             getPersistentObj().save();
 173  
         }
 174  0
         catch (Exception e)
 175  
         {
 176  0
             throw new TurbineSecurityException("User object said " 
 177  
                     + e.getMessage(), e);
 178  11
         }
 179  11
     }
 180  
 
 181  
     /**
 182  
      * Returns the name of this object.
 183  
      *
 184  
      * @return The name of the object.
 185  
      */
 186  
     public String getName()
 187  
     {
 188  91
         return UserPeerManager.getName(getPersistentObj());
 189  
     }
 190  
 
 191  
     /**
 192  
      * Sets the name of this object
 193  
      *
 194  
      * @param name The name of the object
 195  
      */
 196  
     public void setName(String name)
 197  
     {
 198  8
         setUserName(name);
 199  8
     }
 200  
 
 201  
     /**
 202  
      * Gets the Id of this object
 203  
      *
 204  
      * @return The Id of the object
 205  
      */
 206  
     public int getId()
 207  
     {
 208  2
         return UserPeerManager.getIdAsObj(getPersistentObj()).intValue();
 209  
     }
 210  
 
 211  
     /**
 212  
      * Gets the Id of this object
 213  
      *
 214  
      * @return The Id of the object
 215  
      */
 216  
     public Integer getIdAsObj()
 217  
     {
 218  0
         return UserPeerManager.getIdAsObj(getPersistentObj());
 219  
     }
 220  
 
 221  
     /**
 222  
      * Sets the Id of this object
 223  
      *
 224  
      * @param id The new Id
 225  
      */
 226  
     public void setId(int id)
 227  
     {
 228  0
         UserPeerManager.setId(getPersistentObj(), id);
 229  0
     }
 230  
 
 231  
     /**
 232  
      * Returns the name of this user.
 233  
      *
 234  
      * @return The name of the user.
 235  
      * @deprecated Use getName() instead.
 236  
      */
 237  
     public String getUserName()
 238  
     {
 239  0
         return getName();
 240  
     }
 241  
 
 242  
     /**
 243  
      * Sets the name of this user.
 244  
      *
 245  
      * @param name The name of the user.
 246  
      */
 247  
     public void setUserName(String name)
 248  
     {
 249  8
         UserPeerManager.setUserName(getPersistentObj(), name);
 250  8
     }
 251  
 
 252  
     /**
 253  
      * Returns the password of the User
 254  
      *
 255  
      * @return The password of the User
 256  
      */
 257  
     public String getPassword()
 258  
     {
 259  19
         return UserPeerManager.getUserPassword(getPersistentObj());
 260  
     }
 261  
 
 262  
     /**
 263  
      * Sets the password of the User
 264  
      *
 265  
      * @param password The new password of the User
 266  
      */
 267  
     public void setPassword(String password)
 268  
     {
 269  8
         UserPeerManager.setUserPassword(getPersistentObj(), password);
 270  8
     }
 271  
 
 272  
     /**
 273  
      * Returns the first name of the User
 274  
      *
 275  
      * @return The first name of the User
 276  
      */
 277  
     public String getFirstName()
 278  
     {
 279  0
         return UserPeerManager.getUserFirstName(getPersistentObj());
 280  
     }
 281  
 
 282  
     /**
 283  
      * Sets the first name of the User
 284  
      *
 285  
      * @param firstName The new first name of the User
 286  
      */
 287  
     public void setFirstName(String firstName)
 288  
     {
 289  2
         UserPeerManager.setUserFirstName(getPersistentObj(), firstName);
 290  2
     }
 291  
 
 292  
     /**
 293  
      * Returns the last name of the User
 294  
      *
 295  
      * @return The last name of the User
 296  
      */
 297  
     public String getLastName()
 298  
     {
 299  0
         return UserPeerManager.getUserLastName(getPersistentObj());
 300  
     }
 301  
 
 302  
     /**
 303  
      * Sets the last name of User
 304  
      *
 305  
      * @param lastName The new last name of the User
 306  
      */
 307  
     public void setLastName(String lastName)
 308  
     {
 309  2
         UserPeerManager.setUserLastName(getPersistentObj(), lastName);
 310  2
     }
 311  
 
 312  
     /**
 313  
      * Returns the email address of the user
 314  
      *
 315  
      * @return The email address of the user
 316  
      */
 317  
     public String getEmail()
 318  
     {
 319  0
         return UserPeerManager.getUserEmail(getPersistentObj());
 320  
     }
 321  
 
 322  
     /**
 323  
      * Sets the new email address of the user
 324  
      *
 325  
      * @param email The new email address of the user
 326  
      */
 327  
     public void setEmail(String email)
 328  
     {
 329  0
         UserPeerManager.setUserEmail(getPersistentObj(), email);
 330  0
     }
 331  
 
 332  
     /**
 333  
      * Returns the confirm value of the user
 334  
      *
 335  
      * @return The confirm value of the user
 336  
      */
 337  
     public String getConfirmed()
 338  
     {
 339  0
         return UserPeerManager.getUserConfirmed(getPersistentObj());
 340  
     }
 341  
 
 342  
     /**
 343  
      * Sets the new confirm value of the user
 344  
      *
 345  
      * @param confirm The new confirm value of the user
 346  
      */
 347  
     public void setConfirmed(String confirm)
 348  
     {
 349  0
         UserPeerManager.setUserConfirmed(getPersistentObj(), confirm);
 350  0
     }
 351  
 
 352  
     /**
 353  
      * Returns the creation date of the user
 354  
      *
 355  
      * @return The creation date of the user
 356  
      */
 357  
     public java.util.Date getCreateDate()
 358  
     {
 359  0
         return UserPeerManager.getUserCreateDate(getPersistentObj());
 360  
     }
 361  
 
 362  
     /**
 363  
      * Sets the new creation date of the user
 364  
      *
 365  
      * @param createDate The new creation date of the user
 366  
      */
 367  
     public void setCreateDate(java.util.Date createDate)
 368  
     {
 369  12
         UserPeerManager.setUserCreateDate(getPersistentObj(), createDate);
 370  12
     }
 371  
 
 372  
     /**
 373  
      * Returns the date of the last login of the user
 374  
      *
 375  
      * @return The date of the last login of the user
 376  
      */
 377  
     public java.util.Date getLastLogin()
 378  
     {
 379  0
         return UserPeerManager.getUserLastLogin(getPersistentObj());
 380  
     }
 381  
 
 382  
     /**
 383  
      * Sets the new date of the last login of the user
 384  
      *
 385  
      * @param lastLogin The new the date of the last login of the user
 386  
      */
 387  
     public void setLastLogin(java.util.Date lastLogin)
 388  
     {
 389  0
         UserPeerManager.setUserLastLogin(getPersistentObj(), lastLogin);
 390  0
     }
 391  
 
 392  
     /**
 393  
      * Returns the value of the objectdata for this user.
 394  
      * Objectdata is a VARBINARY column in the table used
 395  
      * to store the permanent storage table from the User
 396  
      * object.
 397  
      *
 398  
      * @return The bytes in the objectdata for this user
 399  
      */
 400  
     public byte [] getObjectdata()
 401  
     {
 402  10
         return UserPeerManager.getUserObjectdata(getPersistentObj());
 403  
     }
 404  
 
 405  
     /**
 406  
      * Sets the value of the objectdata for the user
 407  
      *
 408  
      * @param objectdata The new the date of the last login of the user
 409  
      */
 410  
     public void setObjectdata(byte [] objectdata)
 411  
     {
 412  11
         UserPeerManager.setUserObjectdata(getPersistentObj(), objectdata);
 413  11
     }
 414  
 
 415  
 
 416  
     /**
 417  
      * Gets the access counter for a user from perm storage.
 418  
      *
 419  
      * @return The access counter for the user.
 420  
      */
 421  
     public int getAccessCounter()
 422  
     {
 423  
         try
 424  
         {
 425  3
             return ((Integer) getPerm(User.ACCESS_COUNTER)).intValue();
 426  
         }
 427  2
         catch (Exception e)
 428  
         {
 429  2
             return 0;
 430  
         }
 431  
     }
 432  
 
 433  
     /**
 434  
      * Gets the access counter for a user during a session.
 435  
      *
 436  
      * @return The access counter for the user for the session.
 437  
      */
 438  
     public int getAccessCounterForSession()
 439  
     {
 440  
         try
 441  
         {
 442  0
             return ((Integer) getTemp(User.SESSION_ACCESS_COUNTER)).intValue();
 443  
         }
 444  0
         catch (Exception e)
 445  
         {
 446  0
             return 0;
 447  
         }
 448  
     }
 449  
 
 450  
     /**
 451  
      * Increments the permanent hit counter for the user.
 452  
      */
 453  
     public void incrementAccessCounter()
 454  
     {
 455  
         // Ugh. Race city, here I come...
 456  1
         setAccessCounter(getAccessCounter() + 1);
 457  1
     }
 458  
 
 459  
     /**
 460  
      * Increments the session hit counter for the user.
 461  
      */
 462  
     public void incrementAccessCounterForSession()
 463  
     {
 464  0
         setAccessCounterForSession(getAccessCounterForSession() + 1);
 465  0
     }
 466  
 
 467  
     /**
 468  
      * Sets the access counter for a user, saved in perm storage.
 469  
      *
 470  
      * @param cnt The new count.
 471  
      */
 472  
     public void setAccessCounter(int cnt)
 473  
     {
 474  1
         setPerm(User.ACCESS_COUNTER, new Integer(cnt));
 475  1
     }
 476  
 
 477  
     /**
 478  
      * Sets the session access counter for a user, saved in temp
 479  
      * storage.
 480  
      *
 481  
      * @param cnt The new count.
 482  
      */
 483  
     public void setAccessCounterForSession(int cnt)
 484  
     {
 485  0
         setTemp(User.SESSION_ACCESS_COUNTER, new Integer(cnt));
 486  0
     }
 487  
 
 488  
     /**
 489  
      * This method reports whether or not the user has been confirmed
 490  
      * in the system by checking the User.CONFIRM_VALUE
 491  
      * column in the users record to see if it is equal to
 492  
      * User.CONFIRM_DATA.
 493  
      *
 494  
      * @return True if the user has been confirmed.
 495  
      */
 496  
     public boolean isConfirmed()
 497  
     {
 498  0
         String value = getConfirmed();
 499  0
         return (value != null && value.equals(User.CONFIRM_DATA));
 500  
     }
 501  
 
 502  
     /**
 503  
      * The user is considered logged in if they have not timed out.
 504  
      *
 505  
      * @return Whether the user has logged in.
 506  
      */
 507  
     public boolean hasLoggedIn()
 508  
     {
 509  3
         Boolean loggedIn = getHasLoggedIn();
 510  3
         return (loggedIn != null && loggedIn.booleanValue());
 511  
     }
 512  
 
 513  
     /**
 514  
      * This sets whether or not someone has logged in.  hasLoggedIn()
 515  
      * returns this value.
 516  
      *
 517  
      * @param value Whether someone has logged in or not.
 518  
      */
 519  
     public void setHasLoggedIn(Boolean value)
 520  
     {
 521  157
         setTemp(User.HAS_LOGGED_IN, value);
 522  157
     }
 523  
 
 524  
     /**
 525  
      * Gets the last access date for this User.  This is the last time
 526  
      * that the user object was referenced.
 527  
      *
 528  
      * @return A Java Date with the last access date for the user.
 529  
      */
 530  
     public java.util.Date getLastAccessDate()
 531  
     {
 532  0
         if (lastAccessDate == null)
 533  
         {
 534  0
             setLastAccessDate();
 535  
         }
 536  0
         return lastAccessDate;
 537  
     }
 538  
 
 539  
     /**
 540  
      * Sets the last access date for this User. This is the last time
 541  
      * that the user object was referenced.
 542  
      */
 543  
     public void setLastAccessDate()
 544  
     {
 545  0
         lastAccessDate = new java.util.Date();
 546  0
     }
 547  
 
 548  
     /**
 549  
      * Returns the permanent storage. This is implemented
 550  
      * as a Hashtable and backed by an VARBINARY column in
 551  
      * the database.
 552  
      *
 553  
      * @return A Hashtable.
 554  
      */
 555  
     public Hashtable getPermStorage()
 556  
     {
 557  18
         if (permStorage == null)
 558  
         {
 559  10
             byte [] objectdata = getObjectdata();
 560  
 
 561  10
             if (objectdata != null)
 562  
             {
 563  5
                 permStorage = (Hashtable) ObjectUtils.deserialize(objectdata);
 564  
             }
 565  
 
 566  10
             if (permStorage == null)
 567  
             {
 568  5
                 permStorage = new Hashtable();
 569  
             }
 570  
         }
 571  
 
 572  18
         return permStorage;
 573  
     }
 574  
 
 575  
     /**
 576  
      * This should only be used in the case where we want to save the
 577  
      * data to the database.
 578  
      *
 579  
      * @param storage A Hashtable.
 580  
      */
 581  
     public void setPermStorage(Hashtable permStorage)
 582  
     {
 583  0
         if (permStorage != null)
 584  
         {
 585  0
             this.permStorage = permStorage;
 586  
         }
 587  0
     }
 588  
 
 589  
     /**
 590  
      * Returns the temporary storage. This is implemented
 591  
      * as a Hashtable
 592  
      *
 593  
      * @return A Hashtable.
 594  
      */
 595  
     public Hashtable getTempStorage()
 596  
     {
 597  161
         if (tempStorage == null)
 598  
         {
 599  0
             tempStorage = new Hashtable();
 600  
         }
 601  161
         return tempStorage;
 602  
     }
 603  
 
 604  
     /**
 605  
      * This should only be used in the case where we want to save the
 606  
      * data to the database.
 607  
      *
 608  
      * @param storage A Hashtable.
 609  
      */
 610  
     public void setTempStorage(Hashtable tempStorage)
 611  
     {
 612  0
         if (tempStorage != null)
 613  
         {
 614  0
             this.tempStorage = tempStorage;
 615  
         }
 616  0
     }
 617  
 
 618  
     /**
 619  
      * Get an object from permanent storage.
 620  
      *
 621  
      * @param name The object's name.
 622  
      * @return An Object with the given name.
 623  
      */
 624  
     public Object getPerm(String name)
 625  
     {
 626  3
         return getPermStorage().get(name);
 627  
     }
 628  
 
 629  
     /**
 630  
      * Get an object from permanent storage; return default if value
 631  
      * is null.
 632  
      *
 633  
      * @param name The object's name.
 634  
      * @param def A default value to return.
 635  
      * @return An Object with the given name.
 636  
      */
 637  
     public Object getPerm(String name, Object def)
 638  
     {
 639  
         try
 640  
         {
 641  0
             Object val = getPermStorage().get(name);
 642  0
             return (val == null ? def : val);
 643  
         }
 644  0
         catch (Exception e)
 645  
         {
 646  0
             return def;
 647  
         }
 648  
     }
 649  
 
 650  
     /**
 651  
      * Put an object into permanent storage. If the value is null,
 652  
      * it will convert that to a "" because the underlying storage
 653  
      * mechanism within TorqueUser is currently a Hashtable and
 654  
      * null is not a valid value.
 655  
      *
 656  
      * @param name The object's name.
 657  
      * @param value The object.
 658  
      */
 659  
     public void setPerm(String name, Object value)
 660  
     {
 661  1
         getPermStorage().put(name, (value == null) ? "" : value);
 662  1
     }
 663  
 
 664  
     /**
 665  
      * Get an object from temporary storage.
 666  
      *
 667  
      * @param name The object's name.
 668  
      * @return An Object with the given name.
 669  
      */
 670  
     public Object getTemp(String name)
 671  
     {
 672  3
         return getTempStorage().get(name);
 673  
     }
 674  
 
 675  
     /**
 676  
      * Get an object from temporary storage; return default if value
 677  
      * is null.
 678  
      *
 679  
      * @param name The object's name.
 680  
      * @param def A default value to return.
 681  
      * @return An Object with the given name.
 682  
      */
 683  
     public Object getTemp(String name, Object def)
 684  
     {
 685  
         Object val;
 686  
         try
 687  
         {
 688  0
             val = getTempStorage().get(name);
 689  0
             if (val == null)
 690  
             {
 691  0
                 val = def;
 692  
             }
 693  
         }
 694  0
         catch (Exception e)
 695  
         {
 696  0
             val = def;
 697  0
         }
 698  0
         return val;
 699  
     }
 700  
 
 701  
     /**
 702  
      * Put an object into temporary storage. If the value is null,
 703  
      * it will convert that to a "" because the underlying storage
 704  
      * mechanism within TorqueUser is currently a Hashtable and
 705  
      * null is not a valid value.
 706  
      *
 707  
      * @param name The object's name.
 708  
      * @param value The object.
 709  
      */
 710  
     public void setTemp(String name, Object value)
 711  
     {
 712  157
         getTempStorage().put(name, (value == null) ? "" : value);
 713  157
     }
 714  
 
 715  
     /**
 716  
      * Remove an object from temporary storage and return the object.
 717  
      *
 718  
      * @param name The name of the object to remove.
 719  
      * @return An Object.
 720  
      */
 721  
     public Object removeTemp(String name)
 722  
     {
 723  0
         return getTempStorage().remove(name);
 724  
     }
 725  
 
 726  
     /**
 727  
      * Updates the last login date in the database.
 728  
      *
 729  
      * @exception Exception A generic exception.
 730  
      */
 731  
     public void updateLastLogin()
 732  
         throws Exception
 733  
     {
 734  0
         setLastLogin(new java.util.Date());
 735  0
     }
 736  
 
 737  
     /**
 738  
      * Implement this method if you wish to be notified when the User
 739  
      * has been Bound to the session.
 740  
      *
 741  
      * @param event Indication of value/session binding.
 742  
      */
 743  
     public void valueBound(HttpSessionBindingEvent hsbe)
 744  
     {
 745  
         // Currently we have no need for this method.
 746  0
     }
 747  
 
 748  
     /**
 749  
      * Implement this method if you wish to be notified when the User
 750  
      * has been Unbound from the session.
 751  
      *
 752  
      * @param event Indication of value/session unbinding.
 753  
      */
 754  
     public void valueUnbound(HttpSessionBindingEvent hsbe)
 755  
     {
 756  
         try
 757  
         {
 758  0
             if (hasLoggedIn())
 759  
             {
 760  0
                 TurbineSecurity.saveOnSessionUnbind(this);
 761  
             }
 762  
         }
 763  0
         catch (Exception e)
 764  
         {
 765  
             //Log.error("TorqueUser.valueUnbound(): " + e.getMessage(), e);
 766  
 
 767  
             // To prevent messages being lost in case the logging system
 768  
             // goes away before sessions get unbound on servlet container
 769  
             // shutdown, print the stcktrace to the container's console.
 770  0
             ByteArrayOutputStream ostr = new ByteArrayOutputStream();
 771  0
             e.printStackTrace(new PrintWriter(ostr, true));
 772  0
             String stackTrace = ostr.toString();
 773  0
             System.out.println(stackTrace);
 774  0
         }
 775  0
     }
 776  
 
 777  
     /**
 778  
      * This gets whether or not someone has logged in.  hasLoggedIn()
 779  
      * returns this value as a boolean.  This is private because you
 780  
      * should use hasLoggedIn() instead.
 781  
      *
 782  
      * @return True if someone has logged in.
 783  
      */
 784  
     private Boolean getHasLoggedIn()
 785  
     {
 786  3
         return (Boolean) getTemp(User.HAS_LOGGED_IN);
 787  
     }
 788  
 
 789  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.