001    /*
002     * Copyright 2011-2015 UnboundID Corp.
003     * All Rights Reserved.
004     */
005    /*
006     * Copyright (C) 2011-2015 UnboundID Corp.
007     *
008     * This program is free software; you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (GPLv2 only)
010     * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011     * as published by the Free Software Foundation.
012     *
013     * This program is distributed in the hope that it will be useful,
014     * but WITHOUT ANY WARRANTY; without even the implied warranty of
015     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     * GNU General Public License for more details.
017     *
018     * You should have received a copy of the GNU General Public License
019     * along with this program; if not, see <http://www.gnu.org/licenses>.
020     */
021    package com.unboundid.ldap.sdk;
022    
023    
024    
025    import java.io.Serializable;
026    
027    
028    
029    
030    /**
031     * This class defines an API that may be used to obtain a clear-text password
032     * that may be used for authentication or other purposes.  Passwords must be
033     * returned in the form of a byte array, and the contents of that array will be
034     * zeroed out as soon as the password is no longer required in order to minimize
035     * the length of time that the password will remain in memory.
036     */
037    public abstract class PasswordProvider
038           implements Serializable
039    {
040      /**
041       * The serial version UID for this serializable class.
042       */
043      private static final long serialVersionUID = -1582416755360005908L;
044    
045    
046    
047      /**
048       * Retrieves a password in a newly-created byte array.  Once the password is
049       * no longer required, the contents of the array will be overwritten so that
050       * the password is no longer contained in memory.
051       *
052       * @return  A byte array containing the password that should be used.
053       *
054       * @throws  LDAPException  If a problem is encountered while attempting to
055       *                         obtain the password.
056       */
057      public abstract byte[] getPasswordBytes()
058             throws LDAPException;
059    }