More changes for the removal of the Axis dependencies.

Removed the log files created by the Windows INSTALL.

Corrected the "Author" for files created by Greg.

Tuned the ATS logs to be less chatty and have a greater backlog.

Updated the NOTICES file and added READMEs to provide information
about external packages included in the project.
This commit is contained in:
Juan Carlos Luciani 2007-03-17 06:39:46 +00:00
parent 33a49c686a
commit 7a44908936
26 changed files with 2650 additions and 2904 deletions

View File

@ -6,291 +6,15 @@
********************************************************************************
********************************************************************************
* Package: axis-1.4 *
* Package: xml-security-1_4_0 *
* *
* Supplier: The Apache Software Foundation http://www.apache.org/ *
********************************************************************************
Components from package included in project:
Components from package utilized in project:
axis-ant
axis
commons-discovery
commons-logging
jaxrpc
log4j
saaj
wsdl4j
Package license:
////////////////////////////////////////////////////////////////////////////////
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
////////////////////////////////////////////////////////////////////////////////
Package notice:
////////////////////////////////////////////////////////////////////////////////
=========================================================================
== NOTICE file corresponding to section 4(d) of the Apache License, ==
== Version 2.0, in this case for the Apache Axis distribution. ==
=========================================================================
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
////////////////////////////////////////////////////////////////////////////////
Component axis-ant license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component axis license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component commons-discovery license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component commons-logging license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component jaxrpc license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component log4j license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component saaj license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component wsdl4j license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
* Package: xml-security-1_2_1 *
* *
* Supplier: The Apache Software Foundation http://www.apache.org/ *
********************************************************************************
Components from package included in project:
commons-logging-api
xalan
xercesImpl
xml-apis
xmlsec
Package license:
@ -510,40 +234,16 @@ The development of this software was partly funded by the European
Commission in the <WebSig> project in the ISIS Programme.
////////////////////////////////////////////////////////////////////////////////
Component commons-logging-api license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component xalan license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component xercesImpl license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component xml-apis license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
Component xmlsec license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
* Package: wss4j-1.5 *
* Package: logging-log4j-1.2.14 *
* *
* Supplier: The Apache Software Foundation http://www.apache.org/ *
********************************************************************************
Components from package included in project:
Components from package utilized in project:
wss4j
log4j
Package license:
////////////////////////////////////////////////////////////////////////////////
@ -752,41 +452,10 @@ Package license:
Package notice:
////////////////////////////////////////////////////////////////////////////////
Not present.
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
////////////////////////////////////////////////////////////////////////////////
Component wss4j license in package:
////////////////////////////////////////////////////////////////////////////////
Not present.
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
* File: Svc/src/com/novell/casa/authtoksvc/WSSecurity.java *
* *
* Supplier: http://www.novell.com/ *
********************************************************************************
This project file includes code copied from file WSSecurityUtil.java from
package org.apache.ws.security.util. The supplier of this package is the
The Apache Software Foundation(http://www.apache.org/).
Copyright Notice for org.apache.ws.security.util.WSSecurityUtil.java:
////////////////////////////////////////////////////////////////////////////////
Copyright 2003-2006 The Apache Software Foundation, or their licensors, as
appropriate.
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
////////////////////////////////////////////////////////////////////////////////
********************************************************************************
* File: Svc/src/com/novell/casa/authtoksvc/Base64Coder.java *

View File

@ -1,25 +1,3 @@
The following describes the source of the files present in this folder.
axis-1_4 ----> axis-ant.jar
axis-1_4 ----> axis.jar
axis-1_4 ----> commons-discovery-0.2.jar
axis-1_4 ----> commons-logging-1.0.4.jar
xml-security-1_2_1 ----> commons-logging-api.jar
axis-1_4 ----> jaxrpc.jar
axis-1_4 ----> log4j-1.2.8.jar
axis-1_4 ----> log4j.properties
axis-1_4 ----> saaj.jar
axis-1_4 ----> wsdl4j-1.5.1.jar
wss4j-1.5 ----> wss4j-1.5.0.jar
xml-security-1_2_1 ----> xalan.jar
xml-security-1_2_1 ----> xercesImpl.jar
xml-security-1_2_1 ----> xml-apis.jar
xml-security-1_2_1 ----> xmlsec-1.2.1.jar
xml-security-1_2_1 - URL: http://xml.apache.org/security/dist/java-library/ - File: xml-security-bin-1_2_1.zip
axis-1_4 - URL: http://www.apache.org/dyn/closer.cgi/ws/axis/1_4 - File: axis-bin-1_4.tar.gz
wss4j-1.5 - URL: http://www.apache.org/dyn/closer.cgi/ws/wss4j/1_5_0 - File: wss4j-bin-1.5.0.zip
This folder contains components which this project depends on.

View File

@ -26,7 +26,7 @@ DIST_SUBDIRS = logging-log4j-1.2.14
CFILES =
EXTRA_DIST =
EXTRA_DIST = README
.PHONY: package package-clean package-install package-uninstall
package package-clean package-install package-uninstall:

View File

@ -0,0 +1,8 @@
The files in this folder were downloaded from: http://www.apache.org/dist/logging/log4j/1.2.14/
Only the files necessary to satisfy the dependencies of this project were extracted from the
downloaded files.
The downloaded files are included in the project to improve maintenability. Use of these files
for any other purpose is discouraged, instead they should be obtained from apache.org.

View File

@ -26,7 +26,7 @@ DIST_SUBDIRS = xml-security-1_4_0
CFILES =
EXTRA_DIST =
EXTRA_DIST = README
.PHONY: package package-clean package-install package-uninstall
package package-clean package-install package-uninstall:

View File

@ -0,0 +1,11 @@
The files in this folder were downloaded from: http://www.apache.org/dist/xml/security/java-library/
Only the files necessary to satisfy the dependencies of this project were extracted from the
downloaded files.
The downloaded files are included in the project to improve maintenability. Use of these files
for any other purpose is discouraged, instead they should be obtained from apache.org.

View File

@ -27,6 +27,7 @@ DIST_SUBDIRS =
CFILES =
EXTRA_DIST = commons-logging.jar \
xercesImpl.jar \
xmlsec-1.4.0.jar
.PHONY: package package-clean package-install package-uninstall

View File

@ -12,14 +12,14 @@
#
# Root logger configuration.
#
log4j.rootLogger=info, DefaultAppender
log4j.rootLogger=warn, DefaultAppender
#
# DefaultAppender configuration.
#
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
log4j.appender.DefaultAppender.File=/srv/www/casaats/logs/ats.log
log4j.appender.DefaultAppender.MaxFileSize=100KB
log4j.appender.DefaultAppender.MaxFileSize=300KB
log4j.appender.DefaultAppender.MaxBackupIndex=2
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DefaultAppender.layout.ConversionPattern=%d{ISO8601} %p %C{2} %m%n
@ -35,7 +35,7 @@ log4j.additivity.ATS_Trace=false
#
log4j.appender.TraceAppender=org.apache.log4j.RollingFileAppender
log4j.appender.TraceAppender.File=/srv/www/casaats/logs/ats.trace
log4j.appender.TraceAppender.MaxFileSize=100KB
log4j.appender.TraceAppender.MaxFileSize=300KB
log4j.appender.TraceAppender.MaxBackupIndex=2
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n

View File

@ -36,7 +36,7 @@ import org.apache.log4j.Logger;
/**
* AuthMechConfig Class.
* <p>
* This class obtains and maintains authentication token configuration.
* This class obtains and maintains configuration for authentication mechanisms.
*
*/
public final class AuthMechConfig
@ -106,7 +106,7 @@ public final class AuthMechConfig
}
catch (FileNotFoundException e)
{
m_log.warn("Constructor()- File " + mechSettingsFileName + " not found");
m_log.debug("Constructor()- File " + mechSettingsFileName + " not found");
throw new Exception("Constructor- File not found", e);
}
catch (IOException e)

View File

@ -176,7 +176,7 @@ public final class AuthTokenConfig
}
catch (FileNotFoundException e)
{
m_log.warn("Constructor()- File " + authTokenSettingsFileName + " not found");
m_log.debug("Constructor()- File " + authTokenSettingsFileName + " not found");
throw new Exception("AuthTokenConfig()- File not found", e);
}
catch (IOException e)

View File

@ -128,7 +128,7 @@ public final class EnabledSvcsConfig
}
catch (FileNotFoundException e)
{
m_log.warn("Constructor()- File " + configFolder + File.separator + m_authPolicyFileName + " not found");
m_log.debug("Constructor()- File " + configFolder + File.separator + m_authPolicyFileName + " not found");
}
catch (IOException e)
{

View File

@ -118,7 +118,7 @@ public final class IdenTokenConfig
}
catch (FileNotFoundException e)
{
m_log.warn("Constructor()- File " + idenTokenSettingsFileName + " not found");
m_log.debug("Constructor()- File " + idenTokenSettingsFileName + " not found");
throw new Exception("IdenTokenConfig()- File not found", e);
}
catch (IOException e)

View File

@ -176,7 +176,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
}
catch (GSSException e)
{
m_log.warn("Constructor()- GSS Exception caught: " + e.getLocalizedMessage());
m_log.debug("Constructor()- GSS Exception caught: " + e.getLocalizedMessage());
throw new Exception("Failed to instantiate needed GSS objects", e);
}
}

View File

@ -12,14 +12,14 @@
#
# Root logger configuration.
#
log4j.rootLogger=info, DefaultAppender
log4j.rootLogger=warn, DefaultAppender
#
# DefaultAppender configuration.
#
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
log4j.appender.DefaultAppender.File=ATS_INSTALL_DIRats\\catalinabase\\logs\\ats.log
log4j.appender.DefaultAppender.MaxFileSize=100KB
log4j.appender.DefaultAppender.MaxFileSize=300KB
log4j.appender.DefaultAppender.MaxBackupIndex=2
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DefaultAppender.layout.ConversionPattern=%d{ISO8601} %p %C{2} %m%n
@ -35,7 +35,7 @@ log4j.additivity.ATS_Trace=false
#
log4j.appender.TraceAppender=org.apache.log4j.RollingFileAppender
log4j.appender.TraceAppender.File=ATS_INSTALL_DIRats\\catalinabase\\logs\\ats.trace
log4j.appender.TraceAppender.MaxFileSize=100KB
log4j.appender.TraceAppender.MaxFileSize=300KB
log4j.appender.TraceAppender.MaxBackupIndex=2
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -27,376 +27,378 @@ import java.util.*;
public class ClientKeystoreSetup
{
final static int ERROR_NO_ERROR = 0;
final static int ERROR_EXEC_FAILED = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
final static int ERROR_UNKNOWN_PARAM = -9;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
final static int ERROR_EXEC_INTERRUPTED = -12;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_EXEC_FAILED = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
final static int ERROR_UNKNOWN_PARAM = -9;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
final static int ERROR_EXEC_INTERRUPTED = -12;
final static int ERROR_IO_EXCEPTION = -13;
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
String sInstallDir;
Properties properties;
int rc;
String sInstallDir;
Properties properties;
int rc;
// debug stuff
File file;
FileWriter fw;
// debug stuff
//File file;
//FileWriter fw;
public static void main(String[] args)
{
ClientKeystoreSetup p = new ClientKeystoreSetup(args);
System.exit(p.rc);
}
public static void main(String[] args)
{
ClientKeystoreSetup p = new ClientKeystoreSetup(args);
System.exit(p.rc);
}
ClientKeystoreSetup(String[] args)
{
rc = ERROR_NO_ERROR;
ClientKeystoreSetup(String[] args)
{
rc = ERROR_NO_ERROR;
try
{
// DEBUG STUFF
file = new File("c:\\test4.log");
fw = new FileWriter(file);
try
{
// DEBUG STUFF
//file = new File("c:\\test4.log");
//fw = new FileWriter(file);
log("Here we go again: " + args.length);
for (int i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
// DEBUG STUFF
log("Here we go again: " + args.length);
for (int i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
// DEBUG STUFF
// Process the input params
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Make sure we got everything we need
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
{
// Make sure the client keystore has been created
rc = createClientKeystore();
}
}
// Process the input params
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Make sure we got everything we need
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
{
// Make sure the client keystore has been created
rc = createClientKeystore();
}
}
// DEBUG STUFF
log(rc);
fw.flush();
fw.close();
// DEBUG STUFF
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
}
// DEBUG STUFF
log(rc);
//fw.flush();
//fw.close();
// DEBUG STUFF
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
}
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
File fileProperties = null;
FileInputStream fisProperties = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
File fileProperties = null;
FileInputStream fisProperties = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (argsOld.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (argsOld.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
for (i = 0; i <= iNew; i++)
{
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
for (i = 0; i <= iNew; i++)
{
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE))
{
// Make sure it is more the the param tag
if (args[i].length() <= PROPERTY_FILE.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE))
{
// Make sure it is more the the param tag
if (args[i].length() <= PROPERTY_FILE.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
fileProperties = new File(sProperties);
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
fileProperties = new File(sProperties);
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties = new Properties();
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties = new Properties();
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Unknown parameter
else
{
log(ERROR_UNKNOWN_PARAM, args[i]);
return ERROR_UNKNOWN_PARAM;
}
}
// Unknown parameter
else
{
log(ERROR_UNKNOWN_PARAM, args[i]);
return ERROR_UNKNOWN_PARAM;
}
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int findRequiredValues()
{
String[] rgsRequired = {
"ATS_JAVA_HOME"};
int i;
String sValue;
int findRequiredValues()
{
String[] rgsRequired = {
"ATS_JAVA_HOME"};
int i;
String sValue;
for (i = 0; i < rgsRequired.length; i++)
{
log("look for required value: " + rgsRequired[i]);
for (i = 0; i < rgsRequired.length; i++)
{
log("look for required value: " + rgsRequired[i]);
if (!properties.containsKey(rgsRequired[i]))
{
log("look for required value in envirement: " + rgsRequired[i]);
if (null == (sValue = System.getProperty(rgsRequired[i])))
{
log("unable to find required value in envirement: " + rgsRequired[i]);
return ERROR_REQUIRED_VALUE_MISSING;
}
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
properties.put(rgsRequired[i], sValue);
}
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
}
return ERROR_NO_ERROR;
}
if (!properties.containsKey(rgsRequired[i]))
{
log("look for required value in envirement: " + rgsRequired[i]);
if (null == (sValue = System.getProperty(rgsRequired[i])))
{
log("unable to find required value in envirement: " + rgsRequired[i]);
return ERROR_REQUIRED_VALUE_MISSING;
}
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
properties.put(rgsRequired[i], sValue);
}
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
}
return ERROR_NO_ERROR;
}
int createClientKeystore()
{
int rc;
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
int createClientKeystore()
{
int rc;
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
log("keytool = " + sKeytool);
log("keytool = " + sKeytool);
// Do not do anything if the server keystore has already been created
if (keyStoreAlreadyExists())
{
return ERROR_NO_ERROR;
}
// Do not do anything if the server keystore has already been created
if (keyStoreAlreadyExists())
{
return ERROR_NO_ERROR;
}
// Import the servers certificate in the client keystore
rc = invokeCommand(sKeytool + " -import -noprompt -keystore " +
sInstallDir + "ats\\etc\\keys\\client\\jks-store -alias signingCert -storepass secret -keypass secret -file " +
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert");
// Import the servers certificate in the client keystore
rc = invokeCommand(sKeytool + " -import -noprompt -keystore " +
sInstallDir + "ats\\etc\\keys\\client\\jks-store -alias signingCert -storepass secret -keypass secret -file " +
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert");
return rc;
}
return rc;
}
boolean keyStoreAlreadyExists()
{
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\client\\jks-store");
boolean keyStoreAlreadyExists()
{
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\client\\jks-store");
// Why is this always returning true? exists() also always returns true.
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\client\\jks-store" + ") already exists = " + (file.isFile()));
// return (file.isFile());
// Why is this always returning true? exists() also always returns true.
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\client\\jks-store" + ") already exists = " + (file.isFile()));
// return (file.isFile());
File fileParent = fileKeystore.getParentFile();
String[] rgChildren = fileParent.list();
if (null != rgChildren)
{
for (int i = 0; i < rgChildren.length; i++)
{
log("child " + i + " = " + rgChildren[i]);
if ("jks-store".equals(rgChildren[i]))
{
return true;
}
}
}
File fileParent = fileKeystore.getParentFile();
String[] rgChildren = fileParent.list();
if (null != rgChildren)
{
for (int i = 0; i < rgChildren.length; i++)
{
log("child " + i + " = " + rgChildren[i]);
if ("jks-store".equals(rgChildren[i]))
{
return true;
}
}
}
return false;
}
return false;
}
int invokeCommand(String sCommand)
{
Process p;
int rc;
int invokeCommand(String sCommand)
{
Process p;
int rc;
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("Ioexception");
return ERROR_EXEC_FAILED;
}
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("Ioexception");
return ERROR_EXEC_FAILED;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_EXEC_FAILED:
sMessage = "Execute command failed ";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of params";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is bad";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install dir";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install dir is not a dir";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Invalid porperty file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Property file not found";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "Unable to read property file";
break;
case ERROR_UNKNOWN_PARAM:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is missing";
break;
case ERROR_REQUIRED_VALUE_MISSING:
sMessage = "Required value is missing ";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Execution iinterrupted: ";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException ";
break;
default:
sMessage = "Unknown error";
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_EXEC_FAILED:
sMessage = "Execute command failed ";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of params";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is bad";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install dir";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install dir is not a dir";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Invalid porperty file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Property file not found";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "Unable to read property file";
break;
case ERROR_UNKNOWN_PARAM:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is missing";
break;
case ERROR_REQUIRED_VALUE_MISSING:
sMessage = "Required value is missing ";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Execution iinterrupted: ";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException ";
break;
default:
sMessage = "Unknown error";
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -1,3 +1,28 @@
/***********************************************************************
*
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
// CommandLauncher.cpp : Defines the entry point for the application.
//
@ -11,8 +36,8 @@
#include <errno.h>
WCHAR ** G_rgArgs; // Command line arguments
int G_cArg; // Count of command line arguments
FILE * G_pf;
int G_cArg; // Count of command line arguments
//FILE * G_pf;
// Forward declarations of functions included in this code module:
int processArguments(LPTSTR lpCmdLine);
@ -24,476 +49,478 @@ _TCHAR * errorMessage(int err);
int executeCommand( int cArg, _TCHAR* rgArg[]);
#define ERROR_NO_ERROR 0
#define ERROR_MEMORY_ALLOCATION_FAILED -1
#define ERROR_INVALID_NUMBER_OF_PARAMETERS -2
#define ERROR_EXEC_E2BIG -3
#define ERROR_EXEC_EACCES -4
#define ERROR_EXEC_EINVAL -5
#define ERROR_EXEC_EMFILE -6
#define ERROR_EXEC_ENOENT -7
#define ERROR_EXEC_ENOEXEC -8
#define ERROR_EXEC_ENOMEM -9
#define ERROR_EXEC_UNKNOWN -10
#define ERROR_STRCPY_FAILED -11
#define ERROR_JAVA_EXE_ARG_MISSING -12
#define ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING -13
#define ERROR_JAVA_CLASSPATH_ARG_MISSING -14
#define ERROR_BAD_COMMAND_LINE -15
#define ERROR_NO_ERROR 0
#define ERROR_MEMORY_ALLOCATION_FAILED -1
#define ERROR_INVALID_NUMBER_OF_PARAMETERS -2
#define ERROR_EXEC_E2BIG -3
#define ERROR_EXEC_EACCES -4
#define ERROR_EXEC_EINVAL -5
#define ERROR_EXEC_EMFILE -6
#define ERROR_EXEC_ENOENT -7
#define ERROR_EXEC_ENOEXEC -8
#define ERROR_EXEC_ENOMEM -9
#define ERROR_EXEC_UNKNOWN -10
#define ERROR_STRCPY_FAILED -11
#define ERROR_JAVA_EXE_ARG_MISSING -12
#define ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING -13
#define ERROR_JAVA_CLASSPATH_ARG_MISSING -14
#define ERROR_BAD_COMMAND_LINE -15
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
int rc;
int rc;
_wfopen_s(&G_pf, L"C:\\CommandLauncher.log", L"a+");
//_wfopen_s(&G_pf, L"C:\\CommandLauncher.log", L"a+");
// Process the command line
if (ERROR_NO_ERROR != (rc = processArguments(lpCmdLine)))
{
return rc;
}
// Process the command line
if (ERROR_NO_ERROR != (rc = processArguments(lpCmdLine)))
{
return rc;
}
rc = executeCommand(G_cArg, G_rgArgs);
rc = executeCommand(G_cArg, G_rgArgs);
log(errorMessage(rc));
log(errorMessage(rc));
fwprintf(G_pf, L"CommandLauncher: return = %d\n", rc);
//fwprintf(G_pf, L"CommandLauncher: return = %d\n", rc);
fclose(G_pf);
//fclose(G_pf);
return rc;
return rc;
}
// <java exe path> -cp <classpath> class k1=v1 k2=k2
int processArguments(LPTSTR lpCmdLine)
{
int iArg;
int iChar;
int iAssignment;
int iClassStart;
int iClassEnd;
int iClassPathStart;
int iClassPathEnd;
int rc;
bool fClasspathOptionFound = false;
int iKeyStart;
int iValueEnd;
int iArg;
int iChar;
int iAssignment;
int iClassStart;
int iClassEnd;
int iClassPathStart;
int iClassPathEnd;
int rc;
bool fClasspathOptionFound = false;
int iKeyStart;
int iValueEnd;
fwprintf( G_pf, L"current command line = %s\n", lpCmdLine);
//fwprintf( G_pf, L"current command line = %s\n", lpCmdLine);
// Validate the command line
if (NULL == lpCmdLine || (WCHAR)0 == *lpCmdLine)
{
return ERROR_BAD_COMMAND_LINE;
}
// Validate the command line
if (NULL == lpCmdLine || (WCHAR)0 == *lpCmdLine)
{
return ERROR_BAD_COMMAND_LINE;
}
// Count the arguments on the command line. TThe name of this executable
// is not included in the count.
G_cArg = countArgs(lpCmdLine);
// Count the arguments on the command line. TThe name of this executable
// is not included in the count.
G_cArg = countArgs(lpCmdLine);
// Make sure we got enough to exec something. There must be at least the
// path to jave.exe, the classpath option, the classpath and a class.
if (G_cArg < 4)
{
return ERROR_INVALID_NUMBER_OF_PARAMETERS;
}
// Make sure we got enough to exec something. There must be at least the
// path to jave.exe, the classpath option, the classpath and a class.
if (G_cArg < 4)
{
return ERROR_INVALID_NUMBER_OF_PARAMETERS;
}
// Allocate an array of wide string for the arguments, add 1 for a NULL at
// the end of the array
G_rgArgs = (WCHAR**)malloc((G_cArg + 1) * sizeof(WCHAR *));
if (NULL == G_rgArgs)
{
return ERROR_MEMORY_ALLOCATION_FAILED;
}
// Allocate an array of wide string for the arguments, add 1 for a NULL at
// the end of the array
G_rgArgs = (WCHAR**)malloc((G_cArg + 1) * sizeof(WCHAR *));
if (NULL == G_rgArgs)
{
return ERROR_MEMORY_ALLOCATION_FAILED;
}
// Null out the array
memset(G_rgArgs, 0, (G_cArg + 1) * sizeof(WCHAR *));
// Null out the array
memset(G_rgArgs, 0, (G_cArg + 1) * sizeof(WCHAR *));
// Find the java.exe argument
iChar = 0;
for (iChar = 0; 0 != lpCmdLine[iChar + 4]; iChar++)
{
if (0 == _wcsnicmp(lpCmdLine + iChar, L".exe", 4))
{
break;
}
}
if (0 == lpCmdLine[iChar + 4])
{
rc = ERROR_JAVA_EXE_ARG_MISSING;
goto ErrorOut;
}
// Find the java.exe argument
iChar = 0;
for (iChar = 0; 0 != lpCmdLine[iChar + 4]; iChar++)
{
if (0 == _wcsnicmp(lpCmdLine + iChar, L".exe", 4))
{
break;
}
}
if (0 == lpCmdLine[iChar + 4])
{
rc = ERROR_JAVA_EXE_ARG_MISSING;
goto ErrorOut;
}
// Add the java.exe argument
if (ERROR_NO_ERROR != (rc = addArg(0, lpCmdLine, iChar + 4)))
{
goto ErrorOut;
}
// Add the java.exe argument
if (ERROR_NO_ERROR != (rc = addArg(0, lpCmdLine, iChar + 4)))
{
goto ErrorOut;
}
// Move past the java.exe argument
iChar += 4;
// Move past the java.exe argument
iChar += 4;
// Move past any spaces
for (;L' ' == lpCmdLine[iChar]; iChar++)
{
// Intentionally left blank
}
// Move past any spaces
for (;L' ' == lpCmdLine[iChar]; iChar++)
{
// Intentionally left blank
}
// Find the classpath argument
for (; 0 != lpCmdLine[iChar + 3]; iChar++)
{
if (0 == _wcsnicmp(lpCmdLine + iChar, L"-cp", 3))
{
fClasspathOptionFound = true;
break;
}
}
if (!fClasspathOptionFound)
{
rc = ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING;
goto ErrorOut;
}
if (0 == lpCmdLine[iChar + 3])
{
rc = ERROR_JAVA_CLASSPATH_ARG_MISSING;
goto ErrorOut;
}
// Find the classpath argument
for (; 0 != lpCmdLine[iChar + 3]; iChar++)
{
if (0 == _wcsnicmp(lpCmdLine + iChar, L"-cp", 3))
{
fClasspathOptionFound = true;
break;
}
}
if (!fClasspathOptionFound)
{
rc = ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING;
goto ErrorOut;
}
if (0 == lpCmdLine[iChar + 3])
{
rc = ERROR_JAVA_CLASSPATH_ARG_MISSING;
goto ErrorOut;
}
// Add the classpath option argument
if (ERROR_NO_ERROR != (rc = addArg(1, L"-cp", iChar + 3)))
{
goto ErrorOut;
}
// Add the classpath option argument
if (ERROR_NO_ERROR != (rc = addArg(1, L"-cp", iChar + 3)))
{
goto ErrorOut;
}
// Move past the classpath option argument
iChar += 3;
// Move past the classpath option argument
iChar += 3;
// Move past any spaces
for (;L' ' == lpCmdLine[iChar]; iChar++)
{
// Intentionally left blank
}
// Move past any spaces
for (;L' ' == lpCmdLine[iChar]; iChar++)
{
// Intentionally left blank
}
// The classpath is next. It can have spaces in it so we need to work
// backards from the first key/value pair, or the end of the line if
// there are no key/value pairs.
iClassPathStart = iChar;
// The classpath is next. It can have spaces in it so we need to work
// backards from the first key/value pair, or the end of the line if
// there are no key/value pairs.
iClassPathStart = iChar;
// Find the location of the next '='
for (; 0 != lpCmdLine[iChar] && L'=' != lpCmdLine[iChar]; iChar++)
{
// Intentially left blank
}
// Find the location of the next '='
for (; 0 != lpCmdLine[iChar] && L'=' != lpCmdLine[iChar]; iChar++)
{
// Intentially left blank
}
// If there was a key/value pair - move to the start of the key
if (L'=' == lpCmdLine[iChar])
{
iAssignment = iChar;
// If there was a key/value pair - move to the start of the key
if (L'=' == lpCmdLine[iChar])
{
iAssignment = iChar;
// Move back to the previous space. This should put us at the
// beginning of the first key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iChar] && iChar >= 0; iChar--)
{
// Intentially left blank
}
}
// Move back to the previous space. This should put us at the
// beginning of the first key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iChar] && iChar >= 0; iChar--)
{
// Intentially left blank
}
}
else
{
iAssignment = 0;
iChar--;
}
else
{
iAssignment = 0;
iChar--;
}
// Move past any spaces (moving toward the start of the line)
for (;L' ' == lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
// Move past any spaces (moving toward the start of the line)
for (;L' ' == lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
// This should put us at the end of the class to be executed
iClassEnd = iChar;
// This should put us at the end of the class to be executed
iClassEnd = iChar;
// Move to the previous space (moving toward the start of the line)
for (;L' ' != lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
// Move to the previous space (moving toward the start of the line)
for (;L' ' != lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
iClassStart = iChar + 1;
iClassStart = iChar + 1;
// Add the class argument
if (ERROR_NO_ERROR != (rc = addArg(3, lpCmdLine + iClassStart, iClassEnd - iClassStart + 1)))
{
goto ErrorOut;
}
// Add the class argument
if (ERROR_NO_ERROR != (rc = addArg(3, lpCmdLine + iClassStart, iClassEnd - iClassStart + 1)))
{
goto ErrorOut;
}
// Move past any spaces (moving toward the start of the line)
for (;L' ' == lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
// Move past any spaces (moving toward the start of the line)
for (;L' ' == lpCmdLine[iChar]; iChar--)
{
// Intentionally left blank
}
// This should put us at the end of the classpath
iClassPathEnd = iChar;
// This should put us at the end of the classpath
iClassPathEnd = iChar;
// Add the class path argument
if (ERROR_NO_ERROR != (rc = addArg(2, lpCmdLine + iClassPathStart, iClassPathEnd - iClassPathStart + 1)))
{
goto ErrorOut;
}
// Add the class path argument
if (ERROR_NO_ERROR != (rc = addArg(2, lpCmdLine + iClassPathStart, iClassPathEnd - iClassPathStart + 1)))
{
goto ErrorOut;
}
// Are the any key/value pairs?
if (0 != iAssignment)
{
iArg = 4;
while (0 != lpCmdLine[iAssignment])
{
iKeyStart = iAssignment;
// Are the any key/value pairs?
if (0 != iAssignment)
{
iArg = 4;
while (0 != lpCmdLine[iAssignment])
{
iKeyStart = iAssignment;
// Move back to the previous space. This should put us at the
// beginning of the current next key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iKeyStart] && iKeyStart > 0; iKeyStart--)
{
// Intentially left blank
}
if (L' ' == lpCmdLine[iKeyStart])
{
iKeyStart++;
}
// Move back to the previous space. This should put us at the
// beginning of the current next key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iKeyStart] && iKeyStart > 0; iKeyStart--)
{
// Intentially left blank
}
if (L' ' == lpCmdLine[iKeyStart])
{
iKeyStart++;
}
// Find the location of the next '='
iValueEnd = iAssignment + 1;
for (; 0 != lpCmdLine[iValueEnd] && L'=' != lpCmdLine[iValueEnd]; iValueEnd++)
{
// Intentially left blank
}
// Find the location of the next '='
iValueEnd = iAssignment + 1;
for (; 0 != lpCmdLine[iValueEnd] && L'=' != lpCmdLine[iValueEnd]; iValueEnd++)
{
// Intentially left blank
}
// If there was a property...
if (L'=' == lpCmdLine[iValueEnd])
{
iAssignment = iValueEnd;
// If there was a property...
if (L'=' == lpCmdLine[iValueEnd])
{
iAssignment = iValueEnd;
// Move back to the previous space. This should put us at the
// beginning of the next key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
{
// Intentially left blank
}
}
// Move back to the previous space. This should put us at the
// beginning of the next key/value pair. Assume that all args
// are property key/value pairs and property keys have no spaces.
for (; L' ' != lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
{
// Intentially left blank
}
}
else
{
// We have reached the end of the command line - back off from the
// null terminator.
iAssignment = iValueEnd;
iValueEnd--;
}
else
{
// We have reached the end of the command line - back off from the
// null terminator.
iAssignment = iValueEnd;
iValueEnd--;
}
// Move thorugh any spaces
for (; L' ' == lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
{
// Intentially left blank
}
// Move thorugh any spaces
for (; L' ' == lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
{
// Intentially left blank
}
// Add the key/value pair
if (ERROR_NO_ERROR != (rc = addArg(iArg, lpCmdLine + iKeyStart, iValueEnd - iKeyStart + 1)))
{
goto ErrorOut;
}
// Add the key/value pair
if (ERROR_NO_ERROR != (rc = addArg(iArg, lpCmdLine + iKeyStart, iValueEnd - iKeyStart + 1)))
{
goto ErrorOut;
}
// Go on to the next arg
iArg++;
}
}
// Go on to the next arg
iArg++;
}
}
return ERROR_NO_ERROR;
return ERROR_NO_ERROR;
ErrorOut:
freeArgs();
log(errorMessage(rc));
return rc;
freeArgs();
log(errorMessage(rc));
return rc;
}
void freeArgs()
{
int iArg;
if (NULL != G_rgArgs)
{
for (iArg = 0; iArg < G_cArg; iArg++)
{
if (NULL != G_rgArgs[iArg])
{
free(G_rgArgs[iArg]);
G_rgArgs[iArg] = NULL;
}
}
free(G_rgArgs);
G_rgArgs = NULL;
}
int iArg;
if (NULL != G_rgArgs)
{
for (iArg = 0; iArg < G_cArg; iArg++)
{
if (NULL != G_rgArgs[iArg])
{
free(G_rgArgs[iArg]);
G_rgArgs[iArg] = NULL;
}
}
free(G_rgArgs);
G_rgArgs = NULL;
}
}
int countArgs(LPTSTR lpCmdLine)
{
int cArgument;
int cArgument;
// Check if the exe to execute is the only argument. Assume that all additional
// arguments have an '=' in them.
for (cArgument = 4; *lpCmdLine != (WCHAR)0; lpCmdLine++)
{
if (*lpCmdLine == L'=')
{
cArgument++;
}
}
return cArgument;
// Check if the exe to execute is the only argument. Assume that all additional
// arguments have an '=' in them.
for (cArgument = 4; *lpCmdLine != (WCHAR)0; lpCmdLine++)
{
if (*lpCmdLine == L'=')
{
cArgument++;
}
}
return cArgument;
}
int addArg(int iArg, LPTSTR lpString, int cChar)
{
int cb = (cChar + 3) * sizeof(WCHAR); // count of bytes
int cb = (cChar + 3) * sizeof(WCHAR); // count of bytes
// Allocate space for the new arg
G_rgArgs[iArg] = (WCHAR *)malloc(cb);
if (NULL == G_rgArgs[iArg])
{
return ERROR_MEMORY_ALLOCATION_FAILED;
}
// Allocate space for the new arg
G_rgArgs[iArg] = (WCHAR *)malloc(cb);
if (NULL == G_rgArgs[iArg])
{
return ERROR_MEMORY_ALLOCATION_FAILED;
}
// Null out the argument
memset(G_rgArgs[iArg], 0, cb);
// Null out the argument
memset(G_rgArgs[iArg], 0, cb);
// Add a starting quote
// G_rgArgs[iArg][0] = L'\"';
// Add a starting quote
// G_rgArgs[iArg][0] = L'\"';
// Copy the arg
if (0 != wcsncpy_s(G_rgArgs[iArg], cChar + 1, lpString, cChar))
{
return ERROR_STRCPY_FAILED;
}
// Copy the arg
if (0 != wcsncpy_s(G_rgArgs[iArg], cChar + 1, lpString, cChar))
{
return ERROR_STRCPY_FAILED;
}
// Add a terminating quote
// G_rgArgs[iArg][cb-1] = L'\"';
// Add a terminating quote
// G_rgArgs[iArg][cb-1] = L'\"';
return ERROR_NO_ERROR;
return ERROR_NO_ERROR;
}
void log(LPTSTR szMessage)
{
LPTSTR szT = L"";
if (NULL == szMessage)
szMessage = szT;
fwprintf(G_pf, L"JavaLauncher: %s\n", szMessage);
/*
LPTSTR szT = L"";
if (NULL == szMessage)
szMessage = szT;
fwprintf(G_pf, L"JavaLauncher: %s\n", szMessage);
*/
}
_TCHAR * errorMessage(int err)
{
switch (err)
{
case ERROR_NO_ERROR:
return L"No error\n";
case ERROR_MEMORY_ALLOCATION_FAILED:
return L"Memory allocation failed\n";
case ERROR_INVALID_NUMBER_OF_PARAMETERS:
return L"Invalid number of parameters\n";
case ERROR_EXEC_E2BIG:
return L"_exec: The space required for the arguments and environment settings exceeds 32 KB.\n";
case ERROR_EXEC_EACCES:
return L"_exec: The specified file has a locking or sharing violation.\n";
case ERROR_EXEC_EINVAL:
return L"_exec: Invalid parameter.\n";
case ERROR_EXEC_EMFILE:
return L"_exec: Too many files open (the specified file must be opened to determine whether it is executable).\n";
case ERROR_EXEC_ENOENT:
return L"_exec: The file or path not found.\n";
case ERROR_EXEC_ENOEXEC:
return L"_exec: The specified file is not executable or has an invalid executable-file format.\n";
case ERROR_EXEC_ENOMEM:
return L"_exec: Not enough memory is available to execute the new process; the available memory has been corrupted; or an invalid block exists, indicating that the calling process was not allocated properly.\n";
case ERROR_EXEC_UNKNOWN:
return L"Unknown _exec error.\n";
case ERROR_STRCPY_FAILED:
return L"String copy failed.\n";
case ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING:
return L"Classpath option \"-cp\" missing\n";
case ERROR_JAVA_CLASSPATH_ARG_MISSING:
return L"Classpath argument missing\n";
case ERROR_BAD_COMMAND_LINE:
return L"Bad command line\n";
default:
return L"Unknown error.\n";
}
switch (err)
{
case ERROR_NO_ERROR:
return L"No error\n";
case ERROR_MEMORY_ALLOCATION_FAILED:
return L"Memory allocation failed\n";
case ERROR_INVALID_NUMBER_OF_PARAMETERS:
return L"Invalid number of parameters\n";
case ERROR_EXEC_E2BIG:
return L"_exec: The space required for the arguments and environment settings exceeds 32 KB.\n";
case ERROR_EXEC_EACCES:
return L"_exec: The specified file has a locking or sharing violation.\n";
case ERROR_EXEC_EINVAL:
return L"_exec: Invalid parameter.\n";
case ERROR_EXEC_EMFILE:
return L"_exec: Too many files open (the specified file must be opened to determine whether it is executable).\n";
case ERROR_EXEC_ENOENT:
return L"_exec: The file or path not found.\n";
case ERROR_EXEC_ENOEXEC:
return L"_exec: The specified file is not executable or has an invalid executable-file format.\n";
case ERROR_EXEC_ENOMEM:
return L"_exec: Not enough memory is available to execute the new process; the available memory has been corrupted; or an invalid block exists, indicating that the calling process was not allocated properly.\n";
case ERROR_EXEC_UNKNOWN:
return L"Unknown _exec error.\n";
case ERROR_STRCPY_FAILED:
return L"String copy failed.\n";
case ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING:
return L"Classpath option \"-cp\" missing\n";
case ERROR_JAVA_CLASSPATH_ARG_MISSING:
return L"Classpath argument missing\n";
case ERROR_BAD_COMMAND_LINE:
return L"Bad command line\n";
default:
return L"Unknown error.\n";
}
}
int executeCommand( int cArg, _TCHAR* rgArg[] )
{
int i; // Looping variable
int rc = ERROR_NO_ERROR; // Return code
int i; // Looping variable
int rc = ERROR_NO_ERROR; // Return code
fwprintf( G_pf, L"Arg count = %d\n", cArg);
for (i = 0; i < cArg; i++)
{
fwprintf(G_pf, L"rgArg[%d] (%s)\n", i, rgArg[i]);
}
//fwprintf( G_pf, L"Arg count = %d\n", cArg);
//for (i = 0; i < cArg; i++)
//{
// fwprintf(G_pf, L"rgArg[%d] (%s)\n", i, rgArg[i]);
//}
// exec the command
// if (-1 == _wexecv( rgArg[0], rgArg))
if (-1 == _wspawnv(_P_WAIT, rgArg[0], rgArg))
{
switch (errno)
{
case E2BIG: // The space required for the arguments and environment settings exceeds 32 KB.
rc = ERROR_EXEC_E2BIG;
break;
// exec the command
// if (-1 == _wexecv( rgArg[0], rgArg))
if (-1 == _wspawnv(_P_WAIT, rgArg[0], rgArg))
{
switch (errno)
{
case E2BIG: // The space required for the arguments and environment settings exceeds 32 KB.
rc = ERROR_EXEC_E2BIG;
break;
case EACCES: // The specified file has a locking or sharing violation.
rc = ERROR_EXEC_EACCES;
break;
case EACCES: // The specified file has a locking or sharing violation.
rc = ERROR_EXEC_EACCES;
break;
case EINVAL: // Invalid parameter.
rc = ERROR_EXEC_EINVAL;
break;
case EINVAL: // Invalid parameter.
rc = ERROR_EXEC_EINVAL;
break;
case EMFILE: // Too many files open (the specified file must be opened to determine whether it is executable).
rc = ERROR_EXEC_EMFILE;
break;
case EMFILE: // Too many files open (the specified file must be opened to determine whether it is executable).
rc = ERROR_EXEC_EMFILE;
break;
case ENOENT: // The file or path not found.
rc = ERROR_EXEC_ENOENT;
break;
case ENOENT: // The file or path not found.
rc = ERROR_EXEC_ENOENT;
break;
case ENOEXEC: // The specified file is not executable or has an invalid executable-file format.
rc = ERROR_EXEC_ENOEXEC;
break;
case ENOEXEC: // The specified file is not executable or has an invalid executable-file format.
rc = ERROR_EXEC_ENOEXEC;
break;
case ENOMEM: // Not enough memory is available to execute the new process; the available memory has been
// corrupted; or an invalid block exists, indicating that the calling process was not allocated
// properly.
rc = ERROR_EXEC_ENOMEM;
break;
case ENOMEM: // Not enough memory is available to execute the new process; the available memory has been
// corrupted; or an invalid block exists, indicating that the calling process was not allocated
// properly.
rc = ERROR_EXEC_ENOMEM;
break;
default:
rc = ERROR_EXEC_UNKNOWN;
break;
}
}
default:
rc = ERROR_EXEC_UNKNOWN;
break;
}
}
fwprintf(G_pf, L"ExecuteCommand returning %d\n", rc);
return rc;
//fwprintf(G_pf, L"ExecuteCommand returning %d\n", rc);
return rc;
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -30,347 +30,349 @@ import java.util.*;
*/
public class DeleteFile
{
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_BAD_FILE_PARAM = -2;
final static int ERROR_IO_EXCEPTION = -3;
final static int ERROR_FILE_PARAM_REPEATED = -4;
final static int ERROR_FILTER_PARAM_REPEATED = -5;
final static int ERROR_UNKNOWN_PARAMETER = -6;
final static int ERROR_MISSING_FILE_PARAM = -7;
final static int ERROR_FILTER_ON_NON_DIRECTORY = -8;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -9;;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_BAD_FILE_PARAM = -2;
final static int ERROR_IO_EXCEPTION = -3;
final static int ERROR_FILE_PARAM_REPEATED = -4;
final static int ERROR_FILTER_PARAM_REPEATED = -5;
final static int ERROR_UNKNOWN_PARAMETER = -6;
final static int ERROR_MISSING_FILE_PARAM = -7;
final static int ERROR_FILTER_ON_NON_DIRECTORY = -8;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -9;;
final static String FILE_KEY = "file=";
final static String FILTER_KEY = "filter=";
final static String FILE_KEY = "file=";
final static String FILTER_KEY = "filter=";
RandomAccessFile raf;
int rc;
String sFile;
String sFilter;
//RandomAccessFile raf;
int rc;
String sFile;
String sFilter;
public static void main(String[] args)
{
DeleteFile p = new DeleteFile(args);
System.exit(p.rc);
}
public static void main(String[] args)
{
DeleteFile p = new DeleteFile(args);
System.exit(p.rc);
}
DeleteFile(String[] args)
{
rc = ERROR_NO_ERROR;
sFile = null;
sFilter = null;
DeleteFile(String[] args)
{
rc = ERROR_NO_ERROR;
sFile = null;
sFilter = null;
try
{
raf = new RandomAccessFile(new File("c:\\test8.log"), "rw");
raf.seek(raf.length());
try
{
//raf = new RandomAccessFile(new File("c:\\test8.log"), "rw");
//raf.seek(raf.length());
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
rc = doDelete();
}
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
rc = doDelete();
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
raf.close();
}
catch (Exception e1)
{
}
}
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
//raf.close();
}
catch (Exception e1)
{
}
}
}
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (args.length < 1)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (args.length < 1)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("arg[" + i + "] = " +args[i]);
log("arg[" + i + "] = " +args[i]);
// is this the file to delete param?
if (args[i].startsWith(FILE_KEY))
{
// Have we already processed a file paramter?
if (null != sFile)
{
return ERROR_FILE_PARAM_REPEATED;
}
// is this the file to delete param?
if (args[i].startsWith(FILE_KEY))
{
// Have we already processed a file paramter?
if (null != sFile)
{
return ERROR_FILE_PARAM_REPEATED;
}
// Make sure it is more the param tag
if (args[i].length() <= FILE_KEY.length())
{
return ERROR_BAD_FILE_PARAM;
}
// Make sure it is more the param tag
if (args[i].length() <= FILE_KEY.length())
{
return ERROR_BAD_FILE_PARAM;
}
sFile = args[i].substring(FILE_KEY.length()).trim();
}
sFile = args[i].substring(FILE_KEY.length()).trim();
}
// is this the filter param?
else if (args[i].startsWith(FILTER_KEY))
{
// Have we already processed a filter paramter?
if (null != sFilter)
{
return ERROR_FILTER_PARAM_REPEATED;
}
// is this the filter param?
else if (args[i].startsWith(FILTER_KEY))
{
// Have we already processed a filter paramter?
if (null != sFilter)
{
return ERROR_FILTER_PARAM_REPEATED;
}
// Make sure it is more than the param tag
if (args[i].length() <= FILTER_KEY.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
// Make sure it is more than the param tag
if (args[i].length() <= FILTER_KEY.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
sFilter = args[i].substring(FILTER_KEY.length()).trim();
}
sFilter = args[i].substring(FILTER_KEY.length()).trim();
}
// Handle additional parameters
else
{
return ERROR_UNKNOWN_PARAMETER;
}
}
// Handle additional parameters
else
{
return ERROR_UNKNOWN_PARAMETER;
}
}
// Make sure we got a file
if (null == sFile)
{
return ERROR_MISSING_FILE_PARAM;
}
// Make sure we got a file
if (null == sFile)
{
return ERROR_MISSING_FILE_PARAM;
}
// Note: the filter parameter is optional, if present the file is assumed to be a directory
// Note: the filter parameter is optional, if present the file is assumed to be a directory
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int doDelete()
{
File file = new File(sFile);
int doDelete()
{
File file = new File(sFile);
log("Attempt to delete: " + sFile);
log("Attempt to delete: " + sFile);
// If the file is already gone - we are happy.
if (!file.exists())
{
log("File did not exist: " + sFile);
return ERROR_NO_ERROR;
}
// If the file is already gone - we are happy.
if (!file.exists())
{
log("File did not exist: " + sFile);
return ERROR_NO_ERROR;
}
// If a filter was passed in but the file is not a directory...
if (null != sFilter)
{
log("there is a filter: + sFilter");
// If a filter was passed in but the file is not a directory...
if (null != sFilter)
{
log("there is a filter: + sFilter");
// The file is not a directory - we wont try to apply the filter
if (!file.isDirectory())
{
log("file is not a directory");
return ERROR_FILTER_ON_NON_DIRECTORY;
}
// The file is not a directory - we wont try to apply the filter
if (!file.isDirectory())
{
log("file is not a directory");
return ERROR_FILTER_ON_NON_DIRECTORY;
}
// The file is a directory
else
{
log("file is a directory");
// Delete the children that match the template
deleteFiles(file);
// The file is a directory
else
{
log("file is a directory");
// Delete the children that match the template
deleteFiles(file);
// Attempt to delete the directory
deleteDirectory(file);
}
}
// Attempt to delete the directory
deleteDirectory(file);
}
}
else
{
if (!file.isDirectory())
{
log("Delete file: " + sFile);
file.delete();
}
else
{
if (!file.isDirectory())
{
log("Delete file: " + sFile);
file.delete();
}
else
{
deleteDirectory(file);
}
}
else
{
deleteDirectory(file);
}
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
void deleteFiles(File file)
{
File fileDelete;
int i;
void deleteFiles(File file)
{
File fileDelete;
int i;
log("attempting to delete file");
log("attempting to delete file");
// Get the children of this directory
File[] rgFile = file.listFiles(
new FileFilter()
{
public boolean accept(File f)
{
if (null == sFilter) return true;
log("file " + f.getName() + " matches filter " + sFilter + " : " + (-1 != f.getName().indexOf(sFilter))) ;
return (-1 != f.getName().indexOf(sFilter));
}
});
// Get the children of this directory
File[] rgFile = file.listFiles(
new FileFilter()
{
public boolean accept(File f)
{
if (null == sFilter) return true;
log("file " + f.getName() + " matches filter " + sFilter + " : " + (-1 != f.getName().indexOf(sFilter))) ;
return (-1 != f.getName().indexOf(sFilter));
}
});
log(file.getAbsolutePath() + " has " + rgFile.length + " children that match the filter: " + sFilter);
log(file.getAbsolutePath() + " has " + rgFile.length + " children that match the filter: " + sFilter);
// Attempt to delete each child file
for (i = 0; i < rgFile.length; i++)
{
if (rgFile[i].isDirectory())
{
deleteDirectory(rgFile[i]);
}
else
{
log("Delete file: " + rgFile[i].getAbsolutePath());
rgFile[i].delete();
}
}
}
// Attempt to delete each child file
for (i = 0; i < rgFile.length; i++)
{
if (rgFile[i].isDirectory())
{
deleteDirectory(rgFile[i]);
}
else
{
log("Delete file: " + rgFile[i].getAbsolutePath());
rgFile[i].delete();
}
}
}
void deleteDirectory(File file)
{
File fileDelete;
int i;
void deleteDirectory(File file)
{
File fileDelete;
int i;
log("Delete directory: " + file.getAbsolutePath());
log("Delete directory: " + file.getAbsolutePath());
// Get the children of this directory
File[] rgFile = file.listFiles();
// Get the children of this directory
File[] rgFile = file.listFiles();
log(file.getAbsolutePath() + " has " + rgFile.length + " children");
log(file.getAbsolutePath() + " has " + rgFile.length + " children");
// Delete empty child directories
for (i = 0; i < rgFile.length; i++)
{
if (rgFile[i].isDirectory())
{
deleteDirectory(rgFile[i]);
}
}
// Delete empty child directories
for (i = 0; i < rgFile.length; i++)
{
if (rgFile[i].isDirectory())
{
deleteDirectory(rgFile[i]);
}
}
// Delete this directory if it is empty
rgFile = file.listFiles();
if (rgFile.length == 0)
{
log("Delete file: " + file.getAbsolutePath());
file.delete();
}
}
// Delete this directory if it is empty
rgFile = file.listFiles();
if (rgFile.length == 0)
{
log("Delete file: " + file.getAbsolutePath());
file.delete();
}
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 1 expected";
break;
case ERROR_BAD_FILE_PARAM:
sMessage = "Bad file parameter";
break;
case ERROR_FILE_PARAM_REPEATED:
sMessage = "File parameter repeated";
break;
case ERROR_FILTER_PARAM_REPEATED:
sMessage = "Filter parameter repeated";
break;
case ERROR_UNKNOWN_PARAMETER:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_FILE_PARAM:
sMessage = "Missing file parameter";
break;
case ERROR_FILTER_ON_NON_DIRECTORY:
sMessage = "Filter parameter of non-directory file";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 1 expected";
break;
case ERROR_BAD_FILE_PARAM:
sMessage = "Bad file parameter";
break;
case ERROR_FILE_PARAM_REPEATED:
sMessage = "File parameter repeated";
break;
case ERROR_FILTER_PARAM_REPEATED:
sMessage = "Filter parameter repeated";
break;
case ERROR_UNKNOWN_PARAMETER:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_FILE_PARAM:
sMessage = "Missing file parameter";
break;
case ERROR_FILTER_ON_NON_DIRECTORY:
sMessage = "Filter parameter of non-directory file";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Greg Richardson
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -68,9 +68,9 @@ public class InitConfigFile
FileInputStream fisProperties;
File fileTemplate;
File fileOutput;
File file;
//File file;
//FileWriter fw;
RandomAccessFile raf;
//RandomAccessFile raf;
String[] rgsSearchFor;
String[] rgsReplaceWith;
String sInstallDir;
@ -97,22 +97,21 @@ public class InitConfigFile
try
{
file = new File("c:\\test.log");
//file = new File("c:\\test.log");
//fw = new FileWriter(file);
raf = new RandomAccessFile(file, "rw");
raf.seek(raf.length());
//raf = new RandomAccessFile(file, "rw");
//raf.seek(raf.length());
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Process the properties
if (ERROR_NO_ERROR == (rc = processProperties()))
{
rc = createOutputFile();
}
// Process the properties
if (ERROR_NO_ERROR == (rc = processProperties()))
{
rc = createOutputFile();
}
}
}
catch (IOException e)
{
@ -123,7 +122,7 @@ public class InitConfigFile
try
{
log(rc, " " + sOutput + "\n\n\n");
raf.close();
//raf.close();
}
catch (Exception e1)
{
@ -279,7 +278,7 @@ public class InitConfigFile
String value = args[i].substring(ESCAPE_PATH_CHARS.length()).trim();
if (value.equalsIgnoreCase("true"))
{
escapePathCharsInReplaceString = true;
escapePathCharsInReplaceString = true;
}
}
@ -408,7 +407,7 @@ public class InitConfigFile
{
log("replacing " + rgsSearchFor[i] + " at position " + iSearchFor + " with " + rgsReplaceWith[i]);
sLineOutput = sLineOutput.substring(0, iSearchFor) + rgsReplaceWith[i] +
sLineOutput.substring(iSearchFor + rgsSearchFor[i].length());
sLineOutput.substring(iSearchFor + rgsSearchFor[i].length());
}
}
try
@ -531,6 +530,7 @@ public class InitConfigFile
void log(String s)
{
/*
try
{
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
@ -538,5 +538,6 @@ public class InitConfigFile
catch (IOException ioe)
{
}
*/
}
}

View File

@ -48,8 +48,8 @@ public class MungeCryptoPropertiesFilePath
File fileInput;
File fileOutput;
File file;
FileWriter fw;
//File file;
//FileWriter fw;
String sInput;
String sOutput;
int rc;
@ -69,8 +69,8 @@ public class MungeCryptoPropertiesFilePath
try
{
file = new File("c:\\test5.log");
fw = new FileWriter(file);
//file = new File("c:\\test5.log");
//fw = new FileWriter(file);
log("Here we go: " + args.length);
for (int i = 0; i < args.length; i++)
@ -84,7 +84,6 @@ public class MungeCryptoPropertiesFilePath
// Process the file
rc = createOutputFile();
}
}
catch (IOException e)
{
@ -95,8 +94,8 @@ public class MungeCryptoPropertiesFilePath
try
{
log(rc);
fw.flush();
fw.close();
//fw.flush();
//fw.close();
}
catch (Exception e1)
{
@ -235,7 +234,7 @@ public class MungeCryptoPropertiesFilePath
{
log("replacing \\ at position " + iSearchFor + " with //");
sLineOutput = sLineOutput.substring(0, iSearchFor) + "//" +
sLineOutput.substring(iSearchFor + 1);
sLineOutput.substring(iSearchFor + 1);
}
}
try
@ -278,43 +277,33 @@ public class MungeCryptoPropertiesFilePath
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 2 expected";
break;
case ERROR_MISSING_INPUT_FILE:
sMessage = "Missing input file";
break;
case ERROR_OUTPUT_COPY_FAILED:
sMessage = "Unable to create output file";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException";
break;
case ERROR_BAD_INPUT_FILE_PARAM:
sMessage = "Invalid input file parameter";
break;
case ERROR_BAD_OUTPUT_FILE_PARAM:
sMessage = "Invalid output file parameter";
break;
case ERROR_MISSING_INPUT_FILE_PARAM:
sMessage = "Missing input file parameter";
break;
case ERROR_MISSING_OUTPUT_FILE_PARAM:
sMessage = "Missing output file parameter";
break;
case ERROR_CANNOT_READ_FILE:
sMessage = "Cannot read file";
break;
case ERROR_CANNOT_CREATE_FILE:
sMessage = "Cannot create file";
break;
default:
sMessage = "Unknown error: " + err;
break;
@ -329,6 +318,7 @@ public class MungeCryptoPropertiesFilePath
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
@ -336,5 +326,6 @@ public class MungeCryptoPropertiesFilePath
catch (IOException ioe)
{
}
*/
}
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -27,382 +27,384 @@ import java.util.*;
public class ServerKeystoreSetup
{
final static int ERROR_NO_ERROR = 0;
final static int ERROR_EXEC_FAILED = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
final static int ERROR_UNKNOWN_PARAM = -9;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
final static int ERROR_EXEC_INTERRUPTED = -12;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_EXEC_FAILED = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
final static int ERROR_UNKNOWN_PARAM = -9;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
final static int ERROR_EXEC_INTERRUPTED = -12;
final static int ERROR_IO_EXCEPTION = -13;
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
String sInstallDir;
Properties properties;
int rc;
String sInstallDir;
Properties properties;
int rc;
// debug stuff
File file;
FileWriter fw;
// debug stuff
//File file;
//FileWriter fw;
public static void main(String[] args)
{
ServerKeystoreSetup p = new ServerKeystoreSetup(args);
System.exit(p.rc);
}
public static void main(String[] args)
{
ServerKeystoreSetup p = new ServerKeystoreSetup(args);
System.exit(p.rc);
}
ServerKeystoreSetup(String[] args)
{
rc = ERROR_NO_ERROR;
try
{
// DEBUG STUFF
file = new File("c:\\test2.log");
fw = new FileWriter(file);
ServerKeystoreSetup(String[] args)
{
rc = ERROR_NO_ERROR;
try
{
// DEBUG STUFF
//file = new File("c:\\test2.log");
//fw = new FileWriter(file);
// Process the input params
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Make sure we got everything we need
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
{
// Make sure the server keystore has been created
rc = createServerKeystore();
}
}
// Process the input params
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Make sure we got everything we need
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
{
// Make sure the server keystore has been created
rc = createServerKeystore();
}
}
// DEBUG STUFF
log(rc);
fw.flush();
fw.close();
// DEBUG STUFF
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
}
// DEBUG STUFF
log(rc);
//fw.flush();
//fw.close();
// DEBUG STUFF
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
}
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
File fileProperties = null;
FileInputStream fisProperties = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
File fileProperties = null;
FileInputStream fisProperties = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i] + "\r\n");
}
for (i = 0; i <= iNew; i++)
{
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
for (i = 0; i <= iNew; i++)
{
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE))
{
// Make sure it is more the the param tag
if (args[i].length() <= PROPERTY_FILE.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE))
{
// Make sure it is more the the param tag
if (args[i].length() <= PROPERTY_FILE.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
fileProperties = new File(sProperties);
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
fileProperties = new File(sProperties);
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties = new Properties();
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties = new Properties();
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Unknown parameter
else
{
log(ERROR_UNKNOWN_PARAM, args[i]);
return ERROR_UNKNOWN_PARAM;
}
}
// Unknown parameter
else
{
log(ERROR_UNKNOWN_PARAM, args[i]);
return ERROR_UNKNOWN_PARAM;
}
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int findRequiredValues()
{
String[] rgsRequired = {
"ATS_JAVA_HOME",
"COMPUTERNAME"};
int i;
String sValue;
int findRequiredValues()
{
String[] rgsRequired = {
"ATS_JAVA_HOME",
"COMPUTERNAME"};
int i;
String sValue;
for (i = 0; i < rgsRequired.length; i++)
{
log("look for required value: " + rgsRequired[i]);
for (i = 0; i < rgsRequired.length; i++)
{
log("look for required value: " + rgsRequired[i]);
if (!properties.containsKey(rgsRequired[i]))
{
log("look for required value in envirement: " + rgsRequired[i]);
if (null == (sValue = System.getProperty(rgsRequired[i])))
{
log("unable to find required value in envirement: " + rgsRequired[i]);
return ERROR_REQUIRED_VALUE_MISSING;
}
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
properties.put(rgsRequired[i], sValue);
}
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
}
return ERROR_NO_ERROR;
}
if (!properties.containsKey(rgsRequired[i]))
{
log("look for required value in envirement: " + rgsRequired[i]);
if (null == (sValue = System.getProperty(rgsRequired[i])))
{
log("unable to find required value in envirement: " + rgsRequired[i]);
return ERROR_REQUIRED_VALUE_MISSING;
}
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
properties.put(rgsRequired[i], sValue);
}
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
}
return ERROR_NO_ERROR;
}
int createServerKeystore()
{
int rc;
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
String sHost = (String)properties.get("COMPUTERNAME");
int createServerKeystore()
{
int rc;
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
String sHost = (String)properties.get("COMPUTERNAME");
log("keytool = " + sKeytool);
log("host = " + sHost);
log("keytool = " + sKeytool);
log("host = " + sHost);
// Do not do anything if the server keystore has already been created
if (keyStoreAlreadyExists())
{
return ERROR_NO_ERROR;
}
// Do not do anything if the server keystore has already been created
if (keyStoreAlreadyExists())
{
return ERROR_NO_ERROR;
}
// Create the server keystore with the key that will be used for signing tokens
if (ERROR_NO_ERROR == (rc =invokeCommand(sKeytool + " -genkey -alias signingKey -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=casaatsd@" + sHost +
"\" -validity 3600 -keypass secret -storepass secret")))
{
// Export self-signed certificate for the signing key
if (ERROR_NO_ERROR == (rc = invokeCommand(sKeytool + " -export -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -alias signingKey -storepass secret -keypass secret -file " +
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert")))
{
// Create a key for Tomcat to do SSL communications
rc = invokeCommand(sKeytool + " -genkey -alias tomcat -keyalg RSA -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=" +
sHost + "\" -validity 3600 -keypass secret -storepass secret");
}
}
return rc;
}
// Create the server keystore with the key that will be used for signing tokens
if (ERROR_NO_ERROR == (rc =invokeCommand(sKeytool + " -genkey -alias signingKey -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=casaatsd@" + sHost +
"\" -validity 3600 -keypass secret -storepass secret")))
{
// Export self-signed certificate for the signing key
if (ERROR_NO_ERROR == (rc = invokeCommand(sKeytool + " -export -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -alias signingKey -storepass secret -keypass secret -file " +
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert")))
{
// Create a key for Tomcat to do SSL communications
rc = invokeCommand(sKeytool + " -genkey -alias tomcat -keyalg RSA -keystore " +
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=" +
sHost + "\" -validity 3600 -keypass secret -storepass secret");
}
}
return rc;
}
boolean keyStoreAlreadyExists()
{
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\server\\jks-store");
boolean keyStoreAlreadyExists()
{
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\server\\jks-store");
// Why is this always returning true? exists() also always returns true.
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\server\\jks-store" + ") already exists = " + (file.isFile()));
// return (file.isFile());
// Why is this always returning true? exists() also always returns true.
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\server\\jks-store" + ") already exists = " + (file.isFile()));
// return (file.isFile());
File fileParent = fileKeystore.getParentFile();
String[] rgChildren = fileParent.list();
if (null != rgChildren)
{
for (int i = 0; i < rgChildren.length; i++)
{
log("child " + i + " = " + rgChildren[i]);
if ("jks-store".equals(rgChildren[i]))
{
return true;
}
}
}
File fileParent = fileKeystore.getParentFile();
String[] rgChildren = fileParent.list();
if (null != rgChildren)
{
for (int i = 0; i < rgChildren.length; i++)
{
log("child " + i + " = " + rgChildren[i]);
if ("jks-store".equals(rgChildren[i]))
{
return true;
}
}
}
return false;
}
return false;
}
int invokeCommand(String sCommand)
{
Process p;
int rc;
int invokeCommand(String sCommand)
{
Process p;
int rc;
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("Ioexception");
return ERROR_EXEC_FAILED;
}
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("Ioexception");
return ERROR_EXEC_FAILED;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_EXEC_FAILED:
sMessage = "Execute command failed ";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of params";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is bad";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install dir";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install dir is not a dir";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Invalid porperty file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Property file not found";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "Unable to read property file";
break;
case ERROR_UNKNOWN_PARAM:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is missing";
break;
case ERROR_REQUIRED_VALUE_MISSING:
sMessage = "Required value is missing ";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Execution iinterrupted: ";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IO Exception ";
break;
default:
sMessage = "Unknown error";
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_EXEC_FAILED:
sMessage = "Execute command failed ";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of params";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is bad";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install dir";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install dir is not a dir";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Invalid porperty file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Property file not found";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "Unable to read property file";
break;
case ERROR_UNKNOWN_PARAM:
sMessage = "Unknown parameter: ";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Install dir parameter is missing";
break;
case ERROR_REQUIRED_VALUE_MISSING:
sMessage = "Required value is missing ";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Execution iinterrupted: ";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IO Exception ";
break;
default:
sMessage = "Unknown error";
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -30,482 +30,484 @@ import java.util.*;
*/
public class SetupAsWindowsService
{
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_EXEC_FAILED = -2;
final static int ERROR_EXEC_INTERRUPTED = -3;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
final static int ERROR_MISSING_INSTALL_DIR = -18;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
final static int ERROR_BAD_PROPERTY_PARAM = -29;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_EXEC_FAILED = -2;
final static int ERROR_EXEC_INTERRUPTED = -3;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
final static int ERROR_MISSING_INSTALL_DIR = -18;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
final static int ERROR_BAD_PROPERTY_PARAM = -29;
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
final static String PROPERTY_FILE_PARAM = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
final static String PROPERTY_FILE_PARAM = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
Properties properties;
File fileProperties;
FileInputStream fisProperties;
File fileOutput;
File file;
FileWriter fw;
String sInstallDir;
String sOutput;
int rc;
Properties properties;
File fileProperties;
FileInputStream fisProperties;
File fileOutput;
//File file;
//FileWriter fw;
String sInstallDir;
String sOutput;
int rc;
public static void main(String[] args)
{
SetupAsWindowsService p = new SetupAsWindowsService(args);
System.exit(p.rc);
}
public static void main(String[] args)
{
SetupAsWindowsService p = new SetupAsWindowsService(args);
System.exit(p.rc);
}
SetupAsWindowsService(String[] args)
{
rc = ERROR_NO_ERROR;
SetupAsWindowsService(String[] args)
{
rc = ERROR_NO_ERROR;
properties = new Properties();
fileProperties = null;
fisProperties = null;
fileOutput = null;
properties = new Properties();
fileProperties = null;
fisProperties = null;
fileOutput = null;
try
{
file = new File("c:\\test6.log");
fw = new FileWriter(file);
try
{
//file = new File("c:\\test6.log");
//fw = new FileWriter(file);
// Process the arguments
log("Process args");
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Process the properties
log("Process properties");
if (ERROR_NO_ERROR == (rc = processProperties()))
{
log("setupService");
rc = setupService();
}
}
// Process the arguments
log("Process args");
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Process the properties
log("Process properties");
if (ERROR_NO_ERROR == (rc = processProperties()))
{
log("setupService");
rc = setupService();
}
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
fw.flush();
fw.close();
}
catch (Exception e1)
{
}
}
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
//fw.flush();
//fw.close();
}
catch (Exception e1)
{
}
}
}
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("arg[" + i + "] = " +args[i]);
log("arg[" + i + "] = " +args[i]);
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
}
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
fileProperties = new File(sProperties);
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
fileProperties = new File(sProperties);
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Handle additional parameters
else
{
if (-1 == (iEquals = args[i].indexOf("=")) ||
0 == iEquals ||
args[i].length() == iEquals)
{
return ERROR_BAD_PROPERTY_PARAM;
}
sKey = args[i].substring(0, iEquals);
sValue = args[i].substring(iEquals + 1);
properties.setProperty(sKey, sValue);
}
}
// Handle additional parameters
else
{
if (-1 == (iEquals = args[i].indexOf("=")) ||
0 == iEquals ||
args[i].length() == iEquals)
{
return ERROR_BAD_PROPERTY_PARAM;
}
sKey = args[i].substring(0, iEquals);
sValue = args[i].substring(iEquals + 1);
properties.setProperty(sKey, sValue);
}
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Note: the properties file parameter is optional
return ERROR_NO_ERROR;
}
// Note: the properties file parameter is optional
return ERROR_NO_ERROR;
}
int processProperties()
{
try
{
Enumeration e;
String sKey;
String sValue;
int processProperties()
{
try
{
Enumeration e;
String sKey;
String sValue;
e = properties.propertyNames();
e = properties.propertyNames();
while (e.hasMoreElements())
{
sKey = (String)e.nextElement();
sValue = (String)properties.get(sKey);
while (e.hasMoreElements())
{
sKey = (String)e.nextElement();
sValue = (String)properties.get(sKey);
log("Property key = " + sKey + " Value = " + sValue);
}
}
catch (Exception ex1)
{
return -111;
}
log("Property key = " + sKey + " Value = " + sValue);
}
}
catch (Exception ex1)
{
return -111;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int setupService()
{
String sDirInstall = (String)properties.get(INSTALL_DIR_PROPERTY);
String sDirCatalinaBase = sInstallDir + "ats/catalinabase";
String sDirCatalinaHome = (String)properties.get("TOMCAT_HOME");
String sExe = (String)properties.get("TOMCAT5");
String sFileJaasConf = (String)properties.get("JAAS_CONF");
String sDirConfig = sDirInstall + "ats/etc/svc";
String sDirJavaHome = (String)properties.get("ATS_JAVA_HOME");
String sLogPrefix = "casa-auth-token-svc";
String sDirLogs = sDirCatalinaBase + "/logs";
String sCommand = "";
int iReturn = ERROR_NO_ERROR;
int setupService()
{
String sDirInstall = (String)properties.get(INSTALL_DIR_PROPERTY);
String sDirCatalinaBase = sInstallDir + "ats/catalinabase";
String sDirCatalinaHome = (String)properties.get("TOMCAT_HOME");
String sExe = (String)properties.get("TOMCAT5");
String sFileJaasConf = (String)properties.get("JAAS_CONF");
String sDirConfig = sDirInstall + "ats/etc/svc";
String sDirJavaHome = (String)properties.get("ATS_JAVA_HOME");
String sLogPrefix = "casa-auth-token-svc";
String sDirLogs = sDirCatalinaBase + "/logs";
String sCommand = "";
int iReturn = ERROR_NO_ERROR;
sCommand = sExe + " //IS//CasaAuthTokenService --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //IS//CasaAuthTokenService --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Startup auto";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Startup auto";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --JvmOptions \"-Dcatalina.base=" + sDirCatalinaBase + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --JvmOptions \"-Dcatalina.base=" + sDirCatalinaBase + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcatalina.home=" + sDirCatalinaHome + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcatalina.home=" + sDirCatalinaHome + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.endorsed.dirs=" + sDirCatalinaHome + "/common/endorsed\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.endorsed.dirs=" + sDirCatalinaHome + "/common/endorsed\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.security.auth.login.config=" + sFileJaasConf + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.security.auth.login.config=" + sFileJaasConf + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcom.novell.casa.authtoksvc.config=" + sDirConfig + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcom.novell.casa.authtoksvc.config=" + sDirConfig + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dlog4j.configuration=file:" + sDirInstall + "/ats/etc/log4j.properties";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dlog4j.configuration=file:" + sDirInstall + "/ats/etc/log4j.properties";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.io.tmpdir=" + sDirCatalinaBase+ "/temp\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.io.tmpdir=" + sDirCatalinaBase+ "/temp\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StartMode jvm --StopMode jvm";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StartMode jvm --StopMode jvm";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --JvmMs 128 --JvmMx 512";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --JvmMs 128 --JvmMx 512";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Classpath \"" + sDirCatalinaHome + "/bin/bootstrap.jar\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Classpath \"" + sDirCatalinaHome + "/bin/bootstrap.jar\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Jvm \"" + sDirJavaHome + "/jre/bin/server/jvm.dll\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Jvm \"" + sDirJavaHome + "/jre/bin/server/jvm.dll\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --LogPath \"" + sDirLogs + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --LogPath \"" + sDirLogs + "\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --LogPrefix \"" + sLogPrefix + "_service.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --LogPrefix \"" + sLogPrefix + "_service.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StdOutput \"" + sDirLogs +
File.separator + sLogPrefix + "_stdout.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StdOutput \"" + sDirLogs +
File.separator + sLogPrefix + "_stdout.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StdError \"" + sDirLogs +
File.separator + sLogPrefix + "_stderr.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --StdError \"" + sDirLogs +
File.separator + sLogPrefix + "_stderr.log\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --DisplayName " + "CasaAuthTokenSvc";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --DisplayName " + "CasaAuthTokenSvc";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Description " + "\"Casa Authentication Token Service\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //US//CasaAuthTokenService --Description " + "\"Casa Authentication Token Service\"";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int invokeCommand(String sCommand)
{
Process p;
int rc;
int invokeCommand(String sCommand)
{
Process p;
int rc;
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("IOException");
return ERROR_EXEC_FAILED;
}
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("IOException");
return ERROR_EXEC_FAILED;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 4 expected";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException";
break;
case ERROR_EXEC_FAILED:
sMessage = "Exec failed";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Exec interrupted";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "nable to read properties";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install directory";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install directory is not a directory";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Bad install directory parameter";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Missing properties file";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Missing install directory parameter";
break;
case ERROR_MISSING_PROPERTY_FILE_PARAM:
sMessage = "Missing property file parameter";
break;
case ERROR_BAD_PROPERTY_PARAM:
sMessage = "Bad property parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 4 expected";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException";
break;
case ERROR_EXEC_FAILED:
sMessage = "Exec failed";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Exec interrupted";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "nable to read properties";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install directory";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install directory is not a directory";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Bad install directory parameter";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Missing properties file";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Missing install directory parameter";
break;
case ERROR_MISSING_PROPERTY_FILE_PARAM:
sMessage = "Missing property file parameter";
break;
case ERROR_BAD_PROPERTY_PARAM:
sMessage = "Bad property parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -30,368 +30,370 @@ import java.util.*;
*/
public class ShutdownWindowsService
{
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_EXEC_FAILED = -2;
final static int ERROR_EXEC_INTERRUPTED = -3;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
final static int ERROR_MISSING_INSTALL_DIR = -18;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
final static int ERROR_BAD_PROPERTY_PARAM = -29;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
final static int ERROR_EXEC_FAILED = -2;
final static int ERROR_EXEC_INTERRUPTED = -3;
final static int ERROR_IO_EXCEPTION = -13;
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
final static int ERROR_MISSING_INSTALL_DIR = -18;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
final static int ERROR_BAD_PROPERTY_PARAM = -29;
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
final static String PROPERTY_FILE_PARAM = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
final static String PROPERTY_FILE_PARAM = "propertyfile=";
final static String INSTALL_DIR = "installdir=";
final static String PROPERTY_FILE = "propertyfile=";
Properties properties;
File fileProperties;
FileInputStream fisProperties;
File fileOutput;
File file;
FileWriter fw;
String sInstallDir;
String sOutput;
int rc;
Properties properties;
File fileProperties;
FileInputStream fisProperties;
File fileOutput;
//File file;
//FileWriter fw;
String sInstallDir;
String sOutput;
int rc;
public static void main(String[] args)
{
ShutdownWindowsService p = new ShutdownWindowsService(args);
System.exit(ERROR_NO_ERROR);
}
public static void main(String[] args)
{
ShutdownWindowsService p = new ShutdownWindowsService(args);
System.exit(ERROR_NO_ERROR);
}
ShutdownWindowsService(String[] args)
{
rc = ERROR_NO_ERROR;
ShutdownWindowsService(String[] args)
{
rc = ERROR_NO_ERROR;
properties = new Properties();
fileProperties = null;
fisProperties = null;
fileOutput = null;
properties = new Properties();
fileProperties = null;
fisProperties = null;
fileOutput = null;
try
{
file = new File("c:\\test7.log");
fw = new FileWriter(file);
try
{
//file = new File("c:\\test7.log");
//fw = new FileWriter(file);
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Process the properties
if (ERROR_NO_ERROR == (rc = processProperties()))
{
rc = shutdownService();
}
}
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Process the properties
if (ERROR_NO_ERROR == (rc = processProperties()))
{
rc = shutdownService();
}
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
fw.flush();
fw.close();
}
catch (Exception e1)
{
}
}
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
//fw.flush();
//fw.close();
}
catch (Exception e1)
{
}
}
}
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
String sProperties;
File fileInstallDir = null;
int iEquals;
String sKey;
String sValue;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (args.length < 2)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
if (null == args[i])
{
continue;
}
log("arg[" + i + "] = " +args[i]);
log("arg[" + i + "] = " +args[i]);
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR))
{
// Make sure it is more the the param tag
if (args[i].length() <= INSTALL_DIR.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
fileInstallDir = new File(sInstallDir);
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
}
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
// is this the properties file param?
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
{
return ERROR_BAD_PROPERTY_FILE_PARAM;
}
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
fileProperties = new File(sProperties);
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
fileProperties = new File(sProperties);
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Make sure the properties file can be found
if (!fileProperties.exists())
{
return ERROR_MISSING_PROPERTIES_FILE;
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Read the properties
try
{
fisProperties = new FileInputStream(fileProperties);
properties.load(fisProperties);
}
catch (IOException ioe)
{
return ERROR_UNABLE_TO_READ_PROPERTIES;
}
}
// Handle additional parameters
else
{
if (-1 == (iEquals = args[i].indexOf("=")) ||
0 == iEquals ||
args[i].length() == iEquals)
{
return ERROR_BAD_PROPERTY_PARAM;
}
sKey = args[i].substring(0, iEquals);
sValue = args[i].substring(iEquals + 1);
properties.setProperty(sKey, sValue);
}
}
// Handle additional parameters
else
{
if (-1 == (iEquals = args[i].indexOf("=")) ||
0 == iEquals ||
args[i].length() == iEquals)
{
return ERROR_BAD_PROPERTY_PARAM;
}
sKey = args[i].substring(0, iEquals);
sValue = args[i].substring(iEquals + 1);
properties.setProperty(sKey, sValue);
}
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Note: the properties file parameter is optional
// Note: the properties file parameter is optional
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int processProperties()
{
try
{
Enumeration e;
String sKey;
String sValue;
int processProperties()
{
try
{
Enumeration e;
String sKey;
String sValue;
e = properties.propertyNames();
e = properties.propertyNames();
while (e.hasMoreElements())
{
sKey = (String)e.nextElement();
sValue = (String)properties.get(sKey);
while (e.hasMoreElements())
{
sKey = (String)e.nextElement();
sValue = (String)properties.get(sKey);
log("Property key = " + sKey + " Value = " + sValue);
}
}
catch (Exception ex1)
{
return -111;
}
log("Property key = " + sKey + " Value = " + sValue);
}
}
catch (Exception ex1)
{
return -111;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int shutdownService()
{
String sExe = (String)properties.get("TOMCAT5");
String sCommand = "";
int iReturn = ERROR_NO_ERROR;
int shutdownService()
{
String sExe = (String)properties.get("TOMCAT5");
String sCommand = "";
int iReturn = ERROR_NO_ERROR;
sCommand = sExe + " //SS//CasaAuthTokenService";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //SS//CasaAuthTokenService";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //DS//CasaAuthTokenService";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
sCommand = sExe + " //DS//CasaAuthTokenService";
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
{
return iReturn;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int invokeCommand(String sCommand)
{
Process p;
int rc;
int invokeCommand(String sCommand)
{
Process p;
int rc;
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("IOException");
return ERROR_EXEC_FAILED;
}
log("invoke command: " + sCommand);
Runtime runtime = Runtime.getRuntime();
try
{
p = runtime.exec(sCommand);
try
{
rc = p.waitFor();
log("invoke command return code: " + rc);
}
catch (InterruptedException ie)
{
log(ERROR_EXEC_INTERRUPTED, sCommand);
return ERROR_EXEC_INTERRUPTED;
}
}
catch (IOException e)
{
log("IOException");
return ERROR_EXEC_FAILED;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 4 expected";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException";
break;
case ERROR_EXEC_FAILED:
sMessage = "Exec failed";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Exec interrupted";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "nable to read properties";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install directory";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install directory is not a directory";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Bad install directory parameter";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Missing properties file";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Missing install directory parameter";
break;
case ERROR_MISSING_PROPERTY_FILE_PARAM:
sMessage = "Missing property file parameter";
break;
case ERROR_BAD_PROPERTY_PARAM:
sMessage = "Bad property parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 4 expected";
break;
case ERROR_IO_EXCEPTION:
sMessage = "IOException";
break;
case ERROR_EXEC_FAILED:
sMessage = "Exec failed";
break;
case ERROR_EXEC_INTERRUPTED:
sMessage = "Exec interrupted";
break;
case ERROR_UNABLE_TO_READ_PROPERTIES:
sMessage = "nable to read properties";
break;
case ERROR_MISSING_INSTALL_DIR:
sMessage = "Missing install directory";
break;
case ERROR_INSTALL_DIR_NOT_A_DIR:
sMessage = "Install directory is not a directory";
break;
case ERROR_BAD_INSTALL_DIR_PARAM:
sMessage = "Bad install directory parameter";
break;
case ERROR_BAD_PROPERTY_FILE_PARAM:
sMessage = "Bad property file parameter";
break;
case ERROR_MISSING_PROPERTIES_FILE:
sMessage = "Missing properties file";
break;
case ERROR_MISSING_INSTALL_DIR_PARAM:
sMessage = "Missing install directory parameter";
break;
case ERROR_MISSING_PROPERTY_FILE_PARAM:
sMessage = "Missing property file parameter";
break;
case ERROR_BAD_PROPERTY_PARAM:
sMessage = "Bad property parameter";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -18,7 +18,7 @@
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
* Author: Juan Carlos Luciani <jluciani@novell.com>
* Author: Greg Richardson <grichardson@novell.com>
*
***********************************************************************/
@ -36,403 +36,405 @@ import java.util.jar.*;
*/
public class UpdateWarFile
{
final static String INSTALL_DIR_PARAM = "ATS_INSTALL_DIR=";
final static String INSTALL_DIR_PARAM = "ATS_INSTALL_DIR=";
final static int ERROR_NO_ERROR = 0;
final static int ERROR_IO_EXCEPTION = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -6;
final static int ERROR_WAR_TEMPLATE_FILE_MISSING = -7;
final static int ERROR_NEW_JAR_CANNOT_BE_REPLACED = -8;
final static int ERROR_JAR_COPY_FAILED = -9;
final static int ERROR_CREATE_WAR_FILE_FAILED = -10;
final static int ERROR_CREATE_WAR_FOS_FAILED = -11;
final static int ERROR_OPEN_JAR_TEMPLATE_FAILED = -12;
final static int ERROR_JOS_FLUSH_FAILED = -13;
final static int ERROR_ADD_FILE_TO_JAR_FAILED = -14;
final static int ERROR_JOS_CLOSE_FAILED = -15;
final static int ERROR_FOS_CLOSE_FAILED = -16;
final static int ERROR_JFTEMPLATE_CLOSE_FAILED = -17;
final static int ERROR_NO_ERROR = 0;
final static int ERROR_IO_EXCEPTION = -1;
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
final static int ERROR_MISSING_INSTALL_DIR = -4;
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -6;
final static int ERROR_WAR_TEMPLATE_FILE_MISSING = -7;
final static int ERROR_NEW_JAR_CANNOT_BE_REPLACED = -8;
final static int ERROR_JAR_COPY_FAILED = -9;
final static int ERROR_CREATE_WAR_FILE_FAILED = -10;
final static int ERROR_CREATE_WAR_FOS_FAILED = -11;
final static int ERROR_OPEN_JAR_TEMPLATE_FAILED = -12;
final static int ERROR_JOS_FLUSH_FAILED = -13;
final static int ERROR_ADD_FILE_TO_JAR_FAILED = -14;
final static int ERROR_JOS_CLOSE_FAILED = -15;
final static int ERROR_FOS_CLOSE_FAILED = -16;
final static int ERROR_JFTEMPLATE_CLOSE_FAILED = -17;
String sInstallDir;
File file;
FileWriter fw;
int rc;
String sInstallDir;
//File file;
//FileWriter fw;
int rc;
public static void main(String[] args)
{
UpdateWarFile p = new UpdateWarFile(args);
System.exit(p.rc);
}
public static void main(String[] args)
{
UpdateWarFile p = new UpdateWarFile(args);
System.exit(p.rc);
}
UpdateWarFile(String[] args)
{
sInstallDir = null;
UpdateWarFile(String[] args)
{
sInstallDir = null;
try
{
file = new File("c:\\test3.log");
fw = new FileWriter(file);
try
{
//file = new File("c:\\test3.log");
//fw = new FileWriter(file);
log("Here we go: " + args.length);
for (int i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i]);
}
log("Here we go: " + args.length);
for (int i = 0; i < args.length; i++)
{
log("Arg " + i + " = " + args[i]);
}
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Create the modified war file
rc = createWarFile();
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
fw.flush();
fw.close();
}
catch (Exception e1)
{
}
}
}
// Process the arguments
if (ERROR_NO_ERROR == (rc = processArgs(args)))
{
// Create the modified war file
rc = createWarFile();
}
}
catch (IOException e)
{
rc = ERROR_IO_EXCEPTION;
}
finally
{
try
{
log(rc);
//fw.flush();
//fw.close();
}
catch (Exception e1)
{
}
}
}
int processArgs(String[] argsOld)
{
File fileInstallDir = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
int processArgs(String[] argsOld)
{
File fileInstallDir = null;
int iOld;
int i;
String args[] = new String[argsOld.length];
int iNew;
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
log("Original arg count " + argsOld.length);
for (i = 0; i < argsOld.length; i++)
{
log("Arg " + i + " = " + argsOld[i] + "\r\n");
}
// Validate the number of parameters
if (args.length < 1)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
// Validate the number of parameters
if (args.length < 1)
{
return ERROR_INVALID_NUMBER_OF_PARAMS;
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
iNew = -1;
for (iOld = 0; iOld < argsOld.length; iOld++)
{
if (0 <= argsOld[iOld].indexOf("="))
{
iNew++;
args[iNew] = argsOld[iOld];
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
{
args[iNew] += " " + argsOld[i];
}
}
}
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("arg[" + i + "] = " + args[i]);
log("New arg count " + args.length);
for (i = 0; i < args.length; i++)
{
log("arg[" + i + "] = " + args[i]);
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= INSTALL_DIR_PARAM.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
// is this the install dir param?
if (args[i].startsWith(INSTALL_DIR_PARAM))
{
// Make sure it is more than the param tag
if (args[i].length() <= INSTALL_DIR_PARAM.length())
{
return ERROR_BAD_INSTALL_DIR_PARAM;
}
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
fileInstallDir = new File(sInstallDir);
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
fileInstallDir = new File(sInstallDir);
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir can be found
if (!fileInstallDir.exists())
{
return ERROR_MISSING_INSTALL_DIR;
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
}
// Make sure the install dir is a directory
if (!fileInstallDir.isDirectory())
{
return ERROR_INSTALL_DIR_NOT_A_DIR;
}
}
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
// Make sure we got an install dir
if (null == fileInstallDir)
{
return ERROR_MISSING_INSTALL_DIR_PARAM;
}
return ERROR_NO_ERROR;
}
return ERROR_NO_ERROR;
}
int createWarFile()
{
String sWarTemplate = sInstallDir + "ats\\etc\\svc\\templates\\CasaAuthTokenSvc.war";
String sWarNew = sInstallDir + "ats\\catalinabase\\webapps\\CasaAuthTokenSvc.war";
File fileWarTemplate = new File(sWarTemplate);;
File fileWarNew = new File(sWarNew);
FileOutputStream fosWarNew = null;
ZipOutputStream josWarNew = null;
ZipFile jfTemplate = null;
int rc = ERROR_NO_ERROR;
int createWarFile()
{
String sWarTemplate = sInstallDir + "ats\\etc\\svc\\templates\\CasaAuthTokenSvc.war";
String sWarNew = sInstallDir + "ats\\catalinabase\\webapps\\CasaAuthTokenSvc.war";
File fileWarTemplate = new File(sWarTemplate);;
File fileWarNew = new File(sWarNew);
FileOutputStream fosWarNew = null;
ZipOutputStream josWarNew = null;
ZipFile jfTemplate = null;
int rc = ERROR_NO_ERROR;
// Ensure that the war template exists
log("looking for war template: " + sWarTemplate);
if (!fileWarTemplate.exists())
{
rc = ERROR_WAR_TEMPLATE_FILE_MISSING;
}
// Ensure that the war template exists
log("looking for war template: " + sWarTemplate);
if (!fileWarTemplate.exists())
{
rc = ERROR_WAR_TEMPLATE_FILE_MISSING;
}
if (rc == ERROR_NO_ERROR)
{
// Ensure that the new jar name does not exist
if (fileWarNew.exists())
{
log("war file already exists: " + sWarNew);
if (!fileWarNew.delete())
{
log("could not delete war file: " + sWarNew);
rc = ERROR_NEW_JAR_CANNOT_BE_REPLACED;
}
}
}
if (rc == ERROR_NO_ERROR)
{
// Ensure that the new jar name does not exist
if (fileWarNew.exists())
{
log("war file already exists: " + sWarNew);
if (!fileWarNew.delete())
{
log("could not delete war file: " + sWarNew);
rc = ERROR_NEW_JAR_CANNOT_BE_REPLACED;
}
}
}
if (rc == ERROR_NO_ERROR)
{
// Create/open the new jar
try
{
log("create new war file output stream: " + sWarNew);
fosWarNew = new FileOutputStream(fileWarNew);
josWarNew = new ZipOutputStream(fosWarNew);
}
catch (IOException ioe0)
{
log(ioe0.toString());
rc = ERROR_CREATE_WAR_FOS_FAILED;
}
}
if (rc == ERROR_NO_ERROR)
{
// Create/open the new jar
try
{
log("create new war file output stream: " + sWarNew);
fosWarNew = new FileOutputStream(fileWarNew);
josWarNew = new ZipOutputStream(fosWarNew);
}
catch (IOException ioe0)
{
log(ioe0.toString());
rc = ERROR_CREATE_WAR_FOS_FAILED;
}
}
if (rc == ERROR_NO_ERROR)
{
// Open the old jar
try
{
jfTemplate = new ZipFile(sWarTemplate);
}
catch (IOException ioe1)
{
rc = ERROR_OPEN_JAR_TEMPLATE_FAILED;
}
}
if (rc == ERROR_NO_ERROR)
{
// Open the old jar
try
{
jfTemplate = new ZipFile(sWarTemplate);
}
catch (IOException ioe1)
{
rc = ERROR_OPEN_JAR_TEMPLATE_FAILED;
}
}
if (rc == ERROR_NO_ERROR)
{
// Transfer the files
rc = moveFilesFromJarToJar(josWarNew, jfTemplate);
}
if (rc == ERROR_NO_ERROR)
{
// Transfer the files
rc = moveFilesFromJarToJar(josWarNew, jfTemplate);
}
// Add the files
if (rc == ERROR_NO_ERROR)
{
int i;
String [] rgsFilesToAdd = new String[1];
rgsFilesToAdd[0] = sInstallDir + "ats\\etc\\svc\\templates\\casa_crypto.properties";
String [] rgsNames = new String[1];
rgsNames[0] = "WEB-INF/classes/casa_crypto.properties";
for (i = 0; i < rgsFilesToAdd.length; i++)
{
log("Adding file: " + rgsFilesToAdd[i] + " with name " + rgsNames[i]);
rc = addFileToJar(rgsFilesToAdd[i], rgsNames[i], josWarNew);
}
}
// Add the files
if (rc == ERROR_NO_ERROR)
{
int i;
String [] rgsFilesToAdd = new String[1];
rgsFilesToAdd[0] = sInstallDir + "ats\\etc\\svc\\templates\\casa_crypto.properties";
String [] rgsNames = new String[1];
rgsNames[0] = "WEB-INF/classes/casa_crypto.properties";
for (i = 0; i < rgsFilesToAdd.length; i++)
{
log("Adding file: " + rgsFilesToAdd[i] + " with name " + rgsNames[i]);
rc = addFileToJar(rgsFilesToAdd[i], rgsNames[i], josWarNew);
}
}
// Close up
if (null != josWarNew)
{
try
{
josWarNew.flush();
}
catch (IOException ioe2)
{
rc = ERROR_JOS_FLUSH_FAILED;
}
try
{
josWarNew.close();
}
catch (IOException ioe3)
{
rc = ERROR_JOS_CLOSE_FAILED;
}
try
{
fosWarNew.close();
}
catch (IOException ioe4)
{
rc = ERROR_FOS_CLOSE_FAILED;
}
}
if (null != jfTemplate)
{
try
{
jfTemplate.close();
}
catch (IOException ioe5)
{
rc = ERROR_JFTEMPLATE_CLOSE_FAILED;
}
}
// Close up
if (null != josWarNew)
{
try
{
josWarNew.flush();
}
catch (IOException ioe2)
{
rc = ERROR_JOS_FLUSH_FAILED;
}
try
{
josWarNew.close();
}
catch (IOException ioe3)
{
rc = ERROR_JOS_CLOSE_FAILED;
}
try
{
fosWarNew.close();
}
catch (IOException ioe4)
{
rc = ERROR_FOS_CLOSE_FAILED;
}
}
if (null != jfTemplate)
{
try
{
jfTemplate.close();
}
catch (IOException ioe5)
{
rc = ERROR_JFTEMPLATE_CLOSE_FAILED;
}
}
return rc;
}
return rc;
}
int moveFilesFromJarToJar(ZipOutputStream josDst, ZipFile jfSrc)
{
int rc = ERROR_NO_ERROR;
try
{
Enumeration entries = jfSrc.entries();
ZipEntry jeLoop;
InputStream isLoop;
ZipEntry zeIndex;
int bRead;
byte [] b = new byte[4096];
int moveFilesFromJarToJar(ZipOutputStream josDst, ZipFile jfSrc)
{
int rc = ERROR_NO_ERROR;
try
{
Enumeration entries = jfSrc.entries();
ZipEntry jeLoop;
InputStream isLoop;
ZipEntry zeIndex;
int bRead;
byte [] b = new byte[4096];
while (entries.hasMoreElements())
{
jeLoop = (ZipEntry)entries.nextElement();
while (entries.hasMoreElements())
{
jeLoop = (ZipEntry)entries.nextElement();
// Skip WEB-INF/classes/cypto.properties
if (jeLoop.getName().equalsIgnoreCase("WEB-INF/classes/casa_crypto.properties"))
{
log("skipping: " + "WEB-INF/classes/casa_crypto.properties");
continue;
}
// Skip WEB-INF/classes/cypto.properties
if (jeLoop.getName().equalsIgnoreCase("WEB-INF/classes/casa_crypto.properties"))
{
log("skipping: " + "WEB-INF/classes/casa_crypto.properties");
continue;
}
// Move the rest of the files over
else
{
log("Transferring jar file: " + jeLoop.getName());
// Move the rest of the files over
else
{
log("Transferring jar file: " + jeLoop.getName());
// Create the input stream
isLoop = jfSrc.getInputStream(jeLoop);
// Create the input stream
isLoop = jfSrc.getInputStream(jeLoop);
// Set up the output stream
zeIndex = new ZipEntry(jeLoop.getName());
josDst.putNextEntry( zeIndex);
// Set up the output stream
zeIndex = new ZipEntry(jeLoop.getName());
josDst.putNextEntry( zeIndex);
// Transfer the file contents
while (-1 != (bRead = isLoop.read(b)))
{
josDst.write(b, 0, bRead);
}
// Transfer the file contents
while (-1 != (bRead = isLoop.read(b)))
{
josDst.write(b, 0, bRead);
}
// all done
josDst.closeEntry();
isLoop.close();
}
}
}
catch (Exception e)
{
rc = ERROR_JAR_COPY_FAILED;
}
return rc;
}
// all done
josDst.closeEntry();
isLoop.close();
}
}
}
catch (Exception e)
{
rc = ERROR_JAR_COPY_FAILED;
}
return rc;
}
int addFileToJar(String sFilename, String sName, ZipOutputStream josJarNew)
{
FileInputStream fis;
ZipEntry je;
int bRead;
byte [] b = new byte[4096];
int rc = ERROR_NO_ERROR;
int addFileToJar(String sFilename, String sName, ZipOutputStream josJarNew)
{
FileInputStream fis;
ZipEntry je;
int bRead;
byte [] b = new byte[4096];
int rc = ERROR_NO_ERROR;
try
{
// Create the input stream
fis = new FileInputStream(sFilename);
try
{
// Create the input stream
fis = new FileInputStream(sFilename);
// Set up the output stream
je = new ZipEntry(sName);
josJarNew.putNextEntry(je);
// Set up the output stream
je = new ZipEntry(sName);
josJarNew.putNextEntry(je);
// Tansfer the contents of the file
while (-1 != (bRead = fis.read(b)))
{
josJarNew.write(b, 0, bRead);
}
// Tansfer the contents of the file
while (-1 != (bRead = fis.read(b)))
{
josJarNew.write(b, 0, bRead);
}
// All done
fis.close();
josJarNew.closeEntry();
}
catch (Exception e)
{
log(e.toString());
rc = ERROR_ADD_FILE_TO_JAR_FAILED;
}
return rc;
}
// All done
fis.close();
josJarNew.closeEntry();
}
catch (Exception e)
{
log(e.toString());
rc = ERROR_ADD_FILE_TO_JAR_FAILED;
}
return rc;
}
void log(int err)
{
log(err, null);
}
void log(int err)
{
log(err, null);
}
void log(int err, String s)
{
String sMessage = "";
void log(int err, String s)
{
String sMessage = "";
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 1make expected";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
switch (err)
{
case ERROR_NO_ERROR:
sMessage = "No error";
break;
case ERROR_INVALID_NUMBER_OF_PARAMS:
sMessage = "Invalid number of parameters: 1make expected";
break;
default:
sMessage = "Unknown error: " + err;
break;
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
if (null != s)
{
sMessage = sMessage + s;
}
log(sMessage);
}
void log(String s)
{
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
}
void log(String s)
{
/*
try
{
fw.write(this.getClass().getName() + ": " + s + "\r\n");
}
catch (IOException ioe)
{
}
*/
}
}

View File

@ -111,6 +111,12 @@
}
"Entry"
{
"MsmKey" = "8:_55AF3B67412A49E3A568102FDADDC2FE"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_5B105FED430E4D998914B3562D4A8EA1"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@ -958,7 +964,7 @@
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\xercesImpl.jar"
"TargetName" = "8:xercesImpl.jar"
"Tag" = "8:"
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
@ -1113,6 +1119,26 @@
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_55AF3B67412A49E3A568102FDADDC2FE"
{
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\LICENSE"
"TargetName" = "8:LICENSE"
"Tag" = "8:"
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5B105FED430E4D998914B3562D4A8EA1"
{
"SourcePath" = "8:..\\UpdateWarFile\\bin\\UpdateWarFile.class"
@ -1218,7 +1244,7 @@
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\xmlsec-1.4.0.jar"
"TargetName" = "8:xmlsec-1.4.0.jar"
"Tag" = "8:"
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
@ -1278,7 +1304,7 @@
"SourcePath" = "8:..\\..\\..\\Svc\\external\\log4j\\logging-log4j-1.2.14\\dist\\lib\\log4j-1.2.14.jar"
"TargetName" = "8:log4j-1.2.14.jar"
"Tag" = "8:"
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
@ -1558,7 +1584,7 @@
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\commons-logging.jar"
"TargetName" = "8:commons-logging.jar"
"Tag" = "8:"
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
@ -1828,6 +1854,28 @@
"Property" = "8:_168E54D12032489796CD7A843225EE70"
"Folders"
{
"{9EF0B969-E518-4E46-987F-47570745A589}:_7638BAE158EC4759991B2FC04061FADC"
{
"Name" = "8:external"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_E580B31319AE4C55BC31CFF84AF8C6AE"
"Folders"
{
"{9EF0B969-E518-4E46-987F-47570745A589}:_7F0AE158BB53414DA5BB29F14E55EEBB"
{
"Name" = "8:apache.org"
"AlwaysCreate" = "11:FALSE"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Property" = "8:_B5D79599A831420BBDEBFD4FB0E2EA76"
"Folders"
{
}
}
}
}
}
}
"{9EF0B969-E518-4E46-987F-47570745A589}:_62B357DC6D484761A18291FA3525320C"