org.eclipse.net4j.util.security

## Class FileUserManager

- java.lang.Object
- - org.eclipse.net4j.util.event.Notifier
  - - org.eclipse.net4j.util.lifecycle.Lifecycle
    - - org.eclipse.net4j.util.security.UserManager
      - - org.eclipse.net4j.util.security.FileUserManager

- All Implemented Interfaces:
    INotifier, IDeactivateable, ILifecycle, ILifecycle.DeferrableActivation, IAuthenticator, IUserManager

      public class FileUserManager
      extends UserManager

  Author:
    Eike Stepper

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `ILifecycle.DeferrableActivation`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `fileName`

    - ### Fields inherited from class org.eclipse.net4j.util.security.UserManager

      `users`

    - ### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileUserManager()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doBeforeActivate()`
    `protected void` | `doDeactivate()`
    `java.io.File` | `getFile()`
    `java.lang.String` | `getFileName()`
    `protected void` | `load(java.util.Map<java.lang.String,char[]> users)`
    `protected void` | `load(java.util.Map<java.lang.String,char[]> users, java.io.InputStream stream)`
    `protected java.io.File` | `resolveFile(java.lang.String fileName)`
    `protected void` | `save(java.util.Map<java.lang.String,char[]> users)`
    `protected void` | `save(java.util.Map<java.lang.String,char[]> users, java.io.FileOutputStream stream)`
    `void` | `setFileName(java.lang.String fileName)` Sets the name of the file to be used by this user manager.

    - ### Methods inherited from class org.eclipse.net4j.util.security.UserManager

      `addUser, authenticate, doActivate, encrypt, getPassword, removeUser`

    - ### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

    - ### Methods inherited from class org.eclipse.net4j.util.event.Notifier

      `addListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, removeListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

      `addListener, getListeners, hasListeners, removeListener`

- - ### Field Detail

    - #### fileName

          protected java.lang.String fileName

  - ### Constructor Detail

    - #### FileUserManager

          public FileUserManager()

  - ### Method Detail

    - #### getFileName

          public java.lang.String getFileName()

    - #### setFileName

          public void setFileName(java.lang.String fileName)

      Sets the name of the file to be used by this user manager.

      The `file` is resolved in the following order:

      1. If it starts with the path segment "@config" the subsequent path segments are interpreted as relative to the `config folder`.
      2. If it is relative it is interpreted as relative to the application's current directory.
      3. Otherwise it is interpreted as absolute.
      Unless "-Dnet4j.security.FileUserManager.failIfFileDoesNotExist=true" is specified the resolved file is not required to exist when this user manager is activated. In this case it will be created when `addUser()` or `removeUser()` are called.

      With "-Dnet4j.security.FileUserManager.fallBackToConfigFolder=true" a relative path is resolved in both the application's current folder and the config folder (in this order).

    - #### getFile

          public final java.io.File getFile()

      Since:
        3.7

    - #### resolveFile

          protected java.io.File resolveFile(java.lang.String fileName)
                                      throws java.lang.Exception

      Throws:
        `java.lang.Exception`
      Since:
        3.7

    - #### doBeforeActivate

          protected void doBeforeActivate()
                                   throws java.lang.Exception

      Overrides:
        `doBeforeActivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### doDeactivate

          protected void doDeactivate()
                               throws java.lang.Exception

      Overrides:
        `doDeactivate` in class `UserManager`
      Throws:
        `java.lang.Exception`

    - #### load

          protected void load(java.util.Map<java.lang.String,char[]> users)
                       throws IORuntimeException

      Overrides:
        `load` in class `UserManager`
      Throws:
        `IORuntimeException`

    - #### load

          protected void load(java.util.Map<java.lang.String,char[]> users,
                              java.io.InputStream stream)
                       throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### save

          protected void save(java.util.Map<java.lang.String,char[]> users)
                       throws IORuntimeException

      Overrides:
        `save` in class `UserManager`
      Throws:
        `IORuntimeException`

    - #### save

          protected void save(java.util.Map<java.lang.String,char[]> users,
                              java.io.FileOutputStream stream)
                       throws java.io.IOException

      Throws:
        `java.io.IOException`

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html