Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 package org.eclipse.jetty.security;
 
 
 
 /* ------------------------------------------------------------ */
Properties User Realm. An implementation of UserRealm that stores users and roles in-memory in HashMaps.

Typically these maps are populated by calling the load() method or passing a properties resource to the constructor. The format of the properties file is:

  username: password [,rolename ...]
 
Passwords may be clear text, obfuscated or checksummed. The class com.eclipse.Util.Password should be used to generate obfuscated passwords or password checksums. If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or OBF:.
 
 public class HashLoginService extends MappedLoginService implements UserListener
 {
     private static final Logger LOG = Log.getLogger(HashLoginService.class);
 
     private String _config;
     private Resource _configResource;
     private Scanner _scanner;
     private int _refreshInterval = 0;// default is not to reload
 
     /* ------------------------------------------------------------ */
     public HashLoginService()
     {
     }
 
     /* ------------------------------------------------------------ */
     public HashLoginService(String name)
     {
         setName(name);
     }
 
     /* ------------------------------------------------------------ */
     public HashLoginService(String nameString config)
     {
         setName(name);
         setConfig(config);
     }
 
     /* ------------------------------------------------------------ */
     public String getConfig()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
     public void getConfig(String config)
     {
          = config;
     }
 
     /* ------------------------------------------------------------ */
     public Resource getConfigResource()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Load realm users from properties file. The property file maps usernames to password specs followed by an optional comma separated list of role names.

Parameters:
config Filename or url of user properties file.
    public void setConfig(String config)
    {
         = config;
    }
    /* ------------------------------------------------------------ */
    public void setRefreshInterval(int msec)
    {
         = msec;
    }
    /* ------------------------------------------------------------ */
    public int getRefreshInterval()
    {
        return ;
    }
    /* ------------------------------------------------------------ */
    @Override
    protected UserIdentity loadUser(String username)
    {
        return null;
    }
    /* ------------------------------------------------------------ */
    @Override
    public void loadUsers() throws IOException
    {
        // TODO: Consider refactoring MappedLoginService to not have to override with unused methods
    }
    /* ------------------------------------------------------------ */
    
    protected void doStart() throws Exception
    {
        super.doStart();
        
        if ( == null)
        {
            if(.isDebugEnabled())
                .debug("doStart: Starting new PropertyUserStore. PropertiesFile: " +  + " refreshInterval: " + );
            
             = new PropertyUserStore();
            .setConfig();
            .registerUserListener(this);
            .start();
        }
    }
    /* ------------------------------------------------------------ */
    
    protected void doStop() throws Exception
    {
        super.doStop();
        if ( != null)
            .stop();
         = null;
    }
    
    /* ------------------------------------------------------------ */
    public void update(String userNameCredential credentialString[] roleArray)
    {
        if (.isDebugEnabled())
            .debug("update: " + userName + " Roles: " + roleArray.length);
        putUser(userName,credential,roleArray);
    }
    /* ------------------------------------------------------------ */
    public void remove(String userName)
    {
        if (.isDebugEnabled())
            .debug("remove: " + userName);
        removeUser(userName);
    }
New to GrepCode? Check out our FAQ X