/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011 ForgeRock AS
*/
/**
* This class provides utility functions for all the client side tools.
*/
public class LDAPToolUtils
{
/**
* Parse the specified command line argument to create the
* appropriate LDAPControl. The argument string should be in the format
* controloid[:criticality[:value|::b64value|:<fileurl]]
*
* @param argString The argument string containing the encoded control
* information.
* @param err A print stream to which error messages should be
* written if a problem occurs.
*
* @return The control decoded from the provided string, or <CODE>null</CODE>
* if an error occurs while parsing the argument value.
*/
{
boolean controlCriticality = false;
if(idx < 0)
{
}
else
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
if (idx < 0)
{
return new LDAPControl(controlOID);
}
if(idx == -1)
{
{
controlCriticality = true;
{
controlCriticality = false;
} else
{
return null;
}
return control;
}
{
controlCriticality = true;
{
controlCriticality = false;
} else
{
return null;
}
{
return control;
}
{
{
// Read data from the file.
try
{
}
catch (Exception e)
{
return null;
}
} else
{
}
return control;
}
/**
* Read the data from the specified file and return it in a byte array.
*
* @param filePath The path to the file that should be read.
* @param err A print stream to which error messages should be
* written if a problem occurs.
*
* @return A byte array containing the contents of the requested file.
*
* @throws IOException If a problem occurs while trying to read the
* specified file.
*/
throws IOException
{
try
{
// Read in the bytes
int offset = 0;
int numRead = 0;
}
// Ensure all the bytes have been read in
{
return null;
}
return val;
} finally
{
{
}
}
}
/**
* Prints a multi-line error message with the provided information to the
* given print stream.
*
* @param err The print stream to use to write the error message.
* @param explanation The general explanation to provide to the user, or
* {@code null} if there is none.
* @param resultCode The result code returned from the server, or -1 if
* there is none.
* @param errorMessage The additional information / error message returned
* from the server, or {@code null} if there was none.
* @param matchedDN The matched DN returned from the server, or
* {@code null} if there was none.
*/
{
{
}
if (resultCode >= 0)
{
}
{
}
{
}
}
/**
* Returns the message to be displayed to the user when an exception occurs.
* <br>
* The code simply checks that the exception corresponds to a client side
* time out.
* @param ae the asn1exception that occurred connecting to the server or
* handling the response from the server.
* @return the message to be displayed to the user when an exception occurs.
*/
{
{
boolean isTimeout = false;
{
}
if (isTimeout)
{
}
else
{
}
}
else
{
}
return msg;
}
}