| | |
| | | import java.io.FileReader; |
| | | import java.io.InputStreamReader; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.io.Reader; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.ProtocolOp; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.PasswordReader; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | // The message ID counter to use for requests. |
| | | private AtomicInteger nextMessageID; |
| | | |
| | | // The print stream to use for standard error. |
| | | private PrintStream err; |
| | | |
| | | // The print stream to use for standard output. |
| | | private PrintStream out; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructor for the LDAPCompare object. |
| | | * |
| | | * @param nextMessageID The message ID counter to use for requests. |
| | | * @param out The print stream to use for standard output. |
| | | * @param err The print stream to use for standard error. |
| | | */ |
| | | public LDAPCompare(AtomicInteger nextMessageID) |
| | | public LDAPCompare(AtomicInteger nextMessageID, PrintStream out, |
| | | PrintStream err) |
| | | { |
| | | this.nextMessageID = nextMessageID; |
| | | this.out = out; |
| | | this.err = err; |
| | | } |
| | | |
| | | /** |
| | |
| | | attributeType, attrValOctetStr); |
| | | |
| | | int msgID = MSGID_PROCESSING_COMPARE_OPERATION; |
| | | System.out.println(getMessage(msgID, attributeType, attrValOctetStr, |
| | | dnOctetStr)); |
| | | out.println(getMessage(msgID, attributeType, attrValOctetStr, dnOctetStr)); |
| | | |
| | | if(!compareOptions.showOperations()) |
| | | { |
| | |
| | | { |
| | | msgID = MSGID_OPERATION_FAILED; |
| | | String msg = getMessage(msgID, "COMPARE", line, ae.getMessage()); |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | return; |
| | | } |
| | | } |
| | |
| | | if(resultCode == COMPARE_FALSE) |
| | | { |
| | | msgID = MSGID_COMPARE_OPERATION_RESULT_FALSE; |
| | | System.out.println(getMessage(msgID, line)); |
| | | out.println(getMessage(msgID, line)); |
| | | } else if(resultCode == COMPARE_TRUE) |
| | | { |
| | | msgID = MSGID_COMPARE_OPERATION_RESULT_TRUE; |
| | | System.out.println(getMessage(msgID, line)); |
| | | out.println(getMessage(msgID, line)); |
| | | } else |
| | | { |
| | | msgID = MSGID_OPERATION_FAILED; |
| | | String msg = getMessage(msgID, "COMPARE", line, errorMessage); |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainCompare(args); |
| | | int retCode = mainCompare(args, true, System.out, System.err); |
| | | |
| | | if(retCode != 0) |
| | | { |
| | |
| | | |
| | | public static int mainCompare(String[] args) |
| | | { |
| | | return mainCompare(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Parses the provided command-line arguments and uses that information to |
| | | * run the ldapcompare tool. |
| | | * |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * <CODE>null</CODE> if standard output is not |
| | | * needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * <CODE>null</CODE> if standard error is not |
| | | * needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | |
| | | public static int mainCompare(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | |
| | | LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); |
| | | LDAPCompareOptions compareOptions = new LDAPCompareOptions(); |
| | | LDAPConnection connection = null; |
| | |
| | | showUsage = new BooleanArgument("showUsage", 'H', "help", |
| | | MSGID_DESCRIPTION_SHOWUSAGE); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage, out); |
| | | controlStr = new StringArgument("controls", 'J', "controls", false, |
| | | false, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | |
| | | int msgID = MSGID_ENCPW_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ENCPW_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | System.err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | if(attrAndDNStrings.isEmpty()) |
| | | { |
| | | System.err.println("No Attributes specified for comparison"); |
| | | err.println("No Attributes specified for comparison"); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int idx = attributeString.indexOf(":"); |
| | | if(idx == -1) |
| | | { |
| | | System.err.println("Invalid attribute string:" + attributeString); |
| | | System.err.println("Attribute string must be in one of the " + |
| | | err.println("Invalid attribute string:" + attributeString); |
| | | err.println("Attribute string must be in one of the " + |
| | | "following forms: attribute:value, attribute::base64value, " + |
| | | "attribute:<fileURL" ); |
| | | return 1; |
| | |
| | | } catch (ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | int msgID = MSGID_DESCRIPTION_INVALID_VERSION; |
| | | System.err.println(getMessage(msgID, versionNumber)); |
| | | err.println(getMessage(msgID, versionNumber)); |
| | | return 1; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // read the password from the stdin. |
| | | try |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | bindDNValue)); |
| | | out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, bindDNValue)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | bindPasswordValue = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ex); |
| | | System.err.println(ex.getMessage()); |
| | | err.println(ex.getMessage()); |
| | | return 1; |
| | | } |
| | | } else if(bindPasswordValue == null) |
| | |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); |
| | | if(ctrl == null) |
| | | { |
| | | System.err.println("Invalid control specified:" + ctrlString); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println("Invalid control specified:" + ctrlString); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | compareOptions.getControls().add(ctrl); |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | System.err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | System.err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | return 1; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | System.err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | try |
| | | { |
| | | |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | if (initializeServer) |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | } |
| | | |
| | | // Connect to the specified host with the supplied userDN and password. |
| | | SSLConnectionFactory sslConnectionFactory = null; |
| | |
| | | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions); |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | |
| | | LDAPCompare ldapCompare = new LDAPCompare(nextMessageID); |
| | | LDAPCompare ldapCompare = new LDAPCompare(nextMessageID, out, err); |
| | | if(fileNameValue == null && dnStrings.isEmpty()) |
| | | { |
| | | // Read from stdin. |
| | |
| | | } catch(LDAPException le) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", le); |
| | | System.err.println(le.getMessage()); |
| | | err.println(le.getMessage()); |
| | | int code = le.getResultCode(); |
| | | return code; |
| | | } catch(LDAPConnectionException lce) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", lce); |
| | | System.err.println(lce.getMessage()); |
| | | err.println(lce.getMessage()); |
| | | int code = lce.getErrorCode(); |
| | | return code; |
| | | } catch(Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", e); |
| | | System.err.println(e.getMessage()); |
| | | err.println(e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.net.ConnectException; |
| | | import java.net.Socket; |
| | | import java.net.UnknownHostException; |
| | |
| | | private ASN1Reader asn1Reader; |
| | | private int versionNumber = 3; |
| | | |
| | | private PrintStream out; |
| | | private PrintStream err; |
| | | |
| | | /** |
| | | * Constructor for the LDAPConnection object. |
| | | * |
| | |
| | | */ |
| | | public LDAPConnection(String host, int port, LDAPConnectionOptions options) |
| | | { |
| | | this(host, port, options, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Constructor for the LDAPConnection object. |
| | | * |
| | | * @param host The hostname to send the request to. |
| | | * @param port The port number on which the directory server is accepting |
| | | * requests. |
| | | * @param options The set of options for this connection. |
| | | * @param out The print stream to use for standard output. |
| | | * @param err The print stream to use for standard error. |
| | | */ |
| | | public LDAPConnection(String host, int port, LDAPConnectionOptions options, |
| | | PrintStream out, PrintStream err) |
| | | { |
| | | this.hostName = host; |
| | | this.portNumber = port; |
| | | this.connectionOptions = options; |
| | | this.versionNumber = options.getVersionNumber(); |
| | | this.out = out; |
| | | this.err = err; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | if(result != null) |
| | | { |
| | | System.out.println(result); |
| | | out.println(result); |
| | | } |
| | | |
| | | for (LDAPControl c : responseControls) |
| | |
| | | { |
| | | int msgID = MSGID_BIND_AUTHZID_RETURNED; |
| | | String message = getMessage(msgID, controlValue.stringValue()); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | } |
| | | } |
| | | else if (c.getOID().equals(OID_NS_PASSWORD_EXPIRED)) |
| | | { |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRED; |
| | | String message = getMessage(msgID); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | } |
| | | else if (c.getOID().equals(OID_NS_PASSWORD_EXPIRING)) |
| | | { |
| | |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeString); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | } |
| | | else if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | |
| | | case PASSWORD_EXPIRED: |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRED; |
| | | String message = getMessage(msgID); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | break; |
| | | case ACCOUNT_LOCKED: |
| | | msgID = MSGID_BIND_ACCOUNT_LOCKED; |
| | | message = getMessage(msgID); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | break; |
| | | case CHANGE_AFTER_RESET: |
| | | msgID = MSGID_BIND_MUST_CHANGE_PASSWORD; |
| | | message = getMessage(msgID); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | break; |
| | | } |
| | | } |
| | |
| | | |
| | | int msgID = MSGID_BIND_PASSWORD_EXPIRING; |
| | | String message = getMessage(msgID, timeString); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | break; |
| | | case GRACE_LOGINS_REMAINING: |
| | | msgID = MSGID_BIND_GRACE_LOGINS_REMAINING; |
| | | message = getMessage(msgID, pwPolicyControl.getWarningValue()); |
| | | System.out.println(message); |
| | | out.println(message); |
| | | break; |
| | | } |
| | | } |
| | |
| | | import java.io.FileReader; |
| | | import java.io.InputStreamReader; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.io.Reader; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPException; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.ProtocolOp; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.PasswordReader; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | |
| | | // The message ID counter to use for requests. |
| | | private AtomicInteger nextMessageID; |
| | | |
| | | // The print stream to use for standard error. |
| | | private PrintStream err; |
| | | |
| | | // The print stream to use for standard output. |
| | | private PrintStream out; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructor for the LDAPDelete object. |
| | | * |
| | | * @param nextMessageID The next message ID to use for requests. |
| | | * @param out The print stream to use for standard output. |
| | | * @param err The print stream to use for standard error. |
| | | */ |
| | | public LDAPDelete(AtomicInteger nextMessageID) |
| | | public LDAPDelete(AtomicInteger nextMessageID, PrintStream out, |
| | | PrintStream err) |
| | | { |
| | | this.nextMessageID = nextMessageID; |
| | | this.out = out; |
| | | this.err = err; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | protocolOp = new DeleteRequestProtocolOp(asn1OctetStr); |
| | | int msgID = MSGID_PROCESSING_OPERATION; |
| | | System.out.println(getMessage(msgID, "DELETE", asn1OctetStr)); |
| | | out.println(getMessage(msgID, "DELETE", asn1OctetStr)); |
| | | if(!deleteOptions.showOperations()) |
| | | { |
| | | LDAPMessage message = new LDAPMessage(nextMessageID.getAndIncrement(), |
| | |
| | | { |
| | | msgID = MSGID_OPERATION_FAILED; |
| | | String msg = getMessage(msgID, "DELETE", line, ae.getMessage()); |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | return; |
| | | } |
| | | } |
| | |
| | | { |
| | | msgID = MSGID_OPERATION_FAILED; |
| | | String msg = getMessage(msgID, "DELETE", line, errorMessage); |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | } else |
| | | { |
| | | msgID = MSGID_OPERATION_SUCCESSFUL; |
| | | String msg = getMessage(msgID, "DELETE", line); |
| | | System.out.println(msg); |
| | | out.println(msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainDelete(args); |
| | | int retCode = mainDelete(args, true, System.out, System.err); |
| | | |
| | | if(retCode != 0) |
| | | { |
| | |
| | | |
| | | public static int mainDelete(String[] args) |
| | | { |
| | | return mainDelete(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Parses the provided command-line arguments and uses that information to |
| | | * run the ldapdelete tool. |
| | | * |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * <CODE>null</CODE> if standard output is not |
| | | * needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * <CODE>null</CODE> if standard error is not |
| | | * needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | |
| | | public static int mainDelete(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | |
| | | LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); |
| | | LDAPDeleteOptions deleteOptions = new LDAPDeleteOptions(); |
| | | LDAPConnection connection = null; |
| | |
| | | showUsage = new BooleanArgument("showUsage", 'H', "help", |
| | | MSGID_DESCRIPTION_SHOWUSAGE); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage, out); |
| | | controlStr = new StringArgument("controls", 'J', "controls", false, false, |
| | | true, "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | | null, null, MSGID_DESCRIPTION_CONTROLS); |
| | |
| | | int msgID = MSGID_ENCPW_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ENCPW_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | // If we should just display usage information, then print it and exit. |
| | | if (showUsage.isPresent()) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | out.println(argParser.getUsage()); |
| | | return 0; |
| | | } |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | System.err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | int msgID = MSGID_DESCRIPTION_INVALID_VERSION; |
| | | System.err.println(getMessage(msgID, versionNumber)); |
| | | err.println(getMessage(msgID, versionNumber)); |
| | | return 1; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // read the password from the stdin. |
| | | try |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | bindDNValue)); |
| | | out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, bindDNValue)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | bindPasswordValue = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ex); |
| | | System.err.println(ex.getMessage()); |
| | | err.println(ex.getMessage()); |
| | | return 1; |
| | | } |
| | | } else if(bindPasswordValue == null) |
| | |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); |
| | | if(ctrl == null) |
| | | { |
| | | System.err.println("Invalid control specified:" + ctrlString); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println("Invalid control specified:" + ctrlString); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | deleteOptions.getControls().add(ctrl); |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | System.err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | return 1; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | System.err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | try |
| | | { |
| | | |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | if (initializeServer) |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | } |
| | | |
| | | // Connect to the specified host with the supplied userDN and password. |
| | | SSLConnectionFactory sslConnectionFactory = null; |
| | |
| | | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions); |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | LDAPDelete ldapDelete = new LDAPDelete(nextMessageID); |
| | | LDAPDelete ldapDelete = new LDAPDelete(nextMessageID, out, err); |
| | | if(fileNameValue == null && dnStrings.isEmpty()) |
| | | { |
| | | // Read from stdin. |
| | |
| | | } catch(LDAPException le) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", le); |
| | | System.err.println(le.getMessage()); |
| | | err.println(le.getMessage()); |
| | | int code = le.getResultCode(); |
| | | return code; |
| | | } catch(LDAPConnectionException lce) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", lce); |
| | | System.err.println(lce.getMessage()); |
| | | err.println(lce.getMessage()); |
| | | int code = lce.getErrorCode(); |
| | | return code; |
| | | } catch(Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", e); |
| | | System.err.println(e.getMessage()); |
| | | err.println(e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.protocols.ldap.ProtocolOp; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.ChangeRecordEntry; |
| | | import org.opends.server.util.LDIFException; |
| | |
| | | // The message ID counter to use for requests. |
| | | private AtomicInteger nextMessageID; |
| | | |
| | | // The print stream to use for standard error. |
| | | private PrintStream err; |
| | | |
| | | // The print stream to use for standard output. |
| | | private PrintStream out; |
| | | |
| | | // The LDIF file name. |
| | | private String fileName = null; |
| | | |
| | |
| | | * @param fileName The name of the file containing the LDIF data to use |
| | | * for the modifications. |
| | | * @param nextMessageID The message ID counter to use for requests. |
| | | * @param out The print stream to use for standard output. |
| | | * @param err The print stream to use for standard error. |
| | | */ |
| | | public LDAPModify(String fileName, AtomicInteger nextMessageID) |
| | | public LDAPModify(String fileName, AtomicInteger nextMessageID, |
| | | PrintStream out, PrintStream err) |
| | | { |
| | | if(fileName == null) |
| | | { |
| | |
| | | } |
| | | |
| | | this.nextMessageID = nextMessageID; |
| | | this.out = out; |
| | | this.err = err; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_LDIF_FILE_INVALID_LDIF_ENTRY; |
| | | String message = getMessage(msgID, le.getLineNumber(), fileName, |
| | | String.valueOf(le)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | continue; |
| | | } |
| | | } catch (Exception e) |
| | |
| | | { |
| | | int msgID = MSGID_LDIF_FILE_READ_ERROR; |
| | | String message = getMessage(msgID, fileName, String.valueOf(e)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | } |
| | | protocolOp = new AddRequestProtocolOp(asn1OctetStr, attributes); |
| | | msgID = MSGID_PROCESSING_OPERATION; |
| | | System.out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | break; |
| | | case DELETE: |
| | | operationType = "DELETE"; |
| | | protocolOp = new DeleteRequestProtocolOp(asn1OctetStr); |
| | | msgID = MSGID_PROCESSING_OPERATION; |
| | | System.out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | break; |
| | | case MODIFY: |
| | | operationType = "MODIFY"; |
| | |
| | | new ArrayList<LDAPModification>(modEntry.getModifications()); |
| | | protocolOp = new ModifyRequestProtocolOp(asn1OctetStr, mods); |
| | | msgID = MSGID_PROCESSING_OPERATION; |
| | | System.out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | break; |
| | | case MODIFY_DN: |
| | | operationType = "MODIFY DN"; |
| | |
| | | modDNEntry.deleteOldRDN()); |
| | | } |
| | | msgID = MSGID_PROCESSING_OPERATION; |
| | | System.out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | out.println(getMessage(msgID, operationType, asn1OctetStr)); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | { |
| | | assert debugException(CLASS_NAME, "readAndExecute", ae); |
| | | msgID = MSGID_OPERATION_FAILED; |
| | | System.err.println(getMessage(msgID, operationType, asn1OctetStr, |
| | | ae.getMessage())); |
| | | err.println(getMessage(msgID, operationType, asn1OctetStr, |
| | | ae.getMessage())); |
| | | if(!modifyOptions.continueOnError()) |
| | | { |
| | | throw new IOException(ae.getMessage()); |
| | |
| | | throw new LDAPException(resultCode, msgID, msg); |
| | | } else |
| | | { |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | } |
| | | } else |
| | | { |
| | | msgID = MSGID_OPERATION_SUCCESSFUL; |
| | | String msg = getMessage(msgID, operationType, asn1OctetStr); |
| | | System.out.println(msg); |
| | | out.println(msg); |
| | | |
| | | if (errorMessage != null) |
| | | { |
| | | System.out.println(errorMessage); |
| | | out.println(errorMessage); |
| | | } |
| | | |
| | | if (referralURLs != null) |
| | | { |
| | | System.out.println(referralURLs); |
| | | out.println(referralURLs); |
| | | } |
| | | } |
| | | |
| | |
| | | if (controlValue == null) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_PREREAD_NO_VALUE; |
| | | System.err.println(getMessage(msgID)); |
| | | err.println(getMessage(msgID)); |
| | | continue; |
| | | } |
| | | |
| | |
| | | catch (ASN1Exception ae) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE; |
| | | System.err.println(getMessage(msgID, ae.getMessage())); |
| | | err.println(getMessage(msgID, ae.getMessage())); |
| | | continue; |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE; |
| | | System.err.println(getMessage(msgID, le.getMessage())); |
| | | err.println(getMessage(msgID, le.getMessage())); |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | searchEntry.toLDIF(buffer, 78); |
| | | System.out.println(getMessage(MSGID_LDAPMODIFY_PREREAD_ENTRY)); |
| | | System.out.println(buffer); |
| | | out.println(getMessage(MSGID_LDAPMODIFY_PREREAD_ENTRY)); |
| | | out.println(buffer); |
| | | } |
| | | else if (oid.equals(OID_LDAP_READENTRY_POSTREAD)) |
| | | { |
| | |
| | | if (controlValue == null) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_POSTREAD_NO_VALUE; |
| | | System.err.println(getMessage(msgID)); |
| | | err.println(getMessage(msgID)); |
| | | continue; |
| | | } |
| | | |
| | |
| | | catch (ASN1Exception ae) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE; |
| | | System.err.println(getMessage(msgID, ae.getMessage())); |
| | | err.println(getMessage(msgID, ae.getMessage())); |
| | | continue; |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | msgID = MSGID_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE; |
| | | System.err.println(getMessage(msgID, le.getMessage())); |
| | | err.println(getMessage(msgID, le.getMessage())); |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | searchEntry.toLDIF(buffer, 78); |
| | | System.out.println(getMessage(MSGID_LDAPMODIFY_POSTREAD_ENTRY)); |
| | | System.out.println(buffer); |
| | | out.println(getMessage(MSGID_LDAPMODIFY_POSTREAD_ENTRY)); |
| | | out.println(buffer); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainModify(args); |
| | | int retCode = mainModify(args, true, System.out, System.err); |
| | | |
| | | if(retCode != 0) |
| | | { |
| | |
| | | |
| | | public static int mainModify(String[] args) |
| | | { |
| | | return mainModify(args, true, System.out, System.err); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Parses the provided command-line arguments and uses that information to |
| | | * run the ldapmodify tool. |
| | | * |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * <CODE>null</CODE> if standard output is not |
| | | * needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * <CODE>null</CODE> if standard error is not |
| | | * needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | |
| | | public static int mainModify(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | |
| | | LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); |
| | | LDAPModifyOptions modifyOptions = new LDAPModifyOptions(); |
| | | LDAPConnection connection = null; |
| | |
| | | showUsage = new BooleanArgument("showUsage", 'H', "help", |
| | | MSGID_DESCRIPTION_SHOWUSAGE); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage, out); |
| | | controlStr = new StringArgument("controls", 'J', "controls", false, |
| | | false, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | |
| | | int msgID = MSGID_ENCPW_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ENCPW_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | System.err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | int msgID = MSGID_DESCRIPTION_INVALID_VERSION; |
| | | System.err.println(getMessage(msgID, versionNumber)); |
| | | err.println(getMessage(msgID, versionNumber)); |
| | | return 1; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // read the password from the stdin. |
| | | try |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | bindDNValue)); |
| | | out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, bindDNValue)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | bindPasswordValue = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ex); |
| | | System.err.println(ex.getMessage()); |
| | | err.println(ex.getMessage()); |
| | | return 1; |
| | | } |
| | | } else if(bindPasswordValue == null) |
| | |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); |
| | | if(ctrl == null) |
| | | { |
| | | System.err.println("Invalid control specified:" + ctrlString); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println("Invalid control specified:" + ctrlString); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | modifyOptions.getControls().add(ctrl); |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | System.err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | System.err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | return 1; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | System.err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | try |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | if (initializeServer) |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | } |
| | | |
| | | // Connect to the specified host with the supplied userDN and password. |
| | | SSLConnectionFactory sslConnectionFactory = null; |
| | |
| | | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions); |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | LDAPModify ldapModify = new LDAPModify(fileNameValue, nextMessageID); |
| | | LDAPModify ldapModify = new LDAPModify(fileNameValue, nextMessageID, |
| | | out, err); |
| | | InputStream is = System.in; |
| | | if(fileNameValue != null) |
| | | { |
| | |
| | | } catch(LDAPException le) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", le); |
| | | System.err.println(le.getMessage()); |
| | | err.println(le.getMessage()); |
| | | int code = le.getResultCode(); |
| | | return code; |
| | | } catch(LDAPConnectionException lce) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", lce); |
| | | System.err.println(lce.getMessage()); |
| | | err.println(lce.getMessage()); |
| | | int code = lce.getErrorCode(); |
| | | return code; |
| | | } catch(Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", e); |
| | | System.err.println(e.getMessage()); |
| | | err.println(e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import org.opends.server.protocols.ldap.SearchResultEntryProtocolOp; |
| | | import org.opends.server.protocols.ldap.SearchResultReferenceProtocolOp; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.NullOutputStream; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | |
| | | // The message ID counter to use for requests. |
| | | private AtomicInteger nextMessageID; |
| | | |
| | | // The print stream to use for standard error. |
| | | private PrintStream err; |
| | | |
| | | // The print stream to use for standard output. |
| | | private PrintStream out; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructor for the LDAPSearch object. |
| | | * |
| | | * @param nextMessageID The message ID counter to use for requests. |
| | | * @param out The print stream to use for standard output. |
| | | * @param err The print stream to use for standard error. |
| | | */ |
| | | public LDAPSearch(AtomicInteger nextMessageID) |
| | | public LDAPSearch(AtomicInteger nextMessageID, PrintStream out, |
| | | PrintStream err) |
| | | { |
| | | this.nextMessageID = nextMessageID; |
| | | this.out = out; |
| | | this.err = err; |
| | | } |
| | | |
| | | |
| | |
| | | EntryChangeNotificationControl ecn = |
| | | EntryChangeNotificationControl.decodeControl( |
| | | c.getControl()); |
| | | System.out.println("# Persistent Search Change Type: " + |
| | | ecn.getChangeType().toString()); |
| | | out.println("# Persistent Search Change Type: " + |
| | | ecn.getChangeType().toString()); |
| | | DN previousDN = ecn.getPreviousDN(); |
| | | if (previousDN != null) |
| | | { |
| | | System.out.println("# Persistent Search Previous DN: " + |
| | | previousDN.toString()); |
| | | out.println("# Persistent Search Previous DN: " + |
| | | previousDN.toString()); |
| | | } |
| | | } catch (Exception e) {} |
| | | } |
| | |
| | | AccountUsableResponseControl acrc = |
| | | AccountUsableResponseControl.decodeControl( |
| | | c.getControl()); |
| | | System.out.println("# Account Usable Response Control"); |
| | | out.println("# Account Usable Response Control"); |
| | | if (acrc.isUsable()) |
| | | { |
| | | System.out.println("# Account is usable"); |
| | | out.println("# Account is usable"); |
| | | if (acrc.getSecondsBeforeExpiration() > 0) |
| | | { |
| | | int timeToExp = acrc.getSecondsBeforeExpiration(); |
| | | String timeToExpStr = secondsToTimeString(timeToExp); |
| | | System.out.println("# Time until expiration: " + |
| | | timeToExpStr); |
| | | out.println("# Time until expiration: " + |
| | | timeToExpStr); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | System.out.println("# Account is not usable"); |
| | | out.println("# Account is not usable"); |
| | | if (acrc.isInactive()) |
| | | { |
| | | System.out.println("# Account is inactive"); |
| | | out.println("# Account is inactive"); |
| | | } |
| | | if (acrc.isReset()) |
| | | { |
| | | System.out.println("# Password has been reset"); |
| | | out.println("# Password has been reset"); |
| | | } |
| | | if (acrc.isExpired()) |
| | | { |
| | | System.out.println("# Password is expired"); |
| | | out.println("# Password is expired"); |
| | | |
| | | if (acrc.getRemainingGraceLogins() > 0) |
| | | { |
| | | System.out.println("# Grace logins remaining: " + |
| | | acrc.getRemainingGraceLogins()); |
| | | out.println("# Grace logins remaining: " + |
| | | acrc.getRemainingGraceLogins()); |
| | | } |
| | | } |
| | | if (acrc.isLocked()) |
| | | { |
| | | System.out.println("# Account is locked"); |
| | | out.println("# Account is locked"); |
| | | if (acrc.getSecondsBeforeUnlock() > 0) |
| | | { |
| | | int timeToUnlock = acrc.getSecondsBeforeUnlock(); |
| | | String timeToUnlockStr = |
| | | secondsToTimeString(timeToUnlock); |
| | | System.out.println("# Time until automatic " + |
| | | "unlock: " + timeToUnlockStr); |
| | | out.println("# Time until automatic unlock: " + |
| | | timeToUnlockStr); |
| | | } |
| | | } |
| | | } |
| | |
| | | responseMessage.getSearchResultEntryProtocolOp(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | toLDIF(searchEntryOp, sb, wrapColumn, typesOnly); |
| | | System.out.println(sb.toString()); |
| | | out.println(sb.toString()); |
| | | break; |
| | | |
| | | case OP_TYPE_SEARCH_RESULT_REFERENCE: |
| | | SearchResultReferenceProtocolOp searchRefOp = |
| | | responseMessage.getSearchResultReferenceProtocolOp(); |
| | | System.out.println(searchRefOp.toString()); |
| | | out.println(searchRefOp.toString()); |
| | | break; |
| | | |
| | | case OP_TYPE_SEARCH_RESULT_DONE: |
| | |
| | | // FIXME - throw exception? |
| | | int msgID = MSGID_SEARCH_OPERATION_INVALID_PROTOCOL; |
| | | String msg = getMessage(msgID, opType); |
| | | System.err.println(msg); |
| | | err.println(msg); |
| | | break; |
| | | } |
| | | |
| | |
| | | } |
| | | else if (errorMessage != null) |
| | | { |
| | | System.out.println(); |
| | | System.out.println(errorMessage); |
| | | out.println(); |
| | | out.println(errorMessage); |
| | | } |
| | | |
| | | } while(opType != OP_TYPE_SEARCH_RESULT_DONE); |
| | |
| | | |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainSearch(args); |
| | | int retCode = mainSearch(args, true, System.out, System.err); |
| | | |
| | | if(retCode != 0) |
| | | { |
| | |
| | | |
| | | public static int mainSearch(String[] args) |
| | | { |
| | | return mainSearch(args, true, System.out, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Parses the provided command-line arguments and uses that information to |
| | | * run the ldapsearch tool. |
| | | * |
| | | * @param args The command-line arguments provided to this |
| | | * program. |
| | | * @param initializeServer Indicates whether to initialize the server. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * <CODE>null</CODE> if standard output is not |
| | | * needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * <CODE>null</CODE> if standard error is not |
| | | * needed. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | |
| | | public static int mainSearch(String[] args, boolean initializeServer, |
| | | OutputStream outStream, OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); |
| | | LDAPSearchOptions searchOptions = new LDAPSearchOptions(); |
| | | LDAPConnection connection = null; |
| | |
| | | showUsage = new BooleanArgument("showUsage", 'H', "help", |
| | | MSGID_DESCRIPTION_SHOWUSAGE); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage, out); |
| | | controlStr = new StringArgument("controls", 'J', "controls", false, |
| | | false, true, |
| | | "{controloid[:criticality[:value|::b64value|:<fileurl]]}", |
| | |
| | | int msgID = MSGID_ENCPW_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_ENCPW_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } catch(LDAPException le) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", le); |
| | | System.err.println(le.getMessage()); |
| | | err.println(le.getMessage()); |
| | | return 1; |
| | | } |
| | | // The rest are attributes |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | System.err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | err.println("ERROR: Both -w and -j flags specified. " + |
| | | "Please specify one."); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | int msgID = MSGID_DESCRIPTION_INVALID_VERSION; |
| | | System.err.println(getMessage(msgID, versionNumber)); |
| | | err.println(getMessage(msgID, versionNumber)); |
| | | return 1; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ae); |
| | | System.err.println(ae.getMessage()); |
| | | err.println(ae.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // read the password from the stdin. |
| | | try |
| | | { |
| | | System.out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, |
| | | bindDNValue)); |
| | | out.print(getMessage(MSGID_LDAPAUTH_PASSWORD_PROMPT, bindDNValue)); |
| | | char[] pwChars = PasswordReader.readPassword(); |
| | | bindPasswordValue = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", ex); |
| | | System.err.println(ex.getMessage()); |
| | | err.println(ex.getMessage()); |
| | | return 1; |
| | | } |
| | | } else if(bindPasswordValue == null) |
| | |
| | | searchOptions.setSizeLimit(sizeLimit.getIntValue()); |
| | | } catch(ArgumentException ex1) |
| | | { |
| | | System.err.println(ex1.getMessage()); |
| | | err.println(ex1.getMessage()); |
| | | return 1; |
| | | } |
| | | boolean val = searchOptions.setSearchScope(searchScope.getValue()); |
| | |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString); |
| | | if(ctrl == null) |
| | | { |
| | | System.err.println("Invalid control specified:" + ctrlString); |
| | | System.out.println(argParser.getUsage()); |
| | | err.println("Invalid control specified:" + ctrlString); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | searchOptions.getControls().add(ctrl); |
| | |
| | | { |
| | | int msgID = MSGID_PSEARCH_MISSING_DESCRIPTOR; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | else |
| | |
| | | { |
| | | int msgID = MSGID_PSEARCH_DOESNT_START_WITH_PS; |
| | | String message = getMessage(msgID, String.valueOf(infoString)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_PSEARCH_INVALID_CHANGE_TYPE; |
| | | String message = getMessage(msgID, String.valueOf(token)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_PSEARCH_INVALID_CHANGESONLY; |
| | | String message = getMessage(msgID, String.valueOf(token)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_PSEARCH_INVALID_RETURN_ECS; |
| | | String message = getMessage(msgID, String.valueOf(token)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | System.err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | err.println(getMessage(MSGID_LDAP_ASSERTION_INVALID_FILTER, |
| | | le.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | System.err.println(getMessage(MSGID_LDAP_MATCHEDVALUES_INVALID_FILTER, |
| | | le.getMessage())); |
| | | err.println(getMessage(MSGID_LDAP_MATCHEDVALUES_INVALID_FILTER, |
| | | le.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | System.err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | err.println("SASL External requires either SSL or StartTLS " + |
| | | "options to be requested."); |
| | | return 1; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | System.err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | err.println("SASL External requires a path to the SSL " + |
| | | "client certificate keystore."); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } catch(Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", e); |
| | | System.err.println(e.getMessage()); |
| | | err.println(e.getMessage()); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | if(filters.isEmpty()) |
| | | { |
| | | int msgid = MSGID_SEARCH_NO_FILTERS; |
| | | System.err.println(getMessage(msgid)); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(getMessage(msgid)); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | if (initializeServer) |
| | | { |
| | | // Bootstrap and initialize directory data structures. |
| | | DirectoryServer.bootstrapClient(); |
| | | } |
| | | |
| | | // Connect to the specified host with the supplied userDN and password. |
| | | SSLConnectionFactory sslConnectionFactory = null; |
| | |
| | | |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | connection = new LDAPConnection(hostNameValue, portNumber, |
| | | connectionOptions); |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDNValue, bindPasswordValue, nextMessageID); |
| | | |
| | | LDAPSearch ldapSearch = new LDAPSearch(nextMessageID); |
| | | LDAPSearch ldapSearch = new LDAPSearch(nextMessageID, out, err); |
| | | ldapSearch.executeSearch(connection, baseDNValue, filters, attributes, |
| | | searchOptions, wrapColumn); |
| | | |
| | | } catch(LDAPException le) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", le); |
| | | System.err.println(le.getMessage()); |
| | | err.println(le.getMessage()); |
| | | int code = le.getResultCode(); |
| | | return code; |
| | | } catch(LDAPConnectionException lce) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", lce); |
| | | System.err.println(lce.getMessage()); |
| | | err.println(lce.getMessage()); |
| | | int code = lce.getErrorCode(); |
| | | return code; |
| | | } catch(Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "main", e); |
| | | System.err.println(e.getMessage()); |
| | | err.println(e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | |
| | | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tasks.ShutdownTask; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.ArgumentParser; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int result = stopDS(args); |
| | | int result = stopDS(args, System.out, System.err); |
| | | |
| | | if (result != LDAPResultCode.SUCCESS) |
| | | { |
| | |
| | | */ |
| | | public static int stopDS(String[] args) |
| | | { |
| | | return stopDS(args, System.out, System.err); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parses the provided set of command-line arguments and attempts to contact |
| | | * the Directory Server in order to send it the shutdown request. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * @param outStream The output stream to use for standard output, or |
| | | * <CODE>null</CODE> if standard output is not needed. |
| | | * @param errStream The output stream to use for standard error, or |
| | | * <CODE>null</CODE> if standard error is not needed. |
| | | * |
| | | * @return An integer value that indicates whether the shutdown request was |
| | | * accepted by the Directory Server. A nonzero value should be |
| | | * interpreted as a failure of some kind. |
| | | */ |
| | | public static int stopDS(String[] args, OutputStream outStream, |
| | | OutputStream errStream) |
| | | { |
| | | PrintStream out; |
| | | if (outStream == null) |
| | | { |
| | | out = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | out = new PrintStream(outStream); |
| | | } |
| | | |
| | | PrintStream err; |
| | | if (errStream == null) |
| | | { |
| | | err = NullOutputStream.printStream(); |
| | | } |
| | | else |
| | | { |
| | | err = new PrintStream(errStream); |
| | | } |
| | | |
| | | |
| | | // Define all the arguments that may be used with this program. |
| | | ArgumentParser argParser = new ArgumentParser(CLASS_NAME, false); |
| | | BooleanArgument restart; |
| | |
| | | showUsage = new BooleanArgument("showusage", 'H', "help", |
| | | MSGID_STOPDS_DESCRIPTION_SHOWUSAGE); |
| | | argParser.addArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage); |
| | | argParser.setUsageArgument(showUsage, out); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_INITIALIZE_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_STOPDS_ERROR_PARSING_ARGS; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(message); |
| | | System.err.println(argParser.getUsage()); |
| | | err.println(message); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS; |
| | | String message = getMessage(msgID, bindPW.getLongIdentifier(), |
| | | bindPWFile.getLongIdentifier()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS; |
| | | String message = getMessage(msgID, keyStorePW.getLongIdentifier(), |
| | | keyStorePWFile.getLongIdentifier()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int msgID = MSGID_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS; |
| | | String message = getMessage(msgID, trustStorePW.getLongIdentifier(), |
| | | trustStorePWFile.getLongIdentifier()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_DECODE_STOP_TIME; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_DECODE_STOP_TIME; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | int msgID = MSGID_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS; |
| | | String message = getMessage(msgID, useSSL.getLongIdentifier(), |
| | | useStartTLS.getLongIdentifier()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_INITIALIZE_SSL; |
| | | String message = getMessage(msgID, sce.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_PARSE_SASL_OPTION; |
| | | String message = getMessage(msgID, s); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_NO_SASL_MECHANISM; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | try |
| | | { |
| | | connection = new LDAPConnection(host.getValue(), port.getIntValue(), |
| | | connectionOptions); |
| | | connectionOptions, out, err); |
| | | connection.connectToHost(bindDN.getValue(), bindPW.getValue(), |
| | | nextMessageID); |
| | | } |
| | |
| | | int msgID = MSGID_STOPDS_CANNOT_DETERMINE_PORT; |
| | | String message = getMessage(msgID, port.getLongIdentifier(), |
| | | ae.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | | int msgID = MSGID_STOPDS_CANNOT_CONNECT; |
| | | String message = getMessage(msgID, lce.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_UNEXPECTED_CONNECTION_CLOSURE; |
| | | String message = getMessage(msgID); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | |
| | | { |
| | | int msgID = MSGID_STOPDS_IO_ERROR; |
| | | String message = getMessage(msgID, String.valueOf(ioe)); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | int msgID = MSGID_STOPDS_DECODE_ERROR; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_DECODING_ERROR; |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | int msgID = MSGID_STOPDS_DECODE_ERROR; |
| | | String message = getMessage(msgID, le.getMessage()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_DECODING_ERROR; |
| | | } |
| | | |
| | |
| | | String message = extendedResponse.getErrorMessage(); |
| | | if (message != null) |
| | | { |
| | | System.err.println(message); |
| | | err.println(message); |
| | | } |
| | | |
| | | return extendedResponse.getResultCode(); |
| | |
| | | |
| | | int msgID = MSGID_STOPDS_INVALID_RESPONSE_TYPE; |
| | | String message = getMessage(msgID, responseMessage.getProtocolOpName()); |
| | | System.err.println(message); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | |
| | | String errorMessage = addResponse.getErrorMessage(); |
| | | if (errorMessage != null) |
| | | { |
| | | System.err.println(errorMessage); |
| | | err.println(errorMessage); |
| | | } |
| | | |
| | | return addResponse.getResultCode(); |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a custom output stream that simply discards any |
| | | * data written to it. |
| | | */ |
| | | public class NullOutputStream |
| | | extends OutputStream |
| | | { |
| | | /** |
| | | * The singleton instance for this class. |
| | | */ |
| | | private static final NullOutputStream instance = |
| | | new NullOutputStream(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * The singleton print stream tied to the null output stream. |
| | | */ |
| | | private static final PrintStream printStream = |
| | | new PrintStream(instance); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves an instance of this null output stream. |
| | | * |
| | | * @return An instance of this null output stream. |
| | | */ |
| | | public static NullOutputStream instance() |
| | | { |
| | | return instance; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a print stream using this null output stream. |
| | | * |
| | | * @return A print stream using this null output stream. |
| | | */ |
| | | public static PrintStream printStream() |
| | | { |
| | | return printStream; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this null output stream. |
| | | */ |
| | | private NullOutputStream() |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Closes the output stream. This has no effect. |
| | | */ |
| | | public void close() |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Flushes the output stream. This has no effect. |
| | | */ |
| | | public void flush() |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes the provided data to this output stream. This has no |
| | | * effect. |
| | | * |
| | | * @param b The byte array containing the data to be written. |
| | | */ |
| | | public void write(byte[] b) |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes the provided data to this output stream. This has no |
| | | * effect. |
| | | * |
| | | * @param b The byte array containing the data to be written. |
| | | * @param off The offset at which the real data begins. |
| | | * @param len The number of bytes to be written. |
| | | */ |
| | | public void write(byte[] b, int off, int len) |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes the provided byte to this output stream. This has no |
| | | * effect. |
| | | * |
| | | * @param b The byte to be written. |
| | | */ |
| | | public void write(int b) |
| | | { |
| | | // No implementation is required. |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DN; |
| | |
| | | |
| | | |
| | | /** |
| | | * Ensures that SASL PLAIN authentication works over LDAP as well as via the |
| | | * internal protocol. The authentication will be performed as the root user. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSASLPlainOverLDAP() |
| | | throws Exception |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-o", "mech=PLAIN", |
| | | "-o", "authid=dn:cn=Directory Manager", |
| | | "-w", "password", |
| | | "-b", "", |
| | | "-s", "base", |
| | | "(objectClass=*)", |
| | | "1.1" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, null), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves sets of invalid credentials that will not succeed when using |
| | | * SASL PLAIN. |
| | | * |