diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 index cbded9c..48da7e4 --- a/LICENSE +++ b/LICENSE @@ -1,1049 +1,1049 @@ - - 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. - - - -APACHE TOMCAT SUBCOMPONENTS: - -Apache Tomcat includes a number of subcomponents with separate copyright notices -and license terms. Your use of these subcomponents is subject to the terms and -conditions of the following licenses. - - -For the ecj-x.x.x.jar component: - -Eclipse Public License - v 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and - -b) in the case of each subsequent Contributor: - -i) changes to the Program, and - -ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are -distributed by that particular Contributor. A Contribution 'originates' from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include additions to -the Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) are not -derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents" mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors. - -2. GRANT OF RIGHTS - -a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form. - -b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents to make, use, sell, offer to sell, import and otherwise transfer the -Contribution of such Contributor, if any, in source code and object code form. -This patent license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, such -addition of the Contribution causes such combination to be covered by the -Licensed Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed hereunder. - -c) Recipient understands that although each Contributor grants the licenses to -its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - -d) Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its -own license agreement, provided that: - -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: - -i) effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title and -non-infringement, and implied warranties or conditions of merchantability and -fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for -damages, including direct, indirect, special, incidental and consequential -damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by -that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, -and informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange. - -When the Program is made available in source code form: - -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the -Program. - -Each Contributor must identify itself as the originator of its Contribution, if -any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may -participate in any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement , including but not limited to the risks and costs -of program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program itself -(excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation -may assign the responsibility to serve as the Agreement Steward to a suitable -separate entity. Each new version of the Agreement will be given a -distinguishing version number. The Program (including Contributions) may always -be distributed subject to the version of the Agreement under which it was -received. In addition, after a new version of the Agreement is published, -Contributor may elect to distribute the Program (including its Contributions) -under the new version. Except as expressly stated in Sections 2(a) and 2(b) -above, Recipient receives no rights or licenses to the intellectual property of -any Contributor under this Agreement, whether expressly, by implication, -estoppel or otherwise. All rights in the Program not expressly granted under -this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation. - - -For the Windows Installer component: - - * All NSIS source code, plug-ins, documentation, examples, header files and - graphics, with the exception of the compression modules and where - otherwise noted, are licensed under the zlib/libpng license. - * The zlib compression module for NSIS is licensed under the zlib/libpng - license. - * The bzip2 compression module for NSIS is licensed under the bzip2 license. - * The lzma compression module for NSIS is licensed under the Common Public - License version 1.0. - -zlib/libpng license - -This software is provided 'as-is', without any express or implied warranty. In -no event will the authors be held liable for any damages arising from the use of -this software. - -Permission is granted to anyone to use this software for any purpose, including -commercial applications, and to alter it and redistribute it freely, subject to -the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not claim - that you wrote the original software. If you use this software in a - product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -bzip2 license - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must not claim - that you wrote the original software. If you use this software in a - product, an acknowledgment in the product documentation would be - appreciated but is not required. - 3. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE. - -Julian Seward, Cambridge, UK. - -jseward@acm.org -Common Public License version 1.0 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - -a) in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and b) in the case of each subsequent -Contributor: - -i) changes to the Program, and - -ii) additions to the Program; - -where such changes and/or additions to the Program originate from and are -distributed by that particular Contributor. A Contribution 'originates' from a -Contributor if it was added to the Program by such Contributor itself or anyone -acting on such Contributor's behalf. Contributions do not include additions to -the Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) are not -derivative works of the Program. - -"Contributor" means any person or entity that distributes the Program. - -"Licensed Patents " mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program. - -"Program" means the Contributions distributed in accordance with this Agreement. - -"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors. - -2. GRANT OF RIGHTS - -a) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form. - -b) Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed -Patents to make, use, sell, offer to sell, import and otherwise transfer the -Contribution of such Contributor, if any, in source code and object code form. -This patent license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, such -addition of the Contribution causes such combination to be covered by the -Licensed Patents. The patent license shall not apply to any other combinations -which include the Contribution. No hardware per se is licensed hereunder. - -c) Recipient understands that although each Contributor grants the licenses to -its Contributions set forth herein, no assurances are provided by any -Contributor that the Program does not infringe the patent or other intellectual -property rights of any other entity. Each Contributor disclaims any liability to -Recipient for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, each Recipient hereby assumes sole -responsibility to secure any other intellectual property rights needed, if any. -For example, if a third party patent license is required to allow Recipient to -distribute the Program, it is Recipient's responsibility to acquire that license -before distributing the Program. - -d) Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. - -3. REQUIREMENTS - -A Contributor may choose to distribute the Program in object code form under its -own license agreement, provided that: - -a) it complies with the terms and conditions of this Agreement; and - -b) its license agreement: - -i) effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title and -non-infringement, and implied warranties or conditions of merchantability and -fitness for a particular purpose; - -ii) effectively excludes on behalf of all Contributors all liability for -damages, including direct, indirect, special, incidental and consequential -damages, such as lost profits; - -iii) states that any provisions which differ from this Agreement are offered by -that Contributor alone and not by any other party; and - -iv) states that source code for the Program is available from such Contributor, -and informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange. - -When the Program is made available in source code form: - -a) it must be made available under this Agreement; and - -b) a copy of this Agreement must be included with each copy of the Program. - -Contributors may not remove or alter any copyright notices contained within the -Program. - -Each Contributor must identify itself as the originator of its Contribution, if -any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor to -control, and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may participate in -any such claim at its own expense. - -For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement, including but not limited to the risks and costs of -program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. GENERAL - -If any provision of this Agreement is invalid or unenforceable under applicable -law, it shall not affect the validity or enforceability of the remainder of the -terms of this Agreement, and without further action by the parties hereto, such -provision shall be reformed to the minimum extent necessary to make such -provision valid and enforceable. - -If Recipient institutes patent litigation against a Contributor with respect to -a patent applicable to software (including a cross-claim or counterclaim in a -lawsuit), then any patent licenses granted by that Contributor to such Recipient -under this Agreement shall terminate as of the date such litigation is filed. In -addition, if Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed. - -All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive. - -Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -IBM is the initial Agreement Steward. IBM may assign the responsibility to serve -as the Agreement Steward to a suitable separate entity. Each new version of the -Agreement will be given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the Agreement -under which it was received. In addition, after a new version of the Agreement -is published, Contributor may elect to distribute the Program (including its -Contributions) under the new version. Except as expressly stated in Sections -2(a) and 2(b) above, Recipient receives no rights or licenses to the -intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. - -This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation. - -Special exception for LZMA compression module - -Igor Pavlov and Amir Szekely, the authors of the LZMA compression module for -NSIS, expressly permit you to statically or dynamically link your code (or bind -by name) to the files from the LZMA compression module for NSIS without -subjecting your linked code to the terms of the Common Public license version -1.0. Any modifications or additions to files from the LZMA compression module -for NSIS, however, are subject to the terms of the Common Public License version -1.0. - - -For the following XML Schemas for Java EE Deployment Descriptors: - - javaee_5.xsd - - javaee_web_services_1_2.xsd - - javaee_web_services_client_1_2.xsd - - javaee_6.xsd - - javaee_web_services_1_3.xsd - - javaee_web_services_client_1_3.xsd - - web-app_3_0.xsd - - web-common_3_0.xsd - - web-fragment_3_0.xsd - -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - - 1.1. Contributor. means each individual or entity that creates or contributes - to the creation of Modifications. - - 1.2. Contributor Version. means the combination of the Original Software, - prior Modifications used by a Contributor (if any), and the - Modifications made by that particular Contributor. - - 1.3. Covered Software. means (a) the Original Software, or (b) Modifications, - or (c) the combination of files containing Original Software with files - containing Modifications, in each case including portions thereof. - - 1.4. Executable. means the Covered Software in any form other than Source - Code. - - 1.5. Initial Developer. means the individual or entity that first makes - Original Software available under this License. - - 1.6. Larger Work. means a work which combines Covered Software or portions - thereof with code not governed by the terms of this License. - - 1.7. License. means this document. - - 1.8. Licensable. means having the right to grant, to the maximum extent - possible, whether at the time of the initial grant or subsequently - acquired, any and all of the rights conveyed herein. - - 1.9. Modifications. means the Source Code and Executable form of any of the - following: - - A. Any file that results from an addition to, deletion from or - modification of the contents of a file containing Original Software - or previous Modifications; - - B. Any new file that contains any part of the Original Software or - previous Modification; or - - C. Any new file that is contributed or otherwise made available under - the terms of this License. - - 1.10. Original Software. means the Source Code and Executable form of - computer software code that is originally released under this License. - - 1.11. Patent Claims. means any patent claim(s), now owned or hereafter - acquired, including without limitation, method, process, and apparatus - claims, in any patent Licensable by grantor. - - 1.12. Source Code. means (a) the common form of computer software code in - which modifications are made and (b) associated documentation included - in or with such code. - - 1.13. You. (or .Your.) means an individual or a legal entity exercising - rights under, and complying with all of the terms of, this License. For - legal entities, .You. includes any entity which controls, is controlled - by, or is under common control with You. For purposes of this - definition, .control. means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - -2. License Grants. - - 2.1. The Initial Developer Grant. - - Conditioned upon Your compliance with Section 3.1 below and subject to - third party intellectual property claims, the Initial Developer hereby - grants You a world-wide, royalty-free, non-exclusive license: - - (a) under intellectual property rights (other than patent or trademark) - Licensable by Initial Developer, to use, reproduce, modify, display, - perform, sublicense and distribute the Original Software (or - portions thereof), with or without Modifications, and/or as part of - a Larger Work; and - - (b) under Patent Claims infringed by the making, using or selling of - Original Software, to make, have made, use, practice, sell, and - offer for sale, and/or otherwise dispose of the Original Software - (or portions thereof). - - (c) The licenses granted in Sections 2.1(a) and (b) are effective on the - date Initial Developer first distributes or otherwise makes the - Original Software available to a third party under the terms of this - License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is granted: - (1) for code that You delete from the Original Software, or (2) for - infringements caused by: (i) the modification of the Original - Software, or (ii) the combination of the Original Software with - other software or devices. - - 2.2. Contributor Grant. - - Conditioned upon Your compliance with Section 3.1 below and subject to third - party intellectual property claims, each Contributor hereby grants You a - world-wide, royalty-free, non-exclusive license: - - (a) under intellectual property rights (other than patent or trademark) - Licensable by Contributor to use, reproduce, modify, display, - perform, sublicense and distribute the Modifications created by such - Contributor (or portions thereof), either on an unmodified basis, - with other Modifications, as Covered Software and/or as part of a - Larger Work; and - - (b) under Patent Claims infringed by the making, using, or selling of - Modifications made by that Contributor either alone and/or in - combination with its Contributor Version (or portions of such - combination), to make, use, sell, offer for sale, have made, and/or - otherwise dispose of: (1) Modifications made by that Contributor (or - portions thereof); and (2) the combination of Modifications made by - that Contributor with its Contributor Version (or portions of such - combination). - - (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on - the date Contributor first distributes or otherwise makes the - Modifications available to a third party. - - (d) Notwithstanding Section 2.2(b) above, no patent license is granted: - (1) for any code that Contributor has deleted from the Contributor - Version; (2) for infringements caused by: (i) third party - modifications of Contributor Version, or (ii) the combination of - Modifications made by that Contributor with other software (except - as part of the Contributor Version) or other devices; or (3) under - Patent Claims infringed by Covered Software in the absence of - Modifications made by that Contributor. - -3. Distribution Obligations. - - 3.1. Availability of Source Code. - Any Covered Software that You distribute or otherwise make available in - Executable form must also be made available in Source Code form and that - Source Code form must be distributed only under the terms of this License. - You must include a copy of this License with every copy of the Source Code - form of the Covered Software You distribute or otherwise make available. - You must inform recipients of any such Covered Software in Executable form - as to how they can obtain such Covered Software in Source Code form in a - reasonable manner on or through a medium customarily used for software - exchange. - - 3.2. Modifications. - The Modifications that You create or to which You contribute are governed - by the terms of this License. You represent that You believe Your - Modifications are Your original creation(s) and/or You have sufficient - rights to grant the rights conveyed by this License. - - 3.3. Required Notices. - You must include a notice in each of Your Modifications that identifies - You as the Contributor of the Modification. You may not remove or alter - any copyright, patent or trademark notices contained within the Covered - Software, or any notices of licensing or any descriptive text giving - attribution to any Contributor or the Initial Developer. - - 3.4. Application of Additional Terms. - You may not offer or impose any terms on any Covered Software in Source - Code form that alters or restricts the applicable version of this License - or the recipients. rights hereunder. You may choose to offer, and to - charge a fee for, warranty, support, indemnity or liability obligations to - one or more recipients of Covered Software. However, you may do so only on - Your own behalf, and not on behalf of the Initial Developer or any - Contributor. You must make it absolutely clear that any such warranty, - support, indemnity or liability obligation is offered by You alone, and - You hereby agree to indemnify the Initial Developer and every Contributor - for any liability incurred by the Initial Developer or such Contributor as - a result of warranty, support, indemnity or liability terms You offer. - - 3.5. Distribution of Executable Versions. - You may distribute the Executable form of the Covered Software under the - terms of this License or under the terms of a license of Your choice, - which may contain terms different from this License, provided that You are - in compliance with the terms of this License and that the license for the - Executable form does not attempt to limit or alter the recipient.s rights - in the Source Code form from the rights set forth in this License. If You - distribute the Covered Software in Executable form under a different - license, You must make it absolutely clear that any terms which differ - from this License are offered by You alone, not by the Initial Developer - or Contributor. You hereby agree to indemnify the Initial Developer and - every Contributor for any liability incurred by the Initial Developer or - such Contributor as a result of any such terms You offer. - - 3.6. Larger Works. - You may create a Larger Work by combining Covered Software with other code - not governed by the terms of this License and distribute the Larger Work - as a single product. In such a case, You must make sure the requirements - of this License are fulfilled for the Covered Software. - -4. Versions of the License. - - 4.1. New Versions. - Sun Microsystems, Inc. is the initial license steward and may publish - revised and/or new versions of this License from time to time. Each - version will be given a distinguishing version number. Except as provided - in Section 4.3, no one other than the license steward has the right to - modify this License. - - 4.2. Effect of New Versions. - You may always continue to use, distribute or otherwise make the Covered - Software available under the terms of the version of the License under - which You originally received the Covered Software. If the Initial - Developer includes a notice in the Original Software prohibiting it from - being distributed or otherwise made available under any subsequent version - of the License, You must distribute and make the Covered Software - available under the terms of the version of the License under which You - originally received the Covered Software. Otherwise, You may also choose - to use, distribute or otherwise make the Covered Software available under - the terms of any subsequent version of the License published by the - license steward. - - 4.3. Modified Versions. - When You are an Initial Developer and You want to create a new license for - Your Original Software, You may create and use a modified version of this - License if You: (a) rename the license and remove any references to the - name of the license steward (except to note that the license differs from - this License); and (b) otherwise make it clear that the license contains - terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - - COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT - WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT - LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, - MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK - AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD - ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL - DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY - SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN - ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED - HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -6. TERMINATION. - - 6.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to - cure such breach within 30 days of becoming aware of the breach. - Provisions which, by their nature, must remain in effect beyond the - termination of this License shall survive. - - 6.2. If You assert a patent infringement claim (excluding declaratory - judgment actions) against Initial Developer or a Contributor (the - Initial Developer or Contributor against whom You assert such claim - is referred to as .Participant.) alleging that the Participant - Software (meaning the Contributor Version where the Participant is a - Contributor or the Original Software where the Participant is the - Initial Developer) directly or indirectly infringes any patent, then - any and all rights granted directly or indirectly to You by such - Participant, the Initial Developer (if the Initial Developer is not - the Participant) and all Contributors under Sections 2.1 and/or 2.2 - of this License shall, upon 60 days notice from Participant terminate - prospectively and automatically at the expiration of such 60 day - notice period, unless if within such 60 day period You withdraw Your - claim with respect to the Participant Software against such - Participant either unilaterally or pursuant to a written agreement - with Participant. - - 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end - user licenses that have been validly granted by You or any - distributor hereunder prior to termination (excluding licenses - granted to You by any distributor) shall survive termination. - -7. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING - NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY - OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF - ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, - INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT - LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, - COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR - LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF - SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR - DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT - APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE - EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS - EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - - The Covered Software is a .commercial item,. as that term is defined in 48 - C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as - that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and commercial - computer software documentation. as such terms are used in 48 C.F.R. 12.212 - (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 - through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered - Software with only those rights set forth herein. This U.S. Government Rights - clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or - provision that addresses Government rights in computer software under this - License. - -9. MISCELLANEOUS. - - This License represents the complete agreement concerning subject matter - hereof. If any provision of this License is held to be unenforceable, such - provision shall be reformed only to the extent necessary to make it - enforceable. This License shall be governed by the law of the jurisdiction - specified in a notice contained within the Original Software (except to the - extent applicable law, if any, provides otherwise), excluding such - jurisdiction's conflict-of-law provisions. Any litigation relating to this - License shall be subject to the jurisdiction of the courts located in the - jurisdiction and venue specified in a notice contained within the Original - Software, with the losing party responsible for costs, including, without - limitation, court costs and reasonable attorneys. fees and expenses. The - application of the United Nations Convention on Contracts for the - International Sale of Goods is expressly excluded. Any law or regulation - which provides that the language of a contract shall be construed against - the drafter shall not apply to this License. You agree that You alone are - responsible for compliance with the United States export administration - regulations (and the export control laws and regulation of any other - countries) when You use, distribute or otherwise make available any Covered - Software. - -10. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is responsible - for claims and damages arising, directly or indirectly, out of its - utilization of rights under this License and You agree to work with Initial - Developer and Contributors to distribute such responsibility on an equitable - basis. Nothing herein is intended or shall be deemed to constitute any - admission of liability. - - NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION - LICENSE (CDDL) - - The code released under the CDDL shall be governed by the laws of the State - of California (excluding conflict-of-law provisions). Any litigation relating - to this License shall be subject to the jurisdiction of the Federal Courts of - the Northern District of California and the state courts of the State of - California, with venue lying in Santa Clara County, California. - + + 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. + + + +APACHE TOMCAT SUBCOMPONENTS: + +Apache Tomcat includes a number of subcomponents with separate copyright notices +and license terms. Your use of these subcomponents is subject to the terms and +conditions of the following licenses. + + +For the ecj-x.x.x.jar component: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to +its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by +that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, +and informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement , including but not limited to the risks and costs +of program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Program itself +(excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation +may assign the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) may always +be distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to distribute the Program (including its Contributions) +under the new version. Except as expressly stated in Sections 2(a) and 2(b) +above, Recipient receives no rights or licenses to the intellectual property of +any Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted under +this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + + +For the Windows Installer component: + + * All NSIS source code, plug-ins, documentation, examples, header files and + graphics, with the exception of the compression modules and where + otherwise noted, are licensed under the zlib/libpng license. + * The zlib compression module for NSIS is licensed under the zlib/libpng + license. + * The bzip2 compression module for NSIS is licensed under the bzip2 license. + * The lzma compression module for NSIS is licensed under the Common Public + License version 1.0. + +zlib/libpng license + +This software is provided 'as-is', without any express or implied warranty. In +no event will the authors be held liable for any damages arising from the use of +this software. + +Permission is granted to anyone to use this software for any purpose, including +commercial applications, and to alter it and redistribute it freely, subject to +the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not claim + that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +bzip2 license + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. The origin of this software must not be misrepresented; you must not claim + that you wrote the original software. If you use this software in a + product, an acknowledgment in the product documentation would be + appreciated but is not required. + 3. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 4. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. + +Julian Seward, Cambridge, UK. + +jseward@acm.org +Common Public License version 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and b) in the case of each subsequent +Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to +its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by +that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, +and informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + +Special exception for LZMA compression module + +Igor Pavlov and Amir Szekely, the authors of the LZMA compression module for +NSIS, expressly permit you to statically or dynamically link your code (or bind +by name) to the files from the LZMA compression module for NSIS without +subjecting your linked code to the terms of the Common Public license version +1.0. Any modifications or additions to files from the LZMA compression module +for NSIS, however, are subject to the terms of the Common Public License version +1.0. + + +For the following XML Schemas for Java EE Deployment Descriptors: + - javaee_5.xsd + - javaee_web_services_1_2.xsd + - javaee_web_services_client_1_2.xsd + - javaee_6.xsd + - javaee_web_services_1_3.xsd + - javaee_web_services_client_1_3.xsd + - web-app_3_0.xsd + - web-common_3_0.xsd + - web-fragment_3_0.xsd + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + +1. Definitions. + + 1.1. Contributor. means each individual or entity that creates or contributes + to the creation of Modifications. + + 1.2. Contributor Version. means the combination of the Original Software, + prior Modifications used by a Contributor (if any), and the + Modifications made by that particular Contributor. + + 1.3. Covered Software. means (a) the Original Software, or (b) Modifications, + or (c) the combination of files containing Original Software with files + containing Modifications, in each case including portions thereof. + + 1.4. Executable. means the Covered Software in any form other than Source + Code. + + 1.5. Initial Developer. means the individual or entity that first makes + Original Software available under this License. + + 1.6. Larger Work. means a work which combines Covered Software or portions + thereof with code not governed by the terms of this License. + + 1.7. License. means this document. + + 1.8. Licensable. means having the right to grant, to the maximum extent + possible, whether at the time of the initial grant or subsequently + acquired, any and all of the rights conveyed herein. + + 1.9. Modifications. means the Source Code and Executable form of any of the + following: + + A. Any file that results from an addition to, deletion from or + modification of the contents of a file containing Original Software + or previous Modifications; + + B. Any new file that contains any part of the Original Software or + previous Modification; or + + C. Any new file that is contributed or otherwise made available under + the terms of this License. + + 1.10. Original Software. means the Source Code and Executable form of + computer software code that is originally released under this License. + + 1.11. Patent Claims. means any patent claim(s), now owned or hereafter + acquired, including without limitation, method, process, and apparatus + claims, in any patent Licensable by grantor. + + 1.12. Source Code. means (a) the common form of computer software code in + which modifications are made and (b) associated documentation included + in or with such code. + + 1.13. You. (or .Your.) means an individual or a legal entity exercising + rights under, and complying with all of the terms of, this License. For + legal entities, .You. includes any entity which controls, is controlled + by, or is under common control with You. For purposes of this + definition, .control. means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + +2. License Grants. + + 2.1. The Initial Developer Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to + third party intellectual property claims, the Initial Developer hereby + grants You a world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Initial Developer, to use, reproduce, modify, display, + perform, sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, and/or as part of + a Larger Work; and + + (b) under Patent Claims infringed by the making, using or selling of + Original Software, to make, have made, use, practice, sell, and + offer for sale, and/or otherwise dispose of the Original Software + (or portions thereof). + + (c) The licenses granted in Sections 2.1(a) and (b) are effective on the + date Initial Developer first distributes or otherwise makes the + Original Software available to a third party under the terms of this + License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is granted: + (1) for code that You delete from the Original Software, or (2) for + infringements caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original Software with + other software or devices. + + 2.2. Contributor Grant. + + Conditioned upon Your compliance with Section 3.1 below and subject to third + party intellectual property claims, each Contributor hereby grants You a + world-wide, royalty-free, non-exclusive license: + + (a) under intellectual property rights (other than patent or trademark) + Licensable by Contributor to use, reproduce, modify, display, + perform, sublicense and distribute the Modifications created by such + Contributor (or portions thereof), either on an unmodified basis, + with other Modifications, as Covered Software and/or as part of a + Larger Work; and + + (b) under Patent Claims infringed by the making, using, or selling of + Modifications made by that Contributor either alone and/or in + combination with its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, have made, and/or + otherwise dispose of: (1) Modifications made by that Contributor (or + portions thereof); and (2) the combination of Modifications made by + that Contributor with its Contributor Version (or portions of such + combination). + + (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on + the date Contributor first distributes or otherwise makes the + Modifications available to a third party. + + (d) Notwithstanding Section 2.2(b) above, no patent license is granted: + (1) for any code that Contributor has deleted from the Contributor + Version; (2) for infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the combination of + Modifications made by that Contributor with other software (except + as part of the Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the absence of + Modifications made by that Contributor. + +3. Distribution Obligations. + + 3.1. Availability of Source Code. + Any Covered Software that You distribute or otherwise make available in + Executable form must also be made available in Source Code form and that + Source Code form must be distributed only under the terms of this License. + You must include a copy of this License with every copy of the Source Code + form of the Covered Software You distribute or otherwise make available. + You must inform recipients of any such Covered Software in Executable form + as to how they can obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used for software + exchange. + + 3.2. Modifications. + The Modifications that You create or to which You contribute are governed + by the terms of this License. You represent that You believe Your + Modifications are Your original creation(s) and/or You have sufficient + rights to grant the rights conveyed by this License. + + 3.3. Required Notices. + You must include a notice in each of Your Modifications that identifies + You as the Contributor of the Modification. You may not remove or alter + any copyright, patent or trademark notices contained within the Covered + Software, or any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + + 3.4. Application of Additional Terms. + You may not offer or impose any terms on any Covered Software in Source + Code form that alters or restricts the applicable version of this License + or the recipients. rights hereunder. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability obligations to + one or more recipients of Covered Software. However, you may do so only on + Your own behalf, and not on behalf of the Initial Developer or any + Contributor. You must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by You alone, and + You hereby agree to indemnify the Initial Developer and every Contributor + for any liability incurred by the Initial Developer or such Contributor as + a result of warranty, support, indemnity or liability terms You offer. + + 3.5. Distribution of Executable Versions. + You may distribute the Executable form of the Covered Software under the + terms of this License or under the terms of a license of Your choice, + which may contain terms different from this License, provided that You are + in compliance with the terms of this License and that the license for the + Executable form does not attempt to limit or alter the recipient.s rights + in the Source Code form from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a different + license, You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial Developer + or Contributor. You hereby agree to indemnify the Initial Developer and + every Contributor for any liability incurred by the Initial Developer or + such Contributor as a result of any such terms You offer. + + 3.6. Larger Works. + You may create a Larger Work by combining Covered Software with other code + not governed by the terms of this License and distribute the Larger Work + as a single product. In such a case, You must make sure the requirements + of this License are fulfilled for the Covered Software. + +4. Versions of the License. + + 4.1. New Versions. + Sun Microsystems, Inc. is the initial license steward and may publish + revised and/or new versions of this License from time to time. Each + version will be given a distinguishing version number. Except as provided + in Section 4.3, no one other than the license steward has the right to + modify this License. + + 4.2. Effect of New Versions. + You may always continue to use, distribute or otherwise make the Covered + Software available under the terms of the version of the License under + which You originally received the Covered Software. If the Initial + Developer includes a notice in the Original Software prohibiting it from + being distributed or otherwise made available under any subsequent version + of the License, You must distribute and make the Covered Software + available under the terms of the version of the License under which You + originally received the Covered Software. Otherwise, You may also choose + to use, distribute or otherwise make the Covered Software available under + the terms of any subsequent version of the License published by the + license steward. + + 4.3. Modified Versions. + When You are an Initial Developer and You want to create a new license for + Your Original Software, You may create and use a modified version of this + License if You: (a) rename the license and remove any references to the + name of the license steward (except to note that the license differs from + this License); and (b) otherwise make it clear that the license contains + terms which differ from this License. + +5. DISCLAIMER OF WARRANTY. + + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT + LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, + MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK + AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD + ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL + DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY + SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN + ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED + HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +6. TERMINATION. + + 6.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to + cure such breach within 30 days of becoming aware of the breach. + Provisions which, by their nature, must remain in effect beyond the + termination of this License shall survive. + + 6.2. If You assert a patent infringement claim (excluding declaratory + judgment actions) against Initial Developer or a Contributor (the + Initial Developer or Contributor against whom You assert such claim + is referred to as .Participant.) alleging that the Participant + Software (meaning the Contributor Version where the Participant is a + Contributor or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any patent, then + any and all rights granted directly or indirectly to You by such + Participant, the Initial Developer (if the Initial Developer is not + the Participant) and all Contributors under Sections 2.1 and/or 2.2 + of this License shall, upon 60 days notice from Participant terminate + prospectively and automatically at the expiration of such 60 day + notice period, unless if within such 60 day period You withdraw Your + claim with respect to the Participant Software against such + Participant either unilaterally or pursuant to a written agreement + with Participant. + + 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end + user licenses that have been validly granted by You or any + distributor hereunder prior to termination (excluding licenses + granted to You by any distributor) shall survive termination. + +7. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING + NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY + OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF + ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, + INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, + COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR + LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF + SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR + DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS + EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +8. U.S. GOVERNMENT END USERS. + + The Covered Software is a .commercial item,. as that term is defined in 48 + C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as + that term is defined at 48 C.F.R. ? 252.227-7014(a)(1)) and commercial + computer software documentation. as such terms are used in 48 C.F.R. 12.212 + (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered + Software with only those rights set forth herein. This U.S. Government Rights + clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or + provision that addresses Government rights in computer software under this + License. + +9. MISCELLANEOUS. + + This License represents the complete agreement concerning subject matter + hereof. If any provision of this License is held to be unenforceable, such + provision shall be reformed only to the extent necessary to make it + enforceable. This License shall be governed by the law of the jurisdiction + specified in a notice contained within the Original Software (except to the + extent applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation relating to this + License shall be subject to the jurisdiction of the courts located in the + jurisdiction and venue specified in a notice contained within the Original + Software, with the losing party responsible for costs, including, without + limitation, court costs and reasonable attorneys. fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or regulation + which provides that the language of a contract shall be construed against + the drafter shall not apply to this License. You agree that You alone are + responsible for compliance with the United States export administration + regulations (and the export control laws and regulation of any other + countries) when You use, distribute or otherwise make available any Covered + Software. + +10. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is responsible + for claims and damages arising, directly or indirectly, out of its + utilization of rights under this License and You agree to work with Initial + Developer and Contributors to distribute such responsibility on an equitable + basis. Nothing herein is intended or shall be deemed to constitute any + admission of liability. + + NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION + LICENSE (CDDL) + + The code released under the CDDL shall be governed by the laws of the State + of California (excluding conflict-of-law provisions). Any litigation relating + to this License shall be subject to the jurisdiction of the Federal Courts of + the Northern District of California and the state courts of the State of + California, with venue lying in Santa Clara County, California. + diff --git a/NOTICE b/NOTICE old mode 100644 new mode 100755 index 30d31d5..91916d3 --- a/NOTICE +++ b/NOTICE @@ -1,36 +1,36 @@ -Apache Tomcat -Copyright 1999-2012 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - -The Windows Installer is built with the Nullsoft -Scriptable Install System (NSIS), which is -open source software. The original software and -related information is available at -http://nsis.sourceforge.net. - -Java compilation software for JSP pages is provided by Eclipse, -which is open source software. The original software and -related information is available at -http://www.eclipse.org. - -For the bayeux implementation -The org.apache.cometd.bayeux API is derivative work originating at the Dojo Foundation -* Copyright 2007-2008 Guy Molinari -* Copyright 2007-2008 Filip Hanik -* Copyright 2007 Dojo Foundation -* Copyright 2007 Mort Bay Consulting Pty. Ltd. - -The original XML Schemas for Java EE Deployment Descriptors: - - javaee_5.xsd - - javaee_web_services_1_2.xsd - - javaee_web_services_client_1_2.xsd - - javaee_6.xsd - - javaee_web_services_1_3.xsd - - javaee_web_services_client_1_3.xsd - - web-app_3_0.xsd - - web-common_3_0.xsd - - web-fragment_3_0.xsd - - jsp_2_2.xsd -may be obtained from http://java.sun.com/xml/ns/javaee/ +Apache Tomcat +Copyright 1999-2012 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + +The Windows Installer is built with the Nullsoft +Scriptable Install System (NSIS), which is +open source software. The original software and +related information is available at +http://nsis.sourceforge.net. + +Java compilation software for JSP pages is provided by Eclipse, +which is open source software. The original software and +related information is available at +http://www.eclipse.org. + +For the bayeux implementation +The org.apache.cometd.bayeux API is derivative work originating at the Dojo Foundation +* Copyright 2007-2008 Guy Molinari +* Copyright 2007-2008 Filip Hanik +* Copyright 2007 Dojo Foundation +* Copyright 2007 Mort Bay Consulting Pty. Ltd. + +The original XML Schemas for Java EE Deployment Descriptors: + - javaee_5.xsd + - javaee_web_services_1_2.xsd + - javaee_web_services_client_1_2.xsd + - javaee_6.xsd + - javaee_web_services_1_3.xsd + - javaee_web_services_client_1_3.xsd + - web-app_3_0.xsd + - web-common_3_0.xsd + - web-fragment_3_0.xsd + - jsp_2_2.xsd +may be obtained from http://java.sun.com/xml/ns/javaee/ diff --git a/README b/README old mode 100644 new mode 100755 index 94949a5..ce0fe3a --- a/README +++ b/README @@ -1,111 +1,111 @@ -Caimito is an open source (Apache Software License 2.0) WebDAV,caching, and content-delivery server frontend for cloud storage. Caimito supports Softlayer Object Storage, Open Stack Storage, and Amazon S3. Caimito also features a REST interface for configuring user access. Caimito is ideal for Hosting and Reseller environments. - -Requirements -Requires any Linux distro. - -Download -http://cloud-drive.ngasi.com/s1/f1/caimito/public/caimito.zip - -Install -cd to /usr directory -unzip caimito contents to directory then copy 2 configuration files. -cd /usr unzip -q -o -a caimito.zip cp /usr/caimito/conf/Catalina/localhost/ROOT.xml.sample /usr/caimito/conf/Catalina/localhost/ROOT.xml cp /usr/caimito/webapps/WEB-INF/caimito/config.properties.sample /usr/caimito/webapps/WEB-INF/caimito/config.properties - -Configure -Database -Caimito is installed with a default Derby Database. -To change the database, edit the following file: -/usr/caimito/conf/Catalina/localhost/ROOT.xml -Resource Storage -The resource storage type and access info is set in the following file: -/usr/caimito/webapps/WEB-INF/caimito/config.properties -The default storage type is "file". To change to a Cloud storage, edit the value for "resource". The value for Open Stack and Softlayer Object Storage would be "openstack" (Amazon S3 support coming soon). The values for "cloud.username", "cloud.api.key_password", "cloud.url", and "cloud.store" should be populated with the appropriate information. "cloud.store" is populated with the name of an already created "container" or "bucket". - -Run -cd /usr/caimito/bin -./startup.sh - -To run as a Deamon: -./demon.sh - -To Stop: -./shutdown.sh - -Access: -Point any HTTP enabled client to: -http://hostname:8619/ -NOTE: Make sure access to port 8619 is enabled through any firewall. - -By default access is restricted so you would be prompted to login. Login with the following information: -User: caimitoadmin Password: caimito -The above is the default Super Admin user. Follow the instructions below to change the password. - -Configuring Users: -There are 4 default levels of Users. They are listed below in hierarchical order: -Super Admin -is the single user that has overriding control over all other users. The Super Admin has the privilege to create one or more Directory Admin and assign access to the Directory Admin to a sub directory. -Directory Admin -A Directory Admin has the privilege to create one or more Client and assign access to the client to a directory owned by the Directory Admin. -Client -A Client has the privilege to create one or more End User and assign access to the End User to a directory owned by the Client. -End User -Although the End User may have directory access, the End User has no administrative privilege. -Configuring User access is a 2 step process. First the User is created, then the specific directory access is granted. -Below is the steps to do so with the REST API. (The REST API is based on Shaftwork framework.) -Create User -http://hostname:8619/ca/shaftrest/shaftusermgr/add?shaftuser.new=user1&shaftpassword.new=tiger&shaftuser=caimitoadmin&shaftpassword=caimito -Here a Directory Admin, user1, was created with the password tiger. -Set Directory Privilege -http://hostname:8619/ca/shaftrest/pathprivileges/add?shaftuser=caimitoadmin&shaftpassword=caimito&resourceuser=user1&path=dirpath1&privilege=2&maxspace=20 -Here user1, was assigned access to dirpath1 with a max space of 20GB. The directory path is an absolute path relative to the root directory path of the User (the root path for the Super Admin is /). So the newly protected path would look like: -http://hostname:8619/dirpath1 -In the above example, the privilege was set with a value of 2. A privilege of 2 signifies READ/WRITE access. A privilege of 1 signifies READ only access. -Privileges: -1 -READ only -2 -READ/WRITE -Public Paths -Authentication may not be required for all directory paths. In these situations, you set public path access - which means world read access to the directory. -http://hostname:8619/ca/shaftrest/publicpaths/add?shaftuser=user1&shaftpassword=tiger&path=dirpath1/public&listing=false -In the above example, the path, dirpath1/public, was set to world readable access. So the public path would look like: -http://hostname:8619/dirpath1/public -Also in this example, the optional "listing" attribute was set to false. If "listing" is set the true, users would be able to see a list of the contents contained in the directory. -Change Password -http://hostname:8619/ca/shaftrest/shaftusermgr/update?shaftpassword.new=lion&shaftuser=user1&shaftpassword=tiger -The above example changes the password for user1 to lion. -Delete User -http://hostname:8619/ca/shaftrest/shaftusermgr/delete?shaftuser.eq=user1&shaftuser=caimitoadmin&shaftpassword=caimito -The above example removes user1. -Delete Directory Privilege -http://hostname:8619/ca/shaftrest/pathprivileges/delete?shaftuser=caimitoadmin&shaftpassword=caimito&resourceuser.eq=user1&path.eq=dirpath1 -Here user1's privilege to dirpath1 was removed. -Delete Public Paths -http://hostname:8619/ca/shaftrest/publicpaths/delete?shaftuser=user1&shaftpassword=tiger&path.eq=dirpath1/public -In the above example, world readable access to dirpath1/public, was removed. - -Mounting Caimito as a File System -Windows -Right Click "Computer" -Click "Add a network location" -Enter the appropriate Caimito URL and login credentials. -Linux -Download and install one of the packages at the following link: -http://pkgs.repoforge.org/davfs2/ -Add Caimito access info like so -echo "http://hostname:8619 caimitoadmin caimito" >> /etc/davfs2/secrets -Create a directory to map the mounted file system -mkdir /clouddrive -Mount Caimito like so: -mount -t davfs http://hostname:8619 /clouddrive -Virtuozzo and OpenVZ -Install fuse on the Host system like so: -yum -y install fuse -Then set the following for the VPS like so: -vzctl set 227 --devnodes fuse:rw --save - -Web Interface -COMING SOON! - -Community -Contact: support(AT)ngasi.com +Caimito is an open source (Apache Software License 2.0) WebDAV,caching, and content-delivery server frontend for cloud storage. Caimito supports Softlayer Object Storage, Open Stack Storage, and Amazon S3. Caimito also features a REST interface for configuring user access. Caimito is ideal for Hosting and Reseller environments. + +Requirements +Requires any Linux distro. + +Download +http://cloud-drive.ngasi.com/s1/f1/caimito/public/caimito.zip + +Install +cd to /usr directory +unzip caimito contents to directory then copy 2 configuration files. +cd /usr unzip -q -o -a caimito.zip cp /usr/caimito/conf/Catalina/localhost/ROOT.xml.sample /usr/caimito/conf/Catalina/localhost/ROOT.xml cp /usr/caimito/webapps/WEB-INF/caimito/config.properties.sample /usr/caimito/webapps/WEB-INF/caimito/config.properties + +Configure +Database +Caimito is installed with a default Derby Database. +To change the database, edit the following file: +/usr/caimito/conf/Catalina/localhost/ROOT.xml +Resource Storage +The resource storage type and access info is set in the following file: +/usr/caimito/webapps/WEB-INF/caimito/config.properties +The default storage type is "file". To change to a Cloud storage, edit the value for "resource". The value for Open Stack and Softlayer Object Storage would be "openstack" (Amazon S3 support coming soon). The values for "cloud.username", "cloud.api.key_password", "cloud.url", and "cloud.store" should be populated with the appropriate information. "cloud.store" is populated with the name of an already created "container" or "bucket". + +Run +cd /usr/caimito/bin +./startup.sh + +To run as a Deamon: +./demon.sh + +To Stop: +./shutdown.sh + +Access: +Point any HTTP enabled client to: +http://hostname:8619/ +NOTE: Make sure access to port 8619 is enabled through any firewall. + +By default access is restricted so you would be prompted to login. Login with the following information: +User: caimitoadmin Password: caimito +The above is the default Super Admin user. Follow the instructions below to change the password. + +Configuring Users: +There are 4 default levels of Users. They are listed below in hierarchical order: +Super Admin +is the single user that has overriding control over all other users. The Super Admin has the privilege to create one or more Directory Admin and assign access to the Directory Admin to a sub directory. +Directory Admin +A Directory Admin has the privilege to create one or more Client and assign access to the client to a directory owned by the Directory Admin. +Client +A Client has the privilege to create one or more End User and assign access to the End User to a directory owned by the Client. +End User +Although the End User may have directory access, the End User has no administrative privilege. +Configuring User access is a 2 step process. First the User is created, then the specific directory access is granted. +Below is the steps to do so with the REST API. (The REST API is based on Shaftwork framework.) +Create User +http://hostname:8619/ca/shaftrest/shaftusermgr/add?shaftuser.new=user1&shaftpassword.new=tiger&shaftuser=caimitoadmin&shaftpassword=caimito +Here a Directory Admin, user1, was created with the password tiger. +Set Directory Privilege +http://hostname:8619/ca/shaftrest/pathprivileges/add?shaftuser=caimitoadmin&shaftpassword=caimito&resourceuser=user1&path=dirpath1&privilege=2&maxspace=20 +Here user1, was assigned access to dirpath1 with a max space of 20GB. The directory path is an absolute path relative to the root directory path of the User (the root path for the Super Admin is /). So the newly protected path would look like: +http://hostname:8619/dirpath1 +In the above example, the privilege was set with a value of 2. A privilege of 2 signifies READ/WRITE access. A privilege of 1 signifies READ only access. +Privileges: +1 +READ only +2 +READ/WRITE +Public Paths +Authentication may not be required for all directory paths. In these situations, you set public path access - which means world read access to the directory. +http://hostname:8619/ca/shaftrest/publicpaths/add?shaftuser=user1&shaftpassword=tiger&path=dirpath1/public&listing=false +In the above example, the path, dirpath1/public, was set to world readable access. So the public path would look like: +http://hostname:8619/dirpath1/public +Also in this example, the optional "listing" attribute was set to false. If "listing" is set the true, users would be able to see a list of the contents contained in the directory. +Change Password +http://hostname:8619/ca/shaftrest/shaftusermgr/update?shaftpassword.new=lion&shaftuser=user1&shaftpassword=tiger +The above example changes the password for user1 to lion. +Delete User +http://hostname:8619/ca/shaftrest/shaftusermgr/delete?shaftuser.eq=user1&shaftuser=caimitoadmin&shaftpassword=caimito +The above example removes user1. +Delete Directory Privilege +http://hostname:8619/ca/shaftrest/pathprivileges/delete?shaftuser=caimitoadmin&shaftpassword=caimito&resourceuser.eq=user1&path.eq=dirpath1 +Here user1's privilege to dirpath1 was removed. +Delete Public Paths +http://hostname:8619/ca/shaftrest/publicpaths/delete?shaftuser=user1&shaftpassword=tiger&path.eq=dirpath1/public +In the above example, world readable access to dirpath1/public, was removed. + +Mounting Caimito as a File System +Windows +Right Click "Computer" +Click "Add a network location" +Enter the appropriate Caimito URL and login credentials. +Linux +Download and install one of the packages at the following link: +http://pkgs.repoforge.org/davfs2/ +Add Caimito access info like so +echo "http://hostname:8619 caimitoadmin caimito" >> /etc/davfs2/secrets +Create a directory to map the mounted file system +mkdir /clouddrive +Mount Caimito like so: +mount -t davfs http://hostname:8619 /clouddrive +Virtuozzo and OpenVZ +Install fuse on the Host system like so: +yum -y install fuse +Then set the following for the VPS like so: +vzctl set 227 --devnodes fuse:rw --save + +Web Interface +COMING SOON! + +Community +Contact: support(AT)ngasi.com diff --git a/RELEASE-NOTES b/RELEASE-NOTES old mode 100644 new mode 100755 index f6f9391..a811a2b --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,228 +1,228 @@ -================================================================================ - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -================================================================================ - -$Id: RELEASE-NOTES 1189163 2011-10-26 12:19:26Z kkolinko $ - - - Apache Tomcat Version 7.0.27 - Release Notes - - -========= -CONTENTS: -========= - -* Dependency Changes -* API Stability -* JNI Based Applications -* Bundled APIs -* Web application reloading and static fields in shared libraries -* Tomcat on Linux -* Enabling SSI and CGI Support -* Security manager URLs -* Symlinking static resources -* Viewing the Tomcat Change Log -* Cryptographic software notice -* When all else fails - - -=================== -Dependency Changes: -=================== -Tomcat 7.0 is designed to run on Java SE 6 and later. - -In addition, Tomcat 7.0 uses the Eclipse JDT Java compiler for -compiling JSP pages. This means you no longer need to have the complete -Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment -(JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the -binary Tomcat distributions. Tomcat can also be configured to use the -compiler from the JDK to compile JSPs, or any other Java compiler supported -by Apache Ant. - - -============== -API Stability: -============== -The public interfaces for the following classes are fixed and will not be -changed at all during the remaining lifetime of the 7.x series: -- javax/**/* - -The public interfaces for the following classes may be added to in order to -resolve bugs and/or add new features. No existing interface will be removed or -changed although it may be deprecated. -- org/apache/catalina/* -- org/apache/catalina/comet/* - -Note: As Tomcat 7 matures, the above list will be added to. The list is not - considered complete at this time. - -The remaining classes are considered part of the Tomcat internals and may change -without notice between point releases. - - -======================= -JNI Based Applications: -======================= -Applications that require native libraries must ensure that the libraries have -been loaded prior to use. Typically, this is done with a call like: - - static { - System.loadLibrary("path-to-library-file"); - } - -in some class. However, the application must also ensure that the library is -not loaded more than once. If the above code were placed in a class inside -the web application (i.e. under /WEB-INF/classes or /WEB-INF/lib), and the -application were reloaded, the loadLibrary() call would be attempted a second -time. - -To avoid this problem, place classes that load native libraries outside of the -web application, and ensure that the loadLibrary() call is executed only once -during the lifetime of a particular JVM. - - -============= -Bundled APIs: -============= -A standard installation of Tomcat 7.0 makes all of the following APIs available -for use by web applications (by placing them in "lib"): -* annotations-api.jar (Annotations package) -* catalina.jar (Tomcat Catalina implementation) -* catalina-ant.jar (Tomcat Catalina Ant tasks) -* catalina-ha.jar (High availability package) -* catalina-tribes.jar (Group communication) -* ecj-3.7.2.jar (Eclipse JDT Java compiler) -* el-api.jar (EL 2.2 API) -* jasper.jar (Jasper 2 Compiler and Runtime) -* jasper-el.jar (Jasper 2 EL implementation) -* jsp-api.jar (JSP 2.2 API) -* servlet-api.jar (Servlet 3.0 API) -* tomcat-api.jar (Interfaces shared by Catalina and Jasper) -* tomcat-coyote.jar (Tomcat connectors and utility classes) -* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP) - -You can make additional APIs available to all of your web applications by -putting unpacked classes into a "classes" directory (not created by default), -or by placing them in JAR files in the "lib" directory. - -To override the XML parser implementation or interfaces, use the endorsed -mechanism of the JVM. The default configuration defines JARs located in -"endorsed" as endorsed. - - -================================================================ -Web application reloading and static fields in shared libraries: -================================================================ -Some shared libraries (many are part of the JDK) keep references to objects -instantiated by the web application. To avoid class loading related problems -(ClassCastExceptions, messages indicating that the classloader -is stopped, etc.), the shared libraries state should be reinitialized. - -Something which might help is to avoid putting classes which would be -referenced by a shared static field in the web application classloader, -and putting them in the shared classloader instead (JARs should be put in the -"lib" folder, and classes should be put in the "classes" folder). - - -================ -Tomcat on Linux: -================ -GLIBC 2.2 / Linux 2.4 users should define an environment variable: -export LD_ASSUME_KERNEL=2.2.5 - -Redhat Linux 9.0 users should use the following setting to avoid -stability problems: -export LD_ASSUME_KERNEL=2.4.1 - -There are some Linux bugs reported against the NIO sendfile behavior, make sure you -have a JDK that is up to date, or disable sendfile behavior in the Connector.
-6427312: (fc) FileChannel.transferTo() throws IOException "system call interrupted"
-5103988: (fc) FileChannel.transferTo should return -1 for EAGAIN instead throws IOException
-6253145: (fc) FileChannel.transferTo on Linux fails when going beyond 2GB boundary
-6470086: (fc) FileChannel.transferTo(2147483647, 1, channel) cause "Value too large" exception
- - -============================= -Enabling SSI and CGI Support: -============================= -Because of the security risks associated with CGI and SSI available -to web applications, these features are disabled by default. - -To enable and configure CGI support, please see the cgi-howto.html page. - -To enable and configue SSI support, please see the ssi-howto.html page. - - -====================== -Security manager URLs: -====================== -In order to grant security permissions to JARs located inside the -web application repository, use URLs of of the following format -in your policy file: - -file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar - - -============================ -Symlinking static resources: -============================ -By default, Unix symlinks will not work when used in a web application to link -resources located outside the web application root directory. - -This behavior is optional, and the "allowLinking" flag may be used to disable -the check. - - -============================== -Viewing the Tomcat Change Log: -============================== -See changelog.html in this directory. - - -============================= -Cryptographic software notice -============================= -This distribution includes cryptographic software. The country in -which you currently reside may have restrictions on the import, -possession, use, and/or re-export to another country, of -encryption software. BEFORE using any encryption software, please -check your country's laws, regulations and policies concerning the -import, possession, or use, and re-export of encryption software, to -see if this is permitted. See for more -information. - -The U.S. Government Department of Commerce, Bureau of Industry and -Security (BIS), has classified this software as Export Commodity -Control Number (ECCN) 5D002.C.1, which includes information security -software using or performing cryptographic functions with asymmetric -algorithms. The form and manner of this Apache Software Foundation -distribution makes it eligible for export under the License Exception -ENC Technology Software Unrestricted (TSU) exception (see the BIS -Export Administration Regulations, Section 740.13) for both object -code and source code. - -The following provides more details on the included cryptographic -software: - - Tomcat includes code designed to work with JSSE - - Tomcat includes code designed to work with OpenSSL - - -==================== -When all else fails: -==================== -See the FAQ -http://tomcat.apache.org/faq/ +================================================================================ + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +================================================================================ + +$Id: RELEASE-NOTES 1189163 2011-10-26 12:19:26Z kkolinko $ + + + Apache Tomcat Version 7.0.27 + Release Notes + + +========= +CONTENTS: +========= + +* Dependency Changes +* API Stability +* JNI Based Applications +* Bundled APIs +* Web application reloading and static fields in shared libraries +* Tomcat on Linux +* Enabling SSI and CGI Support +* Security manager URLs +* Symlinking static resources +* Viewing the Tomcat Change Log +* Cryptographic software notice +* When all else fails + + +=================== +Dependency Changes: +=================== +Tomcat 7.0 is designed to run on Java SE 6 and later. + +In addition, Tomcat 7.0 uses the Eclipse JDT Java compiler for +compiling JSP pages. This means you no longer need to have the complete +Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment +(JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the +binary Tomcat distributions. Tomcat can also be configured to use the +compiler from the JDK to compile JSPs, or any other Java compiler supported +by Apache Ant. + + +============== +API Stability: +============== +The public interfaces for the following classes are fixed and will not be +changed at all during the remaining lifetime of the 7.x series: +- javax/**/* + +The public interfaces for the following classes may be added to in order to +resolve bugs and/or add new features. No existing interface will be removed or +changed although it may be deprecated. +- org/apache/catalina/* +- org/apache/catalina/comet/* + +Note: As Tomcat 7 matures, the above list will be added to. The list is not + considered complete at this time. + +The remaining classes are considered part of the Tomcat internals and may change +without notice between point releases. + + +======================= +JNI Based Applications: +======================= +Applications that require native libraries must ensure that the libraries have +been loaded prior to use. Typically, this is done with a call like: + + static { + System.loadLibrary("path-to-library-file"); + } + +in some class. However, the application must also ensure that the library is +not loaded more than once. If the above code were placed in a class inside +the web application (i.e. under /WEB-INF/classes or /WEB-INF/lib), and the +application were reloaded, the loadLibrary() call would be attempted a second +time. + +To avoid this problem, place classes that load native libraries outside of the +web application, and ensure that the loadLibrary() call is executed only once +during the lifetime of a particular JVM. + + +============= +Bundled APIs: +============= +A standard installation of Tomcat 7.0 makes all of the following APIs available +for use by web applications (by placing them in "lib"): +* annotations-api.jar (Annotations package) +* catalina.jar (Tomcat Catalina implementation) +* catalina-ant.jar (Tomcat Catalina Ant tasks) +* catalina-ha.jar (High availability package) +* catalina-tribes.jar (Group communication) +* ecj-3.7.2.jar (Eclipse JDT Java compiler) +* el-api.jar (EL 2.2 API) +* jasper.jar (Jasper 2 Compiler and Runtime) +* jasper-el.jar (Jasper 2 EL implementation) +* jsp-api.jar (JSP 2.2 API) +* servlet-api.jar (Servlet 3.0 API) +* tomcat-api.jar (Interfaces shared by Catalina and Jasper) +* tomcat-coyote.jar (Tomcat connectors and utility classes) +* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP) + +You can make additional APIs available to all of your web applications by +putting unpacked classes into a "classes" directory (not created by default), +or by placing them in JAR files in the "lib" directory. + +To override the XML parser implementation or interfaces, use the endorsed +mechanism of the JVM. The default configuration defines JARs located in +"endorsed" as endorsed. + + +================================================================ +Web application reloading and static fields in shared libraries: +================================================================ +Some shared libraries (many are part of the JDK) keep references to objects +instantiated by the web application. To avoid class loading related problems +(ClassCastExceptions, messages indicating that the classloader +is stopped, etc.), the shared libraries state should be reinitialized. + +Something which might help is to avoid putting classes which would be +referenced by a shared static field in the web application classloader, +and putting them in the shared classloader instead (JARs should be put in the +"lib" folder, and classes should be put in the "classes" folder). + + +================ +Tomcat on Linux: +================ +GLIBC 2.2 / Linux 2.4 users should define an environment variable: +export LD_ASSUME_KERNEL=2.2.5 + +Redhat Linux 9.0 users should use the following setting to avoid +stability problems: +export LD_ASSUME_KERNEL=2.4.1 + +There are some Linux bugs reported against the NIO sendfile behavior, make sure you +have a JDK that is up to date, or disable sendfile behavior in the Connector.
+6427312: (fc) FileChannel.transferTo() throws IOException "system call interrupted"
+5103988: (fc) FileChannel.transferTo should return -1 for EAGAIN instead throws IOException
+6253145: (fc) FileChannel.transferTo on Linux fails when going beyond 2GB boundary
+6470086: (fc) FileChannel.transferTo(2147483647, 1, channel) cause "Value too large" exception
+ + +============================= +Enabling SSI and CGI Support: +============================= +Because of the security risks associated with CGI and SSI available +to web applications, these features are disabled by default. + +To enable and configure CGI support, please see the cgi-howto.html page. + +To enable and configue SSI support, please see the ssi-howto.html page. + + +====================== +Security manager URLs: +====================== +In order to grant security permissions to JARs located inside the +web application repository, use URLs of of the following format +in your policy file: + +file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar + + +============================ +Symlinking static resources: +============================ +By default, Unix symlinks will not work when used in a web application to link +resources located outside the web application root directory. + +This behavior is optional, and the "allowLinking" flag may be used to disable +the check. + + +============================== +Viewing the Tomcat Change Log: +============================== +See changelog.html in this directory. + + +============================= +Cryptographic software notice +============================= +This distribution includes cryptographic software. The country in +which you currently reside may have restrictions on the import, +possession, use, and/or re-export to another country, of +encryption software. BEFORE using any encryption software, please +check your country's laws, regulations and policies concerning the +import, possession, or use, and re-export of encryption software, to +see if this is permitted. See for more +information. + +The U.S. Government Department of Commerce, Bureau of Industry and +Security (BIS), has classified this software as Export Commodity +Control Number (ECCN) 5D002.C.1, which includes information security +software using or performing cryptographic functions with asymmetric +algorithms. The form and manner of this Apache Software Foundation +distribution makes it eligible for export under the License Exception +ENC Technology Software Unrestricted (TSU) exception (see the BIS +Export Administration Regulations, Section 740.13) for both object +code and source code. + +The following provides more details on the included cryptographic +software: + - Tomcat includes code designed to work with JSSE + - Tomcat includes code designed to work with OpenSSL + + +==================== +When all else fails: +==================== +See the FAQ +http://tomcat.apache.org/faq/ diff --git a/RUNNING.txt b/RUNNING.txt old mode 100644 new mode 100755 index bf37d60..8ccc91d --- a/RUNNING.txt +++ b/RUNNING.txt @@ -1,289 +1,289 @@ -================================================================================ - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -================================================================================ - -$Id: RUNNING.txt 1196746 2011-11-02 18:31:50Z kkolinko $ - - =================================================== - Running The Apache Tomcat 7.0 Servlet/JSP Container - =================================================== - -Apache Tomcat 7.0 requires the Java Standard Edition Runtime -Environment (JRE) version 6.0 or later. - -============================= -Running With JRE 6.0 Or Later -============================= - -(1) Download and Install the Java SE Runtime Environment (JRE) - -(1.1) Download the Java SE Runtime Environment (JRE), - release version 6.0 or later, from - http://www.oracle.com/technetwork/java/javase/downloads/index.html - -(1.2) Install the JRE according to the instructions included with the - release. - - You may also use the full JDK rather than just the JRE. In this - case set you have to configure your environment variables - differently - see below. - - -(2) Download and Install the Tomcat Binary Distribution - -(2.1) Download a binary distribution of Tomcat from: - - http://tomcat.apache.org/ - -(2.2) Unpack the binary distribution into a convenient location so that the - distribution resides in its own directory (conventionally named - "apache-tomcat-[version]"). - - For the purposes of the remainder of this document, the name - "CATALINA_HOME" is used to refer to the full pathname of the release - directory. - -NOTE: As an alternative to downloading a binary distribution, you can -create your own from the Tomcat source code, as described in -"BUILDING.txt". You can either - - a) Do the full "release" build and find the created distributive in the - "output/release" directory and then proceed with unpacking as above, or - - b) Do a simple build and use the "output/build" directory as - "CATALINA_HOME". Be warned that there are some differences between - contents of "output/build" and the official "release" distributive. - - -(3) Configure Environment Variables - -Tomcat itself is a Java application and does not use environment variables, -but the startup scripts use them to prepare the command that starts Tomcat. -The full list of supported environment variables is provided as a comment -at the top of catalina.bat (Windows) and catalina.sh (Unix) files. - -(3.1) CATALINA_HOME and CATALINA_BASE - -The CATALINA_HOME and CATALINA_BASE environment variables are used to -specify location of Tomcat itself and of its active configuration -respectively. - -The CATALINA_HOME environment variable should be set as defined in (2.2) -above. The startup scripts have some logic to set this variable -automatically if it is absent (based on the location of the script in -Unixes and on the current directory in Windows), but it might be not -perfect. - -The CATALINA_BASE environment variable is optional and is further described -in "Multiple Tomcat Instances" section below. If it is not set it defaults -to be equal to CATALINA_HOME. - -(3.2) JRE_HOME and other variables - -The third and the last environment variable that is needed to start Tomcat -specifies location of JRE or JDK that should be used to start Tomcat. - -There are two different names of this variable, depending on whether JRE or -JDK is used. Use the JRE_HOME variable to specify location of a JRE and -JAVA_HOME variable to specify location of a JDK. - -All variables except CATALINA_HOME and CATALINA_BASE can be configured in a -setenv.bat (Windows) or setenv.sh (Unix) file. The setenv file can be either -in CATALINA_BASE/bin or in CATALINA_HOME/bin. If both are present, only the -one in CATALINA_BASE is used. - -So, either set JRE_HOME variable by yourselves or create the file. For -example, - -On Windows, %CATALINA_BASE%\bin\setenv.bat: - - set "JRE_HOME=%ProgramFiles%\Java\jre6" - exit /b 0 - -On Unix, $CATALINA_BASE/bin/setenv.sh: - - JRE_HOME=/usr/java/latest - - -(4) Start Up Tomcat - -(4.1) Tomcat can be started by executing one of the following commands: - - %CATALINA_HOME%\bin\startup.bat (Windows) - - $CATALINA_HOME/bin/startup.sh (Unix) - - or - - %CATALINA_HOME%\bin\catalina.bat start (Windows) - - $CATALINA_HOME/bin/catalina.sh start (Unix) - -(4.2) After startup, the default web applications included with Tomcat will be - available by visiting: - - http://localhost:8080/ - -(4.3) Further information about configuring and running Tomcat can be found in - the documentation included here, as well as on the Tomcat web site: - - http://tomcat.apache.org/ - - -(5) Shut Down Tomcat - -(5.1) Tomcat can be shut down by executing one of the following commands: - - %CATALINA_HOME%\bin\shutdown.bat (Windows) - - $CATALINA_HOME/bin/shutdown.sh (Unix) - - or - - %CATALINA_HOME%\bin\catalina.bat stop (Windows) - - $CATALINA_HOME/bin/catalina.sh stop (Unix) - -================================================== -Advanced Configuration - Multiple Tomcat Instances -================================================== - -In many circumstances, it is desirable to have a single copy of a Tomcat -binary distribution shared among multiple users on the same server. To make -this possible, you can set the CATALINA_BASE environment variable to the -directory that contains the files for your 'personal' Tomcat instance. - -When running with separate CATALINA_HOME and CATALINA_BASE, the files -and directories are split as following: - -In CATALINA_BASE: - - * bin - Only the following files: - - * setenv.sh (*nix) or setenv.bat (Windows), - * tomcat-juli.jar - - The setenv scripts were described above. The tomcat-juli library - is documented in the Logging chapter in the User Guide. - - * conf - Server configuration files (including server.xml) - - * lib - Libraries and classes - - * logs - Log and output files - - * webapps - Automatically loaded web applications - - * work - Temporary working directories for web applications - - * temp - Directory used by the JVM for temporary files (java.io.tmpdir) - - -In CATALINA_HOME: - - * bin - Startup and shutdown scripts - - The following files will be used only if they are absent in - CATALINA_BASE/bin: - - setenv.sh (*nix), setenv.bat (Windows), tomcat-juli.jar - - * lib - Libraries and classes, as explained below - - * endorsed - Libraries that override standard "Endorsed Standards" - libraries provided by JRE. See Classloading documentation - in the User Guide for details. - - By default this "endorsed" directory is absent. - -In the default configuration the JAR libraries and classes both in -CATALINA_BASE/lib and in CATALINA_HOME/lib will be added to the common -classpath, but the ones in CATALINA_BASE will be added first and thus will -be searched first. - -The idea is that you may leave the standard Tomcat libraries in -CATALINA_HOME/lib and add other ones such as database drivers into -CATALINA_BASE/lib. - -In general it is advised to never share libraries between web applications, -but put them into WEB-INF/lib directories inside the applications. See -Classloading documentation in the User Guide for details. - - -It might be useful to note that the values of CATALINA_HOME and -CATALINA_BASE can be referenced in the XML configuration files processed -by Tomcat as ${catalina.home} and ${catalina.base} respectively. - -For example, the standard manager web application can be kept in -CATALINA_HOME/webapps/manager and loaded into CATALINA_BASE by using -the following trick: - - * Copy the CATALINA_HOME/webapps/manager/META-INF/context.xml - file as CATALINA_BASE/conf/Catalina/localhost/manager.xml - - * Add docBase attribute as shown below. - -The file will look like the following: - - - - - -See Deployer chapter in User Guide and Context and Host chapters in the -Configuration Reference for more information on contexts and web -application deployment. - - -================ -Troubleshooting -================ - -There are only really 3 things likely to go wrong during the stand-alone -Tomcat install: - -(1) The most common hiccup is when another web server (or any process for that - matter) has laid claim to port 8080. This is the default HTTP port that - Tomcat attempts to bind to at startup. To change this, open the file: - - $CATALINA_HOME/conf/server.xml - - and search for '8080'. Change it to a port that isn't in use, and is - greater than 1024, as ports less than or equal to 1024 require superuser - access to bind under UNIX. - - Restart Tomcat and you're in business. Be sure that you replace the "8080" - in the URL you're using to access Tomcat. For example, if you change the - port to 1977, you would request the URL http://localhost:1977/ in your browser. - -(2) An "out of environment space" error when running the batch files in - Windows 95, 98, or ME operating systems. - - Right-click on the STARTUP.BAT and SHUTDOWN.BAT files. Click on - "Properties", then on the "Memory" tab. For the "Initial environment" field, - enter in something like 4096. - - After you click apply, Windows will create shortcuts which you can use - to start and stop the container. - -(3) The 'localhost' machine isn't found. This could happen if you're behind a - proxy. If that's the case, make sure the proxy configuration for your - browser knows that you shouldn't be going through the proxy to access the - "localhost". - - In Firefox, this is under Tools/Preferences -> Advanced/Network -> - Connection -> Settings..., and in Internet Explorer it is Tools -> - Internet Options -> Connections -> LAN Settings. +================================================================================ + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +================================================================================ + +$Id: RUNNING.txt 1196746 2011-11-02 18:31:50Z kkolinko $ + + =================================================== + Running The Apache Tomcat 7.0 Servlet/JSP Container + =================================================== + +Apache Tomcat 7.0 requires the Java Standard Edition Runtime +Environment (JRE) version 6.0 or later. + +============================= +Running With JRE 6.0 Or Later +============================= + +(1) Download and Install the Java SE Runtime Environment (JRE) + +(1.1) Download the Java SE Runtime Environment (JRE), + release version 6.0 or later, from + http://www.oracle.com/technetwork/java/javase/downloads/index.html + +(1.2) Install the JRE according to the instructions included with the + release. + + You may also use the full JDK rather than just the JRE. In this + case set you have to configure your environment variables + differently - see below. + + +(2) Download and Install the Tomcat Binary Distribution + +(2.1) Download a binary distribution of Tomcat from: + + http://tomcat.apache.org/ + +(2.2) Unpack the binary distribution into a convenient location so that the + distribution resides in its own directory (conventionally named + "apache-tomcat-[version]"). + + For the purposes of the remainder of this document, the name + "CATALINA_HOME" is used to refer to the full pathname of the release + directory. + +NOTE: As an alternative to downloading a binary distribution, you can +create your own from the Tomcat source code, as described in +"BUILDING.txt". You can either + + a) Do the full "release" build and find the created distributive in the + "output/release" directory and then proceed with unpacking as above, or + + b) Do a simple build and use the "output/build" directory as + "CATALINA_HOME". Be warned that there are some differences between + contents of "output/build" and the official "release" distributive. + + +(3) Configure Environment Variables + +Tomcat itself is a Java application and does not use environment variables, +but the startup scripts use them to prepare the command that starts Tomcat. +The full list of supported environment variables is provided as a comment +at the top of catalina.bat (Windows) and catalina.sh (Unix) files. + +(3.1) CATALINA_HOME and CATALINA_BASE + +The CATALINA_HOME and CATALINA_BASE environment variables are used to +specify location of Tomcat itself and of its active configuration +respectively. + +The CATALINA_HOME environment variable should be set as defined in (2.2) +above. The startup scripts have some logic to set this variable +automatically if it is absent (based on the location of the script in +Unixes and on the current directory in Windows), but it might be not +perfect. + +The CATALINA_BASE environment variable is optional and is further described +in "Multiple Tomcat Instances" section below. If it is not set it defaults +to be equal to CATALINA_HOME. + +(3.2) JRE_HOME and other variables + +The third and the last environment variable that is needed to start Tomcat +specifies location of JRE or JDK that should be used to start Tomcat. + +There are two different names of this variable, depending on whether JRE or +JDK is used. Use the JRE_HOME variable to specify location of a JRE and +JAVA_HOME variable to specify location of a JDK. + +All variables except CATALINA_HOME and CATALINA_BASE can be configured in a +setenv.bat (Windows) or setenv.sh (Unix) file. The setenv file can be either +in CATALINA_BASE/bin or in CATALINA_HOME/bin. If both are present, only the +one in CATALINA_BASE is used. + +So, either set JRE_HOME variable by yourselves or create the file. For +example, + +On Windows, %CATALINA_BASE%\bin\setenv.bat: + + set "JRE_HOME=%ProgramFiles%\Java\jre6" + exit /b 0 + +On Unix, $CATALINA_BASE/bin/setenv.sh: + + JRE_HOME=/usr/java/latest + + +(4) Start Up Tomcat + +(4.1) Tomcat can be started by executing one of the following commands: + + %CATALINA_HOME%\bin\startup.bat (Windows) + + $CATALINA_HOME/bin/startup.sh (Unix) + + or + + %CATALINA_HOME%\bin\catalina.bat start (Windows) + + $CATALINA_HOME/bin/catalina.sh start (Unix) + +(4.2) After startup, the default web applications included with Tomcat will be + available by visiting: + + http://localhost:8080/ + +(4.3) Further information about configuring and running Tomcat can be found in + the documentation included here, as well as on the Tomcat web site: + + http://tomcat.apache.org/ + + +(5) Shut Down Tomcat + +(5.1) Tomcat can be shut down by executing one of the following commands: + + %CATALINA_HOME%\bin\shutdown.bat (Windows) + + $CATALINA_HOME/bin/shutdown.sh (Unix) + + or + + %CATALINA_HOME%\bin\catalina.bat stop (Windows) + + $CATALINA_HOME/bin/catalina.sh stop (Unix) + +================================================== +Advanced Configuration - Multiple Tomcat Instances +================================================== + +In many circumstances, it is desirable to have a single copy of a Tomcat +binary distribution shared among multiple users on the same server. To make +this possible, you can set the CATALINA_BASE environment variable to the +directory that contains the files for your 'personal' Tomcat instance. + +When running with separate CATALINA_HOME and CATALINA_BASE, the files +and directories are split as following: + +In CATALINA_BASE: + + * bin - Only the following files: + + * setenv.sh (*nix) or setenv.bat (Windows), + * tomcat-juli.jar + + The setenv scripts were described above. The tomcat-juli library + is documented in the Logging chapter in the User Guide. + + * conf - Server configuration files (including server.xml) + + * lib - Libraries and classes + + * logs - Log and output files + + * webapps - Automatically loaded web applications + + * work - Temporary working directories for web applications + + * temp - Directory used by the JVM for temporary files (java.io.tmpdir) + + +In CATALINA_HOME: + + * bin - Startup and shutdown scripts + + The following files will be used only if they are absent in + CATALINA_BASE/bin: + + setenv.sh (*nix), setenv.bat (Windows), tomcat-juli.jar + + * lib - Libraries and classes, as explained below + + * endorsed - Libraries that override standard "Endorsed Standards" + libraries provided by JRE. See Classloading documentation + in the User Guide for details. + + By default this "endorsed" directory is absent. + +In the default configuration the JAR libraries and classes both in +CATALINA_BASE/lib and in CATALINA_HOME/lib will be added to the common +classpath, but the ones in CATALINA_BASE will be added first and thus will +be searched first. + +The idea is that you may leave the standard Tomcat libraries in +CATALINA_HOME/lib and add other ones such as database drivers into +CATALINA_BASE/lib. + +In general it is advised to never share libraries between web applications, +but put them into WEB-INF/lib directories inside the applications. See +Classloading documentation in the User Guide for details. + + +It might be useful to note that the values of CATALINA_HOME and +CATALINA_BASE can be referenced in the XML configuration files processed +by Tomcat as ${catalina.home} and ${catalina.base} respectively. + +For example, the standard manager web application can be kept in +CATALINA_HOME/webapps/manager and loaded into CATALINA_BASE by using +the following trick: + + * Copy the CATALINA_HOME/webapps/manager/META-INF/context.xml + file as CATALINA_BASE/conf/Catalina/localhost/manager.xml + + * Add docBase attribute as shown below. + +The file will look like the following: + + + + + +See Deployer chapter in User Guide and Context and Host chapters in the +Configuration Reference for more information on contexts and web +application deployment. + + +================ +Troubleshooting +================ + +There are only really 3 things likely to go wrong during the stand-alone +Tomcat install: + +(1) The most common hiccup is when another web server (or any process for that + matter) has laid claim to port 8080. This is the default HTTP port that + Tomcat attempts to bind to at startup. To change this, open the file: + + $CATALINA_HOME/conf/server.xml + + and search for '8080'. Change it to a port that isn't in use, and is + greater than 1024, as ports less than or equal to 1024 require superuser + access to bind under UNIX. + + Restart Tomcat and you're in business. Be sure that you replace the "8080" + in the URL you're using to access Tomcat. For example, if you change the + port to 1977, you would request the URL http://localhost:1977/ in your browser. + +(2) An "out of environment space" error when running the batch files in + Windows 95, 98, or ME operating systems. + + Right-click on the STARTUP.BAT and SHUTDOWN.BAT files. Click on + "Properties", then on the "Memory" tab. For the "Initial environment" field, + enter in something like 4096. + + After you click apply, Windows will create shortcuts which you can use + to start and stop the container. + +(3) The 'localhost' machine isn't found. This could happen if you're behind a + proxy. If that's the case, make sure the proxy configuration for your + browser knows that you shouldn't be going through the proxy to access the + "localhost". + + In Firefox, this is under Tools/Preferences -> Advanced/Network -> + Connection -> Settings..., and in Internet Explorer it is Tools -> + Internet Options -> Connections -> LAN Settings. diff --git a/bin/bootstrap.jar b/bin/bootstrap.jar old mode 100644 new mode 100755 diff --git a/bin/catalina-tasks.xml b/bin/catalina-tasks.xml old mode 100644 new mode 100755 index a40314a..ae5a20d --- a/bin/catalina-tasks.xml +++ b/bin/catalina-tasks.xml @@ -1,61 +1,61 @@ - - - - - - Catalina Ant Manager, JMX and JSPC Tasks - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + Catalina Ant Manager, JMX and JSPC Tasks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/catalina.bat b/bin/catalina.bat old mode 100644 new mode 100755 index 611b4cb..fa96fde --- a/bin/catalina.bat +++ b/bin/catalina.bat @@ -1,323 +1,323 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Start/Stop Script for the CATALINA Server -rem -rem Environment Variable Prerequisites -rem -rem Do not set the variables in this script. Instead put them into a script -rem setenv.bat in CATALINA_BASE/bin to keep your customizations separate. -rem -rem CATALINA_HOME May point at your Catalina "build" directory. -rem -rem CATALINA_BASE (Optional) Base directory for resolving dynamic portions -rem of a Catalina installation. If not present, resolves to -rem the same directory that CATALINA_HOME points to. -rem -rem CATALINA_OPTS (Optional) Java runtime options used when the "start", -rem "run" or "debug" command is executed. -rem Include here and not in JAVA_OPTS all options, that should -rem only be used by Tomcat itself, not by the stop process, -rem the version command etc. -rem Examples are heap size, GC logging, JMX ports etc. -rem -rem CATALINA_TMPDIR (Optional) Directory path location of temporary directory -rem the JVM should use (java.io.tmpdir). Defaults to -rem %CATALINA_BASE%\temp. -rem -rem JAVA_HOME Must point at your Java Development Kit installation. -rem Required to run the with the "debug" argument. -rem -rem JRE_HOME Must point at your Java Runtime installation. -rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME -rem are both set, JRE_HOME is used. -rem -rem JAVA_OPTS (Optional) Java runtime options used when any command -rem is executed. -rem Include here and not in CATALINA_OPTS all options, that -rem should be used by Tomcat and also by the stop process, -rem the version command etc. -rem Most options should go into CATALINA_OPTS. -rem -rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories -rem containing some jars in order to allow replacement of APIs -rem created outside of the JCP (i.e. DOM and SAX from W3C). -rem It can also be used to update the XML parser implementation. -rem Defaults to $CATALINA_HOME/endorsed. -rem -rem JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" -rem command is executed. The default is "dt_socket". -rem -rem JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" -rem command is executed. The default is 8000. -rem -rem JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" -rem command is executed. Specifies whether JVM should suspend -rem execution immediately after startup. Default is "n". -rem -rem JPDA_OPTS (Optional) Java runtime options used when the "jpda start" -rem command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, -rem and JPDA_SUSPEND are ignored. Thus, all required jpda -rem options MUST be specified. The default is: -rem -rem -agentlib:jdwp=transport=%JPDA_TRANSPORT%, -rem address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% -rem -rem LOGGING_CONFIG (Optional) Override Tomcat's logging config file -rem Example (all one line) -rem set LOGGING_CONFIG="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" -rem -rem LOGGING_MANAGER (Optional) Override Tomcat's logging manager -rem Example (all one line) -rem set LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" -rem -rem TITLE (Optional) Specify the title of Tomcat window. The default -rem TITLE is Tomcat if it's not specified. -rem Example (all one line) -rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%] -rem -rem -rem -rem $Id: catalina.bat 1202062 2011-11-15 06:50:02Z mturk $ -rem --------------------------------------------------------------------------- - -rem Suppress Terminate batch job on CTRL+C -if not ""%1"" == ""run"" goto mainEntry -if ""%TEMP%"" == """" goto mainEntry -if exist "%TEMP%\%~nx0.run" goto mainEntry -echo Y>"%TEMP%\%~nx0.run" -if not exist "%TEMP%\%~nx0.run" goto mainEntry -echo Y>"%TEMP%\%~nx0.Y" -call "%~f0" %* <"%TEMP%\%~nx0.Y" -rem Use provided errorlevel -set RETVAL=%ERRORLEVEL% -del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1 -exit /B %RETVAL% -:mainEntry -del /Q "%TEMP%\%~nx0.run" >NUL 2>&1 - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome - -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -rem Copy CATALINA_BASE from CATALINA_HOME if not defined -if not "%CATALINA_BASE%" == "" goto gotBase -set "CATALINA_BASE=%CATALINA_HOME%" -:gotBase - -rem Ensure that any user defined CLASSPATH variables are not used on startup, -rem but allow them to be specified in setenv.bat, in rare case when it is needed. -set CLASSPATH= - -rem Get standard environment variables -if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome -call "%CATALINA_BASE%\bin\setenv.bat" -goto setenvDone -:checkSetenvHome -if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" -:setenvDone - -rem Get standard Java environment variables -if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath -echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" -echo This file is needed to run this program -goto end -:okSetclasspath -call "%CATALINA_HOME%\bin\setclasspath.bat" %1 -if errorlevel 1 goto end - -rem Add on extra jar file to CLASSPATH -rem Note that there are no quotes as we do not want to introduce random -rem quotes into the CLASSPATH -if "%CLASSPATH%" == "" goto emptyClasspath -set "CLASSPATH=%CLASSPATH%;" -:emptyClasspath -set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar" - -if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir -set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" -:gotTmpdir - -rem Add tomcat-juli.jar to classpath -rem tomcat-juli.jar can be over-ridden per instance -if not exist "%CATALINA_BASE%\bin\tomcat-juli.jar" goto juliClasspathHome -set "CLASSPATH=%CLASSPATH%;%CATALINA_BASE%\bin\tomcat-juli.jar" -goto juliClasspathDone -:juliClasspathHome -set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" -:juliClasspathDone - -if not "%LOGGING_CONFIG%" == "" goto noJuliConfig -set LOGGING_CONFIG=-Dnop -if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig -set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" -:noJuliConfig -set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG% - -if not "%LOGGING_MANAGER%" == "" goto noJuliManager -set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -:noJuliManager -set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER% - -rem ----- Execute The Requested Command --------------------------------------- - -echo Using CATALINA_BASE: "%CATALINA_BASE%" -echo Using CATALINA_HOME: "%CATALINA_HOME%" -echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%" -if ""%1"" == ""debug"" goto use_jdk -echo Using JRE_HOME: "%JRE_HOME%" -goto java_dir_displayed -:use_jdk -echo Using JAVA_HOME: "%JAVA_HOME%" -:java_dir_displayed -echo Using CLASSPATH: "%CLASSPATH%" - -set _EXECJAVA=%_RUNJAVA% -set MAINCLASS=org.apache.catalina.startup.Bootstrap -set ACTION=start -set SECURITY_POLICY_FILE= -set DEBUG_OPTS= -set JPDA= - -if not ""%1"" == ""jpda"" goto noJpda -set JPDA=jpda -if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport -set JPDA_TRANSPORT=dt_socket -:gotJpdaTransport -if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress -set JPDA_ADDRESS=8000 -:gotJpdaAddress -if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend -set JPDA_SUSPEND=n -:gotJpdaSuspend -if not "%JPDA_OPTS%" == "" goto gotJpdaOpts -set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% -:gotJpdaOpts -shift -:noJpda - -if ""%1"" == ""debug"" goto doDebug -if ""%1"" == ""run"" goto doRun -if ""%1"" == ""start"" goto doStart -if ""%1"" == ""stop"" goto doStop -if ""%1"" == ""configtest"" goto doConfigTest -if ""%1"" == ""version"" goto doVersion - -echo Usage: catalina ( commands ... ) -echo commands: -echo debug Start Catalina in a debugger -echo debug -security Debug Catalina with a security manager -echo jpda start Start Catalina under JPDA debugger -echo run Start Catalina in the current window -echo run -security Start in the current window with security manager -echo start Start Catalina in a separate window -echo start -security Start in a separate window with security manager -echo stop Stop Catalina -echo configtest Run a basic syntax check on server.xml -echo version What version of tomcat are you running? -goto end - -:doDebug -shift -set _EXECJAVA=%_RUNJDB% -set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java" -if not ""%1"" == ""-security"" goto execCmd -shift -echo Using Security Manager -set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" -goto execCmd - -:doRun -shift -if not ""%1"" == ""-security"" goto execCmd -shift -echo Using Security Manager -set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" -goto execCmd - -:doStart -shift -if not "%OS%" == "Windows_NT" goto noTitle -if "%TITLE%" == "" set TITLE=Tomcat -set _EXECJAVA=start "%TITLE%" %_RUNJAVA% -goto gotTitle -:noTitle -set _EXECJAVA=start %_RUNJAVA% -:gotTitle -if not ""%1"" == ""-security"" goto execCmd -shift -echo Using Security Manager -set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" -goto execCmd - -:doStop -shift -set ACTION=stop -set CATALINA_OPTS= -goto execCmd - -:doConfigTest -shift -set ACTION=configtest -set CATALINA_OPTS= -goto execCmd - -:doVersion -%_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo -goto end - - -:execCmd -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -rem Execute Java with the applicable properties -if not "%JPDA%" == "" goto doJpda -if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity -%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% -goto end -:doSecurity -%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% -goto end -:doJpda -if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda -%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% -goto end -:doSecurityJpda -%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% -goto end - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Start/Stop Script for the CATALINA Server +rem +rem Environment Variable Prerequisites +rem +rem Do not set the variables in this script. Instead put them into a script +rem setenv.bat in CATALINA_BASE/bin to keep your customizations separate. +rem +rem CATALINA_HOME May point at your Catalina "build" directory. +rem +rem CATALINA_BASE (Optional) Base directory for resolving dynamic portions +rem of a Catalina installation. If not present, resolves to +rem the same directory that CATALINA_HOME points to. +rem +rem CATALINA_OPTS (Optional) Java runtime options used when the "start", +rem "run" or "debug" command is executed. +rem Include here and not in JAVA_OPTS all options, that should +rem only be used by Tomcat itself, not by the stop process, +rem the version command etc. +rem Examples are heap size, GC logging, JMX ports etc. +rem +rem CATALINA_TMPDIR (Optional) Directory path location of temporary directory +rem the JVM should use (java.io.tmpdir). Defaults to +rem %CATALINA_BASE%\temp. +rem +rem JAVA_HOME Must point at your Java Development Kit installation. +rem Required to run the with the "debug" argument. +rem +rem JRE_HOME Must point at your Java Runtime installation. +rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME +rem are both set, JRE_HOME is used. +rem +rem JAVA_OPTS (Optional) Java runtime options used when any command +rem is executed. +rem Include here and not in CATALINA_OPTS all options, that +rem should be used by Tomcat and also by the stop process, +rem the version command etc. +rem Most options should go into CATALINA_OPTS. +rem +rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories +rem containing some jars in order to allow replacement of APIs +rem created outside of the JCP (i.e. DOM and SAX from W3C). +rem It can also be used to update the XML parser implementation. +rem Defaults to $CATALINA_HOME/endorsed. +rem +rem JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start" +rem command is executed. The default is "dt_socket". +rem +rem JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start" +rem command is executed. The default is 8000. +rem +rem JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start" +rem command is executed. Specifies whether JVM should suspend +rem execution immediately after startup. Default is "n". +rem +rem JPDA_OPTS (Optional) Java runtime options used when the "jpda start" +rem command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS, +rem and JPDA_SUSPEND are ignored. Thus, all required jpda +rem options MUST be specified. The default is: +rem +rem -agentlib:jdwp=transport=%JPDA_TRANSPORT%, +rem address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% +rem +rem LOGGING_CONFIG (Optional) Override Tomcat's logging config file +rem Example (all one line) +rem set LOGGING_CONFIG="-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" +rem +rem LOGGING_MANAGER (Optional) Override Tomcat's logging manager +rem Example (all one line) +rem set LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" +rem +rem TITLE (Optional) Specify the title of Tomcat window. The default +rem TITLE is Tomcat if it's not specified. +rem Example (all one line) +rem set TITLE=Tomcat.Cluster#1.Server#1 [%DATE% %TIME%] +rem +rem +rem +rem $Id: catalina.bat 1202062 2011-11-15 06:50:02Z mturk $ +rem --------------------------------------------------------------------------- + +rem Suppress Terminate batch job on CTRL+C +if not ""%1"" == ""run"" goto mainEntry +if ""%TEMP%"" == """" goto mainEntry +if exist "%TEMP%\%~nx0.run" goto mainEntry +echo Y>"%TEMP%\%~nx0.run" +if not exist "%TEMP%\%~nx0.run" goto mainEntry +echo Y>"%TEMP%\%~nx0.Y" +call "%~f0" %* <"%TEMP%\%~nx0.Y" +rem Use provided errorlevel +set RETVAL=%ERRORLEVEL% +del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1 +exit /B %RETVAL% +:mainEntry +del /Q "%TEMP%\%~nx0.run" >NUL 2>&1 + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome + +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +rem Copy CATALINA_BASE from CATALINA_HOME if not defined +if not "%CATALINA_BASE%" == "" goto gotBase +set "CATALINA_BASE=%CATALINA_HOME%" +:gotBase + +rem Ensure that any user defined CLASSPATH variables are not used on startup, +rem but allow them to be specified in setenv.bat, in rare case when it is needed. +set CLASSPATH= + +rem Get standard environment variables +if not exist "%CATALINA_BASE%\bin\setenv.bat" goto checkSetenvHome +call "%CATALINA_BASE%\bin\setenv.bat" +goto setenvDone +:checkSetenvHome +if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" +:setenvDone + +rem Get standard Java environment variables +if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath +echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" +echo This file is needed to run this program +goto end +:okSetclasspath +call "%CATALINA_HOME%\bin\setclasspath.bat" %1 +if errorlevel 1 goto end + +rem Add on extra jar file to CLASSPATH +rem Note that there are no quotes as we do not want to introduce random +rem quotes into the CLASSPATH +if "%CLASSPATH%" == "" goto emptyClasspath +set "CLASSPATH=%CLASSPATH%;" +:emptyClasspath +set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar" + +if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir +set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" +:gotTmpdir + +rem Add tomcat-juli.jar to classpath +rem tomcat-juli.jar can be over-ridden per instance +if not exist "%CATALINA_BASE%\bin\tomcat-juli.jar" goto juliClasspathHome +set "CLASSPATH=%CLASSPATH%;%CATALINA_BASE%\bin\tomcat-juli.jar" +goto juliClasspathDone +:juliClasspathHome +set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar" +:juliClasspathDone + +if not "%LOGGING_CONFIG%" == "" goto noJuliConfig +set LOGGING_CONFIG=-Dnop +if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig +set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties" +:noJuliConfig +set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG% + +if not "%LOGGING_MANAGER%" == "" goto noJuliManager +set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager +:noJuliManager +set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER% + +rem ----- Execute The Requested Command --------------------------------------- + +echo Using CATALINA_BASE: "%CATALINA_BASE%" +echo Using CATALINA_HOME: "%CATALINA_HOME%" +echo Using CATALINA_TMPDIR: "%CATALINA_TMPDIR%" +if ""%1"" == ""debug"" goto use_jdk +echo Using JRE_HOME: "%JRE_HOME%" +goto java_dir_displayed +:use_jdk +echo Using JAVA_HOME: "%JAVA_HOME%" +:java_dir_displayed +echo Using CLASSPATH: "%CLASSPATH%" + +set _EXECJAVA=%_RUNJAVA% +set MAINCLASS=org.apache.catalina.startup.Bootstrap +set ACTION=start +set SECURITY_POLICY_FILE= +set DEBUG_OPTS= +set JPDA= + +if not ""%1"" == ""jpda"" goto noJpda +set JPDA=jpda +if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport +set JPDA_TRANSPORT=dt_socket +:gotJpdaTransport +if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress +set JPDA_ADDRESS=8000 +:gotJpdaAddress +if not "%JPDA_SUSPEND%" == "" goto gotJpdaSuspend +set JPDA_SUSPEND=n +:gotJpdaSuspend +if not "%JPDA_OPTS%" == "" goto gotJpdaOpts +set JPDA_OPTS=-agentlib:jdwp=transport=%JPDA_TRANSPORT%,address=%JPDA_ADDRESS%,server=y,suspend=%JPDA_SUSPEND% +:gotJpdaOpts +shift +:noJpda + +if ""%1"" == ""debug"" goto doDebug +if ""%1"" == ""run"" goto doRun +if ""%1"" == ""start"" goto doStart +if ""%1"" == ""stop"" goto doStop +if ""%1"" == ""configtest"" goto doConfigTest +if ""%1"" == ""version"" goto doVersion + +echo Usage: catalina ( commands ... ) +echo commands: +echo debug Start Catalina in a debugger +echo debug -security Debug Catalina with a security manager +echo jpda start Start Catalina under JPDA debugger +echo run Start Catalina in the current window +echo run -security Start in the current window with security manager +echo start Start Catalina in a separate window +echo start -security Start in a separate window with security manager +echo stop Stop Catalina +echo configtest Run a basic syntax check on server.xml +echo version What version of tomcat are you running? +goto end + +:doDebug +shift +set _EXECJAVA=%_RUNJDB% +set DEBUG_OPTS=-sourcepath "%CATALINA_HOME%\..\..\java" +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doRun +shift +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doStart +shift +if not "%OS%" == "Windows_NT" goto noTitle +if "%TITLE%" == "" set TITLE=Tomcat +set _EXECJAVA=start "%TITLE%" %_RUNJAVA% +goto gotTitle +:noTitle +set _EXECJAVA=start %_RUNJAVA% +:gotTitle +if not ""%1"" == ""-security"" goto execCmd +shift +echo Using Security Manager +set "SECURITY_POLICY_FILE=%CATALINA_BASE%\conf\catalina.policy" +goto execCmd + +:doStop +shift +set ACTION=stop +set CATALINA_OPTS= +goto execCmd + +:doConfigTest +shift +set ACTION=configtest +set CATALINA_OPTS= +goto execCmd + +:doVersion +%_EXECJAVA% -classpath "%CATALINA_HOME%\lib\catalina.jar" org.apache.catalina.util.ServerInfo +goto end + + +:execCmd +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +rem Execute Java with the applicable properties +if not "%JPDA%" == "" goto doJpda +if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity +%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% +goto end +:doSecurity +%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% +goto end +:doJpda +if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda +%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% +goto end +:doSecurityJpda +%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% +goto end + +:end diff --git a/bin/catalina.sh b/bin/catalina.sh old mode 100644 new mode 100755 diff --git a/bin/catalina2.sh b/bin/catalina2.sh old mode 100644 new mode 100755 diff --git a/bin/commons-daemon-native.tar.gz b/bin/commons-daemon-native.tar.gz old mode 100644 new mode 100755 diff --git a/bin/commons-daemon.jar b/bin/commons-daemon.jar old mode 100644 new mode 100755 diff --git a/bin/configtest.bat b/bin/configtest.bat old mode 100644 new mode 100755 index a3afc6a..c3bfd89 --- a/bin/configtest.bat +++ b/bin/configtest.bat @@ -1,59 +1,59 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Configuration test script for the CATALINA Server -rem -rem $Id: configtest.bat 1137560 2011-06-20 09:27:44Z rjung $ -rem --------------------------------------------------------------------------- - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" configtest %CMD_LINE_ARGS% - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Configuration test script for the CATALINA Server +rem +rem $Id: configtest.bat 1137560 2011-06-20 09:27:44Z rjung $ +rem --------------------------------------------------------------------------- + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" + +rem Check that target executable exists +if exist "%EXECUTABLE%" goto okExec +echo Cannot find "%EXECUTABLE%" +echo This file is needed to run this program +goto end +:okExec + +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +call "%EXECUTABLE%" configtest %CMD_LINE_ARGS% + +:end diff --git a/bin/configtest.sh b/bin/configtest.sh old mode 100644 new mode 100755 diff --git a/bin/cpappend.bat b/bin/cpappend.bat old mode 100644 new mode 100755 index ca4b5fa..b9b90c1 --- a/bin/cpappend.bat +++ b/bin/cpappend.bat @@ -1,35 +1,35 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -rem --------------------------------------------------------------------------- -rem Append to CLASSPATH -rem -rem $Id: cpappend.bat 562770 2007-08-04 22:13:58Z markt $ -rem --------------------------------------------------------------------------- - -rem Process the first argument -if ""%1"" == """" goto end -set CLASSPATH=%CLASSPATH%;%1 -shift - -rem Process the remaining arguments -:setArgs -if ""%1"" == """" goto doneSetArgs -set CLASSPATH=%CLASSPATH% %1 -shift -goto setArgs -:doneSetArgs -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +rem --------------------------------------------------------------------------- +rem Append to CLASSPATH +rem +rem $Id: cpappend.bat 562770 2007-08-04 22:13:58Z markt $ +rem --------------------------------------------------------------------------- + +rem Process the first argument +if ""%1"" == """" goto end +set CLASSPATH=%CLASSPATH%;%1 +shift + +rem Process the remaining arguments +:setArgs +if ""%1"" == """" goto doneSetArgs +set CLASSPATH=%CLASSPATH% %1 +shift +goto setArgs +:doneSetArgs +:end diff --git a/bin/demon.sh b/bin/demon.sh old mode 100644 new mode 100755 diff --git a/bin/derby.log b/bin/derby.log index 2ab67de..81e8cae 100644 --- a/bin/derby.log +++ b/bin/derby.log @@ -1,10 +1,10 @@ ---------------------------------------------------------------- -Wed May 23 07:49:33 PDT 2012: -Booting Derby version The Apache Software Foundation - Apache Derby - 10.8.2.2 - (1181258): instance a816c00e-0137-7a2c-9e93-000002f597d0 -on database directory /idrive/usr/caimito/bin/caimito_db with class loader org.apache.catalina.loader.StandardClassLoader@1df5a8f -Loaded from file:/idrive/usr/caimito/lib/derby.jar +Tue Jun 05 14:00:21 PDT 2012: +Booting Derby version The Apache Software Foundation - Apache Derby - 10.8.2.2 - (1181258): instance a816c00e-0137-be72-c544-000002f61848 +on database directory /home/idrive/caimito/bin/caimito_db with class loader org.apache.catalina.loader.StandardClassLoader@1df5a8f +Loaded from file:/home/idrive/caimito/lib/derby.jar java.vendor=Sun Microsystems Inc. java.runtime.version=1.6.0_24-b07 -user.dir=/idrive/usr/caimito/bin +user.dir=/home/idrive/caimito/bin derby.system.home=null Database Class Loader started - derby.database.classpath='' diff --git a/bin/digest.bat b/bin/digest.bat old mode 100644 new mode 100755 index dcc21a3..41491dc --- a/bin/digest.bat +++ b/bin/digest.bat @@ -1,59 +1,59 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Script to digest password using the algorithm specified -rem -rem $Id: digest.bat 1137559 2011-06-20 09:27:30Z rjung $ -rem --------------------------------------------------------------------------- - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set "EXECUTABLE=%CATALINA_HOME%\bin\tool-wrapper.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" -server org.apache.catalina.realm.RealmBase %CMD_LINE_ARGS% - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Script to digest password using the algorithm specified +rem +rem $Id: digest.bat 1137559 2011-06-20 09:27:30Z rjung $ +rem --------------------------------------------------------------------------- + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +set "EXECUTABLE=%CATALINA_HOME%\bin\tool-wrapper.bat" + +rem Check that target executable exists +if exist "%EXECUTABLE%" goto okExec +echo Cannot find "%EXECUTABLE%" +echo This file is needed to run this program +goto end +:okExec + +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +call "%EXECUTABLE%" -server org.apache.catalina.realm.RealmBase %CMD_LINE_ARGS% + +:end diff --git a/bin/digest.sh b/bin/digest.sh old mode 100644 new mode 100755 diff --git a/bin/setclasspath.bat b/bin/setclasspath.bat old mode 100644 new mode 100755 index 366912b..e29b41a --- a/bin/setclasspath.bat +++ b/bin/setclasspath.bat @@ -1,88 +1,88 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -rem --------------------------------------------------------------------------- -rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings -rem are valid and consistent with the selected start-up options and set up the -rem endorsed directory. -rem -rem $Id: setclasspath.bat 1202062 2011-11-15 06:50:02Z mturk $ -rem --------------------------------------------------------------------------- - -rem Make sure prerequisite environment variables are set - -rem In debug mode we need a real JDK (JAVA_HOME) -if ""%1"" == ""debug"" goto needJavaHome - -rem Otherwise either JRE or JDK are fine -if not "%JRE_HOME%" == "" goto gotJreHome -if not "%JAVA_HOME%" == "" goto gotJavaHome -echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined -echo At least one of these environment variable is needed to run this program -goto exit - -:needJavaHome -rem Check if we have a usable JDK -if "%JAVA_HOME%" == "" goto noJavaHome -if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome -if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome -if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome -if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome -set "JRE_HOME=%JAVA_HOME%" -goto okJava - -:noJavaHome -echo The JAVA_HOME environment variable is not defined correctly. -echo It is needed to run this program in debug mode. -echo NB: JAVA_HOME should point to a JDK not a JRE. -goto exit - -:gotJavaHome -rem No JRE given, use JAVA_HOME as JRE_HOME -set "JRE_HOME=%JAVA_HOME%" - -:gotJreHome -rem Check if we have a usable JRE -if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome -if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome -goto okJava - -:noJreHome -rem Needed at least a JRE -echo The JRE_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto exit - -:okJava -rem Don't override the endorsed dir if the user has set it previously -if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir -rem Set the default -Djava.endorsed.dirs argument -set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed" -:gotEndorseddir - -rem Set standard command for invoking Java. -rem Note that NT requires a window name argument when using start. -rem Also note the quoting as JAVA_HOME may contain spaces. -set _RUNJAVA="%JRE_HOME%\bin\java" -set _RUNJDB="%JAVA_HOME%\bin\jdb" - -goto end - -:exit -exit /b 1 - -:end -exit /b 0 +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +rem --------------------------------------------------------------------------- +rem Set JAVA_HOME or JRE_HOME if not already set, ensure any provided settings +rem are valid and consistent with the selected start-up options and set up the +rem endorsed directory. +rem +rem $Id: setclasspath.bat 1202062 2011-11-15 06:50:02Z mturk $ +rem --------------------------------------------------------------------------- + +rem Make sure prerequisite environment variables are set + +rem In debug mode we need a real JDK (JAVA_HOME) +if ""%1"" == ""debug"" goto needJavaHome + +rem Otherwise either JRE or JDK are fine +if not "%JRE_HOME%" == "" goto gotJreHome +if not "%JAVA_HOME%" == "" goto gotJavaHome +echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined +echo At least one of these environment variable is needed to run this program +goto exit + +:needJavaHome +rem Check if we have a usable JDK +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +if not exist "%JAVA_HOME%\bin\javaw.exe" goto noJavaHome +if not exist "%JAVA_HOME%\bin\jdb.exe" goto noJavaHome +if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome +set "JRE_HOME=%JAVA_HOME%" +goto okJava + +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly. +echo It is needed to run this program in debug mode. +echo NB: JAVA_HOME should point to a JDK not a JRE. +goto exit + +:gotJavaHome +rem No JRE given, use JAVA_HOME as JRE_HOME +set "JRE_HOME=%JAVA_HOME%" + +:gotJreHome +rem Check if we have a usable JRE +if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome +if not exist "%JRE_HOME%\bin\javaw.exe" goto noJreHome +goto okJava + +:noJreHome +rem Needed at least a JRE +echo The JRE_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto exit + +:okJava +rem Don't override the endorsed dir if the user has set it previously +if not "%JAVA_ENDORSED_DIRS%" == "" goto gotEndorseddir +rem Set the default -Djava.endorsed.dirs argument +set "JAVA_ENDORSED_DIRS=%CATALINA_HOME%\endorsed" +:gotEndorseddir + +rem Set standard command for invoking Java. +rem Note that NT requires a window name argument when using start. +rem Also note the quoting as JAVA_HOME may contain spaces. +set _RUNJAVA="%JRE_HOME%\bin\java" +set _RUNJDB="%JAVA_HOME%\bin\jdb" + +goto end + +:exit +exit /b 1 + +:end +exit /b 0 diff --git a/bin/setclasspath.sh b/bin/setclasspath.sh old mode 100644 new mode 100755 diff --git a/bin/setenv.bat b/bin/setenv.bat old mode 100644 new mode 100755 diff --git a/bin/setenv.sh b/bin/setenv.sh old mode 100644 new mode 100755 index 425abf4..7845878 --- a/bin/setenv.sh +++ b/bin/setenv.sh @@ -1,4 +1,5 @@ #!/bin/sh export JAVA_HOME=/usr/caimito/jdk +#export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0 export JRE_HOME=$JAVA_HOME export PATH=$JAVA_HOME/bin:$PATH diff --git a/bin/shutdown.bat b/bin/shutdown.bat old mode 100644 new mode 100755 index 9c652a5..0f30951 --- a/bin/shutdown.bat +++ b/bin/shutdown.bat @@ -1,59 +1,59 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Stop script for the CATALINA Server -rem -rem $Id: shutdown.bat 895392 2010-01-03 14:02:31Z kkolinko $ -rem --------------------------------------------------------------------------- - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" stop %CMD_LINE_ARGS% - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Stop script for the CATALINA Server +rem +rem $Id: shutdown.bat 895392 2010-01-03 14:02:31Z kkolinko $ +rem --------------------------------------------------------------------------- + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" + +rem Check that target executable exists +if exist "%EXECUTABLE%" goto okExec +echo Cannot find "%EXECUTABLE%" +echo This file is needed to run this program +goto end +:okExec + +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +call "%EXECUTABLE%" stop %CMD_LINE_ARGS% + +:end diff --git a/bin/shutdown.sh b/bin/shutdown.sh old mode 100644 new mode 100755 diff --git a/bin/startup.bat b/bin/startup.bat old mode 100644 new mode 100755 diff --git a/bin/startup.sh b/bin/startup.sh old mode 100644 new mode 100755 diff --git a/bin/tomcat-juli.jar b/bin/tomcat-juli.jar old mode 100644 new mode 100755 diff --git a/bin/tomcat-native.tar.gz b/bin/tomcat-native.tar.gz old mode 100644 new mode 100755 diff --git a/bin/tool-wrapper.bat b/bin/tool-wrapper.bat old mode 100644 new mode 100755 index 9eb3612..0d4dae6 --- a/bin/tool-wrapper.bat +++ b/bin/tool-wrapper.bat @@ -1,97 +1,97 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Wrapper script for command line tools -rem -rem Environment Variable Prerequisites -rem -rem CATALINA_HOME May point at your Catalina "build" directory. -rem -rem TOOL_OPTS (Optional) Java runtime options. -rem -rem JAVA_HOME Must point at your Java Development Kit installation. -rem Using JRE_HOME instead works as well. -rem -rem JRE_HOME Must point at your Java Runtime installation. -rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME -rem are both set, JRE_HOME is used. -rem -rem JAVA_OPTS (Optional) Java runtime options. -rem -rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories -rem containing some jars in order to allow replacement of APIs -rem created outside of the JCP (i.e. DOM and SAX from W3C). -rem It can also be used to update the XML parser implementation. -rem Defaults to $CATALINA_HOME/endorsed. -rem -rem $Id: tool-wrapper.bat 1138835 2011-06-23 11:27:57Z rjung $ -rem --------------------------------------------------------------------------- - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -rem Ensure that any user defined CLASSPATH variables are not used on startup, -rem but allow them to be specified in setenv.bat, in rare case when it is needed. -set CLASSPATH= - -rem Get standard environment variables -if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" - -rem Get standard Java environment variables -if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath -echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" -echo This file is needed to run this program -goto end -:okSetclasspath -call "%CATALINA_HOME%\bin\setclasspath.bat" %1 -if errorlevel 1 goto end - -rem Add on extra jar files to CLASSPATH -rem Note that there are no quotes as we do not want to introduce random -rem quotes into the CLASSPATH -if "%CLASSPATH%" == "" goto emptyClasspath -set "CLASSPATH=%CLASSPATH%;" -:emptyClasspath -set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar;%CATALINA_HOME%\lib\servlet-api.jar" - -set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -%_RUNJAVA% %JAVA_OPTS% %TOOL_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %CMD_LINE_ARGS% - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Wrapper script for command line tools +rem +rem Environment Variable Prerequisites +rem +rem CATALINA_HOME May point at your Catalina "build" directory. +rem +rem TOOL_OPTS (Optional) Java runtime options. +rem +rem JAVA_HOME Must point at your Java Development Kit installation. +rem Using JRE_HOME instead works as well. +rem +rem JRE_HOME Must point at your Java Runtime installation. +rem Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME +rem are both set, JRE_HOME is used. +rem +rem JAVA_OPTS (Optional) Java runtime options. +rem +rem JAVA_ENDORSED_DIRS (Optional) Lists of of semi-colon separated directories +rem containing some jars in order to allow replacement of APIs +rem created outside of the JCP (i.e. DOM and SAX from W3C). +rem It can also be used to update the XML parser implementation. +rem Defaults to $CATALINA_HOME/endorsed. +rem +rem $Id: tool-wrapper.bat 1138835 2011-06-23 11:27:57Z rjung $ +rem --------------------------------------------------------------------------- + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%CATALINA_HOME%\bin\tool-wrapper.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +rem Ensure that any user defined CLASSPATH variables are not used on startup, +rem but allow them to be specified in setenv.bat, in rare case when it is needed. +set CLASSPATH= + +rem Get standard environment variables +if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat" + +rem Get standard Java environment variables +if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath +echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" +echo This file is needed to run this program +goto end +:okSetclasspath +call "%CATALINA_HOME%\bin\setclasspath.bat" %1 +if errorlevel 1 goto end + +rem Add on extra jar files to CLASSPATH +rem Note that there are no quotes as we do not want to introduce random +rem quotes into the CLASSPATH +if "%CLASSPATH%" == "" goto emptyClasspath +set "CLASSPATH=%CLASSPATH%;" +:emptyClasspath +set "CLASSPATH=%CLASSPATH%%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_HOME%\bin\tomcat-juli.jar;%CATALINA_HOME%\lib\servlet-api.jar" + +set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager + +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +%_RUNJAVA% %JAVA_OPTS% %TOOL_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.home="%CATALINA_HOME%" org.apache.catalina.startup.Tool %CMD_LINE_ARGS% + +:end diff --git a/bin/tool-wrapper.sh b/bin/tool-wrapper.sh old mode 100644 new mode 100755 diff --git a/bin/version.bat b/bin/version.bat old mode 100644 new mode 100755 index efe2a2b..3a67165 --- a/bin/version.bat +++ b/bin/version.bat @@ -1,59 +1,59 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal -rem --------------------------------------------------------------------------- -rem Version script for the CATALINA Server -rem -rem $Id: version.bat 895392 2010-01-03 14:02:31Z kkolinko $ -rem --------------------------------------------------------------------------- - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" - -rem Check that target executable exists -if exist "%EXECUTABLE%" goto okExec -echo Cannot find "%EXECUTABLE%" -echo This file is needed to run this program -goto end -:okExec - -rem Get remaining unshifted command line arguments and save them in the -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs - -call "%EXECUTABLE%" version %CMD_LINE_ARGS% - -:end +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal +rem --------------------------------------------------------------------------- +rem Version script for the CATALINA Server +rem +rem $Id: version.bat 895392 2010-01-03 14:02:31Z kkolinko $ +rem --------------------------------------------------------------------------- + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" + +rem Check that target executable exists +if exist "%EXECUTABLE%" goto okExec +echo Cannot find "%EXECUTABLE%" +echo This file is needed to run this program +goto end +:okExec + +rem Get remaining unshifted command line arguments and save them in the +set CMD_LINE_ARGS= +:setArgs +if ""%1""=="""" goto doneSetArgs +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setArgs +:doneSetArgs + +call "%EXECUTABLE%" version %CMD_LINE_ARGS% + +:end diff --git a/bin/version.sh b/bin/version.sh old mode 100644 new mode 100755 diff --git a/conf/Catalina/localhost/ROOT.xml.sample b/conf/Catalina/localhost/ROOT.xml.sample old mode 100644 new mode 100755 diff --git a/conf/catalina.policy b/conf/catalina.policy old mode 100644 new mode 100755 index 3c7748e..7f23e25 --- a/conf/catalina.policy +++ b/conf/catalina.policy @@ -1,246 +1,246 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You 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. - -// ============================================================================ -// catalina.policy - Security Policy Permissions for Tomcat 7 -// -// This file contains a default set of security policies to be enforced (by the -// JVM) when Catalina is executed with the "-security" option. In addition -// to the permissions granted here, the following additional permissions are -// granted to each web application: -// -// * Read access to the web application's document root directory -// * Read, write and delete access to the web application's working directory -// -// $Id: catalina.policy 1220297 2011-12-17 22:55:28Z markt $ -// ============================================================================ - - -// ========== SYSTEM CODE PERMISSIONS ========================================= - - -// These permissions apply to javac -grant codeBase "file:${java.home}/lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions -grant codeBase "file:${java.home}/jre/lib/ext/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/../lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions when -// ${java.home} points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/lib/ext/-" { - permission java.security.AllPermission; -}; - - -// ========== CATALINA CODE PERMISSIONS ======================================= - - -// These permissions apply to the daemon code -grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the logging API -// Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, -// update this section accordingly. -// grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} -grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { - permission java.io.FilePermission - "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; - - permission java.io.FilePermission - "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs", "read, write"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs${file.separator}*", "read, write"; - - permission java.lang.RuntimePermission "shutdownHooks"; - permission java.lang.RuntimePermission "getClassLoader"; - permission java.lang.RuntimePermission "setContextClassLoader"; - - permission java.util.logging.LoggingPermission "control"; - - permission java.util.PropertyPermission "java.util.logging.config.class", "read"; - permission java.util.PropertyPermission "java.util.logging.config.file", "read"; - permission java.util.PropertyPermission "catalina.base", "read"; - permission java.util.PropertyPermission - "org.apache.juli.logging.UserDataHelper.CONFIG", "read"; - permission java.util.PropertyPermission - "org.apache.juli.logging.UserDataHelper.SUPPRESSION_TIME", "read"; - - // Note: To enable per context logging configuration, permit read access to - // the appropriate file. Be sure that the logging configuration is - // secure before enabling such access. - // E.g. for the examples web application (uncomment and unwrap - // the following to be on a single line): - // permission java.io.FilePermission "${catalina.base}${file.separator} - // webapps${file.separator}examples${file.separator}WEB-INF - // ${file.separator}classes${file.separator}logging.properties", "read"; -}; - -// These permissions apply to the server startup code -grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the servlet API classes -// and those that are shared across all class loaders -// located in the "lib" directory -grant codeBase "file:${catalina.home}/lib/-" { - permission java.security.AllPermission; -}; - - -// If using a per instance lib directory, i.e. ${catalina.base}/lib, -// then the following permission will need to be uncommented -// grant codeBase "file:${catalina.base}/lib/-" { -// permission java.security.AllPermission; -// }; - - -// ========== WEB APPLICATION PERMISSIONS ===================================== - - -// These permissions are granted by default to all web applications -// In addition, a web application will be given a read FilePermission -// and JndiPermission for all files and directories in its document root. -grant { - // Required for JNDI lookup of named JDBC DataSource's and - // javamail named MimePart DataSource used to send mail - permission java.util.PropertyPermission "java.home", "read"; - permission java.util.PropertyPermission "java.naming.*", "read"; - permission java.util.PropertyPermission "javax.sql.*", "read"; - - // OS Specific properties to allow read access - permission java.util.PropertyPermission "os.name", "read"; - permission java.util.PropertyPermission "os.version", "read"; - permission java.util.PropertyPermission "os.arch", "read"; - permission java.util.PropertyPermission "file.separator", "read"; - permission java.util.PropertyPermission "path.separator", "read"; - permission java.util.PropertyPermission "line.separator", "read"; - - // JVM properties to allow read access - permission java.util.PropertyPermission "java.version", "read"; - permission java.util.PropertyPermission "java.vendor", "read"; - permission java.util.PropertyPermission "java.vendor.url", "read"; - permission java.util.PropertyPermission "java.class.version", "read"; - permission java.util.PropertyPermission "java.specification.version", "read"; - permission java.util.PropertyPermission "java.specification.vendor", "read"; - permission java.util.PropertyPermission "java.specification.name", "read"; - - permission java.util.PropertyPermission "java.vm.specification.version", "read"; - permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; - permission java.util.PropertyPermission "java.vm.specification.name", "read"; - permission java.util.PropertyPermission "java.vm.version", "read"; - permission java.util.PropertyPermission "java.vm.vendor", "read"; - permission java.util.PropertyPermission "java.vm.name", "read"; - - // Required for OpenJMX - permission java.lang.RuntimePermission "getAttribute"; - - // Allow read of JAXP compliant XML parser debug - permission java.util.PropertyPermission "jaxp.debug", "read"; - - // All JSPs need to be able to read this package - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; - - // Precompiled JSPs need access to these packages. - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; - permission java.lang.RuntimePermission - "accessClassInPackage.org.apache.jasper.runtime.*"; - - // Precompiled JSPs need access to these system properties. - permission java.util.PropertyPermission - "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; - permission java.util.PropertyPermission - "org.apache.el.parser.COERCE_TO_ZERO", "read"; - - // The cookie code needs these. - permission java.util.PropertyPermission - "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; - permission java.util.PropertyPermission - "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; - permission java.util.PropertyPermission - "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; - - // Applications using Comet need to be able to access this package - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; -}; - - -// The Manager application needs access to the following packages to support the -// session display functionality. These settings support the following -// configurations: -// - default CATALINA_HOME == CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME -grant codeBase "file:${catalina.base}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; -}; -grant codeBase "file:${catalina.home}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; -}; - -// You can assign additional permissions to particular web applications by -// adding additional "grant" entries here, based on the code base for that -// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. -// -// Different permissions can be granted to JSP pages, classes loaded from -// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ -// directory, or even to individual jar files in the /WEB-INF/lib/ directory. -// -// For instance, assume that the standard "examples" application -// included a JDBC driver that needed to establish a network connection to the -// corresponding database and used the scrape taglib to get the weather from -// the NOAA web server. You might create a "grant" entries like this: -// -// The permissions granted to the context root directory apply to JSP pages. -// grant codeBase "file:${catalina.base}/webapps/examples/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; -// -// The permissions granted to the context WEB-INF/classes directory -// grant codeBase "file:${catalina.base}/webapps/examples/WEB-INF/classes/-" { -// }; -// -// The permission granted to your JDBC driver -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar!/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// }; -// The permission granted to the scrape taglib -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/scrape.jar!/-" { -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; - +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You 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. + +// ============================================================================ +// catalina.policy - Security Policy Permissions for Tomcat 7 +// +// This file contains a default set of security policies to be enforced (by the +// JVM) when Catalina is executed with the "-security" option. In addition +// to the permissions granted here, the following additional permissions are +// granted to each web application: +// +// * Read access to the web application's document root directory +// * Read, write and delete access to the web application's working directory +// +// $Id: catalina.policy 1220297 2011-12-17 22:55:28Z markt $ +// ============================================================================ + + +// ========== SYSTEM CODE PERMISSIONS ========================================= + + +// These permissions apply to javac +grant codeBase "file:${java.home}/lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions +grant codeBase "file:${java.home}/jre/lib/ext/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/../lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions when +// ${java.home} points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/lib/ext/-" { + permission java.security.AllPermission; +}; + + +// ========== CATALINA CODE PERMISSIONS ======================================= + + +// These permissions apply to the daemon code +grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { + permission java.security.AllPermission; +}; + +// These permissions apply to the logging API +// Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, +// update this section accordingly. +// grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} +grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { + permission java.io.FilePermission + "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; + + permission java.io.FilePermission + "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs", "read, write"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs${file.separator}*", "read, write"; + + permission java.lang.RuntimePermission "shutdownHooks"; + permission java.lang.RuntimePermission "getClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; + + permission java.util.logging.LoggingPermission "control"; + + permission java.util.PropertyPermission "java.util.logging.config.class", "read"; + permission java.util.PropertyPermission "java.util.logging.config.file", "read"; + permission java.util.PropertyPermission "catalina.base", "read"; + permission java.util.PropertyPermission + "org.apache.juli.logging.UserDataHelper.CONFIG", "read"; + permission java.util.PropertyPermission + "org.apache.juli.logging.UserDataHelper.SUPPRESSION_TIME", "read"; + + // Note: To enable per context logging configuration, permit read access to + // the appropriate file. Be sure that the logging configuration is + // secure before enabling such access. + // E.g. for the examples web application (uncomment and unwrap + // the following to be on a single line): + // permission java.io.FilePermission "${catalina.base}${file.separator} + // webapps${file.separator}examples${file.separator}WEB-INF + // ${file.separator}classes${file.separator}logging.properties", "read"; +}; + +// These permissions apply to the server startup code +grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { + permission java.security.AllPermission; +}; + +// These permissions apply to the servlet API classes +// and those that are shared across all class loaders +// located in the "lib" directory +grant codeBase "file:${catalina.home}/lib/-" { + permission java.security.AllPermission; +}; + + +// If using a per instance lib directory, i.e. ${catalina.base}/lib, +// then the following permission will need to be uncommented +// grant codeBase "file:${catalina.base}/lib/-" { +// permission java.security.AllPermission; +// }; + + +// ========== WEB APPLICATION PERMISSIONS ===================================== + + +// These permissions are granted by default to all web applications +// In addition, a web application will be given a read FilePermission +// and JndiPermission for all files and directories in its document root. +grant { + // Required for JNDI lookup of named JDBC DataSource's and + // javamail named MimePart DataSource used to send mail + permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.naming.*", "read"; + permission java.util.PropertyPermission "javax.sql.*", "read"; + + // OS Specific properties to allow read access + permission java.util.PropertyPermission "os.name", "read"; + permission java.util.PropertyPermission "os.version", "read"; + permission java.util.PropertyPermission "os.arch", "read"; + permission java.util.PropertyPermission "file.separator", "read"; + permission java.util.PropertyPermission "path.separator", "read"; + permission java.util.PropertyPermission "line.separator", "read"; + + // JVM properties to allow read access + permission java.util.PropertyPermission "java.version", "read"; + permission java.util.PropertyPermission "java.vendor", "read"; + permission java.util.PropertyPermission "java.vendor.url", "read"; + permission java.util.PropertyPermission "java.class.version", "read"; + permission java.util.PropertyPermission "java.specification.version", "read"; + permission java.util.PropertyPermission "java.specification.vendor", "read"; + permission java.util.PropertyPermission "java.specification.name", "read"; + + permission java.util.PropertyPermission "java.vm.specification.version", "read"; + permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; + permission java.util.PropertyPermission "java.vm.specification.name", "read"; + permission java.util.PropertyPermission "java.vm.version", "read"; + permission java.util.PropertyPermission "java.vm.vendor", "read"; + permission java.util.PropertyPermission "java.vm.name", "read"; + + // Required for OpenJMX + permission java.lang.RuntimePermission "getAttribute"; + + // Allow read of JAXP compliant XML parser debug + permission java.util.PropertyPermission "jaxp.debug", "read"; + + // All JSPs need to be able to read this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; + + // Precompiled JSPs need access to these packages. + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; + permission java.lang.RuntimePermission + "accessClassInPackage.org.apache.jasper.runtime.*"; + + // Precompiled JSPs need access to these system properties. + permission java.util.PropertyPermission + "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; + permission java.util.PropertyPermission + "org.apache.el.parser.COERCE_TO_ZERO", "read"; + + // The cookie code needs these. + permission java.util.PropertyPermission + "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; + + // Applications using Comet need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; +}; + + +// The Manager application needs access to the following packages to support the +// session display functionality. These settings support the following +// configurations: +// - default CATALINA_HOME == CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME +grant codeBase "file:${catalina.base}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; +grant codeBase "file:${catalina.home}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; + +// You can assign additional permissions to particular web applications by +// adding additional "grant" entries here, based on the code base for that +// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. +// +// Different permissions can be granted to JSP pages, classes loaded from +// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ +// directory, or even to individual jar files in the /WEB-INF/lib/ directory. +// +// For instance, assume that the standard "examples" application +// included a JDBC driver that needed to establish a network connection to the +// corresponding database and used the scrape taglib to get the weather from +// the NOAA web server. You might create a "grant" entries like this: +// +// The permissions granted to the context root directory apply to JSP pages. +// grant codeBase "file:${catalina.base}/webapps/examples/-" { +// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; +// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; +// }; +// +// The permissions granted to the context WEB-INF/classes directory +// grant codeBase "file:${catalina.base}/webapps/examples/WEB-INF/classes/-" { +// }; +// +// The permission granted to your JDBC driver +// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar!/-" { +// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; +// }; +// The permission granted to the scrape taglib +// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/scrape.jar!/-" { +// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; +// }; + diff --git a/conf/catalina.properties b/conf/catalina.properties old mode 100644 new mode 100755 index 652a57c..724a4da --- a/conf/catalina.properties +++ b/conf/catalina.properties @@ -1,119 +1,119 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, no packages are restricted for definition, and none of -# the class loaders supplied with the JDK call checkPackageDefinition. -# -package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. - -# -# -# List of comma-separated paths defining the contents of the "common" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank,the JVM system loader will be used as Catalina's "common" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar - -# -# List of comma-separated paths defining the contents of the "server" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank, the "common" loader will be used as Catalina's "server" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -server.loader= - -# -# List of comma-separated paths defining the contents of the "shared" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, -# the "common" loader will be used as Catalina's "shared" loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -# Please note that for single jars, e.g. bar.jar, you need the URL form -# starting with file:. -shared.loader= - -# List of JAR files that should not be scanned for configuration information -# such as web fragments, TLD files etc. It must be a comma separated list of -# JAR file names. -# The JARs listed below include: -# - Tomcat Bootstrap JARs -# - Tomcat API JARs -# - Catalina JARs -# - Jasper JARs -# - Tomcat JARs -# - Common non-Tomcat JARs -# - Sun JDK JARs -# - Apple JDK JARs -tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ -bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ -annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\ -catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\ -jasper.jar,jasper-el.jar,ecj-*.jar,\ -tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\ -tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ -tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\ -tomcat-jdbc.jar,\ -commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\ -commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\ -commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\ -commons-math*.jar,commons-pool*.jar,\ -jstl.jar,\ -geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\ -ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\ -jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\ -xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ -dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunmscapi.jar,\ -sunpkcs11.jar,jhall.jar,tools.jar,\ -sunec.jar,zipfs.jar,\ -apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\ -j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\ -mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar,\ -junit.jar,junit-*.jar,ant-launcher.jar - -# -# String cache configuration. -tomcat.util.buf.StringCache.byte.enabled=true -#tomcat.util.buf.StringCache.char.enabled=true -#tomcat.util.buf.StringCache.trainThreshold=500000 -#tomcat.util.buf.StringCache.cacheSize=5000 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageAccess unless the +# corresponding RuntimePermission ("accessClassInPackage."+package) has +# been granted. +package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageDefinition unless the +# corresponding RuntimePermission ("defineClassInPackage."+package) has +# been granted. +# +# by default, no packages are restricted for definition, and none of +# the class loaders supplied with the JDK call checkPackageDefinition. +# +package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. + +# +# +# List of comma-separated paths defining the contents of the "common" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank,the JVM system loader will be used as Catalina's "common" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar + +# +# List of comma-separated paths defining the contents of the "server" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank, the "common" loader will be used as Catalina's "server" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +server.loader= + +# +# List of comma-separated paths defining the contents of the "shared" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, +# the "common" loader will be used as Catalina's "shared" loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# Please note that for single jars, e.g. bar.jar, you need the URL form +# starting with file:. +shared.loader= + +# List of JAR files that should not be scanned for configuration information +# such as web fragments, TLD files etc. It must be a comma separated list of +# JAR file names. +# The JARs listed below include: +# - Tomcat Bootstrap JARs +# - Tomcat API JARs +# - Catalina JARs +# - Jasper JARs +# - Tomcat JARs +# - Common non-Tomcat JARs +# - Sun JDK JARs +# - Apple JDK JARs +tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ +bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ +annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\ +catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\ +jasper.jar,jasper-el.jar,ecj-*.jar,\ +tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\ +tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ +tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\ +tomcat-jdbc.jar,\ +commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\ +commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\ +commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\ +commons-math*.jar,commons-pool*.jar,\ +jstl.jar,\ +geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\ +ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\ +jmx-tools.jar,jta*.jar,log4j*.jar,mail*.jar,slf4j*.jar,\ +xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ +dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunmscapi.jar,\ +sunpkcs11.jar,jhall.jar,tools.jar,\ +sunec.jar,zipfs.jar,\ +apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\ +j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\ +mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar,\ +junit.jar,junit-*.jar,ant-launcher.jar + +# +# String cache configuration. +tomcat.util.buf.StringCache.byte.enabled=true +#tomcat.util.buf.StringCache.char.enabled=true +#tomcat.util.buf.StringCache.trainThreshold=500000 +#tomcat.util.buf.StringCache.cacheSize=5000 diff --git a/conf/context.xml b/conf/context.xml old mode 100644 new mode 100755 index 745bf95..e313459 --- a/conf/context.xml +++ b/conf/context.xml @@ -1,35 +1,35 @@ - - - - - - - WEB-INF/web.xml - - - - - - - + + + + + + + WEB-INF/web.xml + + + + + + + \ No newline at end of file diff --git a/conf/logging.properties b/conf/logging.properties old mode 100644 new mode 100755 index 76c9512..90d7ea7 --- a/conf/logging.properties +++ b/conf/logging.properties @@ -1,64 +1,64 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler - -.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ - -1catalina.org.apache.juli.FileHandler.level = FINE -1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -1catalina.org.apache.juli.FileHandler.prefix = catalina. - -2localhost.org.apache.juli.FileHandler.level = FINE -2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -2localhost.org.apache.juli.FileHandler.prefix = localhost. - -3manager.org.apache.juli.FileHandler.level = FINE -3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -3manager.org.apache.juli.FileHandler.prefix = manager. - -4host-manager.org.apache.juli.FileHandler.level = FINE -4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs -4host-manager.org.apache.juli.FileHandler.prefix = host-manager. - -java.util.logging.ConsoleHandler.level = FINE -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - - -############################################################ -# Facility specific properties. -# Provides extra control for each logger. -############################################################ - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler - -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO -org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler - -# For example, set the org.apache.catalina.util.LifecycleBase logger to log -# each component that extends LifecycleBase changing state: -#org.apache.catalina.util.LifecycleBase.level = FINE - -# To see debug messages in TldLocationsCache, uncomment the following line: -#org.apache.jasper.compiler.TldLocationsCache.level = FINE +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +1catalina.org.apache.juli.FileHandler.level = FINE +1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +1catalina.org.apache.juli.FileHandler.prefix = catalina. + +2localhost.org.apache.juli.FileHandler.level = FINE +2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +2localhost.org.apache.juli.FileHandler.prefix = localhost. + +3manager.org.apache.juli.FileHandler.level = FINE +3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +3manager.org.apache.juli.FileHandler.prefix = manager. + +4host-manager.org.apache.juli.FileHandler.level = FINE +4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs +4host-manager.org.apache.juli.FileHandler.prefix = host-manager. + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler + +# For example, set the org.apache.catalina.util.LifecycleBase logger to log +# each component that extends LifecycleBase changing state: +#org.apache.catalina.util.LifecycleBase.level = FINE + +# To see debug messages in TldLocationsCache, uncomment the following line: +#org.apache.jasper.compiler.TldLocationsCache.level = FINE diff --git a/conf/server.xml b/conf/server.xml old mode 100644 new mode 100755 index b8a10f9..2a11ded --- a/conf/server.xml +++ b/conf/server.xml @@ -1,142 +1,142 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/conf/tomcat-users.xml b/conf/tomcat-users.xml old mode 100644 new mode 100755 index 7f022ff..34e268d --- a/conf/tomcat-users.xml +++ b/conf/tomcat-users.xml @@ -1,36 +1,36 @@ - - - - - - - + + + + + + + diff --git a/conf/web.xml b/conf/web.xml old mode 100644 new mode 100755 index cc8383c..762c168 --- a/conf/web.xml +++ b/conf/web.xml @@ -1,4283 +1,4283 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default - org.apache.catalina.servlets.DefaultServlet - - debug - 0 - - - listings - false - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jsp - org.apache.jasper.servlet.JspServlet - - fork - false - - - xpoweredBy - false - - 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default - / - - - - - jsp - *.jsp - *.jspx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30 - - - - - - - - - - - - 123 - application/vnd.lotus-1-2-3 - - - 3dml - text/vnd.in3d.3dml - - - 3g2 - video/3gpp2 - - - 3gp - video/3gpp - - - 7z - application/x-7z-compressed - - - aab - application/x-authorware-bin - - - aac - audio/x-aac - - - aam - application/x-authorware-map - - - aas - application/x-authorware-seg - - - abs - audio/x-mpeg - - - abw - application/x-abiword - - - ac - application/pkix-attr-cert - - - acc - application/vnd.americandynamics.acc - - - ace - application/x-ace-compressed - - - acu - application/vnd.acucobol - - - acutc - application/vnd.acucorp - - - adp - audio/adpcm - - - aep - application/vnd.audiograph - - - afm - application/x-font-type1 - - - afp - application/vnd.ibm.modcap - - - ahead - application/vnd.ahead.space - - - ai - application/postscript - - - aif - audio/x-aiff - - - aifc - audio/x-aiff - - - aiff - audio/x-aiff - - - aim - application/x-aim - - - air - application/vnd.adobe.air-application-installer-package+zip - - - ait - application/vnd.dvb.ait - - - ami - application/vnd.amiga.ami - - - anx - application/annodex - - - apk - application/vnd.android.package-archive - - - application - application/x-ms-application - - - apr - application/vnd.lotus-approach - - - art - image/x-jg - - - asc - application/pgp-signature - - - asf - video/x-ms-asf - - - asm - text/x-asm - - - aso - application/vnd.accpac.simply.aso - - - asx - video/x-ms-asf - - - atc - application/vnd.acucorp - - - atom - application/atom+xml - - - atomcat - application/atomcat+xml - - - atomsvc - application/atomsvc+xml - - - atx - application/vnd.antix.game-component - - - au - audio/basic - - - avi - video/x-msvideo - - - avx - video/x-rad-screenplay - - - aw - application/applixware - - - axa - audio/annodex - - - axv - video/annodex - - - azf - application/vnd.airzip.filesecure.azf - - - azs - application/vnd.airzip.filesecure.azs - - - azw - application/vnd.amazon.ebook - - - bat - application/x-msdownload - - - bcpio - application/x-bcpio - - - bdf - application/x-font-bdf - - - bdm - application/vnd.syncml.dm+wbxml - - - bed - application/vnd.realvnc.bed - - - bh2 - application/vnd.fujitsu.oasysprs - - - bin - application/octet-stream - - - bmi - application/vnd.bmi - - - bmp - image/bmp - - - body - text/html - - - book - application/vnd.framemaker - - - box - application/vnd.previewsystems.box - - - boz - application/x-bzip2 - - - bpk - application/octet-stream - - - btif - image/prs.btif - - - bz - application/x-bzip - - - bz2 - application/x-bzip2 - - - c - text/x-c - - - c11amc - application/vnd.cluetrust.cartomobile-config - - - c11amz - application/vnd.cluetrust.cartomobile-config-pkg - - - c4d - application/vnd.clonk.c4group - - - c4f - application/vnd.clonk.c4group - - - c4g - application/vnd.clonk.c4group - - - c4p - application/vnd.clonk.c4group - - - c4u - application/vnd.clonk.c4group - - - cab - application/vnd.ms-cab-compressed - - - cap - application/vnd.tcpdump.pcap - - - car - application/vnd.curl.car - - - cat - application/vnd.ms-pki.seccat - - - cc - text/x-c - - - cct - application/x-director - - - ccxml - application/ccxml+xml - - - cdbcmsg - application/vnd.contact.cmsg - - - cdf - application/x-cdf - - - cdkey - application/vnd.mediastation.cdkey - - - cdmia - application/cdmi-capability - - - cdmic - application/cdmi-container - - - cdmid - application/cdmi-domain - - - cdmio - application/cdmi-object - - - cdmiq - application/cdmi-queue - - - cdx - chemical/x-cdx - - - cdxml - application/vnd.chemdraw+xml - - - cdy - application/vnd.cinderella - - - cer - application/pkix-cert - - - cgm - image/cgm - - - chat - application/x-chat - - - chm - application/vnd.ms-htmlhelp - - - chrt - application/vnd.kde.kchart - - - cif - chemical/x-cif - - - cii - application/vnd.anser-web-certificate-issue-initiation - - - cil - application/vnd.ms-artgalry - - - cla - application/vnd.claymore - - - class - application/java - - - clkk - application/vnd.crick.clicker.keyboard - - - clkp - application/vnd.crick.clicker.palette - - - clkt - application/vnd.crick.clicker.template - - - clkw - application/vnd.crick.clicker.wordbank - - - clkx - application/vnd.crick.clicker - - - clp - application/x-msclip - - - cmc - application/vnd.cosmocaller - - - cmdf - chemical/x-cmdf - - - cml - chemical/x-cml - - - cmp - application/vnd.yellowriver-custom-menu - - - cmx - image/x-cmx - - - cod - application/vnd.rim.cod - - - com - application/x-msdownload - - - conf - text/plain - - - cpio - application/x-cpio - - - cpp - text/x-c - - - cpt - application/mac-compactpro - - - crd - application/x-mscardfile - - - crl - application/pkix-crl - - - crt - application/x-x509-ca-cert - - - cryptonote - application/vnd.rig.cryptonote - - - csh - application/x-csh - - - csml - chemical/x-csml - - - csp - application/vnd.commonspace - - - css - text/css - - - cst - application/x-director - - - csv - text/csv - - - cu - application/cu-seeme - - - curl - text/vnd.curl - - - cww - application/prs.cww - - - cxt - application/x-director - - - cxx - text/x-c - - - dae - model/vnd.collada+xml - - - daf - application/vnd.mobius.daf - - - dataless - application/vnd.fdsn.seed - - - davmount - application/davmount+xml - - - dcr - application/x-director - - - dcurl - text/vnd.curl.dcurl - - - dd2 - application/vnd.oma.dd2+xml - - - ddd - application/vnd.fujixerox.ddd - - - deb - application/x-debian-package - - - def - text/plain - - - deploy - application/octet-stream - - - der - application/x-x509-ca-cert - - - dfac - application/vnd.dreamfactory - - - dib - image/bmp - - - dic - text/x-c - - - dir - application/x-director - - - dis - application/vnd.mobius.dis - - - dist - application/octet-stream - - - distz - application/octet-stream - - - djv - image/vnd.djvu - - - djvu - image/vnd.djvu - - - dll - application/x-msdownload - - - dmg - application/octet-stream - - - dmp - application/vnd.tcpdump.pcap - - - dms - application/octet-stream - - - dna - application/vnd.dna - - - doc - application/msword - - - docm - application/vnd.ms-word.document.macroenabled.12 - - - docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document - - - dot - application/msword - - - dotm - application/vnd.ms-word.template.macroenabled.12 - - - dotx - application/vnd.openxmlformats-officedocument.wordprocessingml.template - - - dp - application/vnd.osgi.dp - - - dpg - application/vnd.dpgraph - - - dra - audio/vnd.dra - - - dsc - text/prs.lines.tag - - - dssc - application/dssc+der - - - dtb - application/x-dtbook+xml - - - dtd - application/xml-dtd - - - dts - audio/vnd.dts - - - dtshd - audio/vnd.dts.hd - - - dump - application/octet-stream - - - dv - video/x-dv - - - dvb - video/vnd.dvb.file - - - dvi - application/x-dvi - - - dwf - model/vnd.dwf - - - dwg - image/vnd.dwg - - - dxf - image/vnd.dxf - - - dxp - application/vnd.spotfire.dxp - - - dxr - application/x-director - - - ecelp4800 - audio/vnd.nuera.ecelp4800 - - - ecelp7470 - audio/vnd.nuera.ecelp7470 - - - ecelp9600 - audio/vnd.nuera.ecelp9600 - - - ecma - application/ecmascript - - - edm - application/vnd.novadigm.edm - - - edx - application/vnd.novadigm.edx - - - efif - application/vnd.picsel - - - ei6 - application/vnd.pg.osasli - - - elc - application/octet-stream - - - eml - message/rfc822 - - - emma - application/emma+xml - - - eol - audio/vnd.digital-winds - - - eot - application/vnd.ms-fontobject - - - eps - application/postscript - - - epub - application/epub+zip - - - es3 - application/vnd.eszigno3+xml - - - esf - application/vnd.epson.esf - - - et3 - application/vnd.eszigno3+xml - - - etx - text/x-setext - - - exe - application/octet-stream - - - exi - application/exi - - - ext - application/vnd.novadigm.ext - - - ez - application/andrew-inset - - - ez2 - application/vnd.ezpix-album - - - ez3 - application/vnd.ezpix-package - - - f - text/x-fortran - - - f4v - video/x-f4v - - - f77 - text/x-fortran - - - f90 - text/x-fortran - - - fbs - image/vnd.fastbidsheet - - - fcs - application/vnd.isac.fcs - - - fdf - application/vnd.fdf - - - fe_launch - application/vnd.denovo.fcselayout-link - - - fg5 - application/vnd.fujitsu.oasysgp - - - fgd - application/x-director - - - fh - image/x-freehand - - - fh4 - image/x-freehand - - - fh5 - image/x-freehand - - - fh7 - image/x-freehand - - - fhc - image/x-freehand - - - fig - application/x-xfig - - - flac - audio/flac - - - fli - video/x-fli - - - flo - application/vnd.micrografx.flo - - - flv - video/x-flv - - - flw - application/vnd.kde.kivio - - - flx - text/vnd.fmi.flexstor - - - fly - text/vnd.fly - - - fm - application/vnd.framemaker - - - fnc - application/vnd.frogans.fnc - - - for - text/x-fortran - - - fpx - image/vnd.fpx - - - frame - application/vnd.framemaker - - - fsc - application/vnd.fsc.weblaunch - - - fst - image/vnd.fst - - - ftc - application/vnd.fluxtime.clip - - - fti - application/vnd.anser-web-funds-transfer-initiation - - - fvt - video/vnd.fvt - - - fxp - application/vnd.adobe.fxp - - - fxpl - application/vnd.adobe.fxp - - - fzs - application/vnd.fuzzysheet - - - g2w - application/vnd.geoplan - - - g3 - image/g3fax - - - g3w - application/vnd.geospace - - - gac - application/vnd.groove-account - - - gbr - application/rpki-ghostbusters - - - gdl - model/vnd.gdl - - - geo - application/vnd.dynageo - - - gex - application/vnd.geometry-explorer - - - ggb - application/vnd.geogebra.file - - - ggt - application/vnd.geogebra.tool - - - ghf - application/vnd.groove-help - - - gif - image/gif - - - gim - application/vnd.groove-identity-message - - - gmx - application/vnd.gmx - - - gnumeric - application/x-gnumeric - - - gph - application/vnd.flographit - - - gqf - application/vnd.grafeq - - - gqs - application/vnd.grafeq - - - gram - application/srgs - - - gre - application/vnd.geometry-explorer - - - grv - application/vnd.groove-injector - - - grxml - application/srgs+xml - - - gsf - application/x-font-ghostscript - - - gtar - application/x-gtar - - - gtm - application/vnd.groove-tool-message - - - gtw - model/vnd.gtw - - - gv - text/vnd.graphviz - - - gxt - application/vnd.geonext - - - gz - application/x-gzip - - - h - text/x-c - - - h261 - video/h261 - - - h263 - video/h263 - - - h264 - video/h264 - - - hal - application/vnd.hal+xml - - - hbci - application/vnd.hbci - - - hdf - application/x-hdf - - - hh - text/x-c - - - hlp - application/winhlp - - - hpgl - application/vnd.hp-hpgl - - - hpid - application/vnd.hp-hpid - - - hps - application/vnd.hp-hps - - - hqx - application/mac-binhex40 - - - htc - text/x-component - - - htke - application/vnd.kenameaapp - - - htm - text/html - - - html - text/html - - - hvd - application/vnd.yamaha.hv-dic - - - hvp - application/vnd.yamaha.hv-voice - - - hvs - application/vnd.yamaha.hv-script - - - i2g - application/vnd.intergeo - - - icc - application/vnd.iccprofile - - - ice - x-conference/x-cooltalk - - - icm - application/vnd.iccprofile - - - ico - image/x-icon - - - ics - text/calendar - - - ief - image/ief - - - ifb - text/calendar - - - ifm - application/vnd.shana.informed.formdata - - - iges - model/iges - - - igl - application/vnd.igloader - - - igm - application/vnd.insors.igm - - - igs - model/iges - - - igx - application/vnd.micrografx.igx - - - iif - application/vnd.shana.informed.interchange - - - imp - application/vnd.accpac.simply.imp - - - ims - application/vnd.ms-ims - - - in - text/plain - - - ink - application/inkml+xml - - - inkml - application/inkml+xml - - - iota - application/vnd.astraea-software.iota - - - ipfix - application/ipfix - - - ipk - application/vnd.shana.informed.package - - - irm - application/vnd.ibm.rights-management - - - irp - application/vnd.irepository.package+xml - - - iso - application/octet-stream - - - itp - application/vnd.shana.informed.formtemplate - - - ivp - application/vnd.immervision-ivp - - - ivu - application/vnd.immervision-ivu - - - jad - text/vnd.sun.j2me.app-descriptor - - - jam - application/vnd.jam - - - jar - application/java-archive - - - java - text/x-java-source - - - jisp - application/vnd.jisp - - - jlt - application/vnd.hp-jlyt - - - jnlp - application/x-java-jnlp-file - - - joda - application/vnd.joost.joda-archive - - - jpe - image/jpeg - - - jpeg - image/jpeg - - - jpg - image/jpeg - - - jpgm - video/jpm - - - jpgv - video/jpeg - - - jpm - video/jpm - - - js - application/javascript - - - jsf - text/plain - - - json - application/json - - - jspf - text/plain - - - kar - audio/midi - - - karbon - application/vnd.kde.karbon - - - kfo - application/vnd.kde.kformula - - - kia - application/vnd.kidspiration - - - kml - application/vnd.google-earth.kml+xml - - - kmz - application/vnd.google-earth.kmz - - - kne - application/vnd.kinar - - - knp - application/vnd.kinar - - - kon - application/vnd.kde.kontour - - - kpr - application/vnd.kde.kpresenter - - - kpt - application/vnd.kde.kpresenter - - - ksp - application/vnd.kde.kspread - - - ktr - application/vnd.kahootz - - - ktx - image/ktx - - - ktz - application/vnd.kahootz - - - kwd - application/vnd.kde.kword - - - kwt - application/vnd.kde.kword - - - lasxml - application/vnd.las.las+xml - - - latex - application/x-latex - - - lbd - application/vnd.llamagraphics.life-balance.desktop - - - lbe - application/vnd.llamagraphics.life-balance.exchange+xml - - - les - application/vnd.hhe.lesson-player - - - lha - application/octet-stream - - - link66 - application/vnd.route66.link66+xml - - - list - text/plain - - - list3820 - application/vnd.ibm.modcap - - - listafp - application/vnd.ibm.modcap - - - log - text/plain - - - lostxml - application/lost+xml - - - lrf - application/octet-stream - - - lrm - application/vnd.ms-lrm - - - ltf - application/vnd.frogans.ltf - - - lvp - audio/vnd.lucent.voice - - - lwp - application/vnd.lotus-wordpro - - - lzh - application/octet-stream - - - m13 - application/x-msmediaview - - - m14 - application/x-msmediaview - - - m1v - video/mpeg - - - m21 - application/mp21 - - - m2a - audio/mpeg - - - m2v - video/mpeg - - - m3a - audio/mpeg - - - m3u - audio/x-mpegurl - - - m3u8 - application/vnd.apple.mpegurl - - - m4a - audio/mp4 - - - m4b - audio/mp4 - - - m4r - audio/mp4 - - - m4u - video/vnd.mpegurl - - - m4v - video/mp4 - - - ma - application/mathematica - - - mac - image/x-macpaint - - - mads - application/mads+xml - - - mag - application/vnd.ecowin.chart - - - maker - application/vnd.framemaker - - - man - text/troff - - - mathml - application/mathml+xml - - - mb - application/mathematica - - - mbk - application/vnd.mobius.mbk - - - mbox - application/mbox - - - mc1 - application/vnd.medcalcdata - - - mcd - application/vnd.mcd - - - mcurl - text/vnd.curl.mcurl - - - mdb - application/x-msaccess - - - mdi - image/vnd.ms-modi - - - me - text/troff - - - mesh - model/mesh - - - meta4 - application/metalink4+xml - - - mets - application/mets+xml - - - mfm - application/vnd.mfmp - - - mft - application/rpki-manifest - - - mgp - application/vnd.osgeo.mapguide.package - - - mgz - application/vnd.proteus.magazine - - - mid - audio/midi - - - midi - audio/midi - - - mif - application/x-mif - - - mime - message/rfc822 - - - mj2 - video/mj2 - - - mjp2 - video/mj2 - - - mlp - application/vnd.dolby.mlp - - - mmd - application/vnd.chipnuts.karaoke-mmd - - - mmf - application/vnd.smaf - - - mmr - image/vnd.fujixerox.edmics-mmr - - - mny - application/x-msmoney - - - mobi - application/x-mobipocket-ebook - - - mods - application/mods+xml - - - mov - video/quicktime - - - movie - video/x-sgi-movie - - - mp1 - audio/mpeg - - - mp2 - audio/mpeg - - - mp21 - application/mp21 - - - mp2a - audio/mpeg - - - mp3 - audio/mpeg - - - mp4 - video/mp4 - - - mp4a - audio/mp4 - - - mp4s - application/mp4 - - - mp4v - video/mp4 - - - mpa - audio/mpeg - - - mpc - application/vnd.mophun.certificate - - - mpe - video/mpeg - - - mpeg - video/mpeg - - - mpega - audio/x-mpeg - - - mpg - video/mpeg - - - mpg4 - video/mp4 - - - mpga - audio/mpeg - - - mpkg - application/vnd.apple.installer+xml - - - mpm - application/vnd.blueice.multipass - - - mpn - application/vnd.mophun.application - - - mpp - application/vnd.ms-project - - - mpt - application/vnd.ms-project - - - mpv2 - video/mpeg2 - - - mpy - application/vnd.ibm.minipay - - - mqy - application/vnd.mobius.mqy - - - mrc - application/marc - - - mrcx - application/marcxml+xml - - - ms - text/troff - - - mscml - application/mediaservercontrol+xml - - - mseed - application/vnd.fdsn.mseed - - - mseq - application/vnd.mseq - - - msf - application/vnd.epson.msf - - - msh - model/mesh - - - msi - application/x-msdownload - - - msl - application/vnd.mobius.msl - - - msty - application/vnd.muvee.style - - - mts - model/vnd.mts - - - mus - application/vnd.musician - - - musicxml - application/vnd.recordare.musicxml+xml - - - mvb - application/x-msmediaview - - - mwf - application/vnd.mfer - - - mxf - application/mxf - - - mxl - application/vnd.recordare.musicxml - - - mxml - application/xv+xml - - - mxs - application/vnd.triscape.mxs - - - mxu - video/vnd.mpegurl - - - n-gage - application/vnd.nokia.n-gage.symbian.install - - - n3 - text/n3 - - - nb - application/mathematica - - - nbp - application/vnd.wolfram.player - - - nc - application/x-netcdf - - - ncx - application/x-dtbncx+xml - - - ngdat - application/vnd.nokia.n-gage.data - - - nlu - application/vnd.neurolanguage.nlu - - - nml - application/vnd.enliven - - - nnd - application/vnd.noblenet-directory - - - nns - application/vnd.noblenet-sealer - - - nnw - application/vnd.noblenet-web - - - npx - image/vnd.net-fpx - - - nsf - application/vnd.lotus-notes - - - oa2 - application/vnd.fujitsu.oasys2 - - - oa3 - application/vnd.fujitsu.oasys3 - - - oas - application/vnd.fujitsu.oasys - - - obd - application/x-msbinder - - - oda - application/oda - - - - odb - application/vnd.oasis.opendocument.database - - - - odc - application/vnd.oasis.opendocument.chart - - - - odf - application/vnd.oasis.opendocument.formula - - - odft - application/vnd.oasis.opendocument.formula-template - - - - odg - application/vnd.oasis.opendocument.graphics - - - - odi - application/vnd.oasis.opendocument.image - - - - odm - application/vnd.oasis.opendocument.text-master - - - - odp - application/vnd.oasis.opendocument.presentation - - - - ods - application/vnd.oasis.opendocument.spreadsheet - - - - odt - application/vnd.oasis.opendocument.text - - - oga - audio/ogg - - - ogg - audio/ogg - - - ogv - video/ogg - - - - ogx - application/ogg - - - onepkg - application/onenote - - - onetmp - application/onenote - - - onetoc - application/onenote - - - onetoc2 - application/onenote - - - opf - application/oebps-package+xml - - - oprc - application/vnd.palm - - - org - application/vnd.lotus-organizer - - - osf - application/vnd.yamaha.openscoreformat - - - osfpvg - application/vnd.yamaha.openscoreformat.osfpvg+xml - - - otc - application/vnd.oasis.opendocument.chart-template - - - otf - application/x-font-otf - - - - otg - application/vnd.oasis.opendocument.graphics-template - - - - oth - application/vnd.oasis.opendocument.text-web - - - oti - application/vnd.oasis.opendocument.image-template - - - - otp - application/vnd.oasis.opendocument.presentation-template - - - - ots - application/vnd.oasis.opendocument.spreadsheet-template - - - - ott - application/vnd.oasis.opendocument.text-template - - - oxps - application/oxps - - - oxt - application/vnd.openofficeorg.extension - - - p - text/x-pascal - - - p10 - application/pkcs10 - - - p12 - application/x-pkcs12 - - - p7b - application/x-pkcs7-certificates - - - p7c - application/pkcs7-mime - - - p7m - application/pkcs7-mime - - - p7r - application/x-pkcs7-certreqresp - - - p7s - application/pkcs7-signature - - - p8 - application/pkcs8 - - - pas - text/x-pascal - - - paw - application/vnd.pawaafile - - - pbd - application/vnd.powerbuilder6 - - - pbm - image/x-portable-bitmap - - - pcap - application/vnd.tcpdump.pcap - - - pcf - application/x-font-pcf - - - pcl - application/vnd.hp-pcl - - - pclxl - application/vnd.hp-pclxl - - - pct - image/pict - - - pcurl - application/vnd.curl.pcurl - - - pcx - image/x-pcx - - - pdb - application/vnd.palm - - - pdf - application/pdf - - - pfa - application/x-font-type1 - - - pfb - application/x-font-type1 - - - pfm - application/x-font-type1 - - - pfr - application/font-tdpfr - - - pfx - application/x-pkcs12 - - - pgm - image/x-portable-graymap - - - pgn - application/x-chess-pgn - - - pgp - application/pgp-encrypted - - - pic - image/pict - - - pict - image/pict - - - pkg - application/octet-stream - - - pki - application/pkixcmp - - - pkipath - application/pkix-pkipath - - - plb - application/vnd.3gpp.pic-bw-large - - - plc - application/vnd.mobius.plc - - - plf - application/vnd.pocketlearn - - - pls - audio/x-scpls - - - pml - application/vnd.ctc-posml - - - png - image/png - - - pnm - image/x-portable-anymap - - - pnt - image/x-macpaint - - - portpkg - application/vnd.macports.portpkg - - - pot - application/vnd.ms-powerpoint - - - potm - application/vnd.ms-powerpoint.template.macroenabled.12 - - - potx - application/vnd.openxmlformats-officedocument.presentationml.template - - - ppam - application/vnd.ms-powerpoint.addin.macroenabled.12 - - - ppd - application/vnd.cups-ppd - - - ppm - image/x-portable-pixmap - - - pps - application/vnd.ms-powerpoint - - - ppsm - application/vnd.ms-powerpoint.slideshow.macroenabled.12 - - - ppsx - application/vnd.openxmlformats-officedocument.presentationml.slideshow - - - ppt - application/vnd.ms-powerpoint - - - pptm - application/vnd.ms-powerpoint.presentation.macroenabled.12 - - - pptx - application/vnd.openxmlformats-officedocument.presentationml.presentation - - - pqa - application/vnd.palm - - - prc - application/x-mobipocket-ebook - - - pre - application/vnd.lotus-freelance - - - prf - application/pics-rules - - - ps - application/postscript - - - psb - application/vnd.3gpp.pic-bw-small - - - psd - image/vnd.adobe.photoshop - - - psf - application/x-font-linux-psf - - - pskcxml - application/pskc+xml - - - ptid - application/vnd.pvi.ptid1 - - - pub - application/x-mspublisher - - - pvb - application/vnd.3gpp.pic-bw-var - - - pwn - application/vnd.3m.post-it-notes - - - pya - audio/vnd.ms-playready.media.pya - - - pyv - video/vnd.ms-playready.media.pyv - - - qam - application/vnd.epson.quickanime - - - qbo - application/vnd.intu.qbo - - - qfx - application/vnd.intu.qfx - - - qps - application/vnd.publishare-delta-tree - - - qt - video/quicktime - - - qti - image/x-quicktime - - - qtif - image/x-quicktime - - - qwd - application/vnd.quark.quarkxpress - - - qwt - application/vnd.quark.quarkxpress - - - qxb - application/vnd.quark.quarkxpress - - - qxd - application/vnd.quark.quarkxpress - - - qxl - application/vnd.quark.quarkxpress - - - qxt - application/vnd.quark.quarkxpress - - - ra - audio/x-pn-realaudio - - - ram - audio/x-pn-realaudio - - - rar - application/x-rar-compressed - - - ras - image/x-cmu-raster - - - rcprofile - application/vnd.ipunplugged.rcprofile - - - rdf - application/rdf+xml - - - rdz - application/vnd.data-vision.rdz - - - rep - application/vnd.businessobjects - - - res - application/x-dtbresource+xml - - - rgb - image/x-rgb - - - rif - application/reginfo+xml - - - rip - audio/vnd.rip - - - rl - application/resource-lists+xml - - - rlc - image/vnd.fujixerox.edmics-rlc - - - rld - application/resource-lists-diff+xml - - - rm - application/vnd.rn-realmedia - - - rmi - audio/midi - - - rmp - audio/x-pn-realaudio-plugin - - - rms - application/vnd.jcp.javame.midlet-rms - - - rnc - application/relax-ng-compact-syntax - - - roa - application/rpki-roa - - - roff - text/troff - - - rp9 - application/vnd.cloanto.rp9 - - - rpss - application/vnd.nokia.radio-presets - - - rpst - application/vnd.nokia.radio-preset - - - rq - application/sparql-query - - - rs - application/rls-services+xml - - - rsd - application/rsd+xml - - - rss - application/rss+xml - - - rtf - application/rtf - - - rtx - text/richtext - - - s - text/x-asm - - - saf - application/vnd.yamaha.smaf-audio - - - sbml - application/sbml+xml - - - sc - application/vnd.ibm.secure-container - - - scd - application/x-msschedule - - - scm - application/vnd.lotus-screencam - - - scq - application/scvp-cv-request - - - scs - application/scvp-cv-response - - - scurl - text/vnd.curl.scurl - - - sda - application/vnd.stardivision.draw - - - sdc - application/vnd.stardivision.calc - - - sdd - application/vnd.stardivision.impress - - - sdkd - application/vnd.solent.sdkm+xml - - - sdkm - application/vnd.solent.sdkm+xml - - - sdp - application/sdp - - - sdw - application/vnd.stardivision.writer - - - see - application/vnd.seemail - - - seed - application/vnd.fdsn.seed - - - sema - application/vnd.sema - - - semd - application/vnd.semd - - - semf - application/vnd.semf - - - ser - application/java-serialized-object - - - setpay - application/set-payment-initiation - - - setreg - application/set-registration-initiation - - - sfd-hdstx - application/vnd.hydrostatix.sof-data - - - sfs - application/vnd.spotfire.sfs - - - sgl - application/vnd.stardivision.writer-global - - - sgm - text/sgml - - - sgml - text/sgml - - - sh - application/x-sh - - - shar - application/x-shar - - - shf - application/shf+xml - - - - sig - application/pgp-signature - - - silo - model/mesh - - - sis - application/vnd.symbian.install - - - sisx - application/vnd.symbian.install - - - sit - application/x-stuffit - - - sitx - application/x-stuffitx - - - skd - application/vnd.koan - - - skm - application/vnd.koan - - - skp - application/vnd.koan - - - skt - application/vnd.koan - - - sldm - application/vnd.ms-powerpoint.slide.macroenabled.12 - - - sldx - application/vnd.openxmlformats-officedocument.presentationml.slide - - - slt - application/vnd.epson.salt - - - sm - application/vnd.stepmania.stepchart - - - smf - application/vnd.stardivision.math - - - smi - application/smil+xml - - - smil - application/smil+xml - - - smzip - application/vnd.stepmania.package - - - snd - audio/basic - - - snf - application/x-font-snf - - - so - application/octet-stream - - - spc - application/x-pkcs7-certificates - - - spf - application/vnd.yamaha.smaf-phrase - - - spl - application/x-futuresplash - - - spot - text/vnd.in3d.spot - - - spp - application/scvp-vp-response - - - spq - application/scvp-vp-request - - - spx - audio/ogg - - - src - application/x-wais-source - - - sru - application/sru+xml - - - srx - application/sparql-results+xml - - - sse - application/vnd.kodak-descriptor - - - ssf - application/vnd.epson.ssf - - - ssml - application/ssml+xml - - - st - application/vnd.sailingtracker.track - - - stc - application/vnd.sun.xml.calc.template - - - std - application/vnd.sun.xml.draw.template - - - stf - application/vnd.wt.stf - - - sti - application/vnd.sun.xml.impress.template - - - stk - application/hyperstudio - - - stl - application/vnd.ms-pki.stl - - - str - application/vnd.pg.format - - - stw - application/vnd.sun.xml.writer.template - - - sub - text/vnd.dvb.subtitle - - - sus - application/vnd.sus-calendar - - - susp - application/vnd.sus-calendar - - - sv4cpio - application/x-sv4cpio - - - sv4crc - application/x-sv4crc - - - svc - application/vnd.dvb.service - - - svd - application/vnd.svd - - - svg - image/svg+xml - - - svgz - image/svg+xml - - - swa - application/x-director - - - swf - application/x-shockwave-flash - - - swi - application/vnd.aristanetworks.swi - - - sxc - application/vnd.sun.xml.calc - - - sxd - application/vnd.sun.xml.draw - - - sxg - application/vnd.sun.xml.writer.global - - - sxi - application/vnd.sun.xml.impress - - - sxm - application/vnd.sun.xml.math - - - sxw - application/vnd.sun.xml.writer - - - t - text/troff - - - taglet - application/vnd.mynfc - - - tao - application/vnd.tao.intent-module-archive - - - tar - application/x-tar - - - tcap - application/vnd.3gpp2.tcap - - - tcl - application/x-tcl - - - teacher - application/vnd.smart.teacher - - - tei - application/tei+xml - - - teicorpus - application/tei+xml - - - tex - application/x-tex - - - texi - application/x-texinfo - - - texinfo - application/x-texinfo - - - text - text/plain - - - tfi - application/thraud+xml - - - tfm - application/x-tex-tfm - - - thmx - application/vnd.ms-officetheme - - - tif - image/tiff - - - tiff - image/tiff - - - tmo - application/vnd.tmobile-livetv - - - torrent - application/x-bittorrent - - - tpl - application/vnd.groove-tool-template - - - tpt - application/vnd.trid.tpt - - - tr - text/troff - - - tra - application/vnd.trueapp - - - trm - application/x-msterminal - - - tsd - application/timestamped-data - - - tsv - text/tab-separated-values - - - ttc - application/x-font-ttf - - - ttf - application/x-font-ttf - - - ttl - text/turtle - - - twd - application/vnd.simtech-mindmapper - - - twds - application/vnd.simtech-mindmapper - - - txd - application/vnd.genomatix.tuxedo - - - txf - application/vnd.mobius.txf - - - txt - text/plain - - - u32 - application/x-authorware-bin - - - udeb - application/x-debian-package - - - ufd - application/vnd.ufdl - - - ufdl - application/vnd.ufdl - - - ulw - audio/basic - - - umj - application/vnd.umajin - - - unityweb - application/vnd.unity - - - uoml - application/vnd.uoml+xml - - - uri - text/uri-list - - - uris - text/uri-list - - - urls - text/uri-list - - - ustar - application/x-ustar - - - utz - application/vnd.uiq.theme - - - uu - text/x-uuencode - - - uva - audio/vnd.dece.audio - - - uvd - application/vnd.dece.data - - - uvf - application/vnd.dece.data - - - uvg - image/vnd.dece.graphic - - - uvh - video/vnd.dece.hd - - - uvi - image/vnd.dece.graphic - - - uvm - video/vnd.dece.mobile - - - uvp - video/vnd.dece.pd - - - uvs - video/vnd.dece.sd - - - uvt - application/vnd.dece.ttml+xml - - - uvu - video/vnd.uvvu.mp4 - - - uvv - video/vnd.dece.video - - - uvva - audio/vnd.dece.audio - - - uvvd - application/vnd.dece.data - - - uvvf - application/vnd.dece.data - - - uvvg - image/vnd.dece.graphic - - - uvvh - video/vnd.dece.hd - - - uvvi - image/vnd.dece.graphic - - - uvvm - video/vnd.dece.mobile - - - uvvp - video/vnd.dece.pd - - - uvvs - video/vnd.dece.sd - - - uvvt - application/vnd.dece.ttml+xml - - - uvvu - video/vnd.uvvu.mp4 - - - uvvv - video/vnd.dece.video - - - uvvx - application/vnd.dece.unspecified - - - uvvz - application/vnd.dece.zip - - - uvx - application/vnd.dece.unspecified - - - uvz - application/vnd.dece.zip - - - vcard - text/vcard - - - vcd - application/x-cdlink - - - vcf - text/x-vcard - - - vcg - application/vnd.groove-vcard - - - vcs - text/x-vcalendar - - - vcx - application/vnd.vcx - - - vis - application/vnd.visionary - - - viv - video/vnd.vivo - - - vor - application/vnd.stardivision.writer - - - vox - application/x-authorware-bin - - - vrml - model/vrml - - - vsd - application/vnd.visio - - - vsf - application/vnd.vsf - - - vss - application/vnd.visio - - - vst - application/vnd.visio - - - vsw - application/vnd.visio - - - vtu - model/vnd.vtu - - - vxml - application/voicexml+xml - - - w3d - application/x-director - - - wad - application/x-doom - - - wav - audio/x-wav - - - wax - audio/x-ms-wax - - - - wbmp - image/vnd.wap.wbmp - - - wbs - application/vnd.criticaltools.wbs+xml - - - wbxml - application/vnd.wap.wbxml - - - wcm - application/vnd.ms-works - - - wdb - application/vnd.ms-works - - - weba - audio/webm - - - webm - video/webm - - - webp - image/webp - - - wg - application/vnd.pmi.widget - - - wgt - application/widget - - - wks - application/vnd.ms-works - - - wm - video/x-ms-wm - - - wma - audio/x-ms-wma - - - wmd - application/x-ms-wmd - - - wmf - application/x-msmetafile - - - - wml - text/vnd.wap.wml - - - - wmlc - application/vnd.wap.wmlc - - - - wmls - text/vnd.wap.wmlscript - - - - wmlsc - application/vnd.wap.wmlscriptc - - - wmv - video/x-ms-wmv - - - wmx - video/x-ms-wmx - - - wmz - application/x-ms-wmz - - - woff - application/x-font-woff - - - wpd - application/vnd.wordperfect - - - wpl - application/vnd.ms-wpl - - - wps - application/vnd.ms-works - - - wqd - application/vnd.wqd - - - wri - application/x-mswrite - - - wrl - model/vrml - - - wsdl - application/wsdl+xml - - - wspolicy - application/wspolicy+xml - - - wtb - application/vnd.webturbo - - - wvx - video/x-ms-wvx - - - x32 - application/x-authorware-bin - - - x3d - application/vnd.hzn-3d-crossword - - - xap - application/x-silverlight-app - - - xar - application/vnd.xara - - - xbap - application/x-ms-xbap - - - xbd - application/vnd.fujixerox.docuworks.binder - - - xbm - image/x-xbitmap - - - xdf - application/xcap-diff+xml - - - xdm - application/vnd.syncml.dm+xml - - - xdp - application/vnd.adobe.xdp+xml - - - xdssc - application/dssc+xml - - - xdw - application/vnd.fujixerox.docuworks - - - xenc - application/xenc+xml - - - xer - application/patch-ops-error+xml - - - xfdf - application/vnd.adobe.xfdf - - - xfdl - application/vnd.xfdl - - - xht - application/xhtml+xml - - - xhtml - application/xhtml+xml - - - xhvml - application/xv+xml - - - xif - image/vnd.xiff - - - xla - application/vnd.ms-excel - - - xlam - application/vnd.ms-excel.addin.macroenabled.12 - - - xlc - application/vnd.ms-excel - - - xlm - application/vnd.ms-excel - - - xls - application/vnd.ms-excel - - - xlsb - application/vnd.ms-excel.sheet.binary.macroenabled.12 - - - xlsm - application/vnd.ms-excel.sheet.macroenabled.12 - - - xlsx - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - - - xlt - application/vnd.ms-excel - - - xltm - application/vnd.ms-excel.template.macroenabled.12 - - - xltx - application/vnd.openxmlformats-officedocument.spreadsheetml.template - - - xlw - application/vnd.ms-excel - - - xml - application/xml - - - xo - application/vnd.olpc-sugar - - - xop - application/xop+xml - - - xpi - application/x-xpinstall - - - xpm - image/x-xpixmap - - - xpr - application/vnd.is-xpr - - - xps - application/vnd.ms-xpsdocument - - - xpw - application/vnd.intercon.formnet - - - xpx - application/vnd.intercon.formnet - - - xsl - application/xml - - - xslt - application/xslt+xml - - - xsm - application/vnd.syncml+xml - - - xspf - application/xspf+xml - - - xul - application/vnd.mozilla.xul+xml - - - xvm - application/xv+xml - - - xvml - application/xv+xml - - - xwd - image/x-xwindowdump - - - xyz - chemical/x-xyz - - - yang - application/yang - - - yin - application/yin+xml - - - z - application/x-compress - - - Z - application/x-compress - - - zaz - application/vnd.zzazz.deck+xml - - - zip - application/zip - - - zir - application/vnd.zul - - - zirz - application/vnd.zul - - - zmm - application/vnd.handheld-entertainment+xml - - - - - - - - - - - - - - - - - - index.html - index.htm - index.jsp - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default + org.apache.catalina.servlets.DefaultServlet + + debug + 0 + + + listings + false + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jsp + org.apache.jasper.servlet.JspServlet + + fork + false + + + xpoweredBy + false + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default + / + + + + + jsp + *.jsp + *.jspx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 30 + + + + + + + + + + + + 123 + application/vnd.lotus-1-2-3 + + + 3dml + text/vnd.in3d.3dml + + + 3g2 + video/3gpp2 + + + 3gp + video/3gpp + + + 7z + application/x-7z-compressed + + + aab + application/x-authorware-bin + + + aac + audio/x-aac + + + aam + application/x-authorware-map + + + aas + application/x-authorware-seg + + + abs + audio/x-mpeg + + + abw + application/x-abiword + + + ac + application/pkix-attr-cert + + + acc + application/vnd.americandynamics.acc + + + ace + application/x-ace-compressed + + + acu + application/vnd.acucobol + + + acutc + application/vnd.acucorp + + + adp + audio/adpcm + + + aep + application/vnd.audiograph + + + afm + application/x-font-type1 + + + afp + application/vnd.ibm.modcap + + + ahead + application/vnd.ahead.space + + + ai + application/postscript + + + aif + audio/x-aiff + + + aifc + audio/x-aiff + + + aiff + audio/x-aiff + + + aim + application/x-aim + + + air + application/vnd.adobe.air-application-installer-package+zip + + + ait + application/vnd.dvb.ait + + + ami + application/vnd.amiga.ami + + + anx + application/annodex + + + apk + application/vnd.android.package-archive + + + application + application/x-ms-application + + + apr + application/vnd.lotus-approach + + + art + image/x-jg + + + asc + application/pgp-signature + + + asf + video/x-ms-asf + + + asm + text/x-asm + + + aso + application/vnd.accpac.simply.aso + + + asx + video/x-ms-asf + + + atc + application/vnd.acucorp + + + atom + application/atom+xml + + + atomcat + application/atomcat+xml + + + atomsvc + application/atomsvc+xml + + + atx + application/vnd.antix.game-component + + + au + audio/basic + + + avi + video/x-msvideo + + + avx + video/x-rad-screenplay + + + aw + application/applixware + + + axa + audio/annodex + + + axv + video/annodex + + + azf + application/vnd.airzip.filesecure.azf + + + azs + application/vnd.airzip.filesecure.azs + + + azw + application/vnd.amazon.ebook + + + bat + application/x-msdownload + + + bcpio + application/x-bcpio + + + bdf + application/x-font-bdf + + + bdm + application/vnd.syncml.dm+wbxml + + + bed + application/vnd.realvnc.bed + + + bh2 + application/vnd.fujitsu.oasysprs + + + bin + application/octet-stream + + + bmi + application/vnd.bmi + + + bmp + image/bmp + + + body + text/html + + + book + application/vnd.framemaker + + + box + application/vnd.previewsystems.box + + + boz + application/x-bzip2 + + + bpk + application/octet-stream + + + btif + image/prs.btif + + + bz + application/x-bzip + + + bz2 + application/x-bzip2 + + + c + text/x-c + + + c11amc + application/vnd.cluetrust.cartomobile-config + + + c11amz + application/vnd.cluetrust.cartomobile-config-pkg + + + c4d + application/vnd.clonk.c4group + + + c4f + application/vnd.clonk.c4group + + + c4g + application/vnd.clonk.c4group + + + c4p + application/vnd.clonk.c4group + + + c4u + application/vnd.clonk.c4group + + + cab + application/vnd.ms-cab-compressed + + + cap + application/vnd.tcpdump.pcap + + + car + application/vnd.curl.car + + + cat + application/vnd.ms-pki.seccat + + + cc + text/x-c + + + cct + application/x-director + + + ccxml + application/ccxml+xml + + + cdbcmsg + application/vnd.contact.cmsg + + + cdf + application/x-cdf + + + cdkey + application/vnd.mediastation.cdkey + + + cdmia + application/cdmi-capability + + + cdmic + application/cdmi-container + + + cdmid + application/cdmi-domain + + + cdmio + application/cdmi-object + + + cdmiq + application/cdmi-queue + + + cdx + chemical/x-cdx + + + cdxml + application/vnd.chemdraw+xml + + + cdy + application/vnd.cinderella + + + cer + application/pkix-cert + + + cgm + image/cgm + + + chat + application/x-chat + + + chm + application/vnd.ms-htmlhelp + + + chrt + application/vnd.kde.kchart + + + cif + chemical/x-cif + + + cii + application/vnd.anser-web-certificate-issue-initiation + + + cil + application/vnd.ms-artgalry + + + cla + application/vnd.claymore + + + class + application/java + + + clkk + application/vnd.crick.clicker.keyboard + + + clkp + application/vnd.crick.clicker.palette + + + clkt + application/vnd.crick.clicker.template + + + clkw + application/vnd.crick.clicker.wordbank + + + clkx + application/vnd.crick.clicker + + + clp + application/x-msclip + + + cmc + application/vnd.cosmocaller + + + cmdf + chemical/x-cmdf + + + cml + chemical/x-cml + + + cmp + application/vnd.yellowriver-custom-menu + + + cmx + image/x-cmx + + + cod + application/vnd.rim.cod + + + com + application/x-msdownload + + + conf + text/plain + + + cpio + application/x-cpio + + + cpp + text/x-c + + + cpt + application/mac-compactpro + + + crd + application/x-mscardfile + + + crl + application/pkix-crl + + + crt + application/x-x509-ca-cert + + + cryptonote + application/vnd.rig.cryptonote + + + csh + application/x-csh + + + csml + chemical/x-csml + + + csp + application/vnd.commonspace + + + css + text/css + + + cst + application/x-director + + + csv + text/csv + + + cu + application/cu-seeme + + + curl + text/vnd.curl + + + cww + application/prs.cww + + + cxt + application/x-director + + + cxx + text/x-c + + + dae + model/vnd.collada+xml + + + daf + application/vnd.mobius.daf + + + dataless + application/vnd.fdsn.seed + + + davmount + application/davmount+xml + + + dcr + application/x-director + + + dcurl + text/vnd.curl.dcurl + + + dd2 + application/vnd.oma.dd2+xml + + + ddd + application/vnd.fujixerox.ddd + + + deb + application/x-debian-package + + + def + text/plain + + + deploy + application/octet-stream + + + der + application/x-x509-ca-cert + + + dfac + application/vnd.dreamfactory + + + dib + image/bmp + + + dic + text/x-c + + + dir + application/x-director + + + dis + application/vnd.mobius.dis + + + dist + application/octet-stream + + + distz + application/octet-stream + + + djv + image/vnd.djvu + + + djvu + image/vnd.djvu + + + dll + application/x-msdownload + + + dmg + application/octet-stream + + + dmp + application/vnd.tcpdump.pcap + + + dms + application/octet-stream + + + dna + application/vnd.dna + + + doc + application/msword + + + docm + application/vnd.ms-word.document.macroenabled.12 + + + docx + application/vnd.openxmlformats-officedocument.wordprocessingml.document + + + dot + application/msword + + + dotm + application/vnd.ms-word.template.macroenabled.12 + + + dotx + application/vnd.openxmlformats-officedocument.wordprocessingml.template + + + dp + application/vnd.osgi.dp + + + dpg + application/vnd.dpgraph + + + dra + audio/vnd.dra + + + dsc + text/prs.lines.tag + + + dssc + application/dssc+der + + + dtb + application/x-dtbook+xml + + + dtd + application/xml-dtd + + + dts + audio/vnd.dts + + + dtshd + audio/vnd.dts.hd + + + dump + application/octet-stream + + + dv + video/x-dv + + + dvb + video/vnd.dvb.file + + + dvi + application/x-dvi + + + dwf + model/vnd.dwf + + + dwg + image/vnd.dwg + + + dxf + image/vnd.dxf + + + dxp + application/vnd.spotfire.dxp + + + dxr + application/x-director + + + ecelp4800 + audio/vnd.nuera.ecelp4800 + + + ecelp7470 + audio/vnd.nuera.ecelp7470 + + + ecelp9600 + audio/vnd.nuera.ecelp9600 + + + ecma + application/ecmascript + + + edm + application/vnd.novadigm.edm + + + edx + application/vnd.novadigm.edx + + + efif + application/vnd.picsel + + + ei6 + application/vnd.pg.osasli + + + elc + application/octet-stream + + + eml + message/rfc822 + + + emma + application/emma+xml + + + eol + audio/vnd.digital-winds + + + eot + application/vnd.ms-fontobject + + + eps + application/postscript + + + epub + application/epub+zip + + + es3 + application/vnd.eszigno3+xml + + + esf + application/vnd.epson.esf + + + et3 + application/vnd.eszigno3+xml + + + etx + text/x-setext + + + exe + application/octet-stream + + + exi + application/exi + + + ext + application/vnd.novadigm.ext + + + ez + application/andrew-inset + + + ez2 + application/vnd.ezpix-album + + + ez3 + application/vnd.ezpix-package + + + f + text/x-fortran + + + f4v + video/x-f4v + + + f77 + text/x-fortran + + + f90 + text/x-fortran + + + fbs + image/vnd.fastbidsheet + + + fcs + application/vnd.isac.fcs + + + fdf + application/vnd.fdf + + + fe_launch + application/vnd.denovo.fcselayout-link + + + fg5 + application/vnd.fujitsu.oasysgp + + + fgd + application/x-director + + + fh + image/x-freehand + + + fh4 + image/x-freehand + + + fh5 + image/x-freehand + + + fh7 + image/x-freehand + + + fhc + image/x-freehand + + + fig + application/x-xfig + + + flac + audio/flac + + + fli + video/x-fli + + + flo + application/vnd.micrografx.flo + + + flv + video/x-flv + + + flw + application/vnd.kde.kivio + + + flx + text/vnd.fmi.flexstor + + + fly + text/vnd.fly + + + fm + application/vnd.framemaker + + + fnc + application/vnd.frogans.fnc + + + for + text/x-fortran + + + fpx + image/vnd.fpx + + + frame + application/vnd.framemaker + + + fsc + application/vnd.fsc.weblaunch + + + fst + image/vnd.fst + + + ftc + application/vnd.fluxtime.clip + + + fti + application/vnd.anser-web-funds-transfer-initiation + + + fvt + video/vnd.fvt + + + fxp + application/vnd.adobe.fxp + + + fxpl + application/vnd.adobe.fxp + + + fzs + application/vnd.fuzzysheet + + + g2w + application/vnd.geoplan + + + g3 + image/g3fax + + + g3w + application/vnd.geospace + + + gac + application/vnd.groove-account + + + gbr + application/rpki-ghostbusters + + + gdl + model/vnd.gdl + + + geo + application/vnd.dynageo + + + gex + application/vnd.geometry-explorer + + + ggb + application/vnd.geogebra.file + + + ggt + application/vnd.geogebra.tool + + + ghf + application/vnd.groove-help + + + gif + image/gif + + + gim + application/vnd.groove-identity-message + + + gmx + application/vnd.gmx + + + gnumeric + application/x-gnumeric + + + gph + application/vnd.flographit + + + gqf + application/vnd.grafeq + + + gqs + application/vnd.grafeq + + + gram + application/srgs + + + gre + application/vnd.geometry-explorer + + + grv + application/vnd.groove-injector + + + grxml + application/srgs+xml + + + gsf + application/x-font-ghostscript + + + gtar + application/x-gtar + + + gtm + application/vnd.groove-tool-message + + + gtw + model/vnd.gtw + + + gv + text/vnd.graphviz + + + gxt + application/vnd.geonext + + + gz + application/x-gzip + + + h + text/x-c + + + h261 + video/h261 + + + h263 + video/h263 + + + h264 + video/h264 + + + hal + application/vnd.hal+xml + + + hbci + application/vnd.hbci + + + hdf + application/x-hdf + + + hh + text/x-c + + + hlp + application/winhlp + + + hpgl + application/vnd.hp-hpgl + + + hpid + application/vnd.hp-hpid + + + hps + application/vnd.hp-hps + + + hqx + application/mac-binhex40 + + + htc + text/x-component + + + htke + application/vnd.kenameaapp + + + htm + text/html + + + html + text/html + + + hvd + application/vnd.yamaha.hv-dic + + + hvp + application/vnd.yamaha.hv-voice + + + hvs + application/vnd.yamaha.hv-script + + + i2g + application/vnd.intergeo + + + icc + application/vnd.iccprofile + + + ice + x-conference/x-cooltalk + + + icm + application/vnd.iccprofile + + + ico + image/x-icon + + + ics + text/calendar + + + ief + image/ief + + + ifb + text/calendar + + + ifm + application/vnd.shana.informed.formdata + + + iges + model/iges + + + igl + application/vnd.igloader + + + igm + application/vnd.insors.igm + + + igs + model/iges + + + igx + application/vnd.micrografx.igx + + + iif + application/vnd.shana.informed.interchange + + + imp + application/vnd.accpac.simply.imp + + + ims + application/vnd.ms-ims + + + in + text/plain + + + ink + application/inkml+xml + + + inkml + application/inkml+xml + + + iota + application/vnd.astraea-software.iota + + + ipfix + application/ipfix + + + ipk + application/vnd.shana.informed.package + + + irm + application/vnd.ibm.rights-management + + + irp + application/vnd.irepository.package+xml + + + iso + application/octet-stream + + + itp + application/vnd.shana.informed.formtemplate + + + ivp + application/vnd.immervision-ivp + + + ivu + application/vnd.immervision-ivu + + + jad + text/vnd.sun.j2me.app-descriptor + + + jam + application/vnd.jam + + + jar + application/java-archive + + + java + text/x-java-source + + + jisp + application/vnd.jisp + + + jlt + application/vnd.hp-jlyt + + + jnlp + application/x-java-jnlp-file + + + joda + application/vnd.joost.joda-archive + + + jpe + image/jpeg + + + jpeg + image/jpeg + + + jpg + image/jpeg + + + jpgm + video/jpm + + + jpgv + video/jpeg + + + jpm + video/jpm + + + js + application/javascript + + + jsf + text/plain + + + json + application/json + + + jspf + text/plain + + + kar + audio/midi + + + karbon + application/vnd.kde.karbon + + + kfo + application/vnd.kde.kformula + + + kia + application/vnd.kidspiration + + + kml + application/vnd.google-earth.kml+xml + + + kmz + application/vnd.google-earth.kmz + + + kne + application/vnd.kinar + + + knp + application/vnd.kinar + + + kon + application/vnd.kde.kontour + + + kpr + application/vnd.kde.kpresenter + + + kpt + application/vnd.kde.kpresenter + + + ksp + application/vnd.kde.kspread + + + ktr + application/vnd.kahootz + + + ktx + image/ktx + + + ktz + application/vnd.kahootz + + + kwd + application/vnd.kde.kword + + + kwt + application/vnd.kde.kword + + + lasxml + application/vnd.las.las+xml + + + latex + application/x-latex + + + lbd + application/vnd.llamagraphics.life-balance.desktop + + + lbe + application/vnd.llamagraphics.life-balance.exchange+xml + + + les + application/vnd.hhe.lesson-player + + + lha + application/octet-stream + + + link66 + application/vnd.route66.link66+xml + + + list + text/plain + + + list3820 + application/vnd.ibm.modcap + + + listafp + application/vnd.ibm.modcap + + + log + text/plain + + + lostxml + application/lost+xml + + + lrf + application/octet-stream + + + lrm + application/vnd.ms-lrm + + + ltf + application/vnd.frogans.ltf + + + lvp + audio/vnd.lucent.voice + + + lwp + application/vnd.lotus-wordpro + + + lzh + application/octet-stream + + + m13 + application/x-msmediaview + + + m14 + application/x-msmediaview + + + m1v + video/mpeg + + + m21 + application/mp21 + + + m2a + audio/mpeg + + + m2v + video/mpeg + + + m3a + audio/mpeg + + + m3u + audio/x-mpegurl + + + m3u8 + application/vnd.apple.mpegurl + + + m4a + audio/mp4 + + + m4b + audio/mp4 + + + m4r + audio/mp4 + + + m4u + video/vnd.mpegurl + + + m4v + video/mp4 + + + ma + application/mathematica + + + mac + image/x-macpaint + + + mads + application/mads+xml + + + mag + application/vnd.ecowin.chart + + + maker + application/vnd.framemaker + + + man + text/troff + + + mathml + application/mathml+xml + + + mb + application/mathematica + + + mbk + application/vnd.mobius.mbk + + + mbox + application/mbox + + + mc1 + application/vnd.medcalcdata + + + mcd + application/vnd.mcd + + + mcurl + text/vnd.curl.mcurl + + + mdb + application/x-msaccess + + + mdi + image/vnd.ms-modi + + + me + text/troff + + + mesh + model/mesh + + + meta4 + application/metalink4+xml + + + mets + application/mets+xml + + + mfm + application/vnd.mfmp + + + mft + application/rpki-manifest + + + mgp + application/vnd.osgeo.mapguide.package + + + mgz + application/vnd.proteus.magazine + + + mid + audio/midi + + + midi + audio/midi + + + mif + application/x-mif + + + mime + message/rfc822 + + + mj2 + video/mj2 + + + mjp2 + video/mj2 + + + mlp + application/vnd.dolby.mlp + + + mmd + application/vnd.chipnuts.karaoke-mmd + + + mmf + application/vnd.smaf + + + mmr + image/vnd.fujixerox.edmics-mmr + + + mny + application/x-msmoney + + + mobi + application/x-mobipocket-ebook + + + mods + application/mods+xml + + + mov + video/quicktime + + + movie + video/x-sgi-movie + + + mp1 + audio/mpeg + + + mp2 + audio/mpeg + + + mp21 + application/mp21 + + + mp2a + audio/mpeg + + + mp3 + audio/mpeg + + + mp4 + video/mp4 + + + mp4a + audio/mp4 + + + mp4s + application/mp4 + + + mp4v + video/mp4 + + + mpa + audio/mpeg + + + mpc + application/vnd.mophun.certificate + + + mpe + video/mpeg + + + mpeg + video/mpeg + + + mpega + audio/x-mpeg + + + mpg + video/mpeg + + + mpg4 + video/mp4 + + + mpga + audio/mpeg + + + mpkg + application/vnd.apple.installer+xml + + + mpm + application/vnd.blueice.multipass + + + mpn + application/vnd.mophun.application + + + mpp + application/vnd.ms-project + + + mpt + application/vnd.ms-project + + + mpv2 + video/mpeg2 + + + mpy + application/vnd.ibm.minipay + + + mqy + application/vnd.mobius.mqy + + + mrc + application/marc + + + mrcx + application/marcxml+xml + + + ms + text/troff + + + mscml + application/mediaservercontrol+xml + + + mseed + application/vnd.fdsn.mseed + + + mseq + application/vnd.mseq + + + msf + application/vnd.epson.msf + + + msh + model/mesh + + + msi + application/x-msdownload + + + msl + application/vnd.mobius.msl + + + msty + application/vnd.muvee.style + + + mts + model/vnd.mts + + + mus + application/vnd.musician + + + musicxml + application/vnd.recordare.musicxml+xml + + + mvb + application/x-msmediaview + + + mwf + application/vnd.mfer + + + mxf + application/mxf + + + mxl + application/vnd.recordare.musicxml + + + mxml + application/xv+xml + + + mxs + application/vnd.triscape.mxs + + + mxu + video/vnd.mpegurl + + + n-gage + application/vnd.nokia.n-gage.symbian.install + + + n3 + text/n3 + + + nb + application/mathematica + + + nbp + application/vnd.wolfram.player + + + nc + application/x-netcdf + + + ncx + application/x-dtbncx+xml + + + ngdat + application/vnd.nokia.n-gage.data + + + nlu + application/vnd.neurolanguage.nlu + + + nml + application/vnd.enliven + + + nnd + application/vnd.noblenet-directory + + + nns + application/vnd.noblenet-sealer + + + nnw + application/vnd.noblenet-web + + + npx + image/vnd.net-fpx + + + nsf + application/vnd.lotus-notes + + + oa2 + application/vnd.fujitsu.oasys2 + + + oa3 + application/vnd.fujitsu.oasys3 + + + oas + application/vnd.fujitsu.oasys + + + obd + application/x-msbinder + + + oda + application/oda + + + + odb + application/vnd.oasis.opendocument.database + + + + odc + application/vnd.oasis.opendocument.chart + + + + odf + application/vnd.oasis.opendocument.formula + + + odft + application/vnd.oasis.opendocument.formula-template + + + + odg + application/vnd.oasis.opendocument.graphics + + + + odi + application/vnd.oasis.opendocument.image + + + + odm + application/vnd.oasis.opendocument.text-master + + + + odp + application/vnd.oasis.opendocument.presentation + + + + ods + application/vnd.oasis.opendocument.spreadsheet + + + + odt + application/vnd.oasis.opendocument.text + + + oga + audio/ogg + + + ogg + audio/ogg + + + ogv + video/ogg + + + + ogx + application/ogg + + + onepkg + application/onenote + + + onetmp + application/onenote + + + onetoc + application/onenote + + + onetoc2 + application/onenote + + + opf + application/oebps-package+xml + + + oprc + application/vnd.palm + + + org + application/vnd.lotus-organizer + + + osf + application/vnd.yamaha.openscoreformat + + + osfpvg + application/vnd.yamaha.openscoreformat.osfpvg+xml + + + otc + application/vnd.oasis.opendocument.chart-template + + + otf + application/x-font-otf + + + + otg + application/vnd.oasis.opendocument.graphics-template + + + + oth + application/vnd.oasis.opendocument.text-web + + + oti + application/vnd.oasis.opendocument.image-template + + + + otp + application/vnd.oasis.opendocument.presentation-template + + + + ots + application/vnd.oasis.opendocument.spreadsheet-template + + + + ott + application/vnd.oasis.opendocument.text-template + + + oxps + application/oxps + + + oxt + application/vnd.openofficeorg.extension + + + p + text/x-pascal + + + p10 + application/pkcs10 + + + p12 + application/x-pkcs12 + + + p7b + application/x-pkcs7-certificates + + + p7c + application/pkcs7-mime + + + p7m + application/pkcs7-mime + + + p7r + application/x-pkcs7-certreqresp + + + p7s + application/pkcs7-signature + + + p8 + application/pkcs8 + + + pas + text/x-pascal + + + paw + application/vnd.pawaafile + + + pbd + application/vnd.powerbuilder6 + + + pbm + image/x-portable-bitmap + + + pcap + application/vnd.tcpdump.pcap + + + pcf + application/x-font-pcf + + + pcl + application/vnd.hp-pcl + + + pclxl + application/vnd.hp-pclxl + + + pct + image/pict + + + pcurl + application/vnd.curl.pcurl + + + pcx + image/x-pcx + + + pdb + application/vnd.palm + + + pdf + application/pdf + + + pfa + application/x-font-type1 + + + pfb + application/x-font-type1 + + + pfm + application/x-font-type1 + + + pfr + application/font-tdpfr + + + pfx + application/x-pkcs12 + + + pgm + image/x-portable-graymap + + + pgn + application/x-chess-pgn + + + pgp + application/pgp-encrypted + + + pic + image/pict + + + pict + image/pict + + + pkg + application/octet-stream + + + pki + application/pkixcmp + + + pkipath + application/pkix-pkipath + + + plb + application/vnd.3gpp.pic-bw-large + + + plc + application/vnd.mobius.plc + + + plf + application/vnd.pocketlearn + + + pls + audio/x-scpls + + + pml + application/vnd.ctc-posml + + + png + image/png + + + pnm + image/x-portable-anymap + + + pnt + image/x-macpaint + + + portpkg + application/vnd.macports.portpkg + + + pot + application/vnd.ms-powerpoint + + + potm + application/vnd.ms-powerpoint.template.macroenabled.12 + + + potx + application/vnd.openxmlformats-officedocument.presentationml.template + + + ppam + application/vnd.ms-powerpoint.addin.macroenabled.12 + + + ppd + application/vnd.cups-ppd + + + ppm + image/x-portable-pixmap + + + pps + application/vnd.ms-powerpoint + + + ppsm + application/vnd.ms-powerpoint.slideshow.macroenabled.12 + + + ppsx + application/vnd.openxmlformats-officedocument.presentationml.slideshow + + + ppt + application/vnd.ms-powerpoint + + + pptm + application/vnd.ms-powerpoint.presentation.macroenabled.12 + + + pptx + application/vnd.openxmlformats-officedocument.presentationml.presentation + + + pqa + application/vnd.palm + + + prc + application/x-mobipocket-ebook + + + pre + application/vnd.lotus-freelance + + + prf + application/pics-rules + + + ps + application/postscript + + + psb + application/vnd.3gpp.pic-bw-small + + + psd + image/vnd.adobe.photoshop + + + psf + application/x-font-linux-psf + + + pskcxml + application/pskc+xml + + + ptid + application/vnd.pvi.ptid1 + + + pub + application/x-mspublisher + + + pvb + application/vnd.3gpp.pic-bw-var + + + pwn + application/vnd.3m.post-it-notes + + + pya + audio/vnd.ms-playready.media.pya + + + pyv + video/vnd.ms-playready.media.pyv + + + qam + application/vnd.epson.quickanime + + + qbo + application/vnd.intu.qbo + + + qfx + application/vnd.intu.qfx + + + qps + application/vnd.publishare-delta-tree + + + qt + video/quicktime + + + qti + image/x-quicktime + + + qtif + image/x-quicktime + + + qwd + application/vnd.quark.quarkxpress + + + qwt + application/vnd.quark.quarkxpress + + + qxb + application/vnd.quark.quarkxpress + + + qxd + application/vnd.quark.quarkxpress + + + qxl + application/vnd.quark.quarkxpress + + + qxt + application/vnd.quark.quarkxpress + + + ra + audio/x-pn-realaudio + + + ram + audio/x-pn-realaudio + + + rar + application/x-rar-compressed + + + ras + image/x-cmu-raster + + + rcprofile + application/vnd.ipunplugged.rcprofile + + + rdf + application/rdf+xml + + + rdz + application/vnd.data-vision.rdz + + + rep + application/vnd.businessobjects + + + res + application/x-dtbresource+xml + + + rgb + image/x-rgb + + + rif + application/reginfo+xml + + + rip + audio/vnd.rip + + + rl + application/resource-lists+xml + + + rlc + image/vnd.fujixerox.edmics-rlc + + + rld + application/resource-lists-diff+xml + + + rm + application/vnd.rn-realmedia + + + rmi + audio/midi + + + rmp + audio/x-pn-realaudio-plugin + + + rms + application/vnd.jcp.javame.midlet-rms + + + rnc + application/relax-ng-compact-syntax + + + roa + application/rpki-roa + + + roff + text/troff + + + rp9 + application/vnd.cloanto.rp9 + + + rpss + application/vnd.nokia.radio-presets + + + rpst + application/vnd.nokia.radio-preset + + + rq + application/sparql-query + + + rs + application/rls-services+xml + + + rsd + application/rsd+xml + + + rss + application/rss+xml + + + rtf + application/rtf + + + rtx + text/richtext + + + s + text/x-asm + + + saf + application/vnd.yamaha.smaf-audio + + + sbml + application/sbml+xml + + + sc + application/vnd.ibm.secure-container + + + scd + application/x-msschedule + + + scm + application/vnd.lotus-screencam + + + scq + application/scvp-cv-request + + + scs + application/scvp-cv-response + + + scurl + text/vnd.curl.scurl + + + sda + application/vnd.stardivision.draw + + + sdc + application/vnd.stardivision.calc + + + sdd + application/vnd.stardivision.impress + + + sdkd + application/vnd.solent.sdkm+xml + + + sdkm + application/vnd.solent.sdkm+xml + + + sdp + application/sdp + + + sdw + application/vnd.stardivision.writer + + + see + application/vnd.seemail + + + seed + application/vnd.fdsn.seed + + + sema + application/vnd.sema + + + semd + application/vnd.semd + + + semf + application/vnd.semf + + + ser + application/java-serialized-object + + + setpay + application/set-payment-initiation + + + setreg + application/set-registration-initiation + + + sfd-hdstx + application/vnd.hydrostatix.sof-data + + + sfs + application/vnd.spotfire.sfs + + + sgl + application/vnd.stardivision.writer-global + + + sgm + text/sgml + + + sgml + text/sgml + + + sh + application/x-sh + + + shar + application/x-shar + + + shf + application/shf+xml + + + + sig + application/pgp-signature + + + silo + model/mesh + + + sis + application/vnd.symbian.install + + + sisx + application/vnd.symbian.install + + + sit + application/x-stuffit + + + sitx + application/x-stuffitx + + + skd + application/vnd.koan + + + skm + application/vnd.koan + + + skp + application/vnd.koan + + + skt + application/vnd.koan + + + sldm + application/vnd.ms-powerpoint.slide.macroenabled.12 + + + sldx + application/vnd.openxmlformats-officedocument.presentationml.slide + + + slt + application/vnd.epson.salt + + + sm + application/vnd.stepmania.stepchart + + + smf + application/vnd.stardivision.math + + + smi + application/smil+xml + + + smil + application/smil+xml + + + smzip + application/vnd.stepmania.package + + + snd + audio/basic + + + snf + application/x-font-snf + + + so + application/octet-stream + + + spc + application/x-pkcs7-certificates + + + spf + application/vnd.yamaha.smaf-phrase + + + spl + application/x-futuresplash + + + spot + text/vnd.in3d.spot + + + spp + application/scvp-vp-response + + + spq + application/scvp-vp-request + + + spx + audio/ogg + + + src + application/x-wais-source + + + sru + application/sru+xml + + + srx + application/sparql-results+xml + + + sse + application/vnd.kodak-descriptor + + + ssf + application/vnd.epson.ssf + + + ssml + application/ssml+xml + + + st + application/vnd.sailingtracker.track + + + stc + application/vnd.sun.xml.calc.template + + + std + application/vnd.sun.xml.draw.template + + + stf + application/vnd.wt.stf + + + sti + application/vnd.sun.xml.impress.template + + + stk + application/hyperstudio + + + stl + application/vnd.ms-pki.stl + + + str + application/vnd.pg.format + + + stw + application/vnd.sun.xml.writer.template + + + sub + text/vnd.dvb.subtitle + + + sus + application/vnd.sus-calendar + + + susp + application/vnd.sus-calendar + + + sv4cpio + application/x-sv4cpio + + + sv4crc + application/x-sv4crc + + + svc + application/vnd.dvb.service + + + svd + application/vnd.svd + + + svg + image/svg+xml + + + svgz + image/svg+xml + + + swa + application/x-director + + + swf + application/x-shockwave-flash + + + swi + application/vnd.aristanetworks.swi + + + sxc + application/vnd.sun.xml.calc + + + sxd + application/vnd.sun.xml.draw + + + sxg + application/vnd.sun.xml.writer.global + + + sxi + application/vnd.sun.xml.impress + + + sxm + application/vnd.sun.xml.math + + + sxw + application/vnd.sun.xml.writer + + + t + text/troff + + + taglet + application/vnd.mynfc + + + tao + application/vnd.tao.intent-module-archive + + + tar + application/x-tar + + + tcap + application/vnd.3gpp2.tcap + + + tcl + application/x-tcl + + + teacher + application/vnd.smart.teacher + + + tei + application/tei+xml + + + teicorpus + application/tei+xml + + + tex + application/x-tex + + + texi + application/x-texinfo + + + texinfo + application/x-texinfo + + + text + text/plain + + + tfi + application/thraud+xml + + + tfm + application/x-tex-tfm + + + thmx + application/vnd.ms-officetheme + + + tif + image/tiff + + + tiff + image/tiff + + + tmo + application/vnd.tmobile-livetv + + + torrent + application/x-bittorrent + + + tpl + application/vnd.groove-tool-template + + + tpt + application/vnd.trid.tpt + + + tr + text/troff + + + tra + application/vnd.trueapp + + + trm + application/x-msterminal + + + tsd + application/timestamped-data + + + tsv + text/tab-separated-values + + + ttc + application/x-font-ttf + + + ttf + application/x-font-ttf + + + ttl + text/turtle + + + twd + application/vnd.simtech-mindmapper + + + twds + application/vnd.simtech-mindmapper + + + txd + application/vnd.genomatix.tuxedo + + + txf + application/vnd.mobius.txf + + + txt + text/plain + + + u32 + application/x-authorware-bin + + + udeb + application/x-debian-package + + + ufd + application/vnd.ufdl + + + ufdl + application/vnd.ufdl + + + ulw + audio/basic + + + umj + application/vnd.umajin + + + unityweb + application/vnd.unity + + + uoml + application/vnd.uoml+xml + + + uri + text/uri-list + + + uris + text/uri-list + + + urls + text/uri-list + + + ustar + application/x-ustar + + + utz + application/vnd.uiq.theme + + + uu + text/x-uuencode + + + uva + audio/vnd.dece.audio + + + uvd + application/vnd.dece.data + + + uvf + application/vnd.dece.data + + + uvg + image/vnd.dece.graphic + + + uvh + video/vnd.dece.hd + + + uvi + image/vnd.dece.graphic + + + uvm + video/vnd.dece.mobile + + + uvp + video/vnd.dece.pd + + + uvs + video/vnd.dece.sd + + + uvt + application/vnd.dece.ttml+xml + + + uvu + video/vnd.uvvu.mp4 + + + uvv + video/vnd.dece.video + + + uvva + audio/vnd.dece.audio + + + uvvd + application/vnd.dece.data + + + uvvf + application/vnd.dece.data + + + uvvg + image/vnd.dece.graphic + + + uvvh + video/vnd.dece.hd + + + uvvi + image/vnd.dece.graphic + + + uvvm + video/vnd.dece.mobile + + + uvvp + video/vnd.dece.pd + + + uvvs + video/vnd.dece.sd + + + uvvt + application/vnd.dece.ttml+xml + + + uvvu + video/vnd.uvvu.mp4 + + + uvvv + video/vnd.dece.video + + + uvvx + application/vnd.dece.unspecified + + + uvvz + application/vnd.dece.zip + + + uvx + application/vnd.dece.unspecified + + + uvz + application/vnd.dece.zip + + + vcard + text/vcard + + + vcd + application/x-cdlink + + + vcf + text/x-vcard + + + vcg + application/vnd.groove-vcard + + + vcs + text/x-vcalendar + + + vcx + application/vnd.vcx + + + vis + application/vnd.visionary + + + viv + video/vnd.vivo + + + vor + application/vnd.stardivision.writer + + + vox + application/x-authorware-bin + + + vrml + model/vrml + + + vsd + application/vnd.visio + + + vsf + application/vnd.vsf + + + vss + application/vnd.visio + + + vst + application/vnd.visio + + + vsw + application/vnd.visio + + + vtu + model/vnd.vtu + + + vxml + application/voicexml+xml + + + w3d + application/x-director + + + wad + application/x-doom + + + wav + audio/x-wav + + + wax + audio/x-ms-wax + + + + wbmp + image/vnd.wap.wbmp + + + wbs + application/vnd.criticaltools.wbs+xml + + + wbxml + application/vnd.wap.wbxml + + + wcm + application/vnd.ms-works + + + wdb + application/vnd.ms-works + + + weba + audio/webm + + + webm + video/webm + + + webp + image/webp + + + wg + application/vnd.pmi.widget + + + wgt + application/widget + + + wks + application/vnd.ms-works + + + wm + video/x-ms-wm + + + wma + audio/x-ms-wma + + + wmd + application/x-ms-wmd + + + wmf + application/x-msmetafile + + + + wml + text/vnd.wap.wml + + + + wmlc + application/vnd.wap.wmlc + + + + wmls + text/vnd.wap.wmlscript + + + + wmlsc + application/vnd.wap.wmlscriptc + + + wmv + video/x-ms-wmv + + + wmx + video/x-ms-wmx + + + wmz + application/x-ms-wmz + + + woff + application/x-font-woff + + + wpd + application/vnd.wordperfect + + + wpl + application/vnd.ms-wpl + + + wps + application/vnd.ms-works + + + wqd + application/vnd.wqd + + + wri + application/x-mswrite + + + wrl + model/vrml + + + wsdl + application/wsdl+xml + + + wspolicy + application/wspolicy+xml + + + wtb + application/vnd.webturbo + + + wvx + video/x-ms-wvx + + + x32 + application/x-authorware-bin + + + x3d + application/vnd.hzn-3d-crossword + + + xap + application/x-silverlight-app + + + xar + application/vnd.xara + + + xbap + application/x-ms-xbap + + + xbd + application/vnd.fujixerox.docuworks.binder + + + xbm + image/x-xbitmap + + + xdf + application/xcap-diff+xml + + + xdm + application/vnd.syncml.dm+xml + + + xdp + application/vnd.adobe.xdp+xml + + + xdssc + application/dssc+xml + + + xdw + application/vnd.fujixerox.docuworks + + + xenc + application/xenc+xml + + + xer + application/patch-ops-error+xml + + + xfdf + application/vnd.adobe.xfdf + + + xfdl + application/vnd.xfdl + + + xht + application/xhtml+xml + + + xhtml + application/xhtml+xml + + + xhvml + application/xv+xml + + + xif + image/vnd.xiff + + + xla + application/vnd.ms-excel + + + xlam + application/vnd.ms-excel.addin.macroenabled.12 + + + xlc + application/vnd.ms-excel + + + xlm + application/vnd.ms-excel + + + xls + application/vnd.ms-excel + + + xlsb + application/vnd.ms-excel.sheet.binary.macroenabled.12 + + + xlsm + application/vnd.ms-excel.sheet.macroenabled.12 + + + xlsx + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + + + xlt + application/vnd.ms-excel + + + xltm + application/vnd.ms-excel.template.macroenabled.12 + + + xltx + application/vnd.openxmlformats-officedocument.spreadsheetml.template + + + xlw + application/vnd.ms-excel + + + xml + application/xml + + + xo + application/vnd.olpc-sugar + + + xop + application/xop+xml + + + xpi + application/x-xpinstall + + + xpm + image/x-xpixmap + + + xpr + application/vnd.is-xpr + + + xps + application/vnd.ms-xpsdocument + + + xpw + application/vnd.intercon.formnet + + + xpx + application/vnd.intercon.formnet + + + xsl + application/xml + + + xslt + application/xslt+xml + + + xsm + application/vnd.syncml+xml + + + xspf + application/xspf+xml + + + xul + application/vnd.mozilla.xul+xml + + + xvm + application/xv+xml + + + xvml + application/xv+xml + + + xwd + image/x-xwindowdump + + + xyz + chemical/x-xyz + + + yang + application/yang + + + yin + application/yin+xml + + + z + application/x-compress + + + Z + application/x-compress + + + zaz + application/vnd.zzazz.deck+xml + + + zip + application/zip + + + zir + application/vnd.zul + + + zirz + application/vnd.zul + + + zmm + application/vnd.handheld-entertainment+xml + + + + + + + + + + + + + + + + + + index.html + index.htm + index.jsp + + + diff --git a/jdk/bin/ControlPanel b/jdk/bin/ControlPanel old mode 100644 new mode 100755 diff --git a/jdk/bin/HtmlConverter b/jdk/bin/HtmlConverter old mode 100644 new mode 100755 diff --git a/jdk/bin/appletviewer b/jdk/bin/appletviewer old mode 100644 new mode 100755 diff --git a/jdk/bin/apt b/jdk/bin/apt old mode 100644 new mode 100755 diff --git a/jdk/bin/extcheck b/jdk/bin/extcheck old mode 100644 new mode 100755 diff --git a/jdk/bin/idlj b/jdk/bin/idlj old mode 100644 new mode 100755 diff --git a/jdk/bin/jar b/jdk/bin/jar old mode 100644 new mode 100755 diff --git a/jdk/bin/jarsigner b/jdk/bin/jarsigner old mode 100644 new mode 100755 diff --git a/jdk/bin/java b/jdk/bin/java old mode 100644 new mode 100755 diff --git a/jdk/bin/java-rmi.cgi b/jdk/bin/java-rmi.cgi old mode 100644 new mode 100755 diff --git a/jdk/bin/javac b/jdk/bin/javac old mode 100644 new mode 100755 diff --git a/jdk/bin/javadoc b/jdk/bin/javadoc old mode 100644 new mode 100755 diff --git a/jdk/bin/javah b/jdk/bin/javah old mode 100644 new mode 100755 diff --git a/jdk/bin/javap b/jdk/bin/javap old mode 100644 new mode 100755 diff --git a/jdk/bin/javaws b/jdk/bin/javaws old mode 100644 new mode 100755 diff --git a/jdk/bin/jconsole b/jdk/bin/jconsole old mode 100644 new mode 100755 diff --git a/jdk/bin/jcontrol b/jdk/bin/jcontrol old mode 100644 new mode 100755 diff --git a/jdk/bin/jdb b/jdk/bin/jdb old mode 100644 new mode 100755 diff --git a/jdk/bin/jhat b/jdk/bin/jhat old mode 100644 new mode 100755 diff --git a/jdk/bin/jinfo b/jdk/bin/jinfo old mode 100644 new mode 100755 diff --git a/jdk/bin/jmap b/jdk/bin/jmap old mode 100644 new mode 100755 diff --git a/jdk/bin/jps b/jdk/bin/jps old mode 100644 new mode 100755 diff --git a/jdk/bin/jrunscript b/jdk/bin/jrunscript old mode 100644 new mode 100755 diff --git a/jdk/bin/jsadebugd b/jdk/bin/jsadebugd old mode 100644 new mode 100755 diff --git a/jdk/bin/jstack b/jdk/bin/jstack old mode 100644 new mode 100755 diff --git a/jdk/bin/jstat b/jdk/bin/jstat old mode 100644 new mode 100755 diff --git a/jdk/bin/jstatd b/jdk/bin/jstatd old mode 100644 new mode 100755 diff --git a/jdk/bin/jvisualvm b/jdk/bin/jvisualvm old mode 100644 new mode 100755 diff --git a/jdk/bin/keytool b/jdk/bin/keytool old mode 100644 new mode 100755 diff --git a/jdk/bin/native2ascii b/jdk/bin/native2ascii old mode 100644 new mode 100755 diff --git a/jdk/bin/orbd b/jdk/bin/orbd old mode 100644 new mode 100755 diff --git a/jdk/bin/pack200 b/jdk/bin/pack200 old mode 100644 new mode 100755 diff --git a/jdk/bin/policytool b/jdk/bin/policytool old mode 100644 new mode 100755 diff --git a/jdk/bin/rmic b/jdk/bin/rmic old mode 100644 new mode 100755 diff --git a/jdk/bin/rmid b/jdk/bin/rmid old mode 100644 new mode 100755 diff --git a/jdk/bin/rmiregistry b/jdk/bin/rmiregistry old mode 100644 new mode 100755 diff --git a/jdk/bin/schemagen b/jdk/bin/schemagen old mode 100644 new mode 100755 diff --git a/jdk/bin/serialver b/jdk/bin/serialver old mode 100644 new mode 100755 diff --git a/jdk/bin/servertool b/jdk/bin/servertool old mode 100644 new mode 100755 diff --git a/jdk/bin/tnameserv b/jdk/bin/tnameserv old mode 100644 new mode 100755 diff --git a/jdk/bin/unpack200 b/jdk/bin/unpack200 old mode 100644 new mode 100755 diff --git a/jdk/bin/wsgen b/jdk/bin/wsgen old mode 100644 new mode 100755 diff --git a/jdk/bin/wsimport b/jdk/bin/wsimport old mode 100644 new mode 100755 diff --git a/jdk/bin/xjc b/jdk/bin/xjc old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/ControlPanel b/jdk/jre/bin/ControlPanel old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/java b/jdk/jre/bin/java old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/java_vm b/jdk/jre/bin/java_vm old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/javaws b/jdk/jre/bin/javaws old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/jcontrol b/jdk/jre/bin/jcontrol old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/keytool b/jdk/jre/bin/keytool old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/orbd b/jdk/jre/bin/orbd old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/pack200 b/jdk/jre/bin/pack200 old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/policytool b/jdk/jre/bin/policytool old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/rmid b/jdk/jre/bin/rmid old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/rmiregistry b/jdk/jre/bin/rmiregistry old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/servertool b/jdk/jre/bin/servertool old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/tnameserv b/jdk/jre/bin/tnameserv old mode 100644 new mode 100755 diff --git a/jdk/jre/bin/unpack200 b/jdk/jre/bin/unpack200 old mode 100644 new mode 100755 diff --git a/jdk/jre/javaws/javaws b/jdk/jre/javaws/javaws old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/deploy/messages_zh_HK.properties b/jdk/jre/lib/deploy/messages_zh_HK.properties old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/client/libjsig.so b/jdk/jre/lib/i386/client/libjsig.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/client/libjvm.so b/jdk/jre/lib/i386/client/libjvm.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/headless/libmawt.so b/jdk/jre/lib/i386/headless/libmawt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/jli/libjli.so b/jdk/jre/lib/i386/jli/libjli.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libJdbcOdbc.so b/jdk/jre/lib/i386/libJdbcOdbc.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libattach.so b/jdk/jre/lib/i386/libattach.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libawt.so b/jdk/jre/lib/i386/libawt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libcmm.so b/jdk/jre/lib/i386/libcmm.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libdcpr.so b/jdk/jre/lib/i386/libdcpr.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libdeploy.so b/jdk/jre/lib/i386/libdeploy.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libdt_socket.so b/jdk/jre/lib/i386/libdt_socket.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libfontmanager.so b/jdk/jre/lib/i386/libfontmanager.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libhprof.so b/jdk/jre/lib/i386/libhprof.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libinstrument.so b/jdk/jre/lib/i386/libinstrument.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libioser12.so b/jdk/jre/lib/i386/libioser12.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libj2gss.so b/jdk/jre/lib/i386/libj2gss.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libj2pcsc.so b/jdk/jre/lib/i386/libj2pcsc.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libj2pkcs11.so b/jdk/jre/lib/i386/libj2pkcs11.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjaas_unix.so b/jdk/jre/lib/i386/libjaas_unix.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjava.so b/jdk/jre/lib/i386/libjava.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjava_crw_demo.so b/jdk/jre/lib/i386/libjava_crw_demo.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjavaplugin_jni.so b/jdk/jre/lib/i386/libjavaplugin_jni.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjavaplugin_nscp.so b/jdk/jre/lib/i386/libjavaplugin_nscp.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjavaplugin_nscp_gcc29.so b/jdk/jre/lib/i386/libjavaplugin_nscp_gcc29.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjawt.so b/jdk/jre/lib/i386/libjawt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjdwp.so b/jdk/jre/lib/i386/libjdwp.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjpeg.so b/jdk/jre/lib/i386/libjpeg.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjsig.so b/jdk/jre/lib/i386/libjsig.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjsound.so b/jdk/jre/lib/i386/libjsound.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libjsoundalsa.so b/jdk/jre/lib/i386/libjsoundalsa.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libmanagement.so b/jdk/jre/lib/i386/libmanagement.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libmlib_image.so b/jdk/jre/lib/i386/libmlib_image.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libnet.so b/jdk/jre/lib/i386/libnet.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libnio.so b/jdk/jre/lib/i386/libnio.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libnpjp2.so b/jdk/jre/lib/i386/libnpjp2.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libnpt.so b/jdk/jre/lib/i386/libnpt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/librmi.so b/jdk/jre/lib/i386/librmi.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libsaproc.so b/jdk/jre/lib/i386/libsaproc.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libsplashscreen.so b/jdk/jre/lib/i386/libsplashscreen.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libunpack.so b/jdk/jre/lib/i386/libunpack.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libverify.so b/jdk/jre/lib/i386/libverify.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/libzip.so b/jdk/jre/lib/i386/libzip.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/motif21/libmawt.so b/jdk/jre/lib/i386/motif21/libmawt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/native_threads/libhpi.so b/jdk/jre/lib/i386/native_threads/libhpi.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/server/libjsig.so b/jdk/jre/lib/i386/server/libjsig.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/server/libjvm.so b/jdk/jre/lib/i386/server/libjvm.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/i386/xawt/libmawt.so b/jdk/jre/lib/i386/xawt/libmawt.so old mode 100644 new mode 100755 diff --git a/jdk/jre/lib/jexec b/jdk/jre/lib/jexec old mode 100644 new mode 100755 diff --git a/jdk/jre/plugin/i386/ns7-gcc29/libjavaplugin_oji.so b/jdk/jre/plugin/i386/ns7-gcc29/libjavaplugin_oji.so old mode 100644 new mode 100755 diff --git a/jdk/jre/plugin/i386/ns7/libjavaplugin_oji.so b/jdk/jre/plugin/i386/ns7/libjavaplugin_oji.so old mode 100644 new mode 100755 diff --git a/jdk/lib/jexec b/jdk/lib/jexec old mode 100644 new mode 100755 diff --git a/lib/activation.jar b/lib/activation.jar old mode 100644 new mode 100755 diff --git a/lib/annotations-api.jar b/lib/annotations-api.jar old mode 100644 new mode 100755 diff --git a/lib/catalina-ant.jar b/lib/catalina-ant.jar old mode 100644 new mode 100755 diff --git a/lib/catalina-ha.jar b/lib/catalina-ha.jar old mode 100644 new mode 100755 diff --git a/lib/catalina-tribes.jar b/lib/catalina-tribes.jar old mode 100644 new mode 100755 diff --git a/lib/catalina.jar b/lib/catalina.jar old mode 100644 new mode 100755 diff --git a/lib/derby.jar b/lib/derby.jar old mode 100644 new mode 100755 diff --git a/lib/ecj-3.7.2.jar b/lib/ecj-3.7.2.jar old mode 100644 new mode 100755 diff --git a/lib/el-api.jar b/lib/el-api.jar old mode 100644 new mode 100755 diff --git a/lib/jasper-el.jar b/lib/jasper-el.jar old mode 100644 new mode 100755 diff --git a/lib/jasper.jar b/lib/jasper.jar old mode 100644 new mode 100755 diff --git a/lib/jcr-2.0.jar b/lib/jcr-2.0.jar old mode 100644 new mode 100755 diff --git a/lib/jsp-api.jar b/lib/jsp-api.jar old mode 100644 new mode 100755 diff --git a/lib/mail.jar b/lib/mail.jar old mode 100644 new mode 100755 diff --git a/lib/mysql-connector-java-5.0.4-bin.jar b/lib/mysql-connector-java-5.0.4-bin.jar old mode 100644 new mode 100755 diff --git a/lib/postgresql.jar b/lib/postgresql.jar old mode 100644 new mode 100755 diff --git a/lib/servlet-api.jar b/lib/servlet-api.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-api.jar b/lib/tomcat-api.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-coyote.jar b/lib/tomcat-coyote.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-dbcp.jar b/lib/tomcat-dbcp.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-i18n-es.jar b/lib/tomcat-i18n-es.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-i18n-fr.jar b/lib/tomcat-i18n-fr.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-i18n-ja.jar b/lib/tomcat-i18n-ja.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-jdbc.jar b/lib/tomcat-jdbc.jar old mode 100644 new mode 100755 diff --git a/lib/tomcat-util.jar b/lib/tomcat-util.jar old mode 100644 new mode 100755 diff --git a/source/ngasi/caimito/CaimitoConfig.java b/source/ngasi/caimito/CaimitoConfig.java old mode 100644 new mode 100755 index 877ee79..4b2f832 --- a/source/ngasi/caimito/CaimitoConfig.java +++ b/source/ngasi/caimito/CaimitoConfig.java @@ -51,6 +51,7 @@ public class CaimitoConfig{ public static boolean cacheable = true; public static String serverinfo = "Caimito"; public static String CAIMITO_CSS = null; + public static String version = "0.2"; public static void init()throws CaimitoException{ if (! new File(getConfigFile()).exists()) { diff --git a/source/ngasi/caimito/CaimitoDefaultServlet.java b/source/ngasi/caimito/CaimitoDefaultServlet.java old mode 100644 new mode 100755 index 2f6ffe4..e83a8d0 --- a/source/ngasi/caimito/CaimitoDefaultServlet.java +++ b/source/ngasi/caimito/CaimitoDefaultServlet.java @@ -1,2246 +1,2246 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 ngasi.caimito; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.RandomAccessFile; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import java.util.Enumeration; - -import javax.naming.InitialContext; -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.DirContext; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.ServletResponse; -import javax.servlet.ServletResponseWrapper; -import javax.servlet.UnavailableException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.apache.catalina.Globals; -import org.apache.catalina.connector.RequestFacade; -import org.apache.catalina.connector.ResponseFacade; -import org.apache.catalina.util.RequestUtil; -import org.apache.catalina.util.ServerInfo; -import org.apache.catalina.util.URLEncoder; -import org.apache.naming.resources.CacheEntry; -import org.apache.naming.resources.ProxyDirContext; -import org.apache.naming.resources.Resource; -import org.apache.naming.resources.ResourceAttributes; -//import org.apache.tomcat.util.res.StringManager; -import org.apache.catalina.servlets.*; -import ngasi.caimito.resource.*; - -/** - *

The default resource-serving servlet for most web applications, - * used to serve static resources such as HTML pages and images. - *

- *

- * This servlet is intended to be mapped to / e.g.: - *

- *
- *   <servlet-mapping>
- *       <servlet-name>default</servlet-name>
- *       <url-pattern>/</url-pattern>
- *   </servlet-mapping>
- * 
- *

It can be mapped to sub-paths, however in all cases resources are served - * from the web appplication resource root using the full path from the root - * of the web application context. - *
e.g. given a web application structure: - *

- *
- * /context
- *   /images
- *     tomcat2.jpg
- *   /static
- *     /images
- *       tomcat.jpg
- * 
- *

- * ... and a servlet mapping that maps only /static/* to the default servlet: - *

- *
- *   <servlet-mapping>
- *       <servlet-name>default</servlet-name>
- *       <url-pattern>/static/*</url-pattern>
- *   </servlet-mapping>
- * 
- *

- * Then a request to /context/static/images/tomcat.jpg will succeed - * while a request to /context/images/tomcat2.jpg will fail. - *

- * @author Craig R. McClanahan - * @author Remy Maucherat - * @version $Id: DefaultServlet.java 1200163 2011-11-10 05:40:04Z kkolinko $ - */ - -public class CaimitoDefaultServlet - extends HttpServlet { - - private static final long serialVersionUID = 1L; - - // ----------------------------------------------------- Instance Variables - - - /** - * The debugging detail level for this servlet. - */ - protected int debug = 0; - - - /** - * The input buffer size to use when serving resources. - */ - protected int input = 2048; - - - /** - * Should we generate directory listings? - */ - protected boolean listings = false; - - - /** - * Read only flag. By default, it's set to true. - */ - protected boolean readOnly = true; - - - /** - * The output buffer size to use when serving resources. - */ - protected int output = 2048; - - - /** - * Array containing the safe characters set. - */ - protected static URLEncoder urlEncoder; - - - /** - * Allow customized directory listing per directory. - */ - protected String localXsltFile = null; - - - /** - * Allow customized directory listing per context. - */ - protected String contextXsltFile = null; - - - /** - * Allow customized directory listing per instance. - */ - protected String globalXsltFile = null; - - - /** - * Allow a readme file to be included. - */ - protected String readmeFile = null; - - - /** - * Proxy directory context. - */ - protected transient ProxyDirContext resources = null; - - - /** - * File encoding to be used when reading static files. If none is specified - * the platform default is used. - */ - protected String fileEncoding = null; - - - /** - * Minimum size for sendfile usage in bytes. - */ - protected int sendfileSize = 48 * 1024; - - /** - * Should the Accept-Ranges: bytes header be send with static resources? - */ - protected boolean useAcceptRanges = true; - - /** - * Full range marker. - */ - protected static ArrayList FULL = new ArrayList(); - - - // ----------------------------------------------------- Static Initializer - - - /** - * GMT timezone - all HTTP dates are on GMT - */ - static { - urlEncoder = new URLEncoder(); - urlEncoder.addSafeCharacter('-'); - urlEncoder.addSafeCharacter('_'); - urlEncoder.addSafeCharacter('.'); - urlEncoder.addSafeCharacter('*'); - urlEncoder.addSafeCharacter('/'); - } - - - /** - * MIME multipart separation string - */ - protected static final String mimeSeparation = "CATALINA_MIME_BOUNDARY"; - - - /** - * JNDI resources name. - */ - protected static final String RESOURCES_JNDI_NAME = "java:/comp/Resources"; - - - /** - * The string manager for this package. - */ - //protected static final StringManager sm = - // StringManager.getManager(Constants.Package); - - - /** - * Size of file transfer buffer in bytes. - */ - protected static final int BUFFER_SIZE = 4096; - - - // --------------------------------------------------------- Public Methods - - - /** - * Finalize this servlet. - */ - @Override - public void destroy() { - // NOOP - } - - - /** - * Initialize this servlet. - */ - @Override - public void init() throws ServletException { - - if (getServletConfig().getInitParameter("debug") != null) - debug = Integer.parseInt(getServletConfig().getInitParameter("debug")); - - if (getServletConfig().getInitParameter("input") != null) - input = Integer.parseInt(getServletConfig().getInitParameter("input")); - - if (getServletConfig().getInitParameter("output") != null) - output = Integer.parseInt(getServletConfig().getInitParameter("output")); - - listings = Boolean.parseBoolean(getServletConfig().getInitParameter("listings")); - - if (getServletConfig().getInitParameter("readonly") != null) - readOnly = Boolean.parseBoolean(getServletConfig().getInitParameter("readonly")); - - if (getServletConfig().getInitParameter("sendfileSize") != null) - sendfileSize = - Integer.parseInt(getServletConfig().getInitParameter("sendfileSize")) * 1024; - - fileEncoding = getServletConfig().getInitParameter("fileEncoding"); - - globalXsltFile = getServletConfig().getInitParameter("globalXsltFile"); - contextXsltFile = getServletConfig().getInitParameter("contextXsltFile"); - localXsltFile = getServletConfig().getInitParameter("localXsltFile"); - readmeFile = getServletConfig().getInitParameter("readmeFile"); - - if (getServletConfig().getInitParameter("useAcceptRanges") != null) - useAcceptRanges = Boolean.parseBoolean(getServletConfig().getInitParameter("useAcceptRanges")); - - // Sanity check on the specified buffer sizes - if (input < 256) - input = 256; - if (output < 256) - output = 256; - - if (debug > 0) { - log("DefaultServlet.init: input buffer size=" + input + - ", output buffer size=" + output); - } - - // Load the proxy dir context. - resources = (ProxyDirContext) getServletContext() - .getAttribute(Globals.RESOURCES_ATTR); - if (resources == null) { - try { - resources = - (ProxyDirContext) new InitialContext() - .lookup(RESOURCES_JNDI_NAME); - } catch (NamingException e) { - // Failed - throw new ServletException("No resources", e); - } - } - - if (resources == null) { - throw new UnavailableException("No resources"); - } - - } - - protected String smgetString(String msg,HttpServletRequest request){ - return smgetString(msg,null,request); - } - protected String smgetString(String msg,String val,HttpServletRequest request){ - try{ - String ms2 = (String)CaimitoConfig.getConfig().get(msg); - if (ms2 != null) - return ms2; - }catch (Exception e){ - e.printStackTrace(); - } - return msg; - } - - - - /*protected String checkAccess(String path, HttpServletRequest request, - HttpServletResponse response, - int acc) - throws CaimitoException { - if (path.equals("/") - { - - } - return path; - }*/ - - // ------------------------------------------------------ Protected Methods - - - /** - * Return the relative path associated with this servlet. - * - * @param request The servlet request we are processing - */ - protected String getRelativePath(HttpServletRequest request) { - // IMPORTANT: DefaultServlet can be mapped to '/' or '/path/*' but always - // serves resources from the web app root with context rooted paths. - // i.e. it can not be used to mount the web app root under a sub-path - // This method must construct a complete context rooted path, although - // subclasses can change this behaviour. - - // Are we being processed by a RequestDispatcher.include()? - if (request.getAttribute( - RequestDispatcher.INCLUDE_REQUEST_URI) != null) { - String result = (String) request.getAttribute( - RequestDispatcher.INCLUDE_PATH_INFO); - if (result == null) { - result = (String) request.getAttribute( - RequestDispatcher.INCLUDE_SERVLET_PATH); - } else { - result = (String) request.getAttribute( - RequestDispatcher.INCLUDE_SERVLET_PATH) + result; - } - if ((result == null) || (result.equals(""))) { - result = "/"; - } - result = tools.util.StringUtil.replaceSubstring(result,"..",""); - result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); - result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); - result = tools.util.StringUtil.replaceSubstring(result,":",""); - - return (result); - } - - // No, extract the desired path directly from the request - String result = request.getPathInfo(); - if (result == null) { - result = request.getServletPath(); - } else { - result = request.getServletPath() + result; - } - if ((result == null) || (result.equals(""))) { - result = "/"; - } - result = tools.util.StringUtil.replaceSubstring(result,"..",""); - result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); - result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); - result = tools.util.StringUtil.replaceSubstring(result,":",""); - - return (result); - - } - - - /** - * Determines the appropriate path to prepend resources with - * when generating directory listings. Depending on the behaviour of - * {@link #getRelativePath(HttpServletRequest)} this will change. - * @param request the request to determine the path for - * @return the prefix to apply to all resources in the listing. - */ - protected String getPathPrefix(final HttpServletRequest request) { - return request.getContextPath(); - } - - - /** - * Process a GET request for the specified resource. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doGet(HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - - // Serve the requested resource, including the data content - serveResource(request, response, true); - - } - - - /** - * Process a HEAD request for the specified resource. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doHead(HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - - // Serve the requested resource, without the data content - serveResource(request, response, false); - - } - - - /** - * Override default implementation to ensure that TRACE is correctly - * handled. - * - * @param req the {@link HttpServletRequest} object that - * contains the request the client made of - * the servlet - * - * @param resp the {@link HttpServletResponse} object that - * contains the response the servlet returns - * to the client - * - * @exception IOException if an input or output error occurs - * while the servlet is handling the - * OPTIONS request - * - * @exception ServletException if the request for the - * OPTIONS cannot be handled - */ - /*@Override - protected void doOptions(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - //("DOP 1"); - StringBuilder allow = new StringBuilder(); - // There is a doGet method - allow.append("GET, HEAD"); - // There is a doPost - allow.append(", POST"); - // There is a doPut - allow.append(", PUT"); - // There is a doDelete - allow.append(", DELETE"); - // Trace - assume disabled unless we can prove otherwise - if (req instanceof RequestFacade && - ((RequestFacade) req).getAllowTrace()) { - allow.append(", TRACE"); - } - // Always allow options - allow.append(", OPTIONS"); - - resp.setHeader("Allow", allow.toString()); - }*/ - - - /** - * Process a POST request for the specified resource. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doPost(HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { - doGet(request, response); - } - - - /** - * Process a PUT request for the specified resource. - * - * @param req The servlet request we are processing - * @param resp The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doPut(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - - String path = getRelativePath(req); - - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); - if (ro == null)return; - if (ro == null) { - resp.sendError(HttpServletResponse.SC_FORBIDDEN); - return; - } - - - boolean exists = ro.exists(); - //(path + " EXISTSRE " + exists); - - //boolean result = true; - - // Temp. content file used to support partial PUT - //File contentFile = null; - - //Range range = parseContentRange(req, resp); - - InputStream resourceInputStream = null; - - // Append data specified in ranges to existing content for this - // resource - create a temp. file on the local filesystem to - // perform this operation - // Assume just one range is specified for now - //if (range != null) { - // contentFile = executePartialPut(req, range, path); - // resourceInputStream = new FileInputStream(contentFile); - // } else { - resourceInputStream = req.getInputStream(); - // } - - String ct = getServletContext().getMimeType(ro.getName()); - ro.contentType = ct; - ro.contentLength = req.getContentLength(); - ro.write(resourceInputStream); - - /*try { - Resource newResource = new Resource(resourceInputStream); - // FIXME: Add attributes - if (exists) { - resources.rebind(path, newResource); - } else { - resources.bind(path, newResource); - } - } catch(NamingException e) { - result = false; - }*/ - - //if (result) { - if (exists) { - resp.setStatus(HttpServletResponse.SC_NO_CONTENT); - } else { - resp.setStatus(HttpServletResponse.SC_CREATED); - } - // } else { - // resp.sendError(HttpServletResponse.SC_CONFLICT); - // } - - } - - - /** - * Handle a partial PUT. New content specified in request is appended to - * existing content in oldRevisionContent (if present). This code does - * not support simultaneous partial updates to the same resource. - */ - /*protected File executePartialPut(HttpServletRequest req, Range range, - String path) - throws IOException { - - // Append data specified in ranges to existing content for this - // resource - create a temp. file on the local filesystem to - // perform this operation - File tempDir = (File) getServletContext().getAttribute - (ServletContext.TEMPDIR); - // Convert all '/' characters to '.' in resourcePath - String convertedResourcePath = path.replace('/', '.'); - File contentFile = new File(tempDir, convertedResourcePath); - if (contentFile.createNewFile()) { - // Clean up contentFile when Tomcat is terminated - contentFile.deleteOnExit(); - } - - RandomAccessFile randAccessContentFile = - new RandomAccessFile(contentFile, "rw"); - - Resource oldResource = null; - try { - Object obj = resources.lookup(path); - if (obj instanceof Resource) - oldResource = (Resource) obj; - } catch (NamingException e) { - // Ignore - } - - // Copy data in oldRevisionContent to contentFile - if (oldResource != null) { - BufferedInputStream bufOldRevStream = - new BufferedInputStream(oldResource.streamContent(), - BUFFER_SIZE); - - int numBytesRead; - byte[] copyBuffer = new byte[BUFFER_SIZE]; - while ((numBytesRead = bufOldRevStream.read(copyBuffer)) != -1) { - randAccessContentFile.write(copyBuffer, 0, numBytesRead); - } - - bufOldRevStream.close(); - } - - randAccessContentFile.setLength(range.length); - - // Append data in request input stream to contentFile - randAccessContentFile.seek(range.start); - int numBytesRead; - byte[] transferBuffer = new byte[BUFFER_SIZE]; - BufferedInputStream requestBufInStream = - new BufferedInputStream(req.getInputStream(), BUFFER_SIZE); - while ((numBytesRead = requestBufInStream.read(transferBuffer)) != -1) { - randAccessContentFile.write(transferBuffer, 0, numBytesRead); - } - randAccessContentFile.close(); - requestBufInStream.close(); - - return contentFile; - - }*/ - - - /** - * Process a DELETE request for the specified resource. - * - * @param req The servlet request we are processing - * @param resp The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - /*if (readOnly) { - resp.sendError(HttpServletResponse.SC_FORBIDDEN); - return; - }*/ - - String path = getRelativePath(req); - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); - if (ro == null)return; - - if (!ro.canWrite()) { - resp.sendError(HttpServletResponse.SC_FORBIDDEN); - return; - } - - boolean exists = ro.exists(); - - - /*try { - resources.lookup(path); - } catch (NamingException e) { - exists = false; - }*/ - - if (exists) { - boolean result = true; - try { - ro.delete(); - } catch (Exception e) { - result = false; - } - if (result) { - resp.setStatus(HttpServletResponse.SC_NO_CONTENT); - } else { - resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - } - } else { - resp.sendError(HttpServletResponse.SC_NOT_FOUND); - } - - } - - - /** - * Check if the conditions specified in the optional If headers are - * satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes The resource information - * @return boolean true if the resource meets all the specified conditions, - * and false if any of the conditions is not satisfied, in which case - * request processing is stopped - */ - protected boolean checkIfHeaders(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) - throws IOException,CaimitoException { - - return checkIfMatch(request, response, resourceAttributes) - && checkIfModifiedSince(request, response, resourceAttributes) - && checkIfNoneMatch(request, response, resourceAttributes) - && checkIfUnmodifiedSince(request, response, resourceAttributes); - - } - - - /** - * URL rewriter. - * - * @param path Path which has to be rewritten - */ - protected String rewriteUrl(String path) { - return urlEncoder.encode( path ); - } - - - /** - * Display the size of a file. - */ - protected void displaySize(StringBuilder buf, int filesize) { - - int leftside = filesize / 1024; - int rightside = (filesize % 1024) / 103; // makes 1 digit - // To avoid 0.0 for non-zero file, we bump to 0.1 - if (leftside == 0 && rightside == 0 && filesize != 0) - rightside = 1; - buf.append(leftside).append(".").append(rightside); - buf.append(" KB"); - - } - - - /** - * Serve the specified resource, optionally including the data content. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param content Should the content be included? - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - protected void serveResource(HttpServletRequest request, - HttpServletResponse response, - boolean content) - throws IOException, ServletException { - - boolean serveContent = content; - - // Identify the requested resource path - String path = getRelativePath(request); - ResourceObj ro = ResourceStore.lookup(path,request,response,ResourceStore.READ); - - if (ro == null)return; - - if (!ro.canRead()) { - response.sendError(HttpServletResponse.SC_FORBIDDEN); - return; - } - - if (debug > 0) { - if (serveContent) - log("DefaultServlet.serveResource: Serving resource '" + - path + "' headers and data"); - else - log("DefaultServlet.serveResource: Serving resource '" + - path + "' headers only"); - } - - // CacheEntry cacheEntry = resources.lookupCache(path); - - if (!ro.exists()) { - // Check if we're included so we can return the appropriate - // missing resource name in the error - String requestUri = (String) request.getAttribute( - RequestDispatcher.INCLUDE_REQUEST_URI); - if (requestUri == null) { - requestUri = request.getRequestURI(); - } else { - // We're included - // SRV.9.3 says we must throw a FNFE - throw new FileNotFoundException( - "defaultServlet.missingResource"); - } - - response.sendError(HttpServletResponse.SC_NOT_FOUND, - requestUri); - return; - } - - // If the resource is not a collection, and the resource path - // ends with "/" or "\", return NOT FOUND - if (!ro.isDirectory()) { - if (path.endsWith("/") || (path.endsWith("\\"))) { - // Check if we're included so we can return the appropriate - // missing resource name in the error - String requestUri = (String) request.getAttribute( - RequestDispatcher.INCLUDE_REQUEST_URI); - if (requestUri == null) { - requestUri = request.getRequestURI(); - } - response.sendError(HttpServletResponse.SC_NOT_FOUND, - requestUri); - return; - } - } - - boolean isError = - response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST; - - // Check if the conditions specified in the optional If headers are - // satisfied. - if (!ro.isDirectory()) { - - // Checking If headers - boolean included = (request.getAttribute( - RequestDispatcher.INCLUDE_CONTEXT_PATH) != null); - if (!included && !isError && - !checkIfHeaders(request, response, ro)) { - return; - } - - } - - // Find content type. - String contentType = ro.getMimeType(); - if (contentType == null) { - contentType = getServletContext().getMimeType(ro.path); - ro.setMimeType(contentType); - } - - ArrayList ranges = null; - long contentLength = -1L; - - if (ro.isDirectory()) { - - // Skip directory listings if we have been configured to - // suppress them - if (!ro.listings()) { - response.sendError(HttpServletResponse.SC_NOT_FOUND, - request.getRequestURI()); - return; - } - contentType = "text/html;charset=UTF-8"; - - } else { - if (!isError) { - if (useAcceptRanges) { - // Accept ranges header - response.setHeader("Accept-Ranges", "bytes"); - } - - // Parse range specifier - ranges = parseRange(request, response, ro); - - // ETag header - response.setHeader("ETag", ro.getETag()); - - // Last-Modified header - response.setHeader("Last-Modified", - ro.getLastModifiedHttp()); - } - - // Get content length - contentLength = ro.getContentLength(); - // Special case for zero length files, which would cause a - // (silent) ISE when setting the output buffer size - if (contentLength == 0L) { - serveContent = false; - //("SERVER CONTENT = fale"); - } - - } -//(contentType + " serveContent " + serveContent); - ServletOutputStream ostream = null; - PrintWriter writer = null; - - if (serveContent) { - - // Trying to retrieve the servlet output stream - - try { - ostream = response.getOutputStream(); - } catch (IllegalStateException e) { - // If it fails, we try to get a Writer instead if we're - // trying to serve a text file - if ( (contentType == null) - || (contentType.startsWith("text")) - || (contentType.endsWith("xml")) - || (contentType.contains("/javascript")) ) { - writer = response.getWriter(); - // Cannot reliably serve partial content with a Writer - ranges = FULL; - } else { - throw e; - } - } - - } - - // Check to see if a Filter, Valve of wrapper has written some content. - // If it has, disable range requests and setting of a content length - // since neither can be done reliably. - ServletResponse r = response; - long contentWritten = 0; - while (r instanceof ServletResponseWrapper) { - r = ((ServletResponseWrapper) r).getResponse(); - } - if (r instanceof ResponseFacade) { - contentWritten = ((ResponseFacade) r).getContentWritten(); - } - if (contentWritten > 0) { - ranges = FULL; - } - - if ( (ro.isDirectory()) - || isError - || ( ((ranges == null) || (ranges.isEmpty())) - && (request.getHeader("Range") == null) ) - || (ranges == FULL) ) { - - // Set the appropriate output headers - if (contentType != null) { - if (debug > 0) - log("DefaultServlet.serveFile: contentType='" + - contentType + "'"); - response.setContentType(contentType); - } - //???(cacheEntry.resource != null) && - if ( (contentLength >= 0) - && (!serveContent || ostream != null)) { - if (debug > 0) - log("DefaultServlet.serveFile: contentLength=" + - contentLength); - // Don't set a content length if something else has already - // written to the response. - if (contentWritten == 0) { - if (contentLength < Integer.MAX_VALUE) { - response.setContentLength((int) contentLength); - } else { - // Set the content-length as String to be able to use a - // long - response.setHeader("content-length", - "" + contentLength); - } - } - } - - InputStream renderResult = null; - if (ro.isDirectory()) { - - if (serveContent) { - // Serve the directory browser - renderResult = render(getPathPrefix(request), ro,request); - } - - } - - // Copy the input stream to our output stream (if requested) - if (serveContent) { - try { - response.setBufferSize(output); - } catch (IllegalStateException e) { - // Silent catch - } - if (ostream != null ) { - if (!checkSendfile(request, response, ro, contentLength, null)) - copy(ro, renderResult, ostream); - } else { - //(writer + " SENDY FDIR " + renderResult); - copy(ro, renderResult, writer); - } - } - - } else { - - if ((ranges == null) || (ranges.isEmpty())) - return; - - // Partial content response. - - response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); - - if (ranges.size() == 1) { - - Range range = ranges.get(0); - response.addHeader("Content-Range", "bytes " - + range.start - + "-" + range.end + "/" - + range.length); - long length = range.end - range.start + 1; - if (length < Integer.MAX_VALUE) { - response.setContentLength((int) length); - } else { - // Set the content-length as String to be able to use a long - response.setHeader("content-length", "" + length); - } - - if (contentType != null) { - if (debug > 0) - log("DefaultServlet.serveFile: contentType='" + - contentType + "'"); - response.setContentType(contentType); - } - - if (serveContent) { - try { - response.setBufferSize(output); - } catch (IllegalStateException e) { - // Silent catch - } - if (ostream != null) { - if (!checkSendfile(request, response, ro, range.end - range.start + 1, range)) - copy(ro, ostream, range,request); - } else { - // we should not get here - throw new IllegalStateException(); - } - } - - } else { - - response.setContentType("multipart/byteranges; boundary=" - + mimeSeparation); - - if (serveContent) { - try { - response.setBufferSize(output); - } catch (IllegalStateException e) { - // Silent catch - } - if (ostream != null) { - copy(ro, ostream, ranges.iterator(), - contentType,request); - } else { - // we should not get here - throw new IllegalStateException(); - } - } - - } - - } - - } - - - /** - * Parse the content-range header. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @return Range - */ - protected Range parseContentRange(HttpServletRequest request, - HttpServletResponse response) - throws IOException { - - // Retrieving the content-range header (if any is specified - String rangeHeader = request.getHeader("Content-Range"); - - if (rangeHeader == null) - return null; - - // bytes is the only range unit supported - if (!rangeHeader.startsWith("bytes")) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return null; - } - - rangeHeader = rangeHeader.substring(6).trim(); - - int dashPos = rangeHeader.indexOf('-'); - int slashPos = rangeHeader.indexOf('/'); - - if (dashPos == -1) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return null; - } - - if (slashPos == -1) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return null; - } - - Range range = new Range(); - - try { - range.start = Long.parseLong(rangeHeader.substring(0, dashPos)); - range.end = - Long.parseLong(rangeHeader.substring(dashPos + 1, slashPos)); - range.length = Long.parseLong - (rangeHeader.substring(slashPos + 1, rangeHeader.length())); - } catch (NumberFormatException e) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return null; - } - - if (!range.validate()) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return null; - } - - return range; - - } - - - /** - * Parse the range header. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @return Vector of ranges - */ - protected ArrayList parseRange(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) throws CaimitoException,IOException { - - // Checking If-Range - String headerValue = request.getHeader("If-Range"); - - if (headerValue != null) { - - long headerValueTime = (-1L); - try { - headerValueTime = request.getDateHeader("If-Range"); - } catch (IllegalArgumentException e) { - // Ignore - } - - String eTag = resourceAttributes.getETag(); - long lastModified = resourceAttributes.getLastModified(); - - if (headerValueTime == (-1L)) { - - // If the ETag the client gave does not match the entity - // etag, then the entire entity is returned. - if (!eTag.equals(headerValue.trim())) - return FULL; - - } else { - - // If the timestamp of the entity the client got is older than - // the last modification date of the entity, the entire entity - // is returned. - if (lastModified > (headerValueTime + 1000)) - return FULL; - - } - - } - - long fileLength = resourceAttributes.getContentLength(); - - if (fileLength == 0) - return null; - - // Retrieving the range header (if any is specified - String rangeHeader = request.getHeader("Range"); - - if (rangeHeader == null) - return null; - // bytes is the only range unit supported (and I don't see the point - // of adding new ones). - if (!rangeHeader.startsWith("bytes")) { - response.addHeader("Content-Range", "bytes */" + fileLength); - response.sendError - (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return null; - } - - rangeHeader = rangeHeader.substring(6); - - // Vector which will contain all the ranges which are successfully - // parsed. - ArrayList result = new ArrayList(); - StringTokenizer commaTokenizer = new StringTokenizer(rangeHeader, ","); - - // Parsing the range list - while (commaTokenizer.hasMoreTokens()) { - String rangeDefinition = commaTokenizer.nextToken().trim(); - - Range currentRange = new Range(); - currentRange.length = fileLength; - - int dashPos = rangeDefinition.indexOf('-'); - - if (dashPos == -1) { - response.addHeader("Content-Range", "bytes */" + fileLength); - response.sendError - (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return null; - } - - if (dashPos == 0) { - - try { - long offset = Long.parseLong(rangeDefinition); - currentRange.start = fileLength + offset; - currentRange.end = fileLength - 1; - } catch (NumberFormatException e) { - response.addHeader("Content-Range", - "bytes */" + fileLength); - response.sendError - (HttpServletResponse - .SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return null; - } - - } else { - - try { - currentRange.start = Long.parseLong - (rangeDefinition.substring(0, dashPos)); - if (dashPos < rangeDefinition.length() - 1) - currentRange.end = Long.parseLong - (rangeDefinition.substring - (dashPos + 1, rangeDefinition.length())); - else - currentRange.end = fileLength - 1; - } catch (NumberFormatException e) { - response.addHeader("Content-Range", - "bytes */" + fileLength); - response.sendError - (HttpServletResponse - .SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return null; - } - - } - - if (!currentRange.validate()) { - response.addHeader("Content-Range", "bytes */" + fileLength); - response.sendError - (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); - return null; - } - - result.add(currentRange); - } - - return result; - } - - - - /** - * Decide which way to render. HTML or XML. - */ - protected InputStream render(String contextPath, ResourceObj cacheEntry,HttpServletRequest request) - throws IOException, ServletException { - - //InputStream xsltInputStream = - // findXsltInputStream(cacheEntry.context); - - //if (xsltInputStream==null) { - return renderHtml(contextPath, cacheEntry,request); - //} - //return renderXml(contextPath, cacheEntry, xsltInputStream); - - } - - /** - * Return an InputStream to an HTML representation of the contents - * of this directory. - * - * @param contextPath Context path to which our internal paths are - * relative - */ - protected InputStream renderXml(String contextPath, - ResourceObj ro, - InputStream xsltInputStream) - throws IOException, ServletException { - - StringBuilder sb = new StringBuilder(); - - sb.append(""); - sb.append(""); - - sb.append(""); - - try { - - // Render the directory entries within this directory - Enumeration enumeration = - ro.list().elements(); - - // rewriteUrl(contextPath) is expensive. cache result for later reuse - String rewrittenContextPath = rewriteUrl(contextPath); - - while (enumeration.hasMoreElements()) { - - ResourceObj ncPair = enumeration.nextElement(); - String resourceName = ncPair.getName(); - String trimmed = resourceName/*.substring(trim)*/; - // if (trimmed.equalsIgnoreCase("WEB-INF") || - // trimmed.equalsIgnoreCase("META-INF") || - // trimmed.equalsIgnoreCase(localXsltFile)) - // continue; - - // if ((cacheEntry.name + trimmed).equals(contextXsltFile)) - // continue; - - // CacheEntry childCacheEntry = - // resources.lookupCache(cacheEntry.name + resourceName); - // if (!childCacheEntry.exists) { - // continue; - // } - - sb.append(""); - sb.append(RequestUtil.filter(trimmed)); - if (ncPair.isDirectory()) - sb.append("/"); - sb.append(""); - - } - - } catch (Exception e) { - // Something went wrong - throw new ServletException("Error accessing resource", e); - } - - sb.append(""); - - String readme = getReadme(ro); - - if (readme!=null) { - sb.append(""); - } - - - sb.append(""); - - - try { - TransformerFactory tFactory = TransformerFactory.newInstance(); - Source xmlSource = new StreamSource(new StringReader(sb.toString())); - Source xslSource = new StreamSource(xsltInputStream); - Transformer transformer = tFactory.newTransformer(xslSource); - - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8"); - StreamResult out = new StreamResult(osWriter); - transformer.transform(xmlSource, out); - osWriter.flush(); - return (new ByteArrayInputStream(stream.toByteArray())); - } catch (TransformerException e) { - throw new ServletException("XSL transformer error", e); - } - } - - /** - * Return an InputStream to an HTML representation of the contents - * of this directory. - * - * @param contextPath Context path to which our internal paths are - * relative - */ - protected InputStream renderHtml(String contextPath, ResourceObj ro,HttpServletRequest request) - throws IOException, ServletException { - - String name = ro.path; - - // Prepare a writer to a buffered area - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8"); - PrintWriter writer = new PrintWriter(osWriter); - - StringBuilder sb = new StringBuilder(); - - // rewriteUrl(contextPath) is expensive. cache result for later reuse - String rewrittenContextPath = rewriteUrl(contextPath); - - // Render the page header - sb.append("\r\n"); - sb.append("\r\n"); - sb.append(""); - sb.append(smgetString("directory.title", name,request)); - sb.append("\r\n"); - sb.append(" "); - sb.append("\r\n"); - sb.append(""); - sb.append("

"); - sb.append(smgetString("directory.title", name,request)); - - // Render the link to our parent (if required) - String parentDirectory = name; - if (parentDirectory.endsWith("/")) { - parentDirectory = - parentDirectory.substring(0, parentDirectory.length() - 1); - } - int slash = parentDirectory.lastIndexOf('/'); - if (slash >= 0) { - String parent = name.substring(0, slash); - sb.append(" - "); - sb.append(""); - sb.append(smgetString("directory.parent", parent,request)); - sb.append(""); - sb.append(""); - } - - sb.append("

"); - sb.append("
"); - - sb.append("\r\n"); - - // Render the column headings - sb.append("\r\n"); - sb.append("\r\n"); - sb.append("\r\n"); - sb.append("\r\n"); - sb.append(""); - - try { - - // Render the directory entries within this directory - Enumeration enumeration = - ro.list().elements(); - boolean shade = false; - while (enumeration.hasMoreElements()) { - - ResourceObj ncPair = enumeration.nextElement(); - String resourceName = ncPair.getName(); - //(ro.path + " GET 1 " + ncPair + ":" + resourceName); - String trimmed = resourceName/*.substring(trim)*/; - //if (trimmed.equalsIgnoreCase("WEB-INF") || - // trimmed.equalsIgnoreCase("META-INF")) - // continue; - - // CacheEntry childCacheEntry = - // resources.lookupCache(cacheEntry.name + resourceName); - //if (!childCacheEntry.exists) { - // continue; - //} - - sb.append("\r\n"); - shade = !shade; - - sb.append("\r\n"); - - sb.append("\r\n"); - - sb.append("\r\n"); - - sb.append("\r\n"); - } - - } catch (Exception e) { - // Something went wrong - throw new ServletException("Error accessing resource", e); - } - - // Render the page footer - sb.append("
"); - sb.append(smgetString("directory.filename",request)); - sb.append(""); - sb.append(smgetString("directory.size",request)); - sb.append(""); - sb.append(smgetString("directory.lastModified",request)); - sb.append("
  \r\n"); - sb.append(""); - sb.append(RequestUtil.filter(trimmed)); - if (ncPair.isDirectory()) - sb.append("/"); - sb.append(""); - if (ncPair.isDirectory()) - sb.append(" "); - else - sb.append(renderSize(ncPair.getContentLength())); - sb.append(""); - sb.append(ncPair.getLastModifiedHttp()); - sb.append("
\r\n"); - - sb.append("
"); - - String readme = getReadme(ro); - if (readme!=null) { - sb.append(readme); - sb.append("
"); - } - - sb.append("

").append(CaimitoConfig.serverinfo).append("

"); - sb.append("\r\n"); - sb.append("\r\n"); - - // Return an input stream to the underlying bytes - writer.write(sb.toString()); - writer.flush(); - return (new ByteArrayInputStream(stream.toByteArray())); - - } - - - /** - * Render the specified file size (in bytes). - * - * @param size File size (in bytes) - */ - protected String renderSize(long size) { - - long leftSide = size / 1024; - long rightSide = (size % 1024) / 103; // Makes 1 digit - if ((leftSide == 0) && (rightSide == 0) && (size > 0)) - rightSide = 1; - - return ("" + leftSide + "." + rightSide + " kb"); - - } - - - /** - * Get the readme file as a string. - */ - protected String getReadme(ResourceObj directory) - throws CaimitoException,IOException { - ResourceObj rmf = directory.getReadmeFile(); - if (rmf != null) { - try { - //Object obj = directory.lookup(readmeFile); - // if ((obj != null) && (obj instanceof Resource)) { - StringWriter buffer = new StringWriter(); - InputStream is = rmf.getInputStream(); - //((Resource) obj).streamContent(); - copyRange(new InputStreamReader(is), - new PrintWriter(buffer)); - return buffer.toString(); - // } - } catch (Exception e) { - if (debug > 10) - log("readme '" + readmeFile + "' not found", e); - - return null; - } - } - - return null; - } - - - /** - * Return the xsl template inputstream (if possible) - */ - protected InputStream findXsltInputStream(DirContext directory) - throws IOException { - - if (localXsltFile != null) { - try { - Object obj = directory.lookup(localXsltFile); - if ((obj != null) && (obj instanceof Resource)) { - InputStream is = ((Resource) obj).streamContent(); - if (is != null) - return is; - } - } catch (NamingException e) { - if (debug > 10) - log("localXsltFile '" + localXsltFile + "' not found", e); - } - } - - if (contextXsltFile != null) { - InputStream is = - getServletContext().getResourceAsStream(contextXsltFile); - if (is != null) - return is; - - if (debug > 10) - log("contextXsltFile '" + contextXsltFile + "' not found"); - } - - /* Open and read in file in one fell swoop to reduce chance - * chance of leaving handle open. - */ - if (globalXsltFile!=null) { - FileInputStream fis = null; - - try { - File f = new File(globalXsltFile); - if (f.exists()){ - fis =new FileInputStream(f); - byte b[] = new byte[(int)f.length()]; /* danger! */ - fis.read(b); - return new ByteArrayInputStream(b); - } - } finally { - if (fis!=null) - fis.close(); - } - } - - return null; - - } - - - // -------------------------------------------------------- protected Methods - - - /** - * Check if sendfile can be used. - */ - protected boolean checkSendfile(HttpServletRequest request, - HttpServletResponse response, - ResourceObj entry, - long length, Range range) { - /*if ((sendfileSize > 0) - - && ((length > sendfileSize) || (entry.getContentLength() > 0)) - && (entry.getCanonicalPath() != null) - && (Boolean.TRUE == request.getAttribute("org.apache.tomcat.sendfile.support")) - && (request.getClass().getName().equals("org.apache.catalina.connector.RequestFacade")) - && (response.getClass().getName().equals("org.apache.catalina.connector.ResponseFacade"))) { - request.setAttribute("org.apache.tomcat.sendfile.filename", entry.getCanonicalPath()); - if (range == null) { - request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(0L)); - request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(length)); - } else { - request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(range.start)); - request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(range.end + 1)); - } - return true; - }*/ - return false; - } - - - /** - * Check if the if-match condition is satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes File object - * @return boolean true if the resource meets the specified condition, - * and false if the condition is not satisfied, in which case request - * processing is stopped - */ - protected boolean checkIfMatch(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) - throws CaimitoException,IOException { - - String eTag = resourceAttributes.getETag(); - String headerValue = request.getHeader("If-Match"); - if (headerValue != null) { - if (headerValue.indexOf('*') == -1) { - - StringTokenizer commaTokenizer = new StringTokenizer - (headerValue, ","); - boolean conditionSatisfied = false; - - while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { - String currentToken = commaTokenizer.nextToken(); - if (currentToken.trim().equals(eTag)) - conditionSatisfied = true; - } - - // If none of the given ETags match, 412 Precodition failed is - // sent back - if (!conditionSatisfied) { - response.sendError - (HttpServletResponse.SC_PRECONDITION_FAILED); - return false; - } - - } - } - return true; - - } - - - /** - * Check if the if-modified-since condition is satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes File object - * @return boolean true if the resource meets the specified condition, - * and false if the condition is not satisfied, in which case request - * processing is stopped - */ - protected boolean checkIfModifiedSince(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) { - try { - long headerValue = request.getDateHeader("If-Modified-Since"); - long lastModified = resourceAttributes.getLastModified(); - if (headerValue != -1) { - - // If an If-None-Match header has been specified, if modified since - // is ignored. - if ((request.getHeader("If-None-Match") == null) - && (lastModified < headerValue + 1000)) { - // The entity has not been modified since the date - // specified by the client. This is not an error case. - response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); - response.setHeader("ETag", resourceAttributes.getETag()); - - return false; - } - } - } catch (Exception illegalArgument) { - return true; - } - return true; - - } - - - /** - * Check if the if-none-match condition is satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes File object - * @return boolean true if the resource meets the specified condition, - * and false if the condition is not satisfied, in which case request - * processing is stopped - */ - protected boolean checkIfNoneMatch(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) - throws CaimitoException,IOException { - - String eTag = resourceAttributes.getETag(); - String headerValue = request.getHeader("If-None-Match"); - if (headerValue != null) { - - boolean conditionSatisfied = false; - - if (!headerValue.equals("*")) { - - StringTokenizer commaTokenizer = - new StringTokenizer(headerValue, ","); - - while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { - String currentToken = commaTokenizer.nextToken(); - if (currentToken.trim().equals(eTag)) - conditionSatisfied = true; - } - - } else { - conditionSatisfied = true; - } - - if (conditionSatisfied) { - - // For GET and HEAD, we should respond with - // 304 Not Modified. - // For every other method, 412 Precondition Failed is sent - // back. - if ( ("GET".equals(request.getMethod())) - || ("HEAD".equals(request.getMethod())) ) { - response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); - response.setHeader("ETag", eTag); - - return false; - } - response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); - return false; - } - } - return true; - - } - - - /** - * Check if the if-unmodified-since condition is satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes File object - * @return boolean true if the resource meets the specified condition, - * and false if the condition is not satisfied, in which case request - * processing is stopped - */ - protected boolean checkIfUnmodifiedSince(HttpServletRequest request, - HttpServletResponse response, - ResourceObj resourceAttributes) - throws CaimitoException { - try { - long lastModified = resourceAttributes.getLastModified(); - long headerValue = request.getDateHeader("If-Unmodified-Since"); - if (headerValue != -1) { - if ( lastModified >= (headerValue + 1000)) { - // The entity has not been modified since the date - // specified by the client. This is not an error case. - response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); - return false; - } - } - } catch(Exception illegalArgument) { - return true; - } - return true; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param cacheEntry The cache entry for the source resource - * @param is The input stream to read the source resource from - * @param ostream The output stream to write to - * - * @exception IOException if an input/output error occurs - */ - protected void copy(ResourceObj cacheEntry, InputStream is, - ServletOutputStream ostream) - throws CaimitoException,IOException { - - IOException exception = null; - InputStream resourceInputStream = null; - - // Optimization: If the binary content has already been loaded, send - // it directly - //("cacheEntry.resource 1 " + cacheEntry); - if (!cacheEntry.isDirectory() && cacheEntry.getContentLength() >0) { - /*byte buffer[] = cacheEntry.resource.getContent(); - if (buffer != null) { - //("cacheEntry.resource 2 " + cacheEntry); - - ostream.write(buffer, 0, buffer.length); - return; - }*/ - resourceInputStream = cacheEntry.getInputStream(); - } else { - resourceInputStream = is; - } - - InputStream istream = new BufferedInputStream - (resourceInputStream, input); - - // Copy the input stream to the output stream - exception = copyRange(istream, ostream); - - // Clean up the input stream - istream.close(); - - // Rethrow any exception that has occurred - if (exception != null) - throw exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param cacheEntry The cache entry for the source resource - * @param is The input stream to read the source resource from - * @param writer The writer to write to - * - * @exception IOException if an input/output error occurs - */ - protected void copy(ResourceObj cacheEntry, InputStream is, PrintWriter writer) - throws CaimitoException,IOException { - - IOException exception = null; - - InputStream resourceInputStream = null; - if (!cacheEntry.isDirectory() && cacheEntry.getContentLength() > 0) { - resourceInputStream = cacheEntry.getInputStream(); - } else { - resourceInputStream = is; - } - - Reader reader; - if (fileEncoding == null) { - reader = new InputStreamReader(resourceInputStream); - } else { - reader = new InputStreamReader(resourceInputStream, - fileEncoding); - } - - // Copy the input stream to the output stream - exception = copyRange(reader, writer); - - // Clean up the reader - reader.close(); - - // Rethrow any exception that has occurred - if (exception != null) - throw exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param cacheEntry The cache entry for the source resource - * @param ostream The output stream to write to - * @param range Range the client wanted to retrieve - * @exception IOException if an input/output error occurs - */ - protected void copy(ResourceObj cacheEntry, ServletOutputStream ostream, - Range range,HttpServletRequest request) - throws CaimitoException,IOException { - - IOException exception = null; - - InputStream resourceInputStream = cacheEntry.getInputStream(); - InputStream istream = - new BufferedInputStream(resourceInputStream, input); - exception = copyRange(istream, ostream, range.start, range.end,request); - - // Clean up the input stream - istream.close(); - - // Rethrow any exception that has occurred - if (exception != null) - throw exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param cacheEntry The cache entry for the source resource - * @param ostream The output stream to write to - * @param ranges Enumeration of the ranges the client wanted to retrieve - * @param contentType Content type of the resource - * @exception IOException if an input/output error occurs - */ - protected void copy(ResourceObj cacheEntry, ServletOutputStream ostream, - Iterator ranges, String contentType,HttpServletRequest request) - throws CaimitoException,IOException { - - IOException exception = null; - - while ( (exception == null) && (ranges.hasNext()) ) { - - InputStream resourceInputStream = cacheEntry.getInputStream(); - InputStream istream = - new BufferedInputStream(resourceInputStream, input); - - Range currentRange = ranges.next(); - - // Writing MIME header. - ostream.println(); - ostream.println("--" + mimeSeparation); - if (contentType != null) - ostream.println("Content-Type: " + contentType); - ostream.println("Content-Range: bytes " + currentRange.start - + "-" + currentRange.end + "/" - + currentRange.length); - ostream.println(); - - // Printing content - exception = copyRange(istream, ostream, currentRange.start, - currentRange.end,request); - - istream.close(); - - } - - ostream.println(); - ostream.print("--" + mimeSeparation + "--"); - - // Rethrow any exception that has occurred - if (exception != null) - throw exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param istream The input stream to read from - * @param ostream The output stream to write to - * @return Exception which occurred during processing - */ - protected IOException copyRange(InputStream istream, - ServletOutputStream ostream) { - - // Copy the input stream to the output stream - IOException exception = null; - byte buffer[] = new byte[input]; - int len = buffer.length; - while (true) { - try { - len = istream.read(buffer); - if (len == -1) - break; - ostream.write(buffer, 0, len); - } catch (IOException e) { - exception = e; - len = -1; - break; - } - } - return exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param reader The reader to read from - * @param writer The writer to write to - * @return Exception which occurred during processing - */ - protected IOException copyRange(Reader reader, PrintWriter writer) { - - // Copy the input stream to the output stream - IOException exception = null; - char buffer[] = new char[input]; - int len = buffer.length; - while (true) { - try { - len = reader.read(buffer); - if (len == -1) - break; - writer.write(buffer, 0, len); - } catch (IOException e) { - exception = e; - len = -1; - break; - } - } - return exception; - - } - - - /** - * Copy the contents of the specified input stream to the specified - * output stream, and ensure that both streams are closed before returning - * (even in the face of an exception). - * - * @param istream The input stream to read from - * @param ostream The output stream to write to - * @param start Start of the range which will be copied - * @param end End of the range which will be copied - * @return Exception which occurred during processing - */ - protected IOException copyRange(InputStream istream, - ServletOutputStream ostream, - long start, long end,HttpServletRequest request) { - - if (debug > 10) - log("Serving bytes:" + start + "-" + end); - - long skipped = 0; - try { - skipped = istream.skip(start); - } catch (IOException e) { - return e; - } - if (skipped < start) { - return new IOException(smgetString("defaultservlet.skipfail", - ("" +skipped),request)); - } - - IOException exception = null; - long bytesToRead = end - start + 1; - - byte buffer[] = new byte[input]; - int len = buffer.length; - while ( (bytesToRead > 0) && (len >= buffer.length)) { - try { - len = istream.read(buffer); - if (bytesToRead >= len) { - ostream.write(buffer, 0, len); - bytesToRead -= len; - } else { - ostream.write(buffer, 0, (int) bytesToRead); - bytesToRead = 0; - } - } catch (IOException e) { - exception = e; - len = -1; - } - if (len < buffer.length) - break; - } - - return exception; - - } - - - // ------------------------------------------------------ Range Inner Class - - - protected static class Range { - - public long start; - public long end; - public long length; - - /** - * Validate range. - */ - public boolean validate() { - if (end >= length) - end = length - 1; - return (start >= 0) && (end >= 0) && (start <= end) && (length > 0); - } - } -} +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 ngasi.caimito; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.RandomAccessFile; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.StringTokenizer; +import java.util.Enumeration; + +import javax.naming.InitialContext; +import javax.naming.NameClassPair; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.ServletResponse; +import javax.servlet.ServletResponseWrapper; +import javax.servlet.UnavailableException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.apache.catalina.Globals; +import org.apache.catalina.connector.RequestFacade; +import org.apache.catalina.connector.ResponseFacade; +import org.apache.catalina.util.RequestUtil; +import org.apache.catalina.util.ServerInfo; +import org.apache.catalina.util.URLEncoder; +import org.apache.naming.resources.CacheEntry; +import org.apache.naming.resources.ProxyDirContext; +import org.apache.naming.resources.Resource; +import org.apache.naming.resources.ResourceAttributes; +//import org.apache.tomcat.util.res.StringManager; +import org.apache.catalina.servlets.*; +import ngasi.caimito.resource.*; + +/** + *

The default resource-serving servlet for most web applications, + * used to serve static resources such as HTML pages and images. + *

+ *

+ * This servlet is intended to be mapped to / e.g.: + *

+ *
+ *   <servlet-mapping>
+ *       <servlet-name>default</servlet-name>
+ *       <url-pattern>/</url-pattern>
+ *   </servlet-mapping>
+ * 
+ *

It can be mapped to sub-paths, however in all cases resources are served + * from the web appplication resource root using the full path from the root + * of the web application context. + *
e.g. given a web application structure: + *

+ *
+ * /context
+ *   /images
+ *     tomcat2.jpg
+ *   /static
+ *     /images
+ *       tomcat.jpg
+ * 
+ *

+ * ... and a servlet mapping that maps only /static/* to the default servlet: + *

+ *
+ *   <servlet-mapping>
+ *       <servlet-name>default</servlet-name>
+ *       <url-pattern>/static/*</url-pattern>
+ *   </servlet-mapping>
+ * 
+ *

+ * Then a request to /context/static/images/tomcat.jpg will succeed + * while a request to /context/images/tomcat2.jpg will fail. + *

+ * @author Craig R. McClanahan + * @author Remy Maucherat + * @version $Id: DefaultServlet.java 1200163 2011-11-10 05:40:04Z kkolinko $ + */ + +public class CaimitoDefaultServlet + extends HttpServlet { + + private static final long serialVersionUID = 1L; + + // ----------------------------------------------------- Instance Variables + + + /** + * The debugging detail level for this servlet. + */ + protected int debug = 0; + + + /** + * The input buffer size to use when serving resources. + */ + protected int input = 2048; + + + /** + * Should we generate directory listings? + */ + protected boolean listings = false; + + + /** + * Read only flag. By default, it's set to true. + */ + protected boolean readOnly = true; + + + /** + * The output buffer size to use when serving resources. + */ + protected int output = 2048; + + + /** + * Array containing the safe characters set. + */ + protected static URLEncoder urlEncoder; + + + /** + * Allow customized directory listing per directory. + */ + protected String localXsltFile = null; + + + /** + * Allow customized directory listing per context. + */ + protected String contextXsltFile = null; + + + /** + * Allow customized directory listing per instance. + */ + protected String globalXsltFile = null; + + + /** + * Allow a readme file to be included. + */ + protected String readmeFile = null; + + + /** + * Proxy directory context. + */ + protected transient ProxyDirContext resources = null; + + + /** + * File encoding to be used when reading static files. If none is specified + * the platform default is used. + */ + protected String fileEncoding = null; + + + /** + * Minimum size for sendfile usage in bytes. + */ + protected int sendfileSize = 48 * 1024; + + /** + * Should the Accept-Ranges: bytes header be send with static resources? + */ + protected boolean useAcceptRanges = true; + + /** + * Full range marker. + */ + protected static ArrayList FULL = new ArrayList(); + + + // ----------------------------------------------------- Static Initializer + + + /** + * GMT timezone - all HTTP dates are on GMT + */ + static { + urlEncoder = new URLEncoder(); + urlEncoder.addSafeCharacter('-'); + urlEncoder.addSafeCharacter('_'); + urlEncoder.addSafeCharacter('.'); + urlEncoder.addSafeCharacter('*'); + urlEncoder.addSafeCharacter('/'); + } + + + /** + * MIME multipart separation string + */ + protected static final String mimeSeparation = "CATALINA_MIME_BOUNDARY"; + + + /** + * JNDI resources name. + */ + protected static final String RESOURCES_JNDI_NAME = "java:/comp/Resources"; + + + /** + * The string manager for this package. + */ + //protected static final StringManager sm = + // StringManager.getManager(Constants.Package); + + + /** + * Size of file transfer buffer in bytes. + */ + protected static final int BUFFER_SIZE = 4096; + + + // --------------------------------------------------------- Public Methods + + + /** + * Finalize this servlet. + */ + @Override + public void destroy() { + // NOOP + } + + + /** + * Initialize this servlet. + */ + @Override + public void init() throws ServletException { + + if (getServletConfig().getInitParameter("debug") != null) + debug = Integer.parseInt(getServletConfig().getInitParameter("debug")); + + if (getServletConfig().getInitParameter("input") != null) + input = Integer.parseInt(getServletConfig().getInitParameter("input")); + + if (getServletConfig().getInitParameter("output") != null) + output = Integer.parseInt(getServletConfig().getInitParameter("output")); + + listings = Boolean.parseBoolean(getServletConfig().getInitParameter("listings")); + + if (getServletConfig().getInitParameter("readonly") != null) + readOnly = Boolean.parseBoolean(getServletConfig().getInitParameter("readonly")); + + if (getServletConfig().getInitParameter("sendfileSize") != null) + sendfileSize = + Integer.parseInt(getServletConfig().getInitParameter("sendfileSize")) * 1024; + + fileEncoding = getServletConfig().getInitParameter("fileEncoding"); + + globalXsltFile = getServletConfig().getInitParameter("globalXsltFile"); + contextXsltFile = getServletConfig().getInitParameter("contextXsltFile"); + localXsltFile = getServletConfig().getInitParameter("localXsltFile"); + readmeFile = getServletConfig().getInitParameter("readmeFile"); + + if (getServletConfig().getInitParameter("useAcceptRanges") != null) + useAcceptRanges = Boolean.parseBoolean(getServletConfig().getInitParameter("useAcceptRanges")); + + // Sanity check on the specified buffer sizes + if (input < 256) + input = 256; + if (output < 256) + output = 256; + + if (debug > 0) { + log("DefaultServlet.init: input buffer size=" + input + + ", output buffer size=" + output); + } + + // Load the proxy dir context. + resources = (ProxyDirContext) getServletContext() + .getAttribute(Globals.RESOURCES_ATTR); + if (resources == null) { + try { + resources = + (ProxyDirContext) new InitialContext() + .lookup(RESOURCES_JNDI_NAME); + } catch (NamingException e) { + // Failed + throw new ServletException("No resources", e); + } + } + + if (resources == null) { + throw new UnavailableException("No resources"); + } + + } + + protected String smgetString(String msg,HttpServletRequest request){ + return smgetString(msg,null,request); + } + protected String smgetString(String msg,String val,HttpServletRequest request){ + try{ + String ms2 = (String)CaimitoConfig.getConfig().get(msg); + if (ms2 != null) + return ms2; + }catch (Exception e){ + e.printStackTrace(); + } + return msg; + } + + + + /*protected String checkAccess(String path, HttpServletRequest request, + HttpServletResponse response, + int acc) + throws CaimitoException { + if (path.equals("/") + { + + } + return path; + }*/ + + // ------------------------------------------------------ Protected Methods + + + /** + * Return the relative path associated with this servlet. + * + * @param request The servlet request we are processing + */ + protected String getRelativePath(HttpServletRequest request) { + // IMPORTANT: DefaultServlet can be mapped to '/' or '/path/*' but always + // serves resources from the web app root with context rooted paths. + // i.e. it can not be used to mount the web app root under a sub-path + // This method must construct a complete context rooted path, although + // subclasses can change this behaviour. + + // Are we being processed by a RequestDispatcher.include()? + if (request.getAttribute( + RequestDispatcher.INCLUDE_REQUEST_URI) != null) { + String result = (String) request.getAttribute( + RequestDispatcher.INCLUDE_PATH_INFO); + if (result == null) { + result = (String) request.getAttribute( + RequestDispatcher.INCLUDE_SERVLET_PATH); + } else { + result = (String) request.getAttribute( + RequestDispatcher.INCLUDE_SERVLET_PATH) + result; + } + if ((result == null) || (result.equals(""))) { + result = "/"; + } + result = tools.util.StringUtil.replaceSubstring(result,"..",""); + result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); + result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); + result = tools.util.StringUtil.replaceSubstring(result,":",""); + + return (result); + } + + // No, extract the desired path directly from the request + String result = request.getPathInfo(); + if (result == null) { + result = request.getServletPath(); + } else { + result = request.getServletPath() + result; + } + if ((result == null) || (result.equals(""))) { + result = "/"; + } + result = tools.util.StringUtil.replaceSubstring(result,"..",""); + result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); + result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); + result = tools.util.StringUtil.replaceSubstring(result,":",""); + + return (result); + + } + + + /** + * Determines the appropriate path to prepend resources with + * when generating directory listings. Depending on the behaviour of + * {@link #getRelativePath(HttpServletRequest)} this will change. + * @param request the request to determine the path for + * @return the prefix to apply to all resources in the listing. + */ + protected String getPathPrefix(final HttpServletRequest request) { + return request.getContextPath(); + } + + + /** + * Process a GET request for the specified resource. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doGet(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException { + + // Serve the requested resource, including the data content + serveResource(request, response, true); + + } + + + /** + * Process a HEAD request for the specified resource. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doHead(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException { + + // Serve the requested resource, without the data content + serveResource(request, response, false); + + } + + + /** + * Override default implementation to ensure that TRACE is correctly + * handled. + * + * @param req the {@link HttpServletRequest} object that + * contains the request the client made of + * the servlet + * + * @param resp the {@link HttpServletResponse} object that + * contains the response the servlet returns + * to the client + * + * @exception IOException if an input or output error occurs + * while the servlet is handling the + * OPTIONS request + * + * @exception ServletException if the request for the + * OPTIONS cannot be handled + */ + /*@Override + protected void doOptions(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + //("DOP 1"); + StringBuilder allow = new StringBuilder(); + // There is a doGet method + allow.append("GET, HEAD"); + // There is a doPost + allow.append(", POST"); + // There is a doPut + allow.append(", PUT"); + // There is a doDelete + allow.append(", DELETE"); + // Trace - assume disabled unless we can prove otherwise + if (req instanceof RequestFacade && + ((RequestFacade) req).getAllowTrace()) { + allow.append(", TRACE"); + } + // Always allow options + allow.append(", OPTIONS"); + + resp.setHeader("Allow", allow.toString()); + }*/ + + + /** + * Process a POST request for the specified resource. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doPost(HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException { + doGet(request, response); + } + + + /** + * Process a PUT request for the specified resource. + * + * @param req The servlet request we are processing + * @param resp The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doPut(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + + String path = getRelativePath(req); + + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); + if (ro == null)return; + if (ro == null) { + resp.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + + + boolean exists = ro.exists(); + //(path + " EXISTSRE " + exists); + + //boolean result = true; + + // Temp. content file used to support partial PUT + //File contentFile = null; + + //Range range = parseContentRange(req, resp); + + InputStream resourceInputStream = null; + + // Append data specified in ranges to existing content for this + // resource - create a temp. file on the local filesystem to + // perform this operation + // Assume just one range is specified for now + //if (range != null) { + // contentFile = executePartialPut(req, range, path); + // resourceInputStream = new FileInputStream(contentFile); + // } else { + resourceInputStream = req.getInputStream(); + // } + + String ct = getServletContext().getMimeType(ro.getName()); + ro.contentType = ct; + ro.contentLength = req.getContentLength(); + ro.write(resourceInputStream); + + /*try { + Resource newResource = new Resource(resourceInputStream); + // FIXME: Add attributes + if (exists) { + resources.rebind(path, newResource); + } else { + resources.bind(path, newResource); + } + } catch(NamingException e) { + result = false; + }*/ + + //if (result) { + if (exists) { + resp.setStatus(HttpServletResponse.SC_NO_CONTENT); + } else { + resp.setStatus(HttpServletResponse.SC_CREATED); + } + // } else { + // resp.sendError(HttpServletResponse.SC_CONFLICT); + // } + + } + + + /** + * Handle a partial PUT. New content specified in request is appended to + * existing content in oldRevisionContent (if present). This code does + * not support simultaneous partial updates to the same resource. + */ + /*protected File executePartialPut(HttpServletRequest req, Range range, + String path) + throws IOException { + + // Append data specified in ranges to existing content for this + // resource - create a temp. file on the local filesystem to + // perform this operation + File tempDir = (File) getServletContext().getAttribute + (ServletContext.TEMPDIR); + // Convert all '/' characters to '.' in resourcePath + String convertedResourcePath = path.replace('/', '.'); + File contentFile = new File(tempDir, convertedResourcePath); + if (contentFile.createNewFile()) { + // Clean up contentFile when Tomcat is terminated + contentFile.deleteOnExit(); + } + + RandomAccessFile randAccessContentFile = + new RandomAccessFile(contentFile, "rw"); + + Resource oldResource = null; + try { + Object obj = resources.lookup(path); + if (obj instanceof Resource) + oldResource = (Resource) obj; + } catch (NamingException e) { + // Ignore + } + + // Copy data in oldRevisionContent to contentFile + if (oldResource != null) { + BufferedInputStream bufOldRevStream = + new BufferedInputStream(oldResource.streamContent(), + BUFFER_SIZE); + + int numBytesRead; + byte[] copyBuffer = new byte[BUFFER_SIZE]; + while ((numBytesRead = bufOldRevStream.read(copyBuffer)) != -1) { + randAccessContentFile.write(copyBuffer, 0, numBytesRead); + } + + bufOldRevStream.close(); + } + + randAccessContentFile.setLength(range.length); + + // Append data in request input stream to contentFile + randAccessContentFile.seek(range.start); + int numBytesRead; + byte[] transferBuffer = new byte[BUFFER_SIZE]; + BufferedInputStream requestBufInStream = + new BufferedInputStream(req.getInputStream(), BUFFER_SIZE); + while ((numBytesRead = requestBufInStream.read(transferBuffer)) != -1) { + randAccessContentFile.write(transferBuffer, 0, numBytesRead); + } + randAccessContentFile.close(); + requestBufInStream.close(); + + return contentFile; + + }*/ + + + /** + * Process a DELETE request for the specified resource. + * + * @param req The servlet request we are processing + * @param resp The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + /*if (readOnly) { + resp.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + }*/ + + String path = getRelativePath(req); + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); + if (ro == null)return; + + if (!ro.canWrite()) { + resp.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + + boolean exists = ro.exists(); + + + /*try { + resources.lookup(path); + } catch (NamingException e) { + exists = false; + }*/ + + if (exists) { + boolean result = true; + try { + ro.delete(); + } catch (Exception e) { + result = false; + } + if (result) { + resp.setStatus(HttpServletResponse.SC_NO_CONTENT); + } else { + resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + } + } else { + resp.sendError(HttpServletResponse.SC_NOT_FOUND); + } + + } + + + /** + * Check if the conditions specified in the optional If headers are + * satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes The resource information + * @return boolean true if the resource meets all the specified conditions, + * and false if any of the conditions is not satisfied, in which case + * request processing is stopped + */ + protected boolean checkIfHeaders(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) + throws IOException,CaimitoException { + + return checkIfMatch(request, response, resourceAttributes) + && checkIfModifiedSince(request, response, resourceAttributes) + && checkIfNoneMatch(request, response, resourceAttributes) + && checkIfUnmodifiedSince(request, response, resourceAttributes); + + } + + + /** + * URL rewriter. + * + * @param path Path which has to be rewritten + */ + protected String rewriteUrl(String path) { + return urlEncoder.encode( path ); + } + + + /** + * Display the size of a file. + */ + protected void displaySize(StringBuilder buf, int filesize) { + + int leftside = filesize / 1024; + int rightside = (filesize % 1024) / 103; // makes 1 digit + // To avoid 0.0 for non-zero file, we bump to 0.1 + if (leftside == 0 && rightside == 0 && filesize != 0) + rightside = 1; + buf.append(leftside).append(".").append(rightside); + buf.append(" KB"); + + } + + + /** + * Serve the specified resource, optionally including the data content. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param content Should the content be included? + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + protected void serveResource(HttpServletRequest request, + HttpServletResponse response, + boolean content) + throws IOException, ServletException { + + boolean serveContent = content; + + // Identify the requested resource path + String path = getRelativePath(request); + ResourceObj ro = ResourceStore.lookup(path,request,response,ResourceStore.READ); + + if (ro == null)return; + + if (!ro.canRead()) { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + + if (debug > 0) { + if (serveContent) + log("DefaultServlet.serveResource: Serving resource '" + + path + "' headers and data"); + else + log("DefaultServlet.serveResource: Serving resource '" + + path + "' headers only"); + } + + // CacheEntry cacheEntry = resources.lookupCache(path); + + if (!ro.exists()) { + // Check if we're included so we can return the appropriate + // missing resource name in the error + String requestUri = (String) request.getAttribute( + RequestDispatcher.INCLUDE_REQUEST_URI); + if (requestUri == null) { + requestUri = request.getRequestURI(); + } else { + // We're included + // SRV.9.3 says we must throw a FNFE + throw new FileNotFoundException( + "defaultServlet.missingResource"); + } + + response.sendError(HttpServletResponse.SC_NOT_FOUND, + requestUri); + return; + } + + // If the resource is not a collection, and the resource path + // ends with "/" or "\", return NOT FOUND + if (!ro.isDirectory()) { + if (path.endsWith("/") || (path.endsWith("\\"))) { + // Check if we're included so we can return the appropriate + // missing resource name in the error + String requestUri = (String) request.getAttribute( + RequestDispatcher.INCLUDE_REQUEST_URI); + if (requestUri == null) { + requestUri = request.getRequestURI(); + } + response.sendError(HttpServletResponse.SC_NOT_FOUND, + requestUri); + return; + } + } + + boolean isError = + response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST; + + // Check if the conditions specified in the optional If headers are + // satisfied. + if (!ro.isDirectory()) { + + // Checking If headers + boolean included = (request.getAttribute( + RequestDispatcher.INCLUDE_CONTEXT_PATH) != null); + if (!included && !isError && + !checkIfHeaders(request, response, ro)) { + return; + } + + } + + // Find content type. + String contentType = ro.getMimeType(); + if (contentType == null) { + contentType = getServletContext().getMimeType(ro.path); + ro.setMimeType(contentType); + } + + ArrayList ranges = null; + long contentLength = -1L; + + if (ro.isDirectory()) { + + // Skip directory listings if we have been configured to + // suppress them + if (!ro.listings()) { + response.sendError(HttpServletResponse.SC_NOT_FOUND, + request.getRequestURI()); + return; + } + contentType = "text/html;charset=UTF-8"; + + } else { + if (!isError) { + if (useAcceptRanges) { + // Accept ranges header + response.setHeader("Accept-Ranges", "bytes"); + } + + // Parse range specifier + ranges = parseRange(request, response, ro); + + // ETag header + response.setHeader("ETag", ro.getETag()); + + // Last-Modified header + response.setHeader("Last-Modified", + ro.getLastModifiedHttp()); + } + + // Get content length + contentLength = ro.getContentLength(); + // Special case for zero length files, which would cause a + // (silent) ISE when setting the output buffer size + if (contentLength == 0L) { + serveContent = false; + //("SERVER CONTENT = fale"); + } + + } +//(contentType + " serveContent " + serveContent); + ServletOutputStream ostream = null; + PrintWriter writer = null; + + if (serveContent) { + + // Trying to retrieve the servlet output stream + + try { + ostream = response.getOutputStream(); + } catch (IllegalStateException e) { + // If it fails, we try to get a Writer instead if we're + // trying to serve a text file + if ( (contentType == null) + || (contentType.startsWith("text")) + || (contentType.endsWith("xml")) + || (contentType.contains("/javascript")) ) { + writer = response.getWriter(); + // Cannot reliably serve partial content with a Writer + ranges = FULL; + } else { + throw e; + } + } + + } + + // Check to see if a Filter, Valve of wrapper has written some content. + // If it has, disable range requests and setting of a content length + // since neither can be done reliably. + ServletResponse r = response; + long contentWritten = 0; + while (r instanceof ServletResponseWrapper) { + r = ((ServletResponseWrapper) r).getResponse(); + } + if (r instanceof ResponseFacade) { + contentWritten = ((ResponseFacade) r).getContentWritten(); + } + if (contentWritten > 0) { + ranges = FULL; + } + + if ( (ro.isDirectory()) + || isError + || ( ((ranges == null) || (ranges.isEmpty())) + && (request.getHeader("Range") == null) ) + || (ranges == FULL) ) { + + // Set the appropriate output headers + if (contentType != null) { + if (debug > 0) + log("DefaultServlet.serveFile: contentType='" + + contentType + "'"); + response.setContentType(contentType); + } + //???(cacheEntry.resource != null) && + if ( (contentLength >= 0) + && (!serveContent || ostream != null)) { + if (debug > 0) + log("DefaultServlet.serveFile: contentLength=" + + contentLength); + // Don't set a content length if something else has already + // written to the response. + if (contentWritten == 0) { + if (contentLength < Integer.MAX_VALUE) { + response.setContentLength((int) contentLength); + } else { + // Set the content-length as String to be able to use a + // long + response.setHeader("content-length", + "" + contentLength); + } + } + } + + InputStream renderResult = null; + if (ro.isDirectory()) { + + if (serveContent) { + // Serve the directory browser + renderResult = render(getPathPrefix(request), ro,request); + } + + } + + // Copy the input stream to our output stream (if requested) + if (serveContent) { + try { + response.setBufferSize(output); + } catch (IllegalStateException e) { + // Silent catch + } + if (ostream != null ) { + if (!checkSendfile(request, response, ro, contentLength, null)) + copy(ro, renderResult, ostream); + } else { + //(writer + " SENDY FDIR " + renderResult); + copy(ro, renderResult, writer); + } + } + + } else { + + if ((ranges == null) || (ranges.isEmpty())) + return; + + // Partial content response. + + response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT); + + if (ranges.size() == 1) { + + Range range = ranges.get(0); + response.addHeader("Content-Range", "bytes " + + range.start + + "-" + range.end + "/" + + range.length); + long length = range.end - range.start + 1; + if (length < Integer.MAX_VALUE) { + response.setContentLength((int) length); + } else { + // Set the content-length as String to be able to use a long + response.setHeader("content-length", "" + length); + } + + if (contentType != null) { + if (debug > 0) + log("DefaultServlet.serveFile: contentType='" + + contentType + "'"); + response.setContentType(contentType); + } + + if (serveContent) { + try { + response.setBufferSize(output); + } catch (IllegalStateException e) { + // Silent catch + } + if (ostream != null) { + if (!checkSendfile(request, response, ro, range.end - range.start + 1, range)) + copy(ro, ostream, range,request); + } else { + // we should not get here + throw new IllegalStateException(); + } + } + + } else { + + response.setContentType("multipart/byteranges; boundary=" + + mimeSeparation); + + if (serveContent) { + try { + response.setBufferSize(output); + } catch (IllegalStateException e) { + // Silent catch + } + if (ostream != null) { + copy(ro, ostream, ranges.iterator(), + contentType,request); + } else { + // we should not get here + throw new IllegalStateException(); + } + } + + } + + } + + } + + + /** + * Parse the content-range header. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @return Range + */ + protected Range parseContentRange(HttpServletRequest request, + HttpServletResponse response) + throws IOException { + + // Retrieving the content-range header (if any is specified + String rangeHeader = request.getHeader("Content-Range"); + + if (rangeHeader == null) + return null; + + // bytes is the only range unit supported + if (!rangeHeader.startsWith("bytes")) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return null; + } + + rangeHeader = rangeHeader.substring(6).trim(); + + int dashPos = rangeHeader.indexOf('-'); + int slashPos = rangeHeader.indexOf('/'); + + if (dashPos == -1) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return null; + } + + if (slashPos == -1) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return null; + } + + Range range = new Range(); + + try { + range.start = Long.parseLong(rangeHeader.substring(0, dashPos)); + range.end = + Long.parseLong(rangeHeader.substring(dashPos + 1, slashPos)); + range.length = Long.parseLong + (rangeHeader.substring(slashPos + 1, rangeHeader.length())); + } catch (NumberFormatException e) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return null; + } + + if (!range.validate()) { + response.sendError(HttpServletResponse.SC_BAD_REQUEST); + return null; + } + + return range; + + } + + + /** + * Parse the range header. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @return Vector of ranges + */ + protected ArrayList parseRange(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) throws CaimitoException,IOException { + + // Checking If-Range + String headerValue = request.getHeader("If-Range"); + + if (headerValue != null) { + + long headerValueTime = (-1L); + try { + headerValueTime = request.getDateHeader("If-Range"); + } catch (IllegalArgumentException e) { + // Ignore + } + + String eTag = resourceAttributes.getETag(); + long lastModified = resourceAttributes.getLastModified(); + + if (headerValueTime == (-1L)) { + + // If the ETag the client gave does not match the entity + // etag, then the entire entity is returned. + if (!eTag.equals(headerValue.trim())) + return FULL; + + } else { + + // If the timestamp of the entity the client got is older than + // the last modification date of the entity, the entire entity + // is returned. + if (lastModified > (headerValueTime + 1000)) + return FULL; + + } + + } + + long fileLength = resourceAttributes.getContentLength(); + + if (fileLength == 0) + return null; + + // Retrieving the range header (if any is specified + String rangeHeader = request.getHeader("Range"); + + if (rangeHeader == null) + return null; + // bytes is the only range unit supported (and I don't see the point + // of adding new ones). + if (!rangeHeader.startsWith("bytes")) { + response.addHeader("Content-Range", "bytes */" + fileLength); + response.sendError + (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); + return null; + } + + rangeHeader = rangeHeader.substring(6); + + // Vector which will contain all the ranges which are successfully + // parsed. + ArrayList result = new ArrayList(); + StringTokenizer commaTokenizer = new StringTokenizer(rangeHeader, ","); + + // Parsing the range list + while (commaTokenizer.hasMoreTokens()) { + String rangeDefinition = commaTokenizer.nextToken().trim(); + + Range currentRange = new Range(); + currentRange.length = fileLength; + + int dashPos = rangeDefinition.indexOf('-'); + + if (dashPos == -1) { + response.addHeader("Content-Range", "bytes */" + fileLength); + response.sendError + (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); + return null; + } + + if (dashPos == 0) { + + try { + long offset = Long.parseLong(rangeDefinition); + currentRange.start = fileLength + offset; + currentRange.end = fileLength - 1; + } catch (NumberFormatException e) { + response.addHeader("Content-Range", + "bytes */" + fileLength); + response.sendError + (HttpServletResponse + .SC_REQUESTED_RANGE_NOT_SATISFIABLE); + return null; + } + + } else { + + try { + currentRange.start = Long.parseLong + (rangeDefinition.substring(0, dashPos)); + if (dashPos < rangeDefinition.length() - 1) + currentRange.end = Long.parseLong + (rangeDefinition.substring + (dashPos + 1, rangeDefinition.length())); + else + currentRange.end = fileLength - 1; + } catch (NumberFormatException e) { + response.addHeader("Content-Range", + "bytes */" + fileLength); + response.sendError + (HttpServletResponse + .SC_REQUESTED_RANGE_NOT_SATISFIABLE); + return null; + } + + } + + if (!currentRange.validate()) { + response.addHeader("Content-Range", "bytes */" + fileLength); + response.sendError + (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE); + return null; + } + + result.add(currentRange); + } + + return result; + } + + + + /** + * Decide which way to render. HTML or XML. + */ + protected InputStream render(String contextPath, ResourceObj cacheEntry,HttpServletRequest request) + throws IOException, ServletException { + + //InputStream xsltInputStream = + // findXsltInputStream(cacheEntry.context); + + //if (xsltInputStream==null) { + return renderHtml(contextPath, cacheEntry,request); + //} + //return renderXml(contextPath, cacheEntry, xsltInputStream); + + } + + /** + * Return an InputStream to an HTML representation of the contents + * of this directory. + * + * @param contextPath Context path to which our internal paths are + * relative + */ + protected InputStream renderXml(String contextPath, + ResourceObj ro, + InputStream xsltInputStream) + throws IOException, ServletException { + + StringBuilder sb = new StringBuilder(); + + sb.append(""); + sb.append(""); + + sb.append(""); + + try { + + // Render the directory entries within this directory + Enumeration enumeration = + ro.list().elements(); + + // rewriteUrl(contextPath) is expensive. cache result for later reuse + String rewrittenContextPath = rewriteUrl(contextPath); + + while (enumeration.hasMoreElements()) { + + ResourceObj ncPair = enumeration.nextElement(); + String resourceName = ncPair.getName(); + String trimmed = resourceName/*.substring(trim)*/; + // if (trimmed.equalsIgnoreCase("WEB-INF") || + // trimmed.equalsIgnoreCase("META-INF") || + // trimmed.equalsIgnoreCase(localXsltFile)) + // continue; + + // if ((cacheEntry.name + trimmed).equals(contextXsltFile)) + // continue; + + // CacheEntry childCacheEntry = + // resources.lookupCache(cacheEntry.name + resourceName); + // if (!childCacheEntry.exists) { + // continue; + // } + + sb.append(""); + sb.append(RequestUtil.filter(trimmed)); + if (ncPair.isDirectory()) + sb.append("/"); + sb.append(""); + + } + + } catch (Exception e) { + // Something went wrong + throw new ServletException("Error accessing resource", e); + } + + sb.append(""); + + String readme = getReadme(ro); + + if (readme!=null) { + sb.append(""); + } + + + sb.append(""); + + + try { + TransformerFactory tFactory = TransformerFactory.newInstance(); + Source xmlSource = new StreamSource(new StringReader(sb.toString())); + Source xslSource = new StreamSource(xsltInputStream); + Transformer transformer = tFactory.newTransformer(xslSource); + + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8"); + StreamResult out = new StreamResult(osWriter); + transformer.transform(xmlSource, out); + osWriter.flush(); + return (new ByteArrayInputStream(stream.toByteArray())); + } catch (TransformerException e) { + throw new ServletException("XSL transformer error", e); + } + } + + /** + * Return an InputStream to an HTML representation of the contents + * of this directory. + * + * @param contextPath Context path to which our internal paths are + * relative + */ + protected InputStream renderHtml(String contextPath, ResourceObj ro,HttpServletRequest request) + throws IOException, ServletException { + + String name = ro.path; + + // Prepare a writer to a buffered area + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter osWriter = new OutputStreamWriter(stream, "UTF8"); + PrintWriter writer = new PrintWriter(osWriter); + + StringBuilder sb = new StringBuilder(); + + // rewriteUrl(contextPath) is expensive. cache result for later reuse + String rewrittenContextPath = rewriteUrl(contextPath); + + // Render the page header + sb.append("\r\n"); + sb.append("\r\n"); + sb.append(""); + sb.append(smgetString("directory.title", name,request)); + sb.append("\r\n"); + sb.append(" "); + sb.append("\r\n"); + sb.append(""); + sb.append("

"); + sb.append(smgetString("directory.title", name,request)); + + // Render the link to our parent (if required) + String parentDirectory = name; + if (parentDirectory.endsWith("/")) { + parentDirectory = + parentDirectory.substring(0, parentDirectory.length() - 1); + } + int slash = parentDirectory.lastIndexOf('/'); + if (slash >= 0) { + String parent = name.substring(0, slash); + sb.append(" - "); + sb.append(""); + sb.append(smgetString("directory.parent", parent,request)); + sb.append(""); + sb.append(""); + } + + sb.append("

"); + sb.append("
"); + + sb.append("\r\n"); + + // Render the column headings + sb.append("\r\n"); + sb.append("\r\n"); + sb.append("\r\n"); + sb.append("\r\n"); + sb.append(""); + + try { + + // Render the directory entries within this directory + Enumeration enumeration = + ro.list().elements(); + boolean shade = false; + while (enumeration.hasMoreElements()) { + + ResourceObj ncPair = enumeration.nextElement(); + String resourceName = ncPair.getName(); + //(ro.path + " GET 1 " + ncPair + ":" + resourceName); + String trimmed = resourceName/*.substring(trim)*/; + //if (trimmed.equalsIgnoreCase("WEB-INF") || + // trimmed.equalsIgnoreCase("META-INF")) + // continue; + + // CacheEntry childCacheEntry = + // resources.lookupCache(cacheEntry.name + resourceName); + //if (!childCacheEntry.exists) { + // continue; + //} + + sb.append("\r\n"); + shade = !shade; + + sb.append("\r\n"); + + sb.append("\r\n"); + + sb.append("\r\n"); + + sb.append("\r\n"); + } + + } catch (Exception e) { + // Something went wrong + throw new ServletException("Error accessing resource", e); + } + + // Render the page footer + sb.append("
"); + sb.append(smgetString("directory.filename",request)); + sb.append(""); + sb.append(smgetString("directory.size",request)); + sb.append(""); + sb.append(smgetString("directory.lastModified",request)); + sb.append("
  \r\n"); + sb.append(""); + sb.append(RequestUtil.filter(trimmed)); + if (ncPair.isDirectory()) + sb.append("/"); + sb.append(""); + if (ncPair.isDirectory()) + sb.append(" "); + else + sb.append(renderSize(ncPair.getContentLength())); + sb.append(""); + sb.append(ncPair.getLastModifiedHttp()); + sb.append("
\r\n"); + + sb.append("
"); + + String readme = getReadme(ro); + if (readme!=null) { + sb.append(readme); + sb.append("
"); + } + + sb.append("

").append(CaimitoConfig.serverinfo).append("

"); + sb.append("\r\n"); + sb.append("\r\n"); + + // Return an input stream to the underlying bytes + writer.write(sb.toString()); + writer.flush(); + return (new ByteArrayInputStream(stream.toByteArray())); + + } + + + /** + * Render the specified file size (in bytes). + * + * @param size File size (in bytes) + */ + protected String renderSize(long size) { + + long leftSide = size / 1024; + long rightSide = (size % 1024) / 103; // Makes 1 digit + if ((leftSide == 0) && (rightSide == 0) && (size > 0)) + rightSide = 1; + + return ("" + leftSide + "." + rightSide + " kb"); + + } + + + /** + * Get the readme file as a string. + */ + protected String getReadme(ResourceObj directory) + throws CaimitoException,IOException { + ResourceObj rmf = directory.getReadmeFile(); + if (rmf != null) { + try { + //Object obj = directory.lookup(readmeFile); + // if ((obj != null) && (obj instanceof Resource)) { + StringWriter buffer = new StringWriter(); + InputStream is = rmf.getInputStream(); + //((Resource) obj).streamContent(); + copyRange(new InputStreamReader(is), + new PrintWriter(buffer)); + return buffer.toString(); + // } + } catch (Exception e) { + if (debug > 10) + log("readme '" + readmeFile + "' not found", e); + + return null; + } + } + + return null; + } + + + /** + * Return the xsl template inputstream (if possible) + */ + protected InputStream findXsltInputStream(DirContext directory) + throws IOException { + + if (localXsltFile != null) { + try { + Object obj = directory.lookup(localXsltFile); + if ((obj != null) && (obj instanceof Resource)) { + InputStream is = ((Resource) obj).streamContent(); + if (is != null) + return is; + } + } catch (NamingException e) { + if (debug > 10) + log("localXsltFile '" + localXsltFile + "' not found", e); + } + } + + if (contextXsltFile != null) { + InputStream is = + getServletContext().getResourceAsStream(contextXsltFile); + if (is != null) + return is; + + if (debug > 10) + log("contextXsltFile '" + contextXsltFile + "' not found"); + } + + /* Open and read in file in one fell swoop to reduce chance + * chance of leaving handle open. + */ + if (globalXsltFile!=null) { + FileInputStream fis = null; + + try { + File f = new File(globalXsltFile); + if (f.exists()){ + fis =new FileInputStream(f); + byte b[] = new byte[(int)f.length()]; /* danger! */ + fis.read(b); + return new ByteArrayInputStream(b); + } + } finally { + if (fis!=null) + fis.close(); + } + } + + return null; + + } + + + // -------------------------------------------------------- protected Methods + + + /** + * Check if sendfile can be used. + */ + protected boolean checkSendfile(HttpServletRequest request, + HttpServletResponse response, + ResourceObj entry, + long length, Range range) { + /*if ((sendfileSize > 0) + + && ((length > sendfileSize) || (entry.getContentLength() > 0)) + && (entry.getCanonicalPath() != null) + && (Boolean.TRUE == request.getAttribute("org.apache.tomcat.sendfile.support")) + && (request.getClass().getName().equals("org.apache.catalina.connector.RequestFacade")) + && (response.getClass().getName().equals("org.apache.catalina.connector.ResponseFacade"))) { + request.setAttribute("org.apache.tomcat.sendfile.filename", entry.getCanonicalPath()); + if (range == null) { + request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(0L)); + request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(length)); + } else { + request.setAttribute("org.apache.tomcat.sendfile.start", Long.valueOf(range.start)); + request.setAttribute("org.apache.tomcat.sendfile.end", Long.valueOf(range.end + 1)); + } + return true; + }*/ + return false; + } + + + /** + * Check if the if-match condition is satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes File object + * @return boolean true if the resource meets the specified condition, + * and false if the condition is not satisfied, in which case request + * processing is stopped + */ + protected boolean checkIfMatch(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) + throws CaimitoException,IOException { + + String eTag = resourceAttributes.getETag(); + String headerValue = request.getHeader("If-Match"); + if (headerValue != null) { + if (headerValue.indexOf('*') == -1) { + + StringTokenizer commaTokenizer = new StringTokenizer + (headerValue, ","); + boolean conditionSatisfied = false; + + while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { + String currentToken = commaTokenizer.nextToken(); + if (currentToken.trim().equals(eTag)) + conditionSatisfied = true; + } + + // If none of the given ETags match, 412 Precodition failed is + // sent back + if (!conditionSatisfied) { + response.sendError + (HttpServletResponse.SC_PRECONDITION_FAILED); + return false; + } + + } + } + return true; + + } + + + /** + * Check if the if-modified-since condition is satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes File object + * @return boolean true if the resource meets the specified condition, + * and false if the condition is not satisfied, in which case request + * processing is stopped + */ + protected boolean checkIfModifiedSince(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) { + try { + long headerValue = request.getDateHeader("If-Modified-Since"); + long lastModified = resourceAttributes.getLastModified(); + if (headerValue != -1) { + + // If an If-None-Match header has been specified, if modified since + // is ignored. + if ((request.getHeader("If-None-Match") == null) + && (lastModified < headerValue + 1000)) { + // The entity has not been modified since the date + // specified by the client. This is not an error case. + response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); + response.setHeader("ETag", resourceAttributes.getETag()); + + return false; + } + } + } catch (Exception illegalArgument) { + return true; + } + return true; + + } + + + /** + * Check if the if-none-match condition is satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes File object + * @return boolean true if the resource meets the specified condition, + * and false if the condition is not satisfied, in which case request + * processing is stopped + */ + protected boolean checkIfNoneMatch(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) + throws CaimitoException,IOException { + + String eTag = resourceAttributes.getETag(); + String headerValue = request.getHeader("If-None-Match"); + if (headerValue != null) { + + boolean conditionSatisfied = false; + + if (!headerValue.equals("*")) { + + StringTokenizer commaTokenizer = + new StringTokenizer(headerValue, ","); + + while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { + String currentToken = commaTokenizer.nextToken(); + if (currentToken.trim().equals(eTag)) + conditionSatisfied = true; + } + + } else { + conditionSatisfied = true; + } + + if (conditionSatisfied) { + + // For GET and HEAD, we should respond with + // 304 Not Modified. + // For every other method, 412 Precondition Failed is sent + // back. + if ( ("GET".equals(request.getMethod())) + || ("HEAD".equals(request.getMethod())) ) { + response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); + response.setHeader("ETag", eTag); + + return false; + } + response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); + return false; + } + } + return true; + + } + + + /** + * Check if the if-unmodified-since condition is satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes File object + * @return boolean true if the resource meets the specified condition, + * and false if the condition is not satisfied, in which case request + * processing is stopped + */ + protected boolean checkIfUnmodifiedSince(HttpServletRequest request, + HttpServletResponse response, + ResourceObj resourceAttributes) + throws CaimitoException { + try { + long lastModified = resourceAttributes.getLastModified(); + long headerValue = request.getDateHeader("If-Unmodified-Since"); + if (headerValue != -1) { + if ( lastModified >= (headerValue + 1000)) { + // The entity has not been modified since the date + // specified by the client. This is not an error case. + response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED); + return false; + } + } + } catch(Exception illegalArgument) { + return true; + } + return true; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param cacheEntry The cache entry for the source resource + * @param is The input stream to read the source resource from + * @param ostream The output stream to write to + * + * @exception IOException if an input/output error occurs + */ + protected void copy(ResourceObj cacheEntry, InputStream is, + ServletOutputStream ostream) + throws CaimitoException,IOException { + + IOException exception = null; + InputStream resourceInputStream = null; + + // Optimization: If the binary content has already been loaded, send + // it directly + //("cacheEntry.resource 1 " + cacheEntry); + if (!cacheEntry.isDirectory() && cacheEntry.getContentLength() >0) { + /*byte buffer[] = cacheEntry.resource.getContent(); + if (buffer != null) { + //("cacheEntry.resource 2 " + cacheEntry); + + ostream.write(buffer, 0, buffer.length); + return; + }*/ + resourceInputStream = cacheEntry.getInputStream(); + } else { + resourceInputStream = is; + } + + InputStream istream = new BufferedInputStream + (resourceInputStream, input); + + // Copy the input stream to the output stream + exception = copyRange(istream, ostream); + + // Clean up the input stream + istream.close(); + + // Rethrow any exception that has occurred + if (exception != null) + throw exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param cacheEntry The cache entry for the source resource + * @param is The input stream to read the source resource from + * @param writer The writer to write to + * + * @exception IOException if an input/output error occurs + */ + protected void copy(ResourceObj cacheEntry, InputStream is, PrintWriter writer) + throws CaimitoException,IOException { + + IOException exception = null; + + InputStream resourceInputStream = null; + if (!cacheEntry.isDirectory() && cacheEntry.getContentLength() > 0) { + resourceInputStream = cacheEntry.getInputStream(); + } else { + resourceInputStream = is; + } + + Reader reader; + if (fileEncoding == null) { + reader = new InputStreamReader(resourceInputStream); + } else { + reader = new InputStreamReader(resourceInputStream, + fileEncoding); + } + + // Copy the input stream to the output stream + exception = copyRange(reader, writer); + + // Clean up the reader + reader.close(); + + // Rethrow any exception that has occurred + if (exception != null) + throw exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param cacheEntry The cache entry for the source resource + * @param ostream The output stream to write to + * @param range Range the client wanted to retrieve + * @exception IOException if an input/output error occurs + */ + protected void copy(ResourceObj cacheEntry, ServletOutputStream ostream, + Range range,HttpServletRequest request) + throws CaimitoException,IOException { + + IOException exception = null; + + InputStream resourceInputStream = cacheEntry.getInputStream(); + InputStream istream = + new BufferedInputStream(resourceInputStream, input); + exception = copyRange(istream, ostream, range.start, range.end,request); + + // Clean up the input stream + istream.close(); + + // Rethrow any exception that has occurred + if (exception != null) + throw exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param cacheEntry The cache entry for the source resource + * @param ostream The output stream to write to + * @param ranges Enumeration of the ranges the client wanted to retrieve + * @param contentType Content type of the resource + * @exception IOException if an input/output error occurs + */ + protected void copy(ResourceObj cacheEntry, ServletOutputStream ostream, + Iterator ranges, String contentType,HttpServletRequest request) + throws CaimitoException,IOException { + + IOException exception = null; + + while ( (exception == null) && (ranges.hasNext()) ) { + + InputStream resourceInputStream = cacheEntry.getInputStream(); + InputStream istream = + new BufferedInputStream(resourceInputStream, input); + + Range currentRange = ranges.next(); + + // Writing MIME header. + ostream.println(); + ostream.println("--" + mimeSeparation); + if (contentType != null) + ostream.println("Content-Type: " + contentType); + ostream.println("Content-Range: bytes " + currentRange.start + + "-" + currentRange.end + "/" + + currentRange.length); + ostream.println(); + + // Printing content + exception = copyRange(istream, ostream, currentRange.start, + currentRange.end,request); + + istream.close(); + + } + + ostream.println(); + ostream.print("--" + mimeSeparation + "--"); + + // Rethrow any exception that has occurred + if (exception != null) + throw exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param istream The input stream to read from + * @param ostream The output stream to write to + * @return Exception which occurred during processing + */ + protected IOException copyRange(InputStream istream, + ServletOutputStream ostream) { + + // Copy the input stream to the output stream + IOException exception = null; + byte buffer[] = new byte[input]; + int len = buffer.length; + while (true) { + try { + len = istream.read(buffer); + if (len == -1) + break; + ostream.write(buffer, 0, len); + } catch (IOException e) { + exception = e; + len = -1; + break; + } + } + return exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param reader The reader to read from + * @param writer The writer to write to + * @return Exception which occurred during processing + */ + protected IOException copyRange(Reader reader, PrintWriter writer) { + + // Copy the input stream to the output stream + IOException exception = null; + char buffer[] = new char[input]; + int len = buffer.length; + while (true) { + try { + len = reader.read(buffer); + if (len == -1) + break; + writer.write(buffer, 0, len); + } catch (IOException e) { + exception = e; + len = -1; + break; + } + } + return exception; + + } + + + /** + * Copy the contents of the specified input stream to the specified + * output stream, and ensure that both streams are closed before returning + * (even in the face of an exception). + * + * @param istream The input stream to read from + * @param ostream The output stream to write to + * @param start Start of the range which will be copied + * @param end End of the range which will be copied + * @return Exception which occurred during processing + */ + protected IOException copyRange(InputStream istream, + ServletOutputStream ostream, + long start, long end,HttpServletRequest request) { + + if (debug > 10) + log("Serving bytes:" + start + "-" + end); + + long skipped = 0; + try { + skipped = istream.skip(start); + } catch (IOException e) { + return e; + } + if (skipped < start) { + return new IOException(smgetString("defaultservlet.skipfail", + ("" +skipped),request)); + } + + IOException exception = null; + long bytesToRead = end - start + 1; + + byte buffer[] = new byte[input]; + int len = buffer.length; + while ( (bytesToRead > 0) && (len >= buffer.length)) { + try { + len = istream.read(buffer); + if (bytesToRead >= len) { + ostream.write(buffer, 0, len); + bytesToRead -= len; + } else { + ostream.write(buffer, 0, (int) bytesToRead); + bytesToRead = 0; + } + } catch (IOException e) { + exception = e; + len = -1; + } + if (len < buffer.length) + break; + } + + return exception; + + } + + + // ------------------------------------------------------ Range Inner Class + + + protected static class Range { + + public long start; + public long end; + public long length; + + /** + * Validate range. + */ + public boolean validate() { + if (end >= length) + end = length - 1; + return (start >= 0) && (end >= 0) && (start <= end) && (length > 0); + } + } +} diff --git a/source/ngasi/caimito/CaimitoException.java b/source/ngasi/caimito/CaimitoException.java old mode 100644 new mode 100755 index fcd89f3..b4b0474 --- a/source/ngasi/caimito/CaimitoException.java +++ b/source/ngasi/caimito/CaimitoException.java @@ -59,4 +59,4 @@ public static void throwException(Throwable e)throws CaimitoException{ public void throwIt()throws CaimitoException{ throw this; } -} \ No newline at end of file +} diff --git a/source/ngasi/caimito/CaimitoUtil.java b/source/ngasi/caimito/CaimitoUtil.java old mode 100644 new mode 100755 diff --git a/source/ngasi/caimito/CaimitoWebdavServlet.java b/source/ngasi/caimito/CaimitoWebdavServlet.java old mode 100644 new mode 100755 index 2c63ddf..25b09e9 --- a/source/ngasi/caimito/CaimitoWebdavServlet.java +++ b/source/ngasi/caimito/CaimitoWebdavServlet.java @@ -1,3458 +1,3457 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 ngasi.caimito; - - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.nio.charset.Charset; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Locale; -import java.util.Stack; -import java.util.TimeZone; -import java.util.Vector; - -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.DirContext; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.UnavailableException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.catalina.util.DOMWriter; -import org.apache.catalina.util.MD5Encoder; -import org.apache.catalina.util.XMLWriter; -import org.apache.naming.resources.CacheEntry; -import org.apache.naming.resources.Resource; -import org.apache.naming.resources.ResourceAttributes; -import org.apache.tomcat.util.http.FastHttpDateFormat; -import org.apache.tomcat.util.http.RequestUtil; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.apache.catalina.servlets.*; -import ngasi.caimito.resource.*; - - - -/** - * Servlet which adds support for WebDAV level 2. All the basic HTTP requests - * are handled by the DefaultServlet. The WebDAVServlet must not be used as the - * default servlet (ie mapped to '/') as it will not work in this configuration. - *

- * Mapping a subpath (e.g. /webdav/* to this servlet has the effect - * of re-mounting the entire web application under that sub-path, with WebDAV - * access to all the resources. This WEB-INF and META-INF - * directories are protected in this re-mounted resource tree. - *

- * To enable WebDAV for a context add the following to web.xml: - *

- * <servlet>
- *  <servlet-name>webdav</servlet-name>
- *  <servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
- *    <init-param>
- *      <param-name>debug</param-name>
- *      <param-value>0</param-value>
- *    </init-param>
- *    <init-param>
- *      <param-name>listings</param-name>
- *      <param-value>false</param-value>
- *    </init-param>
- *  </servlet>
- *  <servlet-mapping>
- *    <servlet-name>webdav</servlet-name>
- *    <url-pattern>/*</url-pattern>
- *  </servlet-mapping>
- * 
- * This will enable read only access. To enable read-write access add: - *
- *  <init-param>
- *    <param-name>readonly</param-name>
- *    <param-value>false</param-value>
- *  </init-param>
- * 
- * To make the content editable via a different URL, use the following - * mapping: - *
- *  <servlet-mapping>
- *    <servlet-name>webdav</servlet-name>
- *    <url-pattern>/webdavedit/*</url-pattern>
- *  </servlet-mapping>
- * 
- * By default access to /WEB-INF and META-INF are not available via WebDAV. To - * enable access to these URLs, use add: - *
- *  <init-param>
- *    <param-name>allowSpecialPaths</param-name>
- *    <param-value>true</param-value>
- *  </init-param>
- * 
- * Don't forget to secure access appropriately to the editing URLs, especially - * if allowSpecialPaths is used. With the mapping configuration above, the - * context will be accessible to normal users as before. Those users with the - * necessary access will be able to edit content available via - * http://host:port/context/content using - * http://host:port/context/webdavedit/content - * - * @author Remy Maucherat - * @version $Id: WebdavServlet.java 1239053 2012-02-01 10:52:00Z markt $ - */ - -public class CaimitoWebdavServlet - extends CaimitoDefaultServlet { - - private static final long serialVersionUID = 1L; - - - // -------------------------------------------------------------- Constants - - private static final String METHOD_PROPFIND = "PROPFIND"; - private static final String METHOD_PROPPATCH = "PROPPATCH"; - private static final String METHOD_MKCOL = "MKCOL"; - private static final String METHOD_COPY = "COPY"; - private static final String METHOD_MOVE = "MOVE"; - private static final String METHOD_LOCK = "LOCK"; - private static final String METHOD_UNLOCK = "UNLOCK"; - - - /** - * PROPFIND - Specify a property mask. - */ - private static final int FIND_BY_PROPERTY = 0; - - - /** - * PROPFIND - Display all properties. - */ - private static final int FIND_ALL_PROP = 1; - - - /** - * PROPFIND - Return property names. - */ - private static final int FIND_PROPERTY_NAMES = 2; - - - /** - * Create a new lock. - */ - private static final int LOCK_CREATION = 0; - - - /** - * Refresh lock. - */ - private static final int LOCK_REFRESH = 1; - - - /** - * Default lock timeout value. - */ - private static final int DEFAULT_TIMEOUT = 3600; - - - /** - * Maximum lock timeout. - */ - private static final int MAX_TIMEOUT = 604800; - - - /** - * Default namespace. - */ - protected static final String DEFAULT_NAMESPACE = "DAV:"; - - - /** - * Simple date format for the creation date ISO representation (partial). - */ - protected static final SimpleDateFormat creationDateFormat = - new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); - - - /** - * MD5 message digest provider. - */ - protected static MessageDigest md5Helper; - - - /** - * The MD5 helper object for this class. - */ - protected static final MD5Encoder md5Encoder = new MD5Encoder(); - - - - static { - creationDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - - // ----------------------------------------------------- Instance Variables - - - /** - * Repository of the locks put on single resources. - *

- * Key : path
- * Value : LockInfo - */ - private Hashtable resourceLocks = - new Hashtable(); - - - /** - * Repository of the lock-null resources. - *

- * Key : path of the collection containing the lock-null resource
- * Value : Vector of lock-null resource which are members of the - * collection. Each element of the Vector is the path associated with - * the lock-null resource. - */ - private Hashtable> lockNullResources = - new Hashtable>(); - - - /** - * Vector of the heritable locks. - *

- * Key : path
- * Value : LockInfo - */ - private Vector collectionLocks = new Vector(); - - - /** - * Secret information used to generate reasonably secure lock ids. - */ - private String secret = "catalina"; - - - /** - * Default depth in spec is infinite. Limit depth to 3 by default as - * infinite depth makes operations very expensive. - */ - private int maxDepth = 3; - - - /** - * Is access allowed via WebDAV to the special paths (/WEB-INF and - * /META-INF)? - */ - private boolean allowSpecialPaths = false; - - - // --------------------------------------------------------- Public Methods - - - /** - * Initialize this servlet. - */ - @Override - public void init() - throws ServletException { - - super.init(); - - if (getServletConfig().getInitParameter("secret") != null) - secret = getServletConfig().getInitParameter("secret"); - - if (getServletConfig().getInitParameter("maxDepth") != null) - maxDepth = Integer.parseInt( - getServletConfig().getInitParameter("maxDepth")); - - if (getServletConfig().getInitParameter("allowSpecialPaths") != null) - allowSpecialPaths = Boolean.parseBoolean( - getServletConfig().getInitParameter("allowSpecialPaths")); - - // Load the MD5 helper used to calculate signatures. - try { - md5Helper = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException e) { - throw new UnavailableException("No MD5"); - } - - String rootPath = getServletConfig().getServletContext().getRealPath("/"); - CaimitoConfig.caimitoroot = rootPath; - //(rootPath + " YELLOW ini " + CaimitoConfig.caimitoroot); - CaimitoConfig.init(); - - } - - - // ------------------------------------------------------ Protected Methods - - - /** - * Return JAXP document builder instance. - */ - protected DocumentBuilder getDocumentBuilder() - throws ServletException { - DocumentBuilder documentBuilder = null; - DocumentBuilderFactory documentBuilderFactory = null; - try { - documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - documentBuilderFactory.setExpandEntityReferences(false); - documentBuilder = documentBuilderFactory.newDocumentBuilder(); - documentBuilder.setEntityResolver( - new WebdavResolver(this.getServletContext())); - } catch(ParserConfigurationException e) { - throw new ServletException - ("webdavservlet.jaxpfailed"); - } - return documentBuilder; - } - - - /** - * Handles the special WebDAV methods. - */ - @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - final String path = getRelativePath(req); - - // Block access to special subdirectories. - // DefaultServlet assumes it services resources from the root of the web app - // and doesn't add any special path protection - // WebdavServlet remounts the webapp under a new path, so this check is - // necessary on all methods (including GET). - // if (isSpecialPath(path)) { - // resp.sendError(WebdavServletStatus.SC_NOT_FOUND); - // return; - //} - - final String method = req.getMethod(); - //(method + " SEEERVICE CAMITO WEBDAV " + path); - - if (debug > 0) { - log("[" + method + "] " + path); - } - - if (method.equals(METHOD_PROPFIND)) { - doPropfind(req, resp); - } else if (method.equals(METHOD_PROPPATCH)) { - doProppatch(req, resp); - } else if (method.equals(METHOD_MKCOL)) { - doMkcol(req, resp); - } else if (method.equals(METHOD_COPY)) { - doCopy(req, resp); - } else if (method.equals(METHOD_MOVE)) { - doMove(req, resp); - } else if (method.equals(METHOD_LOCK)) { - doLock(req, resp); - } else if (method.equals(METHOD_UNLOCK)) { - doUnlock(req, resp); - } else { - // DefaultServlet processing - super.service(req, resp); - } - - } - - - /** - * Checks whether a given path refers to a resource under - * WEB-INF or META-INF. - * @param path the full path of the resource being accessed - * @return true if the resource specified is under a special path - */ - private final boolean isSpecialPath(final String path) { - return !allowSpecialPaths && ( - path.toUpperCase(Locale.ENGLISH).startsWith("/WEB-INF") || - path.toUpperCase(Locale.ENGLISH).startsWith("/META-INF")); - } - - - /** - * Check if the conditions specified in the optional If headers are - * satisfied. - * - * @param request The servlet request we are processing - * @param response The servlet response we are creating - * @param resourceAttributes The resource information - * @return boolean true if the resource meets all the specified conditions, - * and false if any of the conditions is not satisfied, in which case - * request processing is stopped - */ - /*@Override - protected boolean checkIfHeaders(HttpServletRequest request, - HttpServletResponse response, - ResourceAttributes resourceAttributes) - throws IOException { - - if (!super.checkIfHeaders(request, response, resourceAttributes)) - return false; - - // TODO : Checking the WebDAV If header - return true; - - }*/ - - - /** - * Override the DefaultServlet implementation and only use the PathInfo. If - * the ServletPath is non-null, it will be because the WebDAV servlet has - * been mapped to a url other than /* to configure editing at different url - * than normal viewing. - * - * @param request The servlet request we are processing - */ - @Override - protected String getRelativePath(HttpServletRequest request) { - // Are we being processed by a RequestDispatcher.include()? - if (request.getAttribute( - RequestDispatcher.INCLUDE_REQUEST_URI) != null) { - String result = (String) request.getAttribute( - RequestDispatcher.INCLUDE_PATH_INFO); - if ((result == null) || (result.equals(""))) - result = "/"; - /* result = tools.util.StringUtil.replaceSubstring(result,"..",""); - result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); - result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); - result = tools.util.StringUtil.replaceSubstring(result,":",""); -*/ - result = CaimitoUtil.normalize(result); - return (result); - } - - // No, extract the desired path directly from the request - String result = request.getPathInfo(); - if ((result == null) || (result.equals(""))) { - result = "/"; - } - /* - result = tools.util.StringUtil.replaceSubstring(result,"..",""); - result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); - result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); - result = tools.util.StringUtil.replaceSubstring(result,":",""); -*/ - result = CaimitoUtil.normalize(result); - - return (result); - - } - - - /** - * Determines the prefix for standard directory GET listings. - */ - @Override - protected String getPathPrefix(final HttpServletRequest request) { - // Repeat the servlet path (e.g. /webdav/) in the listing path - String contextPath = request.getContextPath(); - if (request.getServletPath() != null) { - contextPath = contextPath + request.getServletPath(); - } - return contextPath; - } - - - /** - * OPTIONS Method. - * - * @param req The request - * @param resp The response - * @throws ServletException If an error occurs - * @throws IOException If an IO error occurs - */ - @Override - protected void doOptions(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - resp.addHeader("DAV", "1,2"); - - StringBuilder methodsAllowed = determineMethodsAllowed(req,resp); - //(methodsAllowed + " DOP 2"); - - resp.addHeader("Allow", methodsAllowed.toString()); - resp.addHeader("MS-Author-Via", "DAV"); - - } - - - /** - * PROPFIND Method. - */ - protected void doPropfind(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - - - String path = getRelativePath(req); - if (path.endsWith("/")) - path = path.substring(0, path.length() - 1); - - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.READ); - if (ro == null)return; - - if (!ro.listings()) { - // Get allowed methods - StringBuilder methodsAllowed = determineMethodsAllowed( req,resp); - - resp.addHeader("Allow", methodsAllowed.toString()); - resp.sendError(WebdavServletStatus.SC_METHOD_NOT_ALLOWED); - return; - } - - // Properties which are to be displayed. - Vector properties = null; - // Propfind depth - int depth = maxDepth; - // Propfind type - int type = FIND_ALL_PROP; - - String depthStr = req.getHeader("Depth"); - - if (depthStr == null) { - depth = maxDepth; - } else { - if (depthStr.equals("0")) { - depth = 0; - } else if (depthStr.equals("1")) { - depth = 1; - } else if (depthStr.equals("infinity")) { - depth = maxDepth; - } - } - - Node propNode = null; - - if (req.getContentLength() > 0) { - DocumentBuilder documentBuilder = getDocumentBuilder(); - - try { - Document document = documentBuilder.parse - (new InputSource(req.getInputStream())); - - // Get the root element of the document - Element rootElement = document.getDocumentElement(); - NodeList childList = rootElement.getChildNodes(); - - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - break; - case Node.ELEMENT_NODE: - if (currentNode.getNodeName().endsWith("prop")) { - type = FIND_BY_PROPERTY; - propNode = currentNode; - } - if (currentNode.getNodeName().endsWith("propname")) { - type = FIND_PROPERTY_NAMES; - } - if (currentNode.getNodeName().endsWith("allprop")) { - type = FIND_ALL_PROP; - } - break; - } - } - } catch (SAXException e) { - // Something went wrong - bad request - resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); - } catch (IOException e) { - // Something went wrong - bad request - resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); - } - } - - //(path + " PROP FINDE TYPE " + type ); - if (type == FIND_BY_PROPERTY) { - properties = new Vector(); - // propNode must be non-null if type == FIND_BY_PROPERTY - @SuppressWarnings("null") - NodeList childList = propNode.getChildNodes(); - - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - break; - case Node.ELEMENT_NODE: - String nodeName = currentNode.getNodeName(); - String propertyName = null; - if (nodeName.indexOf(':') != -1) { - propertyName = nodeName.substring - (nodeName.indexOf(':') + 1); - } else { - propertyName = nodeName; - } - // href is a live property which is handled differently - properties.addElement(propertyName); - break; - } - } - - } - - boolean exists = ro.exists(); - /*Object object = null; - try { - object = resources.lookup(path); - } catch (NamingException e) { - exists = false; - int slash = path.lastIndexOf('/'); - if (slash != -1) { - String parentPath = path.substring(0, slash); - Vector currentLockNullResources = - lockNullResources.get(parentPath); - if (currentLockNullResources != null) { - Enumeration lockNullResourcesList = - currentLockNullResources.elements(); - while (lockNullResourcesList.hasMoreElements()) { - String lockNullPath = - lockNullResourcesList.nextElement(); - if (lockNullPath.equals(path)) { - resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); - resp.setContentType("text/xml; charset=UTF-8"); - // Create multistatus object - XMLWriter generatedXML = - new XMLWriter(resp.getWriter()); - generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, - "multistatus", XMLWriter.OPENING); - parseLockNullProperties - (req, generatedXML, lockNullPath, type, - properties); - generatedXML.writeElement("D", "multistatus", - XMLWriter.CLOSING); - generatedXML.sendData(); - return; - } - } - } - } - }*/ - - if (!exists) { - resp.sendError(HttpServletResponse.SC_NOT_FOUND, path); - return; - } - - resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); - - resp.setContentType("text/xml; charset=UTF-8"); - - // Create multistatus object - XMLWriter generatedXML = new XMLWriter(resp.getWriter()); - generatedXML.writeXMLHeader(); - - generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", - XMLWriter.OPENING); - - if (depth == 0) { - parseProperties(req,resp, generatedXML, path, type, - properties); - } else { - // The stack always contains the object of the current level - Stack stack = new Stack(); - stack.push(path); - - // Stack of the objects one level below - Stack stackBelow = new Stack(); - ResourceObj rob = null; - while ((!stack.isEmpty()) && (depth >= 0)) { - - String currentPath = stack.pop(); - parseProperties(req,resp, generatedXML, currentPath, - type, properties); - - // try { - //object = resources.lookup(currentPath); - rob = ResourceStore.lookup(currentPath,req,resp,ResourceStore.READ); - - // } catch (Exception e) { - // continue; - // } - - if ((rob.isDirectory()) && (depth > 0)) { - - try { - Enumeration enumeration = - rob.list().elements(); - while (enumeration.hasMoreElements()) { - ResourceObj ncPair = enumeration.nextElement(); - //String newPath = currentPath; - //if (!(newPath.endsWith("/"))) - // newPath += "/"; - //newPath += ncPair.getName(); - stackBelow.push(ncPair.path); - } - } catch (Exception e) { - e.printStackTrace(); - resp.sendError - (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - path); - return; - } - - // Displaying the lock-null resources present in that - // collection - String lockPath = currentPath; - if (lockPath.endsWith("/")) - lockPath = - lockPath.substring(0, lockPath.length() - 1); - Vector currentLockNullResources = - lockNullResources.get(lockPath); - if (currentLockNullResources != null) { - Enumeration lockNullResourcesList = - currentLockNullResources.elements(); - while (lockNullResourcesList.hasMoreElements()) { - String lockNullPath = - lockNullResourcesList.nextElement(); - parseLockNullProperties - (req, generatedXML, lockNullPath, type, - properties); - } - } - - } - - if (stack.isEmpty()) { - depth--; - stack = stackBelow; - stackBelow = new Stack(); - } - - generatedXML.sendData(); - - } - } - - generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); - - generatedXML.sendData(); - //("generatedXML,value " + generatedXML); - - } - - - /** - * PROPPATCH Method. - */ - protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) - throws IOException { -/* - if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } - - resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); -*/ - //resp.setStatus(200); - resp.setContentType("text/xml"); - String propr = "\r\n" + -"\r\n" + -" \r\n" + - " \r\n" + - " HTTP/1.1 200 OK\r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + - " \r\n" + -"\r\n"; -resp.getWriter().print(propr); - - } - - - /** - * MKCOL Method. - */ - protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - /*if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - }*/ - - String path = getRelativePath(req); - - /*boolean exists = true; - try { - resources.lookup(path); - } catch (NamingException e) { - exists = false; - }*/ - - // Can't create a collection if a resource already exists at the given - // path - - - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); - if (ro == null)return; - - if (!ro.canWrite()) { - resp.sendError(HttpServletResponse.SC_FORBIDDEN); - return; - } - - boolean exists = ro.exists(); - - if (exists) { - // Get allowed methods - StringBuilder methodsAllowed = determineMethodsAllowed( req,resp); - - resp.addHeader("Allow", methodsAllowed.toString()); - - resp.sendError(WebdavServletStatus.SC_METHOD_NOT_ALLOWED); - return; - } - - if (req.getContentLength() > 0) { - //("MKCOL IS MORE DATA"); - DocumentBuilder documentBuilder = getDocumentBuilder(); - try { - // Document document = - documentBuilder.parse(new InputSource(req.getInputStream())); - // TODO : Process this request body - resp.sendError(WebdavServletStatus.SC_NOT_IMPLEMENTED); - return; - - } catch(SAXException saxe) { - // Parse error - assume invalid content - resp.sendError(WebdavServletStatus.SC_UNSUPPORTED_MEDIA_TYPE); - return; - } - } - - try{ - ro.mkdir(); - resp.setStatus(WebdavServletStatus.SC_CREATED); - - }catch (Exception e){ - e.printStackTrace(); - resp.sendError(WebdavServletStatus.SC_CONFLICT, - WebdavServletStatus.getStatusText - (WebdavServletStatus.SC_CONFLICT)); - } - - /*boolean result = true; - try { - resources.createSubcontext(path); - } catch (NamingException e) { - result = false; - } - - if (!result) { - resp.sendError(WebdavServletStatus.SC_CONFLICT, - WebdavServletStatus.getStatusText - (WebdavServletStatus.SC_CONFLICT)); - } else { - resp.setStatus(WebdavServletStatus.SC_CREATED); - // Removing any lock-null resource which would be present - lockNullResources.remove(path); - }*/ - - } - - - /** - * DELETE Method. - */ - /*@Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } - - deleteResource(req, resp); - - }*/ - - - /** - * Process a PUT request for the specified resource. - * - * @param req The servlet request we are processing - * @param resp The servlet response we are creating - * - * @exception IOException if an input/output error occurs - * @exception ServletException if a servlet-specified error occurs - */ - @Override - protected void doPut(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - String path = getRelativePath(req); - - if (isLocked(req)) { - //(path + " IS A LIOCLLERD "); - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } - - super.doPut(req, resp); - - - // Removing any lock-null resource which would be present - lockNullResources.remove(path); - - } - - /** - * COPY Method. - */ - protected void doCopy(HttpServletRequest req, HttpServletResponse resp) - throws ServletException,IOException { - - /// if (readOnly) { - // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - // return; - // } - - copyResource(req, resp); - - } - - - - private boolean moveResource(HttpServletRequest req, - HttpServletResponse resp) - throws CaimitoException,IOException { - - // Parsing destination header - - String destinationPath = req.getHeader("Destination"); - - if (destinationPath == null) { - resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); - return false; - } - - // Remove url encoding from destination - destinationPath = org.apache.catalina.util.RequestUtil.URLDecode( - destinationPath, "UTF8"); - - int protocolIndex = destinationPath.indexOf("://"); - if (protocolIndex >= 0) { - // if the Destination URL contains the protocol, we can safely - // trim everything upto the first "/" character after "://" - int firstSeparator = - destinationPath.indexOf("/", protocolIndex + 4); - if (firstSeparator < 0) { - destinationPath = "/"; - } else { - destinationPath = destinationPath.substring(firstSeparator); - } - } else { - String hostName = req.getServerName(); - if ((hostName != null) && (destinationPath.startsWith(hostName))) { - destinationPath = destinationPath.substring(hostName.length()); - } - - int portIndex = destinationPath.indexOf(":"); - if (portIndex >= 0) { - destinationPath = destinationPath.substring(portIndex); - } - - if (destinationPath.startsWith(":")) { - int firstSeparator = destinationPath.indexOf("/"); - if (firstSeparator < 0) { - destinationPath = "/"; - } else { - destinationPath = - destinationPath.substring(firstSeparator); - } - } - } - - // Normalise destination path (remove '.' and '..') - destinationPath = RequestUtil.normalize(destinationPath); - - String contextPath = req.getContextPath(); - if ((contextPath != null) && - (destinationPath.startsWith(contextPath))) { - destinationPath = destinationPath.substring(contextPath.length()); - } - - String pathInfo = req.getPathInfo(); - if (pathInfo != null) { - String servletPath = req.getServletPath(); - if ((servletPath != null) && - (destinationPath.startsWith(servletPath))) { - destinationPath = destinationPath - .substring(servletPath.length()); - } - } - - if (debug > 0) - log("Dest path :" + destinationPath); - - // Check destination path to protect special subdirectories - //if (isSpecialPath(destinationPath)) { - // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - // return false; - //} - - String path = getRelativePath(req); - - if (destinationPath.equals(path)) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return false; - } - - // Parsing overwrite header - - boolean overwrite = true; - String overwriteHeader = req.getHeader("Overwrite"); - - if (overwriteHeader != null) { - if (overwriteHeader.equalsIgnoreCase("T")) { - overwrite = true; - } else { - overwrite = false; - } - } - - // Overwriting the destination - ResourceObj ro = ResourceStore.lookup(destinationPath,req,resp,ResourceStore.WRITE); - if (ro == null) - return false; - - ResourceObj ros = ResourceStore.lookup(path,req,resp,ResourceStore.READ); - - // if (!ro.canWrite() || !ros.canWrite()) { - if (ro == null || ros == null){ - - //resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - //return false; - return false; - } - - boolean exists = ro.exists(); - /*try { - resources.lookup(destinationPath); - } catch (NamingException e) { - exists = false; - }*/ - - if (overwrite) { - - // destination resource, if it exists - if (exists) { - //if (! Resource(destinationPath, req, resp, true)) { - // return false; - //} - ro.delete(); - } else { - resp.setStatus(WebdavServletStatus.SC_CREATED); - } - - } else { - - // If the destination exists, then it's a conflict - if (exists) { - resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); - return false; - } - - } - - // Copying source to destination - - ros.move(ro); - /*Hashtable errorList = new Hashtable(); - - boolean result = copyResource(resources, errorList, - path, destinationPath); - - if ((!result) || (!errorList.isEmpty())) { - if (errorList.size() == 1) { - resp.sendError(errorList.elements().nextElement().intValue()); - } else { - sendReport(req, resp, errorList); - } - return false; - }*/ - - // Copy was successful - if (exists) { - resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); - } else { - resp.setStatus(WebdavServletStatus.SC_CREATED); - } - - // Removing any lock-null resource which would be present at - // the destination path - lockNullResources.remove(destinationPath); - - return true; - - } - - /** - * MOVE Method. - */ - protected void doMove(HttpServletRequest req, HttpServletResponse resp) - throws ServletException,IOException { - - /*if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - }*/ - - /*String path = getRelativePath(req); - ResourceObj ros = ResourceStore.lookup(path,req,resp); - - if (!ros.canWrite()) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return ; - }*/ - - moveResource(req, resp); - // Resource(path, req, resp, false); - //ros.move(); - //} - - } - - - /** - * LOCK Method. - */ - - /* - protected void doLock(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - }*/ - protected void doLock(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - - /*if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - }*/ - - LockInfo lock = new LockInfo(); - - - String depthStr = req.getHeader("Depth"); - - if (depthStr == null) { - lock.depth = maxDepth; - } else { - if (depthStr.equals("0")) { - lock.depth = 0; - } else { - lock.depth = maxDepth; - } - } - - // Parsing timeout header - - int lockDuration = DEFAULT_TIMEOUT; - String lockDurationStr = req.getHeader("Timeout"); - if (lockDurationStr == null) { - lockDuration = DEFAULT_TIMEOUT; - } else { - int commaPos = lockDurationStr.indexOf(","); - // If multiple timeouts, just use the first - if (commaPos != -1) { - lockDurationStr = lockDurationStr.substring(0,commaPos); - } - if (lockDurationStr.startsWith("Second-")) { - lockDuration = - (new Integer(lockDurationStr.substring(7))).intValue(); - } else { - if (lockDurationStr.equalsIgnoreCase("infinity")) { - lockDuration = MAX_TIMEOUT; - } else { - try { - lockDuration = - (new Integer(lockDurationStr)).intValue(); - } catch (NumberFormatException e) { - lockDuration = MAX_TIMEOUT; - } - } - } - if (lockDuration == 0) { - lockDuration = DEFAULT_TIMEOUT; - } - if (lockDuration > MAX_TIMEOUT) { - lockDuration = MAX_TIMEOUT; - } - } - lock.expiresAt = System.currentTimeMillis() + (lockDuration * 1000); - - int lockRequestType = LOCK_CREATION; - - Node lockInfoNode = null; - - DocumentBuilder documentBuilder = getDocumentBuilder(); - - try { - Document document = documentBuilder.parse(new InputSource - (req.getInputStream())); - - // Get the root element of the document - Element rootElement = document.getDocumentElement(); - lockInfoNode = rootElement; - } catch (IOException e) { - lockRequestType = LOCK_REFRESH; - } catch (SAXException e) { - lockRequestType = LOCK_REFRESH; - } - - if (lockInfoNode != null) { - - // Reading lock information - - NodeList childList = lockInfoNode.getChildNodes(); - StringWriter strWriter = null; - DOMWriter domWriter = null; - - Node lockScopeNode = null; - Node lockTypeNode = null; - Node lockOwnerNode = null; - - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - break; - case Node.ELEMENT_NODE: - String nodeName = currentNode.getNodeName(); - if (nodeName.endsWith("lockscope")) { - lockScopeNode = currentNode; - } - if (nodeName.endsWith("locktype")) { - lockTypeNode = currentNode; - } - if (nodeName.endsWith("owner")) { - lockOwnerNode = currentNode; - } - break; - } - } - - if (lockScopeNode != null) { - - childList = lockScopeNode.getChildNodes(); - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - break; - case Node.ELEMENT_NODE: - String tempScope = currentNode.getNodeName(); - if (tempScope.indexOf(':') != -1) { - lock.scope = tempScope.substring - (tempScope.indexOf(':') + 1); - } else { - lock.scope = tempScope; - } - break; - } - } - - if (lock.scope == null) { - // Bad request - resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); - } - - } else { - // Bad request - resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); - } - - if (lockTypeNode != null) { - - childList = lockTypeNode.getChildNodes(); - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - break; - case Node.ELEMENT_NODE: - String tempType = currentNode.getNodeName(); - if (tempType.indexOf(':') != -1) { - lock.type = - tempType.substring(tempType.indexOf(':') + 1); - } else { - lock.type = tempType; - } - break; - } - } - - if (lock.type == null) { - // Bad request - resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); - } - - } else { - // Bad request - resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); - } - - if (lockOwnerNode != null) { - - childList = lockOwnerNode.getChildNodes(); - for (int i=0; i < childList.getLength(); i++) { - Node currentNode = childList.item(i); - switch (currentNode.getNodeType()) { - case Node.TEXT_NODE: - lock.owner += currentNode.getNodeValue(); - break; - case Node.ELEMENT_NODE: - strWriter = new StringWriter(); - domWriter = new DOMWriter(strWriter, true); - domWriter.setQualifiedNames(false); - domWriter.print(currentNode); - lock.owner += strWriter.toString(); - break; - } - } - - if (lock.owner == null) { - // Bad request - resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); - } - - } else { - lock.owner = ""; - } - - } - - String path = getRelativePath(req); - - lock.path = path; - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); - if (ro == null)return; - boolean exists = ro.exists(); - /*Object object = null; - try { - object = resources.lookup(path); - } catch (NamingException e) { - exists = false; - }*/ - - Enumeration locksList = null; - - if (lockRequestType == LOCK_CREATION) { - - // Generating lock id - String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" - + lock.scope + "-" + req.getUserPrincipal() + "-" - + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" - + lock.expiresAt + "-" + System.currentTimeMillis() + "-" - + secret; - String lockToken = md5Encoder.encode(md5Helper.digest( - lockTokenStr.getBytes(Charset.defaultCharset()))); - - if ( (exists) && (ro.isDirectory()) && - (lock.depth == maxDepth) ) { - - // Locking a collection (and all its member resources) - - // Checking if a child resource of this collection is - // already locked - Vector lockPaths = new Vector(); - locksList = collectionLocks.elements(); - while (locksList.hasMoreElements()) { - LockInfo currentLock = locksList.nextElement(); - if (currentLock.hasExpired()) { - resourceLocks.remove(currentLock.path); - continue; - } - if ( (currentLock.path.startsWith(lock.path)) && - ((currentLock.isExclusive()) || - (lock.isExclusive())) ) { - // A child collection of this collection is locked - lockPaths.addElement(currentLock.path); - } - } - locksList = resourceLocks.elements(); - while (locksList.hasMoreElements()) { - LockInfo currentLock = locksList.nextElement(); - if (currentLock.hasExpired()) { - resourceLocks.remove(currentLock.path); - continue; - } - if ( (currentLock.path.startsWith(lock.path)) && - ((currentLock.isExclusive()) || - (lock.isExclusive())) ) { - // A child resource of this collection is locked - lockPaths.addElement(currentLock.path); - } - } - - if (!lockPaths.isEmpty()) { - - // One of the child paths was locked - // We generate a multistatus error report - - Enumeration lockPathsList = lockPaths.elements(); - - resp.setStatus(WebdavServletStatus.SC_CONFLICT); - - XMLWriter generatedXML = new XMLWriter(); - generatedXML.writeXMLHeader(); - - generatedXML.writeElement("D", DEFAULT_NAMESPACE, - "multistatus", XMLWriter.OPENING); - - while (lockPathsList.hasMoreElements()) { - generatedXML.writeElement("D", "response", - XMLWriter.OPENING); - generatedXML.writeElement("D", "href", - XMLWriter.OPENING); - generatedXML.writeText(lockPathsList.nextElement()); - generatedXML.writeElement("D", "href", - XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", - XMLWriter.OPENING); - generatedXML - .writeText("HTTP/1.1 " + WebdavServletStatus.SC_LOCKED - + " " + WebdavServletStatus - .getStatusText(WebdavServletStatus.SC_LOCKED)); - generatedXML.writeElement("D", "status", - XMLWriter.CLOSING); - - generatedXML.writeElement("D", "response", - XMLWriter.CLOSING); - } - - generatedXML.writeElement("D", "multistatus", - XMLWriter.CLOSING); - - Writer writer = resp.getWriter(); - writer.write(generatedXML.toString()); - writer.close(); - - return; - - } - - boolean addLock = true; - - // Checking if there is already a shared lock on this path - locksList = collectionLocks.elements(); - while (locksList.hasMoreElements()) { - - LockInfo currentLock = locksList.nextElement(); - if (currentLock.path.equals(lock.path)) { - - if (currentLock.isExclusive()) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } else { - if (lock.isExclusive()) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } - } - - currentLock.tokens.addElement(lockToken); - lock = currentLock; - addLock = false; - - } - - } - - if (addLock) { - lock.tokens.addElement(lockToken); - collectionLocks.addElement(lock); - } - - } else { - - // Locking a single resource - - // Retrieving an already existing lock on that resource - LockInfo presentLock = resourceLocks.get(lock.path); - if (presentLock != null) { - - if ((presentLock.isExclusive()) || (lock.isExclusive())) { - // If either lock is exclusive, the lock can't be - // granted - resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); - return; - } else { - presentLock.tokens.addElement(lockToken); - lock = presentLock; - } - - } else { - - lock.tokens.addElement(lockToken); - //FREE WORLD - //resourceLocks.put(lock.path, lock); - - // Checking if a resource exists at this path - /*exists = true; - try { - object = resources.lookup(path); - } catch (NamingException e) { - exists = false; - }*/ - if (!exists) { - - // "Creating" a lock-null resource - int slash = lock.path.lastIndexOf('/'); - String parentPath = lock.path.substring(0, slash); - - Vector lockNulls = - lockNullResources.get(parentPath); - if (lockNulls == null) { - lockNulls = new Vector(); - //FREE WORLD - //lockNullResources.put(parentPath, lockNulls); - } - - //FREE WORLD - //lockNulls.addElement(lock.path); - - } - // Add the Lock-Token header as by RFC 2518 8.10.1 - // - only do this for newly created locks - resp.addHeader("Lock-Token", ""); - //(" LOCKY TOKEN " + lockToken); - } - - } - - } - - if (lockRequestType == LOCK_REFRESH) { - - String ifHeader = req.getHeader("If"); - if (ifHeader == null) - ifHeader = ""; - - // Checking resource locks - - LockInfo toRenew = resourceLocks.get(path); - Enumeration tokenList = null; - - if (toRenew != null) { - // At least one of the tokens of the locks must have been given - tokenList = toRenew.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (ifHeader.indexOf(token) != -1) { - toRenew.expiresAt = lock.expiresAt; - lock = toRenew; - } - } - } - - // Checking inheritable collection locks - - Enumeration collectionLocksList = - collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - toRenew = collectionLocksList.nextElement(); - if (path.equals(toRenew.path)) { - - tokenList = toRenew.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (ifHeader.indexOf(token) != -1) { - toRenew.expiresAt = lock.expiresAt; - lock = toRenew; - } - } - - } - } - - } - - // Set the status, then generate the XML response containing - // the lock information - XMLWriter generatedXML = new XMLWriter(); - generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, "prop", - XMLWriter.OPENING); - - generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING); - - lock.toXML(generatedXML); - - generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - - resp.setStatus(WebdavServletStatus.SC_OK); - resp.setContentType("text/xml; charset=UTF-8"); - Writer writer = resp.getWriter(); - writer.write(generatedXML.toString()); - //(path + " XMLE RITER W " + generatedXML.toString()); - writer.close(); - - } - - - /** - * UNLOCK Method. - */ - protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - - } - - protected void doUnlock1(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - - if (readOnly) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return; - } - - if (isLocked(req)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return; - } - - String path = getRelativePath(req); - - String lockTokenHeader = req.getHeader("Lock-Token"); - if (lockTokenHeader == null) - lockTokenHeader = ""; - - // Checking resource locks - - LockInfo lock = resourceLocks.get(path); - Enumeration tokenList = null; - if (lock != null) { - - // At least one of the tokens of the locks must have been given - - tokenList = lock.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (lockTokenHeader.indexOf(token) != -1) { - lock.tokens.removeElement(token); - } - } - - if (lock.tokens.isEmpty()) { - resourceLocks.remove(path); - // Removing any lock-null resource which would be present - lockNullResources.remove(path); - } - - } - - // Checking inheritable collection locks - - Enumeration collectionLocksList = collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - lock = collectionLocksList.nextElement(); - if (path.equals(lock.path)) { - - tokenList = lock.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (lockTokenHeader.indexOf(token) != -1) { - lock.tokens.removeElement(token); - break; - } - } - - if (lock.tokens.isEmpty()) { - collectionLocks.removeElement(lock); - // Removing any lock-null resource which would be present - lockNullResources.remove(path); - } - - } - } - - resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); - - } - - // -------------------------------------------------------- Private Methods - - /** - * Check to see if a resource is currently write locked. The method - * will look at the "If" header to make sure the client - * has give the appropriate lock tokens. - * - * @param req Servlet request - * @return boolean true if the resource is locked (and no appropriate - * lock token has been found for at least one of the non-shared locks which - * are present on the resource). - */ - private boolean isLocked(HttpServletRequest req) { - - String path = getRelativePath(req); - - String ifHeader = req.getHeader("If"); - if (ifHeader == null) - ifHeader = ""; - - String lockTokenHeader = req.getHeader("Lock-Token"); - if (lockTokenHeader == null) - lockTokenHeader = ""; - - return isLocked(path, ifHeader + lockTokenHeader); - - } - - - /** - * Check to see if a resource is currently write locked. - * - * @param path Path of the resource - * @param ifHeader "If" HTTP header which was included in the request - * @return boolean true if the resource is locked (and no appropriate - * lock token has been found for at least one of the non-shared locks which - * are present on the resource). - */ - private boolean isLocked(String path, String ifHeader) { - - // Checking resource locks - - LockInfo lock = resourceLocks.get(path); - Enumeration tokenList = null; - if ((lock != null) && (lock.hasExpired())) { - resourceLocks.remove(path); - } else if (lock != null) { - - // At least one of the tokens of the locks must have been given - - tokenList = lock.tokens.elements(); - boolean tokenMatch = false; - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (ifHeader.indexOf(token) != -1) - tokenMatch = true; - } - if (!tokenMatch) - return true; - - } - - // Checking inheritable collection locks - - Enumeration collectionLocksList = collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - lock = collectionLocksList.nextElement(); - if (lock.hasExpired()) { - collectionLocks.removeElement(lock); - } else if (path.startsWith(lock.path)) { - - tokenList = lock.tokens.elements(); - boolean tokenMatch = false; - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); - if (ifHeader.indexOf(token) != -1) - tokenMatch = true; - } - if (!tokenMatch) - return true; - - } - } - - return false; - - } - - - /** - * Copy a resource. - * - * @param req Servlet request - * @param resp Servlet response - * @return boolean true if the copy is successful - */ - private boolean copyResource(HttpServletRequest req, - HttpServletResponse resp) - throws CaimitoException,IOException { - - // Parsing destination header - - String destinationPath = req.getHeader("Destination"); - - if (destinationPath == null) { - resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); - return false; - } - - // Remove url encoding from destination - destinationPath = org.apache.catalina.util.RequestUtil.URLDecode( - destinationPath, "UTF8"); - - int protocolIndex = destinationPath.indexOf("://"); - if (protocolIndex >= 0) { - // if the Destination URL contains the protocol, we can safely - // trim everything upto the first "/" character after "://" - int firstSeparator = - destinationPath.indexOf("/", protocolIndex + 4); - if (firstSeparator < 0) { - destinationPath = "/"; - } else { - destinationPath = destinationPath.substring(firstSeparator); - } - } else { - String hostName = req.getServerName(); - if ((hostName != null) && (destinationPath.startsWith(hostName))) { - destinationPath = destinationPath.substring(hostName.length()); - } - - int portIndex = destinationPath.indexOf(":"); - if (portIndex >= 0) { - destinationPath = destinationPath.substring(portIndex); - } - - if (destinationPath.startsWith(":")) { - int firstSeparator = destinationPath.indexOf("/"); - if (firstSeparator < 0) { - destinationPath = "/"; - } else { - destinationPath = - destinationPath.substring(firstSeparator); - } - } - } - - // Normalise destination path (remove '.' and '..') - destinationPath = RequestUtil.normalize(destinationPath); - - String contextPath = req.getContextPath(); - if ((contextPath != null) && - (destinationPath.startsWith(contextPath))) { - destinationPath = destinationPath.substring(contextPath.length()); - } - - String pathInfo = req.getPathInfo(); - if (pathInfo != null) { - String servletPath = req.getServletPath(); - if ((servletPath != null) && - (destinationPath.startsWith(servletPath))) { - destinationPath = destinationPath - .substring(servletPath.length()); - } - } - - if (debug > 0) - log("Dest path :" + destinationPath); - - // Check destination path to protect special subdirectories - //if (isSpecialPath(destinationPath)) { - // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - // return false; - //} - - String path = getRelativePath(req); - - if (destinationPath.equals(path)) { - resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return false; - } - - // Parsing overwrite header - - boolean overwrite = true; - String overwriteHeader = req.getHeader("Overwrite"); - - if (overwriteHeader != null) { - if (overwriteHeader.equalsIgnoreCase("T")) { - overwrite = true; - } else { - overwrite = false; - } - } - - // Overwriting the destination - ResourceObj ro = ResourceStore.lookup(destinationPath,req,resp,ResourceStore.WRITE); - ResourceObj ros = ResourceStore.lookup(path,req,resp,ResourceStore.READ); - - if (ro == null || ros == null){ - - //if (!ro.canWrite() || !ros.canRead()) { - //resp.sendError(WebdavServletStatus.SC_FORBIDDEN); - return false; - } - - boolean exists = ro.exists(); - /*try { - resources.lookup(destinationPath); - } catch (NamingException e) { - exists = false; - }*/ - - if (overwrite) { - - // destination resource, if it exists - if (exists) { - //if (! Resource(destinationPath, req, resp, true)) { - // return false; - //} - ro.delete(); - } else { - resp.setStatus(WebdavServletStatus.SC_CREATED); - } - - } else { - - // If the destination exists, then it's a conflict - if (exists) { - resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); - return false; - } - - } - - // Copying source to destination - - ros.copy(ro); - /*Hashtable errorList = new Hashtable(); - - boolean result = copyResource(resources, errorList, - path, destinationPath); - - if ((!result) || (!errorList.isEmpty())) { - if (errorList.size() == 1) { - resp.sendError(errorList.elements().nextElement().intValue()); - } else { - sendReport(req, resp, errorList); - } - return false; - }*/ - - // Copy was successful - if (exists) { - resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); - } else { - resp.setStatus(WebdavServletStatus.SC_CREATED); - } - - // Removing any lock-null resource which would be present at - // the destination path - lockNullResources.remove(destinationPath); - - return true; - - } - - - /** - * Copy a collection. - * - * @param dirContext Resources implementation to be used - * @param errorList Hashtable containing the list of errors which occurred - * during the copy operation - * @param source Path of the resource to be copied - * @param dest Destination path - */ - private boolean copyResource(DirContext dirContext, - Hashtable errorList, String source, String dest) { - - if (debug > 1) - log("Copy: " + source + " To: " + dest); - - Object object = null; - try { - object = dirContext.lookup(source); - } catch (NamingException e) { - // Ignore - } - - if (object instanceof DirContext) { - - try { - dirContext.createSubcontext(dest); - } catch (NamingException e) { - errorList.put - (dest, new Integer(WebdavServletStatus.SC_CONFLICT)); - return false; - } - - try { - NamingEnumeration enumeration = - dirContext.list(source); - while (enumeration.hasMoreElements()) { - NameClassPair ncPair = enumeration.nextElement(); - String childDest = dest; - if (!childDest.equals("/")) - childDest += "/"; - childDest += ncPair.getName(); - String childSrc = source; - if (!childSrc.equals("/")) - childSrc += "/"; - childSrc += ncPair.getName(); - copyResource(dirContext, errorList, childSrc, childDest); - } - } catch (NamingException e) { - errorList.put - (dest, new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - return false; - } - - } else { - - if (object instanceof Resource) { - try { - dirContext.bind(dest, object); - } catch (NamingException e) { - if (e.getCause() instanceof FileNotFoundException) { - // We know the source exists so it must be the - // destination dir that can't be found - errorList.put(source, - new Integer(WebdavServletStatus.SC_CONFLICT)); - } else { - errorList.put(source, - new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - } - return false; - } - } else { - errorList.put - (source, - new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - return false; - } - - } - - return true; - - } - - - /** - * Delete a resource. - * - * @param req Servlet request - * @param resp Servlet response - * @return boolean true if the copy is successful - */ - private boolean deleteResource(HttpServletRequest req, - HttpServletResponse resp) - throws IOException { - - String path = getRelativePath(req); - - return deleteResource(path, req, resp, true); - - } - - - /** - * Delete a resource. - * - * @param path Path of the resource which is to be deleted - * @param req Servlet request - * @param resp Servlet response - * @param setStatus Should the response status be set on successful - * completion - */ - private boolean deleteResource(String path, HttpServletRequest req, - HttpServletResponse resp, boolean setStatus) - throws IOException { - - String ifHeader = req.getHeader("If"); - if (ifHeader == null) - ifHeader = ""; - - String lockTokenHeader = req.getHeader("Lock-Token"); - if (lockTokenHeader == null) - lockTokenHeader = ""; - - if (isLocked(path, ifHeader + lockTokenHeader)) { - resp.sendError(WebdavServletStatus.SC_LOCKED); - return false; - } - - boolean exists = true; - Object object = null; - try { - object = resources.lookup(path); - } catch (NamingException e) { - exists = false; - } - - if (!exists) { - resp.sendError(WebdavServletStatus.SC_NOT_FOUND); - return false; - } - - boolean collection = (object instanceof DirContext); - - if (!collection) { - try { - resources.unbind(path); - } catch (NamingException e) { - resp.sendError(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR); - return false; - } - } else { - - Hashtable errorList = - new Hashtable(); - - deleteCollection(req, resources, path, errorList); - try { - resources.unbind(path); - } catch (NamingException e) { - errorList.put(path, new Integer - (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - } - - if (!errorList.isEmpty()) { - - sendReport(req, resp, errorList); - return false; - - } - - } - if (setStatus) { - resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); - } - return true; - - } - - - /** - * Deletes a collection. - * - * @param dirContext Resources implementation associated with the context - * @param path Path to the collection to be deleted - * @param errorList Contains the list of the errors which occurred - */ - private void deleteCollection(HttpServletRequest req, - DirContext dirContext, - String path, - Hashtable errorList) { - - if (debug > 1) - log("Delete:" + path); - - // Prevent deletion of special subdirectories - if (isSpecialPath(path)) { - errorList.put(path, new Integer(WebdavServletStatus.SC_FORBIDDEN)); - return; - } - - String ifHeader = req.getHeader("If"); - if (ifHeader == null) - ifHeader = ""; - - String lockTokenHeader = req.getHeader("Lock-Token"); - if (lockTokenHeader == null) - lockTokenHeader = ""; - - Enumeration enumeration = null; - try { - enumeration = dirContext.list(path); - } catch (NamingException e) { - errorList.put(path, new Integer - (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - return; - } - - while (enumeration.hasMoreElements()) { - NameClassPair ncPair = enumeration.nextElement(); - String childName = path; - if (!childName.equals("/")) - childName += "/"; - childName += ncPair.getName(); - - if (isLocked(childName, ifHeader + lockTokenHeader)) { - - errorList.put(childName, new Integer(WebdavServletStatus.SC_LOCKED)); - - } else { - - try { - Object object = dirContext.lookup(childName); - if (object instanceof DirContext) { - deleteCollection(req, dirContext, childName, errorList); - } - - try { - dirContext.unbind(childName); - } catch (NamingException e) { - if (!(object instanceof DirContext)) { - // If it's not a collection, then it's an unknown - // error - errorList.put - (childName, new Integer - (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - } - } - } catch (NamingException e) { - errorList.put - (childName, new Integer - (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); - } - } - - } - - } - - - /** - * Send a multistatus element containing a complete error report to the - * client. - * - * @param req Servlet request - * @param resp Servlet response - * @param errorList List of error to be displayed - */ - private void sendReport(HttpServletRequest req, HttpServletResponse resp, - Hashtable errorList) - throws IOException { - - resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); - - String absoluteUri = req.getRequestURI(); - String relativePath = getRelativePath(req); - - XMLWriter generatedXML = new XMLWriter(); - generatedXML.writeXMLHeader(); - - generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", - XMLWriter.OPENING); - - Enumeration pathList = errorList.keys(); - while (pathList.hasMoreElements()) { - - String errorPath = pathList.nextElement(); - int errorCode = errorList.get(errorPath).intValue(); - - generatedXML.writeElement("D", "response", XMLWriter.OPENING); - - generatedXML.writeElement("D", "href", XMLWriter.OPENING); - String toAppend = errorPath.substring(relativePath.length()); - if (!toAppend.startsWith("/")) - toAppend = "/" + toAppend; - generatedXML.writeText(absoluteUri + toAppend); - generatedXML.writeElement("D", "href", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText("HTTP/1.1 " + errorCode + " " - + WebdavServletStatus.getStatusText(errorCode)); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "response", XMLWriter.CLOSING); - - } - - generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); - - Writer writer = resp.getWriter(); - writer.write(generatedXML.toString()); - writer.close(); - - } - - - /** - * Propfind helper method. - * - * @param req The servlet request - * @param resources Resources object associated with this context - * @param generatedXML XML response to the Propfind request - * @param path Path of the current resource - * @param type Propfind type - * @param propertiesVector If the propfind type is find properties by - * name, then this Vector contains those properties - */ - private void parseProperties(HttpServletRequest req,HttpServletResponse resp, - XMLWriter generatedXML, - String path, int type, - Vector propertiesVector) throws CaimitoException { - - // Exclude any resource in the /WEB-INF and /META-INF subdirectories - // if (isSpecialPath(path)) - // return; - - // CacheEntry cacheEntry = resources.lookupCache(path); - //(type + " parseProperties Z Prop " + path); - ResourceObj cacheEntry = ResourceStore.lookup(path,req,resp,ResourceStore.READ); - - if (!cacheEntry.exists()) { - // File is in directory listing but doesn't appear to exist - // Broken symlink or odd permission settings? - return; - } - - generatedXML.writeElement("D", "response", XMLWriter.OPENING); - String status = "HTTP/1.1 " + WebdavServletStatus.SC_OK + " " + - WebdavServletStatus.getStatusText(WebdavServletStatus.SC_OK); - - // Generating href element - generatedXML.writeElement("D", "href", XMLWriter.OPENING); - - String href = req.getContextPath() + req.getServletPath(); - if ((href.endsWith("/")) && (path.startsWith("/"))) - href += path.substring(1); - else - href += path; - if ((cacheEntry.isDirectory()) && (!href.endsWith("/"))) - href += "/"; - - generatedXML.writeText(rewriteUrl(href)); - - generatedXML.writeElement("D", "href", XMLWriter.CLOSING); - - String resourceName = path; - int lastSlash = path.lastIndexOf('/'); - if (lastSlash != -1) - resourceName = resourceName.substring(lastSlash + 1); - - switch (type) { - - case FIND_ALL_PROP : - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - generatedXML.writeProperty("D", "creationdate", - getISOCreationDate(cacheEntry.getCreation())); - generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); - generatedXML.writeData(resourceName); - generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); - //if (!cacheEntry.isDirectory()) { - generatedXML.writeProperty - ("D", "getlastmodified", FastHttpDateFormat.formatDate - (cacheEntry.getLastModified(), null)); - if (!cacheEntry.isDirectory()) { - generatedXML.writeProperty - ("D", "getcontentlength", - String.valueOf(cacheEntry.getContentLength())); - String contentType = getServletContext().getMimeType - (cacheEntry.getName()); - if (contentType != null) { - generatedXML.writeProperty("D", "getcontenttype", - contentType); - } - generatedXML.writeProperty("D", "getetag", - cacheEntry.getETag()); - generatedXML.writeElement("D", "resourcetype", - XMLWriter.NO_CONTENT); - } else { - generatedXML.writeElement("D", "resourcetype", - XMLWriter.OPENING); - generatedXML.writeElement("D", "collection", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "resourcetype", - XMLWriter.CLOSING); - } - - generatedXML.writeProperty("D", "source", ""); - - String supportedLocks = "" - + "" - + "" - + "" + "" - + "" - + "" - + ""; - generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); - generatedXML.writeText(supportedLocks); - generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); - - generateLockDiscovery(path, generatedXML); - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - break; - - case FIND_PROPERTY_NAMES : - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - generatedXML.writeElement("D", "creationdate", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "displayname", XMLWriter.NO_CONTENT); - if (!cacheEntry.isDirectory()) { - generatedXML.writeElement("D", "getcontentlanguage", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getcontentlength", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getcontenttype", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getetag", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getlastmodified", - XMLWriter.NO_CONTENT); - } - generatedXML.writeElement("D", "resourcetype", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "source", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "lockdiscovery", - XMLWriter.NO_CONTENT); - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - break; - - case FIND_BY_PROPERTY : - - Vector propertiesNotFound = new Vector(); - - // Parse the list of properties - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - Enumeration properties = propertiesVector.elements(); - - while (properties.hasMoreElements()) { - - String property = properties.nextElement(); - - if (property.equals("creationdate")) { - generatedXML.writeProperty - ("D", "creationdate", - getISOCreationDate(cacheEntry.getCreation())); - } else if (property.equals("displayname")) { - generatedXML.writeElement - ("D", "displayname", XMLWriter.OPENING); - generatedXML.writeData(resourceName); - generatedXML.writeElement - ("D", "displayname", XMLWriter.CLOSING); - } else if (property.equals("getcontentlanguage")) { - if (cacheEntry.isDirectory()) { - propertiesNotFound.addElement(property); - } else { - generatedXML.writeElement("D", "getcontentlanguage", - XMLWriter.NO_CONTENT); - } - } else if (property.equals("getcontentlength")) { - if (cacheEntry.isDirectory()) { - propertiesNotFound.addElement(property); - } else { - generatedXML.writeProperty - ("D", "getcontentlength", - (String.valueOf(cacheEntry.getContentLength()))); - } - } else if (property.equals("getcontenttype")) { - if (cacheEntry.isDirectory()) { - propertiesNotFound.addElement(property); - } else { - //(cacheEntry.getName() + " MIMEO TYPE " + getServletContext().getMimeType(cacheEntry.getName())); - generatedXML.writeProperty - ("D", "getcontenttype", - getServletContext().getMimeType - (cacheEntry.getName())); - } - } else if (property.equals("getetag")) { - if (cacheEntry.isDirectory()) { - propertiesNotFound.addElement(property); - } else { - generatedXML.writeProperty - ("D", "getetag", cacheEntry.getETag()); - } - } else if (property.equals("getlastmodified")) { - //if (cacheEntry.isDirectory()) { - // propertiesNotFound.addElement(property); - //} else { - generatedXML.writeProperty - ("D", "getlastmodified", FastHttpDateFormat.formatDate - (cacheEntry.getLastModified(), null)); - //} - } else if (property.equals("resourcetype")) { - if (cacheEntry.isDirectory()) { - generatedXML.writeElement("D", "resourcetype", - XMLWriter.OPENING); - generatedXML.writeElement("D", "collection", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "resourcetype", - XMLWriter.CLOSING); - } else { - generatedXML.writeElement("D", "resourcetype", - XMLWriter.NO_CONTENT); - } - } else if (property.equals("source")) { - generatedXML.writeProperty("D", "source", ""); - } else if (property.equals("supportedlock")) { - supportedLocks = "" - + "" - + "" - + "" + "" - + "" - + "" - + ""; - generatedXML.writeElement("D", "supportedlock", - XMLWriter.OPENING); - generatedXML.writeText(supportedLocks); - generatedXML.writeElement("D", "supportedlock", - XMLWriter.CLOSING); - } else if (property.equals("lockdiscovery")) { - if (!generateLockDiscovery(path, generatedXML)) - propertiesNotFound.addElement(property); - } else { - propertiesNotFound.addElement(property); - } - - } - - //(cacheEntry.getName() + ":" + propertiesVector + " property e propertiesNotFoundList " + propertiesNotFound); - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - Enumeration propertiesNotFoundList = - propertiesNotFound.elements(); - - if (propertiesNotFoundList.hasMoreElements()) { - - status = "HTTP/1.1 " + WebdavServletStatus.SC_NOT_FOUND + " " + - WebdavServletStatus.getStatusText(WebdavServletStatus.SC_NOT_FOUND); - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - while (propertiesNotFoundList.hasMoreElements()) { - generatedXML.writeElement - ("D", propertiesNotFoundList.nextElement(), - XMLWriter.NO_CONTENT); - } - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - } - - break; - - } - - generatedXML.writeElement("D", "response", XMLWriter.CLOSING); - - } - - - /** - * Propfind helper method. Displays the properties of a lock-null resource. - * - * @param resources Resources object associated with this context - * @param generatedXML XML response to the Propfind request - * @param path Path of the current resource - * @param type Propfind type - * @param propertiesVector If the propfind type is find properties by - * name, then this Vector contains those properties - */ - private void parseLockNullProperties(HttpServletRequest req, - XMLWriter generatedXML, - String path, int type, - Vector propertiesVector) { - - // Exclude any resource in the /WEB-INF and /META-INF subdirectories - //if (isSpecialPath(path)) - // return; - - Thread.dumpStack(); - // Retrieving the lock associated with the lock-null resource - LockInfo lock = resourceLocks.get(path); - - if (lock == null) - return; - - generatedXML.writeElement("D", "response", XMLWriter.OPENING); - String status = "HTTP/1.1 " + WebdavServletStatus.SC_OK + " " + - WebdavServletStatus.getStatusText(WebdavServletStatus.SC_OK); - - // Generating href element - generatedXML.writeElement("D", "href", XMLWriter.OPENING); - - String absoluteUri = req.getRequestURI(); - String relativePath = getRelativePath(req); - String toAppend = path.substring(relativePath.length()); - if (!toAppend.startsWith("/")) - toAppend = "/" + toAppend; - - generatedXML.writeText(rewriteUrl(RequestUtil.normalize( - absoluteUri + toAppend))); - - generatedXML.writeElement("D", "href", XMLWriter.CLOSING); - - String resourceName = path; - int lastSlash = path.lastIndexOf('/'); - if (lastSlash != -1) - resourceName = resourceName.substring(lastSlash + 1); - - switch (type) { - - case FIND_ALL_PROP : - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - generatedXML.writeProperty("D", "creationdate", - getISOCreationDate(lock.creationDate.getTime())); - generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); - generatedXML.writeData(resourceName); - generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); - generatedXML.writeProperty("D", "getlastmodified", - FastHttpDateFormat.formatDate - (lock.creationDate.getTime(), null)); - generatedXML.writeProperty("D", "getcontentlength", - String.valueOf(0)); - generatedXML.writeProperty("D", "getcontenttype", ""); - generatedXML.writeProperty("D", "getetag", ""); - generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING); - generatedXML.writeElement("D", "lock-null", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING); - - generatedXML.writeProperty("D", "source", ""); - - String supportedLocks = "" - + "" - + "" - + "" + "" - + "" - + "" - + ""; - generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); - generatedXML.writeText(supportedLocks); - generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); - - generateLockDiscovery(path, generatedXML); - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - break; - - case FIND_PROPERTY_NAMES : - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - generatedXML.writeElement("D", "creationdate", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "displayname", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getcontentlanguage", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getcontentlength", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getcontenttype", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getetag", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "getlastmodified", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "resourcetype", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "source", XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "lockdiscovery", - XMLWriter.NO_CONTENT); - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - break; - - case FIND_BY_PROPERTY : - - Vector propertiesNotFound = new Vector(); - - // Parse the list of properties - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - Enumeration properties = propertiesVector.elements(); - - while (properties.hasMoreElements()) { - - String property = properties.nextElement(); - - if (property.equals("creationdate")) { - generatedXML.writeProperty("D", "creationdate", - getISOCreationDate(lock.creationDate.getTime())); - } else if (property.equals("displayname")) { - generatedXML.writeElement("D", "displayname", - XMLWriter.OPENING); - generatedXML.writeData(resourceName); - generatedXML.writeElement("D", "displayname", - XMLWriter.CLOSING); - } else if (property.equals("getcontentlanguage")) { - generatedXML.writeElement("D", "getcontentlanguage", - XMLWriter.NO_CONTENT); - } else if (property.equals("getcontentlength")) { - generatedXML.writeProperty("D", "getcontentlength", - (String.valueOf(0))); - } else if (property.equals("getcontenttype")) { - generatedXML.writeProperty("D", "getcontenttype", ""); - } else if (property.equals("getetag")) { - generatedXML.writeProperty("D", "getetag", ""); - } else if (property.equals("getlastmodified")) { - generatedXML.writeProperty - ("D", "getlastmodified", - FastHttpDateFormat.formatDate - (lock.creationDate.getTime(), null)); - } else if (property.equals("resourcetype")) { - generatedXML.writeElement("D", "resourcetype", - XMLWriter.OPENING); - generatedXML.writeElement("D", "lock-null", - XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "resourcetype", - XMLWriter.CLOSING); - } else if (property.equals("source")) { - generatedXML.writeProperty("D", "source", ""); - } else if (property.equals("supportedlock")) { - supportedLocks = "" - + "" - + "" - + "" + "" - + "" - + "" - + ""; - generatedXML.writeElement("D", "supportedlock", - XMLWriter.OPENING); - generatedXML.writeText(supportedLocks); - generatedXML.writeElement("D", "supportedlock", - XMLWriter.CLOSING); - } else if (property.equals("lockdiscovery")) { - if (!generateLockDiscovery(path, generatedXML)) - propertiesNotFound.addElement(property); - } else { - propertiesNotFound.addElement(property); - } - - } - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - Enumeration propertiesNotFoundList = propertiesNotFound.elements(); - - if (propertiesNotFoundList.hasMoreElements()) { - - status = "HTTP/1.1 " + WebdavServletStatus.SC_NOT_FOUND + " " + - WebdavServletStatus.getStatusText(WebdavServletStatus.SC_NOT_FOUND); - - generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); - generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - - while (propertiesNotFoundList.hasMoreElements()) { - generatedXML.writeElement - ("D", propertiesNotFoundList.nextElement(), - XMLWriter.NO_CONTENT); - } - - generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", XMLWriter.OPENING); - generatedXML.writeText(status); - generatedXML.writeElement("D", "status", XMLWriter.CLOSING); - generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - - } - - break; - - } - - generatedXML.writeElement("D", "response", XMLWriter.CLOSING); - - } - - - /** - * Print the lock discovery information associated with a path. - * - * @param path Path - * @param generatedXML XML data to which the locks info will be appended - * @return true if at least one lock was displayed - */ - private boolean generateLockDiscovery - (String path, XMLWriter generatedXML) { - - LockInfo resourceLock = resourceLocks.get(path); - Enumeration collectionLocksList = collectionLocks.elements(); - - boolean wroteStart = false; - - if (resourceLock != null) { - wroteStart = true; - generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING); - resourceLock.toXML(generatedXML); - } - - while (collectionLocksList.hasMoreElements()) { - LockInfo currentLock = collectionLocksList.nextElement(); - if (path.startsWith(currentLock.path)) { - if (!wroteStart) { - wroteStart = true; - generatedXML.writeElement("D", "lockdiscovery", - XMLWriter.OPENING); - } - currentLock.toXML(generatedXML); - } - } - - if (wroteStart) { - generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING); - } else { - return false; - } - - return true; - - } - - - /** - * Get creation date in ISO format. - */ - private String getISOCreationDate(long creationDate) { - StringBuilder creationDateValue = new StringBuilder - (creationDateFormat.format - (new Date(creationDate))); - /* - int offset = Calendar.getInstance().getTimeZone().getRawOffset() - / 3600000; // FIXME ? - if (offset < 0) { - creationDateValue.append("-"); - offset = -offset; - } else if (offset > 0) { - creationDateValue.append("+"); - } - if (offset != 0) { - if (offset < 10) - creationDateValue.append("0"); - creationDateValue.append(offset + ":00"); - } else { - creationDateValue.append("Z"); - } - */ - return creationDateValue.toString(); - } - - /** - * Determines the methods normally allowed for the resource. - * - */ - private StringBuilder determineMethodsAllowed(HttpServletRequest req,HttpServletResponse resp) throws CaimitoException { - - StringBuilder methodsAllowed = new StringBuilder(); - - String path = getRelativePath(req); - //(" determineMethodsAllowed path " + path); - ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.READ); - //if (ro == null)return methodsAllowed; - boolean exists = true; - if (ro != null) - exists = ro.exists(); - - - - if (!exists) { - methodsAllowed.append("OPTIONS, MKCOL, PUT, LOCK"); - return methodsAllowed; - } -//PROPPATCH, - methodsAllowed.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE"); - methodsAllowed.append(", COPY, MOVE, LOCK, UNLOCK"); - - if (ro == null || ro.listings()) { - methodsAllowed.append(", PROPFIND"); - } - - if (ro != null && !(ro.isDirectory())) { - methodsAllowed.append(", PUT"); - } - - return methodsAllowed; - } - - // -------------------------------------------------- LockInfo Inner Class - - - /** - * Holds a lock information. - */ - private class LockInfo { - - - // -------------------------------------------------------- Constructor - - - /** - * Constructor. - */ - public LockInfo() { - // Ignore - } - - - // ------------------------------------------------- Instance Variables - - - String path = "/"; - String type = "write"; - String scope = "exclusive"; - int depth = 0; - String owner = ""; - Vector tokens = new Vector(); - long expiresAt = 0; - Date creationDate = new Date(); - - - // ----------------------------------------------------- Public Methods - - - /** - * Get a String representation of this lock token. - */ - @Override - public String toString() { - - StringBuilder result = new StringBuilder("Type:"); - result.append(type); - result.append("\nScope:"); - result.append(scope); - result.append("\nDepth:"); - result.append(depth); - result.append("\nOwner:"); - result.append(owner); - result.append("\nExpiration:"); - result.append(FastHttpDateFormat.formatDate(expiresAt, null)); - Enumeration tokensList = tokens.elements(); - while (tokensList.hasMoreElements()) { - result.append("\nToken:"); - result.append(tokensList.nextElement()); - } - result.append("\n"); - return result.toString(); - } - - - /** - * Return true if the lock has expired. - */ - public boolean hasExpired() { - return (System.currentTimeMillis() > expiresAt); - } - - - /** - * Return true if the lock is exclusive. - */ - public boolean isExclusive() { - - return (scope.equals("exclusive")); - - } - - - /** - * Get an XML representation of this lock token. This method will - * append an XML fragment to the given XML writer. - */ - public void toXML(XMLWriter generatedXML) { - - generatedXML.writeElement("D", "activelock", XMLWriter.OPENING); - - generatedXML.writeElement("D", "locktype", XMLWriter.OPENING); - generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING); - generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT); - generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "depth", XMLWriter.OPENING); - if (depth == maxDepth) { - generatedXML.writeText("Infinity"); - } else { - generatedXML.writeText("0"); - } - generatedXML.writeElement("D", "depth", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "owner", XMLWriter.OPENING); - generatedXML.writeText(owner); - generatedXML.writeElement("D", "owner", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "timeout", XMLWriter.OPENING); - long timeout = (expiresAt - System.currentTimeMillis()) / 1000; - generatedXML.writeText("Second-" + timeout); - generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING); - Enumeration tokensList = tokens.elements(); - while (tokensList.hasMoreElements()) { - generatedXML.writeElement("D", "href", XMLWriter.OPENING); - generatedXML.writeText("opaquelocktoken:" - + tokensList.nextElement()); - generatedXML.writeElement("D", "href", XMLWriter.CLOSING); - } - generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING); - - generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING); - - } - - - } - - - // --------------------------------------------- WebdavResolver Inner Class - /** - * Work around for XML parsers that don't fully respect - * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean)} when - * called with false. External references are filtered out for - * security reasons. See CVE-2007-5461. - */ - private static class WebdavResolver implements EntityResolver { - private ServletContext context; - - public WebdavResolver(ServletContext theContext) { - context = theContext; - } - - @Override - public InputSource resolveEntity (String publicId, String systemId) { - context.log("webdavservlet.enternalEntityIgnored"); - return new InputSource( - new StringReader("Ignored external entity")); - } - } -} - - -// -------------------------------------------------------- WebdavServletStatus Class - - -/** - * Wraps the HttpServletResponse class to abstract the - * specific protocol used. To support other protocols - * we would only need to modify this class and the - * WebDavRetCode classes. - * - * @author Marc Eaddy - * @version 1.0, 16 Nov 1997 - */ -class WebdavServletStatus { - - - // ----------------------------------------------------- Instance Variables - - - /** - * This Hashtable contains the mapping of HTTP and WebDAV - * status codes to descriptive text. This is a static - * variable. - */ - private static Hashtable mapStatusCodes = - new Hashtable(); - - - // ------------------------------------------------------ HTTP Status Codes - - - /** - * Status code (200) indicating the request succeeded normally. - */ - public static final int SC_OK = HttpServletResponse.SC_OK; - - - /** - * Status code (201) indicating the request succeeded and created - * a new resource on the server. - */ - public static final int SC_CREATED = HttpServletResponse.SC_CREATED; - - - /** - * Status code (202) indicating that a request was accepted for - * processing, but was not completed. - */ - public static final int SC_ACCEPTED = HttpServletResponse.SC_ACCEPTED; - - - /** - * Status code (204) indicating that the request succeeded but that - * there was no new information to return. - */ - public static final int SC_NO_CONTENT = HttpServletResponse.SC_NO_CONTENT; - - - /** - * Status code (301) indicating that the resource has permanently - * moved to a new location, and that future references should use a - * new URI with their requests. - */ - public static final int SC_MOVED_PERMANENTLY = - HttpServletResponse.SC_MOVED_PERMANENTLY; - - - /** - * Status code (302) indicating that the resource has temporarily - * moved to another location, but that future references should - * still use the original URI to access the resource. - */ - public static final int SC_MOVED_TEMPORARILY = - HttpServletResponse.SC_MOVED_TEMPORARILY; - - - /** - * Status code (304) indicating that a conditional GET operation - * found that the resource was available and not modified. - */ - public static final int SC_NOT_MODIFIED = - HttpServletResponse.SC_NOT_MODIFIED; - - - /** - * Status code (400) indicating the request sent by the client was - * syntactically incorrect. - */ - public static final int SC_BAD_REQUEST = - HttpServletResponse.SC_BAD_REQUEST; - - - /** - * Status code (401) indicating that the request requires HTTP - * authentication. - */ - public static final int SC_UNAUTHORIZED = - HttpServletResponse.SC_UNAUTHORIZED; - - - /** - * Status code (403) indicating the server understood the request - * but refused to fulfill it. - */ - public static final int SC_FORBIDDEN = HttpServletResponse.SC_FORBIDDEN; - - - /** - * Status code (404) indicating that the requested resource is not - * available. - */ - public static final int SC_NOT_FOUND = HttpServletResponse.SC_NOT_FOUND; - - - /** - * Status code (500) indicating an error inside the HTTP service - * which prevented it from fulfilling the request. - */ - public static final int SC_INTERNAL_SERVER_ERROR = - HttpServletResponse.SC_INTERNAL_SERVER_ERROR; - - - /** - * Status code (501) indicating the HTTP service does not support - * the functionality needed to fulfill the request. - */ - public static final int SC_NOT_IMPLEMENTED = - HttpServletResponse.SC_NOT_IMPLEMENTED; - - - /** - * Status code (502) indicating that the HTTP server received an - * invalid response from a server it consulted when acting as a - * proxy or gateway. - */ - public static final int SC_BAD_GATEWAY = - HttpServletResponse.SC_BAD_GATEWAY; - - - /** - * Status code (503) indicating that the HTTP service is - * temporarily overloaded, and unable to handle the request. - */ - public static final int SC_SERVICE_UNAVAILABLE = - HttpServletResponse.SC_SERVICE_UNAVAILABLE; - - - /** - * Status code (100) indicating the client may continue with - * its request. This interim response is used to inform the - * client that the initial part of the request has been - * received and has not yet been rejected by the server. - */ - public static final int SC_CONTINUE = 100; - - - /** - * Status code (405) indicating the method specified is not - * allowed for the resource. - */ - public static final int SC_METHOD_NOT_ALLOWED = 405; - - - /** - * Status code (409) indicating that the request could not be - * completed due to a conflict with the current state of the - * resource. - */ - public static final int SC_CONFLICT = 409; - - - /** - * Status code (412) indicating the precondition given in one - * or more of the request-header fields evaluated to false - * when it was tested on the server. - */ - public static final int SC_PRECONDITION_FAILED = 412; - - - /** - * Status code (413) indicating the server is refusing to - * process a request because the request entity is larger - * than the server is willing or able to process. - */ - public static final int SC_REQUEST_TOO_LONG = 413; - - - /** - * Status code (415) indicating the server is refusing to service - * the request because the entity of the request is in a format - * not supported by the requested resource for the requested - * method. - */ - public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; - - - // -------------------------------------------- Extended WebDav status code - - - /** - * Status code (207) indicating that the response requires - * providing status for multiple independent operations. - */ - public static final int SC_MULTI_STATUS = 207; - // This one collides with HTTP 1.1 - // "207 Partial Update OK" - - - /** - * Status code (418) indicating the entity body submitted with - * the PATCH method was not understood by the resource. - */ - public static final int SC_UNPROCESSABLE_ENTITY = 418; - // This one collides with HTTP 1.1 - // "418 Reauthentication Required" - - - /** - * Status code (419) indicating that the resource does not have - * sufficient space to record the state of the resource after the - * execution of this method. - */ - public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; - // This one collides with HTTP 1.1 - // "419 Proxy Reauthentication Required" - - - /** - * Status code (420) indicating the method was not executed on - * a particular resource within its scope because some part of - * the method's execution failed causing the entire method to be - * aborted. - */ - public static final int SC_METHOD_FAILURE = 420; - - - /** - * Status code (423) indicating the destination resource of a - * method is locked, and either the request did not contain a - * valid Lock-Info header, or the Lock-Info header identifies - * a lock held by another principal. - */ - public static final int SC_LOCKED = 423; - - - // ------------------------------------------------------------ Initializer - - - static { - // HTTP 1.0 status Code - addStatusCodeMap(SC_OK, "OK"); - addStatusCodeMap(SC_CREATED, "Created"); - addStatusCodeMap(SC_ACCEPTED, "Accepted"); - addStatusCodeMap(SC_NO_CONTENT, "No Content"); - addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently"); - addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily"); - addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified"); - addStatusCodeMap(SC_BAD_REQUEST, "Bad Request"); - addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized"); - addStatusCodeMap(SC_FORBIDDEN, "Forbidden"); - addStatusCodeMap(SC_NOT_FOUND, "Not Found"); - addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error"); - addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented"); - addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway"); - addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable"); - addStatusCodeMap(SC_CONTINUE, "Continue"); - addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed"); - addStatusCodeMap(SC_CONFLICT, "Conflict"); - addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed"); - addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long"); - addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"); - // WebDav Status Codes - addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status"); - addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity"); - addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE, - "Insufficient Space On Resource"); - addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure"); - addStatusCodeMap(SC_LOCKED, "Locked"); - } - - - // --------------------------------------------------------- Public Methods - - - /** - * Returns the HTTP status text for the HTTP or WebDav status code - * specified by looking it up in the static mapping. This is a - * static function. - * - * @param nHttpStatusCode [IN] HTTP or WebDAV status code - * @return A string with a short descriptive phrase for the - * HTTP status code (e.g., "OK"). - */ - public static String getStatusText(int nHttpStatusCode) { - Integer intKey = Integer.valueOf(nHttpStatusCode); - - if (!mapStatusCodes.containsKey(intKey)) { - return ""; - } else { - return mapStatusCodes.get(intKey); - } - } - - - // -------------------------------------------------------- Private Methods - - - /** - * Adds a new status code -> status text mapping. This is a static - * method because the mapping is a static variable. - * - * @param nKey [IN] HTTP or WebDAV status code - * @param strVal [IN] HTTP status text - */ - private static void addStatusCodeMap(int nKey, String strVal) { - mapStatusCodes.put(Integer.valueOf(nKey), strVal); - } - -} - - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 ngasi.caimito; + + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Stack; +import java.util.TimeZone; +import java.util.Vector; + +import javax.naming.NameClassPair; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.catalina.util.DOMWriter; +import org.apache.catalina.util.MD5Encoder; +import org.apache.catalina.util.XMLWriter; +import org.apache.naming.resources.CacheEntry; +import org.apache.naming.resources.Resource; +import org.apache.naming.resources.ResourceAttributes; +import org.apache.tomcat.util.http.FastHttpDateFormat; +import org.apache.tomcat.util.http.RequestUtil; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.apache.catalina.servlets.*; +import ngasi.caimito.resource.*; + + + +/** + * Servlet which adds support for WebDAV level 2. All the basic HTTP requests + * are handled by the DefaultServlet. The WebDAVServlet must not be used as the + * default servlet (ie mapped to '/') as it will not work in this configuration. + *

+ * Mapping a subpath (e.g. /webdav/* to this servlet has the effect + * of re-mounting the entire web application under that sub-path, with WebDAV + * access to all the resources. This WEB-INF and META-INF + * directories are protected in this re-mounted resource tree. + *

+ * To enable WebDAV for a context add the following to web.xml: + *

+ * <servlet>
+ *  <servlet-name>webdav</servlet-name>
+ *  <servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
+ *    <init-param>
+ *      <param-name>debug</param-name>
+ *      <param-value>0</param-value>
+ *    </init-param>
+ *    <init-param>
+ *      <param-name>listings</param-name>
+ *      <param-value>false</param-value>
+ *    </init-param>
+ *  </servlet>
+ *  <servlet-mapping>
+ *    <servlet-name>webdav</servlet-name>
+ *    <url-pattern>/*</url-pattern>
+ *  </servlet-mapping>
+ * 
+ * This will enable read only access. To enable read-write access add: + *
+ *  <init-param>
+ *    <param-name>readonly</param-name>
+ *    <param-value>false</param-value>
+ *  </init-param>
+ * 
+ * To make the content editable via a different URL, use the following + * mapping: + *
+ *  <servlet-mapping>
+ *    <servlet-name>webdav</servlet-name>
+ *    <url-pattern>/webdavedit/*</url-pattern>
+ *  </servlet-mapping>
+ * 
+ * By default access to /WEB-INF and META-INF are not available via WebDAV. To + * enable access to these URLs, use add: + *
+ *  <init-param>
+ *    <param-name>allowSpecialPaths</param-name>
+ *    <param-value>true</param-value>
+ *  </init-param>
+ * 
+ * Don't forget to secure access appropriately to the editing URLs, especially + * if allowSpecialPaths is used. With the mapping configuration above, the + * context will be accessible to normal users as before. Those users with the + * necessary access will be able to edit content available via + * http://host:port/context/content using + * http://host:port/context/webdavedit/content + * + * @author Remy Maucherat + * @version $Id: WebdavServlet.java 1239053 2012-02-01 10:52:00Z markt $ + */ + +public class CaimitoWebdavServlet + extends CaimitoDefaultServlet { + + private static final long serialVersionUID = 1L; + + + // -------------------------------------------------------------- Constants + + private static final String METHOD_PROPFIND = "PROPFIND"; + private static final String METHOD_PROPPATCH = "PROPPATCH"; + private static final String METHOD_MKCOL = "MKCOL"; + private static final String METHOD_COPY = "COPY"; + private static final String METHOD_MOVE = "MOVE"; + private static final String METHOD_LOCK = "LOCK"; + private static final String METHOD_UNLOCK = "UNLOCK"; + + + /** + * PROPFIND - Specify a property mask. + */ + private static final int FIND_BY_PROPERTY = 0; + + + /** + * PROPFIND - Display all properties. + */ + private static final int FIND_ALL_PROP = 1; + + + /** + * PROPFIND - Return property names. + */ + private static final int FIND_PROPERTY_NAMES = 2; + + + /** + * Create a new lock. + */ + private static final int LOCK_CREATION = 0; + + + /** + * Refresh lock. + */ + private static final int LOCK_REFRESH = 1; + + + /** + * Default lock timeout value. + */ + private static final int DEFAULT_TIMEOUT = 3600; + + + /** + * Maximum lock timeout. + */ + private static final int MAX_TIMEOUT = 604800; + + + /** + * Default namespace. + */ + protected static final String DEFAULT_NAMESPACE = "DAV:"; + + + /** + * Simple date format for the creation date ISO representation (partial). + */ + protected static final SimpleDateFormat creationDateFormat = + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US); + + + /** + * MD5 message digest provider. + */ + protected static MessageDigest md5Helper; + + + /** + * The MD5 helper object for this class. + */ + protected static final MD5Encoder md5Encoder = new MD5Encoder(); + + + + static { + creationDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } + + + // ----------------------------------------------------- Instance Variables + + + /** + * Repository of the locks put on single resources. + *

+ * Key : path
+ * Value : LockInfo + */ + private Hashtable resourceLocks = + new Hashtable(); + + + /** + * Repository of the lock-null resources. + *

+ * Key : path of the collection containing the lock-null resource
+ * Value : Vector of lock-null resource which are members of the + * collection. Each element of the Vector is the path associated with + * the lock-null resource. + */ + private Hashtable> lockNullResources = + new Hashtable>(); + + + /** + * Vector of the heritable locks. + *

+ * Key : path
+ * Value : LockInfo + */ + private Vector collectionLocks = new Vector(); + + + /** + * Secret information used to generate reasonably secure lock ids. + */ + private String secret = "catalina"; + + + /** + * Default depth in spec is infinite. Limit depth to 3 by default as + * infinite depth makes operations very expensive. + */ + private int maxDepth = 3; + + + /** + * Is access allowed via WebDAV to the special paths (/WEB-INF and + * /META-INF)? + */ + private boolean allowSpecialPaths = false; + + + // --------------------------------------------------------- Public Methods + + + /** + * Initialize this servlet. + */ + @Override + public void init() + throws ServletException { + + super.init(); + if (getServletConfig().getInitParameter("secret") != null) + secret = getServletConfig().getInitParameter("secret"); + + if (getServletConfig().getInitParameter("maxDepth") != null) + maxDepth = Integer.parseInt( + getServletConfig().getInitParameter("maxDepth")); + + if (getServletConfig().getInitParameter("allowSpecialPaths") != null) + allowSpecialPaths = Boolean.parseBoolean( + getServletConfig().getInitParameter("allowSpecialPaths")); + + // Load the MD5 helper used to calculate signatures. + try { + md5Helper = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + throw new UnavailableException("No MD5"); + } + + String rootPath = getServletConfig().getServletContext().getRealPath("/"); + CaimitoConfig.caimitoroot = rootPath; + System.out.println(" Caimito Version " + CaimitoConfig.version); + CaimitoConfig.init(); + + } + + + // ------------------------------------------------------ Protected Methods + + + /** + * Return JAXP document builder instance. + */ + protected DocumentBuilder getDocumentBuilder() + throws ServletException { + DocumentBuilder documentBuilder = null; + DocumentBuilderFactory documentBuilderFactory = null; + try { + documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + documentBuilderFactory.setExpandEntityReferences(false); + documentBuilder = documentBuilderFactory.newDocumentBuilder(); + documentBuilder.setEntityResolver( + new WebdavResolver(this.getServletContext())); + } catch(ParserConfigurationException e) { + throw new ServletException + ("webdavservlet.jaxpfailed"); + } + return documentBuilder; + } + + + /** + * Handles the special WebDAV methods. + */ + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + final String path = getRelativePath(req); + + // Block access to special subdirectories. + // DefaultServlet assumes it services resources from the root of the web app + // and doesn't add any special path protection + // WebdavServlet remounts the webapp under a new path, so this check is + // necessary on all methods (including GET). + // if (isSpecialPath(path)) { + // resp.sendError(WebdavServletStatus.SC_NOT_FOUND); + // return; + //} + + final String method = req.getMethod(); + //(method + " SEEERVICE CAMITO WEBDAV " + path); + + if (debug > 0) { + log("[" + method + "] " + path); + } + + if (method.equals(METHOD_PROPFIND)) { + doPropfind(req, resp); + } else if (method.equals(METHOD_PROPPATCH)) { + doProppatch(req, resp); + } else if (method.equals(METHOD_MKCOL)) { + doMkcol(req, resp); + } else if (method.equals(METHOD_COPY)) { + doCopy(req, resp); + } else if (method.equals(METHOD_MOVE)) { + doMove(req, resp); + } else if (method.equals(METHOD_LOCK)) { + doLock(req, resp); + } else if (method.equals(METHOD_UNLOCK)) { + doUnlock(req, resp); + } else { + // DefaultServlet processing + super.service(req, resp); + } + + } + + + /** + * Checks whether a given path refers to a resource under + * WEB-INF or META-INF. + * @param path the full path of the resource being accessed + * @return true if the resource specified is under a special path + */ + private final boolean isSpecialPath(final String path) { + return !allowSpecialPaths && ( + path.toUpperCase(Locale.ENGLISH).startsWith("/WEB-INF") || + path.toUpperCase(Locale.ENGLISH).startsWith("/META-INF")); + } + + + /** + * Check if the conditions specified in the optional If headers are + * satisfied. + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param resourceAttributes The resource information + * @return boolean true if the resource meets all the specified conditions, + * and false if any of the conditions is not satisfied, in which case + * request processing is stopped + */ + /*@Override + protected boolean checkIfHeaders(HttpServletRequest request, + HttpServletResponse response, + ResourceAttributes resourceAttributes) + throws IOException { + + if (!super.checkIfHeaders(request, response, resourceAttributes)) + return false; + + // TODO : Checking the WebDAV If header + return true; + + }*/ + + + /** + * Override the DefaultServlet implementation and only use the PathInfo. If + * the ServletPath is non-null, it will be because the WebDAV servlet has + * been mapped to a url other than /* to configure editing at different url + * than normal viewing. + * + * @param request The servlet request we are processing + */ + @Override + protected String getRelativePath(HttpServletRequest request) { + // Are we being processed by a RequestDispatcher.include()? + if (request.getAttribute( + RequestDispatcher.INCLUDE_REQUEST_URI) != null) { + String result = (String) request.getAttribute( + RequestDispatcher.INCLUDE_PATH_INFO); + if ((result == null) || (result.equals(""))) + result = "/"; + /* result = tools.util.StringUtil.replaceSubstring(result,"..",""); + result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); + result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); + result = tools.util.StringUtil.replaceSubstring(result,":",""); +*/ + result = CaimitoUtil.normalize(result); + return (result); + } + + // No, extract the desired path directly from the request + String result = request.getPathInfo(); + if ((result == null) || (result.equals(""))) { + result = "/"; + } + /* + result = tools.util.StringUtil.replaceSubstring(result,"..",""); + result = tools.util.StringUtil.replaceSubstring(result,"//","\\"); + result = tools.util.StringUtil.replaceSubstring(result,"\\","/"); + result = tools.util.StringUtil.replaceSubstring(result,":",""); +*/ + result = CaimitoUtil.normalize(result); + + return (result); + + } + + + /** + * Determines the prefix for standard directory GET listings. + */ + @Override + protected String getPathPrefix(final HttpServletRequest request) { + // Repeat the servlet path (e.g. /webdav/) in the listing path + String contextPath = request.getContextPath(); + if (request.getServletPath() != null) { + contextPath = contextPath + request.getServletPath(); + } + return contextPath; + } + + + /** + * OPTIONS Method. + * + * @param req The request + * @param resp The response + * @throws ServletException If an error occurs + * @throws IOException If an IO error occurs + */ + @Override + protected void doOptions(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + resp.addHeader("DAV", "1,2"); + + StringBuilder methodsAllowed = determineMethodsAllowed(req,resp); + //(methodsAllowed + " DOP 2"); + + resp.addHeader("Allow", methodsAllowed.toString()); + resp.addHeader("MS-Author-Via", "DAV"); + + } + + + /** + * PROPFIND Method. + */ + protected void doPropfind(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + + + String path = getRelativePath(req); + if (path.endsWith("/")) + path = path.substring(0, path.length() - 1); + + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.READ); + if (ro == null)return; + + if (!ro.listings()) { + // Get allowed methods + StringBuilder methodsAllowed = determineMethodsAllowed( req,resp); + + resp.addHeader("Allow", methodsAllowed.toString()); + resp.sendError(WebdavServletStatus.SC_METHOD_NOT_ALLOWED); + return; + } + + // Properties which are to be displayed. + Vector properties = null; + // Propfind depth + int depth = maxDepth; + // Propfind type + int type = FIND_ALL_PROP; + + String depthStr = req.getHeader("Depth"); + + if (depthStr == null) { + depth = maxDepth; + } else { + if (depthStr.equals("0")) { + depth = 0; + } else if (depthStr.equals("1")) { + depth = 1; + } else if (depthStr.equals("infinity")) { + depth = maxDepth; + } + } + + Node propNode = null; + + if (req.getContentLength() > 0) { + DocumentBuilder documentBuilder = getDocumentBuilder(); + + try { + Document document = documentBuilder.parse + (new InputSource(req.getInputStream())); + + // Get the root element of the document + Element rootElement = document.getDocumentElement(); + NodeList childList = rootElement.getChildNodes(); + + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + break; + case Node.ELEMENT_NODE: + if (currentNode.getNodeName().endsWith("prop")) { + type = FIND_BY_PROPERTY; + propNode = currentNode; + } + if (currentNode.getNodeName().endsWith("propname")) { + type = FIND_PROPERTY_NAMES; + } + if (currentNode.getNodeName().endsWith("allprop")) { + type = FIND_ALL_PROP; + } + break; + } + } + } catch (SAXException e) { + // Something went wrong - bad request + resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); + } catch (IOException e) { + // Something went wrong - bad request + resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); + } + } + + //(path + " PROP FINDE TYPE " + type ); + if (type == FIND_BY_PROPERTY) { + properties = new Vector(); + // propNode must be non-null if type == FIND_BY_PROPERTY + @SuppressWarnings("null") + NodeList childList = propNode.getChildNodes(); + + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + break; + case Node.ELEMENT_NODE: + String nodeName = currentNode.getNodeName(); + String propertyName = null; + if (nodeName.indexOf(':') != -1) { + propertyName = nodeName.substring + (nodeName.indexOf(':') + 1); + } else { + propertyName = nodeName; + } + // href is a live property which is handled differently + properties.addElement(propertyName); + break; + } + } + + } + + boolean exists = ro.exists(); + /*Object object = null; + try { + object = resources.lookup(path); + } catch (NamingException e) { + exists = false; + int slash = path.lastIndexOf('/'); + if (slash != -1) { + String parentPath = path.substring(0, slash); + Vector currentLockNullResources = + lockNullResources.get(parentPath); + if (currentLockNullResources != null) { + Enumeration lockNullResourcesList = + currentLockNullResources.elements(); + while (lockNullResourcesList.hasMoreElements()) { + String lockNullPath = + lockNullResourcesList.nextElement(); + if (lockNullPath.equals(path)) { + resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); + resp.setContentType("text/xml; charset=UTF-8"); + // Create multistatus object + XMLWriter generatedXML = + new XMLWriter(resp.getWriter()); + generatedXML.writeXMLHeader(); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, + "multistatus", XMLWriter.OPENING); + parseLockNullProperties + (req, generatedXML, lockNullPath, type, + properties); + generatedXML.writeElement("D", "multistatus", + XMLWriter.CLOSING); + generatedXML.sendData(); + return; + } + } + } + } + }*/ + + if (!exists) { + resp.sendError(HttpServletResponse.SC_NOT_FOUND, path); + return; + } + + resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); + + resp.setContentType("text/xml; charset=UTF-8"); + + // Create multistatus object + XMLWriter generatedXML = new XMLWriter(resp.getWriter()); + generatedXML.writeXMLHeader(); + + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", + XMLWriter.OPENING); + + if (depth == 0) { + parseProperties(req,resp, generatedXML, path, type, + properties); + } else { + // The stack always contains the object of the current level + Stack stack = new Stack(); + stack.push(path); + + // Stack of the objects one level below + Stack stackBelow = new Stack(); + ResourceObj rob = null; + while ((!stack.isEmpty()) && (depth >= 0)) { + + String currentPath = stack.pop(); + parseProperties(req,resp, generatedXML, currentPath, + type, properties); + + // try { + //object = resources.lookup(currentPath); + rob = ResourceStore.lookup(currentPath,req,resp,ResourceStore.READ); + + // } catch (Exception e) { + // continue; + // } + + if ((rob.isDirectory()) && (depth > 0)) { + + try { + Enumeration enumeration = + rob.list().elements(); + while (enumeration.hasMoreElements()) { + ResourceObj ncPair = enumeration.nextElement(); + //String newPath = currentPath; + //if (!(newPath.endsWith("/"))) + // newPath += "/"; + //newPath += ncPair.getName(); + stackBelow.push(ncPair.path); + } + } catch (Exception e) { + e.printStackTrace(); + resp.sendError + (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, + path); + return; + } + + // Displaying the lock-null resources present in that + // collection + String lockPath = currentPath; + if (lockPath.endsWith("/")) + lockPath = + lockPath.substring(0, lockPath.length() - 1); + Vector currentLockNullResources = + lockNullResources.get(lockPath); + if (currentLockNullResources != null) { + Enumeration lockNullResourcesList = + currentLockNullResources.elements(); + while (lockNullResourcesList.hasMoreElements()) { + String lockNullPath = + lockNullResourcesList.nextElement(); + parseLockNullProperties + (req, generatedXML, lockNullPath, type, + properties); + } + } + + } + + if (stack.isEmpty()) { + depth--; + stack = stackBelow; + stackBelow = new Stack(); + } + + generatedXML.sendData(); + + } + } + + generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); + + generatedXML.sendData(); + //("generatedXML,value " + generatedXML); + + } + + + /** + * PROPPATCH Method. + */ + protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) + throws IOException { +/* + if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } + + resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); +*/ + //resp.setStatus(200); + resp.setContentType("text/xml"); + String propr = "\r\n" + +"\r\n" + +" \r\n" + + " \r\n" + + " HTTP/1.1 200 OK\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + +"\r\n"; +resp.getWriter().print(propr); + + } + + + /** + * MKCOL Method. + */ + protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + /*if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + }*/ + + String path = getRelativePath(req); + + /*boolean exists = true; + try { + resources.lookup(path); + } catch (NamingException e) { + exists = false; + }*/ + + // Can't create a collection if a resource already exists at the given + // path + + + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); + if (ro == null)return; + + if (!ro.canWrite()) { + resp.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + + boolean exists = ro.exists(); + + if (exists) { + // Get allowed methods + StringBuilder methodsAllowed = determineMethodsAllowed( req,resp); + + resp.addHeader("Allow", methodsAllowed.toString()); + + resp.sendError(WebdavServletStatus.SC_METHOD_NOT_ALLOWED); + return; + } + + if (req.getContentLength() > 0) { + //("MKCOL IS MORE DATA"); + DocumentBuilder documentBuilder = getDocumentBuilder(); + try { + // Document document = + documentBuilder.parse(new InputSource(req.getInputStream())); + // TODO : Process this request body + resp.sendError(WebdavServletStatus.SC_NOT_IMPLEMENTED); + return; + + } catch(SAXException saxe) { + // Parse error - assume invalid content + resp.sendError(WebdavServletStatus.SC_UNSUPPORTED_MEDIA_TYPE); + return; + } + } + + try{ + ro.mkdir(); + resp.setStatus(WebdavServletStatus.SC_CREATED); + + }catch (Exception e){ + e.printStackTrace(); + resp.sendError(WebdavServletStatus.SC_CONFLICT, + WebdavServletStatus.getStatusText + (WebdavServletStatus.SC_CONFLICT)); + } + + /*boolean result = true; + try { + resources.createSubcontext(path); + } catch (NamingException e) { + result = false; + } + + if (!result) { + resp.sendError(WebdavServletStatus.SC_CONFLICT, + WebdavServletStatus.getStatusText + (WebdavServletStatus.SC_CONFLICT)); + } else { + resp.setStatus(WebdavServletStatus.SC_CREATED); + // Removing any lock-null resource which would be present + lockNullResources.remove(path); + }*/ + + } + + + /** + * DELETE Method. + */ + /*@Override + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } + + deleteResource(req, resp); + + }*/ + + + /** + * Process a PUT request for the specified resource. + * + * @param req The servlet request we are processing + * @param resp The servlet response we are creating + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet-specified error occurs + */ + @Override + protected void doPut(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + String path = getRelativePath(req); + + if (isLocked(req)) { + //(path + " IS A LIOCLLERD "); + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } + + super.doPut(req, resp); + + + // Removing any lock-null resource which would be present + lockNullResources.remove(path); + + } + + /** + * COPY Method. + */ + protected void doCopy(HttpServletRequest req, HttpServletResponse resp) + throws ServletException,IOException { + + /// if (readOnly) { + // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + // return; + // } + + copyResource(req, resp); + + } + + + + private boolean moveResource(HttpServletRequest req, + HttpServletResponse resp) + throws CaimitoException,IOException { + + // Parsing destination header + + String destinationPath = req.getHeader("Destination"); + + if (destinationPath == null) { + resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); + return false; + } + + // Remove url encoding from destination + destinationPath = org.apache.catalina.util.RequestUtil.URLDecode( + destinationPath, "UTF8"); + + int protocolIndex = destinationPath.indexOf("://"); + if (protocolIndex >= 0) { + // if the Destination URL contains the protocol, we can safely + // trim everything upto the first "/" character after "://" + int firstSeparator = + destinationPath.indexOf("/", protocolIndex + 4); + if (firstSeparator < 0) { + destinationPath = "/"; + } else { + destinationPath = destinationPath.substring(firstSeparator); + } + } else { + String hostName = req.getServerName(); + if ((hostName != null) && (destinationPath.startsWith(hostName))) { + destinationPath = destinationPath.substring(hostName.length()); + } + + int portIndex = destinationPath.indexOf(":"); + if (portIndex >= 0) { + destinationPath = destinationPath.substring(portIndex); + } + + if (destinationPath.startsWith(":")) { + int firstSeparator = destinationPath.indexOf("/"); + if (firstSeparator < 0) { + destinationPath = "/"; + } else { + destinationPath = + destinationPath.substring(firstSeparator); + } + } + } + + // Normalise destination path (remove '.' and '..') + destinationPath = RequestUtil.normalize(destinationPath); + + String contextPath = req.getContextPath(); + if ((contextPath != null) && + (destinationPath.startsWith(contextPath))) { + destinationPath = destinationPath.substring(contextPath.length()); + } + + String pathInfo = req.getPathInfo(); + if (pathInfo != null) { + String servletPath = req.getServletPath(); + if ((servletPath != null) && + (destinationPath.startsWith(servletPath))) { + destinationPath = destinationPath + .substring(servletPath.length()); + } + } + + if (debug > 0) + log("Dest path :" + destinationPath); + + // Check destination path to protect special subdirectories + //if (isSpecialPath(destinationPath)) { + // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + // return false; + //} + + String path = getRelativePath(req); + + if (destinationPath.equals(path)) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return false; + } + + // Parsing overwrite header + + boolean overwrite = true; + String overwriteHeader = req.getHeader("Overwrite"); + + if (overwriteHeader != null) { + if (overwriteHeader.equalsIgnoreCase("T")) { + overwrite = true; + } else { + overwrite = false; + } + } + + // Overwriting the destination + ResourceObj ro = ResourceStore.lookup(destinationPath,req,resp,ResourceStore.WRITE); + if (ro == null) + return false; + + ResourceObj ros = ResourceStore.lookup(path,req,resp,ResourceStore.READ); + + // if (!ro.canWrite() || !ros.canWrite()) { + if (ro == null || ros == null){ + + //resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + //return false; + return false; + } + + boolean exists = ro.exists(); + /*try { + resources.lookup(destinationPath); + } catch (NamingException e) { + exists = false; + }*/ + + if (overwrite) { + + // destination resource, if it exists + if (exists) { + //if (! Resource(destinationPath, req, resp, true)) { + // return false; + //} + ro.delete(); + } else { + resp.setStatus(WebdavServletStatus.SC_CREATED); + } + + } else { + + // If the destination exists, then it's a conflict + if (exists) { + resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); + return false; + } + + } + + // Copying source to destination + + ros.move(ro); + /*Hashtable errorList = new Hashtable(); + + boolean result = copyResource(resources, errorList, + path, destinationPath); + + if ((!result) || (!errorList.isEmpty())) { + if (errorList.size() == 1) { + resp.sendError(errorList.elements().nextElement().intValue()); + } else { + sendReport(req, resp, errorList); + } + return false; + }*/ + + // Copy was successful + if (exists) { + resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); + } else { + resp.setStatus(WebdavServletStatus.SC_CREATED); + } + + // Removing any lock-null resource which would be present at + // the destination path + lockNullResources.remove(destinationPath); + + return true; + + } + + /** + * MOVE Method. + */ + protected void doMove(HttpServletRequest req, HttpServletResponse resp) + throws ServletException,IOException { + + /*if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + }*/ + + /*String path = getRelativePath(req); + ResourceObj ros = ResourceStore.lookup(path,req,resp); + + if (!ros.canWrite()) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return ; + }*/ + + moveResource(req, resp); + // Resource(path, req, resp, false); + //ros.move(); + //} + + } + + + /** + * LOCK Method. + */ + + /* + protected void doLock(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + }*/ + protected void doLock(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + + /*if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + }*/ + + LockInfo lock = new LockInfo(); + + + String depthStr = req.getHeader("Depth"); + + if (depthStr == null) { + lock.depth = maxDepth; + } else { + if (depthStr.equals("0")) { + lock.depth = 0; + } else { + lock.depth = maxDepth; + } + } + + // Parsing timeout header + + int lockDuration = DEFAULT_TIMEOUT; + String lockDurationStr = req.getHeader("Timeout"); + if (lockDurationStr == null) { + lockDuration = DEFAULT_TIMEOUT; + } else { + int commaPos = lockDurationStr.indexOf(","); + // If multiple timeouts, just use the first + if (commaPos != -1) { + lockDurationStr = lockDurationStr.substring(0,commaPos); + } + if (lockDurationStr.startsWith("Second-")) { + lockDuration = + (new Integer(lockDurationStr.substring(7))).intValue(); + } else { + if (lockDurationStr.equalsIgnoreCase("infinity")) { + lockDuration = MAX_TIMEOUT; + } else { + try { + lockDuration = + (new Integer(lockDurationStr)).intValue(); + } catch (NumberFormatException e) { + lockDuration = MAX_TIMEOUT; + } + } + } + if (lockDuration == 0) { + lockDuration = DEFAULT_TIMEOUT; + } + if (lockDuration > MAX_TIMEOUT) { + lockDuration = MAX_TIMEOUT; + } + } + lock.expiresAt = System.currentTimeMillis() + (lockDuration * 1000); + + int lockRequestType = LOCK_CREATION; + + Node lockInfoNode = null; + + DocumentBuilder documentBuilder = getDocumentBuilder(); + + try { + Document document = documentBuilder.parse(new InputSource + (req.getInputStream())); + + // Get the root element of the document + Element rootElement = document.getDocumentElement(); + lockInfoNode = rootElement; + } catch (IOException e) { + lockRequestType = LOCK_REFRESH; + } catch (SAXException e) { + lockRequestType = LOCK_REFRESH; + } + + if (lockInfoNode != null) { + + // Reading lock information + + NodeList childList = lockInfoNode.getChildNodes(); + StringWriter strWriter = null; + DOMWriter domWriter = null; + + Node lockScopeNode = null; + Node lockTypeNode = null; + Node lockOwnerNode = null; + + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + break; + case Node.ELEMENT_NODE: + String nodeName = currentNode.getNodeName(); + if (nodeName.endsWith("lockscope")) { + lockScopeNode = currentNode; + } + if (nodeName.endsWith("locktype")) { + lockTypeNode = currentNode; + } + if (nodeName.endsWith("owner")) { + lockOwnerNode = currentNode; + } + break; + } + } + + if (lockScopeNode != null) { + + childList = lockScopeNode.getChildNodes(); + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + break; + case Node.ELEMENT_NODE: + String tempScope = currentNode.getNodeName(); + if (tempScope.indexOf(':') != -1) { + lock.scope = tempScope.substring + (tempScope.indexOf(':') + 1); + } else { + lock.scope = tempScope; + } + break; + } + } + + if (lock.scope == null) { + // Bad request + resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); + } + + } else { + // Bad request + resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); + } + + if (lockTypeNode != null) { + + childList = lockTypeNode.getChildNodes(); + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + break; + case Node.ELEMENT_NODE: + String tempType = currentNode.getNodeName(); + if (tempType.indexOf(':') != -1) { + lock.type = + tempType.substring(tempType.indexOf(':') + 1); + } else { + lock.type = tempType; + } + break; + } + } + + if (lock.type == null) { + // Bad request + resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); + } + + } else { + // Bad request + resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); + } + + if (lockOwnerNode != null) { + + childList = lockOwnerNode.getChildNodes(); + for (int i=0; i < childList.getLength(); i++) { + Node currentNode = childList.item(i); + switch (currentNode.getNodeType()) { + case Node.TEXT_NODE: + lock.owner += currentNode.getNodeValue(); + break; + case Node.ELEMENT_NODE: + strWriter = new StringWriter(); + domWriter = new DOMWriter(strWriter, true); + domWriter.setQualifiedNames(false); + domWriter.print(currentNode); + lock.owner += strWriter.toString(); + break; + } + } + + if (lock.owner == null) { + // Bad request + resp.setStatus(WebdavServletStatus.SC_BAD_REQUEST); + } + + } else { + lock.owner = ""; + } + + } + + String path = getRelativePath(req); + + lock.path = path; + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.WRITE); + if (ro == null)return; + boolean exists = ro.exists(); + /*Object object = null; + try { + object = resources.lookup(path); + } catch (NamingException e) { + exists = false; + }*/ + + Enumeration locksList = null; + + if (lockRequestType == LOCK_CREATION) { + + // Generating lock id + String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" + + lock.scope + "-" + req.getUserPrincipal() + "-" + + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" + + lock.expiresAt + "-" + System.currentTimeMillis() + "-" + + secret; + String lockToken = md5Encoder.encode(md5Helper.digest( + lockTokenStr.getBytes(Charset.defaultCharset()))); + + if ( (exists) && (ro.isDirectory()) && + (lock.depth == maxDepth) ) { + + // Locking a collection (and all its member resources) + + // Checking if a child resource of this collection is + // already locked + Vector lockPaths = new Vector(); + locksList = collectionLocks.elements(); + while (locksList.hasMoreElements()) { + LockInfo currentLock = locksList.nextElement(); + if (currentLock.hasExpired()) { + resourceLocks.remove(currentLock.path); + continue; + } + if ( (currentLock.path.startsWith(lock.path)) && + ((currentLock.isExclusive()) || + (lock.isExclusive())) ) { + // A child collection of this collection is locked + lockPaths.addElement(currentLock.path); + } + } + locksList = resourceLocks.elements(); + while (locksList.hasMoreElements()) { + LockInfo currentLock = locksList.nextElement(); + if (currentLock.hasExpired()) { + resourceLocks.remove(currentLock.path); + continue; + } + if ( (currentLock.path.startsWith(lock.path)) && + ((currentLock.isExclusive()) || + (lock.isExclusive())) ) { + // A child resource of this collection is locked + lockPaths.addElement(currentLock.path); + } + } + + if (!lockPaths.isEmpty()) { + + // One of the child paths was locked + // We generate a multistatus error report + + Enumeration lockPathsList = lockPaths.elements(); + + resp.setStatus(WebdavServletStatus.SC_CONFLICT); + + XMLWriter generatedXML = new XMLWriter(); + generatedXML.writeXMLHeader(); + + generatedXML.writeElement("D", DEFAULT_NAMESPACE, + "multistatus", XMLWriter.OPENING); + + while (lockPathsList.hasMoreElements()) { + generatedXML.writeElement("D", "response", + XMLWriter.OPENING); + generatedXML.writeElement("D", "href", + XMLWriter.OPENING); + generatedXML.writeText(lockPathsList.nextElement()); + generatedXML.writeElement("D", "href", + XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", + XMLWriter.OPENING); + generatedXML + .writeText("HTTP/1.1 " + WebdavServletStatus.SC_LOCKED + + " " + WebdavServletStatus + .getStatusText(WebdavServletStatus.SC_LOCKED)); + generatedXML.writeElement("D", "status", + XMLWriter.CLOSING); + + generatedXML.writeElement("D", "response", + XMLWriter.CLOSING); + } + + generatedXML.writeElement("D", "multistatus", + XMLWriter.CLOSING); + + Writer writer = resp.getWriter(); + writer.write(generatedXML.toString()); + writer.close(); + + return; + + } + + boolean addLock = true; + + // Checking if there is already a shared lock on this path + locksList = collectionLocks.elements(); + while (locksList.hasMoreElements()) { + + LockInfo currentLock = locksList.nextElement(); + if (currentLock.path.equals(lock.path)) { + + if (currentLock.isExclusive()) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } else { + if (lock.isExclusive()) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } + } + + currentLock.tokens.addElement(lockToken); + lock = currentLock; + addLock = false; + + } + + } + + if (addLock) { + lock.tokens.addElement(lockToken); + collectionLocks.addElement(lock); + } + + } else { + + // Locking a single resource + + // Retrieving an already existing lock on that resource + LockInfo presentLock = resourceLocks.get(lock.path); + if (presentLock != null) { + + if ((presentLock.isExclusive()) || (lock.isExclusive())) { + // If either lock is exclusive, the lock can't be + // granted + resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); + return; + } else { + presentLock.tokens.addElement(lockToken); + lock = presentLock; + } + + } else { + + lock.tokens.addElement(lockToken); + //FREE WORLD + //resourceLocks.put(lock.path, lock); + + // Checking if a resource exists at this path + /*exists = true; + try { + object = resources.lookup(path); + } catch (NamingException e) { + exists = false; + }*/ + if (!exists) { + + // "Creating" a lock-null resource + int slash = lock.path.lastIndexOf('/'); + String parentPath = lock.path.substring(0, slash); + + Vector lockNulls = + lockNullResources.get(parentPath); + if (lockNulls == null) { + lockNulls = new Vector(); + //FREE WORLD + //lockNullResources.put(parentPath, lockNulls); + } + + //FREE WORLD + //lockNulls.addElement(lock.path); + + } + // Add the Lock-Token header as by RFC 2518 8.10.1 + // - only do this for newly created locks + resp.addHeader("Lock-Token", ""); + //(" LOCKY TOKEN " + lockToken); + } + + } + + } + + if (lockRequestType == LOCK_REFRESH) { + + String ifHeader = req.getHeader("If"); + if (ifHeader == null) + ifHeader = ""; + + // Checking resource locks + + LockInfo toRenew = resourceLocks.get(path); + Enumeration tokenList = null; + + if (toRenew != null) { + // At least one of the tokens of the locks must have been given + tokenList = toRenew.tokens.elements(); + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (ifHeader.indexOf(token) != -1) { + toRenew.expiresAt = lock.expiresAt; + lock = toRenew; + } + } + } + + // Checking inheritable collection locks + + Enumeration collectionLocksList = + collectionLocks.elements(); + while (collectionLocksList.hasMoreElements()) { + toRenew = collectionLocksList.nextElement(); + if (path.equals(toRenew.path)) { + + tokenList = toRenew.tokens.elements(); + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (ifHeader.indexOf(token) != -1) { + toRenew.expiresAt = lock.expiresAt; + lock = toRenew; + } + } + + } + } + + } + + // Set the status, then generate the XML response containing + // the lock information + XMLWriter generatedXML = new XMLWriter(); + generatedXML.writeXMLHeader(); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "prop", + XMLWriter.OPENING); + + generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING); + + lock.toXML(generatedXML); + + generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + + resp.setStatus(WebdavServletStatus.SC_OK); + resp.setContentType("text/xml; charset=UTF-8"); + Writer writer = resp.getWriter(); + writer.write(generatedXML.toString()); + //(path + " XMLE RITER W " + generatedXML.toString()); + writer.close(); + + } + + + /** + * UNLOCK Method. + */ + protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) + throws IOException { + + } + + protected void doUnlock1(HttpServletRequest req, HttpServletResponse resp) + throws IOException { + + if (readOnly) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return; + } + + if (isLocked(req)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return; + } + + String path = getRelativePath(req); + + String lockTokenHeader = req.getHeader("Lock-Token"); + if (lockTokenHeader == null) + lockTokenHeader = ""; + + // Checking resource locks + + LockInfo lock = resourceLocks.get(path); + Enumeration tokenList = null; + if (lock != null) { + + // At least one of the tokens of the locks must have been given + + tokenList = lock.tokens.elements(); + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (lockTokenHeader.indexOf(token) != -1) { + lock.tokens.removeElement(token); + } + } + + if (lock.tokens.isEmpty()) { + resourceLocks.remove(path); + // Removing any lock-null resource which would be present + lockNullResources.remove(path); + } + + } + + // Checking inheritable collection locks + + Enumeration collectionLocksList = collectionLocks.elements(); + while (collectionLocksList.hasMoreElements()) { + lock = collectionLocksList.nextElement(); + if (path.equals(lock.path)) { + + tokenList = lock.tokens.elements(); + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (lockTokenHeader.indexOf(token) != -1) { + lock.tokens.removeElement(token); + break; + } + } + + if (lock.tokens.isEmpty()) { + collectionLocks.removeElement(lock); + // Removing any lock-null resource which would be present + lockNullResources.remove(path); + } + + } + } + + resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); + + } + + // -------------------------------------------------------- Private Methods + + /** + * Check to see if a resource is currently write locked. The method + * will look at the "If" header to make sure the client + * has give the appropriate lock tokens. + * + * @param req Servlet request + * @return boolean true if the resource is locked (and no appropriate + * lock token has been found for at least one of the non-shared locks which + * are present on the resource). + */ + private boolean isLocked(HttpServletRequest req) { + + String path = getRelativePath(req); + + String ifHeader = req.getHeader("If"); + if (ifHeader == null) + ifHeader = ""; + + String lockTokenHeader = req.getHeader("Lock-Token"); + if (lockTokenHeader == null) + lockTokenHeader = ""; + + return isLocked(path, ifHeader + lockTokenHeader); + + } + + + /** + * Check to see if a resource is currently write locked. + * + * @param path Path of the resource + * @param ifHeader "If" HTTP header which was included in the request + * @return boolean true if the resource is locked (and no appropriate + * lock token has been found for at least one of the non-shared locks which + * are present on the resource). + */ + private boolean isLocked(String path, String ifHeader) { + + // Checking resource locks + + LockInfo lock = resourceLocks.get(path); + Enumeration tokenList = null; + if ((lock != null) && (lock.hasExpired())) { + resourceLocks.remove(path); + } else if (lock != null) { + + // At least one of the tokens of the locks must have been given + + tokenList = lock.tokens.elements(); + boolean tokenMatch = false; + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (ifHeader.indexOf(token) != -1) + tokenMatch = true; + } + if (!tokenMatch) + return true; + + } + + // Checking inheritable collection locks + + Enumeration collectionLocksList = collectionLocks.elements(); + while (collectionLocksList.hasMoreElements()) { + lock = collectionLocksList.nextElement(); + if (lock.hasExpired()) { + collectionLocks.removeElement(lock); + } else if (path.startsWith(lock.path)) { + + tokenList = lock.tokens.elements(); + boolean tokenMatch = false; + while (tokenList.hasMoreElements()) { + String token = tokenList.nextElement(); + if (ifHeader.indexOf(token) != -1) + tokenMatch = true; + } + if (!tokenMatch) + return true; + + } + } + + return false; + + } + + + /** + * Copy a resource. + * + * @param req Servlet request + * @param resp Servlet response + * @return boolean true if the copy is successful + */ + private boolean copyResource(HttpServletRequest req, + HttpServletResponse resp) + throws CaimitoException,IOException { + + // Parsing destination header + + String destinationPath = req.getHeader("Destination"); + + if (destinationPath == null) { + resp.sendError(WebdavServletStatus.SC_BAD_REQUEST); + return false; + } + + // Remove url encoding from destination + destinationPath = org.apache.catalina.util.RequestUtil.URLDecode( + destinationPath, "UTF8"); + + int protocolIndex = destinationPath.indexOf("://"); + if (protocolIndex >= 0) { + // if the Destination URL contains the protocol, we can safely + // trim everything upto the first "/" character after "://" + int firstSeparator = + destinationPath.indexOf("/", protocolIndex + 4); + if (firstSeparator < 0) { + destinationPath = "/"; + } else { + destinationPath = destinationPath.substring(firstSeparator); + } + } else { + String hostName = req.getServerName(); + if ((hostName != null) && (destinationPath.startsWith(hostName))) { + destinationPath = destinationPath.substring(hostName.length()); + } + + int portIndex = destinationPath.indexOf(":"); + if (portIndex >= 0) { + destinationPath = destinationPath.substring(portIndex); + } + + if (destinationPath.startsWith(":")) { + int firstSeparator = destinationPath.indexOf("/"); + if (firstSeparator < 0) { + destinationPath = "/"; + } else { + destinationPath = + destinationPath.substring(firstSeparator); + } + } + } + + // Normalise destination path (remove '.' and '..') + destinationPath = RequestUtil.normalize(destinationPath); + + String contextPath = req.getContextPath(); + if ((contextPath != null) && + (destinationPath.startsWith(contextPath))) { + destinationPath = destinationPath.substring(contextPath.length()); + } + + String pathInfo = req.getPathInfo(); + if (pathInfo != null) { + String servletPath = req.getServletPath(); + if ((servletPath != null) && + (destinationPath.startsWith(servletPath))) { + destinationPath = destinationPath + .substring(servletPath.length()); + } + } + + if (debug > 0) + log("Dest path :" + destinationPath); + + // Check destination path to protect special subdirectories + //if (isSpecialPath(destinationPath)) { + // resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + // return false; + //} + + String path = getRelativePath(req); + + if (destinationPath.equals(path)) { + resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return false; + } + + // Parsing overwrite header + + boolean overwrite = true; + String overwriteHeader = req.getHeader("Overwrite"); + + if (overwriteHeader != null) { + if (overwriteHeader.equalsIgnoreCase("T")) { + overwrite = true; + } else { + overwrite = false; + } + } + + // Overwriting the destination + ResourceObj ro = ResourceStore.lookup(destinationPath,req,resp,ResourceStore.WRITE); + ResourceObj ros = ResourceStore.lookup(path,req,resp,ResourceStore.READ); + + if (ro == null || ros == null){ + + //if (!ro.canWrite() || !ros.canRead()) { + //resp.sendError(WebdavServletStatus.SC_FORBIDDEN); + return false; + } + + boolean exists = ro.exists(); + /*try { + resources.lookup(destinationPath); + } catch (NamingException e) { + exists = false; + }*/ + + if (overwrite) { + + // destination resource, if it exists + if (exists) { + //if (! Resource(destinationPath, req, resp, true)) { + // return false; + //} + ro.delete(); + } else { + resp.setStatus(WebdavServletStatus.SC_CREATED); + } + + } else { + + // If the destination exists, then it's a conflict + if (exists) { + resp.sendError(WebdavServletStatus.SC_PRECONDITION_FAILED); + return false; + } + + } + + // Copying source to destination + + ros.copy(ro); + /*Hashtable errorList = new Hashtable(); + + boolean result = copyResource(resources, errorList, + path, destinationPath); + + if ((!result) || (!errorList.isEmpty())) { + if (errorList.size() == 1) { + resp.sendError(errorList.elements().nextElement().intValue()); + } else { + sendReport(req, resp, errorList); + } + return false; + }*/ + + // Copy was successful + if (exists) { + resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); + } else { + resp.setStatus(WebdavServletStatus.SC_CREATED); + } + + // Removing any lock-null resource which would be present at + // the destination path + lockNullResources.remove(destinationPath); + + return true; + + } + + + /** + * Copy a collection. + * + * @param dirContext Resources implementation to be used + * @param errorList Hashtable containing the list of errors which occurred + * during the copy operation + * @param source Path of the resource to be copied + * @param dest Destination path + */ + private boolean copyResource(DirContext dirContext, + Hashtable errorList, String source, String dest) { + + if (debug > 1) + log("Copy: " + source + " To: " + dest); + + Object object = null; + try { + object = dirContext.lookup(source); + } catch (NamingException e) { + // Ignore + } + + if (object instanceof DirContext) { + + try { + dirContext.createSubcontext(dest); + } catch (NamingException e) { + errorList.put + (dest, new Integer(WebdavServletStatus.SC_CONFLICT)); + return false; + } + + try { + NamingEnumeration enumeration = + dirContext.list(source); + while (enumeration.hasMoreElements()) { + NameClassPair ncPair = enumeration.nextElement(); + String childDest = dest; + if (!childDest.equals("/")) + childDest += "/"; + childDest += ncPair.getName(); + String childSrc = source; + if (!childSrc.equals("/")) + childSrc += "/"; + childSrc += ncPair.getName(); + copyResource(dirContext, errorList, childSrc, childDest); + } + } catch (NamingException e) { + errorList.put + (dest, new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + return false; + } + + } else { + + if (object instanceof Resource) { + try { + dirContext.bind(dest, object); + } catch (NamingException e) { + if (e.getCause() instanceof FileNotFoundException) { + // We know the source exists so it must be the + // destination dir that can't be found + errorList.put(source, + new Integer(WebdavServletStatus.SC_CONFLICT)); + } else { + errorList.put(source, + new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + } + return false; + } + } else { + errorList.put + (source, + new Integer(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + return false; + } + + } + + return true; + + } + + + /** + * Delete a resource. + * + * @param req Servlet request + * @param resp Servlet response + * @return boolean true if the copy is successful + */ + private boolean deleteResource(HttpServletRequest req, + HttpServletResponse resp) + throws IOException { + + String path = getRelativePath(req); + + return deleteResource(path, req, resp, true); + + } + + + /** + * Delete a resource. + * + * @param path Path of the resource which is to be deleted + * @param req Servlet request + * @param resp Servlet response + * @param setStatus Should the response status be set on successful + * completion + */ + private boolean deleteResource(String path, HttpServletRequest req, + HttpServletResponse resp, boolean setStatus) + throws IOException { + + String ifHeader = req.getHeader("If"); + if (ifHeader == null) + ifHeader = ""; + + String lockTokenHeader = req.getHeader("Lock-Token"); + if (lockTokenHeader == null) + lockTokenHeader = ""; + + if (isLocked(path, ifHeader + lockTokenHeader)) { + resp.sendError(WebdavServletStatus.SC_LOCKED); + return false; + } + + boolean exists = true; + Object object = null; + try { + object = resources.lookup(path); + } catch (NamingException e) { + exists = false; + } + + if (!exists) { + resp.sendError(WebdavServletStatus.SC_NOT_FOUND); + return false; + } + + boolean collection = (object instanceof DirContext); + + if (!collection) { + try { + resources.unbind(path); + } catch (NamingException e) { + resp.sendError(WebdavServletStatus.SC_INTERNAL_SERVER_ERROR); + return false; + } + } else { + + Hashtable errorList = + new Hashtable(); + + deleteCollection(req, resources, path, errorList); + try { + resources.unbind(path); + } catch (NamingException e) { + errorList.put(path, new Integer + (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + } + + if (!errorList.isEmpty()) { + + sendReport(req, resp, errorList); + return false; + + } + + } + if (setStatus) { + resp.setStatus(WebdavServletStatus.SC_NO_CONTENT); + } + return true; + + } + + + /** + * Deletes a collection. + * + * @param dirContext Resources implementation associated with the context + * @param path Path to the collection to be deleted + * @param errorList Contains the list of the errors which occurred + */ + private void deleteCollection(HttpServletRequest req, + DirContext dirContext, + String path, + Hashtable errorList) { + + if (debug > 1) + log("Delete:" + path); + + // Prevent deletion of special subdirectories + if (isSpecialPath(path)) { + errorList.put(path, new Integer(WebdavServletStatus.SC_FORBIDDEN)); + return; + } + + String ifHeader = req.getHeader("If"); + if (ifHeader == null) + ifHeader = ""; + + String lockTokenHeader = req.getHeader("Lock-Token"); + if (lockTokenHeader == null) + lockTokenHeader = ""; + + Enumeration enumeration = null; + try { + enumeration = dirContext.list(path); + } catch (NamingException e) { + errorList.put(path, new Integer + (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + return; + } + + while (enumeration.hasMoreElements()) { + NameClassPair ncPair = enumeration.nextElement(); + String childName = path; + if (!childName.equals("/")) + childName += "/"; + childName += ncPair.getName(); + + if (isLocked(childName, ifHeader + lockTokenHeader)) { + + errorList.put(childName, new Integer(WebdavServletStatus.SC_LOCKED)); + + } else { + + try { + Object object = dirContext.lookup(childName); + if (object instanceof DirContext) { + deleteCollection(req, dirContext, childName, errorList); + } + + try { + dirContext.unbind(childName); + } catch (NamingException e) { + if (!(object instanceof DirContext)) { + // If it's not a collection, then it's an unknown + // error + errorList.put + (childName, new Integer + (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + } + } + } catch (NamingException e) { + errorList.put + (childName, new Integer + (WebdavServletStatus.SC_INTERNAL_SERVER_ERROR)); + } + } + + } + + } + + + /** + * Send a multistatus element containing a complete error report to the + * client. + * + * @param req Servlet request + * @param resp Servlet response + * @param errorList List of error to be displayed + */ + private void sendReport(HttpServletRequest req, HttpServletResponse resp, + Hashtable errorList) + throws IOException { + + resp.setStatus(WebdavServletStatus.SC_MULTI_STATUS); + + String absoluteUri = req.getRequestURI(); + String relativePath = getRelativePath(req); + + XMLWriter generatedXML = new XMLWriter(); + generatedXML.writeXMLHeader(); + + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", + XMLWriter.OPENING); + + Enumeration pathList = errorList.keys(); + while (pathList.hasMoreElements()) { + + String errorPath = pathList.nextElement(); + int errorCode = errorList.get(errorPath).intValue(); + + generatedXML.writeElement("D", "response", XMLWriter.OPENING); + + generatedXML.writeElement("D", "href", XMLWriter.OPENING); + String toAppend = errorPath.substring(relativePath.length()); + if (!toAppend.startsWith("/")) + toAppend = "/" + toAppend; + generatedXML.writeText(absoluteUri + toAppend); + generatedXML.writeElement("D", "href", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText("HTTP/1.1 " + errorCode + " " + + WebdavServletStatus.getStatusText(errorCode)); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "response", XMLWriter.CLOSING); + + } + + generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); + + Writer writer = resp.getWriter(); + writer.write(generatedXML.toString()); + writer.close(); + + } + + + /** + * Propfind helper method. + * + * @param req The servlet request + * @param resources Resources object associated with this context + * @param generatedXML XML response to the Propfind request + * @param path Path of the current resource + * @param type Propfind type + * @param propertiesVector If the propfind type is find properties by + * name, then this Vector contains those properties + */ + private void parseProperties(HttpServletRequest req,HttpServletResponse resp, + XMLWriter generatedXML, + String path, int type, + Vector propertiesVector) throws CaimitoException { + + // Exclude any resource in the /WEB-INF and /META-INF subdirectories + // if (isSpecialPath(path)) + // return; + + // CacheEntry cacheEntry = resources.lookupCache(path); + //(type + " parseProperties Z Prop " + path); + ResourceObj cacheEntry = ResourceStore.lookup(path,req,resp,ResourceStore.READ); + + if (!cacheEntry.exists()) { + // File is in directory listing but doesn't appear to exist + // Broken symlink or odd permission settings? + return; + } + + generatedXML.writeElement("D", "response", XMLWriter.OPENING); + String status = "HTTP/1.1 " + WebdavServletStatus.SC_OK + " " + + WebdavServletStatus.getStatusText(WebdavServletStatus.SC_OK); + + // Generating href element + generatedXML.writeElement("D", "href", XMLWriter.OPENING); + + String href = req.getContextPath() + req.getServletPath(); + if ((href.endsWith("/")) && (path.startsWith("/"))) + href += path.substring(1); + else + href += path; + if ((cacheEntry.isDirectory()) && (!href.endsWith("/"))) + href += "/"; + + generatedXML.writeText(rewriteUrl(href)); + + generatedXML.writeElement("D", "href", XMLWriter.CLOSING); + + String resourceName = path; + int lastSlash = path.lastIndexOf('/'); + if (lastSlash != -1) + resourceName = resourceName.substring(lastSlash + 1); + + switch (type) { + + case FIND_ALL_PROP : + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + generatedXML.writeProperty("D", "creationdate", + getISOCreationDate(cacheEntry.getCreation())); + generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); + generatedXML.writeData(resourceName); + generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); + //if (!cacheEntry.isDirectory()) { + generatedXML.writeProperty + ("D", "getlastmodified", FastHttpDateFormat.formatDate + (cacheEntry.getLastModified(), null)); + if (!cacheEntry.isDirectory()) { + generatedXML.writeProperty + ("D", "getcontentlength", + String.valueOf(cacheEntry.getContentLength())); + String contentType = getServletContext().getMimeType + (cacheEntry.getName()); + if (contentType != null) { + generatedXML.writeProperty("D", "getcontenttype", + contentType); + } + generatedXML.writeProperty("D", "getetag", + cacheEntry.getETag()); + generatedXML.writeElement("D", "resourcetype", + XMLWriter.NO_CONTENT); + } else { + generatedXML.writeElement("D", "resourcetype", + XMLWriter.OPENING); + generatedXML.writeElement("D", "collection", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "resourcetype", + XMLWriter.CLOSING); + } + + generatedXML.writeProperty("D", "source", ""); + + String supportedLocks = "" + + "" + + "" + + "" + "" + + "" + + "" + + ""; + generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); + generatedXML.writeText(supportedLocks); + generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); + + generateLockDiscovery(path, generatedXML); + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + break; + + case FIND_PROPERTY_NAMES : + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + generatedXML.writeElement("D", "creationdate", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "displayname", XMLWriter.NO_CONTENT); + if (!cacheEntry.isDirectory()) { + generatedXML.writeElement("D", "getcontentlanguage", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontentlength", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontenttype", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getetag", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getlastmodified", + XMLWriter.NO_CONTENT); + } + generatedXML.writeElement("D", "resourcetype", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "source", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "lockdiscovery", + XMLWriter.NO_CONTENT); + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + break; + + case FIND_BY_PROPERTY : + + Vector propertiesNotFound = new Vector(); + + // Parse the list of properties + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + Enumeration properties = propertiesVector.elements(); + + while (properties.hasMoreElements()) { + + String property = properties.nextElement(); + + if (property.equals("creationdate")) { + generatedXML.writeProperty + ("D", "creationdate", + getISOCreationDate(cacheEntry.getCreation())); + } else if (property.equals("displayname")) { + generatedXML.writeElement + ("D", "displayname", XMLWriter.OPENING); + generatedXML.writeData(resourceName); + generatedXML.writeElement + ("D", "displayname", XMLWriter.CLOSING); + } else if (property.equals("getcontentlanguage")) { + if (cacheEntry.isDirectory()) { + propertiesNotFound.addElement(property); + } else { + generatedXML.writeElement("D", "getcontentlanguage", + XMLWriter.NO_CONTENT); + } + } else if (property.equals("getcontentlength")) { + if (cacheEntry.isDirectory()) { + propertiesNotFound.addElement(property); + } else { + generatedXML.writeProperty + ("D", "getcontentlength", + (String.valueOf(cacheEntry.getContentLength()))); + } + } else if (property.equals("getcontenttype")) { + if (cacheEntry.isDirectory()) { + propertiesNotFound.addElement(property); + } else { + //(cacheEntry.getName() + " MIMEO TYPE " + getServletContext().getMimeType(cacheEntry.getName())); + generatedXML.writeProperty + ("D", "getcontenttype", + getServletContext().getMimeType + (cacheEntry.getName())); + } + } else if (property.equals("getetag")) { + if (cacheEntry.isDirectory()) { + propertiesNotFound.addElement(property); + } else { + generatedXML.writeProperty + ("D", "getetag", cacheEntry.getETag()); + } + } else if (property.equals("getlastmodified")) { + //if (cacheEntry.isDirectory()) { + // propertiesNotFound.addElement(property); + //} else { + generatedXML.writeProperty + ("D", "getlastmodified", FastHttpDateFormat.formatDate + (cacheEntry.getLastModified(), null)); + //} + } else if (property.equals("resourcetype")) { + if (cacheEntry.isDirectory()) { + generatedXML.writeElement("D", "resourcetype", + XMLWriter.OPENING); + generatedXML.writeElement("D", "collection", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "resourcetype", + XMLWriter.CLOSING); + } else { + generatedXML.writeElement("D", "resourcetype", + XMLWriter.NO_CONTENT); + } + } else if (property.equals("source")) { + generatedXML.writeProperty("D", "source", ""); + } else if (property.equals("supportedlock")) { + supportedLocks = "" + + "" + + "" + + "" + "" + + "" + + "" + + ""; + generatedXML.writeElement("D", "supportedlock", + XMLWriter.OPENING); + generatedXML.writeText(supportedLocks); + generatedXML.writeElement("D", "supportedlock", + XMLWriter.CLOSING); + } else if (property.equals("lockdiscovery")) { + if (!generateLockDiscovery(path, generatedXML)) + propertiesNotFound.addElement(property); + } else { + propertiesNotFound.addElement(property); + } + + } + + //(cacheEntry.getName() + ":" + propertiesVector + " property e propertiesNotFoundList " + propertiesNotFound); + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + Enumeration propertiesNotFoundList = + propertiesNotFound.elements(); + + if (propertiesNotFoundList.hasMoreElements()) { + + status = "HTTP/1.1 " + WebdavServletStatus.SC_NOT_FOUND + " " + + WebdavServletStatus.getStatusText(WebdavServletStatus.SC_NOT_FOUND); + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + while (propertiesNotFoundList.hasMoreElements()) { + generatedXML.writeElement + ("D", propertiesNotFoundList.nextElement(), + XMLWriter.NO_CONTENT); + } + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + } + + break; + + } + + generatedXML.writeElement("D", "response", XMLWriter.CLOSING); + + } + + + /** + * Propfind helper method. Displays the properties of a lock-null resource. + * + * @param resources Resources object associated with this context + * @param generatedXML XML response to the Propfind request + * @param path Path of the current resource + * @param type Propfind type + * @param propertiesVector If the propfind type is find properties by + * name, then this Vector contains those properties + */ + private void parseLockNullProperties(HttpServletRequest req, + XMLWriter generatedXML, + String path, int type, + Vector propertiesVector) { + + // Exclude any resource in the /WEB-INF and /META-INF subdirectories + //if (isSpecialPath(path)) + // return; + + Thread.dumpStack(); + // Retrieving the lock associated with the lock-null resource + LockInfo lock = resourceLocks.get(path); + + if (lock == null) + return; + + generatedXML.writeElement("D", "response", XMLWriter.OPENING); + String status = "HTTP/1.1 " + WebdavServletStatus.SC_OK + " " + + WebdavServletStatus.getStatusText(WebdavServletStatus.SC_OK); + + // Generating href element + generatedXML.writeElement("D", "href", XMLWriter.OPENING); + + String absoluteUri = req.getRequestURI(); + String relativePath = getRelativePath(req); + String toAppend = path.substring(relativePath.length()); + if (!toAppend.startsWith("/")) + toAppend = "/" + toAppend; + + generatedXML.writeText(rewriteUrl(RequestUtil.normalize( + absoluteUri + toAppend))); + + generatedXML.writeElement("D", "href", XMLWriter.CLOSING); + + String resourceName = path; + int lastSlash = path.lastIndexOf('/'); + if (lastSlash != -1) + resourceName = resourceName.substring(lastSlash + 1); + + switch (type) { + + case FIND_ALL_PROP : + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + generatedXML.writeProperty("D", "creationdate", + getISOCreationDate(lock.creationDate.getTime())); + generatedXML.writeElement("D", "displayname", XMLWriter.OPENING); + generatedXML.writeData(resourceName); + generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); + generatedXML.writeProperty("D", "getlastmodified", + FastHttpDateFormat.formatDate + (lock.creationDate.getTime(), null)); + generatedXML.writeProperty("D", "getcontentlength", + String.valueOf(0)); + generatedXML.writeProperty("D", "getcontenttype", ""); + generatedXML.writeProperty("D", "getetag", ""); + generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING); + generatedXML.writeElement("D", "lock-null", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING); + + generatedXML.writeProperty("D", "source", ""); + + String supportedLocks = "" + + "" + + "" + + "" + "" + + "" + + "" + + ""; + generatedXML.writeElement("D", "supportedlock", XMLWriter.OPENING); + generatedXML.writeText(supportedLocks); + generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); + + generateLockDiscovery(path, generatedXML); + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + break; + + case FIND_PROPERTY_NAMES : + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + generatedXML.writeElement("D", "creationdate", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "displayname", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontentlanguage", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontentlength", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontenttype", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getetag", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getlastmodified", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "resourcetype", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "source", XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "lockdiscovery", + XMLWriter.NO_CONTENT); + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + break; + + case FIND_BY_PROPERTY : + + Vector propertiesNotFound = new Vector(); + + // Parse the list of properties + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + Enumeration properties = propertiesVector.elements(); + + while (properties.hasMoreElements()) { + + String property = properties.nextElement(); + + if (property.equals("creationdate")) { + generatedXML.writeProperty("D", "creationdate", + getISOCreationDate(lock.creationDate.getTime())); + } else if (property.equals("displayname")) { + generatedXML.writeElement("D", "displayname", + XMLWriter.OPENING); + generatedXML.writeData(resourceName); + generatedXML.writeElement("D", "displayname", + XMLWriter.CLOSING); + } else if (property.equals("getcontentlanguage")) { + generatedXML.writeElement("D", "getcontentlanguage", + XMLWriter.NO_CONTENT); + } else if (property.equals("getcontentlength")) { + generatedXML.writeProperty("D", "getcontentlength", + (String.valueOf(0))); + } else if (property.equals("getcontenttype")) { + generatedXML.writeProperty("D", "getcontenttype", ""); + } else if (property.equals("getetag")) { + generatedXML.writeProperty("D", "getetag", ""); + } else if (property.equals("getlastmodified")) { + generatedXML.writeProperty + ("D", "getlastmodified", + FastHttpDateFormat.formatDate + (lock.creationDate.getTime(), null)); + } else if (property.equals("resourcetype")) { + generatedXML.writeElement("D", "resourcetype", + XMLWriter.OPENING); + generatedXML.writeElement("D", "lock-null", + XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "resourcetype", + XMLWriter.CLOSING); + } else if (property.equals("source")) { + generatedXML.writeProperty("D", "source", ""); + } else if (property.equals("supportedlock")) { + supportedLocks = "" + + "" + + "" + + "" + "" + + "" + + "" + + ""; + generatedXML.writeElement("D", "supportedlock", + XMLWriter.OPENING); + generatedXML.writeText(supportedLocks); + generatedXML.writeElement("D", "supportedlock", + XMLWriter.CLOSING); + } else if (property.equals("lockdiscovery")) { + if (!generateLockDiscovery(path, generatedXML)) + propertiesNotFound.addElement(property); + } else { + propertiesNotFound.addElement(property); + } + + } + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + Enumeration propertiesNotFoundList = propertiesNotFound.elements(); + + if (propertiesNotFoundList.hasMoreElements()) { + + status = "HTTP/1.1 " + WebdavServletStatus.SC_NOT_FOUND + " " + + WebdavServletStatus.getStatusText(WebdavServletStatus.SC_NOT_FOUND); + + generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); + generatedXML.writeElement("D", "prop", XMLWriter.OPENING); + + while (propertiesNotFoundList.hasMoreElements()) { + generatedXML.writeElement + ("D", propertiesNotFoundList.nextElement(), + XMLWriter.NO_CONTENT); + } + + generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText(status); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); + + } + + break; + + } + + generatedXML.writeElement("D", "response", XMLWriter.CLOSING); + + } + + + /** + * Print the lock discovery information associated with a path. + * + * @param path Path + * @param generatedXML XML data to which the locks info will be appended + * @return true if at least one lock was displayed + */ + private boolean generateLockDiscovery + (String path, XMLWriter generatedXML) { + + LockInfo resourceLock = resourceLocks.get(path); + Enumeration collectionLocksList = collectionLocks.elements(); + + boolean wroteStart = false; + + if (resourceLock != null) { + wroteStart = true; + generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING); + resourceLock.toXML(generatedXML); + } + + while (collectionLocksList.hasMoreElements()) { + LockInfo currentLock = collectionLocksList.nextElement(); + if (path.startsWith(currentLock.path)) { + if (!wroteStart) { + wroteStart = true; + generatedXML.writeElement("D", "lockdiscovery", + XMLWriter.OPENING); + } + currentLock.toXML(generatedXML); + } + } + + if (wroteStart) { + generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING); + } else { + return false; + } + + return true; + + } + + + /** + * Get creation date in ISO format. + */ + private String getISOCreationDate(long creationDate) { + StringBuilder creationDateValue = new StringBuilder + (creationDateFormat.format + (new Date(creationDate))); + /* + int offset = Calendar.getInstance().getTimeZone().getRawOffset() + / 3600000; // FIXME ? + if (offset < 0) { + creationDateValue.append("-"); + offset = -offset; + } else if (offset > 0) { + creationDateValue.append("+"); + } + if (offset != 0) { + if (offset < 10) + creationDateValue.append("0"); + creationDateValue.append(offset + ":00"); + } else { + creationDateValue.append("Z"); + } + */ + return creationDateValue.toString(); + } + + /** + * Determines the methods normally allowed for the resource. + * + */ + private StringBuilder determineMethodsAllowed(HttpServletRequest req,HttpServletResponse resp) throws CaimitoException { + + StringBuilder methodsAllowed = new StringBuilder(); + + String path = getRelativePath(req); + //(" determineMethodsAllowed path " + path); + ResourceObj ro = ResourceStore.lookup(path,req,resp,ResourceStore.READ); + //if (ro == null)return methodsAllowed; + boolean exists = true; + if (ro != null) + exists = ro.exists(); + + + + if (!exists) { + methodsAllowed.append("OPTIONS, MKCOL, PUT, LOCK"); + return methodsAllowed; + } +//PROPPATCH, + methodsAllowed.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE"); + methodsAllowed.append(", COPY, MOVE, LOCK, UNLOCK"); + + if (ro == null || ro.listings()) { + methodsAllowed.append(", PROPFIND"); + } + + if (ro != null && !(ro.isDirectory())) { + methodsAllowed.append(", PUT"); + } + + return methodsAllowed; + } + + // -------------------------------------------------- LockInfo Inner Class + + + /** + * Holds a lock information. + */ + private class LockInfo { + + + // -------------------------------------------------------- Constructor + + + /** + * Constructor. + */ + public LockInfo() { + // Ignore + } + + + // ------------------------------------------------- Instance Variables + + + String path = "/"; + String type = "write"; + String scope = "exclusive"; + int depth = 0; + String owner = ""; + Vector tokens = new Vector(); + long expiresAt = 0; + Date creationDate = new Date(); + + + // ----------------------------------------------------- Public Methods + + + /** + * Get a String representation of this lock token. + */ + @Override + public String toString() { + + StringBuilder result = new StringBuilder("Type:"); + result.append(type); + result.append("\nScope:"); + result.append(scope); + result.append("\nDepth:"); + result.append(depth); + result.append("\nOwner:"); + result.append(owner); + result.append("\nExpiration:"); + result.append(FastHttpDateFormat.formatDate(expiresAt, null)); + Enumeration tokensList = tokens.elements(); + while (tokensList.hasMoreElements()) { + result.append("\nToken:"); + result.append(tokensList.nextElement()); + } + result.append("\n"); + return result.toString(); + } + + + /** + * Return true if the lock has expired. + */ + public boolean hasExpired() { + return (System.currentTimeMillis() > expiresAt); + } + + + /** + * Return true if the lock is exclusive. + */ + public boolean isExclusive() { + + return (scope.equals("exclusive")); + + } + + + /** + * Get an XML representation of this lock token. This method will + * append an XML fragment to the given XML writer. + */ + public void toXML(XMLWriter generatedXML) { + + generatedXML.writeElement("D", "activelock", XMLWriter.OPENING); + + generatedXML.writeElement("D", "locktype", XMLWriter.OPENING); + generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING); + generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "depth", XMLWriter.OPENING); + if (depth == maxDepth) { + generatedXML.writeText("Infinity"); + } else { + generatedXML.writeText("0"); + } + generatedXML.writeElement("D", "depth", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "owner", XMLWriter.OPENING); + generatedXML.writeText(owner); + generatedXML.writeElement("D", "owner", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "timeout", XMLWriter.OPENING); + long timeout = (expiresAt - System.currentTimeMillis()) / 1000; + generatedXML.writeText("Second-" + timeout); + generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING); + Enumeration tokensList = tokens.elements(); + while (tokensList.hasMoreElements()) { + generatedXML.writeElement("D", "href", XMLWriter.OPENING); + generatedXML.writeText("opaquelocktoken:" + + tokensList.nextElement()); + generatedXML.writeElement("D", "href", XMLWriter.CLOSING); + } + generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING); + + generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING); + + } + + + } + + + // --------------------------------------------- WebdavResolver Inner Class + /** + * Work around for XML parsers that don't fully respect + * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean)} when + * called with false. External references are filtered out for + * security reasons. See CVE-2007-5461. + */ + private static class WebdavResolver implements EntityResolver { + private ServletContext context; + + public WebdavResolver(ServletContext theContext) { + context = theContext; + } + + @Override + public InputSource resolveEntity (String publicId, String systemId) { + context.log("webdavservlet.enternalEntityIgnored"); + return new InputSource( + new StringReader("Ignored external entity")); + } + } +} + + +// -------------------------------------------------------- WebdavServletStatus Class + + +/** + * Wraps the HttpServletResponse class to abstract the + * specific protocol used. To support other protocols + * we would only need to modify this class and the + * WebDavRetCode classes. + * + * @author Marc Eaddy + * @version 1.0, 16 Nov 1997 + */ +class WebdavServletStatus { + + + // ----------------------------------------------------- Instance Variables + + + /** + * This Hashtable contains the mapping of HTTP and WebDAV + * status codes to descriptive text. This is a static + * variable. + */ + private static Hashtable mapStatusCodes = + new Hashtable(); + + + // ------------------------------------------------------ HTTP Status Codes + + + /** + * Status code (200) indicating the request succeeded normally. + */ + public static final int SC_OK = HttpServletResponse.SC_OK; + + + /** + * Status code (201) indicating the request succeeded and created + * a new resource on the server. + */ + public static final int SC_CREATED = HttpServletResponse.SC_CREATED; + + + /** + * Status code (202) indicating that a request was accepted for + * processing, but was not completed. + */ + public static final int SC_ACCEPTED = HttpServletResponse.SC_ACCEPTED; + + + /** + * Status code (204) indicating that the request succeeded but that + * there was no new information to return. + */ + public static final int SC_NO_CONTENT = HttpServletResponse.SC_NO_CONTENT; + + + /** + * Status code (301) indicating that the resource has permanently + * moved to a new location, and that future references should use a + * new URI with their requests. + */ + public static final int SC_MOVED_PERMANENTLY = + HttpServletResponse.SC_MOVED_PERMANENTLY; + + + /** + * Status code (302) indicating that the resource has temporarily + * moved to another location, but that future references should + * still use the original URI to access the resource. + */ + public static final int SC_MOVED_TEMPORARILY = + HttpServletResponse.SC_MOVED_TEMPORARILY; + + + /** + * Status code (304) indicating that a conditional GET operation + * found that the resource was available and not modified. + */ + public static final int SC_NOT_MODIFIED = + HttpServletResponse.SC_NOT_MODIFIED; + + + /** + * Status code (400) indicating the request sent by the client was + * syntactically incorrect. + */ + public static final int SC_BAD_REQUEST = + HttpServletResponse.SC_BAD_REQUEST; + + + /** + * Status code (401) indicating that the request requires HTTP + * authentication. + */ + public static final int SC_UNAUTHORIZED = + HttpServletResponse.SC_UNAUTHORIZED; + + + /** + * Status code (403) indicating the server understood the request + * but refused to fulfill it. + */ + public static final int SC_FORBIDDEN = HttpServletResponse.SC_FORBIDDEN; + + + /** + * Status code (404) indicating that the requested resource is not + * available. + */ + public static final int SC_NOT_FOUND = HttpServletResponse.SC_NOT_FOUND; + + + /** + * Status code (500) indicating an error inside the HTTP service + * which prevented it from fulfilling the request. + */ + public static final int SC_INTERNAL_SERVER_ERROR = + HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + + + /** + * Status code (501) indicating the HTTP service does not support + * the functionality needed to fulfill the request. + */ + public static final int SC_NOT_IMPLEMENTED = + HttpServletResponse.SC_NOT_IMPLEMENTED; + + + /** + * Status code (502) indicating that the HTTP server received an + * invalid response from a server it consulted when acting as a + * proxy or gateway. + */ + public static final int SC_BAD_GATEWAY = + HttpServletResponse.SC_BAD_GATEWAY; + + + /** + * Status code (503) indicating that the HTTP service is + * temporarily overloaded, and unable to handle the request. + */ + public static final int SC_SERVICE_UNAVAILABLE = + HttpServletResponse.SC_SERVICE_UNAVAILABLE; + + + /** + * Status code (100) indicating the client may continue with + * its request. This interim response is used to inform the + * client that the initial part of the request has been + * received and has not yet been rejected by the server. + */ + public static final int SC_CONTINUE = 100; + + + /** + * Status code (405) indicating the method specified is not + * allowed for the resource. + */ + public static final int SC_METHOD_NOT_ALLOWED = 405; + + + /** + * Status code (409) indicating that the request could not be + * completed due to a conflict with the current state of the + * resource. + */ + public static final int SC_CONFLICT = 409; + + + /** + * Status code (412) indicating the precondition given in one + * or more of the request-header fields evaluated to false + * when it was tested on the server. + */ + public static final int SC_PRECONDITION_FAILED = 412; + + + /** + * Status code (413) indicating the server is refusing to + * process a request because the request entity is larger + * than the server is willing or able to process. + */ + public static final int SC_REQUEST_TOO_LONG = 413; + + + /** + * Status code (415) indicating the server is refusing to service + * the request because the entity of the request is in a format + * not supported by the requested resource for the requested + * method. + */ + public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; + + + // -------------------------------------------- Extended WebDav status code + + + /** + * Status code (207) indicating that the response requires + * providing status for multiple independent operations. + */ + public static final int SC_MULTI_STATUS = 207; + // This one collides with HTTP 1.1 + // "207 Partial Update OK" + + + /** + * Status code (418) indicating the entity body submitted with + * the PATCH method was not understood by the resource. + */ + public static final int SC_UNPROCESSABLE_ENTITY = 418; + // This one collides with HTTP 1.1 + // "418 Reauthentication Required" + + + /** + * Status code (419) indicating that the resource does not have + * sufficient space to record the state of the resource after the + * execution of this method. + */ + public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; + // This one collides with HTTP 1.1 + // "419 Proxy Reauthentication Required" + + + /** + * Status code (420) indicating the method was not executed on + * a particular resource within its scope because some part of + * the method's execution failed causing the entire method to be + * aborted. + */ + public static final int SC_METHOD_FAILURE = 420; + + + /** + * Status code (423) indicating the destination resource of a + * method is locked, and either the request did not contain a + * valid Lock-Info header, or the Lock-Info header identifies + * a lock held by another principal. + */ + public static final int SC_LOCKED = 423; + + + // ------------------------------------------------------------ Initializer + + + static { + // HTTP 1.0 status Code + addStatusCodeMap(SC_OK, "OK"); + addStatusCodeMap(SC_CREATED, "Created"); + addStatusCodeMap(SC_ACCEPTED, "Accepted"); + addStatusCodeMap(SC_NO_CONTENT, "No Content"); + addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently"); + addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily"); + addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified"); + addStatusCodeMap(SC_BAD_REQUEST, "Bad Request"); + addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized"); + addStatusCodeMap(SC_FORBIDDEN, "Forbidden"); + addStatusCodeMap(SC_NOT_FOUND, "Not Found"); + addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error"); + addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented"); + addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway"); + addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable"); + addStatusCodeMap(SC_CONTINUE, "Continue"); + addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed"); + addStatusCodeMap(SC_CONFLICT, "Conflict"); + addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed"); + addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long"); + addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"); + // WebDav Status Codes + addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status"); + addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity"); + addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE, + "Insufficient Space On Resource"); + addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure"); + addStatusCodeMap(SC_LOCKED, "Locked"); + } + + + // --------------------------------------------------------- Public Methods + + + /** + * Returns the HTTP status text for the HTTP or WebDav status code + * specified by looking it up in the static mapping. This is a + * static function. + * + * @param nHttpStatusCode [IN] HTTP or WebDAV status code + * @return A string with a short descriptive phrase for the + * HTTP status code (e.g., "OK"). + */ + public static String getStatusText(int nHttpStatusCode) { + Integer intKey = Integer.valueOf(nHttpStatusCode); + + if (!mapStatusCodes.containsKey(intKey)) { + return ""; + } else { + return mapStatusCodes.get(intKey); + } + } + + + // -------------------------------------------------------- Private Methods + + + /** + * Adds a new status code -> status text mapping. This is a static + * method because the mapping is a static variable. + * + * @param nKey [IN] HTTP or WebDAV status code + * @param strVal [IN] HTTP status text + */ + private static void addStatusCodeMap(int nKey, String strVal) { + mapStatusCodes.put(Integer.valueOf(nKey), strVal); + } + +} + + diff --git a/source/ngasi/caimito/resource/CacheMgr.java b/source/ngasi/caimito/resource/CacheMgr.java old mode 100644 new mode 100755 index 4a24b71..ef09e73 --- a/source/ngasi/caimito/resource/CacheMgr.java +++ b/source/ngasi/caimito/resource/CacheMgr.java @@ -1,105 +1,105 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import java.nio.charset.Charset; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import ngasi.caimito.*; -import org.shaft.server.auth.*; -import tools.util.*; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Enumeration; -import java.io.UnsupportedEncodingException; -import org.shaft.server.utils.*; -import tools.util.*; -import java.util.Hashtable; - - -public class CacheMgr - { - int defwaitsleep = 1000; - long defwait = 1800; - - static CacheMgr defc = new CacheMgr(); - public static CacheMgr getCacheMgr(){ - return defc; - } - - public boolean waitFor(String n)throws Exception{ - boolean b = false; - for (int ct = 0; ct < defwait;ct++) - { - b = getBoolean(n); - // if (b == null) - // if (!tf)return tf; - if (!b) - return true; - Thread.sleep(defwaitsleep); - } - return false; - } - - - - public void put(String n)throws Exception{ - for (int ct = 0;ct < defwait;ct++){ - - if (get(n) == null) - break; - Thread.sleep(defwaitsleep); - - } - if (get(n) != null) - CaimitoException.throwException("unable_to_lock_cache"); - cache.put(n,true); - } - - -NameValuePairs cache = new NameValuePairs(); - - - - public Object get(String n)throws Exception{ - return cache.get(n); - } - public Object remove(String n)throws Exception{ - return cache.remove(n); - } - - public boolean getBoolean(String n)throws Exception{ - return cache.getBoolean(n); - } - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import java.nio.charset.Charset; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import ngasi.caimito.*; +import org.shaft.server.auth.*; +import tools.util.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Enumeration; +import java.io.UnsupportedEncodingException; +import org.shaft.server.utils.*; +import tools.util.*; +import java.util.Hashtable; + + +public class CacheMgr + { + int defwaitsleep = 1000; + long defwait = 1800; + + static CacheMgr defc = new CacheMgr(); + public static CacheMgr getCacheMgr(){ + return defc; + } + + public boolean waitFor(String n)throws Exception{ + boolean b = false; + for (int ct = 0; ct < defwait;ct++) + { + b = getBoolean(n); + // if (b == null) + // if (!tf)return tf; + if (!b) + return true; + Thread.sleep(defwaitsleep); + } + return false; + } + + + + public void put(String n)throws Exception{ + for (int ct = 0;ct < defwait;ct++){ + + if (get(n) == null) + break; + Thread.sleep(defwaitsleep); + + } + if (get(n) != null) + CaimitoException.throwException("unable_to_lock_cache"); + cache.put(n,true); + } + + +NameValuePairs cache = new NameValuePairs(); + + + + public Object get(String n)throws Exception{ + return cache.get(n); + } + public Object remove(String n)throws Exception{ + return cache.remove(n); + } + + public boolean getBoolean(String n)throws Exception{ + return cache.getBoolean(n); + } + } \ No newline at end of file diff --git a/source/ngasi/caimito/resource/CloudResourceObj.java b/source/ngasi/caimito/resource/CloudResourceObj.java old mode 100644 new mode 100755 index 941e42b..924d708 --- a/source/ngasi/caimito/resource/CloudResourceObj.java +++ b/source/ngasi/caimito/resource/CloudResourceObj.java @@ -1,120 +1,120 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import ngasi.caimito.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; -import java.util.Vector; -import java.io.InputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import tools.util.FileUtil; -public abstract class CloudResourceObj extends ResourceObj - { - public InputStream doGetInputStream()throws CaimitoException{ - try{ - String tf = CaimitoConfig.cachedir + path; - if (CaimitoConfig.cacheable){ - File ftf = new File(tf); - if (ftf.exists() && ftf.lastModified() == getLastModified()) - { - //("CACHE obje " + tf); - return new FileInputStream(tf); - } - //else - //(ftf.exists() + ":" + tf + ":" + new Date(ftf.lastModified()) + " NO CACHE obje " + new Date(getLastModified()) ); - - - } - //StringUtil.replaceSubstring(path,"/" , "_"); - CacheMgr cmr = CacheMgr.getCacheMgr(); - boolean rl = false; - if (cmr.getBoolean(tf)) - cmr.waitFor(tf); - else{ - - cmr.put(tf); - rl = true; - } - - try{ - - new File(tf).delete(); - int i = tf.lastIndexOf("/"); - new File (tf.substring(0,i)).mkdirs(); - - retrieveCloudFile(path,tf); - if (CaimitoConfig.cacheable) - new File(tf).setLastModified(getLastModified()); - }finally{ - if (rl) - cmr.remove(tf); - } - - return new FileInputStream(tf); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - return null; - - } - - public void doDelete()throws CaimitoException{ - try{ - - try{ - deleteCloudFile(); - }finally{ - String tf = CaimitoConfig.cachedir + path; - FileUtil.deleteAll(tf); - new File(tf).delete(); - } - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - public abstract void retrieveCloudFile(String path,String tf)throws CaimitoException; - public abstract void deleteCloudFile()throws CaimitoException; - -} - - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import ngasi.caimito.*; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.util.Vector; +import java.io.InputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import tools.util.FileUtil; +public abstract class CloudResourceObj extends ResourceObj + { + public InputStream doGetInputStream()throws CaimitoException{ + try{ + String tf = CaimitoConfig.cachedir + path; + if (CaimitoConfig.cacheable){ + File ftf = new File(tf); + if (ftf.exists() && ftf.lastModified() == getLastModified()) + { + //("CACHE obje " + tf); + return new FileInputStream(tf); + } + //else + //(ftf.exists() + ":" + tf + ":" + new Date(ftf.lastModified()) + " NO CACHE obje " + new Date(getLastModified()) ); + + + } + //StringUtil.replaceSubstring(path,"/" , "_"); + CacheMgr cmr = CacheMgr.getCacheMgr(); + boolean rl = false; + if (cmr.getBoolean(tf)) + cmr.waitFor(tf); + else{ + + cmr.put(tf); + rl = true; + } + + try{ + + new File(tf).delete(); + int i = tf.lastIndexOf("/"); + new File (tf.substring(0,i)).mkdirs(); + + retrieveCloudFile(path,tf); + if (CaimitoConfig.cacheable) + new File(tf).setLastModified(getLastModified()); + }finally{ + if (rl) + cmr.remove(tf); + } + + return new FileInputStream(tf); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + return null; + + } + + public void doDelete()throws CaimitoException{ + try{ + + try{ + deleteCloudFile(); + }finally{ + String tf = CaimitoConfig.cachedir + path; + FileUtil.deleteAll(tf); + new File(tf).delete(); + } + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + public abstract void retrieveCloudFile(String path,String tf)throws CaimitoException; + public abstract void deleteCloudFile()throws CaimitoException; + +} + + diff --git a/source/ngasi/caimito/resource/FileResourceObj.java b/source/ngasi/caimito/resource/FileResourceObj.java old mode 100644 new mode 100755 index 263f316..5ce51de --- a/source/ngasi/caimito/resource/FileResourceObj.java +++ b/source/ngasi/caimito/resource/FileResourceObj.java @@ -1,197 +1,197 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import ngasi.caimito.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; - -import tools.util.*; -import java.util.Vector; - -public class FileResourceObj extends ResourceObj - { - private static String home = "/usr/caimito/drive"; - protected static final int BUFFER_SIZE = 2048; - - static{ - try{ - home = CaimitoConfig.getConfig().getString("file.resource.dir"); - new File(home).mkdirs(); - }catch (Exception e){ - e.printStackTrace(); - } - } - - protected String getHome(){ - return home; - } - public InputStream doGetInputStream()throws CaimitoException{ - try{ - - return new FileInputStream(getHome() + path); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - return null; - - } - - - public void doWrite(InputStream dest)throws CaimitoException{ - try{ - if (dest.available() < 0)return; - FileOutputStream fout = new FileOutputStream(getHome() + path); - try{ - //(getHome() + path + " dO THE WRITE THING " + dest.available()); - StreamUtil.write(dest,fout); - - byte buffer[] = new byte[BUFFER_SIZE]; - int len = -1; - while (true) { - len = dest.read(buffer); - //(getHome() + path + " dO THE WRITE THING ********* " + len); - - if (len == -1) - break; - fout.write(buffer, 0, len); - } - - - }finally{ - fout.close(); - } - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - - public void doCopy(ResourceObj dest)throws CaimitoException{ - try{ - - if (new File(getHome() + path).isDirectory()) - new File(getHome() + dest.path).mkdirs(); - - FileUtil.copy(getHome() + path,getHome() + dest.path); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - - public void doMove(ResourceObj dest)throws CaimitoException{ - try{ - - // if (new File(getHome() + path).isDirectory()) - // new File(getHome() + dest.path).mkdirs(); - - new File(getHome() + path).renameTo(new File(getHome() + dest.path)); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - public boolean doExists()throws CaimitoException{ - - return new File(getHome() + path).exists(); - } - public void doDelete()throws CaimitoException{ - try{ - - FileUtil.deleteAll(getHome() + path); - new File(getHome() + path).delete(); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - } - - public void doMkdir()throws CaimitoException{ - try{ - - new File(getHome() + path).mkdirs(); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - } - - public long getLastModified()throws CaimitoException{ - return new File(getHome() + path).lastModified(); - } - - public boolean isDirectory()throws CaimitoException{ - return new File(getHome() + path).isDirectory(); - } - public long getContentLength()throws CaimitoException{ - //(getHome() + path + " GET THE LENGTH " + new File(getHome() + path).length() ); - return new File(getHome() + path).length(); - } - - public Vector doList()throws CaimitoException{ - Vector l = new Vector(); - - String[] dl = new File(getHome() + path).list(); - String ps = ""; - if (!path.endsWith("/")) - ps = "/"; - if (dl != null){ - FileResourceObj ro = null; - for (int ct = 0; ct < dl.length;ct++){ - ro = new FileResourceObj(); - ro.path = path + ps + dl[ct]; - //(getHome() + path + ps + " DO LISTER " + dl[ct]); - ro.user = user; - ro.listing = listing; - l.add(ro); - } - } - - return l; - - } - - -} - - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import ngasi.caimito.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; + +import tools.util.*; +import java.util.Vector; + +public class FileResourceObj extends ResourceObj + { + private static String home = "/usr/caimito/drive"; + protected static final int BUFFER_SIZE = 2048; + + static{ + try{ + home = CaimitoConfig.getConfig().getString("file.resource.dir"); + new File(home).mkdirs(); + }catch (Exception e){ + e.printStackTrace(); + } + } + + protected String getHome(){ + return home; + } + public InputStream doGetInputStream()throws CaimitoException{ + try{ + + return new FileInputStream(getHome() + path); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + return null; + + } + + + public void doWrite(InputStream dest)throws CaimitoException{ + try{ + if (dest.available() < 0)return; + FileOutputStream fout = new FileOutputStream(getHome() + path); + try{ + //(getHome() + path + " dO THE WRITE THING " + dest.available()); + StreamUtil.write(dest,fout); + + byte buffer[] = new byte[BUFFER_SIZE]; + int len = -1; + while (true) { + len = dest.read(buffer); + //(getHome() + path + " dO THE WRITE THING ********* " + len); + + if (len == -1) + break; + fout.write(buffer, 0, len); + } + + + }finally{ + fout.close(); + } + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + + public void doCopy(ResourceObj dest)throws CaimitoException{ + try{ + + if (new File(getHome() + path).isDirectory()) + new File(getHome() + dest.path).mkdirs(); + + FileUtil.copy(getHome() + path,getHome() + dest.path); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + + public void doMove(ResourceObj dest)throws CaimitoException{ + try{ + + // if (new File(getHome() + path).isDirectory()) + // new File(getHome() + dest.path).mkdirs(); + + new File(getHome() + path).renameTo(new File(getHome() + dest.path)); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + public boolean doExists()throws CaimitoException{ + + return new File(getHome() + path).exists(); + } + public void doDelete()throws CaimitoException{ + try{ + + FileUtil.deleteAll(getHome() + path); + new File(getHome() + path).delete(); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + } + + public void doMkdir()throws CaimitoException{ + try{ + + new File(getHome() + path).mkdirs(); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + } + + public long getLastModified()throws CaimitoException{ + return new File(getHome() + path).lastModified(); + } + + public boolean isDirectory()throws CaimitoException{ + return new File(getHome() + path).isDirectory(); + } + public long getContentLength()throws CaimitoException{ + //(getHome() + path + " GET THE LENGTH " + new File(getHome() + path).length() ); + return new File(getHome() + path).length(); + } + + public Vector doList()throws CaimitoException{ + Vector l = new Vector(); + + String[] dl = new File(getHome() + path).list(); + String ps = ""; + if (!path.endsWith("/")) + ps = "/"; + if (dl != null){ + FileResourceObj ro = null; + for (int ct = 0; ct < dl.length;ct++){ + ro = new FileResourceObj(); + ro.path = path + ps + dl[ct]; + //(getHome() + path + ps + " DO LISTER " + dl[ct]); + ro.user = user; + ro.listing = listing; + l.add(ro); + } + } + + return l; + + } + + +} + + diff --git a/source/ngasi/caimito/resource/OpenStackResourceObj.java b/source/ngasi/caimito/resource/OpenStackResourceObj.java old mode 100644 new mode 100755 index 1940aba..925c8bc --- a/source/ngasi/caimito/resource/OpenStackResourceObj.java +++ b/source/ngasi/caimito/resource/OpenStackResourceObj.java @@ -1,716 +1,787 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import ngasi.caimito.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; - -import tools.util.*; -import java.util.Vector; -import java.util.Hashtable; -import com.google.gson.*; -import java.lang.reflect.*; -import com.google.gson.reflect.*; -import java.util.List; -import java.text.*; -import java.util.Locale; -import java.util.Date; -import java.util.Enumeration; -import java.util.Map; -import java.io.ByteArrayInputStream; - -public class OpenStackResourceObj extends CloudResourceObj - { - protected static final int BUFFER_SIZE = 2048; - - - static DateFormat dfm = null; - - static long maxautint = 0; - - - - static{ - try{ - maxautint = CaimitoConfig.getConfig().getLong("cloud.max_auth_interval") * 60* 1000L; - }catch (Exception e){ - e.printStackTrace(); - } - try{ - - dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.obj.details.dateformat")); - }catch (Throwable e){ - e.printStackTrace(); - } - } - - - public void retrieveCloudFile(String path,String tf)throws CaimitoException{ - try{ - auth(); - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - - - HttpClientUtil.trustGetToFile(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path),tf); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - - } - - - public void doWrite(InputStream dest)throws CaimitoException{ - try{ - if (dest.available() < 0)return; - - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - if (contentType != null) - h.put("Content-Type",contentType); - - // if (contentLength > -1 ) - // h.put("Content-Length",String.valueOf(contentLength)); - - - String nv = null; - - - nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path),dest); - //(path + " put me " + nv); - - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - - - -public void doCopy(ResourceObj dest)throws CaimitoException - { - String fs = path; - String t = dest.path; -// if (!isDirectory()) -// return; - if ( !t.endsWith("/")) - t = t + "/"; - -// Vector flist = doList(); - - //----------- - - - auth(); - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - if (isDirectory()) - h.put("Content-Type","application/directory"); - //h.put("Content-Length","0"); - - String tp = path; - if (tp.endsWith("/")) - tp = tp.substring(0,tp.length() -1); - h.put("X_COPY_FROM",CaimitoConfig.getConfig().getString("cloud.store") + tp); - String tp2 = dest.path; - if (tp2.endsWith("/")) - tp2 = tp2.substring(0,tp2.length() -1); -try{ - - String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp2); - //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " ******************X_COPY_FROM 1111 " + nv + ":" + tp2); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - - if (!isDirectory()) - { - - return; - } - Vector flist = doList(); - - if (flist == null || flist.size() < 1) - return; - for(int i = 0 ; i < flist.size() ; i++) -{ - OpenStackResourceObj nf = (OpenStackResourceObj)flist.elementAt(i); - String nt = t; - boolean isd = false; - if (nf.isDirectory()) - { - nt = nt + nf.path.substring(path.length(),nf.path.length()); - OpenStackResourceObj dr = new OpenStackResourceObj(); - dr.path = nt; - dr.doMkdir(); - isd = true; - nf.doCopy(dr); - } - else - try - { - ResourceObj dr = new OpenStackResourceObj(); - dr.path = t + nf.getName(); - - nf.xCopy(dr); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - -} - - - } - - public void xCopy(ResourceObj dest)throws CaimitoException{ - try{ - - - auth(); - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - if (isDirectory()) - h.put("Content-Type","application/directory"); - //h.put("Content-Length","0"); - - String tp = path; - if (tp.endsWith("/")) - tp = tp.substring(0,tp.length() -1); - h.put("X_COPY_FROM",CaimitoConfig.getConfig().getString("cloud.store") + tp); - String tp2 = dest.path; - if (tp2.endsWith("/")) - tp2 = tp2.substring(0,tp2.length() -1); - - String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp2); - //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " ******************X_COPY_FROM " + nv + ":" + tp2); - - - - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - - public void doMove(ResourceObj dest)throws CaimitoException{ - try{ - - doCopy(dest); - doDelete(); - - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - } - } - - public boolean doExists()throws CaimitoException{ - if (path.equals("") || path.equals("/")) - return true; - - //("OEXISTST " + path); - init(); - return ex; - //return new File(root + path).exists(); - } - public void deleteCloudFile()throws CaimitoException{ - - -try{ - - auth(); - - - - if (isDirectory()) - { - - Vector flist = doList(); - - if (flist != null && flist.size() > 0) - for(int i = 0 ; i < flist.size() ; i++) -{ - OpenStackResourceObj nf = (OpenStackResourceObj)flist.elementAt(i); - nf.doDelete(); - /*String nt = t; - boolean isd = false; - if (nf.isDirectory()) - { - nt = nt + nf.path.substring(path.length(),nf.path.length()); - OpenStackResourceObj dr = new OpenStackResourceObj(); - dr.path = nt; - dr.doMkdir(); - isd = true; - nf.doCopy(dr); - } - else - try - { - ResourceObj dr = new OpenStackResourceObj(); - dr.path = t + nf.getName(); - - nf.xCopy(dr); - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - - }*/ - -} - } - - - - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - //( "DEO DELOET " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path) + "?format=json"); - - String nv = null; - String p2 = path; - if (p2.endsWith("/")) - p2 = p2.substring(0,p2.length() -1); - - nv = HttpClientUtil.trustDelete(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) ); - - - //("DELETE OF he2 " + nv); - - - - - - - - - - - - - - - - - - - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - } - - protected void init(){ - if (init)return; -try{ - init = true; - if (path.equals("") || path.equals("/")) - return ; - - auth(); - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - //("INIT 1 " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path) + "?format=json"); - - //String nv = null; - //try{ - String p2 = path; - if (p2.endsWith("/")) - p2 = p2.substring(0,p2.length() -1); - int nv = HttpClientUtil.trustHead(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) + "?format=json"); - if (nv == 404)return; - /*}catch (Exception e){ - try{ - - nv = HttpClientUtil.trustGet(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path + "/") + "?format=json"); - }catch (Exception e2){ - //("INIT 2 OPR.initerr " + e2.toString()); - return; - } - isd = true; - //("CLOUD STORE 2"); - }*/ - //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + path + "-->" + h + " THEY find file AUTHO2 " + nv); -// Last-Modified=Tue, 24 Apr 2012 00:05:15 GMT, Accept-Ranges=bytes, Content-Length=0, X-Trans-Id=txd7c65f16aa884af9a09266da2636daf5, Date=Tue, 24 Apr 2012 03:15:30 GMT, X-Auth-Token=AUTH_tke0c45f67d4fb47189ad41fc771b4b53f, Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1, Connection=keep-alive, Etag=d41d8cd98f00b204e9800998ecf8427e - // nv = nv.substring(1,nv.length() - 1); - //("DEVALUE OF he2 " + nv); - - - - NameValuePairs nvp = new NameValuePairs(h); - -/* if (StringUtil.isRealString(nv)) - { - if (nv.equals(".")) - isd = true; - else{ - - Gson gson = new Gson(); - OSRAttribute oa = gson.fromJson(nv, new TypeToken() {}.getType()); - cl = oa.bytes; - lm = oa.lastModified(); - ex = true; - if (oa.content_type != null && oa.content_type.equals("application/directory")) - isd = true; - - return; - } - }*/ - - //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + path + "-->" + h + " THEY find file AUTHO3 " + nvp); - - cl = nvp.getLong("Content-Length"); - lm = dfm.parse(nvp.getString("Last-Modified")).getTime(); - if (nvp.getString("Content-Type").equals("application/directory")) - isd = true; - - //init = true; - ex = true; -}catch (Throwable e){ - e.printStackTrace(); -} - - - } - - protected boolean ex = false; - protected boolean init = false; - protected boolean isd = false; - protected long lm = 0; - protected long cl = 0; - //protected OSRAttribute attributes = null; - - public void doMkdir()throws CaimitoException{ - try{ - - //new File(root + path).mkdirs(); - - - - auth(); - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - h.put("Content-Type","application/directory"); - String tp = path; - if (tp.endsWith("/")) - //tp = tp + "/"; - tp = tp.substring(0,tp.length() -1); - String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp); - //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " THEY AUTHOiniyt " + nv); - - - }catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - } - - public long getLastModified()throws CaimitoException{ - //return new File(root + path).lastModified(); - init(); - return lm; - } - - public boolean isDirectory()throws CaimitoException{ - if (path.equals("") || path.equals("/")) - return true; - init(); - return isd; - } - public long getContentLength()throws CaimitoException{ - init(); - return cl; - } - - protected static String X_Auth_Token = null; - protected static String X_Storage_Url = null; - protected static long authtime = 0; - void auth()throws CaimitoException{ - try{ - if (X_Auth_Token != null && X_Storage_Url != null && !((System.currentTimeMillis() - authtime) > maxautint))return; - Hashtable h = new Hashtable(); - h.put("X-Auth-User",CaimitoConfig.getConfig().getString("cloud.username")); - h.put("X-Auth-Key",CaimitoConfig.getConfig().getString("cloud.api.key_password")); - String nv = HttpClientUtil.trustGet(h,CaimitoConfig.getConfig().getString("cloud.url")); - //(h + " THEY AUTHO " + nv); - - - - X_Storage_Url = h.get("X-Storage-Url"); - X_Auth_Token = h.get("X-Auth-Token"); - authtime = System.currentTimeMillis(); - }catch (Throwable e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - } - - public Vector doList()throws CaimitoException{ - //doDelete(); - Vector l = new Vector(); - - try{ - - auth(); - - Hashtable h = new Hashtable(); - h.put("X-Auth-Token",X_Auth_Token); - String p2 = path; - if (p2.endsWith("/")) - p2 = p2.substring(0,p2.length() -1); - //p2 = p2 + "/"; - // ?prefix=photos/&delimiter=/ - boolean isroot = (p2.equals("/") || p2.equals("")); - String pars = "?delimiter=/"; - if (!isroot){ - String p2b = p2; - if (p2b.startsWith("/")) - p2b = p2b.substring(1,p2b.length()); - pars = pars + "&prefix=" + CaimitoUtil.urlEncode(p2b) + "/"; - } - //pars = ""; - //("***doList1 " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) + pars + " --> " + h + " h <-->nv "); -//+ CaimitoUtil.urlEncode(p2) - String nv = HttpClientUtil.trustGet(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + pars); - //("doList " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) + pars + " --> " + h + " h <-->nv " + nv); - if (nv == null || nv.length() < 1)return l; - ByteArrayInputStream bin = new ByteArrayInputStream(nv.getBytes()); - EZArrayList lblv = new EZArrayList(bin); - bin.close(); - String oa = null; - OpenStackResourceObj ro = null; - String dn = ""; - String ps = ""; - - if (!path.endsWith("/")) - ps = "/"; - for (int ct = 0;ct < lblv.size();ct++) - { - dn = lblv.elementAt(ct).toString(); - /*//("****************************DN= " + dn); - ro = new OpenStackResourceObj(); - - ro.path = "/" + dn; - ro.user = user; - ro.listing = listing; - ro.ex = true; - try{ - - ro.doDelete(); - }catch (Exception e){ - e.printStackTrace(); - }*/ - if (dn.equals(".")){ - //("****************************DN= " + dn); - - continue; - } - if (dn.endsWith("/")) - { - //("****************************DN= " + dn); - - continue; - - } - //(path + " OS LIST " + dn); - ro = new OpenStackResourceObj(); - - ro.path = "/" + dn; - ro.user = user; - ro.listing = listing; - ro.ex = true; - - - l.add(ro); - - - } - - - - /* Gson gson = new Gson(); - - List attrs = gson.fromJson(nv, new TypeToken>() {}.getType()); - - Vector lblv = new Vector(attrs); - OSRAttribute oa = null; - OpenStackResourceObj ro = null; - String ps = ""; - if (!path.endsWith("/")) - ps = "/"; - String dn = null; - for (int ct = 0;ct < lblv.size();ct++) - { - oa = lblv.elementAt(ct); - //(path + " OS LIST " + oa); - ro = new OpenStackResourceObj(); - dn = oa.name; - if (dn.endsWith("/")) - { - dn = dn.substring(0,dn.length() -1); - ro.isd = true; - - } - ro.path = path + ps + dn; - ro.user = user; - ro.listing = listing; - ro.cl = oa.bytes; - ro.init = true; - ro.ex = true; - ro.lm = oa.lastModified(); - l.add(ro); - - - }*/ -/* - String[] dl = new File(root + path).list(); - String ps = ""; - if (!path.endsWith("/")) - ps = "/"; - if (dl != null){ - FileResourceObj ro = null; - for (int ct = 0; ct < dl.length;ct++){ - ro = new FileResourceObj(); - ro.path = path + ps + dl[ct]; - ro.user = user; - ro.listing = listing; - l.add(ro); - } - }*/ - - }catch (Throwable e){ - e.printStackTrace(); - CaimitoException.throwException(e); - } - return l; - - } - - -} - -class OSRAttribute{ - - static DateFormat dfm = null; - static boolean rmdend = false; - static{ - try{ - //("DATE FORMAT " + CaimitoConfig.getConfig().getString("cloud.dateformat")); - if (CaimitoConfig.getConfig().getBoolean("cloud.date.remove.end")) - { - rmdend = true; - } - dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.dateformat")); - }catch (Throwable e){ - e.printStackTrace(); - } - } - - - String name = null; - String hash = null; - long bytes = 0; - String content_type = null; - String last_modified = null; - public long lastModified()throws Exception{ - if (rmdend) - { - String lm = last_modified; - int i = lm.lastIndexOf("."); - if (i > 0){ - lm = lm.substring(0,i); - return dfm.parse(lm).getTime(); - - } - } - return dfm.parse(last_modified).getTime(); - } - -} - -/*class OSRObjDetails{ - - static DateFormat dfm = null; - static boolean rmdend = false; - static{ - try{ - //("DATE FORMAT " + CaimitoConfig.getConfig().getString("cloud.dateformat")); - if (CaimitoConfig.getConfig().getBoolean("cloud.date.remove.end")) - { - rmdend = true; - } - dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.dateformat")); - }catch (Throwable e){ - e.printStackTrace(); - } - } - - - -Last-Modified=Tue, 24 Apr 2012 00:05:15 GMT, Accept-Ranges=bytes, Content-Length=0, X-Trans-Id=txd7c65f16aa884af9a09266da2636daf5, Date=Tue, 24 Apr 2012 03:15:30 GMT, X-Auth-Token=AUTH_tke0c45f67d4fb47189ad41fc771b4b53f, Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1, Connection=keep-alive, Etag=d41d8cd98f00b204e9800998ecf8427e - - - - public long lastModified()throws Exception{ - if (rmdend) - { - String lm = last_modified; - int i = lm.lastIndexOf("."); - if (i > 0){ - lm = lm.substring(0,i); - return dfm.parse(lm).getTime(); - - } - } - return dfm.parse(last_modified).getTime(); - } - -}*/ - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import ngasi.caimito.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; + +import tools.util.*; +import java.util.Vector; +import java.util.Hashtable; +import com.google.gson.*; +import java.lang.reflect.*; +import com.google.gson.reflect.*; +import java.util.List; +import java.text.*; +import java.util.Locale; +import java.util.Date; +import java.util.Enumeration; +import java.util.Map; +import java.io.ByteArrayInputStream; +import java.util.Iterator; + +public class OpenStackResourceObj extends CloudResourceObj + { + protected static final int BUFFER_SIZE = 2048; + + + static DateFormat dfm = null; + + static long maxautint = 0; + + + + static{ + try{ + maxautint = CaimitoConfig.getConfig().getLong("cloud.max_auth_interval") * 60* 1000L; + }catch (Exception e){ + e.printStackTrace(); + } + try{ + + dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.obj.details.dateformat")); + }catch (Throwable e){ + e.printStackTrace(); + } + } + + + public void retrieveCloudFile(String path,String tf)throws CaimitoException{ + try{ + auth(); + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + + + HttpClientUtil.trustGetToFile(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path),tf); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + + } + + + public void doWrite(InputStream dest)throws CaimitoException{ + try{ + if (dest.available() < 0)return; + + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + if (contentType != null) + h.put("Content-Type",contentType); + + // if (contentLength > -1 ) + // h.put("Content-Length",String.valueOf(contentLength)); + + + String nv = null; + + + nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path),dest); + //(path + " put me " + nv); + + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + + + +public void doCopy(ResourceObj dest)throws CaimitoException + { + String fs = path; + String t = dest.path; +// if (!isDirectory()) +// return; + if ( !t.endsWith("/")) + t = t + "/"; + +// Vector flist = doList(); + + //----------- + + + auth(); + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + if (isDirectory()) + h.put("Content-Type","application/directory"); + //h.put("Content-Length","0"); + + String tp = path; + if (tp.endsWith("/")) + tp = tp.substring(0,tp.length() -1); + h.put("X_COPY_FROM",CaimitoConfig.getConfig().getString("cloud.store") + tp); + String tp2 = dest.path; + if (tp2.endsWith("/")) + tp2 = tp2.substring(0,tp2.length() -1); +try{ + + String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp2); + //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " ******************X_COPY_FROM 1111 " + nv + ":" + tp2); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + + if (!isDirectory()) + { + + return; + } + Vector flist = doList(); + + if (flist == null || flist.size() < 1) + return; + for(int i = 0 ; i < flist.size() ; i++) +{ + OpenStackResourceObj nf = (OpenStackResourceObj)flist.elementAt(i); + String nt = t; + boolean isd = false; + if (nf.isDirectory()) + { + nt = nt + nf.path.substring(path.length(),nf.path.length()); + OpenStackResourceObj dr = new OpenStackResourceObj(); + dr.path = nt; + dr.doMkdir(); + isd = true; + nf.doCopy(dr); + } + else + try + { + ResourceObj dr = new OpenStackResourceObj(); + dr.path = t + nf.getName(); + + nf.xCopy(dr); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + +} + + + } + + public void xCopy(ResourceObj dest)throws CaimitoException{ + try{ + + + auth(); + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + if (isDirectory()) + h.put("Content-Type","application/directory"); + //h.put("Content-Length","0"); + + String tp = path; + if (tp.endsWith("/")) + tp = tp.substring(0,tp.length() -1); + h.put("X_COPY_FROM",CaimitoConfig.getConfig().getString("cloud.store") + tp); + String tp2 = dest.path; + if (tp2.endsWith("/")) + tp2 = tp2.substring(0,tp2.length() -1); + + String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp2); + //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " ******************X_COPY_FROM " + nv + ":" + tp2); + + + + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + + public void doMove(ResourceObj dest)throws CaimitoException{ + try{ + + doCopy(dest); + doDelete(); + + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + } + } + + public boolean doExists()throws CaimitoException{ + if (path.equals("") || path.equals("/")) + return true; + + //("OEXISTST " + path); + init(); + return ex; + //return new File(root + path).exists(); + } + public void deleteCloudFile()throws CaimitoException{ + + +try{ + + auth(); + + + + if (isDirectory()) + { + + Vector flist = doList(); + + if (flist != null && flist.size() > 0) + for(int i = 0 ; i < flist.size() ; i++) +{ + OpenStackResourceObj nf = (OpenStackResourceObj)flist.elementAt(i); + nf.doDelete(); + /*String nt = t; + boolean isd = false; + if (nf.isDirectory()) + { + nt = nt + nf.path.substring(path.length(),nf.path.length()); + OpenStackResourceObj dr = new OpenStackResourceObj(); + dr.path = nt; + dr.doMkdir(); + isd = true; + nf.doCopy(dr); + } + else + try + { + ResourceObj dr = new OpenStackResourceObj(); + dr.path = t + nf.getName(); + + nf.xCopy(dr); + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + + }*/ + +} + } + + + + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + //( "DEO DELOET " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path) + "?format=json"); + + String nv = null; + String p2 = path; + if (p2.endsWith("/")) + p2 = p2.substring(0,p2.length() -1); + + nv = HttpClientUtil.trustDelete(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) ); + + + //("DELETE OF he2 " + nv); + + + + + + + + + + + + + + + + + + + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + } + + protected void init(){ + if (init)return; +try{ + init = true; + if (path.equals("") || path.equals("/")) + return ; + + auth(); + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + //("INIT 1 " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path) + "?format=json"); + + //String nv = null; + //try{ + String p2 = path; + if (p2.endsWith("/")) + p2 = p2.substring(0,p2.length() -1); + int nv = HttpClientUtil.trustHead(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) + "?format=json"); + if (nv == 404)return; + /*}catch (Exception e){ + try{ + + nv = HttpClientUtil.trustGet(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(path + "/") + "?format=json"); + }catch (Exception e2){ + //("INIT 2 OPR.initerr " + e2.toString()); + return; + } + isd = true; + //("CLOUD STORE 2"); + }*/ + //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + path + "-->" + h + " THEY find file AUTHO2 " + nv); +// Last-Modified=Tue, 24 Apr 2012 00:05:15 GMT, Accept-Ranges=bytes, Content-Length=0, X-Trans-Id=txd7c65f16aa884af9a09266da2636daf5, Date=Tue, 24 Apr 2012 03:15:30 GMT, X-Auth-Token=AUTH_tke0c45f67d4fb47189ad41fc771b4b53f, Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1, Connection=keep-alive, Etag=d41d8cd98f00b204e9800998ecf8427e + // nv = nv.substring(1,nv.length() - 1); + //("DEVALUE OF he2 " + nv); + + + + NameValuePairs nvp = new NameValuePairs(h); + +/* if (StringUtil.isRealString(nv)) + { + if (nv.equals(".")) + isd = true; + else{ + + Gson gson = new Gson(); + OSRAttribute oa = gson.fromJson(nv, new TypeToken() {}.getType()); + cl = oa.bytes; + lm = oa.lastModified(); + ex = true; + if (oa.content_type != null && oa.content_type.equals("application/directory")) + isd = true; + + return; + } + }*/ + + //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + path + "-->" + h + " THEY find file AUTHO3 " + nvp); + + cl = nvp.getLong("Content-Length"); + lm = dfm.parse(nvp.getString("Last-Modified")).getTime(); + if (nvp.getString("Content-Type").equals("application/directory")) + isd = true; + + //init = true; + ex = true; +}catch (Throwable e){ + e.printStackTrace(); +} + + + } + + protected boolean ex = false; + protected boolean init = false; + protected boolean isd = false; + protected long lm = 0; + protected long cl = 0; + //protected OSRAttribute attributes = null; + + public void doMkdir()throws CaimitoException{ + try{ + + //new File(root + path).mkdirs(); + + + + auth(); + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + h.put("Content-Type","application/directory"); + String tp = path; + if (tp.endsWith("/")) + //tp = tp + "/"; + tp = tp.substring(0,tp.length() -1); + String nv = HttpClientUtil.trustPut(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp); + //(X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + tp + "-->" + h + " THEY AUTHOiniyt " + nv); + + + }catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + } + + public long getLastModified()throws CaimitoException{ + //return new File(root + path).lastModified(); + init(); + return lm; + } + + public boolean isDirectory()throws CaimitoException{ + if (path.equals("") || path.equals("/")) + return true; + init(); + return isd; + } + public long getContentLength()throws CaimitoException{ + init(); + return cl; + } + + protected static String X_Auth_Token = null; //"5bba5c21-3c8c-4f6b-8b17-9adb7c2ad4ea"; + protected static String X_Storage_Url = null; //"http://swift.rc.nectar.org.au:8888/v1/AUTH_793"; + protected static long authtime = 0; + void auth()throws CaimitoException{ + try{ + if (X_Auth_Token != null && X_Storage_Url != null && !((System.currentTimeMillis() - authtime) > maxautint))return; + Hashtable h = new Hashtable(); + h.put("X-Auth-User",CaimitoConfig.getConfig().getString("cloud.username")); + h.put("X-Auth-Key",CaimitoConfig.getConfig().getString("cloud.api.key_password")); + String curl = CaimitoConfig.getConfig().getString("cloud.url"); + if (curl.endsWith("/")) + curl = curl.substring(0,curl.length() - 1); + String nv = HttpClientUtil.trustGet(h,curl); + + X_Storage_Url = h.get("X-Storage-Url"); + X_Auth_Token = h.get("X-Auth-Token"); + if (X_Storage_Url == null || X_Auth_Token == null){ + + if (!curl.endsWith("/tokens")) + curl = curl + "/tokens"; + Hashtable pc = new Hashtable(); + pc.put("username",CaimitoConfig.getConfig().getString("cloud.username")); + pc.put("password",CaimitoConfig.getConfig().getString("cloud.api.key_password")); + + Hashtable> auh = new Hashtable>(); + auh.put("passwordCredentials",pc); + + Hashtable tl = new Hashtable(); + tl.put("auth",auh); + + h = new Hashtable(); + h.put("Content-type","application/json"); + + Gson gson = new Gson(); + String json = gson.toJson(tl); + ByteArrayInputStream dest = new ByteArrayInputStream(json.getBytes()); + + nv = HttpClientUtil.trustPost(h,curl,dest); + //Gson gson = new Gson(); + OSV2TokenResponse oa = gson.fromJson(nv, new TypeToken() {}.getType()); + Map eps = oa.getResponse(); + if (CaimitoConfig.getConfig().getString("cloud.endpoint.access").equals("internal")) + X_Storage_Url = eps.get("internalURL"); + else + X_Storage_Url = eps.get("publicURL"); + X_Auth_Token = oa.access.token.id; + if (X_Storage_Url == null || X_Auth_Token == null) + CaimitoException.throwException("unable_to_auth"); + + + } + authtime = System.currentTimeMillis(); + }catch (Throwable e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + } + + public Vector doList()throws CaimitoException{ + //doDelete(); + Vector l = new Vector(); + + try{ + + auth(); + + Hashtable h = new Hashtable(); + h.put("X-Auth-Token",X_Auth_Token); + String p2 = path; + if (p2.endsWith("/")) + p2 = p2.substring(0,p2.length() -1); + //p2 = p2 + "/"; + // ?prefix=photos/&delimiter=/ + boolean isroot = (p2.equals("/") || p2.equals("")); + String pars = "?delimiter=/"; + if (!isroot){ + String p2b = p2; + if (p2b.startsWith("/")) + p2b = p2b.substring(1,p2b.length()); + pars = pars + "&prefix=" + CaimitoUtil.urlEncode(p2b) + "/"; + } + //pars = ""; + //("***doList1 " + X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + CaimitoUtil.urlEncode(p2) + pars + " --> " + h + " h <-->nv "); +//+ CaimitoUtil.urlEncode(p2) + String nv = HttpClientUtil.trustGet(h,X_Storage_Url + "/" + CaimitoConfig.getConfig().getString("cloud.store") + pars); + + if (nv == null || nv.length() < 1)return l; + ByteArrayInputStream bin = new ByteArrayInputStream(nv.getBytes()); + EZArrayList lblv = new EZArrayList(bin); + bin.close(); + String oa = null; + OpenStackResourceObj ro = null; + String dn = ""; + String ps = ""; + + if (!path.endsWith("/")) + ps = "/"; + for (int ct = 0;ct < lblv.size();ct++) + { + dn = lblv.elementAt(ct).toString(); + /*//("****************************DN= " + dn); + ro = new OpenStackResourceObj(); + + ro.path = "/" + dn; + ro.user = user; + ro.listing = listing; + ro.ex = true; + try{ + + ro.doDelete(); + }catch (Exception e){ + e.printStackTrace(); + }*/ + if (dn.equals(".")){ + //("****************************DN= " + dn); + + continue; + } + if (dn.endsWith("/")) + { + //("****************************DN= " + dn); + + continue; + + } + //(path + " OS LIST " + dn); + ro = new OpenStackResourceObj(); + + ro.path = "/" + dn; + ro.user = user; + ro.listing = listing; + ro.ex = true; + + + l.add(ro); + + + } + + + + /* Gson gson = new Gson(); + + List attrs = gson.fromJson(nv, new TypeToken>() {}.getType()); + + Vector lblv = new Vector(attrs); + OSRAttribute oa = null; + OpenStackResourceObj ro = null; + String ps = ""; + if (!path.endsWith("/")) + ps = "/"; + String dn = null; + for (int ct = 0;ct < lblv.size();ct++) + { + oa = lblv.elementAt(ct); + //(path + " OS LIST " + oa); + ro = new OpenStackResourceObj(); + dn = oa.name; + if (dn.endsWith("/")) + { + dn = dn.substring(0,dn.length() -1); + ro.isd = true; + + } + ro.path = path + ps + dn; + ro.user = user; + ro.listing = listing; + ro.cl = oa.bytes; + ro.init = true; + ro.ex = true; + ro.lm = oa.lastModified(); + l.add(ro); + + + }*/ +/* + String[] dl = new File(root + path).list(); + String ps = ""; + if (!path.endsWith("/")) + ps = "/"; + if (dl != null){ + FileResourceObj ro = null; + for (int ct = 0; ct < dl.length;ct++){ + ro = new FileResourceObj(); + ro.path = path + ps + dl[ct]; + ro.user = user; + ro.listing = listing; + l.add(ro); + } + }*/ + + }catch (Throwable e){ + e.printStackTrace(); + CaimitoException.throwException(e); + } + return l; + + } + + +} + +class OSRAttribute{ + + static DateFormat dfm = null; + static boolean rmdend = false; + static{ + try{ + //("DATE FORMAT " + CaimitoConfig.getConfig().getString("cloud.dateformat")); + if (CaimitoConfig.getConfig().getBoolean("cloud.date.remove.end")) + { + rmdend = true; + } + dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.dateformat")); + }catch (Throwable e){ + e.printStackTrace(); + } + } + + + String name = null; + String hash = null; + long bytes = 0; + String content_type = null; + String last_modified = null; + public long lastModified()throws Exception{ + if (rmdend) + { + String lm = last_modified; + int i = lm.lastIndexOf("."); + if (i > 0){ + lm = lm.substring(0,i); + return dfm.parse(lm).getTime(); + + } + } + return dfm.parse(last_modified).getTime(); + } + +} +class OSV2TokenResponse { + public TokenObj access = null; + + //public Hashtable> access = null; + public Map getResponse(){ + Hashtable res = new Hashtable(); + Iterator en = access.serviceCatalog.iterator(); + //String n = null; + EndPoints v = null; + while(en.hasNext()){ + v = en.next(); + if (v.type.equals("object-store") && v.name.equals("swift")){ + Iterator> enp = v.endpoints.iterator(); + + if(enp.hasNext()) + return enp.next(); + } + } + return res; + } + +} + class TokenObj{ + public TokenObj2 token = null; + public List serviceCatalog = null; + + } + class EndPoints{ + public List> endpoints = null; + public String type = null; + public String name = null; + + } + class TokenObj2{ + public String id = null; + } +/*class OSRObjDetails{ + + static DateFormat dfm = null; + static boolean rmdend = false; + static{ + try{ + //("DATE FORMAT " + CaimitoConfig.getConfig().getString("cloud.dateformat")); + if (CaimitoConfig.getConfig().getBoolean("cloud.date.remove.end")) + { + rmdend = true; + } + dfm = new SimpleDateFormat(CaimitoConfig.getConfig().getString("cloud.dateformat")); + }catch (Throwable e){ + e.printStackTrace(); + } + } + + + +Last-Modified=Tue, 24 Apr 2012 00:05:15 GMT, Accept-Ranges=bytes, Content-Length=0, X-Trans-Id=txd7c65f16aa884af9a09266da2636daf5, Date=Tue, 24 Apr 2012 03:15:30 GMT, X-Auth-Token=AUTH_tke0c45f67d4fb47189ad41fc771b4b53f, Content-Type=application/x-www-form-urlencoded; charset=ISO-8859-1, Connection=keep-alive, Etag=d41d8cd98f00b204e9800998ecf8427e + + + + public long lastModified()throws Exception{ + if (rmdend) + { + String lm = last_modified; + int i = lm.lastIndexOf("."); + if (i > 0){ + lm = lm.substring(0,i); + return dfm.parse(lm).getTime(); + + } + } + return dfm.parse(last_modified).getTime(); + } + +}*/ + diff --git a/source/ngasi/caimito/resource/ResourceObj.java b/source/ngasi/caimito/resource/ResourceObj.java old mode 100644 new mode 100755 index 7d3e383..86933ad --- a/source/ngasi/caimito/resource/ResourceObj.java +++ b/source/ngasi/caimito/resource/ResourceObj.java @@ -1,186 +1,186 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import ngasi.caimito.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.TimeZone; -import java.util.Vector; -import java.io.InputStream; - -public abstract class ResourceObj - { - public String contentType = null; - public long contentLength = -1; - - public boolean listing = false; - public String user = null; - public String path = null; - String mt = null; - //public String root = null; - public String privilege = null; //r,w,a - - protected static final SimpleDateFormat format = - new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); - protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); - - static { - - format.setTimeZone(gmtZone); - - - } - - public boolean canRead()throws CaimitoException{ - return true; - } - public boolean canWrite()throws CaimitoException{ - return true; - } - - - public void checkRead()throws CaimitoException{ - if (!canRead()) - CaimitoException.throwException("forbidden"); - } - public void checkWrite()throws CaimitoException{ - if (!canWrite()) - CaimitoException.throwException("forbidden"); - - } - public ResourceObj getReadmeFile()throws CaimitoException{ - return null; - } - - public boolean listings()throws CaimitoException{ - checkRead(); - return listing; - } - - public String getName()throws CaimitoException{ - int i = path.lastIndexOf("/"); - if (i > -1 && path.length() > 1){ - return path.substring(i + 1,path.length()); - } - return null; - } - - public String getLastModifiedHttp() throws CaimitoException{ - synchronized (format) { - return format.format(new Date(getLastModified())); - } - } - - public long getCreation() throws CaimitoException{ - return getLastModified(); - } - - - public InputStream getInputStream()throws CaimitoException{ - checkRead(); - return doGetInputStream(); - } - - public Vector list()throws CaimitoException{ - checkRead(); - return doList(); - } - public boolean exists()throws CaimitoException{ - checkRead(); - return doExists(); - } - public void delete()throws CaimitoException{ - checkWrite(); - doDelete(); - } - - public void mkdir()throws CaimitoException{ - checkWrite(); - doMkdir(); - } - - public void write(InputStream inp)throws CaimitoException{ - checkWrite(); - doWrite(inp); - } - - - public void copy(ResourceObj dest)throws CaimitoException{ - checkRead(); - dest.checkWrite(); - doCopy(dest); - } - - public void move(ResourceObj dest)throws CaimitoException{ - checkWrite(); - dest.checkWrite(); - doMove(dest); - } - - public String getMimeType(){ - return mt; - } - public void setMimeType(String t){ - mt = t; - } - public String getETag()throws CaimitoException{ - - long contentLength = getContentLength(); - long lastModified = getLastModified(); - if ((contentLength >= 0) || (lastModified >= 0)) { - return "W/\"" + contentLength + "-" + - lastModified + "\""; - } - - return null; - } - public abstract void doMove(ResourceObj dest)throws CaimitoException; - - public abstract void doCopy(ResourceObj dest)throws CaimitoException; - public abstract void doWrite(InputStream dest)throws CaimitoException; - - public abstract InputStream doGetInputStream()throws CaimitoException; - public abstract long getContentLength()throws CaimitoException; - - public abstract Vector doList()throws CaimitoException; - public abstract boolean doExists()throws CaimitoException; - public abstract void doDelete()throws CaimitoException; - public abstract void doMkdir()throws CaimitoException; - - public abstract boolean isDirectory()throws CaimitoException; - - public abstract long getLastModified()throws CaimitoException; -} - - +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import ngasi.caimito.*; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.util.Vector; +import java.io.InputStream; + +public abstract class ResourceObj + { + public String contentType = null; + public long contentLength = -1; + + public boolean listing = false; + public String user = null; + public String path = null; + String mt = null; + //public String root = null; + public String privilege = null; //r,w,a + + protected static final SimpleDateFormat format = + new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); + protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); + + static { + + format.setTimeZone(gmtZone); + + + } + + public boolean canRead()throws CaimitoException{ + return true; + } + public boolean canWrite()throws CaimitoException{ + return true; + } + + + public void checkRead()throws CaimitoException{ + if (!canRead()) + CaimitoException.throwException("forbidden"); + } + public void checkWrite()throws CaimitoException{ + if (!canWrite()) + CaimitoException.throwException("forbidden"); + + } + public ResourceObj getReadmeFile()throws CaimitoException{ + return null; + } + + public boolean listings()throws CaimitoException{ + checkRead(); + return listing; + } + + public String getName()throws CaimitoException{ + int i = path.lastIndexOf("/"); + if (i > -1 && path.length() > 1){ + return path.substring(i + 1,path.length()); + } + return null; + } + + public String getLastModifiedHttp() throws CaimitoException{ + synchronized (format) { + return format.format(new Date(getLastModified())); + } + } + + public long getCreation() throws CaimitoException{ + return getLastModified(); + } + + + public InputStream getInputStream()throws CaimitoException{ + checkRead(); + return doGetInputStream(); + } + + public Vector list()throws CaimitoException{ + checkRead(); + return doList(); + } + public boolean exists()throws CaimitoException{ + checkRead(); + return doExists(); + } + public void delete()throws CaimitoException{ + checkWrite(); + doDelete(); + } + + public void mkdir()throws CaimitoException{ + checkWrite(); + doMkdir(); + } + + public void write(InputStream inp)throws CaimitoException{ + checkWrite(); + doWrite(inp); + } + + + public void copy(ResourceObj dest)throws CaimitoException{ + checkRead(); + dest.checkWrite(); + doCopy(dest); + } + + public void move(ResourceObj dest)throws CaimitoException{ + checkWrite(); + dest.checkWrite(); + doMove(dest); + } + + public String getMimeType(){ + return mt; + } + public void setMimeType(String t){ + mt = t; + } + public String getETag()throws CaimitoException{ + + long contentLength = getContentLength(); + long lastModified = getLastModified(); + if ((contentLength >= 0) || (lastModified >= 0)) { + return "W/\"" + contentLength + "-" + + lastModified + "\""; + } + + return null; + } + public abstract void doMove(ResourceObj dest)throws CaimitoException; + + public abstract void doCopy(ResourceObj dest)throws CaimitoException; + public abstract void doWrite(InputStream dest)throws CaimitoException; + + public abstract InputStream doGetInputStream()throws CaimitoException; + public abstract long getContentLength()throws CaimitoException; + + public abstract Vector doList()throws CaimitoException; + public abstract boolean doExists()throws CaimitoException; + public abstract void doDelete()throws CaimitoException; + public abstract void doMkdir()throws CaimitoException; + + public abstract boolean isDirectory()throws CaimitoException; + + public abstract long getLastModified()throws CaimitoException; +} + + diff --git a/source/ngasi/caimito/resource/ResourceStore.java b/source/ngasi/caimito/resource/ResourceStore.java old mode 100644 new mode 100755 index 6459ab8..09a30b8 --- a/source/ngasi/caimito/resource/ResourceStore.java +++ b/source/ngasi/caimito/resource/ResourceStore.java @@ -1,733 +1,733 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import java.nio.charset.Charset; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import ngasi.caimito.*; -import org.shaft.server.auth.*; -import tools.util.*; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Enumeration; -import java.io.UnsupportedEncodingException; -import org.shaft.server.utils.*; -import tools.util.*; -import java.sql.Connection; -import java.sql.ResultSet; - - -public class ResourceStore - { - public static int READ = 1; - public static int WRITE = 2; - protected static MessageDigest md5Helper = null; - - static{ - - try { - md5Helper = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - } - - public static ResourceObj lookup(String path, HttpServletRequest request) - throws CaimitoException { - String u = (String)request.getAttribute(CaimitoConfig.caimitouserreqobj); - if (u == null) - u = login(request); - return lookup(path,u); - } - - //public static ResourceObj lookup(String path, HttpServletRequest request, - // HttpServletResponse response) - //throws CaimitoException { - // - //} - protected static Connection getConnection()throws Exception{ - return DBConMgr.getConnection(ShaftRestConfig.datasourceName); - } - public static boolean isPublicPath(String path,CaimitoBooleanHolder l,String u) - throws CaimitoException { - try{ - if (path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")) - return true; - if (path.startsWith("/")) - path = path.substring(1,path.length()); - if (path.endsWith("/")) - path = path.substring(0,path.length() -1); - - return pathMatch(path,"publicpaths",l,u); - }catch (Exception e){ - //e.printStackTrace(); - //(path + " isPublicPath.error " + e.toString()); - } - return false; - } - - - public static boolean pathMatch(String path,String table,CaimitoBooleanHolder l,String u)throws Exception - { - - if (doPathMatch(path,table,l,u)) - return true; - - int i = path.lastIndexOf("/"); - while (i > 0) - { - path = path.substring(0,i); - if (doPathMatch(path,table,l,u)) - return true; - i = path.lastIndexOf("/"); - } - if (i < 0) - return doPathMatch(path,table,l,u); - - return false; - } - - protected static boolean doPathMatch(String path,String table,CaimitoBooleanHolder l,String u)throws Exception - { - SPQueryAndUpdate spq = new SPQueryAndUpdate(getConnection()); - try{ - String sql = "SELECT path,shaftowner,listing from " + CaimitoConfig.shaftapp + "_" + table + " where path = ?"; - spq.setTemplate(sql); - spq.addVariable(path); - ResultSet res = spq.query(); - //(path + " doPathMatch 1 " + table); - - if (res.next()){ - String su = res.getString(2); - NameValuePairs nvp = getUserPriv(su); - //(path + ":" + res.getString(2) + " doPathMatch 2 " + nvp); - if (nvp == null || nvp.size() < 1) - return false; - if (!path.startsWith(nvp.getString("path") + "/") && !(path + "/").startsWith(nvp.getString("path") + "/")) - return false; - if (u == null || (!su.equals(u) && !UserMgr.getUserMgr(CaimitoConfig.shaftapp).isAdminOrOwnerOf(CaimitoConfig.shaftapp,u,su))) - l.value = (res.getBoolean(3)); - else - l.value = CaimitoConfig.getConfig().getBoolean("resource.dir.listing"); - return true; - } - } - - finally{ - if (spq != null)spq.close(); - } - return false; - } - - - - protected static NameValuePairs getUserPrivFromDB(String u)throws Exception - { - try{ - - SPQueryAndUpdate spq = new SPQueryAndUpdate(getConnection()); - try{ - String sql = "SELECT * from " + CaimitoConfig.shaftapp + "_pathprivileges where resourceuser = ? AND shaftowner = ?"; - - // username = UserMgr. (CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,username); - // if (username == null) - // break; - boolean isadmin = false; - if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,u)){ -sql = "SELECT * from " + CaimitoConfig.shaftapp + "_pathprivileges where resourceuser = ?"; - - isadmin = true; - } - - spq.setTemplate(sql); - spq.addVariable(u); - if (!isadmin) - spq.addVariable(UserMgr.getUserMgr(CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,u)); - - return spq.getHash(); - } - - finally{ - if (spq != null)spq.close(); - } - }catch (Exception e){ - //(u + " getUserPrivFromDB " + e.toString() + ":" ); - e.printStackTrace(); - - } - return null; - } - - protected static NameValuePairs getUserPriv(String u)throws Exception - { - try{ - - - - NameValuePairs nvp = getUserPrivFromDB(u); - if (nvp == null || nvp.size() < 1) - return nvp; - String path2 = null; - String username = u; - while (true){ - username = UserMgr.getUserMgr(CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,username); - if (username == null) - break; - if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,username)) - break; - if (path2 == null)path2 = ""; - path2 = getUserPrivFromDB(username).getString("path") + "/" + path2; - } - if (path2 != null){ - path2 = path2 + "/" + nvp.getString("path"); - //("ZEPATH@ A " + path2); - - path2 = CaimitoUtil.normalize(path2); - //("ZEPATH@ " + path2); - - nvp.put("path",path2); - - - } - return nvp; - - - - }catch (Exception e){ - //(u + " getUserPriv.error " + e.toString() + ":" ); - e.printStackTrace(); - - } - return null; - } - - - public static ResourceObj lookup(String path, HttpServletRequest request, - HttpServletResponse response,int action) - throws CaimitoException { - String u = null; - //ResourceObj ro = null; - - if (path.equals("/") || path.equals("")) - { - if (CaimitoConfig.protectedRoot) - { - - u = login(request,response); - if (u == null)return null; - } - } - - if (u == null) - { - u = (String)request.getAttribute(CaimitoConfig.caimitouserreqobj); - if (u == null) - u = login(request); - } -try{ - //(action + ":" + path + " THE USER IS " + u); - if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,u)) - return lookup(path,u); - - - if (action == READ){ - - CaimitoBooleanHolder l = new CaimitoBooleanHolder(); - if (isPublicPath(path,l,u)){ - - ResourceObj ro = lookup(path,u); - if (ro != null) - ro.listing = l.value; - return ro; - } - } - if (u == null){ - - u = login(request,response); - if (u == null)return null; - } - - - - NameValuePairs nvp = getUserPriv(u); - //(u + " PRIVILEGE GO " + nvp); - if (nvp == null || nvp.size() < 1) - { - response.sendError(HttpServletResponse.SC_FORBIDDEN); - return null; - } - - - if (action == WRITE && (nvp.getInt("privilege") != WRITE ||(path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")))) - { - //(u + " PRIVILEGE GO 2 " + nvp); - - response.sendError(HttpServletResponse.SC_FORBIDDEN); - return null; - } - if (!path.startsWith("/" + nvp.getString("path") + "/") && !(path + "/").startsWith("/" + nvp.getString("path") + "/")) - { - //(path + " PRIVILEGE GO 3 " + nvp); - - response.sendError(HttpServletResponse.SC_FORBIDDEN); - return null; - }else lookup("/" + nvp.getString("path") + "/",u) .mkdir(); - return lookup(path,u); - - }catch (Exception e){ - - e.printStackTrace(); - return null; - } - /*//(u + " WOWWW SD 1 " + CaimitoConfig.resource + ":" + path); - if (CaimitoConfig.resource.equals("file")){ - ro = new FileResourceObj(); - } - //(u + " WOWWW SD 2 " + ro); - - if (ro != null){ - ro.user = u; - ro.path = path; - } - return ro;*/ -// return null; - } - - - public static ResourceObj lookup(String path,String u) - throws CaimitoException { - ResourceObj ro = null; - //if (u == null) - // Thread.dumpStack(); - //(u + " WOWWW SD 1 " + CaimitoConfig.resource + ":" + path); - if (path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")) - { - if (!path.startsWith("/" + CaimitoConfig.shaftapp + "/public/")) - path = "/" + CaimitoConfig.shaftapp + "/public/" + path.substring(CaimitoConfig.shaftapp.length() + 1,path.length()); - ro = new ShaftResourceObj(); - - } - else if (CaimitoConfig.resource.equals("file")){ - ro = new FileResourceObj(); - } - else if (CaimitoConfig.resource.equals("openstack")){ - //(u + " WOWWW SD 2 " + CaimitoConfig.resource + ":" + path); - - ro = new OpenStackResourceObj(); - } - //(u + " WOWWW SD 2 " + ro); - - if (ro != null){ - ro.user = u; - ro.path = path; - ro.listing = CaimitoConfig.getConfig().getBoolean("resource.dir.listing"); - } - return ro; - } - - - public static String login( HttpServletRequest request ) - throws CaimitoException { - return login(request,null); - } - - - - - protected static String getDigest(String username, String realmName)throws CaimitoException { - -try{ - - return UserMgr.getUserMgr(CaimitoConfig.shaftapp).getMD5Digest(CaimitoConfig.shaftapp,username); - /*String digestValue = username + ":" + realmName + ":" - + UserMgr. (CaimitoConfig.shaftapp).getPasswd(CaimitoConfig.shaftapp,username); - - byte[] valueBytes = null; - valueBytes = digestValue.getBytes(Charset.defaultCharset()); - - byte[] digest = null; - synchronized(md5Helper) { - digest = md5Helper.digest(valueBytes); - } - - return md5Encode(digest);*/ -}catch (Exception e){ - e.printStackTrace(); - CaimitoException.throwException(e); -} -return null; - } - - - - protected static String authenticate(NameValuePairs nvp) throws CaimitoException{ - // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" - -String username = (String)nvp.get("username"); - String clientDigest = (String)nvp.get("response"); - String nonce = (String)nvp.get("nonce"); - String nc = (String)nvp.get("nc"); -String cnonce = (String)nvp.get("cnonce"); -String qop = (String)nvp.get("qop"); -String realm = (String)nvp.get("realm"); - String a2 = nvp.get("method") + ":" + nvp.get("uri"); - - byte[] buffer; - synchronized (md5Helper) { - buffer = md5Helper.digest(a2.getBytes(Charset.defaultCharset())); - } - String md5a2 = md5Encode(buffer); - - - String md5a1 = getDigest(username, realm); - if (md5a1 == null) - return null; - String serverDigestValue; - if (qop == null) { - serverDigestValue = md5a1 + ":" + nonce + ":" + md5a2; - } else { - serverDigestValue = md5a1 + ":" + nonce + ":" + nc + ":" + - cnonce + ":" + qop + ":" + md5a2; - } - - byte[] valueBytes = null; - // try { - valueBytes = serverDigestValue.getBytes(Charset.defaultCharset()); - // } catch (UnsupportedEncodingException uee) { - // log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); - // throw new IllegalArgumentException(uee.getMessage()); - //} - - String serverDigest = null; - // Bugzilla 32137 - synchronized(md5Helper) { - serverDigest = md5Encode(md5Helper.digest(valueBytes)); - } - - /*if (log.isDebugEnabled()) { - log.debug("Digest : " + clientDigest + " Username:" + username - + " ClientSigest:" + clientDigest + " nonce:" + nonce - + " nc:" + nc + " cnonce:" + cnonce + " qop:" + qop - + " realm:" + realm + "md5a2:" + md5a2 - + " Server digest:" + serverDigest); - }*/ - - if (serverDigest.equals(clientDigest)) { - return (username); - } - - return null; - } - - - - public static String login( HttpServletRequest request, - HttpServletResponse response - ) - throws CaimitoException { - String ua = request.getHeader("user-agent"); - //if (ua.equals("Microsoft Data Access Internet Publishing Provider DAV") || ua.indexOf("davfs2") > -1 || CaimitoConfig.getConfig().getString(ua + ".auth").equals("basic")) - // return basicLogin(request,response); - //("USER AGAENT " + ua); - if (CaimitoConfig.getConfig().getString(ua + ".auth").equals("digest")) - return digestLogin(request,response); - return basicLogin(request,response); - } - - - public static String digestLogin( HttpServletRequest request, - HttpServletResponse response - ) - throws CaimitoException { - NameValuePairs nvp = new NameValuePairs(); - String hr = request.getHeader("Authorization"); - if (hr != null) - { - if (hr.startsWith("Digest ")) - { -try{ - //hr = SharedMethods.replaceSubstring(hr,"Digest ",""); - hr = hr.trim(); - hr = hr.substring(7,hr.length()); - // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" - NameValuePairs nvp1 = NameValuePairs.toNameValuePair(hr,"=",","); - Enumeration nvp1e = nvp1.keys(); - String k = null; - String v = null; - while(nvp1e.hasMoreElements()) - { - k = (String)nvp1e.nextElement(); - v = nvp1.getString(k); - nvp.put(k.trim(),StringUtil.getTrimmedValue(v.trim())); - } - nvp.put("method",request.getMethod()); - //(nvp + " DIGEST 1 " + hr); - //byte[] b = Base64Decoder.fromBase64(hr.getBytes()); - //String auth = new String(b); - //String name = auth.substring(0,auth.indexOf(":")); - //String pass = auth.substring(auth.indexOf(":") + 1,auth.length()); - - - String name = authenticate(nvp); - //if (UserMgr. (CaimitoConfig.shaftapp).login(CaimitoConfig.shaftapp,name,pass) != null) - if (name != null) - { - //request.setPrincipal(RealmEngine.get().getPrincipal(name)); - //request.setAuthType("BASIC"); - // request.getSession() - request.setAttribute(CaimitoConfig.caimitouserreqobj,name); - return name; - } - }catch (Exception e){ - e.printStackTrace(); - //return null; - } - } - } - if (response != null) - sendError(request,response,nvp.getString("nonce").trim()); - return null; - - } - - - - protected static boolean isNonceStale(String nonce){ - - - int i = nonce.indexOf(":"); - if (i < 0 || (i + 1) == nonce.length()) { - return true; - } - long nonceTime; - try { - nonceTime = Long.parseLong(nonce.substring(0, i)); - } catch (NumberFormatException nfe) { - return true; - } - //String md5clientIpTimeKey = nonce.substring(i + 1); - long currentTime = System.currentTimeMillis(); - //(currentTime + ":" + nonceTime + ":" + CaimitoConfig.nonceValidity + ":IS NONE STALE ##########################"); - if ((currentTime - nonceTime) > CaimitoConfig.nonceValidity) { - return true; - } - else return false; -// return true; - - } - - - public static void sendError( HttpServletRequest request,HttpServletResponse response,String nonce1) - { - try - { - String nonce = generateNonce(request); - boolean isn = isNonceStale(nonce1); - //(nonce1 + " IS NOT STALE " + isn); - setAuthenticateHeader(request, response, nonce, - isn); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - } - catch (Exception e) - { - e.printStackTrace(); - - } - } - - - protected static String generateNonce(HttpServletRequest request) { - - long currentTime = System.currentTimeMillis(); - - - String ipTimeKey = - request.getRemoteAddr() + ":" + currentTime + ":" + randomGenerate(); - - byte[] buffer; - synchronized (md5Helper) { - buffer = md5Helper.digest( - ipTimeKey.getBytes(Charset.defaultCharset())); - } - - return currentTime + ":" + md5Encode(buffer); - } - - private static final char[] hexadecimal = - {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f'}; - - - // --------------------------------------------------------- Public Methods - - - /** - * Encodes the 128 bit (16 bytes) MD5 into a 32 character String. - * - * @param binaryData Array containing the digest - * @return Encoded MD5, or null if encoding failed - */ - protected static String md5Encode( byte[] binaryData ) { - - if (binaryData.length != 16) - return null; - - char[] buffer = new char[32]; - - for (int i=0; i<16; i++) { - int low = binaryData[i] & 0x0f; - int high = (binaryData[i] & 0xf0) >> 4; - buffer[i*2] = hexadecimal[high]; - buffer[i*2 + 1] = hexadecimal[low]; - } - - return new String(buffer); - - } - - - - protected static String randomGenerate(){ - - String tid = AlphaNumeric.generateRandomAlphNumeric(CaimitoConfig.digestLength); -String dig = CaimitoConfig.defaultDigest; -if (dig != null) -tid = Crypto.digest(tid,dig); - return tid; - } - - protected static final String AUTH_HEADER_NAME = "WWW-Authenticate"; - protected static final String QOP = "auth"; - - protected static void setAuthenticateHeader(HttpServletRequest request, - HttpServletResponse response, - String nonce, - boolean isNonceStale) { - - // Get the realm name - String realmName = CaimitoConfig.SecurityRealmName; - - String authenticateHeader; - if (isNonceStale) { - authenticateHeader = "Digest realm=\"" + realmName + "\", " + - "qop=\"" + QOP + "\", nonce=\"" + nonce + "\", " + "opaque=\"" + - randomGenerate() + "\", stale=true"; - } else { - authenticateHeader = "Digest realm=\"" + realmName + "\", " + - "qop=\"" + QOP + "\", nonce=\"" + nonce + "\", " + "opaque=\"" + - randomGenerate() + "\""; - } - - -//("authenticateHeader 1 " + authenticateHeader); - response.setHeader(AUTH_HEADER_NAME, authenticateHeader); - - } - - - - public static String basicLogin( HttpServletRequest request, - HttpServletResponse response - ) - throws CaimitoException { - - String hr = request.getHeader("Authorization"); - if (hr != null) - { - if (hr.startsWith("Basic ")) - { - - //hr = SharedMethods.replaceSubstring(hr,"Digest ",""); - hr = hr.trim(); - hr = hr.substring(6,hr.length()); - // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" - NameValuePairs nvp = NameValuePairs.toNameValuePair(hr,"=",","); - //(nvp + " BASIC 1 " + hr); - byte[] b = Base64Decoder.fromBase64(hr.getBytes()); - String auth = new String(b); - String name = auth.substring(0,auth.indexOf(":")); - String pass = auth.substring(auth.indexOf(":") + 1,auth.length()); - try{ - - if (UserMgr.getUserMgr(CaimitoConfig.shaftapp).login(CaimitoConfig.shaftapp,name,pass,false) != null) - { - //request.setPrincipal(RealmEngine.get().getPrincipal(name)); - //request.setAuthType("BASIC"); - // request.getSession() - request.setAttribute(CaimitoConfig.caimitouserreqobj,name); - return name; - } - }catch (Exception e){ - e.printStackTrace(); - //return null; - } - } - } - if (response != null) - sendBasicError(request,response); - return null; - - } - - public static void sendBasicError( HttpServletRequest request,HttpServletResponse response) - { - try - { - /* - if (DeploymentDescriptor.isSecureLoginRequired() && !request.getScheme().equalsIgnoreCase("https")) - { - String fau = request.getTrimmedRequestURI(); - if (request.getQueryString() != null) - fau = fau + "?" + request.getQueryString(); - if (!fau.startsWith("/")) - fau = "/" + fau; - response.sendRedirect("https://" + request.getServerName() + fau); - return; - }*/ - response.setHeader("Content-Type","text/html"); - String rn = CaimitoConfig.SecurityRealmName; - response.setHeader("WWW-Authenticate","Basic realm=\"" + rn + "\""); - response.sendError(401); - } - catch (Exception e) - { - e.printStackTrace(); - - } - } -} - -class CaimitoBooleanHolder{ - public boolean value = false; -} +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import java.nio.charset.Charset; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import ngasi.caimito.*; +import org.shaft.server.auth.*; +import tools.util.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Enumeration; +import java.io.UnsupportedEncodingException; +import org.shaft.server.utils.*; +import tools.util.*; +import java.sql.Connection; +import java.sql.ResultSet; + + +public class ResourceStore + { + public static int READ = 1; + public static int WRITE = 2; + protected static MessageDigest md5Helper = null; + + static{ + + try { + md5Helper = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + + public static ResourceObj lookup(String path, HttpServletRequest request) + throws CaimitoException { + String u = (String)request.getAttribute(CaimitoConfig.caimitouserreqobj); + if (u == null) + u = login(request); + return lookup(path,u); + } + + //public static ResourceObj lookup(String path, HttpServletRequest request, + // HttpServletResponse response) + //throws CaimitoException { + // + //} + protected static Connection getConnection()throws Exception{ + return DBConMgr.getConnection(ShaftRestConfig.datasourceName); + } + public static boolean isPublicPath(String path,CaimitoBooleanHolder l,String u) + throws CaimitoException { + try{ + if (path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")) + return true; + if (path.startsWith("/")) + path = path.substring(1,path.length()); + if (path.endsWith("/")) + path = path.substring(0,path.length() -1); + + return pathMatch(path,"publicpaths",l,u); + }catch (Exception e){ + //e.printStackTrace(); + //(path + " isPublicPath.error " + e.toString()); + } + return false; + } + + + public static boolean pathMatch(String path,String table,CaimitoBooleanHolder l,String u)throws Exception + { + + if (doPathMatch(path,table,l,u)) + return true; + + int i = path.lastIndexOf("/"); + while (i > 0) + { + path = path.substring(0,i); + if (doPathMatch(path,table,l,u)) + return true; + i = path.lastIndexOf("/"); + } + if (i < 0) + return doPathMatch(path,table,l,u); + + return false; + } + + protected static boolean doPathMatch(String path,String table,CaimitoBooleanHolder l,String u)throws Exception + { + SPQueryAndUpdate spq = new SPQueryAndUpdate(getConnection()); + try{ + String sql = "SELECT path,shaftowner,listing from " + CaimitoConfig.shaftapp + "_" + table + " where path = ?"; + spq.setTemplate(sql); + spq.addVariable(path); + ResultSet res = spq.query(); + //(path + " doPathMatch 1 " + table); + + if (res.next()){ + String su = res.getString(2); + NameValuePairs nvp = getUserPriv(su); + //(path + ":" + res.getString(2) + " doPathMatch 2 " + nvp); + if (nvp == null || nvp.size() < 1) + return false; + if (!path.startsWith(nvp.getString("path") + "/") && !(path + "/").startsWith(nvp.getString("path") + "/")) + return false; + if (u == null || (!su.equals(u) && !UserMgr.getUserMgr(CaimitoConfig.shaftapp).isAdminOrOwnerOf(CaimitoConfig.shaftapp,u,su))) + l.value = (res.getBoolean(3)); + else + l.value = CaimitoConfig.getConfig().getBoolean("resource.dir.listing"); + return true; + } + } + + finally{ + if (spq != null)spq.close(); + } + return false; + } + + + + protected static NameValuePairs getUserPrivFromDB(String u)throws Exception + { + try{ + + SPQueryAndUpdate spq = new SPQueryAndUpdate(getConnection()); + try{ + String sql = "SELECT * from " + CaimitoConfig.shaftapp + "_pathprivileges where resourceuser = ? AND shaftowner = ?"; + + // username = UserMgr. (CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,username); + // if (username == null) + // break; + boolean isadmin = false; + if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,u)){ +sql = "SELECT * from " + CaimitoConfig.shaftapp + "_pathprivileges where resourceuser = ?"; + + isadmin = true; + } + + spq.setTemplate(sql); + spq.addVariable(u); + if (!isadmin) + spq.addVariable(UserMgr.getUserMgr(CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,u)); + + return spq.getHash(); + } + + finally{ + if (spq != null)spq.close(); + } + }catch (Exception e){ + //(u + " getUserPrivFromDB " + e.toString() + ":" ); + e.printStackTrace(); + + } + return null; + } + + protected static NameValuePairs getUserPriv(String u)throws Exception + { + try{ + + + + NameValuePairs nvp = getUserPrivFromDB(u); + if (nvp == null || nvp.size() < 1) + return nvp; + String path2 = null; + String username = u; + while (true){ + username = UserMgr.getUserMgr(CaimitoConfig.shaftapp).getOwner(CaimitoConfig.shaftapp,username); + if (username == null) + break; + if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,username)) + break; + if (path2 == null)path2 = ""; + path2 = getUserPrivFromDB(username).getString("path") + "/" + path2; + } + if (path2 != null){ + path2 = path2 + "/" + nvp.getString("path"); + //("ZEPATH@ A " + path2); + + path2 = CaimitoUtil.normalize(path2); + //("ZEPATH@ " + path2); + + nvp.put("path",path2); + + + } + return nvp; + + + + }catch (Exception e){ + //(u + " getUserPriv.error " + e.toString() + ":" ); + e.printStackTrace(); + + } + return null; + } + + + public static ResourceObj lookup(String path, HttpServletRequest request, + HttpServletResponse response,int action) + throws CaimitoException { + String u = null; + //ResourceObj ro = null; + + if (path.equals("/") || path.equals("")) + { + if (CaimitoConfig.protectedRoot) + { + + u = login(request,response); + if (u == null)return null; + } + } + + if (u == null) + { + u = (String)request.getAttribute(CaimitoConfig.caimitouserreqobj); + if (u == null) + u = login(request); + } +try{ + //(action + ":" + path + " THE USER IS " + u); + if (RealmMgr.getRealmMgr(CaimitoConfig.shaftapp).isAdmin(CaimitoConfig.shaftapp,u)) + return lookup(path,u); + + + if (action == READ){ + + CaimitoBooleanHolder l = new CaimitoBooleanHolder(); + if (isPublicPath(path,l,u)){ + + ResourceObj ro = lookup(path,u); + if (ro != null) + ro.listing = l.value; + return ro; + } + } + if (u == null){ + + u = login(request,response); + if (u == null)return null; + } + + + + NameValuePairs nvp = getUserPriv(u); + //(u + " PRIVILEGE GO " + nvp); + if (nvp == null || nvp.size() < 1) + { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return null; + } + + + if (action == WRITE && (nvp.getInt("privilege") != WRITE ||(path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")))) + { + //(u + " PRIVILEGE GO 2 " + nvp); + + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return null; + } + if (!path.startsWith("/" + nvp.getString("path") + "/") && !(path + "/").startsWith("/" + nvp.getString("path") + "/")) + { + //(path + " PRIVILEGE GO 3 " + nvp); + + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return null; + }else lookup("/" + nvp.getString("path") + "/",u) .mkdir(); + return lookup(path,u); + + }catch (Exception e){ + + e.printStackTrace(); + return null; + } + /*//(u + " WOWWW SD 1 " + CaimitoConfig.resource + ":" + path); + if (CaimitoConfig.resource.equals("file")){ + ro = new FileResourceObj(); + } + //(u + " WOWWW SD 2 " + ro); + + if (ro != null){ + ro.user = u; + ro.path = path; + } + return ro;*/ +// return null; + } + + + public static ResourceObj lookup(String path,String u) + throws CaimitoException { + ResourceObj ro = null; + //if (u == null) + // Thread.dumpStack(); + //(u + " WOWWW SD 1 " + CaimitoConfig.resource + ":" + path); + if (path.startsWith("/" + CaimitoConfig.shaftapp + "/") || path.equals("/favicon.ico")) + { + if (!path.startsWith("/" + CaimitoConfig.shaftapp + "/public/")) + path = "/" + CaimitoConfig.shaftapp + "/public/" + path.substring(CaimitoConfig.shaftapp.length() + 1,path.length()); + ro = new ShaftResourceObj(); + + } + else if (CaimitoConfig.resource.equals("file")){ + ro = new FileResourceObj(); + } + else if (CaimitoConfig.resource.equals("openstack")){ + //(u + " WOWWW SD 2 " + CaimitoConfig.resource + ":" + path); + + ro = new OpenStackResourceObj(); + } + //(u + " WOWWW SD 2 " + ro); + + if (ro != null){ + ro.user = u; + ro.path = path; + ro.listing = CaimitoConfig.getConfig().getBoolean("resource.dir.listing"); + } + return ro; + } + + + public static String login( HttpServletRequest request ) + throws CaimitoException { + return login(request,null); + } + + + + + protected static String getDigest(String username, String realmName)throws CaimitoException { + +try{ + + return UserMgr.getUserMgr(CaimitoConfig.shaftapp).getMD5Digest(CaimitoConfig.shaftapp,username); + /*String digestValue = username + ":" + realmName + ":" + + UserMgr. (CaimitoConfig.shaftapp).getPasswd(CaimitoConfig.shaftapp,username); + + byte[] valueBytes = null; + valueBytes = digestValue.getBytes(Charset.defaultCharset()); + + byte[] digest = null; + synchronized(md5Helper) { + digest = md5Helper.digest(valueBytes); + } + + return md5Encode(digest);*/ +}catch (Exception e){ + e.printStackTrace(); + CaimitoException.throwException(e); +} +return null; + } + + + + protected static String authenticate(NameValuePairs nvp) throws CaimitoException{ + // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" + +String username = (String)nvp.get("username"); + String clientDigest = (String)nvp.get("response"); + String nonce = (String)nvp.get("nonce"); + String nc = (String)nvp.get("nc"); +String cnonce = (String)nvp.get("cnonce"); +String qop = (String)nvp.get("qop"); +String realm = (String)nvp.get("realm"); + String a2 = nvp.get("method") + ":" + nvp.get("uri"); + + byte[] buffer; + synchronized (md5Helper) { + buffer = md5Helper.digest(a2.getBytes(Charset.defaultCharset())); + } + String md5a2 = md5Encode(buffer); + + + String md5a1 = getDigest(username, realm); + if (md5a1 == null) + return null; + String serverDigestValue; + if (qop == null) { + serverDigestValue = md5a1 + ":" + nonce + ":" + md5a2; + } else { + serverDigestValue = md5a1 + ":" + nonce + ":" + nc + ":" + + cnonce + ":" + qop + ":" + md5a2; + } + + byte[] valueBytes = null; + // try { + valueBytes = serverDigestValue.getBytes(Charset.defaultCharset()); + // } catch (UnsupportedEncodingException uee) { + // log.error("Illegal digestEncoding: " + getDigestEncoding(), uee); + // throw new IllegalArgumentException(uee.getMessage()); + //} + + String serverDigest = null; + // Bugzilla 32137 + synchronized(md5Helper) { + serverDigest = md5Encode(md5Helper.digest(valueBytes)); + } + + /*if (log.isDebugEnabled()) { + log.debug("Digest : " + clientDigest + " Username:" + username + + " ClientSigest:" + clientDigest + " nonce:" + nonce + + " nc:" + nc + " cnonce:" + cnonce + " qop:" + qop + + " realm:" + realm + "md5a2:" + md5a2 + + " Server digest:" + serverDigest); + }*/ + + if (serverDigest.equals(clientDigest)) { + return (username); + } + + return null; + } + + + + public static String login( HttpServletRequest request, + HttpServletResponse response + ) + throws CaimitoException { + String ua = request.getHeader("user-agent"); + //if (ua.equals("Microsoft Data Access Internet Publishing Provider DAV") || ua.indexOf("davfs2") > -1 || CaimitoConfig.getConfig().getString(ua + ".auth").equals("basic")) + // return basicLogin(request,response); + //("USER AGAENT " + ua); + if (CaimitoConfig.getConfig().getString(ua + ".auth").equals("digest")) + return digestLogin(request,response); + return basicLogin(request,response); + } + + + public static String digestLogin( HttpServletRequest request, + HttpServletResponse response + ) + throws CaimitoException { + NameValuePairs nvp = new NameValuePairs(); + String hr = request.getHeader("Authorization"); + if (hr != null) + { + if (hr.startsWith("Digest ")) + { +try{ + //hr = SharedMethods.replaceSubstring(hr,"Digest ",""); + hr = hr.trim(); + hr = hr.substring(7,hr.length()); + // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" + NameValuePairs nvp1 = NameValuePairs.toNameValuePair(hr,"=",","); + Enumeration nvp1e = nvp1.keys(); + String k = null; + String v = null; + while(nvp1e.hasMoreElements()) + { + k = (String)nvp1e.nextElement(); + v = nvp1.getString(k); + nvp.put(k.trim(),StringUtil.getTrimmedValue(v.trim())); + } + nvp.put("method",request.getMethod()); + //(nvp + " DIGEST 1 " + hr); + //byte[] b = Base64Decoder.fromBase64(hr.getBytes()); + //String auth = new String(b); + //String name = auth.substring(0,auth.indexOf(":")); + //String pass = auth.substring(auth.indexOf(":") + 1,auth.length()); + + + String name = authenticate(nvp); + //if (UserMgr. (CaimitoConfig.shaftapp).login(CaimitoConfig.shaftapp,name,pass) != null) + if (name != null) + { + //request.setPrincipal(RealmEngine.get().getPrincipal(name)); + //request.setAuthType("BASIC"); + // request.getSession() + request.setAttribute(CaimitoConfig.caimitouserreqobj,name); + return name; + } + }catch (Exception e){ + e.printStackTrace(); + //return null; + } + } + } + if (response != null) + sendError(request,response,nvp.getString("nonce").trim()); + return null; + + } + + + + protected static boolean isNonceStale(String nonce){ + + + int i = nonce.indexOf(":"); + if (i < 0 || (i + 1) == nonce.length()) { + return true; + } + long nonceTime; + try { + nonceTime = Long.parseLong(nonce.substring(0, i)); + } catch (NumberFormatException nfe) { + return true; + } + //String md5clientIpTimeKey = nonce.substring(i + 1); + long currentTime = System.currentTimeMillis(); + //(currentTime + ":" + nonceTime + ":" + CaimitoConfig.nonceValidity + ":IS NONE STALE ##########################"); + if ((currentTime - nonceTime) > CaimitoConfig.nonceValidity) { + return true; + } + else return false; +// return true; + + } + + + public static void sendError( HttpServletRequest request,HttpServletResponse response,String nonce1) + { + try + { + String nonce = generateNonce(request); + boolean isn = isNonceStale(nonce1); + //(nonce1 + " IS NOT STALE " + isn); + setAuthenticateHeader(request, response, nonce, + isn); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + } + catch (Exception e) + { + e.printStackTrace(); + + } + } + + + protected static String generateNonce(HttpServletRequest request) { + + long currentTime = System.currentTimeMillis(); + + + String ipTimeKey = + request.getRemoteAddr() + ":" + currentTime + ":" + randomGenerate(); + + byte[] buffer; + synchronized (md5Helper) { + buffer = md5Helper.digest( + ipTimeKey.getBytes(Charset.defaultCharset())); + } + + return currentTime + ":" + md5Encode(buffer); + } + + private static final char[] hexadecimal = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f'}; + + + // --------------------------------------------------------- Public Methods + + + /** + * Encodes the 128 bit (16 bytes) MD5 into a 32 character String. + * + * @param binaryData Array containing the digest + * @return Encoded MD5, or null if encoding failed + */ + protected static String md5Encode( byte[] binaryData ) { + + if (binaryData.length != 16) + return null; + + char[] buffer = new char[32]; + + for (int i=0; i<16; i++) { + int low = binaryData[i] & 0x0f; + int high = (binaryData[i] & 0xf0) >> 4; + buffer[i*2] = hexadecimal[high]; + buffer[i*2 + 1] = hexadecimal[low]; + } + + return new String(buffer); + + } + + + + protected static String randomGenerate(){ + + String tid = AlphaNumeric.generateRandomAlphNumeric(CaimitoConfig.digestLength); +String dig = CaimitoConfig.defaultDigest; +if (dig != null) +tid = Crypto.digest(tid,dig); + return tid; + } + + protected static final String AUTH_HEADER_NAME = "WWW-Authenticate"; + protected static final String QOP = "auth"; + + protected static void setAuthenticateHeader(HttpServletRequest request, + HttpServletResponse response, + String nonce, + boolean isNonceStale) { + + // Get the realm name + String realmName = CaimitoConfig.SecurityRealmName; + + String authenticateHeader; + if (isNonceStale) { + authenticateHeader = "Digest realm=\"" + realmName + "\", " + + "qop=\"" + QOP + "\", nonce=\"" + nonce + "\", " + "opaque=\"" + + randomGenerate() + "\", stale=true"; + } else { + authenticateHeader = "Digest realm=\"" + realmName + "\", " + + "qop=\"" + QOP + "\", nonce=\"" + nonce + "\", " + "opaque=\"" + + randomGenerate() + "\""; + } + + +//("authenticateHeader 1 " + authenticateHeader); + response.setHeader(AUTH_HEADER_NAME, authenticateHeader); + + } + + + + public static String basicLogin( HttpServletRequest request, + HttpServletResponse response + ) + throws CaimitoException { + + String hr = request.getHeader("Authorization"); + if (hr != null) + { + if (hr.startsWith("Basic ")) + { + + //hr = SharedMethods.replaceSubstring(hr,"Digest ",""); + hr = hr.trim(); + hr = hr.substring(6,hr.length()); + // username="caimitoadmin", realm="Caimito", nonce="", uri="/", response="2fb52dbbcb7b25fd33840eac3027e9c5" + NameValuePairs nvp = NameValuePairs.toNameValuePair(hr,"=",","); + //(nvp + " BASIC 1 " + hr); + byte[] b = Base64Decoder.fromBase64(hr.getBytes()); + String auth = new String(b); + String name = auth.substring(0,auth.indexOf(":")); + String pass = auth.substring(auth.indexOf(":") + 1,auth.length()); + try{ + + if (UserMgr.getUserMgr(CaimitoConfig.shaftapp).login(CaimitoConfig.shaftapp,name,pass,false) != null) + { + //request.setPrincipal(RealmEngine.get().getPrincipal(name)); + //request.setAuthType("BASIC"); + // request.getSession() + request.setAttribute(CaimitoConfig.caimitouserreqobj,name); + return name; + } + }catch (Exception e){ + e.printStackTrace(); + //return null; + } + } + } + if (response != null) + sendBasicError(request,response); + return null; + + } + + public static void sendBasicError( HttpServletRequest request,HttpServletResponse response) + { + try + { + /* + if (DeploymentDescriptor.isSecureLoginRequired() && !request.getScheme().equalsIgnoreCase("https")) + { + String fau = request.getTrimmedRequestURI(); + if (request.getQueryString() != null) + fau = fau + "?" + request.getQueryString(); + if (!fau.startsWith("/")) + fau = "/" + fau; + response.sendRedirect("https://" + request.getServerName() + fau); + return; + }*/ + response.setHeader("Content-Type","text/html"); + String rn = CaimitoConfig.SecurityRealmName; + response.setHeader("WWW-Authenticate","Basic realm=\"" + rn + "\""); + response.sendError(401); + } + catch (Exception e) + { + e.printStackTrace(); + + } + } +} + +class CaimitoBooleanHolder{ + public boolean value = false; +} diff --git a/source/ngasi/caimito/resource/ShaftAppMgr.java b/source/ngasi/caimito/resource/ShaftAppMgr.java old mode 100644 new mode 100755 index 4fdb118..8e196ab --- a/source/ngasi/caimito/resource/ShaftAppMgr.java +++ b/source/ngasi/caimito/resource/ShaftAppMgr.java @@ -1,53 +1,53 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import java.nio.charset.Charset; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import ngasi.caimito.*; -import org.shaft.server.auth.*; -import tools.util.*; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Enumeration; -import java.io.UnsupportedEncodingException; -import org.shaft.server.utils.*; -import tools.util.*; -import java.sql.Connection; -import java.sql.ResultSet; - - -public class ShaftAppMgr - { +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import java.nio.charset.Charset; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import ngasi.caimito.*; +import org.shaft.server.auth.*; +import tools.util.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Enumeration; +import java.io.UnsupportedEncodingException; +import org.shaft.server.utils.*; +import tools.util.*; +import java.sql.Connection; +import java.sql.ResultSet; + + +public class ShaftAppMgr + { } \ No newline at end of file diff --git a/source/ngasi/caimito/resource/ShaftResourceObj.java b/source/ngasi/caimito/resource/ShaftResourceObj.java old mode 100644 new mode 100755 index 61905d4..03955bf --- a/source/ngasi/caimito/resource/ShaftResourceObj.java +++ b/source/ngasi/caimito/resource/ShaftResourceObj.java @@ -1,58 +1,58 @@ -/* - Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. -Apache Software License 2.0 -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - - 3. The names of the authors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase -OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - - - - -package ngasi.caimito.resource; -import java.nio.charset.Charset; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import ngasi.caimito.*; -import org.shaft.server.auth.*; -import tools.util.*; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Enumeration; -import java.io.UnsupportedEncodingException; -import org.shaft.server.utils.*; -import tools.util.*; -import java.sql.Connection; -import java.sql.ResultSet; - - -public class ShaftResourceObj extends FileResourceObj - { - - - protected String getHome(){ - return CaimitoConfig.caimitoroot; - } +/* + Copyright (c) 2011-2012, the Caimito project (http://caimito.ngasi.com/). All rights reserved. +Apache Software License 2.0 +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WebAppShowCase +OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + + + + +package ngasi.caimito.resource; +import java.nio.charset.Charset; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import ngasi.caimito.*; +import org.shaft.server.auth.*; +import tools.util.*; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Enumeration; +import java.io.UnsupportedEncodingException; +import org.shaft.server.utils.*; +import tools.util.*; +import java.sql.Connection; +import java.sql.ResultSet; + + +public class ShaftResourceObj extends FileResourceObj + { + + + protected String getHome(){ + return CaimitoConfig.caimitoroot; + } } \ No newline at end of file diff --git a/webapps/RELEASE-NOTES.txt b/webapps/RELEASE-NOTES.txt old mode 100644 new mode 100755 index f6f9391..a811a2b --- a/webapps/RELEASE-NOTES.txt +++ b/webapps/RELEASE-NOTES.txt @@ -1,228 +1,228 @@ -================================================================================ - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -================================================================================ - -$Id: RELEASE-NOTES 1189163 2011-10-26 12:19:26Z kkolinko $ - - - Apache Tomcat Version 7.0.27 - Release Notes - - -========= -CONTENTS: -========= - -* Dependency Changes -* API Stability -* JNI Based Applications -* Bundled APIs -* Web application reloading and static fields in shared libraries -* Tomcat on Linux -* Enabling SSI and CGI Support -* Security manager URLs -* Symlinking static resources -* Viewing the Tomcat Change Log -* Cryptographic software notice -* When all else fails - - -=================== -Dependency Changes: -=================== -Tomcat 7.0 is designed to run on Java SE 6 and later. - -In addition, Tomcat 7.0 uses the Eclipse JDT Java compiler for -compiling JSP pages. This means you no longer need to have the complete -Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment -(JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the -binary Tomcat distributions. Tomcat can also be configured to use the -compiler from the JDK to compile JSPs, or any other Java compiler supported -by Apache Ant. - - -============== -API Stability: -============== -The public interfaces for the following classes are fixed and will not be -changed at all during the remaining lifetime of the 7.x series: -- javax/**/* - -The public interfaces for the following classes may be added to in order to -resolve bugs and/or add new features. No existing interface will be removed or -changed although it may be deprecated. -- org/apache/catalina/* -- org/apache/catalina/comet/* - -Note: As Tomcat 7 matures, the above list will be added to. The list is not - considered complete at this time. - -The remaining classes are considered part of the Tomcat internals and may change -without notice between point releases. - - -======================= -JNI Based Applications: -======================= -Applications that require native libraries must ensure that the libraries have -been loaded prior to use. Typically, this is done with a call like: - - static { - System.loadLibrary("path-to-library-file"); - } - -in some class. However, the application must also ensure that the library is -not loaded more than once. If the above code were placed in a class inside -the web application (i.e. under /WEB-INF/classes or /WEB-INF/lib), and the -application were reloaded, the loadLibrary() call would be attempted a second -time. - -To avoid this problem, place classes that load native libraries outside of the -web application, and ensure that the loadLibrary() call is executed only once -during the lifetime of a particular JVM. - - -============= -Bundled APIs: -============= -A standard installation of Tomcat 7.0 makes all of the following APIs available -for use by web applications (by placing them in "lib"): -* annotations-api.jar (Annotations package) -* catalina.jar (Tomcat Catalina implementation) -* catalina-ant.jar (Tomcat Catalina Ant tasks) -* catalina-ha.jar (High availability package) -* catalina-tribes.jar (Group communication) -* ecj-3.7.2.jar (Eclipse JDT Java compiler) -* el-api.jar (EL 2.2 API) -* jasper.jar (Jasper 2 Compiler and Runtime) -* jasper-el.jar (Jasper 2 EL implementation) -* jsp-api.jar (JSP 2.2 API) -* servlet-api.jar (Servlet 3.0 API) -* tomcat-api.jar (Interfaces shared by Catalina and Jasper) -* tomcat-coyote.jar (Tomcat connectors and utility classes) -* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP) - -You can make additional APIs available to all of your web applications by -putting unpacked classes into a "classes" directory (not created by default), -or by placing them in JAR files in the "lib" directory. - -To override the XML parser implementation or interfaces, use the endorsed -mechanism of the JVM. The default configuration defines JARs located in -"endorsed" as endorsed. - - -================================================================ -Web application reloading and static fields in shared libraries: -================================================================ -Some shared libraries (many are part of the JDK) keep references to objects -instantiated by the web application. To avoid class loading related problems -(ClassCastExceptions, messages indicating that the classloader -is stopped, etc.), the shared libraries state should be reinitialized. - -Something which might help is to avoid putting classes which would be -referenced by a shared static field in the web application classloader, -and putting them in the shared classloader instead (JARs should be put in the -"lib" folder, and classes should be put in the "classes" folder). - - -================ -Tomcat on Linux: -================ -GLIBC 2.2 / Linux 2.4 users should define an environment variable: -export LD_ASSUME_KERNEL=2.2.5 - -Redhat Linux 9.0 users should use the following setting to avoid -stability problems: -export LD_ASSUME_KERNEL=2.4.1 - -There are some Linux bugs reported against the NIO sendfile behavior, make sure you -have a JDK that is up to date, or disable sendfile behavior in the Connector.
-6427312: (fc) FileChannel.transferTo() throws IOException "system call interrupted"
-5103988: (fc) FileChannel.transferTo should return -1 for EAGAIN instead throws IOException
-6253145: (fc) FileChannel.transferTo on Linux fails when going beyond 2GB boundary
-6470086: (fc) FileChannel.transferTo(2147483647, 1, channel) cause "Value too large" exception
- - -============================= -Enabling SSI and CGI Support: -============================= -Because of the security risks associated with CGI and SSI available -to web applications, these features are disabled by default. - -To enable and configure CGI support, please see the cgi-howto.html page. - -To enable and configue SSI support, please see the ssi-howto.html page. - - -====================== -Security manager URLs: -====================== -In order to grant security permissions to JARs located inside the -web application repository, use URLs of of the following format -in your policy file: - -file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar - - -============================ -Symlinking static resources: -============================ -By default, Unix symlinks will not work when used in a web application to link -resources located outside the web application root directory. - -This behavior is optional, and the "allowLinking" flag may be used to disable -the check. - - -============================== -Viewing the Tomcat Change Log: -============================== -See changelog.html in this directory. - - -============================= -Cryptographic software notice -============================= -This distribution includes cryptographic software. The country in -which you currently reside may have restrictions on the import, -possession, use, and/or re-export to another country, of -encryption software. BEFORE using any encryption software, please -check your country's laws, regulations and policies concerning the -import, possession, or use, and re-export of encryption software, to -see if this is permitted. See for more -information. - -The U.S. Government Department of Commerce, Bureau of Industry and -Security (BIS), has classified this software as Export Commodity -Control Number (ECCN) 5D002.C.1, which includes information security -software using or performing cryptographic functions with asymmetric -algorithms. The form and manner of this Apache Software Foundation -distribution makes it eligible for export under the License Exception -ENC Technology Software Unrestricted (TSU) exception (see the BIS -Export Administration Regulations, Section 740.13) for both object -code and source code. - -The following provides more details on the included cryptographic -software: - - Tomcat includes code designed to work with JSSE - - Tomcat includes code designed to work with OpenSSL - - -==================== -When all else fails: -==================== -See the FAQ -http://tomcat.apache.org/faq/ +================================================================================ + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +================================================================================ + +$Id: RELEASE-NOTES 1189163 2011-10-26 12:19:26Z kkolinko $ + + + Apache Tomcat Version 7.0.27 + Release Notes + + +========= +CONTENTS: +========= + +* Dependency Changes +* API Stability +* JNI Based Applications +* Bundled APIs +* Web application reloading and static fields in shared libraries +* Tomcat on Linux +* Enabling SSI and CGI Support +* Security manager URLs +* Symlinking static resources +* Viewing the Tomcat Change Log +* Cryptographic software notice +* When all else fails + + +=================== +Dependency Changes: +=================== +Tomcat 7.0 is designed to run on Java SE 6 and later. + +In addition, Tomcat 7.0 uses the Eclipse JDT Java compiler for +compiling JSP pages. This means you no longer need to have the complete +Java Development Kit (JDK) to run Tomcat, but a Java Runtime Environment +(JRE) is sufficient. The Eclipse JDT Java compiler is bundled with the +binary Tomcat distributions. Tomcat can also be configured to use the +compiler from the JDK to compile JSPs, or any other Java compiler supported +by Apache Ant. + + +============== +API Stability: +============== +The public interfaces for the following classes are fixed and will not be +changed at all during the remaining lifetime of the 7.x series: +- javax/**/* + +The public interfaces for the following classes may be added to in order to +resolve bugs and/or add new features. No existing interface will be removed or +changed although it may be deprecated. +- org/apache/catalina/* +- org/apache/catalina/comet/* + +Note: As Tomcat 7 matures, the above list will be added to. The list is not + considered complete at this time. + +The remaining classes are considered part of the Tomcat internals and may change +without notice between point releases. + + +======================= +JNI Based Applications: +======================= +Applications that require native libraries must ensure that the libraries have +been loaded prior to use. Typically, this is done with a call like: + + static { + System.loadLibrary("path-to-library-file"); + } + +in some class. However, the application must also ensure that the library is +not loaded more than once. If the above code were placed in a class inside +the web application (i.e. under /WEB-INF/classes or /WEB-INF/lib), and the +application were reloaded, the loadLibrary() call would be attempted a second +time. + +To avoid this problem, place classes that load native libraries outside of the +web application, and ensure that the loadLibrary() call is executed only once +during the lifetime of a particular JVM. + + +============= +Bundled APIs: +============= +A standard installation of Tomcat 7.0 makes all of the following APIs available +for use by web applications (by placing them in "lib"): +* annotations-api.jar (Annotations package) +* catalina.jar (Tomcat Catalina implementation) +* catalina-ant.jar (Tomcat Catalina Ant tasks) +* catalina-ha.jar (High availability package) +* catalina-tribes.jar (Group communication) +* ecj-3.7.2.jar (Eclipse JDT Java compiler) +* el-api.jar (EL 2.2 API) +* jasper.jar (Jasper 2 Compiler and Runtime) +* jasper-el.jar (Jasper 2 EL implementation) +* jsp-api.jar (JSP 2.2 API) +* servlet-api.jar (Servlet 3.0 API) +* tomcat-api.jar (Interfaces shared by Catalina and Jasper) +* tomcat-coyote.jar (Tomcat connectors and utility classes) +* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP) + +You can make additional APIs available to all of your web applications by +putting unpacked classes into a "classes" directory (not created by default), +or by placing them in JAR files in the "lib" directory. + +To override the XML parser implementation or interfaces, use the endorsed +mechanism of the JVM. The default configuration defines JARs located in +"endorsed" as endorsed. + + +================================================================ +Web application reloading and static fields in shared libraries: +================================================================ +Some shared libraries (many are part of the JDK) keep references to objects +instantiated by the web application. To avoid class loading related problems +(ClassCastExceptions, messages indicating that the classloader +is stopped, etc.), the shared libraries state should be reinitialized. + +Something which might help is to avoid putting classes which would be +referenced by a shared static field in the web application classloader, +and putting them in the shared classloader instead (JARs should be put in the +"lib" folder, and classes should be put in the "classes" folder). + + +================ +Tomcat on Linux: +================ +GLIBC 2.2 / Linux 2.4 users should define an environment variable: +export LD_ASSUME_KERNEL=2.2.5 + +Redhat Linux 9.0 users should use the following setting to avoid +stability problems: +export LD_ASSUME_KERNEL=2.4.1 + +There are some Linux bugs reported against the NIO sendfile behavior, make sure you +have a JDK that is up to date, or disable sendfile behavior in the Connector.
+6427312: (fc) FileChannel.transferTo() throws IOException "system call interrupted"
+5103988: (fc) FileChannel.transferTo should return -1 for EAGAIN instead throws IOException
+6253145: (fc) FileChannel.transferTo on Linux fails when going beyond 2GB boundary
+6470086: (fc) FileChannel.transferTo(2147483647, 1, channel) cause "Value too large" exception
+ + +============================= +Enabling SSI and CGI Support: +============================= +Because of the security risks associated with CGI and SSI available +to web applications, these features are disabled by default. + +To enable and configure CGI support, please see the cgi-howto.html page. + +To enable and configue SSI support, please see the ssi-howto.html page. + + +====================== +Security manager URLs: +====================== +In order to grant security permissions to JARs located inside the +web application repository, use URLs of of the following format +in your policy file: + +file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar + + +============================ +Symlinking static resources: +============================ +By default, Unix symlinks will not work when used in a web application to link +resources located outside the web application root directory. + +This behavior is optional, and the "allowLinking" flag may be used to disable +the check. + + +============================== +Viewing the Tomcat Change Log: +============================== +See changelog.html in this directory. + + +============================= +Cryptographic software notice +============================= +This distribution includes cryptographic software. The country in +which you currently reside may have restrictions on the import, +possession, use, and/or re-export to another country, of +encryption software. BEFORE using any encryption software, please +check your country's laws, regulations and policies concerning the +import, possession, or use, and re-export of encryption software, to +see if this is permitted. See for more +information. + +The U.S. Government Department of Commerce, Bureau of Industry and +Security (BIS), has classified this software as Export Commodity +Control Number (ECCN) 5D002.C.1, which includes information security +software using or performing cryptographic functions with asymmetric +algorithms. The form and manner of this Apache Software Foundation +distribution makes it eligible for export under the License Exception +ENC Technology Software Unrestricted (TSU) exception (see the BIS +Export Administration Regulations, Section 740.13) for both object +code and source code. + +The following provides more details on the included cryptographic +software: + - Tomcat includes code designed to work with JSSE + - Tomcat includes code designed to work with OpenSSL + + +==================== +When all else fails: +==================== +See the FAQ +http://tomcat.apache.org/faq/ diff --git a/webapps/WEB-INF/caimito/config.properties.sample b/webapps/WEB-INF/caimito/config.properties.sample old mode 100644 new mode 100755 index 49e6dfa..b873074 --- a/webapps/WEB-INF/caimito/config.properties.sample +++ b/webapps/WEB-INF/caimito/config.properties.sample @@ -1,37 +1,40 @@ -#file,openstack +#file,openstack + +resource=file +#A Container or Bucket +cloud.store=store1 +cloud.username=SLOS11111-1:SL11111 +cloud.api.key_password=fffffffffffffffffffffffffffffffffff + +cloud.url=https://dal05.objectstorage.softlayer.net/auth/v1.0/ +#cloud.url=https://dal05.objectstorage.service.networklayer.com/auth/v1.0 -resource=file -#A Container or Bucket -cloud.store=store1 -cloud.username=SLOS11111-1:SL11111 -cloud.api.key_password=fffffffffffffffffffffffffffffffffff +#public,internal +cloud.endpoint.access=public -cloud.url=https://dal05.objectstorage.softlayer.net/auth/v1.0/ -#cloud.url=https://dal05.objectstorage.service.networklayer.com/auth/v1.0 - -#minutes -cloud.max_auth_interval=20 -#Tue, 24 Apr 2012 00:05:15 GMT -cloud.obj.details.dateformat=EEE, dd MMM yyyy HH:mm:ss z -#2012-04-24T00:05:15.474470 -#%Y-%m-%dT%H:%M:%S.000Z -cloud.date.remove.end=true -cloud.dateformat=yyyy-MM-dd'T'HH:mm:ss -#%Y-%m-%dT%H:%M:%S.000Z -#yyyy-MM-dd'T'HH:mm:ss.'Z' -maxspace.units=GB -file.resource.dir=/usr/caimito/drive -SecurityRealmName=Caimito -shaft.app=ca -resource.dir.listing=true -Microsoft-WebDAV-MiniRedir/6.1.7601.auth=digest -protectedRoot=true -cacheable=true -cachedir=/usr/caimito/cache -serverinfo=Caimito -CAIMITO_CSS=H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #FF8FC2;} -directory.title=Directory -directory.parent=Parent -directory.filename=Name -directory.size=Size -directory.lastModified=Date \ No newline at end of file +#minutes +cloud.max_auth_interval=20 +#Tue, 24 Apr 2012 00:05:15 GMT +cloud.obj.details.dateformat=EEE, dd MMM yyyy HH:mm:ss z +#2012-04-24T00:05:15.474470 +#%Y-%m-%dT%H:%M:%S.000Z +cloud.date.remove.end=true +cloud.dateformat=yyyy-MM-dd'T'HH:mm:ss +#%Y-%m-%dT%H:%M:%S.000Z +#yyyy-MM-dd'T'HH:mm:ss.'Z' +maxspace.units=GB +file.resource.dir=/usr/caimito/drive +SecurityRealmName=Caimito +shaft.app=ca +resource.dir.listing=true +Microsoft-WebDAV-MiniRedir/6.1.7601.auth=digest +protectedRoot=true +cacheable=true +cachedir=/usr/caimito/cache +serverinfo=Caimito +CAIMITO_CSS=H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#FF8FC2;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #FF8FC2;} +directory.title=Directory +directory.parent=Parent +directory.filename=Name +directory.size=Size +directory.lastModified=Date diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoConfig.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoConfig.class index dd0b489..12d0a77 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoConfig.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoConfig.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet$Range.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet$Range.class index ac0a2ea..af196a8 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet$Range.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet$Range.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet.class index 4cfca92..89ef340 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoDefaultServlet.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoException.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoException.class index c65f71c..e3527cc 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoException.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoException.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoUtil.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoUtil.class index 7e1ad17..92e78a3 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoUtil.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoUtil.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$LockInfo.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$LockInfo.class index ec4ac7b..7604247 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$LockInfo.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$LockInfo.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$WebdavResolver.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$WebdavResolver.class index a554a8e..5e12dc0 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$WebdavResolver.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet$WebdavResolver.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet.class b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet.class index 2a46573..210dcb1 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet.class and b/webapps/WEB-INF/classes/ngasi/caimito/CaimitoWebdavServlet.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/WebdavServletStatus.class b/webapps/WEB-INF/classes/ngasi/caimito/WebdavServletStatus.class index f263965..e18a7a0 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/WebdavServletStatus.class and b/webapps/WEB-INF/classes/ngasi/caimito/WebdavServletStatus.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/CacheMgr.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/CacheMgr.class index 08b2f4f..ace2b33 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/CacheMgr.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/CacheMgr.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/CaimitoBooleanHolder.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/CaimitoBooleanHolder.class index 677b931..e8f87d1 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/CaimitoBooleanHolder.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/CaimitoBooleanHolder.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/CloudResourceObj.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/CloudResourceObj.class index b7fc98b..2f4f0f4 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/CloudResourceObj.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/CloudResourceObj.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/FileResourceObj.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/FileResourceObj.class index 5fb3972..8cf5e94 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/FileResourceObj.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/FileResourceObj.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/OSRAttribute.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/OSRAttribute.class index f7b7423..d608867 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/OSRAttribute.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/OSRAttribute.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj$1.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj$1.class index 776ee55..ce55df4 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj$1.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj$1.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj.class index 1ed3c11..2a0c844 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/OpenStackResourceObj.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceObj.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceObj.class index 35ceba5..99a2206 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceObj.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceObj.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceStore.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceStore.class index cfdc46f..85bf31d 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceStore.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/ResourceStore.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftAppMgr.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftAppMgr.class index acad916..fd079c7 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftAppMgr.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftAppMgr.class differ diff --git a/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftResourceObj.class b/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftResourceObj.class index f83fe4e..498de30 100644 Binary files a/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftResourceObj.class and b/webapps/WEB-INF/classes/ngasi/caimito/resource/ShaftResourceObj.class differ diff --git a/webapps/WEB-INF/lib/ac.jar b/webapps/WEB-INF/lib/ac.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/asm-3.1.jar b/webapps/WEB-INF/lib/asm-3.1.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/gson.jar b/webapps/WEB-INF/lib/gson.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jackson-core-asl-1.8.3.jar b/webapps/WEB-INF/lib/jackson-core-asl-1.8.3.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jackson-jaxrs-1.8.3.jar b/webapps/WEB-INF/lib/jackson-jaxrs-1.8.3.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jackson-mapper-asl-1.8.3.jar b/webapps/WEB-INF/lib/jackson-mapper-asl-1.8.3.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jackson-xc-1.8.3.jar b/webapps/WEB-INF/lib/jackson-xc-1.8.3.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jersey-client-1.10.jar b/webapps/WEB-INF/lib/jersey-client-1.10.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jersey-core-1.10.jar b/webapps/WEB-INF/lib/jersey-core-1.10.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jersey-json-1.10.jar b/webapps/WEB-INF/lib/jersey-json-1.10.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jersey-server-1.10.jar b/webapps/WEB-INF/lib/jersey-server-1.10.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jersey-servlet-1.10.jar b/webapps/WEB-INF/lib/jersey-servlet-1.10.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jettison-1.1.jar b/webapps/WEB-INF/lib/jettison-1.1.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/jsr311-api-1.1.1.jar b/webapps/WEB-INF/lib/jsr311-api-1.1.1.jar old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/lib/tools.jar b/webapps/WEB-INF/lib/tools.jar index 26b43cc..2054362 100644 Binary files a/webapps/WEB-INF/lib/tools.jar and b/webapps/WEB-INF/lib/tools.jar differ diff --git a/webapps/WEB-INF/shaft/app.properties b/webapps/WEB-INF/shaft/app.properties old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/shaft/load_db.sql b/webapps/WEB-INF/shaft/load_db.sql old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/shaft/server.properties b/webapps/WEB-INF/shaft/server.properties old mode 100644 new mode 100755 diff --git a/webapps/WEB-INF/web.xml b/webapps/WEB-INF/web.xml old mode 100644 new mode 100755 index 7025186..6111728 --- a/webapps/WEB-INF/web.xml +++ b/webapps/WEB-INF/web.xml @@ -1,88 +1,88 @@ - - - - - - Welcome to Caimito - - Welcome to Caimito - - - shf - org.shaft.ShaftFilter - - - shf - /* - - - - - Jersey Web Application - com.sun.jersey.spi.container.servlet.ServletContainer - - com.sun.jersey.config.property.packages - org.shaft.server.rest - - -5 - - - Jersey Web Application - /shaftrest/* - - - - - webdav - ngasi.caimito.CaimitoWebdavServlet - - debug - 0 - - - listings - true - - - readonly - false - - - - webdav - /* - - - - 404 - /ca/404.html - - - 401 - /ca/401.html - - - 500 - /ca/500.html - - + + + + + + Welcome to Caimito + + Welcome to Caimito + + + shf + org.shaft.ShaftFilter + + + shf + /* + + + + + Jersey Web Application + com.sun.jersey.spi.container.servlet.ServletContainer + + com.sun.jersey.config.property.packages + org.shaft.server.rest + + -5 + + + Jersey Web Application + /shaftrest/* + + + + + webdav + ngasi.caimito.CaimitoWebdavServlet + + debug + 0 + + + listings + true + + + readonly + false + + + + webdav + /* + + + + 404 + /ca/404.html + + + 401 + /ca/401.html + + + 500 + /ca/500.html + + diff --git a/webapps/build.xml b/webapps/build.xml old mode 100644 new mode 100755 index bcb2c2d..871daa7 --- a/webapps/build.xml +++ b/webapps/build.xml @@ -1,93 +1,93 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapps/ca/public/.gitattributes b/webapps/ca/public/.gitattributes old mode 100644 new mode 100755 diff --git a/webapps/ca/public/.gitignore b/webapps/ca/public/.gitignore old mode 100644 new mode 100755 diff --git a/webapps/ca/public/.htaccess b/webapps/ca/public/.htaccess old mode 100644 new mode 100755 diff --git a/webapps/ca/public/401.html b/webapps/ca/public/401.html old mode 100644 new mode 100755 diff --git a/webapps/ca/public/404.html b/webapps/ca/public/404.html old mode 100644 new mode 100755 diff --git a/webapps/ca/public/500.html b/webapps/ca/public/500.html old mode 100644 new mode 100755 diff --git a/webapps/ca/public/apple-touch-icon-114x114-precomposed.png b/webapps/ca/public/apple-touch-icon-114x114-precomposed.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/apple-touch-icon-57x57-precomposed.png b/webapps/ca/public/apple-touch-icon-57x57-precomposed.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/apple-touch-icon-72x72-precomposed.png b/webapps/ca/public/apple-touch-icon-72x72-precomposed.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/apple-touch-icon-precomposed.png b/webapps/ca/public/apple-touch-icon-precomposed.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/apple-touch-icon.png b/webapps/ca/public/apple-touch-icon.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/crossdomain.xml b/webapps/ca/public/crossdomain.xml old mode 100644 new mode 100755 diff --git a/webapps/ca/public/css/style.css b/webapps/ca/public/css/style.css old mode 100644 new mode 100755 diff --git a/webapps/ca/public/favicon.ico b/webapps/ca/public/favicon.ico old mode 100644 new mode 100755 diff --git a/webapps/ca/public/humans.txt b/webapps/ca/public/humans.txt old mode 100644 new mode 100755 diff --git a/webapps/ca/public/img/.gitignore b/webapps/ca/public/img/.gitignore old mode 100644 new mode 100755 diff --git a/webapps/ca/public/index.html b/webapps/ca/public/index.html old mode 100644 new mode 100755 diff --git a/webapps/ca/public/js/libs/jquery-1.7.1.js b/webapps/ca/public/js/libs/jquery-1.7.1.js old mode 100644 new mode 100755 diff --git a/webapps/ca/public/js/libs/jquery-1.7.1.min.js b/webapps/ca/public/js/libs/jquery-1.7.1.min.js old mode 100644 new mode 100755 diff --git a/webapps/ca/public/js/libs/modernizr-2.5.3.min.js b/webapps/ca/public/js/libs/modernizr-2.5.3.min.js old mode 100644 new mode 100755 diff --git a/webapps/ca/public/js/plugins.js b/webapps/ca/public/js/plugins.js old mode 100644 new mode 100755 diff --git a/webapps/ca/public/js/script.js b/webapps/ca/public/js/script.js old mode 100644 new mode 100755 diff --git a/webapps/ca/public/logo.png b/webapps/ca/public/logo.png old mode 100644 new mode 100755 diff --git a/webapps/ca/public/readme.md b/webapps/ca/public/readme.md old mode 100644 new mode 100755 diff --git a/webapps/ca/public/robots.txt b/webapps/ca/public/robots.txt old mode 100644 new mode 100755 diff --git a/webapps/ca/public/symbol.png b/webapps/ca/public/symbol.png old mode 100644 new mode 100755 diff --git a/webapps/ca/server/pathprivileges.db b/webapps/ca/server/pathprivileges.db old mode 100644 new mode 100755 diff --git a/webapps/ca/server/publicpaths.db b/webapps/ca/server/publicpaths.db old mode 100644 new mode 100755 diff --git a/webapps/favicon.ico b/webapps/favicon.ico old mode 100644 new mode 100755 diff --git a/webapps/index.jsp b/webapps/index.jsp old mode 100644 new mode 100755 index 19412f5..c24e751 --- a/webapps/index.jsp +++ b/webapps/index.jsp @@ -1,222 +1,222 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You 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. ---%> - -<%@ page session="false" %> -<% -java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy"); -request.setAttribute("year", sdf.format(new java.util.Date())); -request.setAttribute("tomcat7Url", "http://tomcat.apache.org/"); -request.setAttribute("tomcat7DocUrl", "/docs/"); -request.setAttribute("tomcat7ExamplesUrl", "/examples/"); -%> - - - <%=request.getServletContext().getServerInfo() %> - - - - - - -

- -
-

${pageContext.servletContext.serverInfo}

-
-
-
-

If you're seeing this, you've successfully installed Tomcat. Congratulations!

-
- -
- - - -
- -
-
-
-

Developer Quick Start

- - -
-
-

Examples

-
-
- -
-
-
-
-
-

Managing Tomcat

-

For security, access to the manager webapp is restricted. - Users are defined in:

-
$CATALINA_HOME/conf/tomcat-users.xml
-

In Tomcat 7.0 access to the manager application is split between - different users.   Read more...

-
-

Release Notes

-

Changelog

-

Migration Guide

-

Security Notices

-
-
-
-
-

Documentation

-

Tomcat 7.0 Documentation

-

Tomcat 7.0 Configuration

-

Tomcat Wiki

-

Find additional important configuration information in:

-
$CATALINA_HOME/RUNNING.txt
-

Developers may be interested in:

- -
-
-
-
-

Getting Help

-

FAQ and Mailing Lists

-

The following mailing lists are available:

- -
-
-
-
- - -
- - - +<%-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You 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. +--%> + +<%@ page session="false" %> +<% +java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy"); +request.setAttribute("year", sdf.format(new java.util.Date())); +request.setAttribute("tomcat7Url", "http://tomcat.apache.org/"); +request.setAttribute("tomcat7DocUrl", "/docs/"); +request.setAttribute("tomcat7ExamplesUrl", "/examples/"); +%> + + + <%=request.getServletContext().getServerInfo() %> + + + + + + +
+ +
+

${pageContext.servletContext.serverInfo}

+
+
+
+

If you're seeing this, you've successfully installed Tomcat. Congratulations!

+
+ +
+ + + +
+ +
+
+
+

Developer Quick Start

+ + +
+
+

Examples

+
+
+ +
+
+
+
+
+

Managing Tomcat

+

For security, access to the manager webapp is restricted. + Users are defined in:

+
$CATALINA_HOME/conf/tomcat-users.xml
+

In Tomcat 7.0 access to the manager application is split between + different users.   Read more...

+
+

Release Notes

+

Changelog

+

Migration Guide

+

Security Notices

+
+
+
+
+

Documentation

+

Tomcat 7.0 Documentation

+

Tomcat 7.0 Configuration

+

Tomcat Wiki

+

Find additional important configuration information in:

+
$CATALINA_HOME/RUNNING.txt
+

Developers may be interested in:

+ +
+
+
+
+

Getting Help

+

FAQ and Mailing Lists

+

The following mailing lists are available:

+ +
+
+
+
+ + +
+ + + diff --git a/webapps/tomcat.css b/webapps/tomcat.css old mode 100644 new mode 100755 index c3d934b..73d8fba --- a/webapps/tomcat.css +++ b/webapps/tomcat.css @@ -1,351 +1,351 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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. -*/ -body { - margin: 10px 20px; - text-align: center; - font-family: Arial, sans-serif; -} - -h1, h2, h3, h4, h5, h6, p, ul, ol { - margin: 0 0 0.5em; -} -h1 { - font-size: 18pt; - margin: 0.5em 0 0; -} -h2 { - font-size: 16pt; -} -h3 { - font-size: 13pt; -} -h4 { - font-size: 12pt; -} -h5 { - font-size: 11pt; -} -p { - font-size: 11pt -} - -ul { - margin: 0; - padding: 0 0 0 0.25em; - text-indent: 0; - list-style: none; -} -li { - margin: 0; - padding: 0 0 0.25em; - text-indent: 0; - font-size: 80%; -} - -pre { - text-indent: 0.25em; - width: 90%; - font-size: 90%; -} - -br.separator { - margin: 0; - padding: 0; - clear: both; -} - -a img { - border: 0 none; -} - -.container { - padding: 10px; - margin: 0 0 10px; -} - -.col20 { - float: left; - width: 20%; -} - -.col25 { - float: left; - width: 25%; -} - -#wrapper { - display: block; - margin: 0 auto; - text-align: left; - min-width: 720px; - max-width: 1000px; -} -.curved { - border-radius: 10px; - -moz-border-radius: 10px; - -webkit-border-radius: 10px; - -khtml-border-radius: 10px; -} - -#navigation { - background: #eee url(bg-nav.png) repeat-x top left; - margin: 0 0 10px; - padding: 0; -} -#navigation span { - float: left; -} -#navigation span a { - display: block; - padding: 10px; - font-weight: bold; - text-shadow: 1px 1px 1px #fff; -} -#navigation span a:link, -#navigation span a:visited, -#navigation span a:hover, -#navigation span a:active { - color: #666; - text-decoration: none; -} -#navigation span#nav-help { - float: right; - margin-right: 0; -} - -#asf-box { - height: 40px; - background: #fff url(asf-logo.png) no-repeat top right;} -#asf-box h1 { - padding: 0; - margin: 0; -} - -#upper { - background: #fff url(bg-upper.png) repeat-x top left; -} - -#congrats { - text-align: center; - padding: 10px; - margin: 0 40px 20px; - background-color: #9c9; -} -#congrats h2 { - font-size: 14pt; - padding: 0; - margin: 0; - color: #fff; -} - -#notice { - float: left; - width: 560px; - color: #696; -} -#notice a:link, -#notice a:visited, -#notice a:hover, -#notice a:active { - color: #090; - text-decoration: none; -} -#notice img, -#notice #tasks { - float: left; -} -#tasks a:link, -#tasks a:visited, -#tasks a:hover, -#tasks a:active { - text-decoration: underline; -} -#notice img { - margin-right: 20px; -} - -#actions { - float: right; - width: 140px; -} - -#actions .button { - display: block; - padding: 0; - height: 36px; - background: url(bg-button.png) no-repeat top left; -} - -#actions .button a { - display: block; - padding: 0; -} - -#actions .button a:link, -#actions .button a:visited, -#actions .button a:hover, -#actions .button a:active { - color: #696; - text-decoration: none; -} - -#actions .button a span { - display: block; - padding: 6px 10px; - color: #666; - text-shadow: 1px 1px 1px #fff; - font-size: 10pt; - font-weight: bold; -} - -#middle { - background: #eef url(bg-middle.png) repeat-x top left; - margin: 20px 0; - padding: 1px 10px; -} -#middle h3 { - margin: 0 0 10px; - color: #033; -} -#middle p { - font-size: 10pt; -} -#middle a:link, -#middle a:visited, -#middle a:hover, -#middle a:active { - color: #366; - font-weight: bold; -} -#middle .col25 .container { - padding: 0 0 1px; -} - -#developers { - float: left; - width: 40%; -} -#security { - float: right; - width: 50%; -} - -#lower { - padding: 0; -} - -#lower a:link, -#lower a:visited, -#lower a:hover, -#lower a:active { - color: #600; -} - -#lower strong a:link, -#lower strong a:visited, -#lower strong a:hover, -#lower strong a:active { - color: #c00; -} - -#lower h3 { - color: #963; - font-size: 14pt; -} -#lower h4 { - font-size: 12pt; -} -#lower ul { - padding: 0; - margin: 0.5em 0; -} -#lower p, -#lower li { - font-size: 9pt; - color: #753; - margin: 0 0 0.1em; -} -#lower li { - padding: 3px 5px; -} -#lower li strong { - color: #a53; -} -#lower li#list-announce { - border: 1px solid #f90; - background-color: #ffe8c8; -} -#lower p { - font-size: 10.5pt; -} - -#low-manage, -#low-docs, -#low-help { - float: left; - width: 32%; -} -#low-docs { - margin: 0 0 0 2.2%; -} -#low-help { - float: right; -} - -#low-manage div, -#low-docs div, -#low-help div { - min-height: 280px; - border: 3px solid #ffdc75; - background-color: #fff1c8; - padding: 10px; -} - -#footer { - padding: 0; - margin: 20px 0; - color: #999; - background-color: #eee; -} -#footer h4 { - margin: 0 0 10px; - font-size: 10pt; -} -#footer p { - margin: 0 0 10px; - font-size: 10pt; -} -#footer ul { - margin: 6px 0 1px; - padding: 0; -} -#footer li { - margin: 0; - font-size: 9pt; -} - -#footer a:link, -#footer a:visited, -#footer a:hover, -#footer a:active { - color: #666; -} - -.copyright { - font-size: 10pt; - color: #666; +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +*/ +body { + margin: 10px 20px; + text-align: center; + font-family: Arial, sans-serif; +} + +h1, h2, h3, h4, h5, h6, p, ul, ol { + margin: 0 0 0.5em; +} +h1 { + font-size: 18pt; + margin: 0.5em 0 0; +} +h2 { + font-size: 16pt; +} +h3 { + font-size: 13pt; +} +h4 { + font-size: 12pt; +} +h5 { + font-size: 11pt; +} +p { + font-size: 11pt +} + +ul { + margin: 0; + padding: 0 0 0 0.25em; + text-indent: 0; + list-style: none; +} +li { + margin: 0; + padding: 0 0 0.25em; + text-indent: 0; + font-size: 80%; +} + +pre { + text-indent: 0.25em; + width: 90%; + font-size: 90%; +} + +br.separator { + margin: 0; + padding: 0; + clear: both; +} + +a img { + border: 0 none; +} + +.container { + padding: 10px; + margin: 0 0 10px; +} + +.col20 { + float: left; + width: 20%; +} + +.col25 { + float: left; + width: 25%; +} + +#wrapper { + display: block; + margin: 0 auto; + text-align: left; + min-width: 720px; + max-width: 1000px; +} +.curved { + border-radius: 10px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + -khtml-border-radius: 10px; +} + +#navigation { + background: #eee url(bg-nav.png) repeat-x top left; + margin: 0 0 10px; + padding: 0; +} +#navigation span { + float: left; +} +#navigation span a { + display: block; + padding: 10px; + font-weight: bold; + text-shadow: 1px 1px 1px #fff; +} +#navigation span a:link, +#navigation span a:visited, +#navigation span a:hover, +#navigation span a:active { + color: #666; + text-decoration: none; +} +#navigation span#nav-help { + float: right; + margin-right: 0; +} + +#asf-box { + height: 40px; + background: #fff url(asf-logo.png) no-repeat top right;} +#asf-box h1 { + padding: 0; + margin: 0; +} + +#upper { + background: #fff url(bg-upper.png) repeat-x top left; +} + +#congrats { + text-align: center; + padding: 10px; + margin: 0 40px 20px; + background-color: #9c9; +} +#congrats h2 { + font-size: 14pt; + padding: 0; + margin: 0; + color: #fff; +} + +#notice { + float: left; + width: 560px; + color: #696; +} +#notice a:link, +#notice a:visited, +#notice a:hover, +#notice a:active { + color: #090; + text-decoration: none; +} +#notice img, +#notice #tasks { + float: left; +} +#tasks a:link, +#tasks a:visited, +#tasks a:hover, +#tasks a:active { + text-decoration: underline; +} +#notice img { + margin-right: 20px; +} + +#actions { + float: right; + width: 140px; +} + +#actions .button { + display: block; + padding: 0; + height: 36px; + background: url(bg-button.png) no-repeat top left; +} + +#actions .button a { + display: block; + padding: 0; +} + +#actions .button a:link, +#actions .button a:visited, +#actions .button a:hover, +#actions .button a:active { + color: #696; + text-decoration: none; +} + +#actions .button a span { + display: block; + padding: 6px 10px; + color: #666; + text-shadow: 1px 1px 1px #fff; + font-size: 10pt; + font-weight: bold; +} + +#middle { + background: #eef url(bg-middle.png) repeat-x top left; + margin: 20px 0; + padding: 1px 10px; +} +#middle h3 { + margin: 0 0 10px; + color: #033; +} +#middle p { + font-size: 10pt; +} +#middle a:link, +#middle a:visited, +#middle a:hover, +#middle a:active { + color: #366; + font-weight: bold; +} +#middle .col25 .container { + padding: 0 0 1px; +} + +#developers { + float: left; + width: 40%; +} +#security { + float: right; + width: 50%; +} + +#lower { + padding: 0; +} + +#lower a:link, +#lower a:visited, +#lower a:hover, +#lower a:active { + color: #600; +} + +#lower strong a:link, +#lower strong a:visited, +#lower strong a:hover, +#lower strong a:active { + color: #c00; +} + +#lower h3 { + color: #963; + font-size: 14pt; +} +#lower h4 { + font-size: 12pt; +} +#lower ul { + padding: 0; + margin: 0.5em 0; +} +#lower p, +#lower li { + font-size: 9pt; + color: #753; + margin: 0 0 0.1em; +} +#lower li { + padding: 3px 5px; +} +#lower li strong { + color: #a53; +} +#lower li#list-announce { + border: 1px solid #f90; + background-color: #ffe8c8; +} +#lower p { + font-size: 10.5pt; +} + +#low-manage, +#low-docs, +#low-help { + float: left; + width: 32%; +} +#low-docs { + margin: 0 0 0 2.2%; +} +#low-help { + float: right; +} + +#low-manage div, +#low-docs div, +#low-help div { + min-height: 280px; + border: 3px solid #ffdc75; + background-color: #fff1c8; + padding: 10px; +} + +#footer { + padding: 0; + margin: 20px 0; + color: #999; + background-color: #eee; +} +#footer h4 { + margin: 0 0 10px; + font-size: 10pt; +} +#footer p { + margin: 0 0 10px; + font-size: 10pt; +} +#footer ul { + margin: 6px 0 1px; + padding: 0; +} +#footer li { + margin: 0; + font-size: 9pt; +} + +#footer a:link, +#footer a:visited, +#footer a:hover, +#footer a:active { + color: #666; +} + +.copyright { + font-size: 10pt; + color: #666; } \ No newline at end of file