001 /*
002 * Copyright 2011-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2011-2016 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 import com.unboundid.util.Extensible;
028 import com.unboundid.util.ThreadSafety;
029 import com.unboundid.util.ThreadSafetyLevel;
030
031
032
033 /**
034 * This class defines an API that may be used to obtain a clear-text password
035 * that may be used for authentication or other purposes. Passwords must be
036 * returned in the form of a byte array, and the contents of that array will be
037 * zeroed out as soon as the password is no longer required in order to minimize
038 * the length of time that the password will remain in memory.
039 */
040 @Extensible()
041 @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
042 public abstract class PasswordProvider
043 implements Serializable
044 {
045 /**
046 * The serial version UID for this serializable class.
047 */
048 private static final long serialVersionUID = -1582416755360005908L;
049
050
051
052 /**
053 * Retrieves a password in a newly-created byte array. Once the password is
054 * no longer required, the contents of the array will be overwritten so that
055 * the password is no longer contained in memory.
056 *
057 * @return A byte array containing the password that should be used.
058 *
059 * @throws LDAPException If a problem is encountered while attempting to
060 * obtain the password.
061 */
062 public abstract byte[] getPasswordBytes()
063 throws LDAPException;
064 }