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:
parent
33a49c686a
commit
7a44908936
@ -6,291 +6,15 @@
|
|||||||
********************************************************************************
|
********************************************************************************
|
||||||
|
|
||||||
********************************************************************************
|
********************************************************************************
|
||||||
* Package: axis-1.4 *
|
* Package: xml-security-1_4_0 *
|
||||||
* *
|
* *
|
||||||
* Supplier: The Apache Software Foundation http://www.apache.org/ *
|
* 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
|
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
|
xercesImpl
|
||||||
xml-apis
|
|
||||||
xmlsec
|
xmlsec
|
||||||
|
|
||||||
Package license:
|
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.
|
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/ *
|
* 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:
|
Package license:
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -752,41 +452,10 @@ Package license:
|
|||||||
|
|
||||||
Package notice:
|
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 *
|
* File: Svc/src/com/novell/casa/authtoksvc/Base64Coder.java *
|
||||||
|
24
CASA-auth-token/server-java/Svc/external/README
vendored
24
CASA-auth-token/server-java/Svc/external/README
vendored
@ -1,25 +1,3 @@
|
|||||||
The following describes the source of the files present in this folder.
|
This folder contains components which this project depends on.
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ DIST_SUBDIRS = logging-log4j-1.2.14
|
|||||||
|
|
||||||
CFILES =
|
CFILES =
|
||||||
|
|
||||||
EXTRA_DIST =
|
EXTRA_DIST = README
|
||||||
|
|
||||||
.PHONY: package package-clean package-install package-uninstall
|
.PHONY: package package-clean package-install package-uninstall
|
||||||
package package-clean package-install package-uninstall:
|
package package-clean package-install package-uninstall:
|
||||||
|
8
CASA-auth-token/server-java/Svc/external/log4j/README
vendored
Normal file
8
CASA-auth-token/server-java/Svc/external/log4j/README
vendored
Normal 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.
|
||||||
|
|
@ -26,7 +26,7 @@ DIST_SUBDIRS = xml-security-1_4_0
|
|||||||
|
|
||||||
CFILES =
|
CFILES =
|
||||||
|
|
||||||
EXTRA_DIST =
|
EXTRA_DIST = README
|
||||||
|
|
||||||
.PHONY: package package-clean package-install package-uninstall
|
.PHONY: package package-clean package-install package-uninstall
|
||||||
package package-clean package-install package-uninstall:
|
package package-clean package-install package-uninstall:
|
||||||
|
11
CASA-auth-token/server-java/Svc/external/xmlsec/README
vendored
Normal file
11
CASA-auth-token/server-java/Svc/external/xmlsec/README
vendored
Normal 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,6 +27,7 @@ DIST_SUBDIRS =
|
|||||||
CFILES =
|
CFILES =
|
||||||
|
|
||||||
EXTRA_DIST = commons-logging.jar \
|
EXTRA_DIST = commons-logging.jar \
|
||||||
|
xercesImpl.jar \
|
||||||
xmlsec-1.4.0.jar
|
xmlsec-1.4.0.jar
|
||||||
|
|
||||||
.PHONY: package package-clean package-install package-uninstall
|
.PHONY: package package-clean package-install package-uninstall
|
||||||
|
Binary file not shown.
BIN
CASA-auth-token/server-java/Svc/external/xmlsec/xml-security-1_4_0/libs/xercesImpl.jar
vendored
Normal file
BIN
CASA-auth-token/server-java/Svc/external/xmlsec/xml-security-1_4_0/libs/xercesImpl.jar
vendored
Normal file
Binary file not shown.
@ -12,14 +12,14 @@
|
|||||||
#
|
#
|
||||||
# Root logger configuration.
|
# Root logger configuration.
|
||||||
#
|
#
|
||||||
log4j.rootLogger=info, DefaultAppender
|
log4j.rootLogger=warn, DefaultAppender
|
||||||
|
|
||||||
#
|
#
|
||||||
# DefaultAppender configuration.
|
# DefaultAppender configuration.
|
||||||
#
|
#
|
||||||
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
|
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.DefaultAppender.File=/srv/www/casaats/logs/ats.log
|
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.MaxBackupIndex=2
|
||||||
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
|
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.DefaultAppender.layout.ConversionPattern=%d{ISO8601} %p %C{2} %m%n
|
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=org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.TraceAppender.File=/srv/www/casaats/logs/ats.trace
|
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.MaxBackupIndex=2
|
||||||
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
|
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n
|
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n
|
||||||
|
@ -36,7 +36,7 @@ import org.apache.log4j.Logger;
|
|||||||
/**
|
/**
|
||||||
* AuthMechConfig Class.
|
* AuthMechConfig Class.
|
||||||
* <p>
|
* <p>
|
||||||
* This class obtains and maintains authentication token configuration.
|
* This class obtains and maintains configuration for authentication mechanisms.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class AuthMechConfig
|
public final class AuthMechConfig
|
||||||
@ -106,7 +106,7 @@ public final class AuthMechConfig
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
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);
|
throw new Exception("Constructor- File not found", e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -176,7 +176,7 @@ public final class AuthTokenConfig
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
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);
|
throw new Exception("AuthTokenConfig()- File not found", e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -128,7 +128,7 @@ public final class EnabledSvcsConfig
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
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)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,7 @@ public final class IdenTokenConfig
|
|||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
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);
|
throw new Exception("IdenTokenConfig()- File not found", e);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -176,7 +176,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
|
|||||||
}
|
}
|
||||||
catch (GSSException e)
|
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);
|
throw new Exception("Failed to instantiate needed GSS objects", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
#
|
#
|
||||||
# Root logger configuration.
|
# Root logger configuration.
|
||||||
#
|
#
|
||||||
log4j.rootLogger=info, DefaultAppender
|
log4j.rootLogger=warn, DefaultAppender
|
||||||
|
|
||||||
#
|
#
|
||||||
# DefaultAppender configuration.
|
# DefaultAppender configuration.
|
||||||
#
|
#
|
||||||
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
|
log4j.appender.DefaultAppender=org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.DefaultAppender.File=ATS_INSTALL_DIRats\\catalinabase\\logs\\ats.log
|
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.MaxBackupIndex=2
|
||||||
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
|
log4j.appender.DefaultAppender.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.DefaultAppender.layout.ConversionPattern=%d{ISO8601} %p %C{2} %m%n
|
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=org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.TraceAppender.File=ATS_INSTALL_DIRats\\catalinabase\\logs\\ats.trace
|
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.MaxBackupIndex=2
|
||||||
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
|
log4j.appender.TraceAppender.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n
|
log4j.appender.TraceAppender.layout.ConversionPattern=%d{ISO8601} %p [%x] %m%n
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
public class ClientKeystoreSetup
|
||||||
{
|
{
|
||||||
final static int ERROR_NO_ERROR = 0;
|
final static int ERROR_NO_ERROR = 0;
|
||||||
final static int ERROR_EXEC_FAILED = -1;
|
final static int ERROR_EXEC_FAILED = -1;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
||||||
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
||||||
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
||||||
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
|
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
|
||||||
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
|
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
|
||||||
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
|
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
|
||||||
final static int ERROR_UNKNOWN_PARAM = -9;
|
final static int ERROR_UNKNOWN_PARAM = -9;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
|
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
|
||||||
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
|
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
|
||||||
final static int ERROR_EXEC_INTERRUPTED = -12;
|
final static int ERROR_EXEC_INTERRUPTED = -12;
|
||||||
final static int ERROR_IO_EXCEPTION = -13;
|
final static int ERROR_IO_EXCEPTION = -13;
|
||||||
|
|
||||||
final static String INSTALL_DIR = "installdir=";
|
final static String INSTALL_DIR = "installdir=";
|
||||||
final static String PROPERTY_FILE = "propertyfile=";
|
final static String PROPERTY_FILE = "propertyfile=";
|
||||||
|
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
Properties properties;
|
Properties properties;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// debug stuff
|
// debug stuff
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
ClientKeystoreSetup p = new ClientKeystoreSetup(args);
|
ClientKeystoreSetup p = new ClientKeystoreSetup(args);
|
||||||
System.exit(p.rc);
|
System.exit(p.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientKeystoreSetup(String[] args)
|
ClientKeystoreSetup(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
file = new File("c:\\test4.log");
|
//file = new File("c:\\test4.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
log("Here we go again: " + args.length);
|
log("Here we go again: " + args.length);
|
||||||
for (int i = 0; i < args.length; i++)
|
for (int i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i] + "\r\n");
|
log("Arg " + i + " = " + args[i] + "\r\n");
|
||||||
}
|
}
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
|
|
||||||
// Process the input params
|
// Process the input params
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Make sure we got everything we need
|
// Make sure we got everything we need
|
||||||
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
|
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
|
||||||
{
|
{
|
||||||
// Make sure the client keystore has been created
|
// Make sure the client keystore has been created
|
||||||
rc = createClientKeystore();
|
rc = createClientKeystore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
String sProperties;
|
String sProperties;
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
File fileProperties = null;
|
File fileProperties = null;
|
||||||
FileInputStream fisProperties = null;
|
FileInputStream fisProperties = null;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (argsOld.length < 2)
|
if (argsOld.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i] + "\r\n");
|
log("Arg " + i + " = " + args[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i <= iNew; i++)
|
for (i = 0; i <= iNew; i++)
|
||||||
{
|
{
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR))
|
if (args[i].startsWith(INSTALL_DIR))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= INSTALL_DIR.length())
|
if (args[i].length() <= INSTALL_DIR.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// is this the properties file param?
|
// is this the properties file param?
|
||||||
else if (args[i].startsWith(PROPERTY_FILE))
|
else if (args[i].startsWith(PROPERTY_FILE))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= PROPERTY_FILE.length())
|
if (args[i].length() <= PROPERTY_FILE.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
|
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
|
||||||
fileProperties = new File(sProperties);
|
fileProperties = new File(sProperties);
|
||||||
|
|
||||||
// Make sure the properties file can be found
|
// Make sure the properties file can be found
|
||||||
if (!fileProperties.exists())
|
if (!fileProperties.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_PROPERTIES_FILE;
|
return ERROR_MISSING_PROPERTIES_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the properties
|
// Read the properties
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fisProperties = new FileInputStream(fileProperties);
|
fisProperties = new FileInputStream(fileProperties);
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
properties.load(fisProperties);
|
properties.load(fisProperties);
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown parameter
|
// Unknown parameter
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log(ERROR_UNKNOWN_PARAM, args[i]);
|
log(ERROR_UNKNOWN_PARAM, args[i]);
|
||||||
return ERROR_UNKNOWN_PARAM;
|
return ERROR_UNKNOWN_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int findRequiredValues()
|
int findRequiredValues()
|
||||||
{
|
{
|
||||||
String[] rgsRequired = {
|
String[] rgsRequired = {
|
||||||
"ATS_JAVA_HOME"};
|
"ATS_JAVA_HOME"};
|
||||||
int i;
|
int i;
|
||||||
String sValue;
|
String sValue;
|
||||||
|
|
||||||
for (i = 0; i < rgsRequired.length; i++)
|
for (i = 0; i < rgsRequired.length; i++)
|
||||||
{
|
{
|
||||||
log("look for required value: " + rgsRequired[i]);
|
log("look for required value: " + rgsRequired[i]);
|
||||||
|
|
||||||
if (!properties.containsKey(rgsRequired[i]))
|
if (!properties.containsKey(rgsRequired[i]))
|
||||||
{
|
{
|
||||||
log("look for required value in envirement: " + rgsRequired[i]);
|
log("look for required value in envirement: " + rgsRequired[i]);
|
||||||
if (null == (sValue = System.getProperty(rgsRequired[i])))
|
if (null == (sValue = System.getProperty(rgsRequired[i])))
|
||||||
{
|
{
|
||||||
log("unable to find required value in envirement: " + rgsRequired[i]);
|
log("unable to find required value in envirement: " + rgsRequired[i]);
|
||||||
return ERROR_REQUIRED_VALUE_MISSING;
|
return ERROR_REQUIRED_VALUE_MISSING;
|
||||||
}
|
}
|
||||||
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
|
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
|
||||||
properties.put(rgsRequired[i], sValue);
|
properties.put(rgsRequired[i], sValue);
|
||||||
}
|
}
|
||||||
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
|
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
|
||||||
}
|
}
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int createClientKeystore()
|
int createClientKeystore()
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
|
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
|
// Do not do anything if the server keystore has already been created
|
||||||
if (keyStoreAlreadyExists())
|
if (keyStoreAlreadyExists())
|
||||||
{
|
{
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import the servers certificate in the client keystore
|
// Import the servers certificate in the client keystore
|
||||||
rc = invokeCommand(sKeytool + " -import -noprompt -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\\client\\jks-store -alias signingCert -storepass secret -keypass secret -file " +
|
||||||
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert");
|
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert");
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean keyStoreAlreadyExists()
|
boolean keyStoreAlreadyExists()
|
||||||
{
|
{
|
||||||
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\client\\jks-store");
|
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\client\\jks-store");
|
||||||
|
|
||||||
// Why is this always returning true? exists() also always returns true.
|
// Why is this always returning true? exists() also always returns true.
|
||||||
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\client\\jks-store" + ") already exists = " + (file.isFile()));
|
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\client\\jks-store" + ") already exists = " + (file.isFile()));
|
||||||
// return (file.isFile());
|
// return (file.isFile());
|
||||||
|
|
||||||
File fileParent = fileKeystore.getParentFile();
|
File fileParent = fileKeystore.getParentFile();
|
||||||
String[] rgChildren = fileParent.list();
|
String[] rgChildren = fileParent.list();
|
||||||
if (null != rgChildren)
|
if (null != rgChildren)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rgChildren.length; i++)
|
for (int i = 0; i < rgChildren.length; i++)
|
||||||
{
|
{
|
||||||
log("child " + i + " = " + rgChildren[i]);
|
log("child " + i + " = " + rgChildren[i]);
|
||||||
if ("jks-store".equals(rgChildren[i]))
|
if ("jks-store".equals(rgChildren[i]))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invokeCommand(String sCommand)
|
int invokeCommand(String sCommand)
|
||||||
{
|
{
|
||||||
Process p;
|
Process p;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
log("invoke command: " + sCommand);
|
log("invoke command: " + sCommand);
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = runtime.exec(sCommand);
|
p = runtime.exec(sCommand);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = p.waitFor();
|
rc = p.waitFor();
|
||||||
log("invoke command return code: " + rc);
|
log("invoke command return code: " + rc);
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
catch (InterruptedException ie)
|
||||||
{
|
{
|
||||||
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
||||||
return ERROR_EXEC_INTERRUPTED;
|
return ERROR_EXEC_INTERRUPTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log("Ioexception");
|
log("Ioexception");
|
||||||
return ERROR_EXEC_FAILED;
|
return ERROR_EXEC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_FAILED:
|
case ERROR_EXEC_FAILED:
|
||||||
sMessage = "Execute command failed ";
|
sMessage = "Execute command failed ";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of params";
|
sMessage = "Invalid number of params";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_INSTALL_DIR_PARAM:
|
case ERROR_BAD_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Install dir parameter is bad";
|
sMessage = "Install dir parameter is bad";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR:
|
case ERROR_MISSING_INSTALL_DIR:
|
||||||
sMessage = "Missing install dir";
|
sMessage = "Missing install dir";
|
||||||
break;
|
break;
|
||||||
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
||||||
sMessage = "Install dir is not a dir";
|
sMessage = "Install dir is not a dir";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Invalid porperty file parameter";
|
sMessage = "Invalid porperty file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTIES_FILE:
|
case ERROR_MISSING_PROPERTIES_FILE:
|
||||||
sMessage = "Property file not found";
|
sMessage = "Property file not found";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
||||||
sMessage = "Unable to read property file";
|
sMessage = "Unable to read property file";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNKNOWN_PARAM:
|
case ERROR_UNKNOWN_PARAM:
|
||||||
sMessage = "Unknown parameter: ";
|
sMessage = "Unknown parameter: ";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Install dir parameter is missing";
|
sMessage = "Install dir parameter is missing";
|
||||||
break;
|
break;
|
||||||
case ERROR_REQUIRED_VALUE_MISSING:
|
case ERROR_REQUIRED_VALUE_MISSING:
|
||||||
sMessage = "Required value is missing ";
|
sMessage = "Required value is missing ";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_INTERRUPTED:
|
case ERROR_EXEC_INTERRUPTED:
|
||||||
sMessage = "Execution iinterrupted: ";
|
sMessage = "Execution iinterrupted: ";
|
||||||
break;
|
break;
|
||||||
case ERROR_IO_EXCEPTION:
|
case ERROR_IO_EXCEPTION:
|
||||||
sMessage = "IOException ";
|
sMessage = "IOException ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error";
|
sMessage = "Unknown error";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// CommandLauncher.cpp : Defines the entry point for the application.
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -11,8 +36,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
WCHAR ** G_rgArgs; // Command line arguments
|
WCHAR ** G_rgArgs; // Command line arguments
|
||||||
int G_cArg; // Count of command line arguments
|
int G_cArg; // Count of command line arguments
|
||||||
FILE * G_pf;
|
//FILE * G_pf;
|
||||||
|
|
||||||
// Forward declarations of functions included in this code module:
|
// Forward declarations of functions included in this code module:
|
||||||
int processArguments(LPTSTR lpCmdLine);
|
int processArguments(LPTSTR lpCmdLine);
|
||||||
@ -24,476 +49,478 @@ _TCHAR * errorMessage(int err);
|
|||||||
int executeCommand( int cArg, _TCHAR* rgArg[]);
|
int executeCommand( int cArg, _TCHAR* rgArg[]);
|
||||||
|
|
||||||
|
|
||||||
#define ERROR_NO_ERROR 0
|
#define ERROR_NO_ERROR 0
|
||||||
#define ERROR_MEMORY_ALLOCATION_FAILED -1
|
#define ERROR_MEMORY_ALLOCATION_FAILED -1
|
||||||
#define ERROR_INVALID_NUMBER_OF_PARAMETERS -2
|
#define ERROR_INVALID_NUMBER_OF_PARAMETERS -2
|
||||||
#define ERROR_EXEC_E2BIG -3
|
#define ERROR_EXEC_E2BIG -3
|
||||||
#define ERROR_EXEC_EACCES -4
|
#define ERROR_EXEC_EACCES -4
|
||||||
#define ERROR_EXEC_EINVAL -5
|
#define ERROR_EXEC_EINVAL -5
|
||||||
#define ERROR_EXEC_EMFILE -6
|
#define ERROR_EXEC_EMFILE -6
|
||||||
#define ERROR_EXEC_ENOENT -7
|
#define ERROR_EXEC_ENOENT -7
|
||||||
#define ERROR_EXEC_ENOEXEC -8
|
#define ERROR_EXEC_ENOEXEC -8
|
||||||
#define ERROR_EXEC_ENOMEM -9
|
#define ERROR_EXEC_ENOMEM -9
|
||||||
#define ERROR_EXEC_UNKNOWN -10
|
#define ERROR_EXEC_UNKNOWN -10
|
||||||
#define ERROR_STRCPY_FAILED -11
|
#define ERROR_STRCPY_FAILED -11
|
||||||
#define ERROR_JAVA_EXE_ARG_MISSING -12
|
#define ERROR_JAVA_EXE_ARG_MISSING -12
|
||||||
#define ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING -13
|
#define ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING -13
|
||||||
#define ERROR_JAVA_CLASSPATH_ARG_MISSING -14
|
#define ERROR_JAVA_CLASSPATH_ARG_MISSING -14
|
||||||
#define ERROR_BAD_COMMAND_LINE -15
|
#define ERROR_BAD_COMMAND_LINE -15
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
HINSTANCE hPrevInstance,
|
HINSTANCE hPrevInstance,
|
||||||
LPTSTR lpCmdLine,
|
LPTSTR lpCmdLine,
|
||||||
int nCmdShow)
|
int nCmdShow)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(hInstance);
|
UNREFERENCED_PARAMETER(hInstance);
|
||||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
UNREFERENCED_PARAMETER(nCmdShow);
|
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
|
// Process the command line
|
||||||
if (ERROR_NO_ERROR != (rc = processArguments(lpCmdLine)))
|
if (ERROR_NO_ERROR != (rc = processArguments(lpCmdLine)))
|
||||||
{
|
{
|
||||||
return rc;
|
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
|
// <java exe path> -cp <classpath> class k1=v1 k2=k2
|
||||||
int processArguments(LPTSTR lpCmdLine)
|
int processArguments(LPTSTR lpCmdLine)
|
||||||
{
|
{
|
||||||
int iArg;
|
int iArg;
|
||||||
int iChar;
|
int iChar;
|
||||||
int iAssignment;
|
int iAssignment;
|
||||||
int iClassStart;
|
int iClassStart;
|
||||||
int iClassEnd;
|
int iClassEnd;
|
||||||
int iClassPathStart;
|
int iClassPathStart;
|
||||||
int iClassPathEnd;
|
int iClassPathEnd;
|
||||||
int rc;
|
int rc;
|
||||||
bool fClasspathOptionFound = false;
|
bool fClasspathOptionFound = false;
|
||||||
int iKeyStart;
|
int iKeyStart;
|
||||||
int iValueEnd;
|
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
|
// Validate the command line
|
||||||
if (NULL == lpCmdLine || (WCHAR)0 == *lpCmdLine)
|
if (NULL == lpCmdLine || (WCHAR)0 == *lpCmdLine)
|
||||||
{
|
{
|
||||||
return ERROR_BAD_COMMAND_LINE;
|
return ERROR_BAD_COMMAND_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the arguments on the command line. TThe name of this executable
|
// Count the arguments on the command line. TThe name of this executable
|
||||||
// is not included in the count.
|
// is not included in the count.
|
||||||
G_cArg = countArgs(lpCmdLine);
|
G_cArg = countArgs(lpCmdLine);
|
||||||
|
|
||||||
// Make sure we got enough to exec something. There must be at least the
|
// 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.
|
// path to jave.exe, the classpath option, the classpath and a class.
|
||||||
if (G_cArg < 4)
|
if (G_cArg < 4)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMETERS;
|
return ERROR_INVALID_NUMBER_OF_PARAMETERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate an array of wide string for the arguments, add 1 for a NULL at
|
// Allocate an array of wide string for the arguments, add 1 for a NULL at
|
||||||
// the end of the array
|
// the end of the array
|
||||||
G_rgArgs = (WCHAR**)malloc((G_cArg + 1) * sizeof(WCHAR *));
|
G_rgArgs = (WCHAR**)malloc((G_cArg + 1) * sizeof(WCHAR *));
|
||||||
if (NULL == G_rgArgs)
|
if (NULL == G_rgArgs)
|
||||||
{
|
{
|
||||||
return ERROR_MEMORY_ALLOCATION_FAILED;
|
return ERROR_MEMORY_ALLOCATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Null out the array
|
// Null out the array
|
||||||
memset(G_rgArgs, 0, (G_cArg + 1) * sizeof(WCHAR *));
|
memset(G_rgArgs, 0, (G_cArg + 1) * sizeof(WCHAR *));
|
||||||
|
|
||||||
// Find the java.exe argument
|
// Find the java.exe argument
|
||||||
iChar = 0;
|
iChar = 0;
|
||||||
for (iChar = 0; 0 != lpCmdLine[iChar + 4]; iChar++)
|
for (iChar = 0; 0 != lpCmdLine[iChar + 4]; iChar++)
|
||||||
{
|
{
|
||||||
if (0 == _wcsnicmp(lpCmdLine + iChar, L".exe", 4))
|
if (0 == _wcsnicmp(lpCmdLine + iChar, L".exe", 4))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (0 == lpCmdLine[iChar + 4])
|
if (0 == lpCmdLine[iChar + 4])
|
||||||
{
|
{
|
||||||
rc = ERROR_JAVA_EXE_ARG_MISSING;
|
rc = ERROR_JAVA_EXE_ARG_MISSING;
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the java.exe argument
|
// Add the java.exe argument
|
||||||
if (ERROR_NO_ERROR != (rc = addArg(0, lpCmdLine, iChar + 4)))
|
if (ERROR_NO_ERROR != (rc = addArg(0, lpCmdLine, iChar + 4)))
|
||||||
{
|
{
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past the java.exe argument
|
// Move past the java.exe argument
|
||||||
iChar += 4;
|
iChar += 4;
|
||||||
|
|
||||||
// Move past any spaces
|
// Move past any spaces
|
||||||
for (;L' ' == lpCmdLine[iChar]; iChar++)
|
for (;L' ' == lpCmdLine[iChar]; iChar++)
|
||||||
{
|
{
|
||||||
// Intentionally left blank
|
// Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the classpath argument
|
// Find the classpath argument
|
||||||
for (; 0 != lpCmdLine[iChar + 3]; iChar++)
|
for (; 0 != lpCmdLine[iChar + 3]; iChar++)
|
||||||
{
|
{
|
||||||
if (0 == _wcsnicmp(lpCmdLine + iChar, L"-cp", 3))
|
if (0 == _wcsnicmp(lpCmdLine + iChar, L"-cp", 3))
|
||||||
{
|
{
|
||||||
fClasspathOptionFound = true;
|
fClasspathOptionFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fClasspathOptionFound)
|
if (!fClasspathOptionFound)
|
||||||
{
|
{
|
||||||
rc = ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING;
|
rc = ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING;
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
if (0 == lpCmdLine[iChar + 3])
|
if (0 == lpCmdLine[iChar + 3])
|
||||||
{
|
{
|
||||||
rc = ERROR_JAVA_CLASSPATH_ARG_MISSING;
|
rc = ERROR_JAVA_CLASSPATH_ARG_MISSING;
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the classpath option argument
|
// Add the classpath option argument
|
||||||
if (ERROR_NO_ERROR != (rc = addArg(1, L"-cp", iChar + 3)))
|
if (ERROR_NO_ERROR != (rc = addArg(1, L"-cp", iChar + 3)))
|
||||||
{
|
{
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past the classpath option argument
|
// Move past the classpath option argument
|
||||||
iChar += 3;
|
iChar += 3;
|
||||||
|
|
||||||
// Move past any spaces
|
// Move past any spaces
|
||||||
for (;L' ' == lpCmdLine[iChar]; iChar++)
|
for (;L' ' == lpCmdLine[iChar]; iChar++)
|
||||||
{
|
{
|
||||||
// Intentionally left blank
|
// Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// The classpath is next. It can have spaces in it so we need to work
|
// 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
|
// backards from the first key/value pair, or the end of the line if
|
||||||
// there are no key/value pairs.
|
// there are no key/value pairs.
|
||||||
iClassPathStart = iChar;
|
iClassPathStart = iChar;
|
||||||
|
|
||||||
// Find the location of the next '='
|
// Find the location of the next '='
|
||||||
for (; 0 != lpCmdLine[iChar] && L'=' != lpCmdLine[iChar]; iChar++)
|
for (; 0 != lpCmdLine[iChar] && L'=' != lpCmdLine[iChar]; iChar++)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there was a key/value pair - move to the start of the key
|
// If there was a key/value pair - move to the start of the key
|
||||||
if (L'=' == lpCmdLine[iChar])
|
if (L'=' == lpCmdLine[iChar])
|
||||||
{
|
{
|
||||||
iAssignment = iChar;
|
iAssignment = iChar;
|
||||||
|
|
||||||
// Move back to the previous space. This should put us at the
|
// Move back to the previous space. This should put us at the
|
||||||
// beginning of the first key/value pair. Assume that all args
|
// beginning of the first key/value pair. Assume that all args
|
||||||
// are property key/value pairs and property keys have no spaces.
|
// are property key/value pairs and property keys have no spaces.
|
||||||
for (; L' ' != lpCmdLine[iChar] && iChar >= 0; iChar--)
|
for (; L' ' != lpCmdLine[iChar] && iChar >= 0; iChar--)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iAssignment = 0;
|
iAssignment = 0;
|
||||||
iChar--;
|
iChar--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past any spaces (moving toward the start of the line)
|
// Move past any spaces (moving toward the start of the line)
|
||||||
for (;L' ' == lpCmdLine[iChar]; iChar--)
|
for (;L' ' == lpCmdLine[iChar]; iChar--)
|
||||||
{
|
{
|
||||||
// Intentionally left blank
|
// Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should put us at the end of the class to be executed
|
// This should put us at the end of the class to be executed
|
||||||
iClassEnd = iChar;
|
iClassEnd = iChar;
|
||||||
|
|
||||||
// Move to the previous space (moving toward the start of the line)
|
// Move to the previous space (moving toward the start of the line)
|
||||||
for (;L' ' != lpCmdLine[iChar]; iChar--)
|
for (;L' ' != lpCmdLine[iChar]; iChar--)
|
||||||
{
|
{
|
||||||
// Intentionally left blank
|
// Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
iClassStart = iChar + 1;
|
iClassStart = iChar + 1;
|
||||||
|
|
||||||
// Add the class argument
|
// Add the class argument
|
||||||
if (ERROR_NO_ERROR != (rc = addArg(3, lpCmdLine + iClassStart, iClassEnd - iClassStart + 1)))
|
if (ERROR_NO_ERROR != (rc = addArg(3, lpCmdLine + iClassStart, iClassEnd - iClassStart + 1)))
|
||||||
{
|
{
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move past any spaces (moving toward the start of the line)
|
// Move past any spaces (moving toward the start of the line)
|
||||||
for (;L' ' == lpCmdLine[iChar]; iChar--)
|
for (;L' ' == lpCmdLine[iChar]; iChar--)
|
||||||
{
|
{
|
||||||
// Intentionally left blank
|
// Intentionally left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should put us at the end of the classpath
|
// This should put us at the end of the classpath
|
||||||
iClassPathEnd = iChar;
|
iClassPathEnd = iChar;
|
||||||
|
|
||||||
// Add the class path argument
|
// Add the class path argument
|
||||||
if (ERROR_NO_ERROR != (rc = addArg(2, lpCmdLine + iClassPathStart, iClassPathEnd - iClassPathStart + 1)))
|
if (ERROR_NO_ERROR != (rc = addArg(2, lpCmdLine + iClassPathStart, iClassPathEnd - iClassPathStart + 1)))
|
||||||
{
|
{
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are the any key/value pairs?
|
// Are the any key/value pairs?
|
||||||
if (0 != iAssignment)
|
if (0 != iAssignment)
|
||||||
{
|
{
|
||||||
iArg = 4;
|
iArg = 4;
|
||||||
while (0 != lpCmdLine[iAssignment])
|
while (0 != lpCmdLine[iAssignment])
|
||||||
{
|
{
|
||||||
iKeyStart = iAssignment;
|
iKeyStart = iAssignment;
|
||||||
|
|
||||||
// Move back to the previous space. This should put us at the
|
// Move back to the previous space. This should put us at the
|
||||||
// beginning of the current next key/value pair. Assume that all args
|
// beginning of the current next key/value pair. Assume that all args
|
||||||
// are property key/value pairs and property keys have no spaces.
|
// are property key/value pairs and property keys have no spaces.
|
||||||
for (; L' ' != lpCmdLine[iKeyStart] && iKeyStart > 0; iKeyStart--)
|
for (; L' ' != lpCmdLine[iKeyStart] && iKeyStart > 0; iKeyStart--)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
if (L' ' == lpCmdLine[iKeyStart])
|
if (L' ' == lpCmdLine[iKeyStart])
|
||||||
{
|
{
|
||||||
iKeyStart++;
|
iKeyStart++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the location of the next '='
|
// Find the location of the next '='
|
||||||
iValueEnd = iAssignment + 1;
|
iValueEnd = iAssignment + 1;
|
||||||
for (; 0 != lpCmdLine[iValueEnd] && L'=' != lpCmdLine[iValueEnd]; iValueEnd++)
|
for (; 0 != lpCmdLine[iValueEnd] && L'=' != lpCmdLine[iValueEnd]; iValueEnd++)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there was a property...
|
// If there was a property...
|
||||||
if (L'=' == lpCmdLine[iValueEnd])
|
if (L'=' == lpCmdLine[iValueEnd])
|
||||||
{
|
{
|
||||||
iAssignment = iValueEnd;
|
iAssignment = iValueEnd;
|
||||||
|
|
||||||
// Move back to the previous space. This should put us at the
|
// Move back to the previous space. This should put us at the
|
||||||
// beginning of the next key/value pair. Assume that all args
|
// beginning of the next key/value pair. Assume that all args
|
||||||
// are property key/value pairs and property keys have no spaces.
|
// are property key/value pairs and property keys have no spaces.
|
||||||
for (; L' ' != lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
|
for (; L' ' != lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We have reached the end of the command line - back off from the
|
// We have reached the end of the command line - back off from the
|
||||||
// null terminator.
|
// null terminator.
|
||||||
iAssignment = iValueEnd;
|
iAssignment = iValueEnd;
|
||||||
iValueEnd--;
|
iValueEnd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move thorugh any spaces
|
// Move thorugh any spaces
|
||||||
for (; L' ' == lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
|
for (; L' ' == lpCmdLine[iValueEnd] && iValueEnd >= 0; iValueEnd--)
|
||||||
{
|
{
|
||||||
// Intentially left blank
|
// Intentially left blank
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the key/value pair
|
// Add the key/value pair
|
||||||
if (ERROR_NO_ERROR != (rc = addArg(iArg, lpCmdLine + iKeyStart, iValueEnd - iKeyStart + 1)))
|
if (ERROR_NO_ERROR != (rc = addArg(iArg, lpCmdLine + iKeyStart, iValueEnd - iKeyStart + 1)))
|
||||||
{
|
{
|
||||||
goto ErrorOut;
|
goto ErrorOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go on to the next arg
|
// Go on to the next arg
|
||||||
iArg++;
|
iArg++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
|
|
||||||
ErrorOut:
|
ErrorOut:
|
||||||
|
|
||||||
freeArgs();
|
freeArgs();
|
||||||
log(errorMessage(rc));
|
log(errorMessage(rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeArgs()
|
void freeArgs()
|
||||||
{
|
{
|
||||||
int iArg;
|
int iArg;
|
||||||
if (NULL != G_rgArgs)
|
if (NULL != G_rgArgs)
|
||||||
{
|
{
|
||||||
for (iArg = 0; iArg < G_cArg; iArg++)
|
for (iArg = 0; iArg < G_cArg; iArg++)
|
||||||
{
|
{
|
||||||
if (NULL != G_rgArgs[iArg])
|
if (NULL != G_rgArgs[iArg])
|
||||||
{
|
{
|
||||||
free(G_rgArgs[iArg]);
|
free(G_rgArgs[iArg]);
|
||||||
G_rgArgs[iArg] = NULL;
|
G_rgArgs[iArg] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(G_rgArgs);
|
free(G_rgArgs);
|
||||||
G_rgArgs = NULL;
|
G_rgArgs = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int countArgs(LPTSTR lpCmdLine)
|
int countArgs(LPTSTR lpCmdLine)
|
||||||
{
|
{
|
||||||
int cArgument;
|
int cArgument;
|
||||||
|
|
||||||
// Check if the exe to execute is the only argument. Assume that all additional
|
// Check if the exe to execute is the only argument. Assume that all additional
|
||||||
// arguments have an '=' in them.
|
// arguments have an '=' in them.
|
||||||
for (cArgument = 4; *lpCmdLine != (WCHAR)0; lpCmdLine++)
|
for (cArgument = 4; *lpCmdLine != (WCHAR)0; lpCmdLine++)
|
||||||
{
|
{
|
||||||
if (*lpCmdLine == L'=')
|
if (*lpCmdLine == L'=')
|
||||||
{
|
{
|
||||||
cArgument++;
|
cArgument++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cArgument;
|
return cArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addArg(int iArg, LPTSTR lpString, int cChar)
|
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
|
// Allocate space for the new arg
|
||||||
G_rgArgs[iArg] = (WCHAR *)malloc(cb);
|
G_rgArgs[iArg] = (WCHAR *)malloc(cb);
|
||||||
if (NULL == G_rgArgs[iArg])
|
if (NULL == G_rgArgs[iArg])
|
||||||
{
|
{
|
||||||
return ERROR_MEMORY_ALLOCATION_FAILED;
|
return ERROR_MEMORY_ALLOCATION_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Null out the argument
|
// Null out the argument
|
||||||
memset(G_rgArgs[iArg], 0, cb);
|
memset(G_rgArgs[iArg], 0, cb);
|
||||||
|
|
||||||
// Add a starting quote
|
// Add a starting quote
|
||||||
// G_rgArgs[iArg][0] = L'\"';
|
// G_rgArgs[iArg][0] = L'\"';
|
||||||
|
|
||||||
// Copy the arg
|
// Copy the arg
|
||||||
if (0 != wcsncpy_s(G_rgArgs[iArg], cChar + 1, lpString, cChar))
|
if (0 != wcsncpy_s(G_rgArgs[iArg], cChar + 1, lpString, cChar))
|
||||||
{
|
{
|
||||||
return ERROR_STRCPY_FAILED;
|
return ERROR_STRCPY_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a terminating quote
|
// Add a terminating quote
|
||||||
// G_rgArgs[iArg][cb-1] = L'\"';
|
// G_rgArgs[iArg][cb-1] = L'\"';
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void log(LPTSTR szMessage)
|
void log(LPTSTR szMessage)
|
||||||
{
|
{
|
||||||
LPTSTR szT = L"";
|
/*
|
||||||
if (NULL == szMessage)
|
LPTSTR szT = L"";
|
||||||
szMessage = szT;
|
if (NULL == szMessage)
|
||||||
fwprintf(G_pf, L"JavaLauncher: %s\n", szMessage);
|
szMessage = szT;
|
||||||
|
fwprintf(G_pf, L"JavaLauncher: %s\n", szMessage);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
_TCHAR * errorMessage(int err)
|
_TCHAR * errorMessage(int err)
|
||||||
{
|
{
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
return L"No error\n";
|
return L"No error\n";
|
||||||
case ERROR_MEMORY_ALLOCATION_FAILED:
|
case ERROR_MEMORY_ALLOCATION_FAILED:
|
||||||
return L"Memory allocation failed\n";
|
return L"Memory allocation failed\n";
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMETERS:
|
case ERROR_INVALID_NUMBER_OF_PARAMETERS:
|
||||||
return L"Invalid number of parameters\n";
|
return L"Invalid number of parameters\n";
|
||||||
case ERROR_EXEC_E2BIG:
|
case ERROR_EXEC_E2BIG:
|
||||||
return L"_exec: The space required for the arguments and environment settings exceeds 32 KB.\n";
|
return L"_exec: The space required for the arguments and environment settings exceeds 32 KB.\n";
|
||||||
case ERROR_EXEC_EACCES:
|
case ERROR_EXEC_EACCES:
|
||||||
return L"_exec: The specified file has a locking or sharing violation.\n";
|
return L"_exec: The specified file has a locking or sharing violation.\n";
|
||||||
case ERROR_EXEC_EINVAL:
|
case ERROR_EXEC_EINVAL:
|
||||||
return L"_exec: Invalid parameter.\n";
|
return L"_exec: Invalid parameter.\n";
|
||||||
case ERROR_EXEC_EMFILE:
|
case ERROR_EXEC_EMFILE:
|
||||||
return L"_exec: Too many files open (the specified file must be opened to determine whether it is executable).\n";
|
return L"_exec: Too many files open (the specified file must be opened to determine whether it is executable).\n";
|
||||||
case ERROR_EXEC_ENOENT:
|
case ERROR_EXEC_ENOENT:
|
||||||
return L"_exec: The file or path not found.\n";
|
return L"_exec: The file or path not found.\n";
|
||||||
case ERROR_EXEC_ENOEXEC:
|
case ERROR_EXEC_ENOEXEC:
|
||||||
return L"_exec: The specified file is not executable or has an invalid executable-file format.\n";
|
return L"_exec: The specified file is not executable or has an invalid executable-file format.\n";
|
||||||
case ERROR_EXEC_ENOMEM:
|
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";
|
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:
|
case ERROR_EXEC_UNKNOWN:
|
||||||
return L"Unknown _exec error.\n";
|
return L"Unknown _exec error.\n";
|
||||||
case ERROR_STRCPY_FAILED:
|
case ERROR_STRCPY_FAILED:
|
||||||
return L"String copy failed.\n";
|
return L"String copy failed.\n";
|
||||||
case ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING:
|
case ERROR_JAVA_CLASSPATH_OPTION_ARG_MISSING:
|
||||||
return L"Classpath option \"-cp\" missing\n";
|
return L"Classpath option \"-cp\" missing\n";
|
||||||
case ERROR_JAVA_CLASSPATH_ARG_MISSING:
|
case ERROR_JAVA_CLASSPATH_ARG_MISSING:
|
||||||
return L"Classpath argument missing\n";
|
return L"Classpath argument missing\n";
|
||||||
case ERROR_BAD_COMMAND_LINE:
|
case ERROR_BAD_COMMAND_LINE:
|
||||||
return L"Bad command line\n";
|
return L"Bad command line\n";
|
||||||
default:
|
default:
|
||||||
return L"Unknown error.\n";
|
return L"Unknown error.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int executeCommand( int cArg, _TCHAR* rgArg[] )
|
int executeCommand( int cArg, _TCHAR* rgArg[] )
|
||||||
{
|
{
|
||||||
int i; // Looping variable
|
int i; // Looping variable
|
||||||
int rc = ERROR_NO_ERROR; // Return code
|
int rc = ERROR_NO_ERROR; // Return code
|
||||||
|
|
||||||
fwprintf( G_pf, L"Arg count = %d\n", cArg);
|
//fwprintf( G_pf, L"Arg count = %d\n", cArg);
|
||||||
for (i = 0; i < cArg; i++)
|
//for (i = 0; i < cArg; i++)
|
||||||
{
|
//{
|
||||||
fwprintf(G_pf, L"rgArg[%d] (%s)\n", i, rgArg[i]);
|
// fwprintf(G_pf, L"rgArg[%d] (%s)\n", i, rgArg[i]);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// exec the command
|
// exec the command
|
||||||
// if (-1 == _wexecv( rgArg[0], rgArg))
|
// if (-1 == _wexecv( rgArg[0], rgArg))
|
||||||
if (-1 == _wspawnv(_P_WAIT, rgArg[0], rgArg))
|
if (-1 == _wspawnv(_P_WAIT, rgArg[0], rgArg))
|
||||||
{
|
{
|
||||||
switch (errno)
|
switch (errno)
|
||||||
{
|
{
|
||||||
case E2BIG: // The space required for the arguments and environment settings exceeds 32 KB.
|
case E2BIG: // The space required for the arguments and environment settings exceeds 32 KB.
|
||||||
rc = ERROR_EXEC_E2BIG;
|
rc = ERROR_EXEC_E2BIG;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EACCES: // The specified file has a locking or sharing violation.
|
case EACCES: // The specified file has a locking or sharing violation.
|
||||||
rc = ERROR_EXEC_EACCES;
|
rc = ERROR_EXEC_EACCES;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EINVAL: // Invalid parameter.
|
case EINVAL: // Invalid parameter.
|
||||||
rc = ERROR_EXEC_EINVAL;
|
rc = ERROR_EXEC_EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMFILE: // Too many files open (the specified file must be opened to determine whether it is executable).
|
case EMFILE: // Too many files open (the specified file must be opened to determine whether it is executable).
|
||||||
rc = ERROR_EXEC_EMFILE;
|
rc = ERROR_EXEC_EMFILE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENOENT: // The file or path not found.
|
case ENOENT: // The file or path not found.
|
||||||
rc = ERROR_EXEC_ENOENT;
|
rc = ERROR_EXEC_ENOENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENOEXEC: // The specified file is not executable or has an invalid executable-file format.
|
case ENOEXEC: // The specified file is not executable or has an invalid executable-file format.
|
||||||
rc = ERROR_EXEC_ENOEXEC;
|
rc = ERROR_EXEC_ENOEXEC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENOMEM: // Not enough memory is available to execute the new process; the available memory has been
|
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
|
// corrupted; or an invalid block exists, indicating that the calling process was not allocated
|
||||||
// properly.
|
// properly.
|
||||||
rc = ERROR_EXEC_ENOMEM;
|
rc = ERROR_EXEC_ENOMEM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rc = ERROR_EXEC_UNKNOWN;
|
rc = ERROR_EXEC_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fwprintf(G_pf, L"ExecuteCommand returning %d\n", rc);
|
//fwprintf(G_pf, L"ExecuteCommand returning %d\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
public class DeleteFile
|
||||||
{
|
{
|
||||||
final static int ERROR_NO_ERROR = 0;
|
final static int ERROR_NO_ERROR = 0;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
||||||
final static int ERROR_BAD_FILE_PARAM = -2;
|
final static int ERROR_BAD_FILE_PARAM = -2;
|
||||||
final static int ERROR_IO_EXCEPTION = -3;
|
final static int ERROR_IO_EXCEPTION = -3;
|
||||||
final static int ERROR_FILE_PARAM_REPEATED = -4;
|
final static int ERROR_FILE_PARAM_REPEATED = -4;
|
||||||
final static int ERROR_FILTER_PARAM_REPEATED = -5;
|
final static int ERROR_FILTER_PARAM_REPEATED = -5;
|
||||||
final static int ERROR_UNKNOWN_PARAMETER = -6;
|
final static int ERROR_UNKNOWN_PARAMETER = -6;
|
||||||
final static int ERROR_MISSING_FILE_PARAM = -7;
|
final static int ERROR_MISSING_FILE_PARAM = -7;
|
||||||
final static int ERROR_FILTER_ON_NON_DIRECTORY = -8;
|
final static int ERROR_FILTER_ON_NON_DIRECTORY = -8;
|
||||||
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -9;;
|
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -9;;
|
||||||
|
|
||||||
final static String FILE_KEY = "file=";
|
final static String FILE_KEY = "file=";
|
||||||
final static String FILTER_KEY = "filter=";
|
final static String FILTER_KEY = "filter=";
|
||||||
|
|
||||||
RandomAccessFile raf;
|
//RandomAccessFile raf;
|
||||||
int rc;
|
int rc;
|
||||||
String sFile;
|
String sFile;
|
||||||
String sFilter;
|
String sFilter;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
DeleteFile p = new DeleteFile(args);
|
DeleteFile p = new DeleteFile(args);
|
||||||
System.exit(p.rc);
|
System.exit(p.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteFile(String[] args)
|
DeleteFile(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
sFile = null;
|
sFile = null;
|
||||||
sFilter = null;
|
sFilter = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
raf = new RandomAccessFile(new File("c:\\test8.log"), "rw");
|
//raf = new RandomAccessFile(new File("c:\\test8.log"), "rw");
|
||||||
raf.seek(raf.length());
|
//raf.seek(raf.length());
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
rc = doDelete();
|
rc = doDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc);
|
log(rc);
|
||||||
raf.close();
|
//raf.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
String sProperties;
|
String sProperties;
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
int iEquals;
|
int iEquals;
|
||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
if (null == args[i])
|
if (null == args[i])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("arg[" + i + "] = " +args[i]);
|
log("arg[" + i + "] = " +args[i]);
|
||||||
|
|
||||||
// is this the file to delete param?
|
// is this the file to delete param?
|
||||||
if (args[i].startsWith(FILE_KEY))
|
if (args[i].startsWith(FILE_KEY))
|
||||||
{
|
{
|
||||||
// Have we already processed a file paramter?
|
// Have we already processed a file paramter?
|
||||||
if (null != sFile)
|
if (null != sFile)
|
||||||
{
|
{
|
||||||
return ERROR_FILE_PARAM_REPEATED;
|
return ERROR_FILE_PARAM_REPEATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure it is more the param tag
|
// Make sure it is more the param tag
|
||||||
if (args[i].length() <= FILE_KEY.length())
|
if (args[i].length() <= FILE_KEY.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_FILE_PARAM;
|
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?
|
// is this the filter param?
|
||||||
else if (args[i].startsWith(FILTER_KEY))
|
else if (args[i].startsWith(FILTER_KEY))
|
||||||
{
|
{
|
||||||
// Have we already processed a filter paramter?
|
// Have we already processed a filter paramter?
|
||||||
if (null != sFilter)
|
if (null != sFilter)
|
||||||
{
|
{
|
||||||
return ERROR_FILTER_PARAM_REPEATED;
|
return ERROR_FILTER_PARAM_REPEATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
if (args[i].length() <= FILTER_KEY.length())
|
if (args[i].length() <= FILTER_KEY.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
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
|
// Handle additional parameters
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ERROR_UNKNOWN_PARAMETER;
|
return ERROR_UNKNOWN_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got a file
|
// Make sure we got a file
|
||||||
if (null == sFile)
|
if (null == sFile)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_FILE_PARAM;
|
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()
|
int doDelete()
|
||||||
{
|
{
|
||||||
File file = new File(sFile);
|
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 the file is already gone - we are happy.
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
log("File did not exist: " + sFile);
|
log("File did not exist: " + sFile);
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a filter was passed in but the file is not a directory...
|
// If a filter was passed in but the file is not a directory...
|
||||||
if (null != sFilter)
|
if (null != sFilter)
|
||||||
{
|
{
|
||||||
log("there is a filter: + sFilter");
|
log("there is a filter: + sFilter");
|
||||||
|
|
||||||
// The file is not a directory - we wont try to apply the filter
|
// The file is not a directory - we wont try to apply the filter
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
{
|
{
|
||||||
log("file is not a directory");
|
log("file is not a directory");
|
||||||
return ERROR_FILTER_ON_NON_DIRECTORY;
|
return ERROR_FILTER_ON_NON_DIRECTORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The file is a directory
|
// The file is a directory
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("file is a directory");
|
log("file is a directory");
|
||||||
// Delete the children that match the template
|
// Delete the children that match the template
|
||||||
deleteFiles(file);
|
deleteFiles(file);
|
||||||
|
|
||||||
// Attempt to delete the directory
|
// Attempt to delete the directory
|
||||||
deleteDirectory(file);
|
deleteDirectory(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!file.isDirectory())
|
if (!file.isDirectory())
|
||||||
{
|
{
|
||||||
log("Delete file: " + sFile);
|
log("Delete file: " + sFile);
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
deleteDirectory(file);
|
deleteDirectory(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteFiles(File file)
|
void deleteFiles(File file)
|
||||||
{
|
{
|
||||||
File fileDelete;
|
File fileDelete;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
log("attempting to delete file");
|
log("attempting to delete file");
|
||||||
|
|
||||||
// Get the children of this directory
|
// Get the children of this directory
|
||||||
File[] rgFile = file.listFiles(
|
File[] rgFile = file.listFiles(
|
||||||
new FileFilter()
|
new FileFilter()
|
||||||
{
|
{
|
||||||
public boolean accept(File f)
|
public boolean accept(File f)
|
||||||
{
|
{
|
||||||
if (null == sFilter) return true;
|
if (null == sFilter) return true;
|
||||||
log("file " + f.getName() + " matches filter " + sFilter + " : " + (-1 != f.getName().indexOf(sFilter))) ;
|
log("file " + f.getName() + " matches filter " + sFilter + " : " + (-1 != f.getName().indexOf(sFilter))) ;
|
||||||
return (-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
|
// Attempt to delete each child file
|
||||||
for (i = 0; i < rgFile.length; i++)
|
for (i = 0; i < rgFile.length; i++)
|
||||||
{
|
{
|
||||||
if (rgFile[i].isDirectory())
|
if (rgFile[i].isDirectory())
|
||||||
{
|
{
|
||||||
deleteDirectory(rgFile[i]);
|
deleteDirectory(rgFile[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("Delete file: " + rgFile[i].getAbsolutePath());
|
log("Delete file: " + rgFile[i].getAbsolutePath());
|
||||||
rgFile[i].delete();
|
rgFile[i].delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteDirectory(File file)
|
void deleteDirectory(File file)
|
||||||
{
|
{
|
||||||
File fileDelete;
|
File fileDelete;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
log("Delete directory: " + file.getAbsolutePath());
|
log("Delete directory: " + file.getAbsolutePath());
|
||||||
|
|
||||||
// Get the children of this directory
|
// Get the children of this directory
|
||||||
File[] rgFile = file.listFiles();
|
File[] rgFile = file.listFiles();
|
||||||
|
|
||||||
log(file.getAbsolutePath() + " has " + rgFile.length + " children");
|
log(file.getAbsolutePath() + " has " + rgFile.length + " children");
|
||||||
|
|
||||||
// Delete empty child directories
|
// Delete empty child directories
|
||||||
for (i = 0; i < rgFile.length; i++)
|
for (i = 0; i < rgFile.length; i++)
|
||||||
{
|
{
|
||||||
if (rgFile[i].isDirectory())
|
if (rgFile[i].isDirectory())
|
||||||
{
|
{
|
||||||
deleteDirectory(rgFile[i]);
|
deleteDirectory(rgFile[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete this directory if it is empty
|
// Delete this directory if it is empty
|
||||||
rgFile = file.listFiles();
|
rgFile = file.listFiles();
|
||||||
if (rgFile.length == 0)
|
if (rgFile.length == 0)
|
||||||
{
|
{
|
||||||
log("Delete file: " + file.getAbsolutePath());
|
log("Delete file: " + file.getAbsolutePath());
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of parameters: 1 expected";
|
sMessage = "Invalid number of parameters: 1 expected";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_FILE_PARAM:
|
case ERROR_BAD_FILE_PARAM:
|
||||||
sMessage = "Bad file parameter";
|
sMessage = "Bad file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_FILE_PARAM_REPEATED:
|
case ERROR_FILE_PARAM_REPEATED:
|
||||||
sMessage = "File parameter repeated";
|
sMessage = "File parameter repeated";
|
||||||
break;
|
break;
|
||||||
case ERROR_FILTER_PARAM_REPEATED:
|
case ERROR_FILTER_PARAM_REPEATED:
|
||||||
sMessage = "Filter parameter repeated";
|
sMessage = "Filter parameter repeated";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNKNOWN_PARAMETER:
|
case ERROR_UNKNOWN_PARAMETER:
|
||||||
sMessage = "Unknown parameter: ";
|
sMessage = "Unknown parameter: ";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_FILE_PARAM:
|
case ERROR_MISSING_FILE_PARAM:
|
||||||
sMessage = "Missing file parameter";
|
sMessage = "Missing file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_FILTER_ON_NON_DIRECTORY:
|
case ERROR_FILTER_ON_NON_DIRECTORY:
|
||||||
sMessage = "Filter parameter of non-directory file";
|
sMessage = "Filter parameter of non-directory file";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Bad property file parameter";
|
sMessage = "Bad property file parameter";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error: " + err;
|
sMessage = "Unknown error: " + err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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;
|
FileInputStream fisProperties;
|
||||||
File fileTemplate;
|
File fileTemplate;
|
||||||
File fileOutput;
|
File fileOutput;
|
||||||
File file;
|
//File file;
|
||||||
//FileWriter fw;
|
//FileWriter fw;
|
||||||
RandomAccessFile raf;
|
//RandomAccessFile raf;
|
||||||
String[] rgsSearchFor;
|
String[] rgsSearchFor;
|
||||||
String[] rgsReplaceWith;
|
String[] rgsReplaceWith;
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
@ -88,31 +88,30 @@ public class InitConfigFile
|
|||||||
InitConfigFile(String[] args)
|
InitConfigFile(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
fileProperties = null;
|
fileProperties = null;
|
||||||
fisProperties = null;
|
fisProperties = null;
|
||||||
fileTemplate = null;
|
fileTemplate = null;
|
||||||
fileOutput = null;
|
fileOutput = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File("c:\\test.log");
|
//file = new File("c:\\test.log");
|
||||||
//fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
raf = new RandomAccessFile(file, "rw");
|
//raf = new RandomAccessFile(file, "rw");
|
||||||
raf.seek(raf.length());
|
//raf.seek(raf.length());
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Process the properties
|
// Process the properties
|
||||||
if (ERROR_NO_ERROR == (rc = processProperties()))
|
if (ERROR_NO_ERROR == (rc = processProperties()))
|
||||||
{
|
{
|
||||||
rc = createOutputFile();
|
rc = createOutputFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@ -123,7 +122,7 @@ public class InitConfigFile
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc, " " + sOutput + "\n\n\n");
|
log(rc, " " + sOutput + "\n\n\n");
|
||||||
raf.close();
|
//raf.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
@ -142,19 +141,19 @@ public class InitConfigFile
|
|||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (argsOld.length < 2)
|
if (argsOld.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
@ -168,7 +167,7 @@ public class InitConfigFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
@ -176,9 +175,9 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("arg[" + i + "] = " +args[i]);
|
log("arg[" + i + "] = " +args[i]);
|
||||||
|
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR_PARAM))
|
if (args[i].startsWith(INSTALL_DIR_PARAM))
|
||||||
{
|
{
|
||||||
@ -187,26 +186,26 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Adding property (key = " + INSTALL_DIR_PROPERTY + " - value = " + sInstallDir);
|
log("Adding property (key = " + INSTALL_DIR_PROPERTY + " - value = " + sInstallDir);
|
||||||
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
|
properties.setProperty(INSTALL_DIR_PROPERTY, sInstallDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// is this the properties file param?
|
// is this the properties file param?
|
||||||
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
||||||
{
|
{
|
||||||
@ -215,16 +214,16 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
||||||
fileProperties = new File(sProperties);
|
fileProperties = new File(sProperties);
|
||||||
|
|
||||||
// Make sure the properties file can be found
|
// Make sure the properties file can be found
|
||||||
if (!fileProperties.exists())
|
if (!fileProperties.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_PROPERTIES_FILE;
|
return ERROR_MISSING_PROPERTIES_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the properties
|
// Read the properties
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -236,7 +235,7 @@ public class InitConfigFile
|
|||||||
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args[i].startsWith(TEMPLATE_FILE_PARAM))
|
else if (args[i].startsWith(TEMPLATE_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
@ -244,10 +243,10 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_TEMPLATE_FILE_PARAM;
|
return ERROR_BAD_TEMPLATE_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sTemplate = args[i].substring(TEMPLATE_FILE_PARAM.length()).trim();
|
sTemplate = args[i].substring(TEMPLATE_FILE_PARAM.length()).trim();
|
||||||
fileTemplate = new File(sTemplate);
|
fileTemplate = new File(sTemplate);
|
||||||
|
|
||||||
// Make sure the template file can be found
|
// Make sure the template file can be found
|
||||||
if (!fileTemplate.exists())
|
if (!fileTemplate.exists())
|
||||||
{
|
{
|
||||||
@ -255,7 +254,7 @@ public class InitConfigFile
|
|||||||
return ERROR_MISSING_TEMPLATE_FILE;
|
return ERROR_MISSING_TEMPLATE_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args[i].startsWith(OUTPUT_FILE_PARAM))
|
else if (args[i].startsWith(OUTPUT_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
@ -263,11 +262,11 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_OUTPUT_FILE_PARAM;
|
return ERROR_BAD_OUTPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sOutput = args[i].substring(OUTPUT_FILE_PARAM.length()).trim();
|
sOutput = args[i].substring(OUTPUT_FILE_PARAM.length()).trim();
|
||||||
fileOutput = new File(sOutput);
|
fileOutput = new File(sOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args[i].startsWith(ESCAPE_PATH_CHARS))
|
else if (args[i].startsWith(ESCAPE_PATH_CHARS))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
@ -275,14 +274,14 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_ESCAPE_PATH_CHARS_PARAM;
|
return ERROR_BAD_ESCAPE_PATH_CHARS_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
String value = args[i].substring(ESCAPE_PATH_CHARS.length()).trim();
|
String value = args[i].substring(ESCAPE_PATH_CHARS.length()).trim();
|
||||||
if (value.equalsIgnoreCase("true"))
|
if (value.equalsIgnoreCase("true"))
|
||||||
{
|
{
|
||||||
escapePathCharsInReplaceString = true;
|
escapePathCharsInReplaceString = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle additional parameters
|
// Handle additional parameters
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -298,27 +297,27 @@ public class InitConfigFile
|
|||||||
properties.setProperty(sKey, sValue);
|
properties.setProperty(sKey, sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got a template file
|
// Make sure we got a template file
|
||||||
if (null == fileTemplate)
|
if (null == fileTemplate)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_TEMPLATE_FILE_PARAM;
|
return ERROR_MISSING_TEMPLATE_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an output file
|
// Make sure we got an output file
|
||||||
if (null == fileOutput)
|
if (null == fileOutput)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_OUTPUT_FILE_PARAM;
|
return ERROR_MISSING_OUTPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the properties file parameter is optional
|
// Note: the properties file parameter is optional
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,20 +329,20 @@ public class InitConfigFile
|
|||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
e = properties.propertyNames();
|
e = properties.propertyNames();
|
||||||
|
|
||||||
rgsSearchFor = new String[properties.size()];
|
rgsSearchFor = new String[properties.size()];
|
||||||
rgsReplaceWith = new String[properties.size()];
|
rgsReplaceWith = new String[properties.size()];
|
||||||
|
|
||||||
log("property count = " + properties.size());
|
log("property count = " + properties.size());
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
{
|
{
|
||||||
sKey = (String)e.nextElement();
|
sKey = (String)e.nextElement();
|
||||||
sValue = (String)properties.get(sKey);
|
sValue = (String)properties.get(sKey);
|
||||||
|
|
||||||
log("Property key = " + sKey + " Value = " + sValue);
|
log("Property key = " + sKey + " Value = " + sValue);
|
||||||
|
|
||||||
rgsSearchFor[i] = sKey;
|
rgsSearchFor[i] = sKey;
|
||||||
if (escapePathCharsInReplaceString)
|
if (escapePathCharsInReplaceString)
|
||||||
{
|
{
|
||||||
@ -372,7 +371,7 @@ public class InitConfigFile
|
|||||||
String sLineOutput;
|
String sLineOutput;
|
||||||
int iSearchFor;
|
int iSearchFor;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Open the files
|
// Open the files
|
||||||
@ -382,7 +381,7 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
return ERROR_UNABLE_TO_OPEN_TEMPLATE;
|
return ERROR_UNABLE_TO_OPEN_TEMPLATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fwOutput = new FileWriter(fileOutput);
|
fwOutput = new FileWriter(fileOutput);
|
||||||
@ -398,7 +397,7 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
sLineOutput = sLineTemplate;
|
sLineOutput = sLineTemplate;
|
||||||
log("<-- " + sLineOutput);
|
log("<-- " + sLineOutput);
|
||||||
|
|
||||||
// For each term to be replaced...
|
// For each term to be replaced...
|
||||||
for (i = 0; i < rgsSearchFor.length; i++)
|
for (i = 0; i < rgsSearchFor.length; i++)
|
||||||
{
|
{
|
||||||
@ -408,7 +407,7 @@ public class InitConfigFile
|
|||||||
{
|
{
|
||||||
log("replacing " + rgsSearchFor[i] + " at position " + iSearchFor + " with " + rgsReplaceWith[i]);
|
log("replacing " + rgsSearchFor[i] + " at position " + iSearchFor + " with " + rgsReplaceWith[i]);
|
||||||
sLineOutput = sLineOutput.substring(0, iSearchFor) + rgsReplaceWith[i] +
|
sLineOutput = sLineOutput.substring(0, iSearchFor) + rgsReplaceWith[i] +
|
||||||
sLineOutput.substring(iSearchFor + rgsSearchFor[i].length());
|
sLineOutput.substring(iSearchFor + rgsSearchFor[i].length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -421,7 +420,7 @@ public class InitConfigFile
|
|||||||
return -42;
|
return -42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
fwOutput.flush();
|
fwOutput.flush();
|
||||||
fwOutput.close();
|
fwOutput.close();
|
||||||
@ -531,6 +530,7 @@ public class InitConfigFile
|
|||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
|
raf.writeUTF(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
@ -538,5 +538,6 @@ public class InitConfigFile
|
|||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
|
|
||||||
File fileInput;
|
File fileInput;
|
||||||
File fileOutput;
|
File fileOutput;
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
String sInput;
|
String sInput;
|
||||||
String sOutput;
|
String sOutput;
|
||||||
int rc;
|
int rc;
|
||||||
@ -63,28 +63,27 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
MungeCryptoPropertiesFilePath(String[] args)
|
MungeCryptoPropertiesFilePath(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
fileInput = null;
|
fileInput = null;
|
||||||
fileOutput = null;
|
fileOutput = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File("c:\\test5.log");
|
//file = new File("c:\\test5.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
log("Here we go: " + args.length);
|
log("Here we go: " + args.length);
|
||||||
for (int i = 0; i < args.length; i++)
|
for (int i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i]);
|
log("Arg " + i + " = " + args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Process the file
|
// Process the file
|
||||||
rc = createOutputFile();
|
rc = createOutputFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@ -95,8 +94,8 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
@ -110,19 +109,19 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (argsOld.length < 2)
|
if (argsOld.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
@ -136,17 +135,17 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i] + "\r\n");
|
log("Arg " + i + " = " + args[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= iNew; i++)
|
for (i = 0; i <= iNew; i++)
|
||||||
{
|
{
|
||||||
log("arg[" + i + "] = " +args[i]);
|
log("arg[" + i + "] = " +args[i]);
|
||||||
|
|
||||||
if (args[i].startsWith(INPUT_FILE_PARAM))
|
if (args[i].startsWith(INPUT_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
@ -154,10 +153,10 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_INPUT_FILE_PARAM;
|
return ERROR_BAD_INPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInput = args[i].substring(INPUT_FILE_PARAM.length()).trim();
|
sInput = args[i].substring(INPUT_FILE_PARAM.length()).trim();
|
||||||
fileInput = new File(sInput);
|
fileInput = new File(sInput);
|
||||||
|
|
||||||
// Make sure the input file can be found
|
// Make sure the input file can be found
|
||||||
if (!fileInput.exists())
|
if (!fileInput.exists())
|
||||||
{
|
{
|
||||||
@ -165,7 +164,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
return ERROR_MISSING_INPUT_FILE;
|
return ERROR_MISSING_INPUT_FILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (args[i].startsWith(OUTPUT_FILE_PARAM))
|
else if (args[i].startsWith(OUTPUT_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
@ -173,24 +172,24 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
{
|
{
|
||||||
return ERROR_BAD_OUTPUT_FILE_PARAM;
|
return ERROR_BAD_OUTPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sOutput = args[i].substring(OUTPUT_FILE_PARAM.length()).trim();
|
sOutput = args[i].substring(OUTPUT_FILE_PARAM.length()).trim();
|
||||||
fileOutput = new File(sOutput);
|
fileOutput = new File(sOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an input file
|
// Make sure we got an input file
|
||||||
if (null == fileInput)
|
if (null == fileInput)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INPUT_FILE_PARAM;
|
return ERROR_MISSING_INPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an output file
|
// Make sure we got an output file
|
||||||
if (null == fileOutput)
|
if (null == fileOutput)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_OUTPUT_FILE_PARAM;
|
return ERROR_MISSING_OUTPUT_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +200,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
String sLineTemplate;
|
String sLineTemplate;
|
||||||
String sLineOutput;
|
String sLineOutput;
|
||||||
int iSearchFor;
|
int iSearchFor;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Open the file
|
// Open the file
|
||||||
@ -211,7 +210,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
{
|
{
|
||||||
return ERROR_CANNOT_READ_FILE;
|
return ERROR_CANNOT_READ_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fwOutput = new FileWriter(fileOutput);
|
fwOutput = new FileWriter(fileOutput);
|
||||||
@ -227,7 +226,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
{
|
{
|
||||||
sLineOutput = sLineTemplate;
|
sLineOutput = sLineTemplate;
|
||||||
log("<-- " + sLineOutput);
|
log("<-- " + sLineOutput);
|
||||||
|
|
||||||
if (sLineOutput.trim().startsWith(FILE_KEY))
|
if (sLineOutput.trim().startsWith(FILE_KEY))
|
||||||
{
|
{
|
||||||
// Replace all instances of the line separator on the line
|
// Replace all instances of the line separator on the line
|
||||||
@ -235,7 +234,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
{
|
{
|
||||||
log("replacing \\ at position " + iSearchFor + " with //");
|
log("replacing \\ at position " + iSearchFor + " with //");
|
||||||
sLineOutput = sLineOutput.substring(0, iSearchFor) + "//" +
|
sLineOutput = sLineOutput.substring(0, iSearchFor) + "//" +
|
||||||
sLineOutput.substring(iSearchFor + 1);
|
sLineOutput.substring(iSearchFor + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -248,7 +247,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
return -42;
|
return -42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
fwOutput.flush();
|
fwOutput.flush();
|
||||||
fwOutput.close();
|
fwOutput.close();
|
||||||
@ -278,48 +277,38 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of parameters: 2 expected";
|
sMessage = "Invalid number of parameters: 2 expected";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_MISSING_INPUT_FILE:
|
case ERROR_MISSING_INPUT_FILE:
|
||||||
sMessage = "Missing input file";
|
sMessage = "Missing input file";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_OUTPUT_COPY_FAILED:
|
case ERROR_OUTPUT_COPY_FAILED:
|
||||||
sMessage = "Unable to create output file";
|
sMessage = "Unable to create output file";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_IO_EXCEPTION:
|
case ERROR_IO_EXCEPTION:
|
||||||
sMessage = "IOException";
|
sMessage = "IOException";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_BAD_INPUT_FILE_PARAM:
|
case ERROR_BAD_INPUT_FILE_PARAM:
|
||||||
sMessage = "Invalid input file parameter";
|
sMessage = "Invalid input file parameter";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_BAD_OUTPUT_FILE_PARAM:
|
case ERROR_BAD_OUTPUT_FILE_PARAM:
|
||||||
sMessage = "Invalid output file parameter";
|
sMessage = "Invalid output file parameter";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_MISSING_INPUT_FILE_PARAM:
|
case ERROR_MISSING_INPUT_FILE_PARAM:
|
||||||
sMessage = "Missing input file parameter";
|
sMessage = "Missing input file parameter";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_MISSING_OUTPUT_FILE_PARAM:
|
case ERROR_MISSING_OUTPUT_FILE_PARAM:
|
||||||
sMessage = "Missing output file parameter";
|
sMessage = "Missing output file parameter";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_CANNOT_READ_FILE:
|
case ERROR_CANNOT_READ_FILE:
|
||||||
sMessage = "Cannot read file";
|
sMessage = "Cannot read file";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERROR_CANNOT_CREATE_FILE:
|
case ERROR_CANNOT_CREATE_FILE:
|
||||||
sMessage = "Cannot create file";
|
sMessage = "Cannot create file";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error: " + err;
|
sMessage = "Unknown error: " + err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
@ -329,6 +318,7 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
@ -336,5 +326,6 @@ public class MungeCryptoPropertiesFilePath
|
|||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
public class ServerKeystoreSetup
|
||||||
{
|
{
|
||||||
final static int ERROR_NO_ERROR = 0;
|
final static int ERROR_NO_ERROR = 0;
|
||||||
final static int ERROR_EXEC_FAILED = -1;
|
final static int ERROR_EXEC_FAILED = -1;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
||||||
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
||||||
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
||||||
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
|
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -6;
|
||||||
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
|
final static int ERROR_MISSING_PROPERTIES_FILE = -7;
|
||||||
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
|
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -8;
|
||||||
final static int ERROR_UNKNOWN_PARAM = -9;
|
final static int ERROR_UNKNOWN_PARAM = -9;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
|
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -10;
|
||||||
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
|
final static int ERROR_REQUIRED_VALUE_MISSING = -11;
|
||||||
final static int ERROR_EXEC_INTERRUPTED = -12;
|
final static int ERROR_EXEC_INTERRUPTED = -12;
|
||||||
final static int ERROR_IO_EXCEPTION = -13;
|
final static int ERROR_IO_EXCEPTION = -13;
|
||||||
|
|
||||||
final static String INSTALL_DIR = "installdir=";
|
final static String INSTALL_DIR = "installdir=";
|
||||||
final static String PROPERTY_FILE = "propertyfile=";
|
final static String PROPERTY_FILE = "propertyfile=";
|
||||||
|
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
Properties properties;
|
Properties properties;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// debug stuff
|
// debug stuff
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
ServerKeystoreSetup p = new ServerKeystoreSetup(args);
|
ServerKeystoreSetup p = new ServerKeystoreSetup(args);
|
||||||
System.exit(p.rc);
|
System.exit(p.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerKeystoreSetup(String[] args)
|
ServerKeystoreSetup(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
file = new File("c:\\test2.log");
|
//file = new File("c:\\test2.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
// Process the input params
|
// Process the input params
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Make sure we got everything we need
|
// Make sure we got everything we need
|
||||||
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
|
if (ERROR_NO_ERROR == (rc = findRequiredValues()))
|
||||||
{
|
{
|
||||||
// Make sure the server keystore has been created
|
// Make sure the server keystore has been created
|
||||||
rc = createServerKeystore();
|
rc = createServerKeystore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
// DEBUG STUFF
|
// DEBUG STUFF
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
String sProperties;
|
String sProperties;
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
File fileProperties = null;
|
File fileProperties = null;
|
||||||
FileInputStream fisProperties = null;
|
FileInputStream fisProperties = null;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i] + "\r\n");
|
log("Arg " + i + " = " + args[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i <= iNew; i++)
|
for (i = 0; i <= iNew; i++)
|
||||||
{
|
{
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR))
|
if (args[i].startsWith(INSTALL_DIR))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= INSTALL_DIR.length())
|
if (args[i].length() <= INSTALL_DIR.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// is this the properties file param?
|
// is this the properties file param?
|
||||||
else if (args[i].startsWith(PROPERTY_FILE))
|
else if (args[i].startsWith(PROPERTY_FILE))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= PROPERTY_FILE.length())
|
if (args[i].length() <= PROPERTY_FILE.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
|
sProperties = args[i].substring(PROPERTY_FILE.length()).trim();
|
||||||
fileProperties = new File(sProperties);
|
fileProperties = new File(sProperties);
|
||||||
|
|
||||||
// Make sure the properties file can be found
|
// Make sure the properties file can be found
|
||||||
if (!fileProperties.exists())
|
if (!fileProperties.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_PROPERTIES_FILE;
|
return ERROR_MISSING_PROPERTIES_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the properties
|
// Read the properties
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fisProperties = new FileInputStream(fileProperties);
|
fisProperties = new FileInputStream(fileProperties);
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
properties.load(fisProperties);
|
properties.load(fisProperties);
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown parameter
|
// Unknown parameter
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log(ERROR_UNKNOWN_PARAM, args[i]);
|
log(ERROR_UNKNOWN_PARAM, args[i]);
|
||||||
return ERROR_UNKNOWN_PARAM;
|
return ERROR_UNKNOWN_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int findRequiredValues()
|
int findRequiredValues()
|
||||||
{
|
{
|
||||||
String[] rgsRequired = {
|
String[] rgsRequired = {
|
||||||
"ATS_JAVA_HOME",
|
"ATS_JAVA_HOME",
|
||||||
"COMPUTERNAME"};
|
"COMPUTERNAME"};
|
||||||
int i;
|
int i;
|
||||||
String sValue;
|
String sValue;
|
||||||
|
|
||||||
for (i = 0; i < rgsRequired.length; i++)
|
for (i = 0; i < rgsRequired.length; i++)
|
||||||
{
|
{
|
||||||
log("look for required value: " + rgsRequired[i]);
|
log("look for required value: " + rgsRequired[i]);
|
||||||
|
|
||||||
if (!properties.containsKey(rgsRequired[i]))
|
if (!properties.containsKey(rgsRequired[i]))
|
||||||
{
|
{
|
||||||
log("look for required value in envirement: " + rgsRequired[i]);
|
log("look for required value in envirement: " + rgsRequired[i]);
|
||||||
if (null == (sValue = System.getProperty(rgsRequired[i])))
|
if (null == (sValue = System.getProperty(rgsRequired[i])))
|
||||||
{
|
{
|
||||||
log("unable to find required value in envirement: " + rgsRequired[i]);
|
log("unable to find required value in envirement: " + rgsRequired[i]);
|
||||||
return ERROR_REQUIRED_VALUE_MISSING;
|
return ERROR_REQUIRED_VALUE_MISSING;
|
||||||
}
|
}
|
||||||
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
|
log("found required value in envirement: " + rgsRequired[i] + " = " + sValue);
|
||||||
properties.put(rgsRequired[i], sValue);
|
properties.put(rgsRequired[i], sValue);
|
||||||
}
|
}
|
||||||
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
|
log("found required value: " + rgsRequired[i] + " = " + properties.get(rgsRequired[i]));
|
||||||
}
|
}
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int createServerKeystore()
|
int createServerKeystore()
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
|
String sKeytool = properties.get("ATS_JAVA_HOME") + "\\bin\\keytool.exe";
|
||||||
String sHost = (String)properties.get("COMPUTERNAME");
|
String sHost = (String)properties.get("COMPUTERNAME");
|
||||||
|
|
||||||
log("keytool = " + sKeytool);
|
log("keytool = " + sKeytool);
|
||||||
log("host = " + sHost);
|
log("host = " + sHost);
|
||||||
|
|
||||||
// Do not do anything if the server keystore has already been created
|
// Do not do anything if the server keystore has already been created
|
||||||
if (keyStoreAlreadyExists())
|
if (keyStoreAlreadyExists())
|
||||||
{
|
{
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the server keystore with the key that will be used for signing tokens
|
// 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 " +
|
if (ERROR_NO_ERROR == (rc =invokeCommand(sKeytool + " -genkey -alias signingKey -keystore " +
|
||||||
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=casaatsd@" + sHost +
|
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=casaatsd@" + sHost +
|
||||||
"\" -validity 3600 -keypass secret -storepass secret")))
|
"\" -validity 3600 -keypass secret -storepass secret")))
|
||||||
{
|
{
|
||||||
// Export self-signed certificate for the signing key
|
// Export self-signed certificate for the signing key
|
||||||
if (ERROR_NO_ERROR == (rc = invokeCommand(sKeytool + " -export -keystore " +
|
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\\server\\jks-store -alias signingKey -storepass secret -keypass secret -file " +
|
||||||
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert")))
|
sInstallDir + "ats\\etc\\keys\\casaatsdSigningCert")))
|
||||||
{
|
{
|
||||||
// Create a key for Tomcat to do SSL communications
|
// Create a key for Tomcat to do SSL communications
|
||||||
rc = invokeCommand(sKeytool + " -genkey -alias tomcat -keyalg RSA -keystore " +
|
rc = invokeCommand(sKeytool + " -genkey -alias tomcat -keyalg RSA -keystore " +
|
||||||
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=" +
|
sInstallDir + "ats\\etc\\keys\\server\\jks-store -dname \"cn=" +
|
||||||
sHost + "\" -validity 3600 -keypass secret -storepass secret");
|
sHost + "\" -validity 3600 -keypass secret -storepass secret");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean keyStoreAlreadyExists()
|
boolean keyStoreAlreadyExists()
|
||||||
{
|
{
|
||||||
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\server\\jks-store");
|
File fileKeystore = new File(sInstallDir + "ats\\etc\\keys\\server\\jks-store");
|
||||||
|
|
||||||
// Why is this always returning true? exists() also always returns true.
|
// Why is this always returning true? exists() also always returns true.
|
||||||
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\server\\jks-store" + ") already exists = " + (file.isFile()));
|
// log("keystore (" + sInstallDir + "ats\\etc\\keys\\server\\jks-store" + ") already exists = " + (file.isFile()));
|
||||||
// return (file.isFile());
|
// return (file.isFile());
|
||||||
|
|
||||||
File fileParent = fileKeystore.getParentFile();
|
File fileParent = fileKeystore.getParentFile();
|
||||||
String[] rgChildren = fileParent.list();
|
String[] rgChildren = fileParent.list();
|
||||||
if (null != rgChildren)
|
if (null != rgChildren)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rgChildren.length; i++)
|
for (int i = 0; i < rgChildren.length; i++)
|
||||||
{
|
{
|
||||||
log("child " + i + " = " + rgChildren[i]);
|
log("child " + i + " = " + rgChildren[i]);
|
||||||
if ("jks-store".equals(rgChildren[i]))
|
if ("jks-store".equals(rgChildren[i]))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invokeCommand(String sCommand)
|
int invokeCommand(String sCommand)
|
||||||
{
|
{
|
||||||
Process p;
|
Process p;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
log("invoke command: " + sCommand);
|
log("invoke command: " + sCommand);
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = runtime.exec(sCommand);
|
p = runtime.exec(sCommand);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = p.waitFor();
|
rc = p.waitFor();
|
||||||
log("invoke command return code: " + rc);
|
log("invoke command return code: " + rc);
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
catch (InterruptedException ie)
|
||||||
{
|
{
|
||||||
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
||||||
return ERROR_EXEC_INTERRUPTED;
|
return ERROR_EXEC_INTERRUPTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log("Ioexception");
|
log("Ioexception");
|
||||||
return ERROR_EXEC_FAILED;
|
return ERROR_EXEC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_FAILED:
|
case ERROR_EXEC_FAILED:
|
||||||
sMessage = "Execute command failed ";
|
sMessage = "Execute command failed ";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of params";
|
sMessage = "Invalid number of params";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_INSTALL_DIR_PARAM:
|
case ERROR_BAD_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Install dir parameter is bad";
|
sMessage = "Install dir parameter is bad";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR:
|
case ERROR_MISSING_INSTALL_DIR:
|
||||||
sMessage = "Missing install dir";
|
sMessage = "Missing install dir";
|
||||||
break;
|
break;
|
||||||
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
||||||
sMessage = "Install dir is not a dir";
|
sMessage = "Install dir is not a dir";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Invalid porperty file parameter";
|
sMessage = "Invalid porperty file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTIES_FILE:
|
case ERROR_MISSING_PROPERTIES_FILE:
|
||||||
sMessage = "Property file not found";
|
sMessage = "Property file not found";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
||||||
sMessage = "Unable to read property file";
|
sMessage = "Unable to read property file";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNKNOWN_PARAM:
|
case ERROR_UNKNOWN_PARAM:
|
||||||
sMessage = "Unknown parameter: ";
|
sMessage = "Unknown parameter: ";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Install dir parameter is missing";
|
sMessage = "Install dir parameter is missing";
|
||||||
break;
|
break;
|
||||||
case ERROR_REQUIRED_VALUE_MISSING:
|
case ERROR_REQUIRED_VALUE_MISSING:
|
||||||
sMessage = "Required value is missing ";
|
sMessage = "Required value is missing ";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_INTERRUPTED:
|
case ERROR_EXEC_INTERRUPTED:
|
||||||
sMessage = "Execution iinterrupted: ";
|
sMessage = "Execution iinterrupted: ";
|
||||||
break;
|
break;
|
||||||
case ERROR_IO_EXCEPTION:
|
case ERROR_IO_EXCEPTION:
|
||||||
sMessage = "IO Exception ";
|
sMessage = "IO Exception ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error";
|
sMessage = "Unknown error";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
public class SetupAsWindowsService
|
||||||
{
|
{
|
||||||
final static int ERROR_NO_ERROR = 0;
|
final static int ERROR_NO_ERROR = 0;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
||||||
final static int ERROR_EXEC_FAILED = -2;
|
final static int ERROR_EXEC_FAILED = -2;
|
||||||
final static int ERROR_EXEC_INTERRUPTED = -3;
|
final static int ERROR_EXEC_INTERRUPTED = -3;
|
||||||
final static int ERROR_IO_EXCEPTION = -13;
|
final static int ERROR_IO_EXCEPTION = -13;
|
||||||
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
|
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR = -18;
|
final static int ERROR_MISSING_INSTALL_DIR = -18;
|
||||||
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
|
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
|
||||||
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
|
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
|
||||||
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
|
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
|
||||||
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
|
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
|
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
|
||||||
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
|
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
|
||||||
final static int ERROR_BAD_PROPERTY_PARAM = -29;
|
final static int ERROR_BAD_PROPERTY_PARAM = -29;
|
||||||
|
|
||||||
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
|
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
|
||||||
final static String PROPERTY_FILE_PARAM = "propertyfile=";
|
final static String PROPERTY_FILE_PARAM = "propertyfile=";
|
||||||
final static String INSTALL_DIR = "installdir=";
|
final static String INSTALL_DIR = "installdir=";
|
||||||
final static String PROPERTY_FILE = "propertyfile=";
|
final static String PROPERTY_FILE = "propertyfile=";
|
||||||
|
|
||||||
Properties properties;
|
Properties properties;
|
||||||
File fileProperties;
|
File fileProperties;
|
||||||
FileInputStream fisProperties;
|
FileInputStream fisProperties;
|
||||||
File fileOutput;
|
File fileOutput;
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
String sOutput;
|
String sOutput;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
SetupAsWindowsService p = new SetupAsWindowsService(args);
|
SetupAsWindowsService p = new SetupAsWindowsService(args);
|
||||||
System.exit(p.rc);
|
System.exit(p.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupAsWindowsService(String[] args)
|
SetupAsWindowsService(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
fileProperties = null;
|
fileProperties = null;
|
||||||
fisProperties = null;
|
fisProperties = null;
|
||||||
fileOutput = null;
|
fileOutput = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File("c:\\test6.log");
|
//file = new File("c:\\test6.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
log("Process args");
|
log("Process args");
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Process the properties
|
// Process the properties
|
||||||
log("Process properties");
|
log("Process properties");
|
||||||
if (ERROR_NO_ERROR == (rc = processProperties()))
|
if (ERROR_NO_ERROR == (rc = processProperties()))
|
||||||
{
|
{
|
||||||
log("setupService");
|
log("setupService");
|
||||||
rc = setupService();
|
rc = setupService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
String sProperties;
|
String sProperties;
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
int iEquals;
|
int iEquals;
|
||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
if (null == args[i])
|
if (null == args[i])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("arg[" + i + "] = " +args[i]);
|
log("arg[" + i + "] = " +args[i]);
|
||||||
|
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR))
|
if (args[i].startsWith(INSTALL_DIR))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= INSTALL_DIR.length())
|
if (args[i].length() <= INSTALL_DIR.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
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?
|
// is this the properties file param?
|
||||||
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
|
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
||||||
fileProperties = new File(sProperties);
|
fileProperties = new File(sProperties);
|
||||||
|
|
||||||
// Make sure the properties file can be found
|
// Make sure the properties file can be found
|
||||||
if (!fileProperties.exists())
|
if (!fileProperties.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_PROPERTIES_FILE;
|
return ERROR_MISSING_PROPERTIES_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the properties
|
// Read the properties
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fisProperties = new FileInputStream(fileProperties);
|
fisProperties = new FileInputStream(fileProperties);
|
||||||
properties.load(fisProperties);
|
properties.load(fisProperties);
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle additional parameters
|
// Handle additional parameters
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (-1 == (iEquals = args[i].indexOf("=")) ||
|
if (-1 == (iEquals = args[i].indexOf("=")) ||
|
||||||
0 == iEquals ||
|
0 == iEquals ||
|
||||||
args[i].length() == iEquals)
|
args[i].length() == iEquals)
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_PARAM;
|
return ERROR_BAD_PROPERTY_PARAM;
|
||||||
}
|
}
|
||||||
sKey = args[i].substring(0, iEquals);
|
sKey = args[i].substring(0, iEquals);
|
||||||
sValue = args[i].substring(iEquals + 1);
|
sValue = args[i].substring(iEquals + 1);
|
||||||
properties.setProperty(sKey, sValue);
|
properties.setProperty(sKey, sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
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()
|
int processProperties()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Enumeration e;
|
Enumeration e;
|
||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
|
|
||||||
e = properties.propertyNames();
|
e = properties.propertyNames();
|
||||||
|
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
{
|
{
|
||||||
sKey = (String)e.nextElement();
|
sKey = (String)e.nextElement();
|
||||||
sValue = (String)properties.get(sKey);
|
sValue = (String)properties.get(sKey);
|
||||||
|
|
||||||
log("Property key = " + sKey + " Value = " + sValue);
|
log("Property key = " + sKey + " Value = " + sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex1)
|
catch (Exception ex1)
|
||||||
{
|
{
|
||||||
return -111;
|
return -111;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setupService()
|
int setupService()
|
||||||
{
|
{
|
||||||
String sDirInstall = (String)properties.get(INSTALL_DIR_PROPERTY);
|
String sDirInstall = (String)properties.get(INSTALL_DIR_PROPERTY);
|
||||||
String sDirCatalinaBase = sInstallDir + "ats/catalinabase";
|
String sDirCatalinaBase = sInstallDir + "ats/catalinabase";
|
||||||
String sDirCatalinaHome = (String)properties.get("TOMCAT_HOME");
|
String sDirCatalinaHome = (String)properties.get("TOMCAT_HOME");
|
||||||
String sExe = (String)properties.get("TOMCAT5");
|
String sExe = (String)properties.get("TOMCAT5");
|
||||||
String sFileJaasConf = (String)properties.get("JAAS_CONF");
|
String sFileJaasConf = (String)properties.get("JAAS_CONF");
|
||||||
String sDirConfig = sDirInstall + "ats/etc/svc";
|
String sDirConfig = sDirInstall + "ats/etc/svc";
|
||||||
String sDirJavaHome = (String)properties.get("ATS_JAVA_HOME");
|
String sDirJavaHome = (String)properties.get("ATS_JAVA_HOME");
|
||||||
String sLogPrefix = "casa-auth-token-svc";
|
String sLogPrefix = "casa-auth-token-svc";
|
||||||
String sDirLogs = sDirCatalinaBase + "/logs";
|
String sDirLogs = sDirCatalinaBase + "/logs";
|
||||||
String sCommand = "";
|
String sCommand = "";
|
||||||
int iReturn = ERROR_NO_ERROR;
|
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";
|
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)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --Startup auto";
|
sCommand = sExe + " //US//CasaAuthTokenService --Startup auto";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --JvmOptions \"-Dcatalina.base=" + sDirCatalinaBase + "\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --JvmOptions \"-Dcatalina.base=" + sDirCatalinaBase + "\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcatalina.home=" + sDirCatalinaHome + "\"";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcatalina.home=" + sDirCatalinaHome + "\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.endorsed.dirs=" + sDirCatalinaHome + "/common/endorsed\"";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.endorsed.dirs=" + sDirCatalinaHome + "/common/endorsed\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.security.auth.login.config=" + sFileJaasConf + "\"";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.security.auth.login.config=" + sFileJaasConf + "\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcom.novell.casa.authtoksvc.config=" + sDirConfig + "\"";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dcom.novell.casa.authtoksvc.config=" + sDirConfig + "\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dlog4j.configuration=file:" + sDirInstall + "/ats/etc/log4j.properties";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Dlog4j.configuration=file:" + sDirInstall + "/ats/etc/log4j.properties";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.io.tmpdir=" + sDirCatalinaBase+ "/temp\"";
|
sCommand = sExe + " //US//CasaAuthTokenService ++JvmOptions \"-Djava.io.tmpdir=" + sDirCatalinaBase+ "/temp\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --StartMode jvm --StopMode jvm";
|
sCommand = sExe + " //US//CasaAuthTokenService --StartMode jvm --StopMode jvm";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --JvmMs 128 --JvmMx 512";
|
sCommand = sExe + " //US//CasaAuthTokenService --JvmMs 128 --JvmMx 512";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --Classpath \"" + sDirCatalinaHome + "/bin/bootstrap.jar\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --Classpath \"" + sDirCatalinaHome + "/bin/bootstrap.jar\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --Jvm \"" + sDirJavaHome + "/jre/bin/server/jvm.dll\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --Jvm \"" + sDirJavaHome + "/jre/bin/server/jvm.dll\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --LogPath \"" + sDirLogs + "\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --LogPath \"" + sDirLogs + "\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --LogPrefix \"" + sLogPrefix + "_service.log\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --LogPrefix \"" + sLogPrefix + "_service.log\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --StdOutput \"" + sDirLogs +
|
sCommand = sExe + " //US//CasaAuthTokenService --StdOutput \"" + sDirLogs +
|
||||||
File.separator + sLogPrefix + "_stdout.log\"";
|
File.separator + sLogPrefix + "_stdout.log\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --StdError \"" + sDirLogs +
|
sCommand = sExe + " //US//CasaAuthTokenService --StdError \"" + sDirLogs +
|
||||||
File.separator + sLogPrefix + "_stderr.log\"";
|
File.separator + sLogPrefix + "_stderr.log\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --DisplayName " + "CasaAuthTokenSvc";
|
sCommand = sExe + " //US//CasaAuthTokenService --DisplayName " + "CasaAuthTokenSvc";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //US//CasaAuthTokenService --Description " + "\"Casa Authentication Token Service\"";
|
sCommand = sExe + " //US//CasaAuthTokenService --Description " + "\"Casa Authentication Token Service\"";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invokeCommand(String sCommand)
|
int invokeCommand(String sCommand)
|
||||||
{
|
{
|
||||||
Process p;
|
Process p;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
log("invoke command: " + sCommand);
|
log("invoke command: " + sCommand);
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = runtime.exec(sCommand);
|
p = runtime.exec(sCommand);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = p.waitFor();
|
rc = p.waitFor();
|
||||||
log("invoke command return code: " + rc);
|
log("invoke command return code: " + rc);
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
catch (InterruptedException ie)
|
||||||
{
|
{
|
||||||
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
||||||
return ERROR_EXEC_INTERRUPTED;
|
return ERROR_EXEC_INTERRUPTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log("IOException");
|
log("IOException");
|
||||||
return ERROR_EXEC_FAILED;
|
return ERROR_EXEC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of parameters: 4 expected";
|
sMessage = "Invalid number of parameters: 4 expected";
|
||||||
break;
|
break;
|
||||||
case ERROR_IO_EXCEPTION:
|
case ERROR_IO_EXCEPTION:
|
||||||
sMessage = "IOException";
|
sMessage = "IOException";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_FAILED:
|
case ERROR_EXEC_FAILED:
|
||||||
sMessage = "Exec failed";
|
sMessage = "Exec failed";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_INTERRUPTED:
|
case ERROR_EXEC_INTERRUPTED:
|
||||||
sMessage = "Exec interrupted";
|
sMessage = "Exec interrupted";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
||||||
sMessage = "nable to read properties";
|
sMessage = "nable to read properties";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR:
|
case ERROR_MISSING_INSTALL_DIR:
|
||||||
sMessage = "Missing install directory";
|
sMessage = "Missing install directory";
|
||||||
break;
|
break;
|
||||||
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
||||||
sMessage = "Install directory is not a directory";
|
sMessage = "Install directory is not a directory";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_INSTALL_DIR_PARAM:
|
case ERROR_BAD_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Bad install directory parameter";
|
sMessage = "Bad install directory parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Bad property file parameter";
|
sMessage = "Bad property file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTIES_FILE:
|
case ERROR_MISSING_PROPERTIES_FILE:
|
||||||
sMessage = "Missing properties file";
|
sMessage = "Missing properties file";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Missing install directory parameter";
|
sMessage = "Missing install directory parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTY_FILE_PARAM:
|
case ERROR_MISSING_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Missing property file parameter";
|
sMessage = "Missing property file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_PARAM:
|
case ERROR_BAD_PROPERTY_PARAM:
|
||||||
sMessage = "Bad property parameter";
|
sMessage = "Bad property parameter";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error: " + err;
|
sMessage = "Unknown error: " + err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
public class ShutdownWindowsService
|
||||||
{
|
{
|
||||||
final static int ERROR_NO_ERROR = 0;
|
final static int ERROR_NO_ERROR = 0;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -1;
|
||||||
final static int ERROR_EXEC_FAILED = -2;
|
final static int ERROR_EXEC_FAILED = -2;
|
||||||
final static int ERROR_EXEC_INTERRUPTED = -3;
|
final static int ERROR_EXEC_INTERRUPTED = -3;
|
||||||
final static int ERROR_IO_EXCEPTION = -13;
|
final static int ERROR_IO_EXCEPTION = -13;
|
||||||
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
|
final static int ERROR_UNABLE_TO_READ_PROPERTIES = -16;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR = -18;
|
final static int ERROR_MISSING_INSTALL_DIR = -18;
|
||||||
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
|
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -19;
|
||||||
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
|
final static int ERROR_BAD_INSTALL_DIR_PARAM = -20;
|
||||||
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
|
final static int ERROR_BAD_PROPERTY_FILE_PARAM = -21;
|
||||||
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
|
final static int ERROR_MISSING_PROPERTIES_FILE = -22;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
|
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -23;
|
||||||
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
|
final static int ERROR_MISSING_PROPERTY_FILE_PARAM = -24;
|
||||||
final static int ERROR_BAD_PROPERTY_PARAM = -29;
|
final static int ERROR_BAD_PROPERTY_PARAM = -29;
|
||||||
|
|
||||||
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
|
final static String INSTALL_DIR_PROPERTY = "ATS_INSTALL_DIR";
|
||||||
final static String PROPERTY_FILE_PARAM = "propertyfile=";
|
final static String PROPERTY_FILE_PARAM = "propertyfile=";
|
||||||
final static String INSTALL_DIR = "installdir=";
|
final static String INSTALL_DIR = "installdir=";
|
||||||
final static String PROPERTY_FILE = "propertyfile=";
|
final static String PROPERTY_FILE = "propertyfile=";
|
||||||
|
|
||||||
Properties properties;
|
Properties properties;
|
||||||
File fileProperties;
|
File fileProperties;
|
||||||
FileInputStream fisProperties;
|
FileInputStream fisProperties;
|
||||||
File fileOutput;
|
File fileOutput;
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
String sOutput;
|
String sOutput;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
ShutdownWindowsService p = new ShutdownWindowsService(args);
|
ShutdownWindowsService p = new ShutdownWindowsService(args);
|
||||||
System.exit(ERROR_NO_ERROR);
|
System.exit(ERROR_NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShutdownWindowsService(String[] args)
|
ShutdownWindowsService(String[] args)
|
||||||
{
|
{
|
||||||
rc = ERROR_NO_ERROR;
|
rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
fileProperties = null;
|
fileProperties = null;
|
||||||
fisProperties = null;
|
fisProperties = null;
|
||||||
fileOutput = null;
|
fileOutput = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File("c:\\test7.log");
|
//file = new File("c:\\test7.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Process the properties
|
// Process the properties
|
||||||
if (ERROR_NO_ERROR == (rc = processProperties()))
|
if (ERROR_NO_ERROR == (rc = processProperties()))
|
||||||
{
|
{
|
||||||
rc = shutdownService();
|
rc = shutdownService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
String sProperties;
|
String sProperties;
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
int iEquals;
|
int iEquals;
|
||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
if (null == args[i])
|
if (null == args[i])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("arg[" + i + "] = " +args[i]);
|
log("arg[" + i + "] = " +args[i]);
|
||||||
|
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR))
|
if (args[i].startsWith(INSTALL_DIR))
|
||||||
{
|
{
|
||||||
// Make sure it is more the the param tag
|
// Make sure it is more the the param tag
|
||||||
if (args[i].length() <= INSTALL_DIR.length())
|
if (args[i].length() <= INSTALL_DIR.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
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?
|
// is this the properties file param?
|
||||||
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
else if (args[i].startsWith(PROPERTY_FILE_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
|
if (args[i].length() <= PROPERTY_FILE_PARAM.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
return ERROR_BAD_PROPERTY_FILE_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
sProperties = args[i].substring(PROPERTY_FILE_PARAM.length()).trim();
|
||||||
fileProperties = new File(sProperties);
|
fileProperties = new File(sProperties);
|
||||||
|
|
||||||
// Make sure the properties file can be found
|
// Make sure the properties file can be found
|
||||||
if (!fileProperties.exists())
|
if (!fileProperties.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_PROPERTIES_FILE;
|
return ERROR_MISSING_PROPERTIES_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the properties
|
// Read the properties
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fisProperties = new FileInputStream(fileProperties);
|
fisProperties = new FileInputStream(fileProperties);
|
||||||
properties.load(fisProperties);
|
properties.load(fisProperties);
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
return ERROR_UNABLE_TO_READ_PROPERTIES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle additional parameters
|
// Handle additional parameters
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (-1 == (iEquals = args[i].indexOf("=")) ||
|
if (-1 == (iEquals = args[i].indexOf("=")) ||
|
||||||
0 == iEquals ||
|
0 == iEquals ||
|
||||||
args[i].length() == iEquals)
|
args[i].length() == iEquals)
|
||||||
{
|
{
|
||||||
return ERROR_BAD_PROPERTY_PARAM;
|
return ERROR_BAD_PROPERTY_PARAM;
|
||||||
}
|
}
|
||||||
sKey = args[i].substring(0, iEquals);
|
sKey = args[i].substring(0, iEquals);
|
||||||
sValue = args[i].substring(iEquals + 1);
|
sValue = args[i].substring(iEquals + 1);
|
||||||
properties.setProperty(sKey, sValue);
|
properties.setProperty(sKey, sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
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()
|
int processProperties()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Enumeration e;
|
Enumeration e;
|
||||||
String sKey;
|
String sKey;
|
||||||
String sValue;
|
String sValue;
|
||||||
|
|
||||||
e = properties.propertyNames();
|
e = properties.propertyNames();
|
||||||
|
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
{
|
{
|
||||||
sKey = (String)e.nextElement();
|
sKey = (String)e.nextElement();
|
||||||
sValue = (String)properties.get(sKey);
|
sValue = (String)properties.get(sKey);
|
||||||
|
|
||||||
log("Property key = " + sKey + " Value = " + sValue);
|
log("Property key = " + sKey + " Value = " + sValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex1)
|
catch (Exception ex1)
|
||||||
{
|
{
|
||||||
return -111;
|
return -111;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int shutdownService()
|
int shutdownService()
|
||||||
{
|
{
|
||||||
String sExe = (String)properties.get("TOMCAT5");
|
String sExe = (String)properties.get("TOMCAT5");
|
||||||
String sCommand = "";
|
String sCommand = "";
|
||||||
int iReturn = ERROR_NO_ERROR;
|
int iReturn = ERROR_NO_ERROR;
|
||||||
|
|
||||||
sCommand = sExe + " //SS//CasaAuthTokenService";
|
sCommand = sExe + " //SS//CasaAuthTokenService";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
sCommand = sExe + " //DS//CasaAuthTokenService";
|
sCommand = sExe + " //DS//CasaAuthTokenService";
|
||||||
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
if (ERROR_NO_ERROR != (iReturn = invokeCommand(sCommand)))
|
||||||
{
|
{
|
||||||
return iReturn;
|
return iReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int invokeCommand(String sCommand)
|
int invokeCommand(String sCommand)
|
||||||
{
|
{
|
||||||
Process p;
|
Process p;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
log("invoke command: " + sCommand);
|
log("invoke command: " + sCommand);
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p = runtime.exec(sCommand);
|
p = runtime.exec(sCommand);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rc = p.waitFor();
|
rc = p.waitFor();
|
||||||
log("invoke command return code: " + rc);
|
log("invoke command return code: " + rc);
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie)
|
catch (InterruptedException ie)
|
||||||
{
|
{
|
||||||
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
log(ERROR_EXEC_INTERRUPTED, sCommand);
|
||||||
return ERROR_EXEC_INTERRUPTED;
|
return ERROR_EXEC_INTERRUPTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
log("IOException");
|
log("IOException");
|
||||||
return ERROR_EXEC_FAILED;
|
return ERROR_EXEC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of parameters: 4 expected";
|
sMessage = "Invalid number of parameters: 4 expected";
|
||||||
break;
|
break;
|
||||||
case ERROR_IO_EXCEPTION:
|
case ERROR_IO_EXCEPTION:
|
||||||
sMessage = "IOException";
|
sMessage = "IOException";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_FAILED:
|
case ERROR_EXEC_FAILED:
|
||||||
sMessage = "Exec failed";
|
sMessage = "Exec failed";
|
||||||
break;
|
break;
|
||||||
case ERROR_EXEC_INTERRUPTED:
|
case ERROR_EXEC_INTERRUPTED:
|
||||||
sMessage = "Exec interrupted";
|
sMessage = "Exec interrupted";
|
||||||
break;
|
break;
|
||||||
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
case ERROR_UNABLE_TO_READ_PROPERTIES:
|
||||||
sMessage = "nable to read properties";
|
sMessage = "nable to read properties";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR:
|
case ERROR_MISSING_INSTALL_DIR:
|
||||||
sMessage = "Missing install directory";
|
sMessage = "Missing install directory";
|
||||||
break;
|
break;
|
||||||
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
case ERROR_INSTALL_DIR_NOT_A_DIR:
|
||||||
sMessage = "Install directory is not a directory";
|
sMessage = "Install directory is not a directory";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_INSTALL_DIR_PARAM:
|
case ERROR_BAD_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Bad install directory parameter";
|
sMessage = "Bad install directory parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
case ERROR_BAD_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Bad property file parameter";
|
sMessage = "Bad property file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTIES_FILE:
|
case ERROR_MISSING_PROPERTIES_FILE:
|
||||||
sMessage = "Missing properties file";
|
sMessage = "Missing properties file";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
case ERROR_MISSING_INSTALL_DIR_PARAM:
|
||||||
sMessage = "Missing install directory parameter";
|
sMessage = "Missing install directory parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_MISSING_PROPERTY_FILE_PARAM:
|
case ERROR_MISSING_PROPERTY_FILE_PARAM:
|
||||||
sMessage = "Missing property file parameter";
|
sMessage = "Missing property file parameter";
|
||||||
break;
|
break;
|
||||||
case ERROR_BAD_PROPERTY_PARAM:
|
case ERROR_BAD_PROPERTY_PARAM:
|
||||||
sMessage = "Bad property parameter";
|
sMessage = "Bad property parameter";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error: " + err;
|
sMessage = "Unknown error: " + err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* To contact Novell about this file by physical or electronic mail,
|
* To contact Novell about this file by physical or electronic mail,
|
||||||
* you may find current contact information at www.novell.com.
|
* 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
|
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_NO_ERROR = 0;
|
||||||
final static int ERROR_IO_EXCEPTION = -1;
|
final static int ERROR_IO_EXCEPTION = -1;
|
||||||
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
final static int ERROR_INVALID_NUMBER_OF_PARAMS = -2;
|
||||||
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
final static int ERROR_BAD_INSTALL_DIR_PARAM = -3;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
final static int ERROR_MISSING_INSTALL_DIR = -4;
|
||||||
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
final static int ERROR_INSTALL_DIR_NOT_A_DIR = -5;
|
||||||
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -6;
|
final static int ERROR_MISSING_INSTALL_DIR_PARAM = -6;
|
||||||
final static int ERROR_WAR_TEMPLATE_FILE_MISSING = -7;
|
final static int ERROR_WAR_TEMPLATE_FILE_MISSING = -7;
|
||||||
final static int ERROR_NEW_JAR_CANNOT_BE_REPLACED = -8;
|
final static int ERROR_NEW_JAR_CANNOT_BE_REPLACED = -8;
|
||||||
final static int ERROR_JAR_COPY_FAILED = -9;
|
final static int ERROR_JAR_COPY_FAILED = -9;
|
||||||
final static int ERROR_CREATE_WAR_FILE_FAILED = -10;
|
final static int ERROR_CREATE_WAR_FILE_FAILED = -10;
|
||||||
final static int ERROR_CREATE_WAR_FOS_FAILED = -11;
|
final static int ERROR_CREATE_WAR_FOS_FAILED = -11;
|
||||||
final static int ERROR_OPEN_JAR_TEMPLATE_FAILED = -12;
|
final static int ERROR_OPEN_JAR_TEMPLATE_FAILED = -12;
|
||||||
final static int ERROR_JOS_FLUSH_FAILED = -13;
|
final static int ERROR_JOS_FLUSH_FAILED = -13;
|
||||||
final static int ERROR_ADD_FILE_TO_JAR_FAILED = -14;
|
final static int ERROR_ADD_FILE_TO_JAR_FAILED = -14;
|
||||||
final static int ERROR_JOS_CLOSE_FAILED = -15;
|
final static int ERROR_JOS_CLOSE_FAILED = -15;
|
||||||
final static int ERROR_FOS_CLOSE_FAILED = -16;
|
final static int ERROR_FOS_CLOSE_FAILED = -16;
|
||||||
final static int ERROR_JFTEMPLATE_CLOSE_FAILED = -17;
|
final static int ERROR_JFTEMPLATE_CLOSE_FAILED = -17;
|
||||||
|
|
||||||
String sInstallDir;
|
String sInstallDir;
|
||||||
File file;
|
//File file;
|
||||||
FileWriter fw;
|
//FileWriter fw;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
UpdateWarFile p = new UpdateWarFile(args);
|
UpdateWarFile p = new UpdateWarFile(args);
|
||||||
System.exit(p.rc);
|
System.exit(p.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWarFile(String[] args)
|
UpdateWarFile(String[] args)
|
||||||
{
|
{
|
||||||
sInstallDir = null;
|
sInstallDir = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new File("c:\\test3.log");
|
//file = new File("c:\\test3.log");
|
||||||
fw = new FileWriter(file);
|
//fw = new FileWriter(file);
|
||||||
|
|
||||||
log("Here we go: " + args.length);
|
log("Here we go: " + args.length);
|
||||||
for (int i = 0; i < args.length; i++)
|
for (int i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + args[i]);
|
log("Arg " + i + " = " + args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the arguments
|
// Process the arguments
|
||||||
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
if (ERROR_NO_ERROR == (rc = processArgs(args)))
|
||||||
{
|
{
|
||||||
// Create the modified war file
|
// Create the modified war file
|
||||||
rc = createWarFile();
|
rc = createWarFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
rc = ERROR_IO_EXCEPTION;
|
rc = ERROR_IO_EXCEPTION;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log(rc);
|
log(rc);
|
||||||
fw.flush();
|
//fw.flush();
|
||||||
fw.close();
|
//fw.close();
|
||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int processArgs(String[] argsOld)
|
int processArgs(String[] argsOld)
|
||||||
{
|
{
|
||||||
File fileInstallDir = null;
|
File fileInstallDir = null;
|
||||||
int iOld;
|
int iOld;
|
||||||
int i;
|
int i;
|
||||||
String args[] = new String[argsOld.length];
|
String args[] = new String[argsOld.length];
|
||||||
int iNew;
|
int iNew;
|
||||||
|
|
||||||
log("Original arg count " + argsOld.length);
|
log("Original arg count " + argsOld.length);
|
||||||
for (i = 0; i < argsOld.length; i++)
|
for (i = 0; i < argsOld.length; i++)
|
||||||
{
|
{
|
||||||
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
log("Arg " + i + " = " + argsOld[i] + "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the number of parameters
|
// Validate the number of parameters
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
return ERROR_INVALID_NUMBER_OF_PARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
iNew = -1;
|
iNew = -1;
|
||||||
for (iOld = 0; iOld < argsOld.length; iOld++)
|
for (iOld = 0; iOld < argsOld.length; iOld++)
|
||||||
{
|
{
|
||||||
if (0 <= argsOld[iOld].indexOf("="))
|
if (0 <= argsOld[iOld].indexOf("="))
|
||||||
{
|
{
|
||||||
iNew++;
|
iNew++;
|
||||||
args[iNew] = argsOld[iOld];
|
args[iNew] = argsOld[iOld];
|
||||||
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
for (i = iOld + 1; i < argsOld.length && (-1 == argsOld[i].indexOf("=")); i++)
|
||||||
{
|
{
|
||||||
args[iNew] += " " + argsOld[i];
|
args[iNew] += " " + argsOld[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("New arg count " + args.length);
|
log("New arg count " + args.length);
|
||||||
for (i = 0; i < args.length; i++)
|
for (i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
log("arg[" + i + "] = " + args[i]);
|
log("arg[" + i + "] = " + args[i]);
|
||||||
|
|
||||||
// is this the install dir param?
|
// is this the install dir param?
|
||||||
if (args[i].startsWith(INSTALL_DIR_PARAM))
|
if (args[i].startsWith(INSTALL_DIR_PARAM))
|
||||||
{
|
{
|
||||||
// Make sure it is more than the param tag
|
// Make sure it is more than the param tag
|
||||||
if (args[i].length() <= INSTALL_DIR_PARAM.length())
|
if (args[i].length() <= INSTALL_DIR_PARAM.length())
|
||||||
{
|
{
|
||||||
return ERROR_BAD_INSTALL_DIR_PARAM;
|
return ERROR_BAD_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
|
sInstallDir = args[i].substring(INSTALL_DIR_PARAM.length()).trim();
|
||||||
fileInstallDir = new File(sInstallDir);
|
fileInstallDir = new File(sInstallDir);
|
||||||
|
|
||||||
// Make sure the install dir can be found
|
// Make sure the install dir can be found
|
||||||
if (!fileInstallDir.exists())
|
if (!fileInstallDir.exists())
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR;
|
return ERROR_MISSING_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the install dir is a directory
|
// Make sure the install dir is a directory
|
||||||
if (!fileInstallDir.isDirectory())
|
if (!fileInstallDir.isDirectory())
|
||||||
{
|
{
|
||||||
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
return ERROR_INSTALL_DIR_NOT_A_DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got an install dir
|
// Make sure we got an install dir
|
||||||
if (null == fileInstallDir)
|
if (null == fileInstallDir)
|
||||||
{
|
{
|
||||||
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
return ERROR_MISSING_INSTALL_DIR_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ERROR_NO_ERROR;
|
return ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createWarFile()
|
int createWarFile()
|
||||||
{
|
{
|
||||||
String sWarTemplate = sInstallDir + "ats\\etc\\svc\\templates\\CasaAuthTokenSvc.war";
|
String sWarTemplate = sInstallDir + "ats\\etc\\svc\\templates\\CasaAuthTokenSvc.war";
|
||||||
String sWarNew = sInstallDir + "ats\\catalinabase\\webapps\\CasaAuthTokenSvc.war";
|
String sWarNew = sInstallDir + "ats\\catalinabase\\webapps\\CasaAuthTokenSvc.war";
|
||||||
File fileWarTemplate = new File(sWarTemplate);;
|
File fileWarTemplate = new File(sWarTemplate);;
|
||||||
File fileWarNew = new File(sWarNew);
|
File fileWarNew = new File(sWarNew);
|
||||||
FileOutputStream fosWarNew = null;
|
FileOutputStream fosWarNew = null;
|
||||||
ZipOutputStream josWarNew = null;
|
ZipOutputStream josWarNew = null;
|
||||||
ZipFile jfTemplate = null;
|
ZipFile jfTemplate = null;
|
||||||
int rc = ERROR_NO_ERROR;
|
int rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
// Ensure that the war template exists
|
// Ensure that the war template exists
|
||||||
log("looking for war template: " + sWarTemplate);
|
log("looking for war template: " + sWarTemplate);
|
||||||
if (!fileWarTemplate.exists())
|
if (!fileWarTemplate.exists())
|
||||||
{
|
{
|
||||||
rc = ERROR_WAR_TEMPLATE_FILE_MISSING;
|
rc = ERROR_WAR_TEMPLATE_FILE_MISSING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ERROR_NO_ERROR)
|
if (rc == ERROR_NO_ERROR)
|
||||||
{
|
{
|
||||||
// Ensure that the new jar name does not exist
|
// Ensure that the new jar name does not exist
|
||||||
if (fileWarNew.exists())
|
if (fileWarNew.exists())
|
||||||
{
|
{
|
||||||
log("war file already exists: " + sWarNew);
|
log("war file already exists: " + sWarNew);
|
||||||
if (!fileWarNew.delete())
|
if (!fileWarNew.delete())
|
||||||
{
|
{
|
||||||
log("could not delete war file: " + sWarNew);
|
log("could not delete war file: " + sWarNew);
|
||||||
rc = ERROR_NEW_JAR_CANNOT_BE_REPLACED;
|
rc = ERROR_NEW_JAR_CANNOT_BE_REPLACED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ERROR_NO_ERROR)
|
if (rc == ERROR_NO_ERROR)
|
||||||
{
|
{
|
||||||
// Create/open the new jar
|
// Create/open the new jar
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
log("create new war file output stream: " + sWarNew);
|
log("create new war file output stream: " + sWarNew);
|
||||||
fosWarNew = new FileOutputStream(fileWarNew);
|
fosWarNew = new FileOutputStream(fileWarNew);
|
||||||
josWarNew = new ZipOutputStream(fosWarNew);
|
josWarNew = new ZipOutputStream(fosWarNew);
|
||||||
}
|
}
|
||||||
catch (IOException ioe0)
|
catch (IOException ioe0)
|
||||||
{
|
{
|
||||||
log(ioe0.toString());
|
log(ioe0.toString());
|
||||||
rc = ERROR_CREATE_WAR_FOS_FAILED;
|
rc = ERROR_CREATE_WAR_FOS_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ERROR_NO_ERROR)
|
if (rc == ERROR_NO_ERROR)
|
||||||
{
|
{
|
||||||
// Open the old jar
|
// Open the old jar
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jfTemplate = new ZipFile(sWarTemplate);
|
jfTemplate = new ZipFile(sWarTemplate);
|
||||||
}
|
}
|
||||||
catch (IOException ioe1)
|
catch (IOException ioe1)
|
||||||
{
|
{
|
||||||
rc = ERROR_OPEN_JAR_TEMPLATE_FAILED;
|
rc = ERROR_OPEN_JAR_TEMPLATE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == ERROR_NO_ERROR)
|
if (rc == ERROR_NO_ERROR)
|
||||||
{
|
{
|
||||||
// Transfer the files
|
// Transfer the files
|
||||||
rc = moveFilesFromJarToJar(josWarNew, jfTemplate);
|
rc = moveFilesFromJarToJar(josWarNew, jfTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the files
|
// Add the files
|
||||||
if (rc == ERROR_NO_ERROR)
|
if (rc == ERROR_NO_ERROR)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
String [] rgsFilesToAdd = new String[1];
|
String [] rgsFilesToAdd = new String[1];
|
||||||
rgsFilesToAdd[0] = sInstallDir + "ats\\etc\\svc\\templates\\casa_crypto.properties";
|
rgsFilesToAdd[0] = sInstallDir + "ats\\etc\\svc\\templates\\casa_crypto.properties";
|
||||||
String [] rgsNames = new String[1];
|
String [] rgsNames = new String[1];
|
||||||
rgsNames[0] = "WEB-INF/classes/casa_crypto.properties";
|
rgsNames[0] = "WEB-INF/classes/casa_crypto.properties";
|
||||||
for (i = 0; i < rgsFilesToAdd.length; i++)
|
for (i = 0; i < rgsFilesToAdd.length; i++)
|
||||||
{
|
{
|
||||||
log("Adding file: " + rgsFilesToAdd[i] + " with name " + rgsNames[i]);
|
log("Adding file: " + rgsFilesToAdd[i] + " with name " + rgsNames[i]);
|
||||||
rc = addFileToJar(rgsFilesToAdd[i], rgsNames[i], josWarNew);
|
rc = addFileToJar(rgsFilesToAdd[i], rgsNames[i], josWarNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close up
|
// Close up
|
||||||
if (null != josWarNew)
|
if (null != josWarNew)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
josWarNew.flush();
|
josWarNew.flush();
|
||||||
}
|
}
|
||||||
catch (IOException ioe2)
|
catch (IOException ioe2)
|
||||||
{
|
{
|
||||||
rc = ERROR_JOS_FLUSH_FAILED;
|
rc = ERROR_JOS_FLUSH_FAILED;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
josWarNew.close();
|
josWarNew.close();
|
||||||
}
|
}
|
||||||
catch (IOException ioe3)
|
catch (IOException ioe3)
|
||||||
{
|
{
|
||||||
rc = ERROR_JOS_CLOSE_FAILED;
|
rc = ERROR_JOS_CLOSE_FAILED;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fosWarNew.close();
|
fosWarNew.close();
|
||||||
}
|
}
|
||||||
catch (IOException ioe4)
|
catch (IOException ioe4)
|
||||||
{
|
{
|
||||||
rc = ERROR_FOS_CLOSE_FAILED;
|
rc = ERROR_FOS_CLOSE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (null != jfTemplate)
|
if (null != jfTemplate)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jfTemplate.close();
|
jfTemplate.close();
|
||||||
}
|
}
|
||||||
catch (IOException ioe5)
|
catch (IOException ioe5)
|
||||||
{
|
{
|
||||||
rc = ERROR_JFTEMPLATE_CLOSE_FAILED;
|
rc = ERROR_JFTEMPLATE_CLOSE_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int moveFilesFromJarToJar(ZipOutputStream josDst, ZipFile jfSrc)
|
int moveFilesFromJarToJar(ZipOutputStream josDst, ZipFile jfSrc)
|
||||||
{
|
{
|
||||||
int rc = ERROR_NO_ERROR;
|
int rc = ERROR_NO_ERROR;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Enumeration entries = jfSrc.entries();
|
Enumeration entries = jfSrc.entries();
|
||||||
ZipEntry jeLoop;
|
ZipEntry jeLoop;
|
||||||
InputStream isLoop;
|
InputStream isLoop;
|
||||||
ZipEntry zeIndex;
|
ZipEntry zeIndex;
|
||||||
int bRead;
|
int bRead;
|
||||||
byte [] b = new byte[4096];
|
byte [] b = new byte[4096];
|
||||||
|
|
||||||
while (entries.hasMoreElements())
|
while (entries.hasMoreElements())
|
||||||
{
|
{
|
||||||
jeLoop = (ZipEntry)entries.nextElement();
|
jeLoop = (ZipEntry)entries.nextElement();
|
||||||
|
|
||||||
// Skip WEB-INF/classes/cypto.properties
|
// Skip WEB-INF/classes/cypto.properties
|
||||||
if (jeLoop.getName().equalsIgnoreCase("WEB-INF/classes/casa_crypto.properties"))
|
if (jeLoop.getName().equalsIgnoreCase("WEB-INF/classes/casa_crypto.properties"))
|
||||||
{
|
{
|
||||||
log("skipping: " + "WEB-INF/classes/casa_crypto.properties");
|
log("skipping: " + "WEB-INF/classes/casa_crypto.properties");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the rest of the files over
|
// Move the rest of the files over
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log("Transferring jar file: " + jeLoop.getName());
|
log("Transferring jar file: " + jeLoop.getName());
|
||||||
|
|
||||||
// Create the input stream
|
// Create the input stream
|
||||||
isLoop = jfSrc.getInputStream(jeLoop);
|
isLoop = jfSrc.getInputStream(jeLoop);
|
||||||
|
|
||||||
// Set up the output stream
|
// Set up the output stream
|
||||||
zeIndex = new ZipEntry(jeLoop.getName());
|
zeIndex = new ZipEntry(jeLoop.getName());
|
||||||
josDst.putNextEntry( zeIndex);
|
josDst.putNextEntry( zeIndex);
|
||||||
|
|
||||||
// Transfer the file contents
|
// Transfer the file contents
|
||||||
while (-1 != (bRead = isLoop.read(b)))
|
while (-1 != (bRead = isLoop.read(b)))
|
||||||
{
|
{
|
||||||
josDst.write(b, 0, bRead);
|
josDst.write(b, 0, bRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
// all done
|
// all done
|
||||||
josDst.closeEntry();
|
josDst.closeEntry();
|
||||||
isLoop.close();
|
isLoop.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
rc = ERROR_JAR_COPY_FAILED;
|
rc = ERROR_JAR_COPY_FAILED;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int addFileToJar(String sFilename, String sName, ZipOutputStream josJarNew)
|
int addFileToJar(String sFilename, String sName, ZipOutputStream josJarNew)
|
||||||
{
|
{
|
||||||
FileInputStream fis;
|
FileInputStream fis;
|
||||||
ZipEntry je;
|
ZipEntry je;
|
||||||
int bRead;
|
int bRead;
|
||||||
byte [] b = new byte[4096];
|
byte [] b = new byte[4096];
|
||||||
int rc = ERROR_NO_ERROR;
|
int rc = ERROR_NO_ERROR;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create the input stream
|
// Create the input stream
|
||||||
fis = new FileInputStream(sFilename);
|
fis = new FileInputStream(sFilename);
|
||||||
|
|
||||||
// Set up the output stream
|
// Set up the output stream
|
||||||
je = new ZipEntry(sName);
|
je = new ZipEntry(sName);
|
||||||
josJarNew.putNextEntry(je);
|
josJarNew.putNextEntry(je);
|
||||||
|
|
||||||
// Tansfer the contents of the file
|
// Tansfer the contents of the file
|
||||||
while (-1 != (bRead = fis.read(b)))
|
while (-1 != (bRead = fis.read(b)))
|
||||||
{
|
{
|
||||||
josJarNew.write(b, 0, bRead);
|
josJarNew.write(b, 0, bRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
fis.close();
|
fis.close();
|
||||||
josJarNew.closeEntry();
|
josJarNew.closeEntry();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log(e.toString());
|
log(e.toString());
|
||||||
rc = ERROR_ADD_FILE_TO_JAR_FAILED;
|
rc = ERROR_ADD_FILE_TO_JAR_FAILED;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err)
|
void log(int err)
|
||||||
{
|
{
|
||||||
log(err, null);
|
log(err, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int err, String s)
|
void log(int err, String s)
|
||||||
{
|
{
|
||||||
String sMessage = "";
|
String sMessage = "";
|
||||||
|
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
case ERROR_NO_ERROR:
|
case ERROR_NO_ERROR:
|
||||||
sMessage = "No error";
|
sMessage = "No error";
|
||||||
break;
|
break;
|
||||||
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
case ERROR_INVALID_NUMBER_OF_PARAMS:
|
||||||
sMessage = "Invalid number of parameters: 1make expected";
|
sMessage = "Invalid number of parameters: 1make expected";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sMessage = "Unknown error: " + err;
|
sMessage = "Unknown error: " + err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != s)
|
if (null != s)
|
||||||
{
|
{
|
||||||
sMessage = sMessage + s;
|
sMessage = sMessage + s;
|
||||||
}
|
}
|
||||||
log(sMessage);
|
log(sMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(String s)
|
void log(String s)
|
||||||
{
|
{
|
||||||
try
|
/*
|
||||||
{
|
try
|
||||||
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
{
|
||||||
}
|
fw.write(this.getClass().getName() + ": " + s + "\r\n");
|
||||||
catch (IOException ioe)
|
}
|
||||||
{
|
catch (IOException ioe)
|
||||||
}
|
{
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,12 @@
|
|||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
|
"MsmKey" = "8:_55AF3B67412A49E3A568102FDADDC2FE"
|
||||||
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
"MsmKey" = "8:_5B105FED430E4D998914B3562D4A8EA1"
|
"MsmKey" = "8:_5B105FED430E4D998914B3562D4A8EA1"
|
||||||
"OwnerKey" = "8:_UNDEFINED"
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
@ -958,7 +964,7 @@
|
|||||||
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\xercesImpl.jar"
|
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\xercesImpl.jar"
|
||||||
"TargetName" = "8:xercesImpl.jar"
|
"TargetName" = "8:xercesImpl.jar"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
|
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
|
||||||
"Condition" = "8:"
|
"Condition" = "8:"
|
||||||
"Transitive" = "11:FALSE"
|
"Transitive" = "11:FALSE"
|
||||||
"Vital" = "11:TRUE"
|
"Vital" = "11:TRUE"
|
||||||
@ -1113,6 +1119,26 @@
|
|||||||
"IsDependency" = "11:FALSE"
|
"IsDependency" = "11:FALSE"
|
||||||
"IsolateTo" = "8:"
|
"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"
|
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5B105FED430E4D998914B3562D4A8EA1"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\UpdateWarFile\\bin\\UpdateWarFile.class"
|
"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"
|
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\xmlsec-1.4.0.jar"
|
||||||
"TargetName" = "8:xmlsec-1.4.0.jar"
|
"TargetName" = "8:xmlsec-1.4.0.jar"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
|
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
|
||||||
"Condition" = "8:"
|
"Condition" = "8:"
|
||||||
"Transitive" = "11:FALSE"
|
"Transitive" = "11:FALSE"
|
||||||
"Vital" = "11:TRUE"
|
"Vital" = "11:TRUE"
|
||||||
@ -1278,7 +1304,7 @@
|
|||||||
"SourcePath" = "8:..\\..\\..\\Svc\\external\\log4j\\logging-log4j-1.2.14\\dist\\lib\\log4j-1.2.14.jar"
|
"SourcePath" = "8:..\\..\\..\\Svc\\external\\log4j\\logging-log4j-1.2.14\\dist\\lib\\log4j-1.2.14.jar"
|
||||||
"TargetName" = "8:log4j-1.2.14.jar"
|
"TargetName" = "8:log4j-1.2.14.jar"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
|
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
|
||||||
"Condition" = "8:"
|
"Condition" = "8:"
|
||||||
"Transitive" = "11:FALSE"
|
"Transitive" = "11:FALSE"
|
||||||
"Vital" = "11:TRUE"
|
"Vital" = "11:TRUE"
|
||||||
@ -1558,7 +1584,7 @@
|
|||||||
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\commons-logging.jar"
|
"SourcePath" = "8:..\\..\\..\\Svc\\external\\xmlsec\\xml-security-1_4_0\\libs\\commons-logging.jar"
|
||||||
"TargetName" = "8:commons-logging.jar"
|
"TargetName" = "8:commons-logging.jar"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_516714B01FD34E218E009D96264F30AC"
|
"Folder" = "8:_7F0AE158BB53414DA5BB29F14E55EEBB"
|
||||||
"Condition" = "8:"
|
"Condition" = "8:"
|
||||||
"Transitive" = "11:FALSE"
|
"Transitive" = "11:FALSE"
|
||||||
"Vital" = "11:TRUE"
|
"Vital" = "11:TRUE"
|
||||||
@ -1828,6 +1854,28 @@
|
|||||||
"Property" = "8:_168E54D12032489796CD7A843225EE70"
|
"Property" = "8:_168E54D12032489796CD7A843225EE70"
|
||||||
"Folders"
|
"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"
|
"{9EF0B969-E518-4E46-987F-47570745A589}:_62B357DC6D484761A18291FA3525320C"
|
||||||
|
Loading…
Reference in New Issue
Block a user