| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
package org.ietf.ldap.client.opers; |
| 39 |
|
| 40 |
import java.io.IOException; |
| 41 |
|
| 42 |
import org.ietf.ldap.ber.stream.BERElement; |
| 43 |
import org.ietf.ldap.ber.stream.BEREnumerated; |
| 44 |
import org.ietf.ldap.ber.stream.BEROctetString; |
| 45 |
import org.ietf.ldap.ber.stream.BERSequence; |
| 46 |
import org.ietf.ldap.ber.stream.BERTag; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
public class JDAPResult { |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public final static int SUCCESS = 0; |
| 81 |
public final static int OPERATION_ERROR = 1; |
| 82 |
public final static int PROTOCOL_ERROR = 2; |
| 83 |
public final static int TIME_LIMIT_EXCEEDED = 3; |
| 84 |
public final static int SIZE_LIMIT_EXCEEDED = 4; |
| 85 |
public final static int COMPARE_FALSE = 5; |
| 86 |
public final static int COMPARE_TRUE = 6; |
| 87 |
public final static int AUTH_METHOD_NOT_SUPPORTED = 7; |
| 88 |
public final static int STRONG_AUTH_REQUIRED = 8; |
| 89 |
|
| 90 |
public final static int LDAP_PARTIAL_RESULTS = 9; |
| 91 |
|
| 92 |
public final static int REFERRAL = 10; |
| 93 |
public final static int ADMIN_LIMIT_EXCEEDED = 11; |
| 94 |
public final static int UNAVAILABLE_CRITICAL_EXTENSION = 12; |
| 95 |
public final static int CONFIDENTIALITY_REQUIRED = 13; |
| 96 |
public final static int SASL_BIND_IN_PROGRESS = 14; |
| 97 |
|
| 98 |
public final static int NO_SUCH_ATTRIBUTE = 16; |
| 99 |
public final static int UNDEFINED_ATTRIBUTE_TYPE = 17; |
| 100 |
public final static int INAPPROPRIATE_MATCHING = 18; |
| 101 |
public final static int CONSTRAINT_VIOLATION = 19; |
| 102 |
public final static int ATTRIBUTE_OR_VALUE_EXISTS = 20; |
| 103 |
public final static int INVALID_ATTRIBUTE_SYNTAX = 21; |
| 104 |
public final static int NO_SUCH_OBJECT = 32; |
| 105 |
public final static int ALIAS_PROBLEM = 33; |
| 106 |
public final static int INVALID_DN_SYNTAX = 34; |
| 107 |
public final static int IS_LEAF = 35; |
| 108 |
public final static int ALIAS_DEREFERENCING_PROBLEM = 36; |
| 109 |
public final static int INAPPROPRIATE_AUTHENTICATION = 48; |
| 110 |
public final static int INVALID_CREDENTIALS = 49; |
| 111 |
public final static int INSUFFICIENT_ACCESS_RIGHTS = 50; |
| 112 |
public final static int BUSY = 51; |
| 113 |
public final static int UNAVAILABLE = 52; |
| 114 |
public final static int UNWILLING_TO_PERFORM = 53; |
| 115 |
public final static int LOOP_DETECT = 54; |
| 116 |
public final static int NAMING_VIOLATION = 64; |
| 117 |
public final static int OBJECT_CLASS_VIOLATION = 65; |
| 118 |
public final static int NOT_ALLOWED_ON_NONLEAF = 66; |
| 119 |
public final static int NOT_ALLOWED_ON_RDN = 67; |
| 120 |
public final static int ENTRY_ALREADY_EXISTS = 68; |
| 121 |
public final static int OBJECT_CLASS_MODS_PROHIBITED = 69; |
| 122 |
public final static int AFFECTS_MULTIPLE_DSAS = 71; |
| 123 |
public final static int OTHER = 80; |
| 124 |
public final static int SERVER_DOWN = 81; |
| 125 |
public final static int PARAM_ERROR = 89; |
| 126 |
public final static int CONNECT_ERROR = 91; |
| 127 |
public final static int LDAP_NOT_SUPPORTED = 92; |
| 128 |
public final static int CONTROL_NOT_FOUND = 93; |
| 129 |
public final static int NO_RESULTS_RETURNED = 94; |
| 130 |
public final static int MORE_RESULTS_TO_RETURN = 95; |
| 131 |
public final static int CLIENT_LOOP = 96; |
| 132 |
public final static int REFERRAL_LIMIT_EXCEEDED = 97; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
protected BERElement m_element = null; |
| 138 |
protected int m_result_code; |
| 139 |
protected String m_matched_dn = null; |
| 140 |
protected String m_error_message = null; |
| 141 |
protected String m_referrals[] = null; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
public JDAPResult(BERElement element) throws IOException { |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
m_element = element; |
| 164 |
BERSequence seq = (BERSequence)element; |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
BERElement e = seq.elementAt(0); |
| 170 |
if (e.getType() == BERElement.SEQUENCE) |
| 171 |
seq = (BERSequence)e; |
| 172 |
m_result_code = ((BEREnumerated)seq.elementAt(0)).getValue(); |
| 173 |
byte buf[] = null; |
| 174 |
buf = ((BEROctetString)seq.elementAt(1)).getValue(); |
| 175 |
if (buf == null) |
| 176 |
m_matched_dn = null; |
| 177 |
else { |
| 178 |
try{ |
| 179 |
m_matched_dn = new String(buf, "UTF8"); |
| 180 |
} catch(Throwable x) |
| 181 |
{} |
| 182 |
} |
| 183 |
buf = ((BEROctetString)seq.elementAt(2)).getValue(); |
| 184 |
if (buf == null) |
| 185 |
m_error_message = null; |
| 186 |
else { |
| 187 |
try { |
| 188 |
m_error_message = new String(buf, "UTF8"); |
| 189 |
} catch(Throwable x) |
| 190 |
{} |
| 191 |
} |
| 192 |
|
| 193 |
if (seq.size() >= 4) { |
| 194 |
BERTag t = (BERTag)seq.elementAt(3); |
| 195 |
BERElement v = t.getValue(); |
| 196 |
if (v.getType() == BERElement.INTEGER) { |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
} else if (v instanceof BERSequence) { |
| 202 |
|
| 203 |
BERSequence rseq = (BERSequence)v; |
| 204 |
if (rseq.size() > 0) { |
| 205 |
m_referrals = new String[rseq.size()]; |
| 206 |
for (int i = 0; i < rseq.size(); i++) { |
| 207 |
try{ |
| 208 |
m_referrals[i] = new |
| 209 |
String(((BEROctetString)rseq.elementAt(i)).getValue(), "UTF8"); |
| 210 |
} catch(Throwable x) |
| 211 |
{} |
| 212 |
} |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
public int getResultCode() { |
| 223 |
return m_result_code; |
| 224 |
} |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
public String getMatchedDN() { |
| 231 |
return m_matched_dn; |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
public String getErrorMessage() { |
| 239 |
return m_error_message; |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
public String[] getReferrals() { |
| 247 |
return m_referrals; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
public BERElement getBERElement() { |
| 255 |
return m_element; |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
public String getParamString() { |
| 265 |
StringBuffer sb = new StringBuffer("{resultCode="); |
| 266 |
sb.append(m_result_code); |
| 267 |
if (m_matched_dn != null) { |
| 268 |
sb.append(", matchedDN="); |
| 269 |
sb.append(m_matched_dn); |
| 270 |
} |
| 271 |
if (m_error_message != null) { |
| 272 |
sb.append(", errorMessage="); |
| 273 |
sb.append(m_error_message); |
| 274 |
} |
| 275 |
if (m_referrals != null && m_referrals.length > 0) { |
| 276 |
sb.append(", referrals="); |
| 277 |
for (int i=0; i < m_referrals.length; i++) { |
| 278 |
sb.append((i==0 ? "" : " ")); |
| 279 |
sb.append(m_referrals[i]); |
| 280 |
} |
| 281 |
} |
| 282 |
sb.append("}"); |
| 283 |
return sb.toString(); |
| 284 |
} |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
public String toString() { |
| 291 |
return "Result " + getParamString(); |
| 292 |
} |
| 293 |
} |