001/* 002 * Copyright 2011-2014 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2011-2014 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 */ 021package com.unboundid.util; 022 023 024 025import java.io.Serializable; 026 027 028 029/** 030 * This class provides a data structure that holds information about an option 031 * that can be used in the course of SASL authentication. 032 */ 033@NotMutable() 034@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 035public final class SASLOption 036 implements Serializable 037{ 038 /** 039 * The serial version UID for this serializable class. 040 */ 041 private static final long serialVersionUID = -683675804002105357L; 042 043 044 045 // Indicates whether this option is allowed to be specified multiple times for 046 // a single bind request. 047 private final boolean isMultiValued; 048 049 // Indicates whether this SASL option is required for use in conjunction with 050 // the associated SASL mechanism. 051 private final boolean isRequired; 052 053 // A description for this SASL option. 054 private final String description; 055 056 // The name for this SASL option. 057 private final String name; 058 059 060 061 /** 062 * Creates a new SASL option with the provided information. 063 * 064 * @param name The name for this SASL option. 065 * @param description A description for this SASL option. 066 * @param isRequired Indicates whether this option is required for use in 067 * conjunction with the associated SASL mechanism. 068 * @param isMultiValued Indicates whether this option is allowed to be 069 * specified multiple times for a single bind request. 070 */ 071 public SASLOption(final String name, final String description, 072 final boolean isRequired, final boolean isMultiValued) 073 { 074 this.name = name; 075 this.description = description; 076 this.isRequired = isRequired; 077 this.isMultiValued = isMultiValued; 078 } 079 080 081 082 /** 083 * Retrieves the name for this SASL option. 084 * 085 * @return The name for this SASL option. 086 */ 087 public String getName() 088 { 089 return name; 090 } 091 092 093 094 /** 095 * Retrieves a description for this SASL option. 096 * 097 * @return A description for this SASL option. 098 */ 099 public String getDescription() 100 { 101 return description; 102 } 103 104 105 106 /** 107 * Indicates whether this SASL option must be provided when attempting to bind 108 * with the associated mechanism. 109 * 110 * @return {@code true} if this SASL option must be specified when trying to 111 * bind with the associated mechanism, or {@code false} if not. 112 */ 113 public boolean isRequired() 114 { 115 return isRequired; 116 } 117 118 119 120 /** 121 * Indicates whether this SASL option may be provided multiple times when 122 * trying to bind with the associated mechanism. 123 * 124 * @return {@code true} if this SASL option may be provided multiple times 125 * when trying to bind with the associated mechanism, or 126 * {@code false} if not. 127 */ 128 public boolean isMultiValued() 129 { 130 return isMultiValued; 131 } 132 133 134 135 /** 136 * Retrieves a string representation for this SASL option. 137 * 138 * @return A string representation for this SASL option. 139 */ 140 @Override() 141 public String toString() 142 { 143 final StringBuilder buffer = new StringBuilder(); 144 toString(buffer); 145 return buffer.toString(); 146 } 147 148 149 150 /** 151 * Appends a string representation of this SASL option to the provided buffer. 152 * 153 * @param buffer The buffer to which the information should be appended. 154 */ 155 public void toString(final StringBuilder buffer) 156 { 157 buffer.append("SASLOption(name='"); 158 buffer.append(name); 159 buffer.append("', description='"); 160 buffer.append(description); 161 buffer.append("', isRequired="); 162 buffer.append(isRequired); 163 buffer.append(", isMultiValued="); 164 buffer.append(isMultiValued); 165 buffer.append(')'); 166 } 167}