001 /*
002 * Copyright 2015-2016 UnboundID Corp.
003 * All Rights Reserved.
004 */
005 /*
006 * Copyright (C) 2015-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 com.unboundid.asn1.ASN1OctetString;
026
027
028
029 /**
030 * This class defines an exception that can be thrown if the server sends a bind
031 * response with a result code other than {@code ResultCode#SUCCESS}, which
032 * indicates that the bind operation did not complete successfully. This may be
033 * used to obtain access to any server SASL credentials contained in the
034 * non-successful bind result.
035 */
036 public class LDAPBindException
037 extends LDAPException
038 {
039 /**
040 * The serial version UID for this serializable class.
041 */
042 private static final long serialVersionUID = 6545956074186731236L;
043
044
045
046 // The bind result for this exception.
047 private final BindResult bindResult;
048
049
050
051 /**
052 * Creates a new LDAP bind exception from the provided bind result.
053 *
054 * @param bindResult The bind result to use to create this exception.
055 */
056 public LDAPBindException(final BindResult bindResult)
057 {
058 super(bindResult);
059
060 this.bindResult = bindResult;
061 }
062
063
064
065 /**
066 * Retrieves the bind result that was returned by the server.
067 *
068 * @return The bind result that was returned by the server.
069 */
070 public BindResult getBindResult()
071 {
072 return bindResult;
073 }
074
075
076
077 /**
078 * Retrieves the server SASL credentials included in the bind result, if any.
079 *
080 * @return The server SASL credentials included in the bind result, or
081 * {@code null} if the bind result did not include any server SASL
082 * credentials.
083 */
084 public ASN1OctetString getServerSASLCredentials()
085 {
086 return bindResult.getServerSASLCredentials();
087 }
088 }