mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 20:42:49 +00:00
Updated ldapjdk 4.05
This commit is contained in:
parent
4a274d01f1
commit
276d1ca762
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
@ -342,9 +342,12 @@ public class LDAPBasePropertySupport implements Serializable {
|
||||
m_conn.getAuthenticationPassword() );
|
||||
}
|
||||
};
|
||||
LDAPSearchConstraints cons = conn.getSearchConstraints();
|
||||
cons.setReferrals( true );
|
||||
cons.setRebindProc( rebind );
|
||||
try {
|
||||
conn.setOption(LDAPConnection.REFERRALS, Boolean.TRUE);
|
||||
conn.setOption(LDAPConnection.REFERRALS_REBIND_PROC, rebind);
|
||||
} catch (LDAPException e) {
|
||||
//will never happen
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
@ -288,6 +288,10 @@ public class LDAPFilter implements Cloneable {
|
||||
if ( cFilterTemplate[i] == '%' ) {
|
||||
i++;
|
||||
if ( cFilterTemplate[i] == 'v' ) {
|
||||
if ( i == (cFilterTemplate.length-1) ) {
|
||||
sbFilter.append ( strValue );
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
switch ( cFilterTemplate[i] ) {
|
||||
case '$':
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -365,6 +365,6 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
|
||||
NO_USER_MODIFICATION,
|
||||
SYNTAX};
|
||||
|
||||
private LDAPSyntaxSchemaElement syntaxElement =
|
||||
protected LDAPSyntaxSchemaElement syntaxElement =
|
||||
new LDAPSyntaxSchemaElement();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -176,12 +176,12 @@ class LDAPConnThread extends Thread {
|
||||
if (!(request instanceof JDAPAbandonRequest ||
|
||||
request instanceof JDAPUnbindRequest)) {
|
||||
/* Only worry about toNotify if we expect a response... */
|
||||
this.m_requests.put (new Integer (msg.getID()), toNotify);
|
||||
this.m_requests.put (new Integer (msg.getMessageID()), toNotify);
|
||||
/* Notify the backlog checker that there may be another outstanding
|
||||
request */
|
||||
resultRetrieved();
|
||||
}
|
||||
toNotify.addRequest(msg.getID(), conn, this, cons.getTimeLimit());
|
||||
toNotify.addRequest(msg.getMessageID(), conn, this, cons.getTimeLimit());
|
||||
}
|
||||
|
||||
synchronized( m_sendRequestLock ) {
|
||||
@ -435,7 +435,7 @@ class LDAPConnThread extends Thread {
|
||||
* @param msg New message from LDAP server
|
||||
*/
|
||||
private void processResponse (LDAPMessage msg, int size) {
|
||||
Integer messageID = new Integer (msg.getID());
|
||||
Integer messageID = new Integer (msg.getMessageID());
|
||||
LDAPMessageQueue l = (LDAPMessageQueue)m_requests.get (messageID);
|
||||
|
||||
if (l == null) {
|
||||
@ -451,7 +451,7 @@ class LDAPConnThread extends Thread {
|
||||
/* Were there any controls for this client? */
|
||||
LDAPControl[] con = msg.getControls();
|
||||
if (con != null) {
|
||||
int msgid = msg.getID();
|
||||
int msgid = msg.getMessageID();
|
||||
LDAPConnection ldc = l.getConnection(msgid);
|
||||
if (ldc != null) {
|
||||
ldc.setResponseControls( this,
|
||||
@ -483,7 +483,7 @@ class LDAPConnThread extends Thread {
|
||||
* the entry size to -1.
|
||||
*/
|
||||
private synchronized void cacheSearchResult (LDAPSearchListener l, LDAPMessage msg, int size) {
|
||||
Integer messageID = new Integer (msg.getID());
|
||||
Integer messageID = new Integer (msg.getMessageID());
|
||||
Long key = l.getKey();
|
||||
Vector v = null;
|
||||
|
||||
|
@ -176,10 +176,13 @@ public class LDAPConnection
|
||||
* When -D command line option is used, defining the property with
|
||||
* no value will send the trace output to the standard error. If the
|
||||
* value is defined, it is assumed to be the name of an output file.
|
||||
* If the file name is prefixed with a '+' character, the file is
|
||||
* opened in append mode.
|
||||
* <P>
|
||||
* When the property is set with <CODE>getProperty</CODE> method,
|
||||
* the property must have an output stream as the value. To stop
|
||||
* tracing, <CODE>null</CODE> should be passed as the property value.
|
||||
* the property value must be either a String (represents a file name)
|
||||
* or an OutputStream. To stop tracing, <CODE>null</CODE> should be
|
||||
* passed as the property value.
|
||||
*
|
||||
* @see netscape.ldap.LDAPConnection#setProperty(java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@ -245,15 +248,16 @@ public class LDAPConnection
|
||||
private Properties m_securityProperties;
|
||||
private Hashtable m_properties = new Hashtable();
|
||||
private LDAPConnection m_referralConnection;
|
||||
private String m_authMethod = "none";
|
||||
|
||||
/**
|
||||
* Properties
|
||||
*/
|
||||
private final static Float SdkVersion = new Float(4.04f);
|
||||
private final static Float SdkVersion = new Float(4.05f);
|
||||
private final static Float ProtocolVersion = new Float(3.0f);
|
||||
private final static String SecurityVersion = new String("none,simple,sasl");
|
||||
private final static Float MajorVersion = new Float(4.0f);
|
||||
private final static Float MinorVersion = new Float(0.4f);
|
||||
private final static Float MinorVersion = new Float(0.5f);
|
||||
private final static String DELIM = "#";
|
||||
private final static String PersistSearchPackageName =
|
||||
"netscape.ldap.controls.LDAPPersistSearchControl";
|
||||
@ -432,18 +436,19 @@ public class LDAPConnection
|
||||
|
||||
} else if ( name.equalsIgnoreCase( TRACE_PROPERTY ) ) {
|
||||
|
||||
OutputStream os = null;
|
||||
if (val == null) {
|
||||
m_properties.remove(TRACE_PROPERTY);
|
||||
}
|
||||
else if (! (val instanceof OutputStream)) {
|
||||
throw new LDAPException(TRACE_PROPERTY + " must be OutputStream" );
|
||||
}
|
||||
else {
|
||||
if (m_thread != null) {
|
||||
os = createTraceOutputStream(val);
|
||||
}
|
||||
m_properties.put( TRACE_PROPERTY, val );
|
||||
}
|
||||
|
||||
|
||||
if (m_thread != null) {
|
||||
m_thread.setTraceOutputStream((OutputStream)val);
|
||||
m_thread.setTraceOutputStream(os);
|
||||
}
|
||||
|
||||
// This is used only by the ldapjdk test cases to simulate a
|
||||
@ -456,6 +461,47 @@ public class LDAPConnection
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output stream from the TRACE_PROPERTY value.
|
||||
* The value can be either of type String or OutputStream. The
|
||||
* String value represents output file name. If the name is an empty
|
||||
* string, the output is sent to System.err. If the file name is
|
||||
* prefixed with a '+' character, the file is opened in append mode.
|
||||
* @param out Trace output specifier
|
||||
*/
|
||||
OutputStream createTraceOutputStream(Object out) throws LDAPException {
|
||||
OutputStream os = null;
|
||||
|
||||
if (out instanceof String) { // trace file name
|
||||
String file = (String)out;
|
||||
if (file.length() == 0) {
|
||||
os = System.err;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
boolean appendMode = (file.charAt(0) == '+');
|
||||
if (appendMode) {
|
||||
file = file.substring(1);
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(file, appendMode);
|
||||
os = new BufferedOutputStream(fos);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new LDAPException(
|
||||
"Can not open output trace file " + file + " " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (out instanceof OutputStream) {
|
||||
os = (OutputStream) out;
|
||||
}
|
||||
else {
|
||||
throw new LDAPException(TRACE_PROPERTY + " must be OutputStream or String" );
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the LDAP protocol version that your client prefers to use when
|
||||
* connecting to the LDAP server.
|
||||
@ -927,33 +973,21 @@ public class LDAPConnection
|
||||
/**
|
||||
* Returns the trace output stream if set by the user
|
||||
*/
|
||||
OutputStream getTraceOutputStream() {
|
||||
OutputStream getTraceOutputStream() throws LDAPException {
|
||||
|
||||
// Check first if trace output has been set using setProperty()
|
||||
OutputStream os = (OutputStream)m_properties.get(TRACE_PROPERTY);
|
||||
if (os != null) {
|
||||
return os;
|
||||
Object traceOut = m_properties.get(TRACE_PROPERTY);
|
||||
if (traceOut != null) {
|
||||
return createTraceOutputStream(traceOut);
|
||||
}
|
||||
|
||||
// Check if the property has been set with java -Dcom.netscape.ldap.trace
|
||||
// If the property does not have a value, send the trace to the System.err,
|
||||
// otherwise use the value as the output file name
|
||||
try {
|
||||
String traceProp = System.getProperty(TRACE_PROPERTY);
|
||||
if (traceProp != null) {
|
||||
if (traceProp.length() == 0) {
|
||||
return System.err;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(traceProp);
|
||||
return new BufferedOutputStream(fos);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Can not open output trace file: " + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
traceOut = System.getProperty(TRACE_PROPERTY);
|
||||
if (traceOut != null) {
|
||||
return createTraceOutputStream(traceOut);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -1073,10 +1107,10 @@ public class LDAPConnection
|
||||
return;
|
||||
}
|
||||
|
||||
searchResults.abandon();
|
||||
|
||||
int id = searchResults.getID();
|
||||
abandon(id);
|
||||
int id = searchResults.getMessageID();
|
||||
if ( id != -1 ) {
|
||||
abandon( id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1340,6 +1374,7 @@ public class LDAPConnection
|
||||
m_saslBinder = new LDAPSaslBind( dn, mechanisms, packageName,
|
||||
props, cbh );
|
||||
m_saslBinder.bind( this );
|
||||
m_authMethod = "sasl";
|
||||
m_boundDN = dn;
|
||||
}
|
||||
|
||||
@ -1594,6 +1629,7 @@ public class LDAPConnection
|
||||
|
||||
if (!isConnected()) {
|
||||
m_bound = false;
|
||||
m_authMethod = "none";
|
||||
connect ();
|
||||
// special case: the connection currently is not bound, and now there is
|
||||
// a bind request. The connection needs to reconnect if the thread has
|
||||
@ -1649,17 +1685,18 @@ public class LDAPConnection
|
||||
m_referralConnection.disconnect();
|
||||
m_referralConnection = null;
|
||||
}
|
||||
m_bound = false;
|
||||
sendRequest(new JDAPBindRequest(m_protocolVersion, m_boundDN,
|
||||
m_boundPasswd),
|
||||
myListener, cons);
|
||||
checkMsg( myListener.getResponse() );
|
||||
markConnAsBound();
|
||||
m_authMethod = "simple";
|
||||
} catch (LDAPReferralException e) {
|
||||
m_referralConnection = createReferralConnection(e, cons);
|
||||
} finally {
|
||||
releaseResponseListener(myListener);
|
||||
}
|
||||
|
||||
markConnAsBound();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1722,11 +1759,22 @@ public class LDAPConnection
|
||||
connect();
|
||||
}
|
||||
m_saslBinder.bind(this, false);
|
||||
m_authMethod = "sasl";
|
||||
} else {
|
||||
internalBind (m_protocolVersion, false, cons);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the authentication method used to bind:<BR>
|
||||
* "none", "simple", or "sasl"
|
||||
*
|
||||
* @return the authentication method, or "none"
|
||||
*/
|
||||
public String getAuthenticationMethod() {
|
||||
return isConnected() ? m_authMethod : "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the server and then reconnect using the current
|
||||
* credentials and authentication method
|
||||
@ -1740,6 +1788,7 @@ public class LDAPConnection
|
||||
|
||||
if (m_saslBinder != null) {
|
||||
m_saslBinder.bind(this, true);
|
||||
m_authMethod = "sasl";
|
||||
} else {
|
||||
internalBind (m_protocolVersion, true, m_defaultConstraints);
|
||||
}
|
||||
@ -2333,7 +2382,6 @@ public class LDAPConnection
|
||||
public LDAPSearchResults search( String base, int scope, String filter,
|
||||
String[] attrs, boolean attrsOnly, LDAPSearchConstraints cons )
|
||||
throws LDAPException {
|
||||
|
||||
if (cons == null) {
|
||||
cons = m_defaultConstraints;
|
||||
}
|
||||
@ -2392,9 +2440,27 @@ public class LDAPConnection
|
||||
throw e;
|
||||
}
|
||||
|
||||
/* Is this a persistent search? */
|
||||
boolean isPersistentSearch = false;
|
||||
LDAPControl[] controls =
|
||||
(LDAPControl[])getOption(LDAPv3.SERVERCONTROLS, cons);
|
||||
for (int i = 0; (controls != null) && (i < controls.length); i++) {
|
||||
if ( controls[i] instanceof
|
||||
netscape.ldap.controls.LDAPPersistSearchControl ) {
|
||||
isPersistentSearch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Synchronous search if all requested at once */
|
||||
if ( cons.getBatchSize() == 0 ) {
|
||||
/* For a persistent search, don't wait for a first result, because
|
||||
there may be none at this time if changesOnly was specified in
|
||||
the control.
|
||||
*/
|
||||
if ( isPersistentSearch ) {
|
||||
returnValue.associatePersistentSearch (myListener);
|
||||
|
||||
} else if ( cons.getBatchSize() == 0 ) {
|
||||
/* Synchronous search if all requested at once */
|
||||
try {
|
||||
/* Block until all results are in */
|
||||
LDAPMessage response = myListener.completeSearchOperation();
|
||||
@ -2432,10 +2498,10 @@ public class LDAPConnection
|
||||
* the search didn't fail
|
||||
*/
|
||||
LDAPMessage firstResult = myListener.nextMessage ();
|
||||
if (firstResult instanceof LDAPResponse) {
|
||||
if ( firstResult instanceof LDAPResponse ) {
|
||||
try {
|
||||
checkSearchMsg(returnValue, firstResult, cons, base, scope,
|
||||
filter, attrs, attrsOnly);
|
||||
filter, attrs, attrsOnly);
|
||||
} finally {
|
||||
releaseSearchListener (myListener);
|
||||
}
|
||||
@ -2457,15 +2523,6 @@ public class LDAPConnection
|
||||
}
|
||||
}
|
||||
|
||||
LDAPControl[] controls = (LDAPControl[])getOption(LDAPv3.SERVERCONTROLS, cons);
|
||||
|
||||
for (int i=0; (controls != null) && (i<controls.length); i++) {
|
||||
if ((controls[i].getClass().getName()).equals(PersistSearchPackageName))
|
||||
{
|
||||
returnValue.associatePersistentSearch (myListener);
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
/* we let this listener get garbage collected.. */
|
||||
returnValue.associate (myListener);
|
||||
}
|
||||
@ -2477,7 +2534,7 @@ public class LDAPConnection
|
||||
LDAPSearchConstraints cons, String dn, int scope, String filter,
|
||||
String attrs[], boolean attrsOnly) throws LDAPException {
|
||||
|
||||
value.setMsgID(msg.getID());
|
||||
value.setMsgID(msg.getMessageID());
|
||||
|
||||
try {
|
||||
checkMsg (msg);
|
||||
@ -2756,8 +2813,9 @@ public class LDAPConnection
|
||||
String resultID;
|
||||
|
||||
try {
|
||||
sendRequest ( new JDAPExtendedRequest( op.getID(), op.getValue() ),
|
||||
myListener, cons );
|
||||
sendRequest ( new JDAPExtendedRequest( op.getID(),
|
||||
op.getValue() ),
|
||||
myListener, cons );
|
||||
response = myListener.getResponse();
|
||||
checkMsg (response);
|
||||
JDAPExtendedResponse res = (JDAPExtendedResponse)response.getProtocolOp();
|
||||
@ -3890,7 +3948,7 @@ public class LDAPConnection
|
||||
* @exception LDAPException Failed to send request.
|
||||
*/
|
||||
public void abandon(LDAPSearchListener searchlistener)throws LDAPException {
|
||||
int[] ids = searchlistener.getIDs();
|
||||
int[] ids = searchlistener.getMessageIDs();
|
||||
for (int i=0; i < ids.length; i++) {
|
||||
searchlistener.removeRequest(ids[i]);
|
||||
abandon(ids[i]);
|
||||
@ -4853,11 +4911,7 @@ public class LDAPConnection
|
||||
|
||||
LDAPConnection connection = null;
|
||||
connection = prepareReferral(u[0], cons);
|
||||
String DN = u[0].getDN();
|
||||
if ((DN == null) || (DN.equals(""))) {
|
||||
DN = m_boundDN;
|
||||
}
|
||||
connection.authenticate(m_protocolVersion, DN, m_boundPasswd);
|
||||
connection.authenticate(m_protocolVersion, m_boundDN, m_boundPasswd);
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
@ -61,7 +61,13 @@ public class LDAPDN {
|
||||
*/
|
||||
public static String[] explodeRDN (String rdn, boolean noTypes) {
|
||||
RDN name = new RDN(rdn);
|
||||
return name.explodeRDN(noTypes);
|
||||
if ( noTypes ) {
|
||||
return name.getValues();
|
||||
} else {
|
||||
String[] str = new String[1];
|
||||
str[0] = name.toString();
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,23 +83,32 @@ public class LDAPDN {
|
||||
public static String escapeRDN(String rdn) {
|
||||
|
||||
RDN name = new RDN(rdn);
|
||||
String val = name.getValue();
|
||||
String[] val = name.getValues();
|
||||
if (val == null)
|
||||
return rdn;
|
||||
|
||||
StringBuffer buffer = new StringBuffer(val);
|
||||
StringBuffer[] buffer = new StringBuffer[val.length];
|
||||
StringBuffer retbuf = new StringBuffer();
|
||||
String[] types = name.getTypes();
|
||||
|
||||
int i=0;
|
||||
while (i<buffer.length()) {
|
||||
if (isEscape(buffer.charAt(i))) {
|
||||
buffer.insert(i, '\\');
|
||||
for (int j = 0; j < val.length; j++ ) {
|
||||
buffer[j] = new StringBuffer(val[j]);
|
||||
|
||||
int i=0;
|
||||
while (i<buffer[j].length()) {
|
||||
if (isEscape(buffer[j].charAt(i))) {
|
||||
buffer[j].insert(i, '\\');
|
||||
i++;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
i++;
|
||||
retbuf.append( ((retbuf.length() > 0) ? " + " : "") + types[j] + "=" +
|
||||
( new String( buffer[j] ) ) );
|
||||
}
|
||||
|
||||
return name.getType()+"="+(new String(buffer));
|
||||
return new String( retbuf );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,11 +124,11 @@ public class LDAPDN {
|
||||
*/
|
||||
public static String unEscapeRDN(String rdn) {
|
||||
RDN name = new RDN(rdn);
|
||||
String val = name.getValue();
|
||||
if (val == null)
|
||||
String[] vals = name.getValues();
|
||||
if ( (vals == null) || (vals.length < 1) )
|
||||
return rdn;
|
||||
|
||||
StringBuffer buffer = new StringBuffer(val);
|
||||
StringBuffer buffer = new StringBuffer(vals[0]);
|
||||
StringBuffer copy = new StringBuffer();
|
||||
int i=0;
|
||||
while (i<buffer.length()) {
|
||||
@ -124,7 +139,26 @@ public class LDAPDN {
|
||||
i++;
|
||||
}
|
||||
|
||||
return name.getType()+"="+(new String(copy));
|
||||
return name.getTypes()[0]+"="+(new String(copy));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the dn.
|
||||
* @param dn the DN to normalize
|
||||
* @return the normalized DN
|
||||
*/
|
||||
public static String normalize(String dn) {
|
||||
return (new DN(dn)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two dn's for equality.
|
||||
* @param dn1 the first dn to compare
|
||||
* @param dn2 the second dn to compare
|
||||
* @return true if the two dn's are equal
|
||||
*/
|
||||
public static boolean equals(String dn1, String dn2) {
|
||||
return normalize(dn1).equals(normalize(dn2));
|
||||
}
|
||||
|
||||
private static boolean isEscape(char c) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -46,11 +46,21 @@ public class LDAPExtendedResponse extends LDAPResponse {
|
||||
*
|
||||
* @return the response OID.
|
||||
*/
|
||||
public String getOID() {
|
||||
public String getID() {
|
||||
JDAPExtendedResponse result = (JDAPExtendedResponse)getProtocolOp();
|
||||
return result.getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the OID of the response.
|
||||
*
|
||||
* @return the response OID.
|
||||
* @deprecated Use <CODE>LDAPExtendedResponse.getID()</CODE>
|
||||
*/
|
||||
public String getOID() {
|
||||
return getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw bytes of the value part of the response.
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -99,7 +99,7 @@ import java.util.*;
|
||||
* @see netscape.ldap.LDAPSchemaElement
|
||||
**/
|
||||
|
||||
public class LDAPMatchingRuleSchema extends LDAPSchemaElement {
|
||||
public class LDAPMatchingRuleSchema extends LDAPAttributeSchema {
|
||||
/**
|
||||
* Constructs a matching rule definition, using the specified
|
||||
* information.
|
||||
@ -171,7 +171,12 @@ public class LDAPMatchingRuleSchema extends LDAPSchemaElement {
|
||||
String[] attributes,
|
||||
String syntaxString,
|
||||
String[] aliases ) {
|
||||
super( name, oid, description );
|
||||
if ( (oid == null) || (oid.trim().length() < 1) ) {
|
||||
throw new IllegalArgumentException( "OID required" );
|
||||
}
|
||||
this.name = name;
|
||||
this.oid = oid;
|
||||
this.description = description;
|
||||
attrName = "matchingrules";
|
||||
syntaxElement.syntax = syntaxElement.syntaxCheck( syntaxString );
|
||||
syntaxElement.syntaxString = syntaxString;
|
||||
@ -235,33 +240,6 @@ public class LDAPMatchingRuleSchema extends LDAPSchemaElement {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the syntax of the schema element
|
||||
* @return One of the following values:
|
||||
* <UL>
|
||||
* <LI><CODE>cis</CODE> (case-insensitive string)
|
||||
* <LI><CODE>ces</CODE> (case-exact string)
|
||||
* <LI><CODE>binary</CODE> (binary data)
|
||||
* <LI><CODE>int</CODE> (integer)
|
||||
* <LI><CODE>telephone</CODE> (telephone number -- identical to cis,
|
||||
* but blanks and dashes are ignored during comparisons)
|
||||
* <LI><CODE>dn</CODE> (distinguished name)
|
||||
* <LI><CODE>unknown</CODE> (not a known syntax)
|
||||
* </UL>
|
||||
*/
|
||||
public int getSyntax() {
|
||||
return syntaxElement.syntax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the syntax of the attribute type in dotted-decimal format,
|
||||
* for example "1.2.3.4.5"
|
||||
* @return The attribute syntax in dotted-decimal format.
|
||||
*/
|
||||
public String getSyntaxString() {
|
||||
return syntaxElement.syntaxString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a value in RFC 2252 format for submitting to a server
|
||||
*
|
||||
@ -396,6 +374,4 @@ public class LDAPMatchingRuleSchema extends LDAPSchemaElement {
|
||||
SYNTAX };
|
||||
|
||||
private String[] attributes = null;
|
||||
private LDAPSyntaxSchemaElement syntaxElement =
|
||||
new LDAPSyntaxSchemaElement();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
@ -193,7 +193,7 @@ public class LDAPMessage {
|
||||
* Returns the message identifer.
|
||||
* @return message identifer.
|
||||
*/
|
||||
public int getID(){
|
||||
public int getMessageID(){
|
||||
return m_msgid;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class LDAPMessageQueue {
|
||||
|
||||
// Is the ldap operation completed?
|
||||
if (msg instanceof LDAPResponse) {
|
||||
removeRequest(msg.getID());
|
||||
removeRequest(msg.getMessageID());
|
||||
}
|
||||
|
||||
return msg;
|
||||
@ -220,14 +220,16 @@ class LDAPMessageQueue {
|
||||
* requests are sent by one thread but processed by another one
|
||||
*
|
||||
* A client may be implemented in such a way that one thread makes LDAP
|
||||
* requests and calls l.getIDs(), while another thread is responsible for
|
||||
* requests and calls l.getMessageIDs(), while another thread is
|
||||
* responsible for
|
||||
* processing of responses (call l.getResponse()). Both threads are using
|
||||
* the same listener objects. In such a case, a race
|
||||
* condition may occur, where a LDAP response message is retrieved and
|
||||
* the request terminated (request ID removed) before the first thread
|
||||
* has a chance to execute l.getIDs().
|
||||
* has a chance to execute l.getMessageIDs().
|
||||
* The proper way to handle this scenario is to create a separate listener
|
||||
* for each new request, and after l.getIDs() has been invoked, merge the
|
||||
* for each new request, and after l.getMessageIDs() has been invoked,
|
||||
* merge the
|
||||
* new request with the existing one.
|
||||
* @param mq2 message queue to merge with this one
|
||||
*/
|
||||
@ -271,7 +273,7 @@ class LDAPMessageQueue {
|
||||
// Mark conn as bound for asych bind operations
|
||||
if (isAsynchOp() && msg.getType() == msg.BIND_RESPONSE) {
|
||||
if (((LDAPResponse) msg).getResultCode() == 0) {
|
||||
getConnection(msg.getID()).markConnAsBound();
|
||||
getConnection(msg.getMessageID()).markConnAsBound();
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +322,7 @@ class LDAPMessageQueue {
|
||||
int removeCount=0;
|
||||
for (int i=(m_messageQueue.size()-1); i>=0; i--) {
|
||||
LDAPMessage msg = (LDAPMessage)m_messageQueue.elementAt(i);
|
||||
if (msg.getID() == id) {
|
||||
if (msg.getMessageID() == id) {
|
||||
m_messageQueue.removeElementAt(i);
|
||||
removeCount++;
|
||||
}
|
||||
@ -377,7 +379,7 @@ class LDAPMessageQueue {
|
||||
* Returns message ID of the last request
|
||||
* @return message ID.
|
||||
*/
|
||||
synchronized int getID() {
|
||||
synchronized int getMessageID() {
|
||||
int reqCnt = m_requestList.size();
|
||||
if ( reqCnt == 0) {
|
||||
return -1;
|
||||
@ -392,7 +394,7 @@ class LDAPMessageQueue {
|
||||
* Returns a list of message IDs for all outstanding requests
|
||||
* @return message ID array.
|
||||
*/
|
||||
synchronized int[] getIDs() {
|
||||
synchronized int[] getMessageIDs() {
|
||||
int[] ids = new int[m_requestList.size()];
|
||||
for (int i=0; i < ids.length; i++) {
|
||||
RequestEntry entry = (RequestEntry)m_requestList.elementAt(i);
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -54,25 +54,26 @@ public class LDAPResponseListener extends LDAPMessageQueue{
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge two response listeners
|
||||
* Merge two response listeners.
|
||||
* Move/append the content from another response listener to this one.
|
||||
*
|
||||
* <P>
|
||||
* To be used for synchronization of asynchronous LDAP operations where
|
||||
* requests are sent by one thread but processed by another one
|
||||
*
|
||||
* requests are sent by one thread but processed by another one.
|
||||
* <P>
|
||||
* A client may be implemented in such a way that one thread makes LDAP
|
||||
* requests and calls l.getIDs(), while another thread is responsible for
|
||||
* processing of responses (call l.getResponse()). Both threads are using
|
||||
* requests and calls l.getMessageIDs(), while another thread
|
||||
* is responsible for processing of responses (call l.getResponse()).
|
||||
* Both threads are using
|
||||
* the same listener objects. In such a case, a race
|
||||
* condition may occur, where a LDAP response message is retrieved and
|
||||
* the request terminated (request ID removed) before the first thread
|
||||
* has a chance to execute l.getIDs().
|
||||
* has a chance to execute l.getMessageIDs().
|
||||
* The proper way to handle this scenario is to create a separate listener
|
||||
* for each new request, and after l.getIDs() has been invoked, merge the
|
||||
* for each new request, and after l.getMessageIDs() has been invoked, merge the
|
||||
* new request with the existing one.
|
||||
* @param listener2 the listener with which to merge
|
||||
*/
|
||||
public void merge(LDAPSearchListener listener2) {
|
||||
public void merge(LDAPResponseListener listener2) {
|
||||
super.merge(listener2);
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ public class LDAPResponseListener extends LDAPMessageQueue{
|
||||
* Returns message IDs for all outstanding requests
|
||||
* @return message ID array.
|
||||
*/
|
||||
public int[] getIDs() {
|
||||
return super.getIDs();
|
||||
public int[] getMessageIDs() {
|
||||
return super.getMessageIDs();
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -183,6 +183,10 @@ public class LDAPSchema {
|
||||
public LDAPSchema() {
|
||||
}
|
||||
|
||||
public LDAPSchema( LDAPEntry entry ) {
|
||||
initialize( entry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an object class schema definition to the current schema.
|
||||
* You can also add object class schema definitions by calling the
|
||||
@ -363,8 +367,18 @@ public class LDAPSchema {
|
||||
|
||||
/* Get the entire schema definition entry */
|
||||
LDAPEntry entry = readSchema( ld, entryName );
|
||||
initialize( entry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract all schema elements from subschema entry
|
||||
*
|
||||
* @param entry entry containing schema definitions
|
||||
*/
|
||||
protected void initialize( LDAPEntry entry ) {
|
||||
/* Get all object class definitions */
|
||||
LDAPAttribute attr = entry.getAttribute( "objectclasses" );
|
||||
Enumeration en;
|
||||
if ( attr != null ) {
|
||||
en = attr.getStringValues();
|
||||
while( en.hasMoreElements() ) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -115,10 +115,21 @@ public abstract class LDAPSchemaElement {
|
||||
* @return the OID of the object class, attribute type,
|
||||
* or matching rule.
|
||||
*/
|
||||
public String getOID() {
|
||||
public String getID() {
|
||||
return oid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object ID (OID) of the object class, attribute type,
|
||||
* or matching rule in dotted-string format (for example, "1.2.3.4").
|
||||
* @return the OID of the object class, attribute type,
|
||||
* or matching rule.
|
||||
* @deprecated Use <CODE>LDAPSchemaElement.getID()</CODE>
|
||||
*/
|
||||
public String getOID() {
|
||||
return getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description of the object class, attribute type,
|
||||
* or matching rule.
|
||||
|
@ -84,7 +84,7 @@ public class LDAPSearchListener extends LDAPMessageQueue {
|
||||
|
||||
// Notify LDAPConnThread to wake up if backlog limit has been reached
|
||||
if (result instanceof LDAPSearchResult || result instanceof LDAPSearchResultReference) {
|
||||
LDAPConnection ld = getConnection(result.getID());
|
||||
LDAPConnection ld = getConnection(result.getMessageID());
|
||||
if (ld != null) {
|
||||
ld.resultRetrieved();
|
||||
}
|
||||
@ -94,22 +94,23 @@ public class LDAPSearchListener extends LDAPMessageQueue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge two search listeners
|
||||
* Move/append the content from another search listener to this one.
|
||||
*
|
||||
* Merge two response listeners.
|
||||
* Move/append the content from another response listener to this one.
|
||||
* <P>
|
||||
* To be used for synchronization of asynchronous LDAP operations where
|
||||
* requests are sent by one thread but processed by another one
|
||||
*
|
||||
* requests are sent by one thread but processed by another one.
|
||||
* <P>
|
||||
* A client may be implemented in such a way that one thread makes LDAP
|
||||
* requests and calls l.getIDs(), while another thread is responsible for
|
||||
* requests and calls l.getMessageIDs(), while another thread
|
||||
* is responsible for
|
||||
* processing of responses (call l.getResponse()). Both threads are using
|
||||
* the same listener objects. In such a case, a race
|
||||
* condition may occur, where a LDAP response message is retrieved and
|
||||
* the request terminated (request ID removed) before the first thread
|
||||
* has a chance to execute l.getIDs().
|
||||
* has a chance to execute l.getMessageIDs().
|
||||
* The proper way to handle this scenario is to create a separate listener
|
||||
* for each new request, and after l.getIDs() has been invoked, merge the
|
||||
* new request with the existing one.
|
||||
* for each new request, and after l.getMessageIDs() has been invoked,
|
||||
* merge the new request with the existing one.
|
||||
* @param listener2 the listener with which to merge
|
||||
*/
|
||||
public void merge(LDAPSearchListener listener2) {
|
||||
@ -129,8 +130,8 @@ public class LDAPSearchListener extends LDAPMessageQueue {
|
||||
* Returns message IDs for all outstanding requests
|
||||
* @return message ID array.
|
||||
*/
|
||||
public int[] getIDs() {
|
||||
return super.getIDs();
|
||||
public int[] getMessageIDs() {
|
||||
return super.getMessageIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -479,19 +479,10 @@ public class LDAPSearchResults implements Enumeration {
|
||||
* Returns message ID.
|
||||
* @return Message ID.
|
||||
*/
|
||||
int getID() {
|
||||
int getMessageID() {
|
||||
if ( resultSource == null )
|
||||
return -1;
|
||||
return resultSource.getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates the iteration; called on LDAPConnection.abandon().
|
||||
*/
|
||||
void abandon() {
|
||||
synchronized( this ) {
|
||||
searchComplete = true;
|
||||
}
|
||||
return resultSource.getMessageID();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,14 +509,21 @@ public class LDAPSearchResults implements Enumeration {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg instanceof LDAPResponse) {
|
||||
try {
|
||||
// check response and see if we need to do referral
|
||||
// v2: referral stored in the JDAPResult
|
||||
currConn.checkSearchMsg(this, msg, currCons,
|
||||
currBase, currScope, currFilter, currAttrs, currAttrsOnly);
|
||||
|
||||
if (msg == null) { // Request abandoned
|
||||
searchComplete = true;
|
||||
currConn.releaseSearchListener(resultSource);
|
||||
return;
|
||||
|
||||
} else if (msg instanceof LDAPResponse) {
|
||||
try {
|
||||
// check response and see if we need to do referral
|
||||
// v2: referral stored in the JDAPResult
|
||||
currConn.checkSearchMsg(this, msg, currCons,
|
||||
currBase, currScope, currFilter,
|
||||
currAttrs, currAttrsOnly);
|
||||
} catch (LDAPException e) {
|
||||
System.err.println("Exception: "+e);
|
||||
System.err.println("LDAPSearchResults.fetchResult: "+e);
|
||||
} finally {
|
||||
currConn.releaseSearchListener(resultSource);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -611,13 +611,4 @@ public class LDAPSortControl extends LDAPControl {
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// register SORTRESPONSE with LDAPControl
|
||||
static {
|
||||
try {
|
||||
LDAPControl.register( SORTRESPONSE, LDAPSortControl.class );
|
||||
} catch (LDAPException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset:4 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
263
directory/java-sdk/ldapjdk/netscape/ldap/util/DSMLWriter.java
Normal file
263
directory/java-sdk/ldapjdk/netscape/ldap/util/DSMLWriter.java
Normal file
@ -0,0 +1,263 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package netscape.ldap.util;
|
||||
|
||||
import java.util.*;
|
||||
import netscape.ldap.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Class for outputting LDAP entries to a stream as DSML.
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DSMLWriter extends LDAPWriter {
|
||||
|
||||
// static final long serialVersionUID = -2710382547996750924L;
|
||||
|
||||
/**
|
||||
* Constructs a <CODE>DSMLWriter</CODE> object to output entries
|
||||
* to a stream as DSML.
|
||||
*
|
||||
* @param pw output stream
|
||||
*/
|
||||
public DSMLWriter( PrintWriter pw ) {
|
||||
super( pw );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the schema from an entry containing subschema
|
||||
*
|
||||
* entry entry containing schema definitions
|
||||
*/
|
||||
public void printSchema( LDAPEntry entry ) {
|
||||
LDAPSchema schema = new LDAPSchema( entry );
|
||||
printString( " <dsml:directory-schema>" );
|
||||
printObjectClassSchema( schema );
|
||||
printAttributeSchema( schema );
|
||||
printString( " </dsml:directory-schema>" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the object class schema from a schema object
|
||||
*
|
||||
* schema schema elements
|
||||
*/
|
||||
protected void printObjectClassSchema( LDAPSchema schema ) {
|
||||
Enumeration en = schema.getObjectClasses();
|
||||
while( en.hasMoreElements() ) {
|
||||
LDAPObjectClassSchema s = (LDAPObjectClassSchema)en.nextElement();
|
||||
printString( " <dsml:class" );
|
||||
printString( " id=\"" + s.getName() + "\"" );
|
||||
printString( " oid=\"" + s.getID() + "\"" );
|
||||
String[] superiors = s.getSuperiors();
|
||||
if ( superiors != null ) {
|
||||
for( int i = 0; i < superiors.length; i++ ) {
|
||||
printString( " superior=\"#" + superiors[i] + "\"" );
|
||||
}
|
||||
}
|
||||
String classType = "structural";
|
||||
switch( s.getType() ) {
|
||||
case s.ABSTRACT: classType = "abstract";
|
||||
break;
|
||||
case s.AUXILIARY: classType = "auxiliary";
|
||||
break;
|
||||
}
|
||||
printString( " type=\"" + classType + "\">" );
|
||||
if ( s.isObsolete() ) {
|
||||
printString( " obsolete=true" );
|
||||
}
|
||||
printString( " <dsml:name>" + s.getName() + "</dsml:name>" );
|
||||
printString( " <dsml:description>" + s.getDescription() +
|
||||
"</dsml:description>" );
|
||||
Enumeration attrs = s.getRequiredAttributes();
|
||||
while( attrs.hasMoreElements() ) {
|
||||
printString( " <dsml:attribute ref=\"#" +
|
||||
(String)attrs.nextElement() +
|
||||
" required=\"true\"/>" );
|
||||
}
|
||||
attrs = s.getOptionalAttributes();
|
||||
while( attrs.hasMoreElements() ) {
|
||||
printString( " <dsml:attribute ref=\"#" +
|
||||
(String)attrs.nextElement() +
|
||||
" required=\"false\"/>" );
|
||||
}
|
||||
printString( " </dsml:class>" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the attribute schema from a schema object
|
||||
*
|
||||
* schema schema elements
|
||||
*/
|
||||
protected void printAttributeSchema( LDAPSchema schema ) {
|
||||
Enumeration en = schema.getAttributes();
|
||||
while( en.hasMoreElements() ) {
|
||||
LDAPAttributeSchema s = (LDAPAttributeSchema)en.nextElement();
|
||||
printString( " <dsml:attribute-type" );
|
||||
printString( " id=\"" + s.getName() + "\"" );
|
||||
printString( " oid=\"" + s.getID() + "\"" );
|
||||
String superior = s.getSuperior();
|
||||
if ( superior != null ) {
|
||||
printString( " superior=\"#" + superior + "\"" );
|
||||
}
|
||||
if ( s.isSingleValued() ) {
|
||||
printString( " single-value=true" );
|
||||
}
|
||||
if ( s.isObsolete() ) {
|
||||
printString( " obsolete=true" );
|
||||
}
|
||||
if ( s.getQualifier( s.NO_USER_MODIFICATION ) != null ) {
|
||||
printString( " user-modification=false" );
|
||||
}
|
||||
String[] vals = s.getQualifier( s.EQUALITY );
|
||||
if ( (vals != null) && (vals.length > 0) ) {
|
||||
printString( " equality=" + vals[0] );
|
||||
}
|
||||
vals = s.getQualifier( s.ORDERING );
|
||||
if ( (vals != null) && (vals.length > 0) ) {
|
||||
printString( " ordering=" + vals[0] );
|
||||
}
|
||||
vals = s.getQualifier( s.SUBSTR );
|
||||
if ( (vals != null) && (vals.length > 0) ) {
|
||||
printString( " substring=" + vals[0] );
|
||||
}
|
||||
printString( " <dsml:name>" + s.getName() + "</dsml:name>" );
|
||||
printString( " <dsml:description>" + s.getDescription() +
|
||||
"</dsml:description>" );
|
||||
printString( " <dsml:syntax>" + s.getSyntaxString() +
|
||||
"</dsml:syntax>" );
|
||||
printString( " </dsml:attribute-type>" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print an attribute of an entry
|
||||
*
|
||||
* @param attr the attribute to format to the output stream
|
||||
*/
|
||||
protected void printAttribute( LDAPAttribute attr ) {
|
||||
String attrName = attr.getName();
|
||||
|
||||
// Object classes are treated differently in DSML. Also, they
|
||||
// are always String-valued
|
||||
if ( attrName.equalsIgnoreCase( "objectclass" ) ) {
|
||||
Enumeration enumVals = attr.getStringValues();
|
||||
if ( enumVals != null ) {
|
||||
while ( enumVals.hasMoreElements() ) {
|
||||
String s = (String)enumVals.nextElement();
|
||||
printString( " <dsml:objectclass>" + s +
|
||||
"</dsml:objectclass>" );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
printString( " <dsml:attr name=\"" + attrName + "\">" );
|
||||
|
||||
/* Loop on values for this attribute */
|
||||
Enumeration enumVals = attr.getByteValues();
|
||||
|
||||
if ( enumVals != null ) {
|
||||
while ( enumVals.hasMoreElements() ) {
|
||||
byte[] b = (byte[])enumVals.nextElement();
|
||||
String s;
|
||||
if ( LDIF.isPrintable(b) ) {
|
||||
try {
|
||||
s = new String( b, "UTF8" );
|
||||
} catch ( UnsupportedEncodingException e ) {
|
||||
s = "";
|
||||
}
|
||||
printEscapedValue( " <dsml:value>", s,
|
||||
"</dsml:value>" );
|
||||
} else {
|
||||
s = getPrintableValue( b );
|
||||
if ( s.length() > 0 ) {
|
||||
printString( " " +
|
||||
"<dsml:value encoding=\"base64\">" );
|
||||
printString( " " + s );
|
||||
printString( " </dsml:value>" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printString( " </dsml:attr>" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print prologue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected void printEntryStart( String dn ) {
|
||||
printString( " <dsml:entry dn=\"" + dn + "\">" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print epilogue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected void printEntryEnd( String dn ) {
|
||||
printString( " </dsml:entry>" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the element start, the value with escaping of special
|
||||
* characters, and the element end
|
||||
*
|
||||
* @param prolog element start
|
||||
* @param value value to be escaped
|
||||
* @param epilog element end
|
||||
*/
|
||||
protected void printEscapedValue( String prolog, String value,
|
||||
String epilog ) {
|
||||
m_pw.print( prolog );
|
||||
int l = value.length();
|
||||
char[] text = new char[l];
|
||||
value.getChars( 0, l, text, 0 );
|
||||
for ( int i = 0; i < l; i++ ) {
|
||||
char c = text[i];
|
||||
switch (c) {
|
||||
case '<' :
|
||||
m_pw.print( "<" );
|
||||
break;
|
||||
case '&' :
|
||||
m_pw.print( "&" );
|
||||
break;
|
||||
default :
|
||||
m_pw.print( c );
|
||||
}
|
||||
}
|
||||
m_pw.print( epilog);
|
||||
m_pw.print( '\n' );
|
||||
}
|
||||
|
||||
protected void printString( String value ) {
|
||||
m_pw.print( value );
|
||||
m_pw.print( '\n' );
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
114
directory/java-sdk/ldapjdk/netscape/ldap/util/LDAPWriter.java
Normal file
114
directory/java-sdk/ldapjdk/netscape/ldap/util/LDAPWriter.java
Normal file
@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package netscape.ldap.util;
|
||||
|
||||
import java.util.*;
|
||||
import netscape.ldap.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Abstract class for outputting LDAP entries to a stream.
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class LDAPWriter implements Serializable {
|
||||
|
||||
// static final long serialVersionUID = -2710382547996750924L;
|
||||
protected PrintWriter m_pw;
|
||||
private static MimeBase64Encoder m_encoder = new MimeBase64Encoder();
|
||||
|
||||
/**
|
||||
* Constructs an <CODE>LDAPWriter</CODE> object to output entries
|
||||
* to a stream.
|
||||
*
|
||||
* @param pw output stream
|
||||
*/
|
||||
public LDAPWriter( PrintWriter pw ) {
|
||||
m_pw = pw;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method of LDAPWriter. It calls printEntryIntro,
|
||||
* printAttribute, and printEntryEnd of derived classes.
|
||||
*
|
||||
* @param entry an LDAPEntry to be formatted to the output
|
||||
* stream
|
||||
*/
|
||||
public void printEntry( LDAPEntry entry ) throws IOException {
|
||||
printEntryStart( entry.getDN() );
|
||||
/* Get the attributes of the entry */
|
||||
LDAPAttributeSet attrs = entry.getAttributeSet();
|
||||
Enumeration enumAttrs = attrs.getAttributes();
|
||||
/* Loop on attributes */
|
||||
while ( enumAttrs.hasMoreElements() ) {
|
||||
LDAPAttribute anAttr =
|
||||
(LDAPAttribute)enumAttrs.nextElement();
|
||||
printAttribute( anAttr );
|
||||
}
|
||||
printEntryEnd( entry.getDN() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default schema writer - assumes an ordinary entry
|
||||
*
|
||||
* @param entry an LDAPEntry containing schema to be formatted
|
||||
* to the output stream
|
||||
*/
|
||||
public void printSchema( LDAPEntry entry ) throws IOException {
|
||||
printEntry( entry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an attribute of an entry
|
||||
*
|
||||
* @param attr the attribute to format to the output stream
|
||||
*/
|
||||
protected abstract void printAttribute( LDAPAttribute attr );
|
||||
|
||||
/**
|
||||
* Print prologue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected abstract void printEntryStart( String dn );
|
||||
|
||||
/**
|
||||
* Print epilogue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected abstract void printEntryEnd( String dn );
|
||||
|
||||
protected String getPrintableValue( byte[] b ) {
|
||||
String s = "";
|
||||
ByteBuf inBuf = new ByteBuf( b, 0, b.length );
|
||||
ByteBuf encodedBuf = new ByteBuf();
|
||||
// Translate to base 64
|
||||
m_encoder.translate( inBuf, encodedBuf );
|
||||
int nBytes = encodedBuf.length();
|
||||
if ( nBytes > 0 ) {
|
||||
s = new String(encodedBuf.toBytes(),
|
||||
0, nBytes);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
179
directory/java-sdk/ldapjdk/netscape/ldap/util/LDIFWriter.java
Normal file
179
directory/java-sdk/ldapjdk/netscape/ldap/util/LDIFWriter.java
Normal file
@ -0,0 +1,179 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package netscape.ldap.util;
|
||||
|
||||
import java.util.*;
|
||||
import netscape.ldap.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Class for outputting LDAP entries to a stream as LDIF.
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
public class LDIFWriter extends LDAPWriter {
|
||||
|
||||
// static final long serialVersionUID = -2710382547996750924L;
|
||||
private String m_sep;
|
||||
private boolean m_foldLines;
|
||||
private boolean m_attrsOnly;
|
||||
private boolean m_toFiles;
|
||||
private static final String DEFAULT_SEPARATOR = ":";
|
||||
private static final int MAX_LINE = 77;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an <CODE>LDIFWriter</CODE> object to output entries
|
||||
* to a stream as LDIF.
|
||||
*
|
||||
* @param pw output stream
|
||||
*/
|
||||
public LDIFWriter( PrintWriter pw ) {
|
||||
this( pw, false, DEFAULT_SEPARATOR, true, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an <CODE>LDIFWriter</CODE> object to output entries
|
||||
* to a stream as LDIF.
|
||||
*
|
||||
* @param pw output stream
|
||||
* @param attrsOnly <code>true</code> if only attribute names, not
|
||||
* values, are to be printed
|
||||
* @param separator String to use between attribute names and values;
|
||||
* the default is ":"
|
||||
* @param foldLines <code>true</code> to fold lines at 77 characters,
|
||||
* <code>false</code> to not fold them; the default is <code>true</code>.
|
||||
* @param toFiles <code>true</code> to write each attribute value to a
|
||||
* file in the temp folder, <code>false</code> to write them to the
|
||||
* output stream in printable format; the default is <code>false</code>.
|
||||
*/
|
||||
public LDIFWriter( PrintWriter pw, boolean attrsOnly,
|
||||
String separator, boolean foldLines,
|
||||
boolean toFiles ) {
|
||||
super( pw );
|
||||
m_attrsOnly = attrsOnly;
|
||||
m_sep = separator;
|
||||
m_foldLines = foldLines;
|
||||
m_toFiles = toFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an attribute of an entry
|
||||
*
|
||||
* @param attr the attribute to format to the output stream
|
||||
*/
|
||||
protected void printAttribute( LDAPAttribute attr ) {
|
||||
String attrName = attr.getName();
|
||||
|
||||
if ( m_attrsOnly ) {
|
||||
printString( attrName + m_sep );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Loop on values for this attribute */
|
||||
Enumeration enumVals = attr.getByteValues();
|
||||
|
||||
if ( enumVals != null ) {
|
||||
if ( m_toFiles ) {
|
||||
try {
|
||||
FileOutputStream f = getTempFile( attrName );
|
||||
f.write( (byte[])enumVals.nextElement() );
|
||||
} catch ( Exception e ) {
|
||||
System.err.println( "Error writing values " +
|
||||
"of " + attrName + ", " +
|
||||
e.toString() );
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
byte[] b = (byte[])enumVals.nextElement();
|
||||
String s;
|
||||
if ( LDIF.isPrintable(b) ) {
|
||||
try {
|
||||
s = new String( b, "UTF8" );
|
||||
} catch ( UnsupportedEncodingException e ) {
|
||||
s = "";
|
||||
}
|
||||
printString( attrName + m_sep + " " + s );
|
||||
} else {
|
||||
s = getPrintableValue( b );
|
||||
if ( s.length() > 0 ) {
|
||||
printString( attrName + ":: " + s );
|
||||
} else {
|
||||
printString( attrName + m_sep + ' ' );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printString( attrName + m_sep + ' ' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print prologue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected void printEntryStart( String dn ) {
|
||||
printString( "dn" + m_sep + " " + dn );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print epilogue to entry
|
||||
*
|
||||
* @param dn the DN of the entry
|
||||
*/
|
||||
protected void printEntryEnd( String dn ) {
|
||||
m_pw.println();
|
||||
}
|
||||
|
||||
protected void printString( String value ) {
|
||||
if ( m_foldLines ) {
|
||||
LDIF.breakString( m_pw, value, MAX_LINE );
|
||||
} else {
|
||||
m_pw.print( value );
|
||||
m_pw.print( '\n' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a unique file name in the temp folder and open an
|
||||
* output stream to the file
|
||||
*
|
||||
* @param name base name of file; an extension is appended which
|
||||
* consists of a number that makes the name unique
|
||||
* @return an open output stream to the file
|
||||
* @exception IOException if the file couldn't be opened for output
|
||||
*/
|
||||
protected FileOutputStream getTempFile( String name )
|
||||
throws IOException {
|
||||
int num = 0;
|
||||
File f;
|
||||
String filename;
|
||||
do {
|
||||
filename = name + '.' + num;
|
||||
f = new File( filename );
|
||||
num++;
|
||||
} while ( f.exists() );
|
||||
printString(name + m_sep + " " + filename);
|
||||
return new FileOutputStream( f );
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user