/**
   * Removes UserDetails of user with given id from UserDetails-Cache.
   *
   * @param userId The user Id.
   * @throws SqlDatabaseSystemException Thrown in case of an internal database access error.
   */
  private void clearUserDetailsCache(final String userId) throws SqlDatabaseSystemException {

    final UserAccount userAccount = retrieveUserAccountById(userId);
    if (userAccount != null
        && userAccount.getUserLoginDatas() != null
        && !userAccount.getUserLoginDatas().isEmpty()) {
      for (final UserLoginData userLoginData : userAccount.getUserLoginDatas()) {
        securityHelper.clearUserDetails(userLoginData.getHandle());
      }
    }
  }
  /**
   * Checks if the provided {@link UserLoginData} object for is expired. If this is the case, the
   * object is deleted from the storage. And object is removed from Cache.
   *
   * @param data The {@link UserLoginData} object to check.
   * @return Returns the provided {@link UserLoginData} object or {@code null} if it is expired.
   * @throws SqlDatabaseSystemException Thrown in case of an internal database access error.
   */
  private UserLoginData checkUserLoginData(final UserLoginData data)
      throws SqlDatabaseSystemException {

    UserLoginData result = data;
    if (result != null && isExpired(result)) {
      delete(result);
      securityHelper.clearUserDetails(data.getHandle());
      result = null;
    }
    return result;
  }
 /** See Interface for functional description. */
 @Override
 public void deleteUserLoginData(final String handle) throws SqlDatabaseSystemException {
   // remove UserData from Cache
   securityHelper.clearUserDetails(handle);
   super.delete(retrieveUserLoginDataByHandle(handle));
 }
 /**
  * See Interface for functional description.
  *
  * @see UserAccountDaoInterface #delete(de.escidoc.core.aa.business.persistence.UserLoginData)
  */
 @Override
 public void delete(final UserLoginData data) throws SqlDatabaseSystemException {
   // remove UserData from Cache
   securityHelper.clearUserDetails(data.getHandle());
   super.delete(data);
 }