No public description
PiperOrigin-RevId: 782960646
Change-Id: I14a3f7cd265b6b0f5684dd9cb8f1975b3fc3565f
diff --git a/current/LICENSE b/current/LICENSE
index 872fe1c..b1c74f9 100644
--- a/current/LICENSE
+++ b/current/LICENSE
@@ -1,263 +1,759 @@
-COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1
1. Definitions.
- 1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
+ 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.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.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.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.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.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.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.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:
+ 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;
+ 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
+ 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.
+ 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.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.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.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.
+ 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.
+ 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:
+ 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
+ (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).
+ (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.
+ (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.
+ (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:
+ 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
+ (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).
+ (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.
+ (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.
+ (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.1. Availability of Source Code.
- 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.
+ 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.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.2. Modifications.
- 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.
+ 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.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.3. Required Notices.
- 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.
+ 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.1. New Versions.
- 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.
+ Oracle 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.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.
+ 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.
+ 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.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.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.
+ 6.3. If You assert a patent infringement claim against Participant
+ alleging that the Participant Software directly or indirectly
+ infringes any patent where such claim is resolved (such as by
+ license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 6.4. 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.
+ 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 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.
+ 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.
+ 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.
+ 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.
+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.
-The GNU General Public License (GPL) Version 2, June 1991
+ The GNU General Public License (GPL) Version 2, June 1991
-Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor
+Boston, MA 02110-1335
+USA
-Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
Preamble
-The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public
+License applies to most of the Free Software Foundation's software and
+to any other program whose authors commit to using it. (Some other Free
+Software Foundation software is covered by the GNU Library General
+Public License instead.) You can apply it to your programs, too.
-When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+When we speak of free software, we are referring to freedom, not price.
+Our General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this
+service if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs; and that you know you can do these things.
-To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+To protect your rights, we need to make restrictions that forbid anyone
+to deny you these rights or to ask you to surrender the rights. These
+restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
-For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+For example, if you distribute copies of such a program, whether gratis
+or for a fee, you must give the recipients all the rights that you have.
+You must make sure that they, too, receive or can get the source code.
+And you must show them these terms so they know their rights.
-We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
-Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
-Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+Finally, any free program is threatened constantly by software patents.
+We wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program
+proprietary. To prevent this, we have made it clear that any patent must
+be licensed for everyone's free use or not licensed at all.
-The precise terms and conditions for copying, distribution and modification follow.
-
+The precise terms and conditions for copying, distribution and
+modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+0. This License applies to any program or other work which contains a
+notice placed by the copyright holder saying it may be distributed under
+the terms of this General Public License. The "Program", below, refers
+to any such program or work, and a "work based on the Program" means
+either the Program or any derivative work under copyright law: that is
+to say, a work containing the Program or a portion of it, either
+verbatim or with modifications and/or translated into another language.
+(Hereinafter, translation is included without limitation in the term
+"modification".) Each licensee is addressed as "you".
-Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of running
+the Program is not restricted, and the output from the Program is
+covered only if its contents constitute a work based on the Program
+(independent of having been made by running the Program). Whether that
+is true depends on what the Program does.
-1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously
+and appropriately publish on each copy an appropriate copyright notice
+and disclaimer of warranty; keep intact all the notices that refer to
+this License and to the absence of any warranty; and give any other
+recipients of the Program a copy of this License along with the Program.
-You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
-2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+2. You may modify your copy or copies of the Program or any portion of
+it, thus forming a work based on the Program, and copy and distribute
+such modifications or work under the terms of Section 1 above, provided
+that you also meet all of these conditions:
- a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
- b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any part
+ thereof, to be licensed as a whole at no charge to all third parties
+ under the terms of this License.
- c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a notice
+ that there is no warranty (or else, saying that you provide a
+ warranty) and that users may redistribute the program under these
+ conditions, and telling the user how to view a copy of this License.
+ (Exception: if the Program itself is interactive but does not
+ normally print such an announcement, your work based on the Program
+ is not required to print an announcement.)
-These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program, and
+can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based on
+the Program, the distribution of the whole must be on the terms of this
+License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
-Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
-In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the
+scope of this License.
-3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
- a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections 1
+ and 2 above on a medium customarily used for software interchange; or,
- b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your cost
+ of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
- c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed
+ only for noncommercial distribution and only if you received the
+ program in object code or executable form with such an offer, in
+ accord with Subsection b above.)
-The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to control
+compilation and installation of the executable. However, as a special
+exception, the source code distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies the
+executable.
-If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+If distribution of executable or object code is made by offering access
+to copy from a designated place, then offering equivalent access to copy
+the source code from the same place counts as distribution of the source
+code, even though third parties are not compelled to copy the source
+along with the object code.
-4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt otherwise
+to copy, modify, sublicense or distribute the Program is void, and will
+automatically terminate your rights under this License. However, parties
+who have received copies, or rights, from you under this License will
+not have their licenses terminated so long as such parties remain in
+full compliance.
-5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and all
+its terms and conditions for copying, distributing or modifying the
+Program or works based on it.
-6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further restrictions
+on the recipients' exercise of the rights granted herein. You are not
+responsible for enforcing compliance by third parties to this License.
-7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot distribute
+so as to satisfy simultaneously your obligations under this License and
+any other pertinent obligations, then as a consequence you may not
+distribute the Program at all. For example, if a patent license would
+not permit royalty-free redistribution of the Program by all those who
+receive copies directly or indirectly through you, then the only way you
+could satisfy both it and this License would be to refrain entirely from
+distribution of the Program.
-If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
-It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is implemented
+by public license practices. Many people have made generous
+contributions to the wide range of software distributed through that
+system in reliance on consistent application of that system; it is up to
+the author/donor to decide if he or she is willing to distribute
+software through any other system and a licensee cannot impose that choice.
-This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+This section is intended to make thoroughly clear what is believed to be
+a consequence of the rest of this License.
-8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License may
+add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among countries
+not thus excluded. In such case, this License incorporates the
+limitation as if written in the body of this License.
-9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+9. The Free Software Foundation may publish revised and/or new
+versions of the General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
-Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Program does not specify a version
+number of this License, you may choose any version ever published by the
+Free Software Foundation.
-10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the
+author to ask for permission. For software which is copyrighted by the
+Free Software Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be guided by the
+two goals of preserving the free status of all derivatives of our free
+software and of promoting the sharing and reuse of software generally.
NO WARRANTY
-11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
+YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
-12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
+(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
+INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
+THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
+OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
-
How to Apply These Terms to Your New Programs
-If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
-To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey
+the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
- One line to give the program's name and a brief idea of what it does.
+ One line to give the program's name and a brief idea of what it does.
+ Copyright (C) <year> <name of author>
- Copyright (C)
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
Also add information on how to contact you by electronic and paper mail.
-If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
+ `show w'. This is free software, and you are welcome to redistribute
+ it under certain conditions; type `show c' for details.
-The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+The hypothetical commands `show w' and `show c' should show the
+appropriate parts of the General Public License. Of course, the commands
+you use may be called something other than `show w' and `show c'; they
+could even be mouse-clicks or menu items--whatever suits your program.
-You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program `Gnomovision' (which makes passes at compilers) written by
+ James Hacker.
- signature of Ty Coon, 1 April 1989
- Ty Coon, President of Vice
+ signature of Ty Coon, 1 April 1989
+ Ty Coon, President of Vice
-This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+This General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications
+with the library. If this is what you want to do, use the GNU Library
+General Public License instead of this License.
+#
-"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+Certain source files distributed by Oracle America, Inc. and/or its
+affiliates are subject to the following clarification and special
+exception to the GPLv2, based on the GNU Project exception for its
+Classpath libraries, known as the GNU Classpath Exception, but only
+where Oracle has expressly included in the particular source file's
+header the words "Oracle designates this particular file as subject to
+the "Classpath" exception as provided by Oracle in the LICENSE file
+that accompanied this code."
-Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
+You should also note that Oracle includes multiple, independent
+programs in this software package. Some of those programs are provided
+under licenses deemed incompatible with the GPLv2 by the Free Software
+Foundation and others. For example, the package includes programs
+licensed under the Apache License, Version 2.0. Such programs are
+licensed to you under their original licenses.
-"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
+Oracle facilitates your further distribution of this package by adding
+the Classpath Exception to the necessary parts of its GPLv2 code, which
+permits you to use that code in combination with other independent
+modules not licensed under the GPLv2. However, note that this would
+not permit you to commingle code under an incompatible license with
+Oracle's GPLv2 licensed code by, for example, cutting and pasting such
+code into a file also containing Oracle's GPLv2 licensed code and then
+distributing the result. Additionally, if you were to remove the
+Classpath Exception from any of the files to which it applies and
+distribute the result, you would likely be required to license some or
+all of the other code in that distribution under the GPLv2 as well, and
+since the GPLv2 is incompatible with the license terms of some items
+included in the distribution by Oracle, removing the Classpath
+Exception could therefore effectively compromise your ability to
+further distribute the package.
-Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+Proceed with caution and we recommend that you obtain the advice of a
+lawyer skilled in open source matters before removing the Classpath
+Exception or making modifications to this package which may
+subsequently be redistributed and/or involve the use of third party
+software.
-As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
+CLASSPATH EXCEPTION
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License version 2 cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from or
+based on this library. If you modify this library, you may extend this
+exception to your version of the library, but you are not obligated to
+do so. If you do not wish to do so, delete this exception statement
+from your version.
diff --git a/current/src/main/java/com/sun/mail/auth/MD4.java b/current/src/main/java/com/sun/mail/auth/MD4.java
index 5fe094c..6979f10 100644
--- a/current/src/main/java/com/sun/mail/auth/MD4.java
+++ b/current/src/main/java/com/sun/mail/auth/MD4.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2005-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/auth/Ntlm.java b/current/src/main/java/com/sun/mail/auth/Ntlm.java
index 57354a4..561f432 100644
--- a/current/src/main/java/com/sun/mail/auth/Ntlm.java
+++ b/current/src/main/java/com/sun/mail/auth/Ntlm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2005-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -359,7 +359,7 @@
{ '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
private static String toHex(byte[] b) {
- StringBuffer sb = new StringBuffer(b.length * 3);
+ StringBuilder sb = new StringBuilder(b.length * 3);
for (int i = 0; i < b.length; i++)
sb.append(hex[(b[i]>>4)&0xF]).append(hex[b[i]&0xF]).append(' ');
return sb.toString();
diff --git a/current/src/main/java/com/sun/mail/auth/OAuth2SaslClient.java b/current/src/main/java/com/sun/mail/auth/OAuth2SaslClient.java
index 6c68b18..42ab7c5 100644
--- a/current/src/main/java/com/sun/mail/auth/OAuth2SaslClient.java
+++ b/current/src/main/java/com/sun/mail/auth/OAuth2SaslClient.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -69,17 +69,17 @@
this.cbh = cbh;
}
- //@Override
+ @Override
public String getMechanismName() {
return "XOAUTH2";
}
- //@Override
+ @Override
public boolean hasInitialResponse() {
return true;
}
- //@Override
+ @Override
public byte[] evaluateChallenge(byte[] challenge) throws SaslException {
if (complete)
return new byte[0];
@@ -114,31 +114,31 @@
return response;
}
- //@Override
+ @Override
public boolean isComplete() {
return complete;
}
- //@Override
+ @Override
public byte[] unwrap(byte[] incoming, int offset, int len)
throws SaslException {
throw new IllegalStateException("OAUTH2 unwrap not supported");
}
- //@Override
+ @Override
public byte[] wrap(byte[] outgoing, int offset, int len)
throws SaslException {
throw new IllegalStateException("OAUTH2 wrap not supported");
}
- //@Override
+ @Override
public Object getNegotiatedProperty(String propName) {
if (!complete)
throw new IllegalStateException("OAUTH2 getNegotiatedProperty");
return null;
}
- //@Override
+ @Override
public void dispose() throws SaslException {
}
}
diff --git a/current/src/main/java/com/sun/mail/auth/OAuth2SaslClientFactory.java b/current/src/main/java/com/sun/mail/auth/OAuth2SaslClientFactory.java
index 372464c..21fc208 100644
--- a/current/src/main/java/com/sun/mail/auth/OAuth2SaslClientFactory.java
+++ b/current/src/main/java/com/sun/mail/auth/OAuth2SaslClientFactory.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -65,7 +65,7 @@
}
}
- //@Override
+ @Override
public SaslClient createSaslClient(String[] mechanisms,
String authorizationId, String protocol,
String serverName, Map<String,?> props,
@@ -77,7 +77,7 @@
return null;
}
- //@Override
+ @Override
public String[] getMechanismNames(Map<String,?> props) {
return new String[] { "XOAUTH2" };
}
diff --git a/current/src/main/java/com/sun/mail/handlers/handler_base.java b/current/src/main/java/com/sun/mail/handlers/handler_base.java
index 2ed99d1..31fb4f4 100644
--- a/current/src/main/java/com/sun/mail/handlers/handler_base.java
+++ b/current/src/main/java/com/sun/mail/handlers/handler_base.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -52,12 +52,19 @@
/**
* Return an array of ActivationDataFlavors that we support.
* Usually there will be only one.
+ *
+ * @return array of ActivationDataFlavors that we support
*/
protected abstract ActivationDataFlavor[] getDataFlavors();
/**
* Given the flavor that matched, return the appropriate type of object.
* Usually there's only one flavor so just call getContent.
+ *
+ * @param aFlavor the ActivationDataFlavor
+ * @param ds DataSource containing the data
+ * @return the object
+ * @exception IOException for errors reading the data
*/
protected Object getData(ActivationDataFlavor aFlavor, DataSource ds)
throws IOException {
@@ -69,6 +76,7 @@
*
* @return The DataFlavors
*/
+ @Override
public DataFlavor[] getTransferDataFlavors() {
ActivationDataFlavor[] adf = getDataFlavors();
if (adf.length == 1) // the common case
@@ -81,10 +89,12 @@
/**
* Return the Transfer Data of type DataFlavor from InputStream.
*
- * @param df The DataFlavor
- * @param ds The DataSource corresponding to the data
- * @return String object
+ * @param df The DataFlavor
+ * @param ds The DataSource corresponding to the data
+ * @return the object
+ * @exception IOException for errors reading the data
*/
+ @Override
public Object getTransferData(DataFlavor df, DataSource ds)
throws IOException {
ActivationDataFlavor[] adf = getDataFlavors();
diff --git a/current/src/main/java/com/sun/mail/handlers/image_gif.java b/current/src/main/java/com/sun/mail/handlers/image_gif.java
index 56f905f..95d3a44 100644
--- a/current/src/main/java/com/sun/mail/handlers/image_gif.java
+++ b/current/src/main/java/com/sun/mail/handlers/image_gif.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -52,10 +52,12 @@
new ActivationDataFlavor(Image.class, "image/gif", "GIF Image")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return myDF;
}
+ @Override
public Object getContent(DataSource ds) throws IOException {
InputStream is = ds.getInputStream();
int pos = 0;
@@ -82,6 +84,7 @@
/**
* Write the object to the output stream, using the specified MIME type.
*/
+ @Override
public void writeTo(Object obj, String type, OutputStream os)
throws IOException {
if (!(obj instanceof Image))
diff --git a/current/src/main/java/com/sun/mail/handlers/image_jpeg.java b/current/src/main/java/com/sun/mail/handlers/image_jpeg.java
index 8cf5b75..ef66329 100644
--- a/current/src/main/java/com/sun/mail/handlers/image_jpeg.java
+++ b/current/src/main/java/com/sun/mail/handlers/image_jpeg.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -51,6 +51,7 @@
new ActivationDataFlavor(Image.class, "image/jpeg", "JPEG Image")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return myDF;
}
diff --git a/current/src/main/java/com/sun/mail/handlers/message_rfc822.java b/current/src/main/java/com/sun/mail/handlers/message_rfc822.java
index adff507..b488abc 100644
--- a/current/src/main/java/com/sun/mail/handlers/message_rfc822.java
+++ b/current/src/main/java/com/sun/mail/handlers/message_rfc822.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -58,6 +58,7 @@
new ActivationDataFlavor(Message.class, "message/rfc822", "Message")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return ourDataFlavor;
}
@@ -65,6 +66,7 @@
/**
* Return the content.
*/
+ @Override
public Object getContent(DataSource ds) throws IOException {
// create a new MimeMessage
try {
@@ -92,6 +94,7 @@
/**
* Write the object as a byte stream.
*/
+ @Override
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
// if the object is a message, we know how to write that out
diff --git a/current/src/main/java/com/sun/mail/handlers/multipart_mixed.java b/current/src/main/java/com/sun/mail/handlers/multipart_mixed.java
index 57801a3..f5af1e0 100644
--- a/current/src/main/java/com/sun/mail/handlers/multipart_mixed.java
+++ b/current/src/main/java/com/sun/mail/handlers/multipart_mixed.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -53,6 +53,7 @@
"multipart/mixed", "Multipart")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return myDF;
}
@@ -60,6 +61,7 @@
/**
* Return the content.
*/
+ @Override
public Object getContent(DataSource ds) throws IOException {
try {
return new MimeMultipart(ds);
@@ -74,6 +76,7 @@
/**
* Write the object to the output stream, using the specific MIME type.
*/
+ @Override
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (obj instanceof Multipart) {
diff --git a/current/src/main/java/com/sun/mail/handlers/text_html.java b/current/src/main/java/com/sun/mail/handlers/text_html.java
index 55a20ab..dd14a07 100644
--- a/current/src/main/java/com/sun/mail/handlers/text_html.java
+++ b/current/src/main/java/com/sun/mail/handlers/text_html.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -51,6 +51,7 @@
new ActivationDataFlavor(String.class, "text/html", "HTML String")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return myDF;
}
diff --git a/current/src/main/java/com/sun/mail/handlers/text_plain.java b/current/src/main/java/com/sun/mail/handlers/text_plain.java
index 8550725..93f0275 100644
--- a/current/src/main/java/com/sun/mail/handlers/text_plain.java
+++ b/current/src/main/java/com/sun/mail/handlers/text_plain.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -62,15 +62,18 @@
super(os);
}
+ @Override
public void close() {
// do nothing
}
}
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return myDF;
}
+ @Override
public Object getContent(DataSource ds) throws IOException {
String enc = null;
InputStreamReader is = null;
@@ -121,6 +124,7 @@
/**
* Write the object to the output stream, using the specified MIME type.
*/
+ @Override
public void writeTo(Object obj, String type, OutputStream os)
throws IOException {
if (!(obj instanceof String))
diff --git a/current/src/main/java/com/sun/mail/handlers/text_xml.java b/current/src/main/java/com/sun/mail/handlers/text_xml.java
index dc71932..64438b1 100644
--- a/current/src/main/java/com/sun/mail/handlers/text_xml.java
+++ b/current/src/main/java/com/sun/mail/handlers/text_xml.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -69,10 +69,12 @@
new ActivationDataFlavor(StreamSource.class, "application/xml", "XML")
};
+ @Override
protected ActivationDataFlavor[] getDataFlavors() {
return flavors;
}
+ @Override
protected Object getData(ActivationDataFlavor aFlavor, DataSource ds)
throws IOException {
if (aFlavor.getRepresentationClass() == String.class)
@@ -85,6 +87,7 @@
/**
*/
+ @Override
public void writeTo(Object obj, String mimeType, OutputStream os)
throws IOException {
if (!isXmlType(mimeType))
diff --git a/current/src/main/java/com/sun/mail/iap/Argument.java b/current/src/main/java/com/sun/mail/iap/Argument.java
index b009f09..15d190f 100644
--- a/current/src/main/java/com/sun/mail/iap/Argument.java
+++ b/current/src/main/java/com/sun/mail/iap/Argument.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -43,7 +43,9 @@
import java.util.List;
import java.util.ArrayList;
import java.io.*;
-import com.sun.mail.util.*;
+import java.nio.charset.Charset;
+
+import com.sun.mail.util.ASCIIUtility;
/**
* @author John Mani
@@ -57,7 +59,7 @@
* Constructor
*/
public Argument() {
- items = new ArrayList<Object>(1);
+ items = new ArrayList<>(1);
}
/**
@@ -107,6 +109,23 @@
}
/**
+ * Convert the given string into bytes in the specified
+ * charset, and write the bytes out as an ASTRING
+ *
+ * @param s String to write out
+ * @param charset the charset
+ * @return this
+ * @since JavaMail 1.6.0
+ */
+ public Argument writeString(String s, Charset charset) {
+ if (charset == null) // convenience
+ writeString(s);
+ else
+ items.add(new AString(s.getBytes(charset)));
+ return this;
+ }
+
+ /**
* Write out given string as an NSTRING, depending on the type
* of the characters inside the string. The string should
* contain only ASCII characters. <p>
@@ -145,6 +164,25 @@
}
/**
+ * Convert the given string into bytes in the specified
+ * charset, and write the bytes out as an NSTRING
+ *
+ * @param s String to write out
+ * @param charset the charset
+ * @return this
+ * @since JavaMail 1.6.0
+ */
+ public Argument writeNString(String s, Charset charset) {
+ if (s == null)
+ items.add(new NString(null));
+ else if (charset == null) // convenience
+ writeString(s);
+ else
+ items.add(new NString(s.getBytes(charset)));
+ return this;
+ }
+
+ /**
* Write out given byte[] as a Literal.
* @param b byte[] to write out
* @return this
@@ -286,17 +324,20 @@
// if 0 length, send as quoted-string
boolean quote = len == 0 ? true : doQuote;
boolean escape = false;
-
+ boolean utf8 = protocol.supportsUtf8();
+
byte b;
for (int i = 0; i < len; i++) {
b = bytes[i];
- if (b == '\0' || b == '\r' || b == '\n' || ((b & 0xff) > 0177)) {
+ if (b == '\0' || b == '\r' || b == '\n' ||
+ (!utf8 && ((b & 0xff) > 0177))) {
// NUL, CR or LF means the bytes need to be sent as literals
literal(bytes, protocol);
return;
}
if (b == '*' || b == '%' || b == '(' || b == ')' || b == '{' ||
- b == '"' || b == '\\' || ((b & 0xff) <= ' ')) {
+ b == '"' || b == '\\' ||
+ ((b & 0xff) <= ' ') || ((b & 0xff) > 0177)) {
quote = true;
if (b == '"' || b == '\\') // need to escape these characters
escape = true;
diff --git a/current/src/main/java/com/sun/mail/iap/BadCommandException.java b/current/src/main/java/com/sun/mail/iap/BadCommandException.java
index 132b591..dde7b5b 100644
--- a/current/src/main/java/com/sun/mail/iap/BadCommandException.java
+++ b/current/src/main/java/com/sun/mail/iap/BadCommandException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/ByteArray.java b/current/src/main/java/com/sun/mail/iap/ByteArray.java
index 9ba324f..bf8ce60 100644
--- a/current/src/main/java/com/sun/mail/iap/ByteArray.java
+++ b/current/src/main/java/com/sun/mail/iap/ByteArray.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/CommandFailedException.java b/current/src/main/java/com/sun/mail/iap/CommandFailedException.java
index 45b55c3..aeb630c 100644
--- a/current/src/main/java/com/sun/mail/iap/CommandFailedException.java
+++ b/current/src/main/java/com/sun/mail/iap/CommandFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/ConnectionException.java b/current/src/main/java/com/sun/mail/iap/ConnectionException.java
index 1d8bd86..187b852 100644
--- a/current/src/main/java/com/sun/mail/iap/ConnectionException.java
+++ b/current/src/main/java/com/sun/mail/iap/ConnectionException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/Literal.java b/current/src/main/java/com/sun/mail/iap/Literal.java
index ea87454..44706b0 100644
--- a/current/src/main/java/com/sun/mail/iap/Literal.java
+++ b/current/src/main/java/com/sun/mail/iap/Literal.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/LiteralException.java b/current/src/main/java/com/sun/mail/iap/LiteralException.java
index 7da25ba..ff12d49 100644
--- a/current/src/main/java/com/sun/mail/iap/LiteralException.java
+++ b/current/src/main/java/com/sun/mail/iap/LiteralException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/ParsingException.java b/current/src/main/java/com/sun/mail/iap/ParsingException.java
index 6e73f21..c947609 100644
--- a/current/src/main/java/com/sun/mail/iap/ParsingException.java
+++ b/current/src/main/java/com/sun/mail/iap/ParsingException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/Protocol.java b/current/src/main/java/com/sun/mail/iap/Protocol.java
index fa03931..bed9ef0 100644
--- a/current/src/main/java/com/sun/mail/iap/Protocol.java
+++ b/current/src/main/java/com/sun/mail/iap/Protocol.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,18 +44,24 @@
import java.io.*;
import java.nio.channels.SocketChannel;
import java.net.*;
-import java.util.logging.Level;
import javax.net.ssl.SSLSocket;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Level;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
-import com.sun.mail.util.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.SocketFetcher;
+import com.sun.mail.util.TraceInputStream;
+import com.sun.mail.util.TraceOutputStream;
/**
* General protocol handling code for IMAP-like protocols. <p>
@@ -84,14 +90,18 @@
private volatile DataOutputStream output;
private int tagCounter = 0;
+ private final String tagPrefix;
private String localHostName;
private final List<ResponseHandler> handlers
- = new CopyOnWriteArrayList<ResponseHandler>();
+ = new CopyOnWriteArrayList<>();
private volatile long timestamp;
+ // package private, to allow testing
+ static final AtomicInteger tagNum = new AtomicInteger();
+
private static final byte[] CRLF = { (byte)'\r', (byte)'\n'};
/**
@@ -113,6 +123,7 @@
boolean isSSL, MailLogger logger)
throws IOException, ProtocolException {
boolean connected = false; // did constructor succeed?
+ tagPrefix = computePrefix(props, prefix);
try {
this.host = host;
this.props = props;
@@ -156,6 +167,35 @@
}
/**
+ * Compute the tag prefix to be used for this connection.
+ * Start with "A" - "Z", then "AA" - "ZZ", and finally "AAA" - "ZZZ".
+ * Wrap around after that.
+ */
+ private String computePrefix(Properties props, String prefix) {
+ // XXX - in case someone depends on the tag prefix
+ if (PropUtil.getBooleanProperty(props,
+ prefix + ".reusetagprefix", false))
+ return "A";
+ // tag prefix, wrap around after three letters
+ int n = tagNum.getAndIncrement() % (26*26*26 + 26*26 + 26);
+ String tagPrefix;
+ if (n < 26)
+ tagPrefix = new String(new char[] { (char)('A' + n) });
+ else if (n < (26*26 + 26)) {
+ n -= 26;
+ tagPrefix = new String(new char[] {
+ (char)('A' + n/26), (char)('A' + n%26) });
+ } else {
+ n -= (26*26 + 26);
+ tagPrefix = new String(new char[] {
+ (char)('A' + n/(26*26)),
+ (char)('A' + (n%(26*26))/26),
+ (char)('A' + n%26) });
+ }
+ return tagPrefix;
+ }
+
+ /**
* Constructor for debugging.
*
* @param in the InputStream to read from
@@ -169,6 +209,7 @@
this.host = "localhost";
this.props = props;
this.quote = false;
+ tagPrefix = computePrefix(props, "mail.imap");
logger = new MailLogger(this.getClass(), "DEBUG", debug, System.out);
traceLogger = logger.getSubLogger("protocol", null);
@@ -306,7 +347,7 @@
throws IOException, ProtocolException {
// assert Thread.holdsLock(this);
// can't assert because it's called from constructor
- String tag = "A" + Integer.toString(tagCounter++, 10); // unique tag
+ String tag = tagPrefix + Integer.toString(tagCounter++); // unique tag
output.writeBytes(tag + " " + command);
@@ -331,10 +372,9 @@
*/
public synchronized Response[] command(String command, Argument args) {
commandStart(command);
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
boolean done = false;
String tag = null;
- Response r = null;
// write the command
try {
@@ -350,13 +390,14 @@
Response byeResp = null;
while (!done) {
+ Response r = null;
try {
r = readResponse();
} catch (IOException ioex) {
- if (byeResp != null) // connection closed after BYE was sent
- break;
- // convert this into a BYE response
- r = Response.byeResponse(ioex);
+ if (byeResp == null) // convert this into a BYE response
+ byeResp = Response.byeResponse(ioex);
+ // else, connection closed after BYE was sent
+ break;
} catch (ProtocolException pex) {
logger.log(Level.FINE, "ignoring bad response", pex);
continue; // skip this response
@@ -453,21 +494,6 @@
*/
public synchronized void startCompression(String cmd)
throws IOException, ProtocolException {
- /*
- * The Deflator.SYNC_FLUSH support requires JDK 1.7 so use
- * reflection to allow compiling on 1.5 but running on 1.7.
- */
- Class<DeflaterOutputStream> dc = DeflaterOutputStream.class;
- Constructor<DeflaterOutputStream> cons = null;
- try {
- cons = dc.getConstructor(
- OutputStream.class, Deflater.class, boolean.class);
- } catch (NoSuchMethodException ex) {
- logger.fine("Ignoring COMPRESS; " +
- "missing JDK 1.7 DeflaterOutputStream constructor");
- return; // ignore request, just as if server doesn't support it
- }
-
// XXX - check whether compression is already enabled?
simpleCommand(cmd, null);
@@ -499,14 +525,8 @@
} catch (IllegalArgumentException ex) {
logger.log(Level.FINE, "Ignoring bad compression strategy", ex);
}
- //traceOutput = new TraceOutputStream(new DeflaterOutputStream(
- // socket.getOutputStream(), def, true), traceLogger);
- try {
- traceOutput = new TraceOutputStream(cons.newInstance(
+ traceOutput = new TraceOutputStream(new DeflaterOutputStream(
socket.getOutputStream(), def, true), traceLogger);
- } catch (Exception ex) {
- throw new ProtocolException("can't create deflater", ex);
- }
traceOutput.setQuote(quote);
output = new DataOutputStream(new BufferedOutputStream(traceOutput));
}
@@ -538,7 +558,35 @@
* @since JavaMail 1.5.2
*/
public SocketChannel getChannel() {
- return socket.getChannel();
+ SocketChannel ret = socket.getChannel();
+ if (ret != null)
+ return ret;
+
+ // XXX - Android is broken and SSL wrapped sockets don't delegate
+ // the getChannel method to the wrapped Socket
+ if (socket instanceof SSLSocket) {
+ try {
+ Field f = socket.getClass().getDeclaredField("socket");
+ f.setAccessible(true);
+ Socket s = (Socket)f.get(socket);
+ ret = s.getChannel();
+ } catch (Exception ex) {
+ // ignore anything that might go wrong
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Does the server support UTF-8?
+ * This implementation returns false.
+ * Subclasses should override as appropriate.
+ *
+ * @return true if the server supports UTF-8
+ * @since JavaMail 1.6.0
+ */
+ public boolean supportsUtf8() {
+ return false;
}
/**
@@ -630,6 +678,7 @@
/**
* Finalizer.
*/
+ @Override
protected void finalize() throws Throwable {
try {
disconnect();
diff --git a/current/src/main/java/com/sun/mail/iap/ProtocolException.java b/current/src/main/java/com/sun/mail/iap/ProtocolException.java
index cd33449..b7e366a 100644
--- a/current/src/main/java/com/sun/mail/iap/ProtocolException.java
+++ b/current/src/main/java/com/sun/mail/iap/ProtocolException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/Response.java b/current/src/main/java/com/sun/mail/iap/Response.java
index f1c5b60..0225d9a 100644
--- a/current/src/main/java/com/sun/mail/iap/Response.java
+++ b/current/src/main/java/com/sun/mail/iap/Response.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -42,13 +42,16 @@
import java.io.*;
import java.util.*;
-import com.sun.mail.util.*;
+import java.nio.charset.StandardCharsets;
+
+import com.sun.mail.util.ASCIIUtility;
/**
* This class represents a response obtained from the input stream
* of an IMAP server.
*
- * @author John Mani
+ * @author John Mani
+ * @author Bill Shannon
*/
public class Response {
@@ -60,6 +63,7 @@
protected String tag = null;
/** @since JavaMail 1.5.4 */
protected Exception ex;
+ protected boolean utf8;
private static final int increment = 100;
@@ -96,8 +100,23 @@
private static String ASTRING_CHAR_DELIM = " (){%*\"\\";
public Response(String s) {
- buffer = ASCIIUtility.getBytes(s);
+ this(s, true);
+ }
+
+ /**
+ * Constructor for testing.
+ *
+ * @param s the response string
+ * @param supportsUtf8 allow UTF-8 in response?
+ * @since JavaMail 1.6.0
+ */
+ public Response(String s, boolean supportsUtf8) {
+ if (supportsUtf8)
+ buffer = s.getBytes(StandardCharsets.UTF_8);
+ else
+ buffer = s.getBytes(StandardCharsets.US_ASCII);
size = buffer.length;
+ utf8 = supportsUtf8;
parse();
}
@@ -114,6 +133,7 @@
ByteArray response = p.getInputStream().readResponse(ba);
buffer = response.getBytes();
size = response.getCount() - 2; // Skip the terminating CRLF
+ utf8 = p.supportsUtf8();
parse();
}
@@ -125,10 +145,13 @@
*/
public Response(Response r) {
index = r.index;
+ pindex = r.pindex;
size = r.size;
buffer = r.buffer;
type = r.type;
tag = r.tag;
+ ex = r.ex;
+ utf8 = r.utf8;
}
/**
@@ -147,6 +170,16 @@
return r;
}
+ /**
+ * Does the server support UTF-8?
+ *
+ * @return true if the server supports UTF-8
+ * @since JavaMail 1.6.0
+ */
+ public boolean supportsUtf8() {
+ return utf8;
+ }
+
private void parse() {
index = 0; // position internal index at start
@@ -191,6 +224,23 @@
}
/**
+ * Skip past any spaces. If the next non-space character is c,
+ * consume it and return true. Otherwise stop at that point
+ * and return false.
+ *
+ * @param c the character to look for
+ * @return true if the character is found
+ */
+ public boolean isNextNonSpace(char c) {
+ skipSpaces();
+ if (index < size && buffer[index] == (byte)c) {
+ index++;
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Skip to the next space, for use in error recovery while parsing.
*/
public void skipToken() {
@@ -241,13 +291,13 @@
if (index >= size) // already at end of response
return null;
- byte b;
+ int b;
int start = index;
- while (index < size && ((b = buffer[index]) > ' ') &&
- delim.indexOf((char)b) < 0 && b >= ' ' && b != 0x7f)
+ while (index < size && ((b = (((int)buffer[index])&0xff)) >= ' ') &&
+ delim.indexOf((char)b) < 0 && b != 0x7f)
index++;
- return ASCIIUtility.toString(buffer, start, index);
+ return toString(buffer, start, index);
}
/**
@@ -268,7 +318,7 @@
while (index < size && buffer[index] != delim)
index++;
- return ASCIIUtility.toString(buffer, start, index);
+ return toString(buffer, start, index);
}
public String[] readStringList() {
@@ -287,14 +337,15 @@
}
index++; // skip '('
- List<String> result = new ArrayList<String>();
- skipSpaces();
- if (peekByte() != ')') {
- do {
- result.add(atom ? readAtomString() : readString());
- } while (index < size && buffer[index++] != ')');
- } else
- index++; // skip ')'
+ // to handle buggy IMAP servers, we tolerate multiple spaces as
+ // well as spaces after the left paren or before the right paren
+ List<String> result = new ArrayList<>();
+ while (!isNextNonSpace(')')) {
+ String s = atom ? readAtomString() : readString();
+ if (s == null) // not the expected string or atom
+ break;
+ result.add(s);
+ }
return result.toArray(new String[result.size()]);
}
@@ -447,7 +498,7 @@
index++; // skip past the terminating quote
if (returnString)
- return ASCIIUtility.toString(buffer, start, copyto);
+ return toString(buffer, start, copyto);
else
return new ByteArray(buffer, start, copyto-start);
} else if (b == '{') { // Literal
@@ -468,7 +519,7 @@
index = start + count; // position index to beyond the literal
if (returnString) // return as String
- return ASCIIUtility.toString(buffer, start, start + count);
+ return toString(buffer, start, start + count);
else
return new ByteArray(buffer, start, count);
} else if (parseAtoms) { // parse as ASTRING-CHARs
@@ -486,6 +537,12 @@
return null; // Error
}
+ private String toString(byte[] buffer, int start, int end) {
+ return utf8 ?
+ new String(buffer, start, end - start, StandardCharsets.UTF_8) :
+ ASCIIUtility.toString(buffer, start, end);
+ }
+
public int getType() {
return type;
}
@@ -539,7 +596,7 @@
*/
public String getRest() {
skipSpaces();
- return ASCIIUtility.toString(buffer, index, size);
+ return toString(buffer, index, size);
}
/**
@@ -559,8 +616,9 @@
index = pindex;
}
+ @Override
public String toString() {
- return ASCIIUtility.toString(buffer, 0, size);
+ return toString(buffer, 0, size);
}
}
diff --git a/current/src/main/java/com/sun/mail/iap/ResponseHandler.java b/current/src/main/java/com/sun/mail/iap/ResponseHandler.java
index 0b3685a..54448cf 100644
--- a/current/src/main/java/com/sun/mail/iap/ResponseHandler.java
+++ b/current/src/main/java/com/sun/mail/iap/ResponseHandler.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/iap/ResponseInputStream.java b/current/src/main/java/com/sun/mail/iap/ResponseInputStream.java
index 9e0ecde..96cca2d 100644
--- a/current/src/main/java/com/sun/mail/iap/ResponseInputStream.java
+++ b/current/src/main/java/com/sun/mail/iap/ResponseInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -58,8 +58,8 @@
private static final int maxIncrement = 256 * 1024;
private static final int incrementSlop = 16;
- private final int inputStreamBufferMaxSize =
- Integer.getInteger("com.sun.mail.iap.inputStreamBufferMaxSize", 0);
+ private final int inputStreamBufferMaxSize =
+ Integer.getInteger("com.sun.mail.iap.inputStreamBufferMaxSize", 0);
// where we read from
private BufferedInputStream bin;
@@ -193,4 +193,4 @@
}
ba.grow(incr);
}
-}
+}
\ No newline at end of file
diff --git a/current/src/main/java/com/sun/mail/imap/ACL.java b/current/src/main/java/com/sun/mail/imap/ACL.java
index 25e94af..5730b80 100644
--- a/current/src/main/java/com/sun/mail/imap/ACL.java
+++ b/current/src/main/java/com/sun/mail/imap/ACL.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -109,6 +109,7 @@
/**
* Clone this ACL entry.
*/
+ @Override
public Object clone() throws CloneNotSupportedException {
ACL acl = (ACL)super.clone();
acl.rights = (Rights)this.rights.clone();
diff --git a/current/src/main/java/com/sun/mail/imap/AppendUID.java b/current/src/main/java/com/sun/mail/imap/AppendUID.java
index 397e8ab..78d46b2 100644
--- a/current/src/main/java/com/sun/mail/imap/AppendUID.java
+++ b/current/src/main/java/com/sun/mail/imap/AppendUID.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/CopyUID.java b/current/src/main/java/com/sun/mail/imap/CopyUID.java
index b8e3bda..d4ac723 100644
--- a/current/src/main/java/com/sun/mail/imap/CopyUID.java
+++ b/current/src/main/java/com/sun/mail/imap/CopyUID.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/DefaultFolder.java b/current/src/main/java/com/sun/mail/imap/DefaultFolder.java
index 4d394f2..2218ba4 100644
--- a/current/src/main/java/com/sun/mail/imap/DefaultFolder.java
+++ b/current/src/main/java/com/sun/mail/imap/DefaultFolder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -40,11 +40,13 @@
package com.sun.mail.imap;
-import javax.mail.*;
-import javax.mail.internet.*;
-import com.sun.mail.util.*;
-import com.sun.mail.iap.*;
-import com.sun.mail.imap.protocol.*;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.MethodNotSupportedException;
+import com.sun.mail.iap.ProtocolException;
+import com.sun.mail.imap.protocol.IMAPProtocol;
+import com.sun.mail.imap.protocol.ListInfo;
/**
* The default IMAP folder (root of the naming hierarchy).
@@ -60,19 +62,23 @@
type = HOLDS_FOLDERS; // obviously
}
+ @Override
public synchronized String getName() {
return fullName;
}
+ @Override
public Folder getParent() {
return null;
}
+ @Override
public synchronized Folder[] list(final String pattern)
throws MessagingException {
ListInfo[] li = null;
li = (ListInfo[])doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
return p.list("", pattern);
}
@@ -87,11 +93,13 @@
return folders;
}
+ @Override
public synchronized Folder[] listSubscribed(final String pattern)
throws MessagingException {
ListInfo[] li = null;
li = (ListInfo[])doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
return p.lsub("", pattern);
}
@@ -106,30 +114,36 @@
return folders;
}
+ @Override
public boolean hasNewMessages() throws MessagingException {
// Not applicable on DefaultFolder
return false;
}
+ @Override
public Folder getFolder(String name) throws MessagingException {
return ((IMAPStore)store).newIMAPFolder(name, UNKNOWN_SEPARATOR);
}
+ @Override
public boolean delete(boolean recurse) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot delete Default Folder");
}
+ @Override
public boolean renameTo(Folder f) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot rename Default Folder");
}
+ @Override
public void appendMessages(Message[] msgs) throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot append to Default Folder");
}
+ @Override
public Message[] expunge() throws MessagingException {
// Not applicable on DefaultFolder
throw new MethodNotSupportedException("Cannot expunge Default Folder");
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPBodyPart.java b/current/src/main/java/com/sun/mail/imap/IMAPBodyPart.java
index 5d871fc..416a0f4 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPBodyPart.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPBodyPart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -47,7 +47,10 @@
import javax.mail.internet.*;
import javax.activation.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.ReadableMime;
+import com.sun.mail.util.LineOutputStream;
+import com.sun.mail.util.SharedByteArrayOutputStream;
import com.sun.mail.iap.*;
import com.sun.mail.imap.protocol.*;
@@ -87,46 +90,57 @@
* be inserted in newly crafted MimeMessages, especially when
* forwarding or replying to messages.
*/
+ @Override
protected void updateHeaders() {
return;
}
+ @Override
public int getSize() throws MessagingException {
return bs.size;
}
+ @Override
public int getLineCount() throws MessagingException {
return bs.lines;
}
+ @Override
public String getContentType() throws MessagingException {
return type;
}
+ @Override
public String getDisposition() throws MessagingException {
return bs.disposition;
}
+ @Override
public void setDisposition(String disposition) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public String getEncoding() throws MessagingException {
return bs.encoding;
}
+ @Override
public String getContentID() throws MessagingException {
return bs.id;
}
+ @Override
public String getContentMD5() throws MessagingException {
return bs.md5;
}
+ @Override
public void setContentMD5(String md5) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public String getDescription() throws MessagingException {
if (description != null) // cached value ?
return description;
@@ -143,16 +157,18 @@
return description;
}
+ @Override
public void setDescription(String description, String charset)
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public String getFileName() throws MessagingException {
String filename = null;
if (bs.dParams != null)
filename = bs.dParams.get("filename");
- if (filename == null && bs.cParams != null)
+ if ((filename == null || filename.isEmpty()) && bs.cParams != null)
filename = bs.cParams.get("name");
if (decodeFileName && filename != null) {
try {
@@ -164,10 +180,12 @@
return filename;
}
+ @Override
public void setFileName(String filename) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
protected InputStream getContentStream() throws MessagingException {
InputStream is = null;
boolean pk = message.getPeek(); // acquire outside of message cache lock
@@ -202,10 +220,15 @@
}
}
- if (is == null)
- throw new MessagingException("No content");
- else
- return is;
+ if (is == null) {
+ message.forceCheckExpunged(); // may throw MessageRemovedException
+ // nope, the server doesn't think it's expunged.
+ // can't tell the difference between the server returning NIL
+ // and some other error that caused null to be returned above,
+ // so we'll just assume it was empty content.
+ is = new ByteArrayInputStream(new byte[0]);
+ }
+ return is;
}
/**
@@ -243,7 +266,6 @@
try {
// Write out the header
- @SuppressWarnings("unchecked")
Enumeration<String> hdrLines
= super.getAllHeaderLines();
while (hdrLines.hasMoreElements())
@@ -275,6 +297,7 @@
* @return the MIME format stream
* @since JavaMail 1.4.5
*/
+ @Override
public InputStream getMimeStream() throws MessagingException {
/*
* The IMAP protocol doesn't support returning the entire
@@ -284,6 +307,7 @@
return new SequenceInputStream(getHeaderStream(), getContentStream());
}
+ @Override
public synchronized DataHandler getDataHandler()
throws MessagingException {
if (dh == null) {
@@ -305,75 +329,83 @@
return super.getDataHandler();
}
+ @Override
public void setDataHandler(DataHandler content) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public void setContent(Object o, String type) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public void setContent(Multipart mp) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public String[] getHeader(String name) throws MessagingException {
loadHeaders();
return super.getHeader(name);
}
+ @Override
public void setHeader(String name, String value)
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public void addHeader(String name, String value)
throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
+ @Override
public void removeHeader(String name) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getAllHeaders() throws MessagingException {
loadHeaders();
return super.getAllHeaders();
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getMatchingHeaders(String[] names)
throws MessagingException {
loadHeaders();
return super.getMatchingHeaders(names);
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getNonMatchingHeaders(String[] names)
throws MessagingException {
loadHeaders();
return super.getNonMatchingHeaders(names);
}
+ @Override
public void addHeaderLine(String line) throws MessagingException {
throw new IllegalWriteException("IMAPBodyPart is read-only");
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getAllHeaderLines() throws MessagingException {
loadHeaders();
return super.getAllHeaderLines();
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException {
loadHeaders();
return super.getMatchingHeaderLines(names);
}
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException {
loadHeaders();
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPFolder.java b/current/src/main/java/com/sun/mail/imap/IMAPFolder.java
index b801459..058ad56 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPFolder.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPFolder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -58,7 +58,9 @@
import javax.mail.internet.*;
import javax.mail.search.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.CRLFOutputStream;
import com.sun.mail.iap.*;
import com.sun.mail.imap.protocol.*;
@@ -276,6 +278,7 @@
// the server
private long uidvalidity = -1; // UIDValidity
private long uidnext = -1; // UIDNext
+ private boolean uidNotSticky = false; // RFC 4315
private volatile long highestmodseq = -1; // RFC 4551 - CONDSTORE
private boolean doExpungeNotification = true; // used in expunge handler
@@ -393,8 +396,8 @@
throw new NullPointerException("Folder name is null");
this.fullName = fullName;
this.separator = separator;
- logger = new MailLogger(this.getClass(),
- "DEBUG IMAP", store.getSession());
+ logger = new MailLogger(this.getClass(), "DEBUG IMAP",
+ store.getSession().getDebug(), store.getSession().getDebugOut());
connectionPoolLogger = store.getConnectionPoolLogger();
/*
@@ -534,6 +537,7 @@
/**
* Get the name of this folder.
*/
+ @Override
public synchronized String getName() {
/* Return the last component of this Folder's full name.
* Folder components are delimited by the separator character.
@@ -551,6 +555,7 @@
/**
* Get the fullname of this folder.
*/
+ @Override
public String getFullName() {
return fullName;
}
@@ -558,6 +563,7 @@
/**
* Get this folder's parent.
*/
+ @Override
public synchronized Folder getParent() throws MessagingException {
char c = getSeparator();
int index;
@@ -571,6 +577,7 @@
/**
* Check whether this folder really exists on the server.
*/
+ @Override
public synchronized boolean exists() throws MessagingException {
// Check whether this folder exists ..
ListInfo[] li = null;
@@ -581,6 +588,7 @@
lname = fullName;
li = (ListInfo[])doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
return p.list("", lname);
}
@@ -634,6 +642,7 @@
/**
* List all subfolders matching the specified pattern.
*/
+ @Override
public Folder[] list(String pattern) throws MessagingException {
return doList(pattern, false);
}
@@ -641,6 +650,7 @@
/**
* List all subscribed subfolders matching the specified pattern.
*/
+ @Override
public Folder[] listSubscribed(String pattern) throws MessagingException {
return doList(pattern, true);
}
@@ -657,6 +667,7 @@
ListInfo[] li = (ListInfo[])doCommandIgnoreFailure(
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
if (subscribed)
@@ -695,11 +706,13 @@
/**
* Get the separator character.
*/
+ @Override
public synchronized char getSeparator() throws MessagingException {
if (separator == UNKNOWN_SEPARATOR) {
ListInfo[] li = null;
li = (ListInfo[])doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
// REV1 allows the following LIST format to obtain
@@ -723,6 +736,7 @@
/**
* Get the type of this folder.
*/
+ @Override
public synchronized int getType() throws MessagingException {
if (opened) {
// never throw FolderNotFoundException if folder is open
@@ -737,6 +751,7 @@
/**
* Check whether this folder is subscribed.
*/
+ @Override
public synchronized boolean isSubscribed() {
ListInfo[] li = null;
final String lname;
@@ -747,6 +762,7 @@
try {
li = (ListInfo[])doProtocolCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.lsub("", lname);
@@ -765,9 +781,11 @@
/**
* Subscribe/Unsubscribe this folder.
*/
+ @Override
public synchronized void setSubscribed(final boolean subscribe)
throws MessagingException {
doCommandIgnoreFailure(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
if (subscribe)
p.subscribe(fullName);
@@ -781,6 +799,7 @@
/**
* Create this folder, with the specified type.
*/
+ @Override
public synchronized boolean create(final int type)
throws MessagingException {
@@ -789,6 +808,7 @@
c = getSeparator();
final char sep = c;
Object ret = doCommandIgnoreFailure(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
if ((type & HOLDS_MESSAGES) == 0) // only holds folders
@@ -831,6 +851,7 @@
/**
* Check whether this folder has new messages.
*/
+ @Override
public synchronized boolean hasNewMessages() throws MessagingException {
synchronized (messageCacheLock) {
if (opened) { // If we are open, we already have this information
@@ -857,6 +878,7 @@
else
lname = fullName;
li = (ListInfo[])doCommandIgnoreFailure(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
return p.list("", lname);
}
@@ -892,6 +914,7 @@
/**
* Get the named subfolder.
*/
+ @Override
public synchronized Folder getFolder(String name)
throws MessagingException {
// If we know that this folder is *not* a directory, don't
@@ -906,6 +929,7 @@
/**
* Delete this folder.
*/
+ @Override
public synchronized boolean delete(boolean recurse)
throws MessagingException {
checkClosed(); // insure that this folder is closed.
@@ -920,6 +944,7 @@
// Attempt to delete this folder
Object ret = doCommandIgnoreFailure(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
p.delete(fullName);
return Boolean.TRUE;
@@ -942,6 +967,7 @@
/**
* Rename this folder.
*/
+ @Override
public synchronized boolean renameTo(final Folder f)
throws MessagingException {
checkClosed(); // insure that we are closed.
@@ -951,6 +977,7 @@
Object ret = doCommandIgnoreFailure(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p) throws ProtocolException {
p.rename(fullName, f.getFullName());
return Boolean.TRUE;
@@ -969,6 +996,7 @@
/**
* Open this folder in the given mode.
*/
+ @Override
public synchronized void open(int mode) throws MessagingException {
open(mode, null);
}
@@ -1056,12 +1084,9 @@
} catch (ProtocolException pex) {
// got a BAD or a BYE; connection may be bad, close it
try {
- protocol.logout();
- } catch (ProtocolException pex2) {
- // ignore
+ throw logoutAndThrow(pex.getMessage(), pex);
} finally {
releaseProtocol(false);
- throw new MessagingException(pex.getMessage(), pex);
}
}
@@ -1070,24 +1095,9 @@
((IMAPStore)store).allowReadOnlySelect()) {
; // all ok, allow it
} else { // otherwise, it's an error
- try {
- // close mailbox and return connection
- protocol.close();
- releaseProtocol(true);
- } catch (ProtocolException pex) {
- // something went wrong, close connection
- try {
- protocol.logout();
- } catch (ProtocolException pex2) {
- // ignore
- } finally {
- releaseProtocol(false);
- }
- } finally {
- throw new ReadOnlyFolderException(this,
- "Cannot open in desired mode");
- }
-
+ ReadOnlyFolderException ife = new ReadOnlyFolderException(
+ this, "Cannot open in desired mode");
+ throw cleanupAndThrow(ife);
}
}
@@ -1101,6 +1111,7 @@
recent = mi.recent;
uidvalidity = mi.uidvalidity;
uidnext = mi.uidnext;
+ uidNotSticky = mi.uidNotSticky;
highestmodseq = mi.highestmodseq;
// Create the message cache of appropriate size
@@ -1108,7 +1119,7 @@
// process saved responses and return corresponding events
if (mi.responses != null) {
- openEvents = new ArrayList<MailEvent>();
+ openEvents = new ArrayList<>();
for (IMAPResponse ir : mi.responses) {
if (ir.keyEquals("VANISHED")) {
// "VANISHED" SP ["(EARLIER)"] SP known-uids
@@ -1145,9 +1156,59 @@
return openEvents;
}
+ private MessagingException cleanupAndThrow(MessagingException ife) {
+ try {
+ try {
+ // close mailbox and return connection
+ protocol.close();
+ releaseProtocol(true);
+ } catch (ProtocolException pex) {
+ // something went wrong, close connection
+ try {
+ addSuppressed(ife, logoutAndThrow(pex.getMessage(), pex));
+ } finally {
+ releaseProtocol(false);
+ }
+ }
+ } catch (Throwable thr) {
+ addSuppressed(ife, thr);
+ }
+ return ife;
+ }
+
+ private MessagingException logoutAndThrow(String why, ProtocolException t) {
+ MessagingException ife = new MessagingException(why, t);
+ try {
+ protocol.logout();
+ } catch (Throwable thr) {
+ addSuppressed(ife, thr);
+ }
+ return ife;
+ }
+
+ private void addSuppressed(Throwable ife, Throwable thr) {
+ if (isRecoverable(thr)) {
+ ife.addSuppressed(thr);
+ } else {
+ thr.addSuppressed(ife);
+ if (thr instanceof Error) {
+ throw (Error) thr;
+ }
+ if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
+ }
+ throw new RuntimeException("unexpected exception", thr);
+ }
+ }
+
+ private boolean isRecoverable(Throwable t) {
+ return (t instanceof Exception) || (t instanceof LinkageError);
+ }
+
/**
* Prefetch attributes, based on the given FetchProfile.
*/
+ @Override
public synchronized void fetch(Message[] msgs, FetchProfile fp)
throws MessagingException {
// cache this information in case connection is closed and
@@ -1160,7 +1221,7 @@
fitems = protocol.getFetchItems();
}
- StringBuffer command = new StringBuffer();
+ StringBuilder command = new StringBuilder();
boolean first = true;
boolean allHeaders = false;
@@ -1248,7 +1309,7 @@
Response[] r = null;
// to collect non-FETCH responses & unsolicited FETCH FLAG responses
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
try {
r = getProtocol().fetch(msgsets, command.toString());
} catch (ConnectionException cex) {
@@ -1339,12 +1400,12 @@
* requested headers.
*/
private String createHeaderCommand(String[] hdrs, boolean isRev1) {
- StringBuffer sb;
+ StringBuilder sb;
if (isRev1)
- sb = new StringBuffer("BODY.PEEK[HEADER.FIELDS (");
+ sb = new StringBuilder("BODY.PEEK[HEADER.FIELDS (");
else
- sb = new StringBuffer("RFC822.HEADER.LINES (");
+ sb = new StringBuilder("RFC822.HEADER.LINES (");
for (int i = 0; i < hdrs.length; i++) {
if (i > 0)
@@ -1363,6 +1424,7 @@
/**
* Set the specified flags for the given array of messages.
*/
+ @Override
public synchronized void setFlags(Message[] msgs, Flags flag, boolean value)
throws MessagingException {
checkOpened();
@@ -1390,6 +1452,7 @@
/**
* Set the specified flags for the given range of message numbers.
*/
+ @Override
public synchronized void setFlags(int start, int end,
Flags flag, boolean value) throws MessagingException {
checkOpened();
@@ -1403,6 +1466,7 @@
/**
* Set the specified flags for the given array of message numbers.
*/
+ @Override
public synchronized void setFlags(int[] msgnums, Flags flag, boolean value)
throws MessagingException {
checkOpened();
@@ -1415,6 +1479,7 @@
/**
* Close this folder.
*/
+ @Override
public synchronized void close(boolean expunge) throws MessagingException {
close(expunge, false);
}
@@ -1545,6 +1610,7 @@
/**
* Check whether this connection is really open.
*/
+ @Override
public synchronized boolean isOpen() {
synchronized(messageCacheLock) {
// Probe the connection to make sure its really open.
@@ -1561,6 +1627,7 @@
/**
* Return the permanent flags supported by the server.
*/
+ @Override
public synchronized Flags getPermanentFlags() {
if (permanentFlags == null)
return null;
@@ -1570,6 +1637,7 @@
/**
* Get the total message count.
*/
+ @Override
public synchronized int getMessageCount() throws MessagingException {
synchronized (messageCacheLock) {
if (opened) {
@@ -1618,6 +1686,7 @@
/**
* Get the new message count.
*/
+ @Override
public synchronized int getNewMessageCount() throws MessagingException {
synchronized (messageCacheLock) {
if (opened) {
@@ -1666,6 +1735,7 @@
/**
* Get the unread message count.
*/
+ @Override
public synchronized int getUnreadMessageCount()
throws MessagingException {
if (!opened) {
@@ -1707,6 +1777,7 @@
/**
* Get the deleted message count.
*/
+ @Override
public synchronized int getDeletedMessageCount()
throws MessagingException {
if (!opened) {
@@ -1764,6 +1835,7 @@
/**
* Get the specified message.
*/
+ @Override
public synchronized Message getMessage(int msgnum)
throws MessagingException {
checkOpened();
@@ -1792,6 +1864,7 @@
/**
* Append the given messages into this folder.
*/
+ @Override
public synchronized void appendMessages(Message[] msgs)
throws MessagingException {
checkExists(); // verify that self exists
@@ -1824,6 +1897,7 @@
}
doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
p.append(fullName, f, dd, mos);
@@ -1884,6 +1958,7 @@
final Date dd = d;
final Flags f = m.getFlags();
AppendUID auid = (AppendUID)doCommand(new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.appenduid(fullName, f, dd, mos);
@@ -1937,6 +2012,7 @@
* Copy the specified messages from this folder, to the
* specified destination.
*/
+ @Override
public synchronized void copyMessages(Message[] msgs, Folder folder)
throws MessagingException {
copymoveMessages(msgs, folder, false);
@@ -1968,7 +2044,7 @@
}
/**
- * Copy the specified messages from this folder, to the
+ * Move the specified messages from this folder, to the
* specified destination.
*
* Depends on the MOVE extension
@@ -1986,14 +2062,14 @@
}
/**
- * Copy the specified messages from this folder, to the
+ * Move the specified messages from this folder, to the
* specified destination.
* Return array of AppendUID objects containing
* UIDs of these messages in the destination folder.
* Each element of the returned array corresponds to
* an element of the <code>msgs</code> array. A null
* element means the server didn't return UID information
- * for the copied message. <p>
+ * for the moved message. <p>
*
* Depends on the MOVE extension
* (<A HREF="http://www.ietf.org/rfc/rfc6851.txt">RFC 6851</A>)
@@ -2001,8 +2077,8 @@
* UIDPLUS extension
* (<A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>).
*
- * @param msgs the messages to copy
- * @param folder the folder to copy the messages to
+ * @param msgs the messages to move
+ * @param folder the folder to move the messages to
* @return array of AppendUID objects
* @exception MessagingException for failures
* @since JavaMail 1.5.4
@@ -2197,6 +2273,7 @@
/**
* Expunge all messages marked as DELETED.
*/
+ @Override
public synchronized Message[] expunge() throws MessagingException {
return expunge(null);
}
@@ -2286,6 +2363,7 @@
* true and the search is too complex for the IMAP protocol
* @exception MessagingException for other failures
*/
+ @Override
public synchronized Message[] search(SearchTerm term)
throws MessagingException {
checkOpened();
@@ -2321,6 +2399,7 @@
* array of matching messages. Returns an empty array if no matching
* messages are found.
*/
+ @Override
public synchronized Message[] search(SearchTerm term, Message[] msgs)
throws MessagingException {
checkOpened();
@@ -2426,6 +2505,7 @@
* method. It's too hard to keep track of when all listeners
* are removed, and that's a rare case, so we don't try.
*/
+ @Override
public synchronized void addMessageCountListener(MessageCountListener l) {
super.addMessageCountListener(l);
hasMessageCountListener = true;
@@ -2438,6 +2518,7 @@
/**
* Returns the UIDValidity for this folder.
*/
+ @Override
public synchronized long getUIDValidity() throws MessagingException {
if (opened) // we already have this information
return uidvalidity;
@@ -2461,6 +2542,8 @@
releaseStoreProtocol(p);
}
+ if (status == null)
+ throw new MessagingException("Cannot obtain UIDValidity");
return status.uidvalidity;
}
@@ -2482,7 +2565,7 @@
* @exception MessagingException for failures
* @since JavaMail 1.3.3
*/
- // Not a UIDFolder method, but still useful
+ @Override
public synchronized long getUIDNext() throws MessagingException {
if (opened) // we already have this information
return uidnext;
@@ -2506,6 +2589,8 @@
releaseStoreProtocol(p);
}
+ if (status == null)
+ throw new MessagingException("Cannot obtain UIDNext");
return status.uidnext;
}
@@ -2513,6 +2598,7 @@
* Get the Message corresponding to the given UID.
* If no such message exists, <code> null </code> is returned.
*/
+ @Override
public synchronized Message getMessageByUID(long uid)
throws MessagingException {
checkOpened(); // insure folder is open
@@ -2529,7 +2615,7 @@
if (m != null) // found it
return m;
} else
- uidTable = new Hashtable<Long, IMAPMessage>();
+ uidTable = new Hashtable<>();
// Check with the server
// Issue UID FETCH command
@@ -2556,6 +2642,7 @@
* Returns Message objects for all valid messages in this range.
* Returns an empty array if no messages are found.
*/
+ @Override
public synchronized Message[] getMessagesByUID(long start, long end)
throws MessagingException {
checkOpened(); // insure that folder is open
@@ -2565,12 +2652,12 @@
try {
synchronized(messageCacheLock) {
if (uidTable == null)
- uidTable = new Hashtable<Long, IMAPMessage>();
+ uidTable = new Hashtable<>();
// Issue UID FETCH for given range
long[] ua = getProtocol().fetchSequenceNumbers(start, end);
- List<Message> ma = new ArrayList<Message>();
+ List<Message> ma = new ArrayList<>();
// NOTE: Below must be within messageCacheLock region
for (int i = 0; i < ua.length; i++) {
Message m = uidTable.get(Long.valueOf(ua[i]));
@@ -2595,6 +2682,7 @@
* If any UID in the array is invalid, a <code>null</code> entry
* is returned for that element.
*/
+ @Override
public synchronized Message[] getMessagesByUID(long[] uids)
throws MessagingException {
checkOpened(); // insure that folder is open
@@ -2604,7 +2692,7 @@
long[] unavailUids = uids;
if (uidTable != null) {
// to collect unavailable UIDs
- List<Long> v = new ArrayList<Long>();
+ List<Long> v = new ArrayList<>();
for (long uid : uids) {
if (!uidTable.containsKey(uid)) {
// This UID has not been loaded yet.
@@ -2618,7 +2706,7 @@
unavailUids[i] = v.get(i);
}
} else
- uidTable = new Hashtable<Long, IMAPMessage>();
+ uidTable = new Hashtable<>();
if (unavailUids.length > 0) {
// Issue UID FETCH request for given uids
@@ -2641,6 +2729,7 @@
/**
* Get the UID for the specified message.
*/
+ @Override
public synchronized long getUID(Message message)
throws MessagingException {
if (message.getFolder() != this)
@@ -2669,7 +2758,7 @@
// insert this message into uidTable
if (uidTable == null)
- uidTable = new Hashtable<Long, IMAPMessage>();
+ uidTable = new Hashtable<>();
uidTable.put(Long.valueOf(uid), m);
}
} catch (ConnectionException cex) {
@@ -2683,6 +2772,24 @@
}
/**
+ * Servers that support the UIDPLUS extension
+ * (<A HREF="http://www.ietf.org/rfc/rfc4315.txt">RFC 4315</A>)
+ * may indicate that this folder does not support persistent UIDs;
+ * that is, UIDVALIDITY will be different each time the folder is
+ * opened. Only valid when the folder is open.
+ *
+ * @return true if UIDs are not sticky
+ * @exception MessagingException for failures
+ * @exception IllegalStateException if the folder isn't open
+ * @see "RFC 4315"
+ * @since JavaMail 1.6.0
+ */
+ public synchronized boolean getUIDNotSticky() throws MessagingException {
+ checkOpened();
+ return uidNotSticky;
+ }
+
+ /**
* Get or create Message objects for the UIDs.
*/
private Message[] createMessagesForUIDs(long[] uids) {
@@ -2735,6 +2842,8 @@
releaseStoreProtocol(p);
}
+ if (status == null)
+ throw new MessagingException("Cannot obtain HIGHESTMODSEQ");
return status.highestmodseq;
}
@@ -2794,6 +2903,7 @@
public Quota[] getQuota() throws MessagingException {
return (Quota[])doOptionalCommand("QUOTA not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.getQuotaRoot(fullName);
@@ -2814,6 +2924,7 @@
public void setQuota(final Quota quota) throws MessagingException {
doOptionalCommand("QUOTA not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
p.setQuota(quota);
@@ -2832,6 +2943,7 @@
public ACL[] getACL() throws MessagingException {
return (ACL[])doOptionalCommand("ACL not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.getACL(fullName);
@@ -2862,6 +2974,7 @@
public void removeACL(final String name) throws MessagingException {
doOptionalCommand("ACL not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
p.deleteACL(fullName, name);
@@ -2917,6 +3030,7 @@
public Rights[] listRights(final String name) throws MessagingException {
return (Rights[])doOptionalCommand("ACL not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.listRights(fullName, name);
@@ -2934,6 +3048,7 @@
public Rights myRights() throws MessagingException {
return (Rights)doOptionalCommand("ACL not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.myRights(fullName);
@@ -2945,6 +3060,7 @@
throws MessagingException {
doOptionalCommand("ACL not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
p.setACL(fullName, mod, acl);
@@ -3082,6 +3198,7 @@
"Folder already being watched by another IdleManager");
Boolean started = (Boolean)doOptionalCommand("IDLE not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
// if the IdleManager is already watching this folder,
@@ -3311,6 +3428,7 @@
checkOpened();
return (Map<String,String>)doOptionalCommand("ID not supported",
new ProtocolCommand() {
+ @Override
public Object doCommand(IMAPProtocol p)
throws ProtocolException {
return p.id(clientParams);
@@ -3341,7 +3459,7 @@
p = getStoreProtocol(); // XXX
String[] items = { item };
status = p.status(fullName, items);
- return status.getItem(item);
+ return status != null ? status.getItem(item) : -1;
} catch (BadCommandException bex) {
// doesn't support STATUS, probably vanilla IMAP4 ..
// Could EXAMINE, SEARCH for UNREAD messages and
@@ -3370,6 +3488,7 @@
* synchronized methods on IMAPFolder or IMAPMessage)
* since that will result in violating the locking hierarchy.
*/
+ @Override
public void handleResponse(Response r) {
assert Thread.holdsLock(messageCacheLock);
@@ -3439,6 +3558,13 @@
// EXPUNGE response.
int seqnum = ir.getNumber();
+ if (seqnum > realTotal) {
+ // A message was expunged that we never knew about.
+ // Exchange will do this. Just ignore the notification.
+ // (Alternatively, we could simulate an EXISTS for the
+ // expunged message before expunging it.)
+ return;
+ }
Message[] msgs = null;
if (doExpungeNotification && hasMessageCountListener) {
// save the Message object first; can't look it
@@ -3507,7 +3633,7 @@
if (uid != null && msg.getUID() != uid.uid) {
msg.setUID(uid.uid);
if (uidTable == null)
- uidTable = new Hashtable<Long, IMAPMessage>();
+ uidTable = new Hashtable<>();
uidTable.put(Long.valueOf(uid.uid), msg);
notify = true;
}
@@ -3956,10 +4082,12 @@
buf = lc.getBytes();
}
+ @Override
public int size() {
return msgSize;
}
+ @Override
public void writeTo(OutputStream os) throws IOException {
// the message should not change between the constructor and this call
try {
@@ -3992,6 +4120,7 @@
this.maxsize = maxsize;
}
+ @Override
public void write(int b) {
int newsize = size + 1;
if (buf != null) {
@@ -4009,6 +4138,7 @@
size = newsize;
}
+ @Override
public void write(byte b[], int off, int len) {
if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
@@ -4032,6 +4162,7 @@
size = newsize;
}
+ @Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPInputStream.java b/current/src/main/java/com/sun/mail/imap/IMAPInputStream.java
index 8f79348..ad1f67a 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPInputStream.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,7 +44,8 @@
import javax.mail.*;
import com.sun.mail.imap.protocol.*;
import com.sun.mail.iap.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.FolderClosedIOException;
+import com.sun.mail.util.MessageRemovedIOException;
/**
* This class implements an IMAP data stream.
@@ -164,7 +165,11 @@
if (b == null || ((ba = b.getByteArray()) == null)) {
forceCheckExpunged();
- throw new IOException("No content");
+ // nope, the server doesn't think it's expunged.
+ // can't tell the difference between the server returning NIL
+ // and some other error that caused null to be returned above,
+ // so we'll just assume it was empty content.
+ ba = new ByteArray(0);
}
}
@@ -187,6 +192,7 @@
* Reads the next byte of data from this buffered input stream.
* If no byte is available, the value <code>-1</code> is returned.
*/
+ @Override
public synchronized int read() throws IOException {
if (bufpos >= bufcount) {
fill();
@@ -210,6 +216,7 @@
* the return value to insure that they have obtained the
* requisite number of bytes.
*/
+ @Override
public synchronized int read(byte b[], int off, int len)
throws IOException {
@@ -240,6 +247,7 @@
* the return value to insure that they have obtained the
* requisite number of bytes.
*/
+ @Override
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
}
@@ -248,6 +256,7 @@
* Returns the number of bytes that can be read from this input
* stream without blocking.
*/
+ @Override
public synchronized int available() throws IOException {
return (bufcount - bufpos);
}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPMessage.java b/current/src/main/java/com/sun/mail/imap/IMAPMessage.java
index 767ef29..f3237ad 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPMessage.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPMessage.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -48,7 +48,7 @@
import javax.mail.internet.*;
import javax.activation.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.ReadableMime;
import com.sun.mail.iap.*;
import com.sun.mail.imap.protocol.*;
@@ -91,7 +91,7 @@
protected Map<String, Object> items; // Map<String,Object>
private Date receivedDate; // INTERNALDATE
- private int size = -1; // RFC822.SIZE
+ private long size = -1; // RFC822.SIZE
private Boolean peek; // use BODY.PEEK when fetching content?
@@ -125,7 +125,7 @@
* Could this somehow be included in the InternetHeaders object ??
*/
private Hashtable<String, String> loadedHeaders
- = new Hashtable<String, String>(1);
+ = new Hashtable<>(1);
// This is our Envelope
static final String EnvelopeCmd = "ENVELOPE INTERNALDATE RFC822.SIZE";
@@ -210,6 +210,7 @@
* Wrapper around the protected method Message.setMessageNumber() to
* make that method accessible to IMAPFolder.
*/
+ @Override
protected void setMessageNumber(int msgnum) {
super.setMessageNumber(msgnum);
}
@@ -268,6 +269,7 @@
}
// expose to MessageCache
+ @Override
protected void setExpunged(boolean set) {
super.setExpunged(set);
}
@@ -315,6 +317,7 @@
/**
* Get the "From" attribute.
*/
+ @Override
public Address[] getFrom() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -334,10 +337,12 @@
return aaclone(a);
}
+ @Override
public void setFrom(Address address) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
+ @Override
public void addFrom(Address[] addresses) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -345,6 +350,7 @@
/**
* Get the "Sender" attribute.
*/
+ @Override
public Address getSender() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -357,6 +363,7 @@
}
+ @Override
public void setSender(Address address) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -364,6 +371,7 @@
/**
* Get the desired Recipient type.
*/
+ @Override
public Address[] getRecipients(Message.RecipientType type)
throws MessagingException {
checkExpunged();
@@ -381,11 +389,13 @@
return super.getRecipients(type);
}
+ @Override
public void setRecipients(Message.RecipientType type, Address[] addresses)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
+ @Override
public void addRecipients(Message.RecipientType type, Address[] addresses)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -394,6 +404,7 @@
/**
* Get the ReplyTo addresses.
*/
+ @Override
public Address[] getReplyTo() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -410,6 +421,7 @@
return aaclone(envelope.replyTo);
}
+ @Override
public void setReplyTo(Address[] addresses) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -417,6 +429,7 @@
/**
* Get the decoded subject.
*/
+ @Override
public String getSubject() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -442,6 +455,7 @@
return subject;
}
+ @Override
public void setSubject(String subject, String charset)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -450,6 +464,7 @@
/**
* Get the SentDate.
*/
+ @Override
public Date getSentDate() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -461,6 +476,7 @@
return new Date(envelope.date.getTime());
}
+ @Override
public void setSentDate(Date d) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -468,6 +484,7 @@
/**
* Get the received date (INTERNALDATE).
*/
+ @Override
public Date getReceivedDate() throws MessagingException {
checkExpunged();
if (receivedDate == null)
@@ -483,12 +500,34 @@
*
* Note that this returns RFC822.SIZE. That is, it's the
* size of the whole message, header and body included.
+ * Note also that if the size of the message is greater than
+ * Integer.MAX_VALUE (2GB), this method returns Integer.MAX_VALUE.
*/
+ @Override
public int getSize() throws MessagingException {
checkExpunged();
// if bodyLoaded, size is already set
if (size == -1)
loadEnvelope(); // XXX - could just fetch the size
+ if (size > Integer.MAX_VALUE)
+ return Integer.MAX_VALUE; // the best we can do...
+ else
+ return (int)size;
+ }
+
+ /**
+ * Get the message size as a long. <p>
+ *
+ * Suitable for messages that might be larger than 2GB.
+ * @return the message size as a long integer
+ * @exception MessagingException for failures
+ * @since JavaMail 1.6
+ */
+ public long getSizeLong() throws MessagingException {
+ checkExpunged();
+ // if bodyLoaded, size is already set
+ if (size == -1)
+ loadEnvelope(); // XXX - could just fetch the size
return size;
}
@@ -499,6 +538,7 @@
* BODYSTRUCTURE. Note that this field is available
* only for text/plain and message/rfc822 types
*/
+ @Override
public int getLineCount() throws MessagingException {
checkExpunged();
// XXX - superclass doesn't implement this
@@ -509,6 +549,7 @@
/**
* Get the content language.
*/
+ @Override
public String[] getContentLanguage() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -520,6 +561,7 @@
return null;
}
+ @Override
public void setContentLanguage(String[] languages)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -546,6 +588,7 @@
* Generate this header from the BODYSTRUCTURE. Append parameters
* as well.
*/
+ @Override
public synchronized String getContentType() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -564,6 +607,7 @@
/**
* Get the Content-Disposition.
*/
+ @Override
public String getDisposition() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -572,6 +616,7 @@
return bs.disposition;
}
+ @Override
public void setDisposition(String disposition) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -579,6 +624,7 @@
/**
* Get the Content-Transfer-Encoding.
*/
+ @Override
public String getEncoding() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -590,6 +636,7 @@
/**
* Get the Content-ID.
*/
+ @Override
public String getContentID() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -598,6 +645,7 @@
return bs.id;
}
+ @Override
public void setContentID(String cid) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -605,6 +653,7 @@
/**
* Get the Content-MD5.
*/
+ @Override
public String getContentMD5() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -613,6 +662,7 @@
return bs.md5;
}
+ @Override
public void setContentMD5(String md5) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -620,6 +670,7 @@
/**
* Get the decoded Content-Description.
*/
+ @Override
public String getDescription() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -641,6 +692,7 @@
return description;
}
+ @Override
public void setDescription(String description, String charset)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -649,6 +701,7 @@
/**
* Get the Message-ID.
*/
+ @Override
public String getMessageID() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -662,6 +715,7 @@
* IMAP4rev1). If thats not available, get the "name" ContentType
* parameter.
*/
+ @Override
public String getFileName() throws MessagingException {
checkExpunged();
if (bodyLoaded)
@@ -677,6 +731,7 @@
return filename;
}
+ @Override
public void setFileName(String filename) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -688,6 +743,7 @@
*
* @see javax.mail.internet.MimeMessage#getContentStream
*/
+ @Override
protected InputStream getContentStream() throws MessagingException {
if (bodyLoaded)
return super.getContentStream();
@@ -729,15 +785,21 @@
}
}
- if (is == null)
- throw new MessagingException("No content");
- else
- return is;
+ if (is == null) {
+ forceCheckExpunged(); // may throw MessageRemovedException
+ // nope, the server doesn't think it's expunged.
+ // can't tell the difference between the server returning NIL
+ // and some other error that caused null to be returned above,
+ // so we'll just assume it was empty content.
+ is = new ByteArrayInputStream(new byte[0]);
+ }
+ return is;
}
/**
* Get the DataHandler object for this message.
*/
+ @Override
public synchronized DataHandler getDataHandler()
throws MessagingException {
checkExpunged();
@@ -776,6 +838,7 @@
return super.getDataHandler();
}
+ @Override
public void setDataHandler(DataHandler content)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -787,6 +850,7 @@
* @return the MIME format stream
* @since JavaMail 1.4.5
*/
+ @Override
public InputStream getMimeStream() throws MessagingException {
// XXX - need an "if (bodyLoaded)" version
InputStream is = null;
@@ -825,9 +889,11 @@
if (is == null) {
forceCheckExpunged(); // may throw MessageRemovedException
- // nope, the server doesn't think it's expunged,
- // something else is wrong
- throw new MessagingException("No content");
+ // nope, the server doesn't think it's expunged.
+ // can't tell the difference between the server returning NIL
+ // and some other error that caused null to be returned above,
+ // so we'll just assume it was empty content.
+ is = new ByteArrayInputStream(new byte[0]);
}
return is;
}
@@ -835,6 +901,7 @@
/**
* Write out the bytes into the given OutputStream.
*/
+ @Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
if (bodyLoaded) {
@@ -856,6 +923,7 @@
/**
* Get the named header.
*/
+ @Override
public String[] getHeader(String name) throws MessagingException {
checkExpunged();
@@ -910,6 +978,7 @@
/**
* Get the named header.
*/
+ @Override
public String getHeader(String name, String delimiter)
throws MessagingException {
checkExpunged();
@@ -920,16 +989,19 @@
return headers.getHeader(name, delimiter);
}
+ @Override
public void setHeader(String name, String value)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
+ @Override
public void addHeader(String name, String value)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
+ @Override
public void removeHeader(String name)
throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
@@ -938,7 +1010,7 @@
/**
* Get all headers.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getAllHeaders() throws MessagingException {
checkExpunged();
loadHeaders();
@@ -948,7 +1020,7 @@
/**
* Get matching headers.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getMatchingHeaders(String[] names)
throws MessagingException {
checkExpunged();
@@ -959,7 +1031,7 @@
/**
* Get non-matching headers.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getNonMatchingHeaders(String[] names)
throws MessagingException {
checkExpunged();
@@ -967,6 +1039,7 @@
return super.getNonMatchingHeaders(names);
}
+ @Override
public void addHeaderLine(String line) throws MessagingException {
throw new IllegalWriteException("IMAPMessage is read-only");
}
@@ -974,7 +1047,7 @@
/**
* Get all header-lines.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getAllHeaderLines() throws MessagingException {
checkExpunged();
loadHeaders();
@@ -984,7 +1057,7 @@
/**
* Get all matching header-lines.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException {
checkExpunged();
@@ -995,7 +1068,7 @@
/**
* Get all non-matching headerlines.
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException {
checkExpunged();
@@ -1006,6 +1079,7 @@
/**
* Get the Flags for this message.
*/
+ @Override
public synchronized Flags getFlags() throws MessagingException {
checkExpunged();
loadFlags();
@@ -1015,6 +1089,7 @@
/**
* Test if the given Flags are set in this message.
*/
+ @Override
public synchronized boolean isSet(Flags.Flag flag)
throws MessagingException {
checkExpunged();
@@ -1025,6 +1100,7 @@
/**
* Set/Unset the given flags in this message.
*/
+ @Override
public synchronized void setFlags(Flags flag, boolean set)
throws MessagingException {
// Acquire MessageCacheLock, to freeze seqnum.
@@ -1108,7 +1184,7 @@
private boolean needMessage = false;
private boolean needRDate = false;
private String[] hdrs = null;
- private Set<FetchItem> need = new HashSet<FetchItem>();
+ private Set<FetchItem> need = new HashSet<>();
/**
* Create a FetchProfileCondition to determine if we need to fetch
@@ -1148,6 +1224,7 @@
* Return true if we NEED to fetch the requested information
* for the specified message.
*/
+ @Override
public boolean test(IMAPMessage m) {
if (needEnvelope && m._getEnvelope() == null && !m.bodyLoaded)
return true; // no envelope
@@ -1221,7 +1298,7 @@
// add entry into uid table
if (((IMAPFolder)folder).uidTable == null)
((IMAPFolder) folder).uidTable
- = new Hashtable<Long, IMAPMessage>();
+ = new Hashtable<>();
((IMAPFolder)folder).uidTable.put(Long.valueOf(u.uid), this);
}
@@ -1277,7 +1354,6 @@
* object, because InternetHeaders is not thread
* safe.
*/
- @SuppressWarnings("unchecked")
Enumeration<Header> e = h.getAllHeaders();
while (e.hasMoreElements()) {
Header he = e.nextElement();
@@ -1317,7 +1393,7 @@
if (extensionItems == null || extensionItems.isEmpty())
return;
if (items == null)
- items = new HashMap<String, Object>();
+ items = new HashMap<>();
items.putAll(extensionItems);
}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java b/current/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java
index 306666a..d95c60c 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPMultipartDataSource.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -62,7 +62,7 @@
String sectionId, IMAPMessage msg) {
super(part);
- parts = new ArrayList<IMAPBodyPart>(bs.length);
+ parts = new ArrayList<>(bs.length);
for (int i = 0; i < bs.length; i++)
parts.add(
new IMAPBodyPart(bs[i],
@@ -73,10 +73,12 @@
);
}
+ @Override
public int getCount() {
return parts.size();
}
+ @Override
public BodyPart getBodyPart(int index) throws MessagingException {
return parts.get(index);
}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java b/current/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java
index 5d058a2..2e2782f 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPNestedMessage.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -73,6 +73,7 @@
* Get the enclosing message's Protocol object. Overrides
* IMAPMessage.getProtocol().
*/
+ @Override
protected IMAPProtocol getProtocol()
throws ProtocolException, FolderClosedException {
return msg.getProtocol();
@@ -81,6 +82,7 @@
/*
* Is this an IMAP4 REV1 server?
*/
+ @Override
protected boolean isREV1() throws FolderClosedException {
return msg.isREV1();
}
@@ -89,6 +91,7 @@
* Get the enclosing message's messageCacheLock. Overrides
* IMAPMessage.getMessageCacheLock().
*/
+ @Override
protected Object getMessageCacheLock() {
return msg.getMessageCacheLock();
}
@@ -97,6 +100,7 @@
* Get the enclosing message's sequence number. Overrides
* IMAPMessage.getSequenceNumber().
*/
+ @Override
protected int getSequenceNumber() {
return msg.getSequenceNumber();
}
@@ -105,6 +109,7 @@
* Check whether the enclosing message is expunged. Overrides
* IMAPMessage.checkExpunged().
*/
+ @Override
protected void checkExpunged() throws MessageRemovedException {
msg.checkExpunged();
}
@@ -113,6 +118,7 @@
* Check whether the enclosing message is expunged. Overrides
* Message.isExpunged().
*/
+ @Override
public boolean isExpunged() {
return msg.isExpunged();
}
@@ -120,6 +126,7 @@
/*
* Get the enclosing message's fetchBlockSize.
*/
+ @Override
protected int getFetchBlockSize() {
return msg.getFetchBlockSize();
}
@@ -127,6 +134,7 @@
/*
* Get the enclosing message's ignoreBodyStructureSize.
*/
+ @Override
protected boolean ignoreBodyStructureSize() {
return msg.ignoreBodyStructureSize();
}
@@ -135,6 +143,7 @@
* IMAPMessage uses RFC822.SIZE. We use the "size" field from
* our BODYSTRUCTURE.
*/
+ @Override
public int getSize() throws MessagingException {
return bs.size;
}
@@ -142,6 +151,7 @@
/*
* Disallow setting flags on nested messages
*/
+ @Override
public synchronized void setFlags(Flags flag, boolean set)
throws MessagingException {
// Cannot set FLAGS on a nested IMAP message
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPProvider.java b/current/src/main/java/com/sun/mail/imap/IMAPProvider.java
new file mode 100644
index 0000000..30753fc
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/imap/IMAPProvider.java
@@ -0,0 +1,53 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.imap;
+
+import javax.mail.Provider;
+
+/**
+ * The IMAP protocol provider.
+ */
+public class IMAPProvider extends Provider {
+ public IMAPProvider() {
+ super(Provider.Type.STORE, "imap", IMAPStore.class.getName(),
+ "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPSSLProvider.java b/current/src/main/java/com/sun/mail/imap/IMAPSSLProvider.java
new file mode 100644
index 0000000..80d0129
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/imap/IMAPSSLProvider.java
@@ -0,0 +1,53 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.imap;
+
+import javax.mail.Provider;
+
+/**
+ * The IMAP SSL protocol provider.
+ */
+public class IMAPSSLProvider extends Provider {
+ public IMAPSSLProvider() {
+ super(Provider.Type.STORE, "imaps", IMAPSSLStore.class.getName(),
+ "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPSSLStore.java b/current/src/main/java/com/sun/mail/imap/IMAPSSLStore.java
index a491481..c8dc185 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPSSLStore.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPSSLStore.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/IMAPStore.java b/current/src/main/java/com/sun/mail/imap/IMAPStore.java
index e2d5bb5..fcaab75 100644
--- a/current/src/main/java/com/sun/mail/imap/IMAPStore.java
+++ b/current/src/main/java/com/sun/mail/imap/IMAPStore.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,6 +44,7 @@
import java.util.Vector;
import java.util.StringTokenizer;
import java.util.Locale;
+import java.util.Properties;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -256,7 +257,7 @@
// container for the pool's IMAP protocol objects
private Vector<IMAPProtocol> authenticatedConnections
- = new Vector<IMAPProtocol>();
+ = new Vector<>();
// vectore of open folders
private Vector<IMAPFolder> folders;
@@ -336,14 +337,15 @@
ConnectionPool(String name, MailLogger plogger, Session session) {
lastTimePruned = System.currentTimeMillis();
+ Properties props = session.getProperties();
- boolean debug = PropUtil.getBooleanSessionProperty(session,
+ boolean debug = PropUtil.getBooleanProperty(props,
"mail." + name + ".connectionpool.debug", false);
logger = plogger.getSubLogger("connectionpool",
"DEBUG IMAP CP", debug);
// check if the default connection pool size is overridden
- int size = PropUtil.getIntSessionProperty(session,
+ int size = PropUtil.getIntProperty(props,
"mail." + name + ".connectionpoolsize", -1);
if (size > 0) {
poolSize = size;
@@ -353,7 +355,7 @@
poolSize = 1;
// check if the default client-side timeout value is overridden
- int connectionPoolTimeout = PropUtil.getIntSessionProperty(session,
+ int connectionPoolTimeout = PropUtil.getIntProperty(props,
"mail." + name + ".connectionpooltimeout", -1);
if (connectionPoolTimeout > 0) {
clientTimeoutInterval = connectionPoolTimeout;
@@ -364,7 +366,7 @@
clientTimeoutInterval = 45 * 1000; // 45 seconds
// check if the default server-side timeout value is overridden
- int serverTimeout = PropUtil.getIntSessionProperty(session,
+ int serverTimeout = PropUtil.getIntProperty(props,
"mail." + name + ".servertimeout", -1);
if (serverTimeout > 0) {
serverTimeoutInterval = serverTimeout;
@@ -375,7 +377,7 @@
serverTimeoutInterval = 30 * 60 * 1000; // 30 minutes
// check if the default server-side timeout value is overridden
- int pruning = PropUtil.getIntSessionProperty(session,
+ int pruning = PropUtil.getIntProperty(props,
"mail." + name + ".pruninginterval", -1);
if (pruning > 0) {
pruningInterval = pruning;
@@ -388,7 +390,7 @@
// check to see if we should use a separate (i.e. dedicated)
// store connection
separateStoreConnection =
- PropUtil.getBooleanSessionProperty(session,
+ PropUtil.getBooleanProperty(props,
"mail." + name + ".separatestoreconnection", false);
if (separateStoreConnection)
logger.config("dedicate a store connection");
@@ -406,6 +408,7 @@
* that the connection is dead.
*/
private ResponseHandler nonStoreResponseHandler = new ResponseHandler() {
+ @Override
public void handleResponse(Response r) {
// Any of these responses may have a response code.
if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE())
@@ -437,11 +440,13 @@
protected IMAPStore(Session session, URLName url,
String name, boolean isSSL) {
super(session, url); // call super constructor
+ Properties props = session.getProperties();
+
if (url != null)
name = url.getProtocol();
this.name = name;
if (!isSSL)
- isSSL = PropUtil.getBooleanSessionProperty(session,
+ isSSL = PropUtil.getBooleanProperty(props,
"mail." + name + ".ssl.enable", false);
if (isSSL)
this.defaultPort = 993;
@@ -450,42 +455,43 @@
this.isSSL = isSSL;
debug = session.getDebug();
- debugusername = PropUtil.getBooleanSessionProperty(session,
+ debugusername = PropUtil.getBooleanProperty(props,
"mail.debug.auth.username", true);
- debugpassword = PropUtil.getBooleanSessionProperty(session,
+ debugpassword = PropUtil.getBooleanProperty(props,
"mail.debug.auth.password", false);
logger = new MailLogger(this.getClass(),
- "DEBUG " + name.toUpperCase(Locale.ENGLISH), session);
+ "DEBUG " + name.toUpperCase(Locale.ENGLISH),
+ session.getDebug(), session.getDebugOut());
- boolean partialFetch = PropUtil.getBooleanSessionProperty(session,
+ boolean partialFetch = PropUtil.getBooleanProperty(props,
"mail." + name + ".partialfetch", true);
if (!partialFetch) {
blksize = -1;
logger.config("mail.imap.partialfetch: false");
} else {
- blksize = PropUtil.getIntSessionProperty(session,
+ blksize = PropUtil.getIntProperty(props,
"mail." + name +".fetchsize", 1024 * 16);
if (logger.isLoggable(Level.CONFIG))
logger.config("mail.imap.fetchsize: " + blksize);
}
- ignoreSize = PropUtil.getBooleanSessionProperty(session,
+ ignoreSize = PropUtil.getBooleanProperty(props,
"mail." + name +".ignorebodystructuresize", false);
if (logger.isLoggable(Level.CONFIG))
logger.config("mail.imap.ignorebodystructuresize: " + ignoreSize);
- statusCacheTimeout = PropUtil.getIntSessionProperty(session,
+ statusCacheTimeout = PropUtil.getIntProperty(props,
"mail." + name + ".statuscachetimeout", 1000);
if (logger.isLoggable(Level.CONFIG))
logger.config("mail.imap.statuscachetimeout: " +
statusCacheTimeout);
- appendBufferSize = PropUtil.getIntSessionProperty(session,
+ appendBufferSize = PropUtil.getIntProperty(props,
"mail." + name + ".appendbuffersize", -1);
if (logger.isLoggable(Level.CONFIG))
logger.config("mail.imap.appendbuffersize: " + appendBufferSize);
- minIdleTime = PropUtil.getIntSessionProperty(session,
+ minIdleTime = PropUtil.getIntProperty(props,
"mail." + name + ".minidletime", 10);
if (logger.isLoggable(Level.CONFIG))
logger.config("mail.imap.minidletime: " + minIdleTime);
@@ -499,19 +505,19 @@
}
// check if STARTTLS is enabled
- enableStartTLS = PropUtil.getBooleanSessionProperty(session,
+ enableStartTLS = PropUtil.getBooleanProperty(props,
"mail." + name + ".starttls.enable", false);
if (enableStartTLS)
logger.config("enable STARTTLS");
// check if STARTTLS is required
- requireStartTLS = PropUtil.getBooleanSessionProperty(session,
+ requireStartTLS = PropUtil.getBooleanProperty(props,
"mail." + name + ".starttls.required", false);
if (requireStartTLS)
logger.config("require STARTTLS");
// check if SASL is enabled
- enableSASL = PropUtil.getBooleanSessionProperty(session,
+ enableSASL = PropUtil.getBooleanProperty(props,
"mail." + name + ".sasl.enable", false);
if (enableSASL)
logger.config("enable SASL");
@@ -522,7 +528,7 @@
if (s != null && s.length() > 0) {
if (logger.isLoggable(Level.CONFIG))
logger.config("SASL mechanisms allowed: " + s);
- List<String> v = new ArrayList<String>(5);
+ List<String> v = new ArrayList<>(5);
StringTokenizer st = new StringTokenizer(s, " ,");
while (st.hasMoreTokens()) {
String m = st.nextToken();
@@ -550,25 +556,25 @@
}
// check if forcePasswordRefresh is enabled
- forcePasswordRefresh = PropUtil.getBooleanSessionProperty(session,
+ forcePasswordRefresh = PropUtil.getBooleanProperty(props,
"mail." + name + ".forcepasswordrefresh", false);
if (forcePasswordRefresh)
logger.config("enable forcePasswordRefresh");
// check if enableimapevents is enabled
- enableResponseEvents = PropUtil.getBooleanSessionProperty(session,
+ enableResponseEvents = PropUtil.getBooleanProperty(props,
"mail." + name + ".enableresponseevents", false);
if (enableResponseEvents)
logger.config("enable IMAP response events");
// check if enableresponseevents is enabled
- enableImapEvents = PropUtil.getBooleanSessionProperty(session,
+ enableImapEvents = PropUtil.getBooleanProperty(props,
"mail." + name + ".enableimapevents", false);
if (enableImapEvents)
logger.config("enable IMAP IDLE events");
// check if message cache debugging set
- messageCacheDebug = PropUtil.getBooleanSessionProperty(session,
+ messageCacheDebug = PropUtil.getBooleanProperty(props,
"mail." + name + ".messagecache.debug", false);
guid = session.getProperty("mail." + name + ".yahoo.guid");
@@ -576,31 +582,31 @@
logger.log(Level.CONFIG, "mail.imap.yahoo.guid: {0}", guid);
// check if throwsearchexception is enabled
- throwSearchException = PropUtil.getBooleanSessionProperty(session,
+ throwSearchException = PropUtil.getBooleanProperty(props,
"mail." + name + ".throwsearchexception", false);
if (throwSearchException)
logger.config("throw SearchException");
// check if peek is set
- peek = PropUtil.getBooleanSessionProperty(session,
+ peek = PropUtil.getBooleanProperty(props,
"mail." + name + ".peek", false);
if (peek)
logger.config("peek");
// check if closeFoldersOnStoreFailure is set
- closeFoldersOnStoreFailure = PropUtil.getBooleanSessionProperty(session,
+ closeFoldersOnStoreFailure = PropUtil.getBooleanProperty(props,
"mail." + name + ".closefoldersonstorefailure", true);
if (closeFoldersOnStoreFailure)
logger.config("closeFoldersOnStoreFailure");
// check if COMPRESS is enabled
- enableCompress = PropUtil.getBooleanSessionProperty(session,
+ enableCompress = PropUtil.getBooleanProperty(props,
"mail." + name + ".compress.enable", false);
if (enableCompress)
logger.config("enable COMPRESS");
// check if finalizeCleanClose is enabled
- finalizeCleanClose = PropUtil.getBooleanSessionProperty(session,
+ finalizeCleanClose = PropUtil.getBooleanProperty(props,
"mail." + name + ".finalizecleanclose", false);
if (finalizeCleanClose)
logger.config("close connection cleanly in finalize");
@@ -649,6 +655,7 @@
* being used does not require a password, an empty string or other
* suitable dummy password should be used.
*/
+ @Override
protected synchronized boolean
protocolConnect(String host, int pport, String user, String password)
throws MessagingException {
@@ -669,7 +676,7 @@
if (pport != -1) {
port = pport;
} else {
- port = PropUtil.getIntSessionProperty(session,
+ port = PropUtil.getIntProperty(session.getProperties(),
"mail." + name + ".port", port);
}
@@ -783,7 +790,7 @@
// issue special ID command to Yahoo! Mail IMAP server
// http://en.wikipedia.org/wiki/Yahoo%21_Mail#Free_IMAP_and_SMTPs_access
if (guid != null) {
- Map<String,String> gmap = new HashMap<String,String>();
+ Map<String,String> gmap = new HashMap<>();
gmap.put("GUID", guid);
p.id(gmap);
}
@@ -839,6 +846,11 @@
p.compress();
}
}
+
+ // if server supports UTF-8, enable it for client use
+ // note that this is safe to enable even if mail.mime.allowutf8=false
+ if (p.hasCapability("UTF8=ACCEPT") || p.hasCapability("UTF8=ONLY"))
+ p.enable("UTF8=ACCEPT");
}
/**
@@ -881,8 +893,9 @@
if (mechs == defaultAuthenticationMechanisms) {
String dprop = "mail." + name + ".auth." +
m.toLowerCase(Locale.ENGLISH) + ".disable";
- boolean disabled = PropUtil.getBooleanSessionProperty(
- session, dprop, m.equals("XOAUTH2"));
+ boolean disabled = PropUtil.getBooleanProperty(
+ session.getProperties(),
+ dprop, m.equals("XOAUTH2"));
if (disabled) {
if (logger.isLoggable(Level.FINE))
logger.fine("mechanism " + m +
@@ -1056,11 +1069,11 @@
try {
p.removeResponseHandler(nonStoreResponseHandler);
p.disconnect();
- } finally {
+ } catch (RuntimeException ignored) {
// don't let any exception stop us
- p = null;
- continue; // try again, from the top
}
+ p = null;
+ continue; // try again, from the top
}
}
@@ -1084,11 +1097,11 @@
try {
p.removeResponseHandler(nonStoreResponseHandler);
p.disconnect();
- } finally {
+ } catch (RuntimeException ignored) {
// don't let any exception stop us
- p = null;
- continue; // try again, from the top
}
+ p = null;
+ continue; // try again, from the top
}
}
@@ -1102,7 +1115,7 @@
// Add folder to folder-list
if (folder != null) {
if (pool.folders == null)
- pool.folders = new Vector<IMAPFolder>();
+ pool.folders = new Vector<>();
pool.folders.addElement(folder);
}
}
@@ -1250,7 +1263,7 @@
* do we allow the open to succeed?
*/
boolean allowReadOnlySelect() {
- return PropUtil.getBooleanSessionProperty(session,
+ return PropUtil.getBooleanProperty(session.getProperties(),
"mail." + name + ".allowreadonlyselect", false);
}
@@ -1567,6 +1580,7 @@
* Check whether this store is connected. Override superclass
* method, to actually ping our server connection.
*/
+ @Override
public synchronized boolean isConnected() {
if (!super.isConnected()) {
// if we haven't been connected at all, don't bother with
@@ -1607,68 +1621,16 @@
/**
* Close this Store.
*/
+ @Override
public synchronized void close() throws MessagingException {
- if (!super.isConnected()) // Already closed.
- return;
-
- IMAPProtocol protocol = null;
- try {
- boolean isEmpty;
- synchronized (pool) {
- // If there's no authenticated connections available
- // don't create a new one
- isEmpty = pool.authenticatedConnections.isEmpty();
- }
- /*
- * Have to drop the lock before calling cleanup.
- * Yes, there's a potential race here. The pool could
- * become empty after we check, in which case we'll just
- * waste time getting a new connection and closing it.
- * Or, the pool could be empty now and not empty by the
- * time we get into cleanup, but that's ok because cleanup
- * will just close the connection.
- */
- if (isEmpty) {
- pool.logger.fine("close() - no connections ");
- cleanup();
- return;
- }
-
- protocol = getStoreProtocol();
- /*
- * We have to remove the protocol from the pool so that,
- * when our response handler processes the BYE response
- * and calls cleanup, which calls emptyConnection, that
- * we don't try to log out this connection twice.
- */
- synchronized (pool) {
- pool.authenticatedConnections.removeElement(protocol);
- }
-
- /*
- * LOGOUT.
- *
- * Note that protocol.logout() closes the server socket
- * connection, regardless of what happens ..
- *
- * Also note that protocol.logout() results in a BYE
- * response (As per RFC 3501, BYE is a *required* response
- * to LOGOUT). In fact, even if protocol.logout() fails
- * with an IOException (if the server connection is dead),
- * iap.Protocol.command() converts that exception into a
- * BYE response. So, I depend on my BYE handler to set the
- * flag that causes releaseStoreProtocol to do the
- * Store cleanup.
- */
- protocol.logout();
- } catch (ProtocolException pex) {
- // Hmm .. will this ever happen ?
- throw new MessagingException(pex.getMessage(), pex);
- } finally {
- releaseStoreProtocol(protocol);
- }
+ cleanup();
+ // do these again in case cleanup returned early
+ // because we were already closed due to a failure
+ closeAllFolders(false);
+ emptyConnectionPool(false);
}
+ @Override
protected void finalize() throws Throwable {
if (!finalizeCleanClose) {
// when finalizing, close connections abruptly
@@ -1711,6 +1673,24 @@
logger.fine("IMAPStore cleanup, force " + force);
if (!force || closeFoldersOnStoreFailure) {
+ closeAllFolders(force);
+ }
+
+ emptyConnectionPool(force);
+
+ // to set the state and send the closed connection event
+ try {
+ super.close();
+ } catch (MessagingException mex) {
+ // ignore it
+ }
+ logger.fine("IMAPStore cleanup done");
+ }
+
+ /**
+ * Close all open Folders. If force is true, close them forcibly.
+ */
+ private void closeAllFolders(boolean force) {
List<IMAPFolder> foldersCopy = null;
boolean done = true;
@@ -1759,25 +1739,13 @@
}
}
- }
-
- synchronized (pool) {
- emptyConnectionPool(force);
- }
-
- // to set the state and send the closed connection event
- try {
- super.close();
- } catch (MessagingException mex) {
- // ignore it
- }
- logger.fine("IMAPStore cleanup done");
}
/**
* Get the default folder, representing the root of this user's
* namespace. Returns a closed DefaultFolder object.
*/
+ @Override
public synchronized Folder getDefaultFolder() throws MessagingException {
checkConnected();
return new DefaultFolder(this);
@@ -1786,6 +1754,7 @@
/**
* Get named folder. Returns a new, closed IMAPFolder.
*/
+ @Override
public synchronized Folder getFolder(String name)
throws MessagingException {
checkConnected();
@@ -1795,6 +1764,7 @@
/**
* Get named folder. Returns a new, closed IMAPFolder.
*/
+ @Override
public synchronized Folder getFolder(URLName url)
throws MessagingException {
checkConnected();
@@ -1867,6 +1837,7 @@
* Using the IMAP NAMESPACE command (RFC 2342), return a set
* of folders representing the Personal namespaces.
*/
+ @Override
public Folder[] getPersonalNamespaces() throws MessagingException {
Namespaces ns = getNamespaces();
if (ns == null || ns.personal == null)
@@ -1878,6 +1849,7 @@
* Using the IMAP NAMESPACE command (RFC 2342), return a set
* of folders representing the User's namespaces.
*/
+ @Override
public Folder[] getUserNamespaces(String user)
throws MessagingException {
Namespaces ns = getNamespaces();
@@ -1890,6 +1862,7 @@
* Using the IMAP NAMESPACE command (RFC 2342), return a set
* of folders representing the Shared namespaces.
*/
+ @Override
public Folder[] getSharedNamespaces() throws MessagingException {
Namespaces ns = getNamespaces();
if (ns == null || ns.shared == null)
@@ -1955,6 +1928,7 @@
* @exception MessagingException if the server doesn't support the
* QUOTA extension
*/
+ @Override
public synchronized Quota[] getQuota(String root)
throws MessagingException {
checkConnected();
@@ -1985,6 +1959,7 @@
* @exception MessagingException if the server doesn't support the
* QUOTA extension
*/
+ @Override
public synchronized void setQuota(Quota quota) throws MessagingException {
checkConnected();
IMAPProtocol p = null;
@@ -2011,6 +1986,7 @@
/**
* Response handler method.
*/
+ @Override
public void handleResponse(Response r) {
// Any of these responses may have a response code.
if (r.isOK() || r.isNO() || r.isBAD() || r.isBYE())
diff --git a/current/src/main/java/com/sun/mail/imap/IdleManager.java b/current/src/main/java/com/sun/mail/imap/IdleManager.java
index f45dd5d..0373b49 100644
--- a/current/src/main/java/com/sun/mail/imap/IdleManager.java
+++ b/current/src/main/java/com/sun/mail/imap/IdleManager.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -140,8 +140,8 @@
private MailLogger logger;
private volatile boolean die = false;
private volatile boolean running;
- private Queue<IMAPFolder> toWatch = new ConcurrentLinkedQueue<IMAPFolder>();
- private Queue<IMAPFolder> toAbort = new ConcurrentLinkedQueue<IMAPFolder>();
+ private Queue<IMAPFolder> toWatch = new ConcurrentLinkedQueue<>();
+ private Queue<IMAPFolder> toAbort = new ConcurrentLinkedQueue<>();
/**
* Create an IdleManager. The Session is used only to configure
@@ -154,9 +154,11 @@
*/
public IdleManager(Session session, Executor es) throws IOException {
this.es = es;
- logger = new MailLogger(this.getClass(), "DEBUG IMAP", session);
+ logger = new MailLogger(this.getClass(), "DEBUG IMAP",
+ session.getDebug(), session.getDebugOut());
selector = Selector.open();
es.execute(new Runnable() {
+ @Override
public void run() {
logger.fine("IdleManager select starting");
try {
@@ -199,8 +201,13 @@
throw new MessagingException("Can only watch IMAP folders");
IMAPFolder ifolder = (IMAPFolder)folder;
SocketChannel sc = ifolder.getChannel();
- if (sc == null)
- throw new MessagingException("Folder is not using SocketChannels");
+ if (sc == null) {
+ if (folder.isOpen())
+ throw new MessagingException(
+ "Folder is not using SocketChannels");
+ else
+ throw new MessagingException("Folder is not open");
+ }
if (logger.isLoggable(Level.FINEST))
logger.log(Level.FINEST, "IdleManager watching {0}",
folderName(ifolder));
@@ -346,7 +353,7 @@
Set<SelectionKey> selectedKeys = selector.selectedKeys();
/*
* XXX - this is simpler, but it can fail with
- * ConncurentModificationException
+ * ConcurrentModificationException
*
for (SelectionKey sk : selectedKeys) {
selectedKeys.remove(sk); // only process each key once
@@ -414,7 +421,7 @@
toWatch.remove(folder);
final IMAPFolder folder0 = folder;
es.execute(new Runnable() {
- //@Override
+ @Override
public void run() {
// send the DONE and wait for the response
folder0.idleAbortWait();
diff --git a/current/src/main/java/com/sun/mail/imap/MessageCache.java b/current/src/main/java/com/sun/mail/imap/MessageCache.java
index 00bf610..bab6d8c 100644
--- a/current/src/main/java/com/sun/mail/imap/MessageCache.java
+++ b/current/src/main/java/com/sun/mail/imap/MessageCache.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -217,7 +217,7 @@
public IMAPMessage[] removeExpungedMessages() {
logger.fine("remove expunged messages");
// list of expunged messages
- List<IMAPMessage> mlist = new ArrayList<IMAPMessage>();
+ List<IMAPMessage> mlist = new ArrayList<>();
/*
* Walk through the array compressing it by copying
@@ -268,7 +268,7 @@
public IMAPMessage[] removeExpungedMessages(Message[] msgs) {
logger.fine("remove expunged messages");
// list of expunged messages
- List<IMAPMessage> mlist = new ArrayList<IMAPMessage>();
+ List<IMAPMessage> mlist = new ArrayList<>();
/*
* Copy the message numbers of the expunged messages into
diff --git a/current/src/main/java/com/sun/mail/imap/MessageVanishedEvent.java b/current/src/main/java/com/sun/mail/imap/MessageVanishedEvent.java
index bab8c5e..9279a3f 100644
--- a/current/src/main/java/com/sun/mail/imap/MessageVanishedEvent.java
+++ b/current/src/main/java/com/sun/mail/imap/MessageVanishedEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java b/current/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java
index 0dc6af0..57ad421 100644
--- a/current/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java
+++ b/current/src/main/java/com/sun/mail/imap/ModifiedSinceTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -82,6 +82,7 @@
* MODSEQ
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
long m;
@@ -100,6 +101,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof ModifiedSinceTerm))
return false;
@@ -109,6 +111,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return (int)modseq;
}
diff --git a/current/src/main/java/com/sun/mail/imap/OlderTerm.java b/current/src/main/java/com/sun/mail/imap/OlderTerm.java
index 4c83bc8..b81dbc0 100644
--- a/current/src/main/java/com/sun/mail/imap/OlderTerm.java
+++ b/current/src/main/java/com/sun/mail/imap/OlderTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -83,6 +83,7 @@
* received date
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Date d;
@@ -102,6 +103,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof OlderTerm))
return false;
@@ -111,6 +113,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return interval;
}
diff --git a/current/src/main/java/com/sun/mail/imap/ReferralException.java b/current/src/main/java/com/sun/mail/imap/ReferralException.java
index cbea3b1..d99b9ab 100644
--- a/current/src/main/java/com/sun/mail/imap/ReferralException.java
+++ b/current/src/main/java/com/sun/mail/imap/ReferralException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/ResyncData.java b/current/src/main/java/com/sun/mail/imap/ResyncData.java
index ed27ba8..2719ffc 100644
--- a/current/src/main/java/com/sun/mail/imap/ResyncData.java
+++ b/current/src/main/java/com/sun/mail/imap/ResyncData.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/Rights.java b/current/src/main/java/com/sun/mail/imap/Rights.java
index a9499ad..11f2789 100644
--- a/current/src/main/java/com/sun/mail/imap/Rights.java
+++ b/current/src/main/java/com/sun/mail/imap/Rights.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -159,6 +159,7 @@
return cache[(int)right];
}
+ @Override
public String toString() {
return String.valueOf(right);
}
@@ -272,6 +273,7 @@
*
* @return true if they're equal
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof Rights))
return false;
@@ -290,6 +292,7 @@
*
* @return the hash code
*/
+ @Override
public int hashCode() {
int hash = 0;
for (int i = 0; i < this.rights.length; i++)
@@ -305,7 +308,7 @@
* @return array of Rights.Right objects representing rights
*/
public Right[] getRights() {
- List<Right> v = new ArrayList<Right>();
+ List<Right> v = new ArrayList<>();
for (int i = 0; i < this.rights.length; i++)
if (this.rights[i])
v.add(Right.getInstance((char)i));
@@ -315,6 +318,7 @@
/**
* Returns a clone of this Rights object.
*/
+ @Override
public Object clone() {
Rights r = null;
try {
@@ -327,8 +331,9 @@
return r;
}
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i = 0; i < this.rights.length; i++)
if (this.rights[i])
sb.append((char)i);
diff --git a/current/src/main/java/com/sun/mail/imap/SortTerm.java b/current/src/main/java/com/sun/mail/imap/SortTerm.java
index 8d93954..6ff30cb 100644
--- a/current/src/main/java/com/sun/mail/imap/SortTerm.java
+++ b/current/src/main/java/com/sun/mail/imap/SortTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -98,6 +98,7 @@
this.term = term;
}
+ @Override
public String toString() {
return term;
}
diff --git a/current/src/main/java/com/sun/mail/imap/Utility.java b/current/src/main/java/com/sun/mail/imap/Utility.java
index c914520..0490a29 100644
--- a/current/src/main/java/com/sun/mail/imap/Utility.java
+++ b/current/src/main/java/com/sun/mail/imap/Utility.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -77,7 +77,7 @@
* @return the MessageSet array
*/
public static MessageSet[] toMessageSet(Message[] msgs, Condition cond) {
- List<MessageSet> v = new ArrayList<MessageSet>(1);
+ List<MessageSet> v = new ArrayList<>(1);
int current, next;
IMAPMessage msg;
@@ -154,7 +154,7 @@
msgs = msgs.clone();
Arrays.sort(msgs,
new Comparator<Message>() {
- //@Override
+ @Override
public int compare(Message msg1, Message msg2) {
return msg1.getMessageNumber() - msg2.getMessageNumber();
}
@@ -170,7 +170,7 @@
* @return the UIDSet array
*/
public static UIDSet[] toUIDSet(Message[] msgs) {
- List<UIDSet> v = new ArrayList<UIDSet>(1);
+ List<UIDSet> v = new ArrayList<>(1);
long current, next;
IMAPMessage msg;
diff --git a/current/src/main/java/com/sun/mail/imap/YoungerTerm.java b/current/src/main/java/com/sun/mail/imap/YoungerTerm.java
index 3484328..535a57e 100644
--- a/current/src/main/java/com/sun/mail/imap/YoungerTerm.java
+++ b/current/src/main/java/com/sun/mail/imap/YoungerTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -83,6 +83,7 @@
* received date
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Date d;
@@ -102,6 +103,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof YoungerTerm))
return false;
@@ -111,6 +113,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return interval;
}
diff --git a/current/src/main/java/com/sun/mail/imap/package.html b/current/src/main/java/com/sun/mail/imap/package.html
deleted file mode 100644
index 9ce77bf..0000000
--- a/current/src/main/java/com/sun/mail/imap/package.html
+++ /dev/null
@@ -1,1002 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-An IMAP protocol provider for the JavaMail API
-that provides access to an IMAP message store.
-Both the IMAP4 and IMAP4rev1 protocols are supported.
-Refer to <A HREF="http://www.ietf.org/rfc/rfc3501.txt" TARGET="_top">
-RFC 3501</A>
-for more information.
-The IMAP protocol provider also supports many IMAP extensions (described below).
-Note that the server needs to support these extensions (and not all servers do)
-in order to use the support in the IMAP provider.
-You can query the server for support of these extensions using the
-{@link com.sun.mail.imap.IMAPStore#hasCapability IMAPStore hasCapability}
-method using the capability name defined by the extension
-(see the appropriate RFC) after connecting to the server.
-<H4>UIDPLUS Support</H4>
-<P>
-The IMAP UIDPLUS extension
-(<A HREF="http://www.ietf.org/rfc/rfc4315.txt" TARGET="_top">RFC 4315</A>)
-is supported via the IMAPFolder methods
-{@link com.sun.mail.imap.IMAPFolder#addMessages addMessages},
-{@link com.sun.mail.imap.IMAPFolder#appendUIDMessages appendUIDMessages}, and
-{@link com.sun.mail.imap.IMAPFolder#copyUIDMessages copyUIDMessages}.
-<H4>MOVE Support</H4>
-<P>
-The IMAP MOVE extension
-(<A HREF="http://www.ietf.org/rfc/rfc6851.txt" TARGET="_top">RFC 6851</A>)
-is supported via the IMAPFolder methods
-{@link com.sun.mail.imap.IMAPFolder#moveMessages moveMessages} and
-{@link com.sun.mail.imap.IMAPFolder#moveUIDMessages moveUIDMessages}.
-<H4>SASL Support</H4>
-<P>
-The IMAP protocol provider can use SASL
-(<A HREF="http://www.ietf.org/rfc/rfc4422.txt" TARGET="_top">RFC 4422</A>)
-authentication mechanisms on systems that support the
-<CODE>javax.security.sasl</CODE> APIs.
-The SASL-IR
-(<A HREF="http://www.ietf.org/rfc/rfc4959.txt" TARGET="_top">RFC 4959</A>)
-capability is also supported.
-In addition to the SASL mechanisms that are built into
-the SASL implementation, users can also provide additional
-SASL mechanisms of their own design to support custom authentication
-schemes. See the
-<A HREF="http://download.oracle.com/javase/6/docs/technotes/guides/security/sasl/sasl-refguide.html" TARGET="_top">
-Java SASL API Programming and Deployment Guide</A> for details.
-Note that the current implementation doesn't support SASL mechanisms
-that provide their own integrity or confidentiality layer.
-<H4>OAuth 2.0 Support</H4>
-Support for OAuth 2.0 authentication via the
-<A HREF="https://developers.google.com/gmail/xoauth2_protocol" TARGET="_top">
-XOAUTH2 authentication mechanism</A> is provided either through the SASL
-support described above or as a built-in authentication mechanism in the
-IMAP provider.
-The OAuth 2.0 Access Token should be passed as the password for this mechanism.
-See <A HREF="https://java.net/projects/javamail/pages/OAuth2" TARGET="_top">
-OAuth2 Support</A> for details.
-<H4>Connection Pool</H4>
-<P>
-A connected IMAPStore maintains a pool of IMAP protocol objects for
-use in communicating with the IMAP server. The IMAPStore will create
-the initial AUTHENTICATED connection and seed the pool with this
-connection. As folders are opened and new IMAP protocol objects are
-needed, the IMAPStore will provide them from the connection pool,
-or create them if none are available. When a folder is closed,
-its IMAP protocol object is returned to the connection pool if the
-pool is not over capacity.
-<P>
-A mechanism is provided for timing out idle connection pool IMAP
-protocol objects. Timed out connections are closed and removed (pruned)
-from the connection pool.
-<P>
-The connected IMAPStore object may or may not maintain a separate IMAP
-protocol object that provides the store a dedicated connection to the
-IMAP server. This is provided mainly for compatibility with previous
-implementations of the IMAP protocol provider.
-<H4>QUOTA Support</H4>
-<P>
-The IMAP QUOTA extension
-(<A HREF="http://www.ietf.org/rfc/rfc2087.txt" TARGET="_top">RFC 2087</A>)
-is supported via the
-{@link javax.mail.QuotaAwareStore QuotaAwareStore} interface implemented by
-{@link com.sun.mail.imap.IMAPStore IMAPStore}, and the
-{@link com.sun.mail.imap.IMAPFolder#getQuota IMAPFolder getQuota} and
-{@link com.sun.mail.imap.IMAPFolder#setQuota IMAPFolder setQuota} methods.
-<H4>ACL Support</H4>
-<P>
-The IMAP ACL extension
-(<A HREF="http://www.ietf.org/rfc/rfc2086.txt" TARGET="_top">RFC 2086</A>)
-is supported via the
-{@link com.sun.mail.imap.Rights Rights} class and the IMAPFolder methods
-{@link com.sun.mail.imap.IMAPFolder#getACL getACL},
-{@link com.sun.mail.imap.IMAPFolder#addACL addACL},
-{@link com.sun.mail.imap.IMAPFolder#removeACL removeACL},
-{@link com.sun.mail.imap.IMAPFolder#addRights addRights},
-{@link com.sun.mail.imap.IMAPFolder#removeRights removeRights},
-{@link com.sun.mail.imap.IMAPFolder#listRights listRights}, and
-{@link com.sun.mail.imap.IMAPFolder#myRights myRights}.
-<H4>SORT Support</H4>
-<P>
-The IMAP SORT extension
-(<A HREF="http://www.ietf.org/rfc/rfc5256.txt" TARGET="_top">RFC 5256</A>)
-is supported via the
-{@link com.sun.mail.imap.SortTerm SortTerm} class and the IMAPFolder
-{@link com.sun.mail.imap.IMAPFolder#getSortedMessages getSortedMessages}
-methods.
-<H4>CONDSTORE and QRESYNC Support</H4>
-<P>
-Basic support is provided for the IMAP CONDSTORE
-(<A HREF="http://www.ietf.org/rfc/rfc4551.txt" TARGET="_top">RFC 4551</A>)
-and QRESYNC
-(<A HREF="http://www.ietf.org/rfc/rfc5162.txt" TARGET="_top">RFC 5162</A>)
-extensions for the purpose of resynchronizing a folder after offline operation.
-Of course, the server must support these extensions.
-Use of these extensions is enabled by using the new
-{@link com.sun.mail.imap.IMAPFolder#open(int,com.sun.mail.imap.ResyncData)
-IMAPFolder open} method and supplying an appropriate
-{@link com.sun.mail.imap.ResyncData ResyncData} instance.
-Using
-{@link com.sun.mail.imap.ResyncData#CONDSTORE ResyncData.CONDSTORE}
-enables the CONDSTORE extension, which allows you to discover the
-modification sequence number (modseq) of messages using the
-{@link com.sun.mail.imap.IMAPMessage#getModSeq IMAPMessage getModSeq}
-method and the
-{@link com.sun.mail.imap.IMAPFolder#getHighestModSeq
-IMAPFolder getHighestModSeq} method.
-Using a
-{@link com.sun.mail.imap.ResyncData ResyncData} instance with appropriate
-values also allows the server to report any changes in messages since the last
-resynchronization.
-The changes are reported as a list of
-{@link javax.mail.event.MailEvent MailEvent} instances.
-The special
-{@link com.sun.mail.imap.MessageVanishedEvent MessageVanishedEvent} reports on
-UIDs of messages that have been removed since the last resynchronization.
-A
-{@link javax.mail.event.MessageChangedEvent MessageChangedEvent} reports on
-changes to flags of messages.
-For example:
-<PRE>
- Folder folder = store.getFolder("whatever");
- IMAPFolder ifolder = (IMAPFolder)folder;
- List<MailEvent> events = ifolder.open(Folder.READ_WRITE,
- new ResyncData(prevUidValidity, prevModSeq));
- for (MailEvent ev : events) {
- if (ev instanceOf MessageChangedEvent) {
- // process flag changes
- } else if (ev instanceof MessageVanishedEvent) {
- // process messages that were removed
- }
- }
-</PRE>
-See the referenced RFCs for more details on these IMAP extensions.
-<H4>WITHIN Search Support</H4>
-<P>
-The IMAP WITHIN search extension
-(<A HREF="http://www.ietf.org/rfc/rfc5032.txt" TARGET="_top">RFC 5032</A>)
-is supported via the
-{@link com.sun.mail.imap.YoungerTerm YoungerTerm} and
-{@link com.sun.mail.imap.OlderTerm OlderTerm}
-{@link javax.mail.search.SearchTerm SearchTerms}, which can be used as follows:
-<PRE>
- // search for messages delivered in the last day
- Message[] msgs = folder.search(new YoungerTerm(24 * 60 * 60));
-</PRE>
-<H4>LOGIN-REFERRAL Support</H4>
-<P>
-The IMAP LOGIN-REFERRAL extension
-(<A HREF="http://www.ietf.org/rfc/rfc2221.txt" TARGET="_top">RFC 2221</A>)
-is supported.
-If a login referral is received when connecting or when authentication fails, a
-{@link com.sun.mail.imap.ReferralException ReferralException} is thrown.
-A referral can also occur when login succeeds. By default, no exception is
-thrown in this case. To force an exception to be thrown and the authentication
-to fail, set the <code>mail.imap.referralexception</code> property to "true".
-<H4>COMPRESS Support</H4>
-<P>
-The IMAP COMPRESS extension
-(<A HREF="http://www.ietf.org/rfc/rfc4978.txt" TARGET="_top">RFC 4978</A>)
-is supported.
-If the server supports the extension and the
-<code>mail.imap.compress.enable</code> property is set to "true",
-compression will be enabled.
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-<P>
-The IMAP protocol provider supports the following properties,
-which may be set in the JavaMail <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- props.put("mail.imap.port", "888");
-</PRE>
-to set the <CODE>mail.imap.port</CODE> property, which is of type int.
-<P>
-Note that if you're using the "imaps" protocol to access IMAP over SSL,
-all the properties would be named "mail.imaps.*".
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.imap.user"></A>
-<TR id="mail.imap.user">
-<TD>mail.imap.user</TD>
-<TD>String</TD>
-<TD>Default user name for IMAP.</TD>
-</TR>
-
-<A NAME="mail.imap.host"></A>
-<TR id="mail.imap.host">
-<TD>mail.imap.host</TD>
-<TD>String</TD>
-<TD>The IMAP server to connect to.</TD>
-</TR>
-
-<A NAME="mail.imap.port"></A>
-<TR id="mail.imap.port">
-<TD>mail.imap.port</TD>
-<TD>int</TD>
-<TD>The IMAP server port to connect to, if the connect() method doesn't
-explicitly specify one. Defaults to 143.</TD>
-</TR>
-
-<A NAME="mail.imap.partialfetch"></A>
-<TR id="mail.imap.partialfetch">
-<TD>mail.imap.partialfetch</TD>
-<TD>boolean</TD>
-<TD>Controls whether the IMAP partial-fetch capability should be used.
-Defaults to true.</TD>
-</TR>
-
-<A NAME="mail.imap.fetchsize"></A>
-<TR id="mail.imap.fetchsize">
-<TD>mail.imap.fetchsize</TD>
-<TD>int</TD>
-<TD>Partial fetch size in bytes. Defaults to 16K.</TD>
-</TR>
-
-<A NAME="mail.imap.peek"></A>
-<TR id="mail.imap.peek">
-<TD>mail.imap.peek</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use the IMAP PEEK option when fetching body parts,
-to avoid setting the SEEN flag on messages.
-Defaults to false.
-Can be overridden on a per-message basis by the
-{@link com.sun.mail.imap.IMAPMessage#setPeek setPeek}
-method on IMAPMessage.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ignorebodystructuresize"></A>
-<TR id="mail.imap.ignorebodystructuresize">
-<TD>mail.imap.ignorebodystructuresize</TD>
-<TD>boolean</TD>
-<TD>The IMAP BODYSTRUCTURE response includes the exact size of each body part.
-Normally, this size is used to determine how much data to fetch for each
-body part.
-Some servers report this size incorrectly in some cases; this property can
-be set to work around such server bugs.
-If this property is set to true, this size is ignored and data is fetched
-until the server reports the end of data.
-This will result in an extra fetch if the data size is a multiple of the
-block size.
-Defaults to false.</TD>
-</TR>
-
-<A NAME="mail.imap.connectiontimeout"></A>
-<TR id="mail.imap.connectiontimeout">
-<TD>mail.imap.connectiontimeout</TD>
-<TD>int</TD>
-<TD>Socket connection timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.imap.timeout"></A>
-<TR id="mail.imap.timeout">
-<TD>mail.imap.timeout</TD>
-<TD>int</TD>
-<TD>Socket read timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.imap.writetimeout"></A>
-<TR id="mail.imap.writetimeout">
-<TD>mail.imap.writetimeout</TD>
-<TD>int</TD>
-<TD>Socket write timeout value in milliseconds.
-This timeout is implemented by using a
-java.util.concurrent.ScheduledExecutorService per connection
-that schedules a thread to close the socket if the timeout expires.
-Thus, the overhead of using this timeout is one thread per connection.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.imap.statuscachetimeout"></A>
-<TR id="mail.imap.statuscachetimeout">
-<TD>mail.imap.statuscachetimeout</TD>
-<TD>int</TD>
-<TD>Timeout value in milliseconds for cache of STATUS command response.
-Default is 1000 (1 second). Zero disables cache.</TD>
-</TR>
-
-<A NAME="mail.imap.appendbuffersize"></A>
-<TR id="mail.imap.appendbuffersize">
-<TD>mail.imap.appendbuffersize</TD>
-<TD>int</TD>
-<TD>
-Maximum size of a message to buffer in memory when appending to an IMAP
-folder. If not set, or set to -1, there is no maximum and all messages
-are buffered. If set to 0, no messages are buffered. If set to (e.g.)
-8192, messages of 8K bytes or less are buffered, larger messages are
-not buffered. Buffering saves cpu time at the expense of short term
-memory usage. If you commonly append very large messages to IMAP
-mailboxes you might want to set this to a moderate value (1M or less).
-</TD>
-</TR>
-
-<A NAME="mail.imap.connectionpoolsize"></A>
-<TR id="mail.imap.connectionpoolsize">
-<TD>mail.imap.connectionpoolsize</TD>
-<TD>int</TD>
-<TD>Maximum number of available connections in the connection pool.
-Default is 1.</TD>
-</TR>
-
-<A NAME="mail.imap.connectionpooltimeout"></A>
-<TR id="mail.imap.connectionpooltimeout">
-<TD>mail.imap.connectionpooltimeout</TD>
-<TD>int</TD>
-<TD>Timeout value in milliseconds for connection pool connections. Default
-is 45000 (45 seconds).</TD>
-</TR>
-
-<A NAME="mail.imap.separatestoreconnection"></A>
-<TR id="mail.imap.separatestoreconnection">
-<TD>mail.imap.separatestoreconnection</TD>
-<TD>boolean</TD>
-<TD>Flag to indicate whether to use a dedicated store connection for store
-commands. Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.allowreadonlyselect"></A>
-<TR id="mail.imap.allowreadonlyselect">
-<TD>mail.imap.allowreadonlyselect</TD>
-<TD>boolean</TD>
-<TD>If false, attempts to open a folder read/write will fail
-if the SELECT command succeeds but indicates that the folder is READ-ONLY.
-This sometimes indicates that the folder contents can'tbe changed, but
-the flags are per-user and can be changed, such as might be the case for
-public shared folders. If true, such open attempts will succeed, allowing
-the flags to be changed. The <code>getMode</code> method on the
-<code>Folder</code> object will return <code>Folder.READ_ONLY</code>
-in this case even though the <code>open</code> method specified
-<code>Folder.READ_WRITE</code>. Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.auth.mechanisms"></A>
-<TR id="mail.imap.auth.mechanisms">
-<TD>mail.imap.auth.mechanisms</TD>
-<TD>String</TD>
-<TD>
-If set, lists the authentication mechanisms to consider, and the order
-in which to consider them. Only mechanisms supported by the server and
-supported by the current implementation will be used.
-The default is <code>"PLAIN LOGIN NTLM"</code>, which includes all
-the authentication mechanisms supported by the current implementation
-except XOAUTH2.
-</TD>
-</TR>
-
-<A NAME="mail.imap.auth.login.disable"></A>
-<TR id="mail.imap.auth.login.disable">
-<TD>mail.imap.auth.login.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the non-standard <code>AUTHENTICATE LOGIN</code>
-command, instead using the plain <code>LOGIN</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.auth.plain.disable"></A>
-<TR id="mail.imap.auth.plain.disable">
-<TD>mail.imap.auth.plain.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTHENTICATE PLAIN</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.auth.ntlm.disable"></A>
-<TR id="mail.imap.auth.ntlm.disable">
-<TD>mail.imap.auth.ntlm.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTHENTICATE NTLM</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.auth.ntlm.domain"></A>
-<TR id="mail.imap.auth.ntlm.domain">
-<TD>mail.imap.auth.ntlm.domain</TD>
-<TD>String</TD>
-<TD>
-The NTLM authentication domain.
-</TD>
-</TR>
-
-<A NAME="mail.imap.auth.ntlm.flags"></A>
-<TR id="mail.imap.auth.ntlm.flags">
-<TD>mail.imap.auth.ntlm.flags</TD>
-<TD>int</TD>
-<TD>
-NTLM protocol-specific flags.
-See <A HREF="http://curl.haxx.se/rfc/ntlm.html#theNtlmFlags" TARGET="_top">
-http://curl.haxx.se/rfc/ntlm.html#theNtlmFlags</A> for details.
-</TD>
-</TR>
-
-<A NAME="mail.imap.auth.xoauth2.disable"></A>
-<TR id="mail.imap.auth.xoauth2.disable">
-<TD>mail.imap.auth.xoauth2.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTHENTICATE XOAUTH2</code> command.
-Because the OAuth 2.0 protocol requires a special access token instead of
-a password, this mechanism is disabled by default. Enable it by explicitly
-setting this property to "false" or by setting the "mail.imap.auth.mechanisms"
-property to "XOAUTH2".</TD>
-</TR>
-
-<A NAME="mail.imap.proxyauth.user"></A>
-<TR id="mail.imap.proxyauth.user">
-<TD>mail.imap.proxyauth.user</TD>
-<TD>String</TD>
-<TD>If the server supports the PROXYAUTH extension, this property
-specifies the name of the user to act as. Authenticate to the
-server using the administrator's credentials. After authentication,
-the IMAP provider will issue the <code>PROXYAUTH</code> command with
-the user name specified in this property.
-</TD>
-</TR>
-
-<A NAME="mail.imap.localaddress"></A>
-<TR id="mail.imap.localaddress">
-<TD>mail.imap.localaddress</TD>
-<TD>String</TD>
-<TD>
-Local address (host name) to bind to when creating the IMAP socket.
-Defaults to the address picked by the Socket class.
-Should not normally need to be set, but useful with multi-homed hosts
-where it's important to pick a particular local address to bind to.
-</TD>
-</TR>
-
-<A NAME="mail.imap.localport"></A>
-<TR id="mail.imap.localport">
-<TD>mail.imap.localport</TD>
-<TD>int</TD>
-<TD>
-Local port number to bind to when creating the IMAP socket.
-Defaults to the port number picked by the Socket class.
-</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.enable"></A>
-<TR id="mail.imap.sasl.enable">
-<TD>mail.imap.sasl.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, attempt to use the javax.security.sasl package to
-choose an authentication mechanism for login.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.mechanisms"></A>
-<TR id="mail.imap.sasl.mechanisms">
-<TD>mail.imap.sasl.mechanisms</TD>
-<TD>String</TD>
-<TD>
-A space or comma separated list of SASL mechanism names to try
-to use.
-</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.authorizationid"></A>
-<TR id="mail.imap.sasl.authorizationid">
-<TD>mail.imap.sasl.authorizationid</TD>
-<TD>String</TD>
-<TD>
-The authorization ID to use in the SASL authentication.
-If not set, the authentication ID (user name) is used.
-</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.realm"></A>
-<TR id="mail.imap.sasl.realm">
-<TD>mail.imap.sasl.realm</TD>
-<TD>String</TD>
-<TD>The realm to use with SASL authentication mechanisms that
-require a realm, such as DIGEST-MD5.</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.usecanonicalhostname"></A>
-<TR id="mail.imap.sasl.usecanonicalhostname">
-<TD>mail.imap.sasl.usecanonicalhostname</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the canonical host name returned by
-{@link java.net.InetAddress#getCanonicalHostName InetAddress.getCanonicalHostName}
-is passed to the SASL mechanism, instead of the host name used to connect.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.sasl.xgwtrustedapphack.enable"></A>
-<TR id="mail.imap.sasl.xgwtrustedapphack.enable">
-<TD>mail.imap.sasl. xgwtrustedapphack.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, enables a workaround for a bug in the Novell Groupwise
-XGWTRUSTEDAPP SASL mechanism, when that mechanism is being used.
-Defaults to true.
-</TD>
-</TR>
-
-<A NAME="mail.imap.socketFactory"></A>
-<TR id="mail.imap.socketFactory">
-<TD>mail.imap.socketFactory</TD>
-<TD>SocketFactory</TD>
-<TD>
-If set to a class that implements the
-<code>javax.net.SocketFactory</code> interface, this class
-will be used to create IMAP sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.imap.socketFactory.class"></A>
-<TR id="mail.imap.socketFactory.class">
-<TD>mail.imap.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that implements the
-<code>javax.net.SocketFactory</code> interface. This class
-will be used to create IMAP sockets.
-</TD>
-</TR>
-
-<A NAME="mail.imap.socketFactory.fallback"></A>
-<TR id="mail.imap.socketFactory.fallback">
-<TD>mail.imap.socketFactory.fallback</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, failure to create a socket using the specified
-socket factory class will cause the socket to be created using
-the <code>java.net.Socket</code> class.
-Defaults to true.
-</TD>
-</TR>
-
-<A NAME="mail.imap.socketFactory.port"></A>
-<TR id="mail.imap.socketFactory.port">
-<TD>mail.imap.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.imap.usesocketchannels"></A>
-<TR id="mail.imap.usesocketchannels">
-<TD>mail.imap.usesocketchannels</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use SocketChannels instead of Sockets for connecting
-to the server. Required if using the IdleManager.
-Ignored if a socket factory is set.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.enable"></A>
-<TR id="mail.imap.ssl.enable">
-<TD>mail.imap.ssl.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use SSL to connect and use the SSL port by default.
-Defaults to false for the "imap" protocol and true for the "imaps" protocol.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.checkserveridentity"></A>
-<TR id="mail.imap.ssl.checkserveridentity">
-<TD>mail.imap.ssl.checkserveridentity</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, check the server identity as specified by
-<A HREF="http://www.ietf.org/rfc/rfc2595.txt" TARGET="_top">RFC 2595</A>.
-These additional checks based on the content of the server's certificate
-are intended to prevent man-in-the-middle attacks.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.trust"></A>
-<TR id="mail.imap.ssl.trust">
-<TD>mail.imap.ssl.trust</TD>
-<TD>String</TD>
-<TD>
-If set, and a socket factory hasn't been specified, enables use of a
-{@link com.sun.mail.util.MailSSLSocketFactory MailSSLSocketFactory}.
-If set to "*", all hosts are trusted.
-If set to a whitespace separated list of hosts, those hosts are trusted.
-Otherwise, trust depends on the certificate the server presents.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.socketFactory"></A>
-<TR id="mail.imap.ssl.socketFactory">
-<TD>mail.imap.ssl.socketFactory</TD>
-<TD>SSLSocketFactory</TD>
-<TD>
-If set to a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class, this class
-will be used to create IMAP SSL sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.socketFactory.class"></A>
-<TR id="mail.imap.ssl.socketFactory.class">
-<TD>mail.imap.ssl.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class. This class
-will be used to create IMAP SSL sockets.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.socketFactory.port"></A>
-<TR id="mail.imap.ssl.socketFactory.port">
-<TD>mail.imap.ssl.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.protocols"></A>
-<TR id="mail.imap.ssl.protocols">
-<TD>mail.imap.ssl.protocols</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL protocols that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledProtocols</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.imap.ssl.ciphersuites"></A>
-<TR id="mail.imap.ssl.ciphersuites">
-<TD>mail.imap.ssl.ciphersuites</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL cipher suites that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledCipherSuites</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.imap.starttls.enable"></A>
-<TR id="mail.imap.starttls.enable">
-<TD>mail.imap.starttls.enable</TD>
-<TD>boolean</TD>
-<TD>If true, enables the use of the <code>STARTTLS</code> command (if
-supported by the server) to switch the connection to a TLS-protected
-connection before issuing any login commands. Note that an appropriate
-trust store must configured so that the client will trust the server's
-certificate. This feature only works on J2SE 1.4 and newer systems.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.imap.starttls.required"></A>
-<TR id="mail.imap.starttls.required">
-<TD>mail.imap.starttls.required</TD>
-<TD>boolean</TD>
-<TD>
-If true, requires the use of the <code>STARTTLS</code> command.
-If the server doesn't support the STARTTLS command, or the command
-fails, the connect method will fail.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.socks.host"></A>
-<TR id="mail.imap.socks.host">
-<TD>mail.imap.socks.host</TD>
-<TD>string</TD>
-<TD>
-Specifies the host name of a SOCKS5 proxy server that will be used for
-connections to the mail server.
-(Note that this only works on JDK 1.5 or newer.)
-</TD>
-</TR>
-
-<A NAME="mail.imap.socks.port"></A>
-<TR id="mail.imap.socks.port">
-<TD>mail.imap.socks.port</TD>
-<TD>string</TD>
-<TD>
-Specifies the port number for the SOCKS5 proxy server.
-This should only need to be used if the proxy server is not using
-the standard port number of 1080.
-</TD>
-</TR>
-
-<A NAME="mail.imap.minidletime"></A>
-<TR id="mail.imap.minidletime">
-<TD>mail.imap.minidletime</TD>
-<TD>int</TD>
-<TD>
-Applications typically call the idle method in a loop. If another
-thread termiantes the IDLE command, it needs a chance to do its
-work before another IDLE command is issued. The idle method enforces
-a delay to prevent thrashing between the IDLE command and regular
-commands. This property sets the delay in milliseconds. If not
-set, the default is 10 milliseconds.
-</TD>
-</TR>
-
-<A NAME="mail.imap.enableresponseevents"></A>
-<TR id="mail.imap.enableresponseevents">
-<TD>mail.imap.enableresponseevents</TD>
-<TD>boolean</TD>
-<TD>
-Enable special IMAP-specific events to be delivered to the Store's
-<code>ConnectionListener</code>. If true, IMAP OK, NO, BAD, or BYE responses
-will be sent as <code>ConnectionEvent</code>s with a type of
-<code>IMAPStore.RESPONSE</code>. The event's message will be the
-raw IMAP response string.
-By default, these events are not sent.
-NOTE: This capability is highly experimental and likely will change
-in future releases.
-</TD>
-</TR>
-
-<A NAME="mail.imap.enableimapevents"></A>
-<TR id="mail.imap.enableimapevents">
-<TD>mail.imap.enableimapevents</TD>
-<TD>boolean</TD>
-<TD>
-Enable special IMAP-specific events to be delivered to the Store's
-<code>ConnectionListener</code>. If true, unsolicited responses
-received during the Store's <code>idle</code> method will be sent
-as <code>ConnectionEvent</code>s with a type of
-<code>IMAPStore.RESPONSE</code>. The event's message will be the
-raw IMAP response string.
-By default, these events are not sent.
-NOTE: This capability is highly experimental and likely will change
-in future releases.
-</TD>
-</TR>
-
-<A NAME="mail.imap.throwsearchexception"></A>
-<TR id="mail.imap.throwsearchexception">
-<TD>mail.imap.throwsearchexception</TD>
-<TD>boolean</TD>
-<TD>
-If set to true and a {@link javax.mail.search.SearchTerm SearchTerm}
-passed to the
-{@link javax.mail.Folder#search Folder.search}
-method is too complex for the IMAP protocol, throw a
-{@link javax.mail.search.SearchException SearchException}.
-For example, the IMAP protocol only supports less-than and greater-than
-comparisons for a {@link javax.mail.search.SizeTerm SizeTerm}.
-If false, the search will be done locally by fetching the required
-message data and comparing it locally.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.folder.class"></A>
-<TR id="mail.imap.folder.class">
-<TD>mail.imap.folder.class</TD>
-<TD>String</TD>
-<TD>
-Class name of a subclass of <code>com.sun.mail.imap.IMAPFolder</code>.
-The subclass can be used to provide support for additional IMAP commands.
-The subclass must have public constructors of the form
-<code>public MyIMAPFolder(String fullName, char separator, IMAPStore store,
-Boolean isNamespace)</code> and
-<code>public MyIMAPFolder(ListInfo li, IMAPStore store)</code>
-</TD>
-</TR>
-
-<A NAME="mail.imap.closefoldersonstorefailure"></A>
-<TR id="mail.imap.closefoldersonstorefailure">
-<TD>mail.imap.closefoldersonstorefailure</TD>
-<TD>boolean</TD>
-<TD>
-In some cases, a failure of the Store connection indicates a failure of the
-server, and all Folders associated with that Store should also be closed.
-In other cases, a Store connection failure may be a transient failure, and
-Folders may continue to operate normally.
-If this property is true (the default), failures in the Store connection cause
-all associated Folders to be closed.
-Set this property to false to better handle transient failures in the Store
-connection.
-</TD>
-</TR>
-
-<A NAME="mail.imap.finalizecleanclose"></A>
-<TR id="mail.imap.finalizecleanclose">
-<TD>mail.imap.finalizecleanclose</TD>
-<TD>boolean</TD>
-<TD>
-When the finalizer for IMAPStore is called,
-should the connection to the server be closed cleanly, as if the
-application called the close method?
-Or should the connection to the server be closed without sending
-any commands to the server?
-Defaults to false, the connection is not closed cleanly.
-</TD>
-</TR>
-
-<A NAME="mail.imap.referralexception"></A>
-<TR id="mail.imap.referralexception">
-<TD>mail.imap.referralexception</TD>
-<TD>boolean</TD>
-<TD>
-If set to true and an IMAP login referral is returned when the authentication
-succeeds, fail the connect request and throw a
-{@link com.sun.mail.imap.ReferralException ReferralException}.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.compress.enable"></A>
-<TR id="mail.imap.compress.enable">
-<TD>mail.imap.compress.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true and the IMAP server supports the COMPRESS=DEFLATE extension,
-compression will be enabled.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.imap.compress.level"></A>
-<TR id="mail.imap.compress.level">
-<TD>mail.imap.compress.level</TD>
-<TD>int</TD>
-<TD>
-The compression level to be used, in the range -1 to 9.
-See the {@link java.util.zip.Deflater Deflater} class for details.
-</TD>
-</TR>
-
-<A NAME="mail.imap.compress.strategy"></A>
-<TR id="mail.imap.compress.strategy">
-<TD>mail.imap.compress.strategy</TD>
-<TD>int</TD>
-<TD>
-The compression strategy to be used, in the range 0 to 2.
-See the {@link java.util.zip.Deflater Deflater} class for details.
-</TD>
-</TR>
-
-</TABLE>
-<P>
-In general, applications should not need to use the classes in this
-package directly. Instead, they should use the APIs defined by
-<code>javax.mail</code> package (and subpackages). Applications should
-never construct instances of <code>IMAPStore</code> or
-<code>IMAPFolder</code> directly. Instead, they should use the
-<code>Session</code> method <code>getStore</code> to acquire an
-appropriate <code>Store</code> object, and from that acquire
-<code>Folder</code> objects.
-<H4>Loggers</H4>
-<P>
-In addition to printing debugging output as controlled by the
-{@link javax.mail.Session Session} configuration,
-the com.sun.mail.imap provider logs the same information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the IMAPStore</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap.connectionpool</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the IMAP connection pool</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap.connectionpool</TD>
-<TD>FINE</TD>
-<TD>Debugging output related to the IMAP connection pool</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap.messagecache</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the IMAP message cache</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap.messagecache</TD>
-<TD>FINE</TD>
-<TD>Debugging output related to the IMAP message cache</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.imap.protocol</TD>
-<TD>FINEST</TD>
-<TD>Complete protocol trace</TD>
-</TR>
-</TABLE>
-
-<P>
-<H4>WARNING</H4>
-<strong>WARNING:</strong> The APIs unique to this package should be
-considered <strong>EXPERIMENTAL</strong>. They may be changed in the
-future in ways that are incompatible with applications using the
-current APIs.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxDecoder.java b/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxDecoder.java
index 9f0a8df..3c5a58a 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxDecoder.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxDecoder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxEncoder.java b/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxEncoder.java
index 8330710..e31d321 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxEncoder.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/BASE64MailboxEncoder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/BODY.java b/current/src/main/java/com/sun/mail/imap/protocol/BODY.java
index f2b7309..406846e 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/BODY.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/BODY.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java b/current/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java
index 79e70b0..0c4d7fc 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/BODYSTRUCTURE.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -104,7 +104,7 @@
System.out.println("DEBUG IMAP: parsing multipart");
type = "multipart";
processedType = MULTI;
- List<BODYSTRUCTURE> v = new ArrayList<BODYSTRUCTURE>(1);
+ List<BODYSTRUCTURE> v = new ArrayList<>(1);
int i = 1;
do {
v.add(new BODYSTRUCTURE(r));
@@ -124,7 +124,7 @@
if (parseDebug)
System.out.println("DEBUG IMAP: subtype " + subtype);
- if (r.readByte() == ')') { // done
+ if (r.isNextNonSpace(')')) { // done
if (parseDebug)
System.out.println("DEBUG IMAP: parse DONE");
return;
@@ -136,23 +136,24 @@
System.out.println("DEBUG IMAP: parsing extension data");
// Body parameters
cParams = parseParameters(r);
- if (r.readByte() == ')') { // done
+ if (r.isNextNonSpace(')')) { // done
if (parseDebug)
System.out.println("DEBUG IMAP: body parameters DONE");
return;
}
// Disposition
- byte b = r.readByte();
+ byte b = r.peekByte();
if (b == '(') {
if (parseDebug)
System.out.println("DEBUG IMAP: parse disposition");
+ r.readByte();
disposition = r.readString();
if (parseDebug)
System.out.println("DEBUG IMAP: disposition " +
disposition);
dParams = parseParameters(r);
- if (r.readByte() != ')') // eat the end ')'
+ if (!r.isNextNonSpace(')')) // eat the end ')'
throw new ParsingException(
"BODYSTRUCTURE parse error: " +
"missing ``)'' at end of disposition in multipart");
@@ -161,27 +162,36 @@
} else if (b == 'N' || b == 'n') {
if (parseDebug)
System.out.println("DEBUG IMAP: disposition NIL");
- r.skip(2); // skip 'NIL'
+ r.skip(3); // skip 'NIL'
} else {
+ /*
throw new ParsingException(
"BODYSTRUCTURE parse error: " +
type + "/" + subtype + ": " +
"bad multipart disposition, b " + b);
+ */
+ if (parseDebug)
+ System.out.println("DEBUG IMAP: bad multipart disposition" +
+ ", applying Exchange bug workaround");
+ description = r.readString();
+ if (parseDebug)
+ System.out.println("DEBUG IMAP: multipart description " +
+ description);
+ // Throw away whatever comes after it, since we have no
+ // idea what it's supposed to be
+ while (r.readByte() == ' ')
+ parseBodyExtension(r);
+ return;
}
// RFC3501 allows no body-fld-lang after body-fld-disp,
// even though RFC2060 required it
- if ((b = r.readByte()) == ')') {
+ if (r.isNextNonSpace(')')) {
if (parseDebug)
System.out.println("DEBUG IMAP: no body-fld-lang");
return; // done
}
- if (b != ' ')
- throw new ParsingException(
- "BODYSTRUCTURE parse error: " +
- "missing space after disposition");
-
// Language
if (r.peekByte() == '(') { // a list follows
language = r.readStringList();
@@ -255,8 +265,18 @@
* returns unquoted string.
*/
encoding = r.readAtomString();
- if (encoding != null && encoding.equalsIgnoreCase("NIL"))
+ if (encoding != null && encoding.equalsIgnoreCase("NIL")) {
+ if (parseDebug)
+ System.out.println("DEBUG IMAP: NIL encoding" +
+ ", applying Exchange bug workaround");
encoding = null;
+ }
+ /*
+ * XXX - Work around bug in office365.com that returns
+ * a string with a trailing space in some cases.
+ */
+ if (encoding != null)
+ encoding = encoding.trim();
if (parseDebug)
System.out.println("DEBUG IMAP: encoding " + encoding);
size = r.readNumber();
@@ -312,8 +332,7 @@
type + "/" + subtype);
}
- if (r.peekByte() == ')') {
- r.readByte();
+ if (r.isNextNonSpace(')')) {
if (parseDebug)
System.out.println("DEBUG IMAP: parse DONE");
return; // done
@@ -323,7 +342,7 @@
// MD5
md5 = r.readString();
- if (r.readByte() == ')') {
+ if (r.isNextNonSpace(')')) {
if (parseDebug)
System.out.println("DEBUG IMAP: no MD5 DONE");
return; // done
@@ -339,7 +358,7 @@
dParams = parseParameters(r);
if (parseDebug)
System.out.println("DEBUG IMAP: dParams " + dParams);
- if (r.readByte() != ')') // eat the end ')'
+ if (!r.isNextNonSpace(')')) // eat the end ')'
throw new ParsingException(
"BODYSTRUCTURE parse error: " +
"missing ``)'' at end of disposition");
@@ -354,7 +373,7 @@
"bad single part disposition, b " + b);
}
- if (r.readByte() == ')') {
+ if (r.isNextNonSpace(')')) {
if (parseDebug)
System.out.println("DEBUG IMAP: disposition DONE");
return; // done
@@ -419,10 +438,14 @@
String value = r.readString();
if (parseDebug)
System.out.println("DEBUG IMAP: parameter value " + value);
- if (value == null) // work around buggy servers
+ if (value == null) { // work around buggy servers
+ if (parseDebug)
+ System.out.println("DEBUG IMAP: NIL parameter value" +
+ ", applying Exchange bug workaround");
value = "";
+ }
list.set(name, value);
- } while (r.readByte() != ')');
+ } while (!r.isNextNonSpace(')'));
list.combineSegments();
} else if (b == 'N' || b == 'n') {
if (parseDebug)
@@ -442,7 +465,7 @@
r.skip(1); // skip '('
do {
parseBodyExtension(r);
- } while (r.readByte() != ')');
+ } while (!r.isNextNonSpace(')'));
} else if (Character.isDigit((char)b)) // number
r.readNumber();
else // nstring
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java b/current/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
index e2cec58..1544acc 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/ENVELOPE.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -133,7 +133,7 @@
if (parseDebug)
System.out.println(" Message-ID: " + messageId);
- if (r.readByte() != ')')
+ if (!r.isNextNonSpace(')'))
throw new ParsingException("ENVELOPE parse error");
}
@@ -148,12 +148,10 @@
* list instead of NIL. Handle that here even though it
* doesn't conform to the IMAP spec.
*/
- if (r.peekByte() == ')') {
- r.skip(1);
+ if (r.isNextNonSpace(')'))
return null;
- }
- List<InternetAddress> v = new ArrayList<InternetAddress>();
+ List<InternetAddress> v = new ArrayList<>();
do {
IMAPAddress a = new IMAPAddress(r);
@@ -162,10 +160,7 @@
// if we see an end-of-group address at the top, ignore it
if (!a.isEndOfGroup())
v.add(a);
- } while (r.peekByte() != ')');
-
- // skip the terminating ')' at the end of the addresslist
- r.skip(1);
+ } while (!r.isNextNonSpace(')'));
return v.toArray(new InternetAddress[v.size()]);
} else if (b == 'N' || b == 'n') { // NIL
@@ -197,7 +192,7 @@
// skip bogus spaces inserted by Yahoo IMAP server if
// "undisclosed-recipients" is a recipient
r.skipSpaces();
- if (r.readByte() != ')') // skip past terminating ')'
+ if (!r.isNextNonSpace(')')) // skip past terminating ')'
throw new ParsingException("ADDRESS parse error");
if (host == null) {
@@ -208,10 +203,10 @@
return;
// Accumulate a group list. The members of the group
// are accumulated in a List and the corresponding string
- // representation of the group is accumulated in a StringBuffer.
- StringBuffer sb = new StringBuffer();
+ // representation of the group is accumulated in a StringBuilder.
+ StringBuilder sb = new StringBuilder();
sb.append(groupname).append(':');
- List<InternetAddress> v = new ArrayList<InternetAddress>();
+ List<InternetAddress> v = new ArrayList<>();
while (r.peekByte() != ')') {
IMAPAddress a = new IMAPAddress(r);
if (a.isEndOfGroup()) // reached end of group
@@ -239,10 +234,12 @@
return group && groupname == null;
}
+ @Override
public boolean isGroup() {
return group;
}
+ @Override
public InternetAddress[] getGroup(boolean strict) throws AddressException {
if (grouplist == null)
return null;
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/FLAGS.java b/current/src/main/java/com/sun/mail/imap/protocol/FLAGS.java
index 30a7f88..dc4c298 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/FLAGS.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/FLAGS.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/FetchItem.java b/current/src/main/java/com/sun/mail/imap/protocol/FetchItem.java
index d25029f..69e0902 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/FetchItem.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/FetchItem.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java b/current/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
index fd39289..fe42ed7 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/FetchResponse.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -42,7 +42,7 @@
import java.io.*;
import java.util.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.ASCIIUtility;
import com.sun.mail.iap.*;
/**
@@ -158,7 +158,7 @@
*/
public static <T extends Item> List<T> getItems(Response[] r, int msgno,
Class<T> c) {
- List<T> items = new ArrayList<T>();
+ List<T> items = new ArrayList<>();
if (r == null)
return items;
@@ -196,15 +196,14 @@
private final static char[] TEXT = {'.','T','E','X','T'};
private void parse() throws ParsingException {
- skipSpaces();
- if (buffer[index] != '(')
+ if (!isNextNonSpace('('))
throw new ParsingException(
"error in FETCH parsing, missing '(' at index " + index);
- List<Item> v = new ArrayList<Item>();
+ List<Item> v = new ArrayList<>();
Item i = null;
+ skipSpaces();
do {
- index++; // skip '(', or SPACE
if (index >= size)
throw new ParsingException(
@@ -217,9 +216,8 @@
throw new ParsingException(
"error in FETCH parsing, unrecognized item at index " +
index + ", starts with \"" + next20() + "\"");
- } while (buffer[index] != ')');
+ } while (!isNextNonSpace(')'));
- index++; // skip ')'
items = v.toArray(new Item[v.size()]);
}
@@ -228,7 +226,7 @@
*/
private String next20() {
if (index + 20 > size)
- return ASCIIUtility.toString(buffer, index, index + size);
+ return ASCIIUtility.toString(buffer, index, size);
else
return ASCIIUtility.toString(buffer, index, index + 20) + "...";
}
@@ -298,7 +296,7 @@
for (int i = 0; i < fitems.length; i++) {
if (match(fitems[i].getName())) {
if (extensionItems == null)
- extensionItems = new HashMap<String, Object>();
+ extensionItems = new HashMap<>();
extensionItems.put(fitems[i].getName(),
fitems[i].parseItem(this));
return true;
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/ID.java b/current/src/main/java/com/sun/mail/imap/protocol/ID.java
index 7bbe2d1..e75b0a1 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/ID.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/ID.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -75,7 +75,7 @@
if (c != '(')
throw new ProtocolException("Missing '(' at start of ID");
- serverParams = new HashMap<String, String>();
+ serverParams = new HashMap<>();
String[] v = r.readStringList();
if (v != null) {
@@ -112,7 +112,7 @@
Argument list = new Argument();
// add params to list
for (Map.Entry<String, String> e : clientParams.entrySet()) {
- list.writeNString(e.getKey());
+ list.writeNString(e.getKey()); // assume these are ASCII only
list.writeNString(e.getValue());
}
arg.writeArgument(list);
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java b/current/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
index 2252c2a..aacb703 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -45,12 +45,16 @@
import java.text.*;
import java.lang.reflect.*;
import java.util.logging.Level;
+import java.nio.charset.StandardCharsets;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.search.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.BASE64EncoderStream;
import com.sun.mail.iap.*;
import com.sun.mail.auth.Ntlm;
@@ -91,6 +95,7 @@
private List<String> authmechs;
// WARNING: authmechs may be initialized as a result of superclass
// constructor, don't initialize it here.
+ private boolean utf8; // UTF-8 support enabled?
protected SearchSequence searchSequence;
protected String[] searchCharsets; // array of search charsets
@@ -178,7 +183,7 @@
!PropUtil.getBooleanProperty(props, "mail.debug.auth", false);
if (capabilities == null)
- capabilities = new HashMap<String, String>();
+ capabilities = new HashMap<>();
searchCharsets = new String[2]; // 2, for now.
searchCharsets[0] = "UTF-8";
@@ -213,24 +218,38 @@
Response[] r = command("CAPABILITY", null);
Response response = r[r.length-1];
- if (response.isOK()) {
- capabilities = new HashMap<String, String>(10);
- authmechs = new ArrayList<String>(5);
- for (int i = 0, len = r.length; i < len; i++) {
- if (!(r[i] instanceof IMAPResponse))
- continue;
+ if (response.isOK())
+ handleCapabilityResponse(r);
+ handleResult(response);
+ }
- IMAPResponse ir = (IMAPResponse)r[i];
+ /**
+ * Handle any untagged CAPABILITY response in the Response array.
+ *
+ * @param r the responses
+ */
+ public void handleCapabilityResponse(Response[] r) {
+ boolean first = true;
+ for (int i = 0, len = r.length; i < len; i++) {
+ if (!(r[i] instanceof IMAPResponse))
+ continue;
- // Handle *all* untagged CAPABILITY responses.
- // Though the spec seemingly states that only
- // one CAPABILITY response string is allowed (6.1.1),
- // some server vendors claim otherwise.
- if (ir.keyEquals("CAPABILITY"))
- parseCapabilities(ir);
+ IMAPResponse ir = (IMAPResponse)r[i];
+
+ // Handle *all* untagged CAPABILITY responses.
+ // Though the spec seemingly states that only
+ // one CAPABILITY response string is allowed (6.1.1),
+ // some server vendors claim otherwise.
+ if (ir.keyEquals("CAPABILITY")) {
+ if (first) {
+ // clear out current when first response seen
+ capabilities = new HashMap<>(10);
+ authmechs = new ArrayList<>(5);
+ first = false;
+ }
+ parseCapabilities(ir);
}
}
- handleResult(response);
}
/**
@@ -249,8 +268,8 @@
s = r.readAtom();
if (!s.equalsIgnoreCase("CAPABILITY"))
return;
- capabilities = new HashMap<String, String>(10);
- authmechs = new ArrayList<String>(5);
+ capabilities = new HashMap<>(10);
+ authmechs = new ArrayList<>(5);
parseCapabilities(r);
}
@@ -295,6 +314,7 @@
* @param r the greeting response
* @exception ProtocolException for protocol failures
*/
+ @Override
protected void processGreeting(Response r) throws ProtocolException {
if (r.isBYE()) {
checkReferral(r); // may throw exception
@@ -373,6 +393,7 @@
*
* @return true if non-synchronizing literals are supported
*/
+ @Override
protected boolean supportsNonSyncLiterals() {
return hasCapability("LITERAL+");
}
@@ -384,6 +405,7 @@
* @exception IOException for I/O errors
* @exception ProtocolException for protocol failures
*/
+ @Override
public Response readResponse() throws IOException, ProtocolException {
// assert Thread.holdsLock(this);
// can't assert because it's called from constructor
@@ -425,11 +447,21 @@
}
/**
+ * Does the server support UTF-8?
+ *
+ * @since JavaMail 1.6.0
+ */
+ public boolean supportsUtf8() {
+ return utf8;
+ }
+
+ /**
* Close socket connection.
*
* This method just makes the Protocol.disconnect() method
* public.
*/
+ @Override
public void disconnect() {
super.disconnect();
authenticated = false; // just in case
@@ -489,6 +521,9 @@
resumeTracing();
}
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ handleCapabilityResponse(r);
+
// dispatch untagged responses
notifyResponseHandlers(r);
@@ -512,7 +547,7 @@
*/
public synchronized void authlogin(String u, String p)
throws ProtocolException {
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
@@ -567,7 +602,7 @@
s = p;
// obtain b64 encoded bytes
- b64os.write(ASCIIUtility.getBytes(s));
+ b64os.write(s.getBytes(StandardCharsets.UTF_8));
b64os.flush(); // complete the encoding
bos.write(CRLF); // CRLF termination
@@ -592,13 +627,18 @@
resumeTracing();
}
- /* Dispatch untagged responses.
+ Response[] responses = v.toArray(new Response[v.size()]);
+
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ handleCapabilityResponse(responses);
+
+ /*
+ * Dispatch untagged responses.
* NOTE: in our current upper level IMAP classes, we add the
* responseHandler to the Protocol object only *after* the
* connection has been authenticated. So, for now, the below
* code really ends up being just a no-op.
*/
- Response[] responses = v.toArray(new Response[v.size()]);
notifyResponseHandlers(responses);
// Handle the final OK, NO, BAD or BYE response
@@ -626,7 +666,7 @@
*/
public synchronized void authplain(String authzid, String u, String p)
throws ProtocolException {
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
@@ -677,7 +717,7 @@
nullByte + u + nullByte + p;
// obtain b64 encoded bytes
- b64os.write(ASCIIUtility.getBytes(s));
+ b64os.write(s.getBytes(StandardCharsets.UTF_8));
b64os.flush(); // complete the encoding
bos.write(CRLF); // CRLF termination
@@ -702,13 +742,18 @@
resumeTracing();
}
- /* Dispatch untagged responses.
+ Response[] responses = v.toArray(new Response[v.size()]);
+
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ handleCapabilityResponse(responses);
+
+ /*
+ * Dispatch untagged responses.
* NOTE: in our current upper level IMAP classes, we add the
* responseHandler to the Protocol object only *after* the
* connection has been authenticated. So, for now, the below
* code really ends up being just a no-op.
*/
- Response[] responses = v.toArray(new Response[v.size()]);
notifyResponseHandlers(responses);
// Handle the final OK, NO, BAD or BYE response
@@ -735,7 +780,7 @@
*/
public synchronized void authntlm(String authzid, String u, String p)
throws ProtocolException {
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
@@ -778,7 +823,7 @@
s = ntlm.generateType3Msg(r.getRest());
}
- os.write(ASCIIUtility.getBytes(s));
+ os.write(s.getBytes(StandardCharsets.UTF_8));
os.write(CRLF); // CRLF termination
os.flush(); // flush the stream
} else if (r.isTagged() && r.getTag().equals(tag))
@@ -799,6 +844,11 @@
resumeTracing();
}
+ Response[] responses = v.toArray(new Response[v.size()]);
+
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ handleCapabilityResponse(responses);
+
/*
* Dispatch untagged responses.
* NOTE: in our current upper level IMAP classes, we add the
@@ -806,7 +856,6 @@
* connection has been authenticated. So, for now, the below
* code really ends up being just a no-op.
*/
- Response[] responses = v.toArray(new Response[v.size()]);
notifyResponseHandlers(responses);
// Handle the final OK, NO, BAD or BYE response
@@ -832,7 +881,7 @@
*/
public synchronized void authoauth2(String u, String p)
throws ProtocolException {
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
@@ -850,7 +899,7 @@
if (hasCapability("SASL-IR")) {
String resp = "user=" + u + "\001auth=Bearer " + p + "\001\001";
byte[] ba = BASE64EncoderStream.encode(
- ASCIIUtility.getBytes(resp));
+ resp.getBytes(StandardCharsets.UTF_8));
String irs = ASCIIUtility.toString(ba, 0, ba.length);
args.writeAtom(irs);
}
@@ -871,7 +920,7 @@
String resp = "user=" + u + "\001auth=Bearer " +
p + "\001\001";
byte[] b = BASE64EncoderStream.encode(
- ASCIIUtility.getBytes(resp));
+ resp.getBytes(StandardCharsets.UTF_8));
os.write(b); // write out response
os.write(CRLF); // CRLF termination
os.flush(); // flush the stream
@@ -893,13 +942,18 @@
resumeTracing();
}
- /* Dispatch untagged responses.
+ Response[] responses = v.toArray(new Response[v.size()]);
+
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ handleCapabilityResponse(responses);
+
+ /*
+ * Dispatch untagged responses.
* NOTE: in our current upper level IMAP classes, we add the
* responseHandler to the Protocol object only *after* the
* connection has been authenticated. So, for now, the below
* code really ends up being just a no-op.
*/
- Response[] responses = v.toArray(new Response[v.size()]);
notifyResponseHandlers(responses);
// Handle the final OK, NO, BAD or BYE response
@@ -961,7 +1015,7 @@
List<String> v;
if (allowed != null && allowed.length > 0) {
// remove anything not supported by the server
- v = new ArrayList<String>(allowed.length);
+ v = new ArrayList<>(allowed.length);
for (int i = 0; i < allowed.length; i++)
if (authmechs.contains(allowed[i])) // XXX - case must match
v.add(allowed[i]);
@@ -1063,7 +1117,7 @@
@Deprecated
public void id(String guid) throws ProtocolException {
// support this for now, but remove it soon
- Map<String,String> gmap = new HashMap<String,String>();
+ Map<String,String> gmap = new HashMap<>();
gmap.put("GUID", guid);
id(gmap);
}
@@ -1121,6 +1175,23 @@
}
/**
+ * Encode a mailbox name appropriately depending on whether or not
+ * the server supports UTF-8, and add the encoded name to the
+ * Argument.
+ *
+ * @param args the arguments
+ * @param name the name to encode
+ * @since JavaMail 1.6.0
+ */
+ protected void writeMailboxName(Argument args, String name) {
+ if (utf8)
+ args.writeString(name, StandardCharsets.UTF_8);
+ else
+ // encode the mbox as per RFC2060
+ args.writeString(BASE64MailboxEncoder.encode(name));
+ }
+
+ /**
* SELECT Command.
*
* @param mbox the mailbox name
@@ -1145,11 +1216,8 @@
*/
public MailboxInfo select(String mbox, ResyncData rd)
throws ProtocolException {
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
if (rd != null) {
if (rd == ResyncData.CONDSTORE) {
@@ -1210,11 +1278,8 @@
*/
public MailboxInfo examine(String mbox, ResyncData rd)
throws ProtocolException {
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
if (rd != null) {
if (rd == ResyncData.CONDSTORE) {
@@ -1273,8 +1338,11 @@
args.writeAtom(cap);
simpleCommand("ENABLE", args);
if (enabled == null)
- enabled = new HashSet<String>();
+ enabled = new HashSet<>();
enabled.add(cap.toUpperCase(Locale.ENGLISH));
+
+ // update the utf8 flag
+ utf8 = isEnabled("UTF8=ACCEPT");
}
/**
@@ -1321,11 +1389,8 @@
// does support this.
throw new BadCommandException("STATUS not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Argument itemArgs = new Argument();
if (items == null)
@@ -1371,11 +1436,8 @@
* @see "RFC2060, section 6.3.3"
*/
public void create(String mbox) throws ProtocolException {
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
simpleCommand("CREATE", args);
}
@@ -1388,11 +1450,8 @@
* @see "RFC2060, section 6.3.4"
*/
public void delete(String mbox) throws ProtocolException {
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
simpleCommand("DELETE", args);
}
@@ -1406,13 +1465,9 @@
* @see "RFC2060, section 6.3.5"
*/
public void rename(String o, String n) throws ProtocolException {
- // encode the mbox as per RFC2060
- o = BASE64MailboxEncoder.encode(o);
- n = BASE64MailboxEncoder.encode(n);
-
Argument args = new Argument();
- args.writeString(o);
- args.writeString(n);
+ writeMailboxName(args, o);
+ writeMailboxName(args, n);
simpleCommand("RENAME", args);
}
@@ -1426,9 +1481,7 @@
*/
public void subscribe(String mbox) throws ProtocolException {
Argument args = new Argument();
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
simpleCommand("SUBSCRIBE", args);
}
@@ -1442,9 +1495,7 @@
*/
public void unsubscribe(String mbox) throws ProtocolException {
Argument args = new Argument();
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
simpleCommand("UNSUBSCRIBE", args);
}
@@ -1490,13 +1541,9 @@
*/
protected ListInfo[] doList(String cmd, String ref, String pat)
throws ProtocolException {
- // encode the mbox as per RFC2060
- ref = BASE64MailboxEncoder.encode(ref);
- pat = BASE64MailboxEncoder.encode(pat);
-
Argument args = new Argument();
- args.writeString(ref);
- args.writeString(pat);
+ writeMailboxName(args, ref);
+ writeMailboxName(args, pat);
Response[] r = command(cmd, args);
@@ -1504,7 +1551,7 @@
Response response = r[r.length-1];
if (response.isOK()) { // command succesful
- List<ListInfo> v = new ArrayList<ListInfo>(1);
+ List<ListInfo> v = new ArrayList<>(1);
for (int i = 0, len = r.length; i < len; i++) {
if (!(r[i] instanceof IMAPResponse))
continue;
@@ -1559,11 +1606,8 @@
public AppendUID appenduid(String mbox, Flags f, Date d,
Literal data, boolean uid) throws ProtocolException {
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
if (f != null) { // set Flags in appended message
// can't set the \Recent flag in APPEND
@@ -1849,6 +1893,7 @@
*
* @return the buffer to use
*/
+ @Override
protected ByteArray getResponseBuffer() {
ByteArray ret = ba;
ba = null;
@@ -2004,7 +2049,7 @@
"UID", true);
UID u;
- List<UID> v = new ArrayList<UID>();
+ List<UID> v = new ArrayList<>();
for (int i = 0, len = r.length; i < len; i++) {
if (r[i] == null || !(r[i] instanceof FetchResponse))
continue;
@@ -2035,7 +2080,7 @@
* @since JavaMail 1.5.3
*/
public void fetchSequenceNumbers(long[] uids) throws ProtocolException {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i = 0; i < uids.length; i++) {
if (i > 0)
sb.append(",");
@@ -2069,7 +2114,7 @@
Response[] r = command("UID FETCH " + msgSequence +
" (FLAGS) (CHANGEDSINCE " + String.valueOf(modseq) + ")", null);
- List<Integer> v = new ArrayList<Integer>();
+ List<Integer> v = new ArrayList<>();
for (int i = 0, len = r.length; i < len; i++) {
if (r[i] == null || !(r[i] instanceof FetchResponse))
continue;
@@ -2173,12 +2218,10 @@
throws ProtocolException {
if (uid && !hasCapability("UIDPLUS"))
throw new BadCommandException("UIDPLUS not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
Argument args = new Argument();
args.writeAtom(msgSequence);
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Response[] r = command("COPY", args);
@@ -2271,12 +2314,10 @@
throw new BadCommandException("MOVE not supported");
if (uid && !hasCapability("UIDPLUS"))
throw new BadCommandException("UIDPLUS not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
Argument args = new Argument();
args.writeAtom(msgSequence);
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Response[] r = command("MOVE", args);
@@ -2373,8 +2414,7 @@
* @since JavaMail 1.5.4
*/
protected String createFlagList(Flags flags) {
- StringBuffer sb = new StringBuffer();
- sb.append("("); // start of flag_list
+ StringBuilder sb = new StringBuilder("("); // start of flag_list
Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags
boolean first = true;
@@ -2453,17 +2493,20 @@
*/
private int[] search(String msgSequence, SearchTerm term)
throws ProtocolException, SearchException {
- // Check if the search "text" terms contain only ASCII chars
- if (SearchSequence.isAscii(term)) {
+ // Check if the search "text" terms contain only ASCII chars,
+ // or if utf8 support has been enabled (in which case CHARSET
+ // is not allowed; see RFC 6855, section 3, last paragraph)
+ if (supportsUtf8() || SearchSequence.isAscii(term)) {
try {
return issueSearch(msgSequence, term, null);
} catch (IOException ioex) { /* will not happen */ }
}
/*
- * The search "text" terms do contain non-ASCII chars. We need to
- * use SEARCH CHARSET <charset> ...
- * The charsets we try to use are UTF-8 and the locale's
+ * The search "text" terms do contain non-ASCII chars and utf8
+ * support has not been enabled. We need to use:
+ * "SEARCH CHARSET <charset> ..."
+ * The charsets we try to use are UTF-8 and the locale's
* default charset. If the server supports UTF-8, great,
* always use it. Else we try to use the default charset.
*/
@@ -2526,7 +2569,7 @@
// Grab all SEARCH responses
if (response.isOK()) { // command succesful
- List<Integer> v = new ArrayList<Integer>();
+ List<Integer> v = new ArrayList<>();
int num;
for (int i = 0, len = r.length; i < len; i++) {
if (!(r[i] instanceof IMAPResponse))
@@ -2566,7 +2609,7 @@
*/
protected SearchSequence getSearchSequence() {
if (searchSequence == null)
- searchSequence = new SearchSequence();
+ searchSequence = new SearchSequence(this);
return searchSequence;
}
@@ -2618,7 +2661,7 @@
// Grab all SORT responses
if (response.isOK()) { // command succesful
- List<Integer> v = new ArrayList<Integer>();
+ List<Integer> v = new ArrayList<>();
int num;
for (int i = 0, len = r.length; i < len; i++) {
if (!(r[i] instanceof IMAPResponse))
@@ -2698,17 +2741,14 @@
if (!hasCapability("QUOTA"))
throw new BadCommandException("GETQUOTAROOT not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Response[] r = command("GETQUOTAROOT", args);
Response response = r[r.length-1];
- Map<String, Quota> tab = new HashMap<String, Quota>();
+ Map<String, Quota> tab = new HashMap<>();
// Grab all QUOTAROOT and QUOTA responses
if (response.isOK()) { // command succesful
@@ -2771,12 +2811,12 @@
throw new BadCommandException("QUOTA not supported");
Argument args = new Argument();
- args.writeString(root);
+ args.writeString(root); // XXX - could be UTF-8?
Response[] r = command("GETQUOTA", args);
Quota quota = null;
- List<Quota> v = new ArrayList<Quota>();
+ List<Quota> v = new ArrayList<>();
Response response = r[r.length-1];
// Grab all QUOTA responses
@@ -2814,7 +2854,7 @@
throw new BadCommandException("QUOTA not supported");
Argument args = new Argument();
- args.writeString(quota.quotaRoot);
+ args.writeString(quota.quotaRoot); // XXX - could be UTF-8?
Argument qargs = new Argument();
if (quota.resources != null) {
for (int i = 0; i < quota.resources.length; i++) {
@@ -2871,8 +2911,8 @@
if (r.readByte() != '(')
throw new ParsingException("parse error in QUOTA");
- List<Quota.Resource> v = new ArrayList<Quota.Resource>();
- while (r.peekByte() != ')') {
+ List<Quota.Resource> v = new ArrayList<>();
+ while (!r.isNextNonSpace(')')) {
// quota_resource ::= atom SP number SP number
String name = r.readAtom();
if (name != null) {
@@ -2882,7 +2922,6 @@
v.add(res);
}
}
- r.readByte();
q.resources = v.toArray(new Quota.Resource[v.size()]);
return q;
}
@@ -2902,11 +2941,8 @@
if (!hasCapability("ACL"))
throw new BadCommandException("ACL not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
args.writeString(acl.getName());
String rights = acl.getRights().toString();
if (modifier == '+' || modifier == '-')
@@ -2933,12 +2969,9 @@
if (!hasCapability("ACL"))
throw new BadCommandException("ACL not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
- args.writeString(user);
+ writeMailboxName(args, mbox);
+ args.writeString(user); // XXX - could be UTF-8?
Response[] r = command("DELETEACL", args);
Response response = r[r.length-1];
@@ -2960,17 +2993,14 @@
if (!hasCapability("ACL"))
throw new BadCommandException("ACL not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Response[] r = command("GETACL", args);
Response response = r[r.length-1];
// Grab all ACL responses
- List<ACL> v = new ArrayList<ACL>();
+ List<ACL> v = new ArrayList<>();
if (response.isOK()) { // command succesful
for (int i = 0, len = r.length; i < len; i++) {
if (!(r[i] instanceof IMAPResponse))
@@ -3015,18 +3045,15 @@
if (!hasCapability("ACL"))
throw new BadCommandException("ACL not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
- args.writeString(user);
+ writeMailboxName(args, mbox);
+ args.writeString(user); // XXX - could be UTF-8?
Response[] r = command("LISTRIGHTS", args);
Response response = r[r.length-1];
// Grab LISTRIGHTS response
- List<Rights> v = new ArrayList<Rights>();
+ List<Rights> v = new ArrayList<>();
if (response.isOK()) { // command succesful
for (int i = 0, len = r.length; i < len; i++) {
if (!(r[i] instanceof IMAPResponse))
@@ -3066,11 +3093,8 @@
if (!hasCapability("ACL"))
throw new BadCommandException("ACL not supported");
- // encode the mbox as per RFC2060
- mbox = BASE64MailboxEncoder.encode(mbox);
-
Argument args = new Argument();
- args.writeString(mbox);
+ writeMailboxName(args, mbox);
Response[] r = command("MYRIGHTS", args);
Response response = r[r.length-1];
@@ -3129,7 +3153,7 @@
if (!hasCapability("IDLE"))
throw new BadCommandException("IDLE not supported");
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
boolean done = false;
Response r = null;
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/IMAPReferralException.java b/current/src/main/java/com/sun/mail/imap/protocol/IMAPReferralException.java
index ab518cd..393b1ed 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/IMAPReferralException.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/IMAPReferralException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/IMAPResponse.java b/current/src/main/java/com/sun/mail/imap/protocol/IMAPResponse.java
index 784a387..6ccf0ca 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/IMAPResponse.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/IMAPResponse.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -42,7 +42,7 @@
import java.io.*;
import java.util.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.ASCIIUtility;
import com.sun.mail.iap.*;
/**
@@ -93,15 +93,31 @@
* @exception ProtocolException for protocol failures
*/
public IMAPResponse(String r) throws IOException, ProtocolException {
- super(r);
+ this(r, true);
+ }
+
+ /**
+ * For testing.
+ *
+ * @param r the response string
+ * @param utf8 UTF-8 allowed?
+ * @exception IOException for I/O errors
+ * @exception ProtocolException for protocol failures
+ * @since JavaMail 1.6.0
+ */
+ public IMAPResponse(String r, boolean utf8)
+ throws IOException, ProtocolException {
+ super(r, utf8);
init();
}
/**
- * Read a list of space-separated "flag_extension" sequences and
+ * Read a list of space-separated "flag-extension" sequences and
* return the list as a array of Strings. An empty list is returned
- * as null. This is an IMAP-ism, and perhaps this method should
- * moved into the IMAP layer.
+ * as null. Each item is expected to be an atom, possibly preceeded
+ * by a backslash, but we aren't that strict; we just look for strings
+ * separated by spaces and terminated by a right paren. We assume items
+ * are always ASCII.
*
* @return the list items as a String array
*/
@@ -112,7 +128,7 @@
return null;
index++; // skip '('
- List<String> v = new ArrayList<String>();
+ List<String> v = new ArrayList<>();
int start;
for (start = index; buffer[index] != ')'; index++) {
if (buffer[index] == ' ') { // got one item
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/IMAPSaslAuthenticator.java b/current/src/main/java/com/sun/mail/imap/protocol/IMAPSaslAuthenticator.java
index 52cad4d..d8df5a9 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/IMAPSaslAuthenticator.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/IMAPSaslAuthenticator.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -48,7 +48,11 @@
import com.sun.mail.iap.*;
import com.sun.mail.imap.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BASE64DecoderStream;
/**
* This class contains a single method that does authentication using
@@ -85,12 +89,13 @@
this.host = host;
}
+ @Override
public boolean authenticate(String[] mechs, final String realm,
final String authzid, final String u,
final String p) throws ProtocolException {
synchronized (pr) { // authenticate method should be synchronized
- List<Response> v = new ArrayList<Response>();
+ List<Response> v = new ArrayList<>();
String tag = null;
Response r = null;
boolean done = false;
@@ -103,6 +108,7 @@
SaslClient sc;
CallbackHandler cbh = new CallbackHandler() {
+ @Override
public void handle(Callback[] callbacks) {
if (logger.isLoggable(Level.FINE))
logger.fine("SASL callback length: " + callbacks.length);
@@ -259,13 +265,18 @@
}
}
- /* Dispatch untagged responses.
+ Response[] responses = v.toArray(new Response[v.size()]);
+
+ // handle an illegal but not uncommon untagged CAPABILTY response
+ pr.handleCapabilityResponse(responses);
+
+ /*
+ * Dispatch untagged responses.
* NOTE: in our current upper level IMAP classes, we add the
* responseHandler to the Protocol object only *after* the
* connection has been authenticated. So, for now, the below
* code really ends up being just a no-op.
*/
- Response[] responses = v.toArray(new Response[v.size()]);
pr.notifyResponseHandlers(responses);
// Handle the final OK, NO, BAD or BYE response
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java b/current/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
index abe3afb..3304e06 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/INTERNALDATE.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/Item.java b/current/src/main/java/com/sun/mail/imap/protocol/Item.java
index a119fe8..3aa83df 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/Item.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/Item.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/ListInfo.java b/current/src/main/java/com/sun/mail/imap/protocol/ListInfo.java
index 8e75b0b..9571aef 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/ListInfo.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/ListInfo.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -67,7 +67,7 @@
public ListInfo(IMAPResponse r) throws ParsingException {
String[] s = r.readSimpleList();
- List<String> v = new ArrayList<String>(); // accumulate attributes
+ List<String> v = new ArrayList<>(); // accumulate attributes
if (s != null) {
// non-empty attribute list
for (int i = 0; i < s.length; i++) {
@@ -96,7 +96,8 @@
r.skipSpaces();
name = r.readAtomString();
- // decode the name (using RFC2060's modified UTF7)
- name = BASE64MailboxDecoder.decode(name);
+ if (!r.supportsUtf8())
+ // decode the name (using RFC2060's modified UTF7)
+ name = BASE64MailboxDecoder.decode(name);
}
}
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/MODSEQ.java b/current/src/main/java/com/sun/mail/imap/protocol/MODSEQ.java
index 8dd91dc..a1b285b 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/MODSEQ.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/MODSEQ.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -71,7 +71,7 @@
modseq = r.readLong();
- if (r.readByte() != ')')
+ if (!r.isNextNonSpace(')'))
throw new ParsingException("MODSEQ parse error");
}
}
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java b/current/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java
index 44c9a53..5f94fd3 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/MailboxInfo.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -69,6 +69,8 @@
public long uidvalidity = -1;
/** The next UID value to be assigned. */
public long uidnext = -1;
+ /** UIDs are not sticky. */
+ public boolean uidNotSticky = false; // RFC 4315
/** The highest MODSEQ value. */
public long highestmodseq = -1; // RFC 4551 - CONDSTORE
/** Folder.READ_WRITE or Folder.READ_ONLY, set by IMAPProtocol. */
@@ -101,12 +103,12 @@
r[i] = null; // remove this response
} else if (ir.keyEquals("VANISHED")) {
if (responses == null)
- responses = new ArrayList<IMAPResponse>();
+ responses = new ArrayList<>();
responses.add(ir);
r[i] = null; // remove this response
} else if (ir.keyEquals("FETCH")) {
if (responses == null)
- responses = new ArrayList<IMAPResponse>();
+ responses = new ArrayList<>();
responses.add(ir);
r[i] = null; // remove this response
} else if (ir.isUnTagged() && ir.isOK()) {
@@ -144,6 +146,29 @@
r[i] = null; // remove this response
else
ir.reset(); // so ALERT can be read
+ } else if (ir.isUnTagged() && ir.isNO()) {
+ /*
+ * should be one of:
+ * * NO [UIDNOTSTICKY]
+ */
+ ir.skipSpaces();
+
+ if (ir.readByte() != '[') { // huh ???
+ ir.reset();
+ continue;
+ }
+
+ boolean handled = true;
+ String s = ir.readAtom();
+ if (s.equalsIgnoreCase("UIDNOTSTICKY"))
+ uidNotSticky = true;
+ else
+ handled = false; // possibly an ALERT
+
+ if (handled)
+ r[i] = null; // remove this response
+ else
+ ir.reset(); // so ALERT can be read
}
}
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/MessageSet.java b/current/src/main/java/com/sun/mail/imap/protocol/MessageSet.java
index 0aea386..88671ef 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/MessageSet.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/MessageSet.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -74,7 +74,7 @@
* @return array of MessageSet objects
*/
public static MessageSet[] createMessageSets(int[] msgs) {
- List<MessageSet> v = new ArrayList<MessageSet>();
+ List<MessageSet> v = new ArrayList<>();
int i,j;
for (i=0; i < msgs.length; i++) {
@@ -104,7 +104,7 @@
return null;
int i = 0; // msgset index
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
int size = msgsets.length;
int start, end;
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/Namespaces.java b/current/src/main/java/com/sun/mail/imap/protocol/Namespaces.java
index 3fd9c10..b9b3b85 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/Namespaces.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/Namespaces.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -77,11 +77,13 @@
public Namespace(Response r) throws ProtocolException {
// Namespace_Element = "(" string SP (<"> QUOTED_CHAR <"> / nil)
// *(Namespace_Response_Extension) ")"
- if (r.readByte() != '(')
+ if (!r.isNextNonSpace('('))
throw new ProtocolException(
"Missing '(' at start of Namespace");
// first, the prefix
- prefix = BASE64MailboxDecoder.decode(r.readString());
+ prefix = r.readString();
+ if (!r.supportsUtf8())
+ prefix = BASE64MailboxDecoder.decode(prefix);
r.skipSpaces();
// delimiter is a quoted character or NIL
if (r.peekByte() == '"') {
@@ -101,16 +103,16 @@
delimiter = 0;
}
// at end of Namespace data?
- if (r.peekByte() != ')') {
- // otherwise, must be a Namespace_Response_Extension
- // Namespace_Response_Extension = SP string SP
- // "(" string *(SP string) ")"
- r.skipSpaces();
- r.readString();
- r.skipSpaces();
- r.readStringList();
- }
- if (r.readByte() != ')')
+ if (r.isNextNonSpace(')'))
+ return;
+
+ // otherwise, must be a Namespace_Response_Extension
+ // Namespace_Response_Extension = SP string SP
+ // "(" string *(SP string) ")"
+ r.readString();
+ r.skipSpaces();
+ r.readStringList();
+ if (!r.isNextNonSpace(')'))
throw new ProtocolException("Missing ')' at end of Namespace");
}
};
@@ -149,16 +151,13 @@
* Parse out one of the three sets of namespaces.
*/
private Namespace[] getNamespaces(Response r) throws ProtocolException {
- r.skipSpaces();
// Namespace = nil / "(" 1*( Namespace_Element) ")"
- if (r.peekByte() == '(') {
- List<Namespace> v = new ArrayList<Namespace>();
- r.readByte();
+ if (r.isNextNonSpace('(')) {
+ List<Namespace> v = new ArrayList<>();
do {
Namespace ns = new Namespace(r);
v.add(ns);
- } while (r.peekByte() != ')');
- r.readByte();
+ } while (!r.isNextNonSpace(')'));
return v.toArray(new Namespace[v.size()]);
} else {
String s = r.readAtom();
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java b/current/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java
index 614bdaf..3c440bd 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/RFC822DATA.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java b/current/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java
index b73c57e..51fa06b 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/RFC822SIZE.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -53,7 +53,7 @@
static final char[] name = {'R','F','C','8','2','2','.','S','I','Z','E'};
public int msgno;
- public int size;
+ public long size;
/**
* Constructor.
@@ -64,6 +64,6 @@
public RFC822SIZE(FetchResponse r) throws ParsingException {
msgno = r.getNumber();
r.skipSpaces();
- size = r.readNumber();
+ size = r.readLong();
}
}
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/SaslAuthenticator.java b/current/src/main/java/com/sun/mail/imap/protocol/SaslAuthenticator.java
index 21c0bbe..92f53bd 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/SaslAuthenticator.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/SaslAuthenticator.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java b/current/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java
index 70b032b..07e7321 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/SearchSequence.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -59,9 +59,29 @@
* support for additional product-specific search terms.
*
* @author John Mani
+ * @author Bill Shannon
*/
public class SearchSequence {
+ private IMAPProtocol protocol; // for hasCapability checks; may be null
+
+ /**
+ * Create a SearchSequence for this IMAPProtocol.
+ *
+ * @param p the IMAPProtocol object for the server
+ * @since JavaMail 1.6.0
+ */
+ public SearchSequence(IMAPProtocol p) {
+ protocol = p;
+ }
+
+ /**
+ * Create a SearchSequence.
+ */
+ @Deprecated
+ public SearchSequence() {
+ }
+
/**
* Generate the IMAP search sequence for the given search expression.
*
@@ -404,7 +424,7 @@
protected Calendar cal = new GregorianCalendar();
protected String toIMAPDate(Date date) {
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
cal.setTime(date);
@@ -486,6 +506,8 @@
* @since JavaMail 1.5.1
*/
protected Argument older(OlderTerm term) throws SearchException {
+ if (protocol != null && !protocol.hasCapability("WITHIN"))
+ throw new SearchException("Server doesn't support OLDER searches");
Argument result = new Argument();
result.writeAtom("OLDER");
result.writeNumber(term.getInterval());
@@ -501,6 +523,8 @@
* @since JavaMail 1.5.1
*/
protected Argument younger(YoungerTerm term) throws SearchException {
+ if (protocol != null && !protocol.hasCapability("WITHIN"))
+ throw new SearchException("Server doesn't support YOUNGER searches");
Argument result = new Argument();
result.writeAtom("YOUNGER");
result.writeNumber(term.getInterval());
@@ -517,6 +541,8 @@
*/
protected Argument modifiedSince(ModifiedSinceTerm term)
throws SearchException {
+ if (protocol != null && !protocol.hasCapability("CONDSTORE"))
+ throw new SearchException("Server doesn't support MODSEQ searches");
Argument result = new Argument();
result.writeAtom("MODSEQ");
result.writeNumber(term.getModSeq());
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/Status.java b/current/src/main/java/com/sun/mail/imap/protocol/Status.java
index 75e5df9..25600f4 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/Status.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/Status.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -68,11 +68,13 @@
public Status(Response r) throws ParsingException {
// mailbox := astring
- mbox = BASE64MailboxDecoder.decode(r.readAtomString());
+ mbox = r.readAtomString();
+ if (!r.supportsUtf8())
+ mbox = BASE64MailboxDecoder.decode(mbox);
// Workaround buggy IMAP servers that don't quote folder names
// with spaces.
- final StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
boolean onlySpaces = true;
while (r.peekByte() != '(' && r.peekByte() != 0) {
@@ -94,6 +96,8 @@
do {
String attr = r.readAtom();
+ if (attr == null)
+ throw new ParsingException("parse error in STATUS");
if (attr.equalsIgnoreCase("MESSAGES"))
total = r.readNumber();
else if (attr.equalsIgnoreCase("RECENT"))
@@ -108,11 +112,11 @@
highestmodseq = r.readLong();
else {
if (items == null)
- items = new HashMap<String,Long>();
+ items = new HashMap<>();
items.put(attr.toUpperCase(Locale.ENGLISH),
Long.valueOf(r.readLong()));
}
- } while (r.readByte() != ')');
+ } while (!r.isNextNonSpace(')'));
}
/**
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/UID.java b/current/src/main/java/com/sun/mail/imap/protocol/UID.java
index e7c0a79..b917861 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/UID.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/UID.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/imap/protocol/UIDSet.java b/current/src/main/java/com/sun/mail/imap/protocol/UIDSet.java
index 436a0ad..f6fdebd 100644
--- a/current/src/main/java/com/sun/mail/imap/protocol/UIDSet.java
+++ b/current/src/main/java/com/sun/mail/imap/protocol/UIDSet.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -78,7 +78,7 @@
public static UIDSet[] createUIDSets(long[] uids) {
if (uids == null)
return null;
- List<UIDSet> v = new ArrayList<UIDSet>();
+ List<UIDSet> v = new ArrayList<>();
int i,j;
for (i=0; i < uids.length; i++) {
@@ -108,7 +108,7 @@
public static UIDSet[] parseUIDSets(String uids) {
if (uids == null)
return null;
- List<UIDSet> v = new ArrayList<UIDSet>();
+ List<UIDSet> v = new ArrayList<>();
StringTokenizer st = new StringTokenizer(uids, ",:", true);
long start = -1;
UIDSet cur = null;
diff --git a/current/src/main/java/com/sun/mail/pop3/AppendStream.java b/current/src/main/java/com/sun/mail/pop3/AppendStream.java
index a6d392d..9ef6c43 100644
--- a/current/src/main/java/com/sun/mail/pop3/AppendStream.java
+++ b/current/src/main/java/com/sun/mail/pop3/AppendStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -64,18 +64,22 @@
raf.seek(start);
}
+ @Override
public void write(int b) throws IOException {
raf.write(b);
}
+ @Override
public void write(byte[] b) throws IOException {
raf.write(b);
}
+ @Override
public void write(byte[] b, int off, int len) throws IOException {
raf.write(b, off, len);
}
+ @Override
public synchronized void close() throws IOException {
end = tf.updateLength();
raf = null; // no more writing allowed
diff --git a/current/src/main/java/com/sun/mail/pop3/DefaultFolder.java b/current/src/main/java/com/sun/mail/pop3/DefaultFolder.java
index 71a6299..4ceb36e 100644
--- a/current/src/main/java/com/sun/mail/pop3/DefaultFolder.java
+++ b/current/src/main/java/com/sun/mail/pop3/DefaultFolder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -53,43 +53,53 @@
super(store);
}
+ @Override
public String getName() {
return "";
}
+ @Override
public String getFullName() {
return "";
}
+ @Override
public Folder getParent() {
return null;
}
+ @Override
public boolean exists() {
return true;
}
+ @Override
public Folder[] list(String pattern) throws MessagingException {
Folder[] f = { getInbox() };
return f;
}
+ @Override
public char getSeparator() {
return '/';
}
+ @Override
public int getType() {
return HOLDS_FOLDERS;
}
+ @Override
public boolean create(int type) throws MessagingException {
return false;
}
+ @Override
public boolean hasNewMessages() throws MessagingException {
return false;
}
+ @Override
public Folder getFolder(String name) throws MessagingException {
if (!name.equalsIgnoreCase("INBOX")) {
throw new MessagingException("only INBOX supported");
@@ -103,42 +113,52 @@
}
+ @Override
public boolean delete(boolean recurse) throws MessagingException {
throw new MethodNotSupportedException("delete");
}
+ @Override
public boolean renameTo(Folder f) throws MessagingException {
throw new MethodNotSupportedException("renameTo");
}
+ @Override
public void open(int mode) throws MessagingException {
throw new MethodNotSupportedException("open");
}
+ @Override
public void close(boolean expunge) throws MessagingException {
throw new MethodNotSupportedException("close");
}
+ @Override
public boolean isOpen() {
return false;
}
+ @Override
public Flags getPermanentFlags() {
return new Flags(); // empty flags object
}
+ @Override
public int getMessageCount() throws MessagingException {
return 0;
}
+ @Override
public Message getMessage(int msgno) throws MessagingException {
throw new MethodNotSupportedException("getMessage");
}
+ @Override
public void appendMessages(Message[] msgs) throws MessagingException {
throw new MethodNotSupportedException("Append not supported");
}
+ @Override
public Message[] expunge() throws MessagingException {
throw new MethodNotSupportedException("expunge");
}
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3Folder.java b/current/src/main/java/com/sun/mail/pop3/POP3Folder.java
index e1cc587..2589cab 100644
--- a/current/src/main/java/com/sun/mail/pop3/POP3Folder.java
+++ b/current/src/main/java/com/sun/mail/pop3/POP3Folder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -85,18 +85,21 @@
this.store = store;
if (name.equalsIgnoreCase("INBOX"))
exists = true;
- logger = new MailLogger(this.getClass(),
- "DEBUG POP3", store.getSession());
+ logger = new MailLogger(this.getClass(), "DEBUG POP3",
+ store.getSession().getDebug(), store.getSession().getDebugOut());
}
+ @Override
public String getName() {
return name;
}
+ @Override
public String getFullName() {
return name;
}
+ @Override
public Folder getParent() {
return new DefaultFolder(store);
}
@@ -107,6 +110,7 @@
*
* @return true for INBOX, false otherwise
*/
+ @Override
public boolean exists() {
return exists;
}
@@ -117,6 +121,7 @@
*
* @exception MessagingException always
*/
+ @Override
public Folder[] list(String pattern) throws MessagingException {
throw new MessagingException("not a directory");
}
@@ -126,6 +131,7 @@
*
* @return NUL
*/
+ @Override
public char getSeparator() {
return '\0';
}
@@ -135,6 +141,7 @@
*
* @return Folder.HOLDS_MESSAGES
*/
+ @Override
public int getType() {
return HOLDS_MESSAGES;
}
@@ -145,6 +152,7 @@
*
* @return false
*/
+ @Override
public boolean create(int type) throws MessagingException {
return false;
}
@@ -155,6 +163,7 @@
*
* @return false
*/
+ @Override
public boolean hasNewMessages() throws MessagingException {
return false; // no way to know
}
@@ -165,6 +174,7 @@
*
* @exception MessagingException always
*/
+ @Override
public Folder getFolder(String name) throws MessagingException {
throw new MessagingException("not a directory");
}
@@ -176,6 +186,7 @@
*
* @exception MethodNotSupportedException always
*/
+ @Override
public boolean delete(boolean recurse) throws MessagingException {
throw new MethodNotSupportedException("delete");
}
@@ -186,6 +197,7 @@
*
* @exception MethodNotSupportedException always
*/
+ @Override
public boolean renameTo(Folder f) throws MessagingException {
throw new MethodNotSupportedException("renameTo");
}
@@ -198,6 +210,7 @@
* @exception AuthenticationFailedException authentication failures
* @exception MessagingException other open failures
*/
+ @Override
public synchronized void open(int mode) throws MessagingException {
checkClosed();
if (!exists)
@@ -238,6 +251,7 @@
notifyConnectionListeners(ConnectionEvent.OPENED);
}
+ @Override
public synchronized void close(boolean expunge) throws MessagingException {
checkOpen();
@@ -297,6 +311,7 @@
}
}
+ @Override
public synchronized boolean isOpen() {
if (!opened)
return false;
@@ -308,9 +323,8 @@
close(false);
} catch (MessagingException mex) {
// ignore it
- } finally {
- return false;
}
+ return false;
}
return true;
}
@@ -321,6 +335,7 @@
*
* @return empty Flags object
*/
+ @Override
public Flags getPermanentFlags() {
return new Flags(); // empty flags object
}
@@ -330,6 +345,7 @@
* protocol doesn't support notification of new messages
* arriving in open folders.
*/
+ @Override
public synchronized int getMessageCount() throws MessagingException {
if (!opened)
return -1;
@@ -337,6 +353,7 @@
return total;
}
+ @Override
public synchronized Message getMessage(int msgno)
throws MessagingException {
checkOpen();
@@ -374,6 +391,7 @@
*
* @exception MethodNotSupportedException always
*/
+ @Override
public void appendMessages(Message[] msgs) throws MessagingException {
throw new MethodNotSupportedException("Append not supported");
}
@@ -387,6 +405,7 @@
*
* @exception MethodNotSupportedException always
*/
+ @Override
public Message[] expunge() throws MessagingException {
throw new MethodNotSupportedException("Expunge not supported");
}
@@ -400,6 +419,7 @@
* the headers and size of all messages are fetched using the POP3 TOP
* and LIST commands.
*/
+ @Override
public synchronized void fetch(Message[] msgs, FetchProfile fp)
throws MessagingException {
checkReadable();
@@ -548,6 +568,7 @@
/**
* Close the folder when we're finalized.
*/
+ @Override
protected void finalize() throws Throwable {
forceClose = !store.finalizeCleanClose;
try {
@@ -600,6 +621,7 @@
/*
* Only here to make accessible to POP3Message.
*/
+ @Override
protected void notifyMessageChangedListeners(int type, Message m) {
super.notifyMessageChangedListeners(type, m);
}
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3Message.java b/current/src/main/java/com/sun/mail/pop3/POP3Message.java
index d241f9c..fc1c5f0 100644
--- a/current/src/main/java/com/sun/mail/pop3/POP3Message.java
+++ b/current/src/main/java/com/sun/mail/pop3/POP3Message.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -73,7 +73,7 @@
// rawData itself is never null
private SoftReference<InputStream> rawData
- = new SoftReference<InputStream>(null);
+ = new SoftReference<>(null);
public POP3Message(Folder folder, int msgno)
throws MessagingException {
@@ -88,6 +88,7 @@
* @param newFlags the flags to be set
* @param set the value to be set
*/
+ @Override
public synchronized void setFlags(Flags newFlags, boolean set)
throws MessagingException {
Flags oldFlags = (Flags)flags.clone();
@@ -108,6 +109,7 @@
* @return size of content in bytes
* @exception MessagingException for failures
*/
+ @Override
public int getSize() throws MessagingException {
try {
synchronized (this) {
@@ -238,7 +240,7 @@
// skipped the header, the message is what's left
msgSize = rawcontent.available();
- rawData = new SoftReference<InputStream>(rawcontent);
+ rawData = new SoftReference<>(rawcontent);
}
}
} catch (EOFException eex) {
@@ -264,6 +266,7 @@
*
* @see #contentStream
*/
+ @Override
protected synchronized InputStream getContentStream()
throws MessagingException {
if (contentStream != null)
@@ -288,6 +291,7 @@
* @return the MIME format stream
* @since JavaMail 1.4.5
*/
+ @Override
public InputStream getMimeStream() throws MessagingException {
return getRawStream(false);
}
@@ -311,7 +315,7 @@
} catch (IOException ex) {
// ignore it
}
- rawData = new SoftReference<InputStream>(null);
+ rawData = new SoftReference<>(null);
}
if (contentStream != null) {
try {
@@ -360,6 +364,7 @@
* @exception MessagingException for failures
* @see javax.mail.internet.MimeUtility
*/
+ @Override
public String[] getHeader(String name)
throws MessagingException {
if (headers == null)
@@ -379,6 +384,7 @@
* this name
* @exception MessagingException for failures
*/
+ @Override
public String getHeader(String name, String delimiter)
throws MessagingException {
if (headers == null)
@@ -399,6 +405,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setHeader(String name, String value)
throws MessagingException {
// XXX - should check for read-only folder?
@@ -417,6 +424,7 @@
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void addHeader(String name, String value)
throws MessagingException {
// XXX - should check for read-only folder?
@@ -432,6 +440,7 @@
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void removeHeader(String name)
throws MessagingException {
// XXX - should check for read-only folder?
@@ -450,7 +459,7 @@
* @exception MessagingException for failures
* @see javax.mail.internet.MimeUtility
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getAllHeaders() throws MessagingException {
if (headers == null)
loadHeaders();
@@ -463,7 +472,7 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getMatchingHeaders(String[] names)
throws MessagingException {
if (headers == null)
@@ -477,7 +486,7 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<Header> getNonMatchingHeaders(String[] names)
throws MessagingException {
if (headers == null)
@@ -494,6 +503,7 @@
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void addHeaderLine(String line) throws MessagingException {
// XXX - should check for read-only folder?
throw new IllegalWriteException("POP3 messages are read-only");
@@ -506,7 +516,7 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getAllHeaderLines() throws MessagingException {
if (headers == null)
loadHeaders();
@@ -520,7 +530,7 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException {
if (headers == null)
@@ -535,7 +545,7 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("unchecked")
+ @Override
public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException {
if (headers == null)
@@ -550,6 +560,7 @@
* @exception IllegalWriteException because the underlying
* implementation does not support modification
*/
+ @Override
public void saveChanges() throws MessagingException {
// POP3 Messages are read-only
throw new IllegalWriteException("POP3 messages are read-only");
@@ -569,6 +580,7 @@
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
+ @Override
public synchronized void writeTo(OutputStream os, String[] ignoreList)
throws IOException, MessagingException {
InputStream rawcontent = rawData.get();
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3Provider.java b/current/src/main/java/com/sun/mail/pop3/POP3Provider.java
new file mode 100644
index 0000000..9020ca5
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/pop3/POP3Provider.java
@@ -0,0 +1,54 @@
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.pop3;
+
+import javax.mail.Provider;
+
+/**
+ * The POP3 protocol provider.
+ */
+public class POP3Provider extends Provider {
+ public POP3Provider() {
+ super(Provider.Type.STORE, "pop3", POP3Store.class.getName(),
+ "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3SSLProvider.java b/current/src/main/java/com/sun/mail/pop3/POP3SSLProvider.java
new file mode 100644
index 0000000..d09be35
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/pop3/POP3SSLProvider.java
@@ -0,0 +1,54 @@
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.pop3;
+
+import javax.mail.Provider;
+
+/**
+ * The POP3 SSL protocol provider.
+ */
+public class POP3SSLProvider extends Provider {
+ public POP3SSLProvider() {
+ super(Provider.Type.STORE, "pop3s", POP3SSLStore.class.getName(),
+ "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3SSLStore.java b/current/src/main/java/com/sun/mail/pop3/POP3SSLStore.java
index 57bd23e..299329b 100644
--- a/current/src/main/java/com/sun/mail/pop3/POP3SSLStore.java
+++ b/current/src/main/java/com/sun/mail/pop3/POP3SSLStore.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/pop3/POP3Store.java b/current/src/main/java/com/sun/mail/pop3/POP3Store.java
index 2a082b7..08ef703 100644
--- a/current/src/main/java/com/sun/mail/pop3/POP3Store.java
+++ b/current/src/main/java/com/sun/mail/pop3/POP3Store.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -107,11 +107,11 @@
if (url != null)
name = url.getProtocol();
this.name = name;
- logger = new MailLogger(this.getClass(),
- "DEBUG POP3", session);
+ logger = new MailLogger(this.getClass(), "DEBUG POP3",
+ session.getDebug(), session.getDebugOut());
if (!isSSL)
- isSSL = PropUtil.getBooleanSessionProperty(session,
+ isSSL = PropUtil.getBooleanProperty(session.getProperties(),
"mail." + name + ".ssl.enable", false);
if (isSSL)
this.defaultPort = 995;
@@ -174,7 +174,8 @@
*/
private final synchronized boolean getBoolProp(String prop) {
prop = "mail." + name + "." + prop;
- boolean val = PropUtil.getBooleanSessionProperty(session, prop, false);
+ boolean val = PropUtil.getBooleanProperty(session.getProperties(),
+ prop, false);
if (logger.isLoggable(Level.CONFIG))
logger.config(prop + ": " + val);
return val;
@@ -187,6 +188,7 @@
return session;
}
+ @Override
protected synchronized boolean protocolConnect(String host, int portNum,
String user, String passwd) throws MessagingException {
@@ -197,7 +199,7 @@
// if port is not specified, set it to value of mail.pop3.port
// property if it exists, otherwise default to 110
if (portNum == -1)
- portNum = PropUtil.getIntSessionProperty(session,
+ portNum = PropUtil.getIntProperty(session.getProperties(),
"mail." + name + ".port", -1);
if (portNum == -1)
@@ -232,6 +234,7 @@
* as long as we can reconnect at that point. This means that we
* need to be able to reconnect the Store on demand.
*/
+ @Override
public synchronized boolean isConnected() {
if (!super.isConnected())
// if we haven't been connected at all, don't bother with
@@ -249,9 +252,8 @@
super.close(); // notifies listeners
} catch (MessagingException mex) {
// ignore it
- } finally {
- return false;
}
+ return false;
}
}
@@ -275,21 +277,13 @@
p.setCapabilities(p.capa());
} else if (requireStartTLS) {
logger.fine("STLS required but failed");
- try {
- p.quit();
- } catch (IOException ioex) {
- } finally {
- throw new EOFException("STLS required but failed");
- }
+ throw cleanupAndThrow(p,
+ new EOFException("STLS required but failed"));
}
} else if (requireStartTLS) {
logger.fine("STLS required but not supported");
- try {
- p.quit();
- } catch (IOException ioex) {
- } finally {
- throw new EOFException("STLS required but not supported");
- }
+ throw cleanupAndThrow(p,
+ new EOFException("STLS required but not supported"));
}
}
@@ -312,12 +306,7 @@
String msg = null;
if ((msg = p.login(user, passwd)) != null) {
- try {
- p.quit();
- } catch (IOException ioex) {
- } finally {
- throw new EOFException(msg);
- }
+ throw cleanupAndThrow(p, new EOFException(msg));
}
/*
@@ -337,6 +326,30 @@
return p;
}
+ private static IOException cleanupAndThrow(Protocol p, IOException ife) {
+ try {
+ p.quit();
+ } catch (Throwable thr) {
+ if (isRecoverable(thr)) {
+ ife.addSuppressed(thr);
+ } else {
+ thr.addSuppressed(ife);
+ if (thr instanceof Error) {
+ throw (Error) thr;
+ }
+ if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
+ }
+ throw new RuntimeException("unexpected exception", thr);
+ }
+ }
+ return ife;
+ }
+
+ private static boolean isRecoverable(Throwable t) {
+ return (t instanceof Exception) || (t instanceof LinkageError);
+ }
+
synchronized void closePort(POP3Folder owner) {
if (portOwner == owner) {
port = null;
@@ -344,6 +357,7 @@
}
}
+ @Override
public synchronized void close() throws MessagingException {
close(false);
}
@@ -365,6 +379,7 @@
}
}
+ @Override
public Folder getDefaultFolder() throws MessagingException {
checkConnected();
return new DefaultFolder(this);
@@ -373,11 +388,13 @@
/**
* Only the name "INBOX" is supported.
*/
+ @Override
public Folder getFolder(String name) throws MessagingException {
checkConnected();
return new POP3Folder(this, name);
}
+ @Override
public Folder getFolder(URLName url) throws MessagingException {
checkConnected();
return new POP3Folder(this, url.getFile());
@@ -419,6 +436,7 @@
return usingSSL;
}
+ @Override
protected void finalize() throws Throwable {
try {
if (port != null) // don't force a connection attempt
diff --git a/current/src/main/java/com/sun/mail/pop3/Protocol.java b/current/src/main/java/com/sun/mail/pop3/Protocol.java
index 885d984..e53a4c4 100644
--- a/current/src/main/java/com/sun/mail/pop3/Protocol.java
+++ b/current/src/main/java/com/sun/mail/pop3/Protocol.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -47,7 +47,13 @@
import java.util.logging.Level;
import javax.net.ssl.SSLSocket;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.SocketFetcher;
+import com.sun.mail.util.LineInputStream;
+import com.sun.mail.util.TraceInputStream;
+import com.sun.mail.util.TraceOutputStream;
+import com.sun.mail.util.SharedByteArrayOutputStream;
class Response {
boolean ok = false; // true if "+OK"
@@ -113,19 +119,11 @@
initStreams();
r = simpleCommand(null);
} catch (IOException ioe) {
- try {
- socket.close();
- } finally {
- throw ioe;
- }
+ throw cleanupAndThrow(socket, ioe);
}
if (!r.ok) {
- try {
- socket.close();
- } finally {
- throw new IOException("Connect failed");
- }
+ throw cleanupAndThrow(socket, new IOException("Connect failed"));
}
if (enableAPOP && r.data != null) {
int challStart = r.data.indexOf('<'); // start of challenge
@@ -145,6 +143,30 @@
logger.config("PIPELINING enabled");
}
+ private static IOException cleanupAndThrow(Socket socket, IOException ife) {
+ try {
+ socket.close();
+ } catch (Throwable thr) {
+ if (isRecoverable(thr)) {
+ ife.addSuppressed(thr);
+ } else {
+ thr.addSuppressed(ife);
+ if (thr instanceof Error) {
+ throw (Error) thr;
+ }
+ if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
+ }
+ throw new RuntimeException("unexpected exception", thr);
+ }
+ }
+ return ife;
+ }
+
+ private static boolean isRecoverable(Throwable t) {
+ return (t instanceof Exception) || (t instanceof LinkageError);
+ }
+
/**
* Get the value of a boolean property.
* Print out the value if logging is enabled.
@@ -176,6 +198,7 @@
new OutputStreamWriter(traceOutput, "iso-8859-1")));
}
+ @Override
protected void finalize() throws Throwable {
try {
if (socket != null) // Forgot to logout ?!
@@ -194,7 +217,7 @@
return;
}
- capabilities = new HashMap<String, String>(10);
+ capabilities = new HashMap<>(10);
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(in, "us-ascii"));
diff --git a/current/src/main/java/com/sun/mail/pop3/Status.java b/current/src/main/java/com/sun/mail/pop3/Status.java
index 309aa75..2a65ccb 100644
--- a/current/src/main/java/com/sun/mail/pop3/Status.java
+++ b/current/src/main/java/com/sun/mail/pop3/Status.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/pop3/TempFile.java b/current/src/main/java/com/sun/mail/pop3/TempFile.java
index 6c01442..4748be1 100644
--- a/current/src/main/java/com/sun/mail/pop3/TempFile.java
+++ b/current/src/main/java/com/sun/mail/pop3/TempFile.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -80,6 +80,7 @@
file.delete();
}
+ @Override
protected void finalize() throws Throwable {
try {
close();
diff --git a/current/src/main/java/com/sun/mail/pop3/WritableSharedFile.java b/current/src/main/java/com/sun/mail/pop3/WritableSharedFile.java
index f27fde8..7a890c6 100644
--- a/current/src/main/java/com/sun/mail/pop3/WritableSharedFile.java
+++ b/current/src/main/java/com/sun/mail/pop3/WritableSharedFile.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -74,6 +74,7 @@
/**
* Close the readable and writable files.
*/
+ @Override
public void close() throws IOException {
try {
super.close();
diff --git a/current/src/main/java/com/sun/mail/pop3/package.html b/current/src/main/java/com/sun/mail/pop3/package.html
deleted file mode 100644
index 33a3776..0000000
--- a/current/src/main/java/com/sun/mail/pop3/package.html
+++ /dev/null
@@ -1,672 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-A POP3 protocol provider for the JavaMail API
-that provides access to a POP3 message store.
-Refer to <A HREF="http://www.ietf.org/rfc/rfc1939.txt" TARGET="_top">
-RFC 1939</A>
-for more information.
-<P>
-The POP3 provider provides a Store object that contains a single Folder
-named "INBOX". Due to the limitations of the POP3 protocol, many of
-the JavaMail API capabilities like event notification, folder management,
-flag management, etc. are not allowed. The corresponding methods throw
-the MethodNotSupportedException exception; see below for details.
-<P>
-Note that JavaMail does <strong>not</strong> include a local store into
-which messages can be downloaded and stored. See our
-<A HREF="http://java.sun.com/products/javamail/Third_Party.html" TARGET="_top">
-Third Party Products</A>
-web page for availability of "mbox" and "MH" local store providers.
-<P>
-The POP3 provider is accessed through the JavaMail APIs by using the protocol
-name "pop3" or a URL of the form "pop3://user:password@host:port/INBOX".
-<P>
-POP3 supports only a single folder named "INBOX".
-<P>
-POP3 supports <strong>no</strong> permanent flags (see
-{@link javax.mail.Folder#getPermanentFlags Folder.getPermanentFlags()}).
-In particular, the <code>Flags.Flag.RECENT</code> flag will never be set
-for POP3
-messages. It's up to the application to determine which messages in a
-POP3 mailbox are "new". There are several strategies to accomplish
-this, depending on the needs of the application and the environment:
-<P>
-<UL>
-<LI>
-A simple approach would be to keep track of the newest
-message seen by the application.
-</LI>
-<LI>
-An alternative would be to keep track of the UIDs (see below)
-of all messages that have been seen.
-</LI>
-<LI>
-Another approach is to download <strong>all</strong> messages into a local
-mailbox, so that all messages in the POP3 mailbox are, by
-definition, new.
-</LI>
-</UL>
-<P>
-All approaches will require some permanent storage associated with the client.
-<P>
-POP3 does not support the <code>Folder.expunge()</code> method. To delete and
-expunge messages, set the <code>Flags.Flag.DELETED</code> flag on the messages
-and close the folder using the <code>Folder.close(true)</code> method. You
-cannot expunge without closing the folder.
-<P>
-POP3 does not provide a "received date", so the <code>getReceivedDate</code>
-method will return null.
-It may be possible to examine other message headers (e.g., the
-"Received" headers) to estimate the received date, but these techniques
-are error-prone at best.
-<P>
-The POP3 provider supports the POP3 UIDL command, see
-{@link com.sun.mail.pop3.POP3Folder#getUID POP3Folder.getUID()}.
-You can use it as follows:
-<P>
-<BLOCKQUOTE><PRE>
-if (folder instanceof com.sun.mail.pop3.POP3Folder) {
- com.sun.mail.pop3.POP3Folder pf =
- (com.sun.mail.pop3.POP3Folder)folder;
- String uid = pf.getUID(msg);
- if (uid != null)
- ... // use it
-}
-</PRE></BLOCKQUOTE>
-<P>
-You can also pre-fetch all the UIDs for all messages like this:
-<P>
-<BLOCKQUOTE><PRE>
-FetchProfile fp = new FetchProfile();
-fp.add(UIDFolder.FetchProfileItem.UID);
-folder.fetch(folder.getMessages(), fp);
-</PRE></BLOCKQUOTE>
-<P>
-Then use the technique above to get the UID for each message. This is
-similar to the technique used with the UIDFolder interface supported by
-IMAP, but note that POP3 UIDs are strings, not integers like IMAP
-UIDs. See the POP3 spec for details.
-<P>
-When the headers of a POP3 message are accessed, the POP3 provider uses
-the TOP command to fetch all headers, which are then cached. Use of the
-TOP command can be disabled with the <CODE>mail.pop3.disabletop</CODE>
-property, in which case the entire message content is fetched with the
-RETR command.
-<P>
-When the content of a POP3 message is accessed, the POP3 provider uses
-the RETR command to fetch the entire message. Normally the message
-content is cached in memory. By setting the
-<CODE>mail.pop3.filecache.enable</CODE> property, the message content
-will instead be cached in a temporary file. The file will be removed
-when the folder is closed. Caching message content in a file is generally
-slower, but uses substantially less memory and may be helpful when dealing
-with very large messages.
-<P>
-The {@link com.sun.mail.pop3.POP3Message#invalidate POP3Message.invalidate}
-method can be used to invalidate cached data without closing the folder.
-Note that if the file cache is being used the data in the file will be
-forgotten and fetched from the server if it's needed again, and stored again
-in the file cache.
-<P>
-The POP3 CAPA command (defined by
-<A HREF="http://www.ietf.org/rfc/rfc2449.txt" TARGET="_top">RFC 2449</A>)
-will be used to determine the capabilities supported by the server.
-Some servers don't implement the CAPA command, and some servers don't
-return correct information, so various properties are available to
-disable use of certain POP3 commands, including CAPA.
-<P>
-If the server advertises the PIPELINING capability (defined by
-<A HREF="http://www.ietf.org/rfc/rfc2449.txt" TARGET="_top">RFC 2449</A>),
-or the <CODE>mail.pop3.pipelining</CODE> property is set, the POP3
-provider will send some commands in batches, which can significantly
-improve performance and memory use.
-Some servers that don't support the CAPA command or don't advertise
-PIPELINING may still support pipelining; experimentation may be required.
-<P>
-If pipelining is supported and the connection is using
-SSL, the USER and PASS commands will be sent as a batch.
-(If SSL is not being used, the PASS command isn't sent
-until the user is verified to avoid exposing the password
-if the user name is bad.)
-<P>
-If pipelining is supported, when fetching a message with the RETR command,
-the LIST command will be sent as well, and the result will be used to size
-the I/O buffer, greatly reducing memory usage when fetching messages.
-<P>
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-The POP3 protocol provider supports the following properties,
-which may be set in the JavaMail <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- props.put("mail.pop3.port", "888");
-</PRE>
-to set the <CODE>mail.pop3.port</CODE> property, which is of type int.
-<P>
-Note that if you're using the "pop3s" protocol to access POP3 over SSL,
-all the properties would be named "mail.pop3s.*".
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.pop3.user"></A>
-<TR id="mail.pop3.user">
-<TD>mail.pop3.user</TD>
-<TD>String</TD>
-<TD>Default user name for POP3.</TD>
-</TR>
-
-<A NAME="mail.pop3.host"></A>
-<TR id="mail.pop3.host">
-<TD>mail.pop3.host</TD>
-<TD>String</TD>
-<TD>The POP3 server to connect to.</TD>
-</TR>
-
-<A NAME="mail.pop3.port"></A>
-<TR id="mail.pop3.port">
-<TD>mail.pop3.port</TD>
-<TD>int</TD>
-<TD>The POP3 server port to connect to, if the connect() method doesn't
-explicitly specify one. Defaults to 110.</TD>
-</TR>
-
-<A NAME="mail.pop3.connectiontimeout"></A>
-<TR id="mail.pop3.connectiontimeout">
-<TD>mail.pop3.connectiontimeout</TD>
-<TD>int</TD>
-<TD>Socket connection timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.pop3.timeout"></A>
-<TR id="mail.pop3.timeout">
-<TD>mail.pop3.timeout</TD>
-<TD>int</TD>
-<TD>Socket read timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.pop3.writetimeout"></A>
-<TR id="mail.pop3.writetimeout">
-<TD>mail.pop3.writetimeout</TD>
-<TD>int</TD>
-<TD>Socket write timeout value in milliseconds.
-This timeout is implemented by using a
-java.util.concurrent.ScheduledExecutorService per connection
-that schedules a thread to close the socket if the timeout expires.
-Thus, the overhead of using this timeout is one thread per connection.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.pop3.rsetbeforequit"></A>
-<TR id="mail.pop3.rsetbeforequit">
-<TD>mail.pop3.rsetbeforequit</TD>
-<TD>boolean</TD>
-<TD>
-Send a POP3 RSET command when closing the folder, before sending the
-QUIT command. Useful with POP3 servers that implicitly mark all
-messages that are read as "deleted"; this will prevent such messages
-from being deleted and expunged unless the client requests so. Default
-is false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.message.class"></A>
-<TR id="mail.pop3.message.class">
-<TD>mail.pop3.message.class</TD>
-<TD>String</TD>
-<TD>
-Class name of a subclass of <code>com.sun.mail.pop3.POP3Message</code>.
-The subclass can be used to handle (for example) non-standard
-Content-Type headers. The subclass must have a public constructor
-of the form <code>MyPOP3Message(Folder f, int msgno)
-throws MessagingException</code>.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.localaddress"></A>
-<TR id="mail.pop3.localaddress">
-<TD>mail.pop3.localaddress</TD>
-<TD>String</TD>
-<TD>
-Local address (host name) to bind to when creating the POP3 socket.
-Defaults to the address picked by the Socket class.
-Should not normally need to be set, but useful with multi-homed hosts
-where it's important to pick a particular local address to bind to.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.localport"></A>
-<TR id="mail.pop3.localport">
-<TD>mail.pop3.localport</TD>
-<TD>int</TD>
-<TD>
-Local port number to bind to when creating the POP3 socket.
-Defaults to the port number picked by the Socket class.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.apop.enable"></A>
-<TR id="mail.pop3.apop.enable">
-<TD>mail.pop3.apop.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use APOP instead of USER/PASS to login to the
-POP3 server, if the POP3 server supports APOP. APOP sends a
-digest of the password rather than the clear text password.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socketFactory"></A>
-<TR id="mail.pop3.socketFactory">
-<TD>mail.pop3.socketFactory</TD>
-<TD>SocketFactory</TD>
-<TD>
-If set to a class that implements the
-<code>javax.net.SocketFactory</code> interface, this class
-will be used to create POP3 sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socketFactory.class"></A>
-<TR id="mail.pop3.socketFactory.class">
-<TD>mail.pop3.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that implements the
-<code>javax.net.SocketFactory</code> interface. This class
-will be used to create POP3 sockets.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socketFactory.fallback"></A>
-<TR id="mail.pop3.socketFactory.fallback">
-<TD>mail.pop3.socketFactory.fallback</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, failure to create a socket using the specified
-socket factory class will cause the socket to be created using
-the <code>java.net.Socket</code> class.
-Defaults to true.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socketFactory.port"></A>
-<TR id="mail.pop3.socketFactory.port">
-<TD>mail.pop3.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.enable"></A>
-<TR id="mail.pop3.ssl.enable">
-<TD>mail.pop3.ssl.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use SSL to connect and use the SSL port by default.
-Defaults to false for the "pop3" protocol and true for the "pop3s" protocol.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.checkserveridentity"></A>
-<TR id="mail.pop3.ssl.checkserveridentity">
-<TD>mail.pop3.ssl.checkserveridentity</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, check the server identity as specified by
-<A HREF="http://www.ietf.org/rfc/rfc2595.txt" TARGET="_top">RFC 2595</A>.
-These additional checks based on the content of the server's certificate
-are intended to prevent man-in-the-middle attacks.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.trust"></A>
-<TR id="mail.pop3.ssl.trust">
-<TD>mail.pop3.ssl.trust</TD>
-<TD>String</TD>
-<TD>
-If set, and a socket factory hasn't been specified, enables use of a
-{@link com.sun.mail.util.MailSSLSocketFactory MailSSLSocketFactory}.
-If set to "*", all hosts are trusted.
-If set to a whitespace separated list of hosts, those hosts are trusted.
-Otherwise, trust depends on the certificate the server presents.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.socketFactory"></A>
-<TR id="mail.pop3.ssl.socketFactory">
-<TD>mail.pop3.ssl.socketFactory</TD>
-<TD>SSLSocketFactory</TD>
-<TD>
-If set to a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class, this class
-will be used to create POP3 SSL sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.socketFactory.class"></A>
-<TR id="mail.pop3.ssl.socketFactory.class">
-<TD>mail.pop3.ssl.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class. This class
-will be used to create POP3 SSL sockets.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.socketFactory.port"></A>
-<TR id="mail.pop3.ssl.socketFactory.port">
-<TD>mail.pop3.ssl.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.protocols"></A>
-<TR id="mail.pop3.ssl.protocols">
-<TD>mail.pop3.ssl.protocols</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL protocols that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledProtocols</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.ssl.ciphersuites"></A>
-<TR id="mail.pop3.ssl.ciphersuites">
-<TD>mail.pop3.ssl.ciphersuites</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL cipher suites that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledCipherSuites</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.starttls.enable"></A>
-<TR id="mail.pop3.starttls.enable">
-<TD>mail.pop3.starttls.enable</TD>
-<TD>boolean</TD>
-<TD>
-If true, enables the use of the <code>STLS</code> command (if
-supported by the server) to switch the connection to a TLS-protected
-connection before issuing any login commands. Note that an appropriate
-trust store must configured so that the client will trust the server's
-certificate.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.starttls.required"></A>
-<TR id="mail.pop3.starttls.required">
-<TD>mail.pop3.starttls.required</TD>
-<TD>boolean</TD>
-<TD>
-If true, requires the use of the <code>STLS</code> command.
-If the server doesn't support the STLS command, or the command
-fails, the connect method will fail.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socks.host"></A>
-<TR id="mail.pop3.socks.host">
-<TD>mail.pop3.socks.host</TD>
-<TD>string</TD>
-<TD>
-Specifies the host name of a SOCKS5 proxy server that will be used for
-connections to the mail server.
-(Note that this only works on JDK 1.5 or newer.)
-</TD>
-</TR>
-
-<A NAME="mail.pop3.socks.port"></A>
-<TR id="mail.pop3.socks.port">
-<TD>mail.pop3.socks.port</TD>
-<TD>string</TD>
-<TD>
-Specifies the port number for the SOCKS5 proxy server.
-This should only need to be used if the proxy server is not using
-the standard port number of 1080.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.disabletop"></A>
-<TR id="mail.pop3.disabletop">
-<TD>mail.pop3.disabletop</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the POP3 TOP command will not be used to fetch
-message headers. This is useful for POP3 servers that don't
-properly implement the TOP command, or that provide incorrect
-information in the TOP command results.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.disablecapa"></A>
-<TR id="mail.pop3.disablecapa">
-<TD>mail.pop3.disablecapa</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the POP3 CAPA command will not be used to fetch
-server capabilities. This is useful for POP3 servers that don't
-properly implement the CAPA command, or that provide incorrect
-information in the CAPA command results.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.forgettopheaders"></A>
-<TR id="mail.pop3.forgettopheaders">
-<TD>mail.pop3.forgettopheaders</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the headers that might have been retrieved using
-the POP3 TOP command will be forgotten and replaced by headers
-retrieved as part of the POP3 RETR command. Some servers, such
-as some versions of Microsft Exchange and IBM Lotus Notes,
-will return slightly different
-headers each time the TOP or RETR command is used. To allow the
-POP3 provider to properly parse the message content returned from
-the RETR command, the headers also returned by the RETR command
-must be used. Setting this property to true will cause these
-headers to be used, even if they differ from the headers returned
-previously as a result of using the TOP command.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.filecache.enable"></A>
-<TR id="mail.pop3.filecache.enable">
-<TD>mail.pop3.filecache.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the POP3 provider will cache message data in a temporary
-file rather than in memory. Messages are only added to the cache when
-accessing the message content. Message headers are always cached in
-memory (on demand). The file cache is removed when the folder is closed
-or the JVM terminates.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.filecache.dir"></A>
-<TR id="mail.pop3.filecache.dir">
-<TD>mail.pop3.filecache.dir</TD>
-<TD>String</TD>
-<TD>
-If the file cache is enabled, this property can be used to override the
-default directory used by the JDK for temporary files.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.cachewriteto"></A>
-<TR id="mail.pop3.cachewriteto">
-<TD>mail.pop3.cachewriteto</TD>
-<TD>boolean</TD>
-<TD>
-Controls the behavior of the
-{@link com.sun.mail.pop3.POP3Message#writeTo writeTo} method
-on a POP3 message object.
-If set to true, and the message content hasn't yet been cached,
-and ignoreList is null, the message is cached before being written.
-Otherwise, the message is streamed directly
-to the output stream without being cached.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.keepmessagecontent"></A>
-<TR id="mail.pop3.keepmessagecontent">
-<TD>mail.pop3.keepmessagecontent</TD>
-<TD>boolean</TD>
-<TD>
-The content of a message is cached when it is first fetched.
-Normally this cache uses a {@link java.lang.ref.SoftReference SoftReference}
-to refer to the cached content. This allows the cached content to be purged
-if memory is low, in which case the content will be fetched again if it's
-needed.
-If this property is set to true, a hard reference to the cached content
-will be kept, preventing the memory from being reused until the folder
-is closed or the cached content is explicitly invalidated (using the
-{@link com.sun.mail.pop3.POP3Message#invalidate invalidate} method).
-(This was the behavior in previous versions of JavaMail.)
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.pop3.finalizecleanclose"></A>
-<TR id="mail.pop3.finalizecleanclose">
-<TD>mail.pop3.finalizecleanclose</TD>
-<TD>boolean</TD>
-<TD>
-When the finalizer for POP3Store or POP3Folder is called,
-should the connection to the server be closed cleanly, as if the
-application called the close method?
-Or should the connection to the server be closed without sending
-any commands to the server?
-Defaults to false, the connection is not closed cleanly.
-</TD>
-</TR>
-
-</TABLE>
-<P>
-In general, applications should not need to use the classes in this
-package directly. Instead, they should use the APIs defined by
-<code>javax.mail</code> package (and subpackages). Applications should
-never construct instances of <code>POP3Store</code> or
-<code>POP3Folder</code> directly. Instead, they should use the
-<code>Session</code> method <code>getStore</code> to acquire an
-appropriate <code>Store</code> object, and from that acquire
-<code>Folder</code> objects.
-<P>
-In addition to printing debugging output as controlled by the
-{@link javax.mail.Session Session} configuration,
-the com.sun.mail.pop3 provider logs the same information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>com.sun.mail.pop3</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the POP3Store</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.pop3</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.pop3.protocol</TD>
-<TD>FINEST</TD>
-<TD>Complete protocol trace</TD>
-</TR>
-</TABLE>
-
-<P>
-<strong>WARNING:</strong> The APIs unique to this package should be
-considered <strong>EXPERIMENTAL</strong>. They may be changed in the
-future in ways that are incompatible with applications using the
-current APIs.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/com/sun/mail/smtp/DigestMD5.java b/current/src/main/java/com/sun/mail/smtp/DigestMD5.java
index 8b744ee..184c050 100644
--- a/current/src/main/java/com/sun/mail/smtp/DigestMD5.java
+++ b/current/src/main/java/com/sun/mail/smtp/DigestMD5.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,8 +44,12 @@
import java.util.*;
import java.util.logging.Level;
import java.security.*;
+import java.nio.charset.StandardCharsets;
-import com.sun.mail.util.*;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BASE64DecoderStream;
/**
* DIGEST-MD5 authentication support.
@@ -91,7 +95,7 @@
logger.log(Level.FINE, "NoSuchAlgorithmException", ex);
throw new IOException(ex.toString());
}
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
uri = "smtp/" + host;
String nc = "00000001";
@@ -113,6 +117,10 @@
// server challenge random value
String nonce = map.get("nonce");
+ // Does server support UTF-8 usernames and passwords?
+ String charset = map.get("charset");
+ boolean utf8 = charset != null && charset.equalsIgnoreCase("utf-8");
+
random.nextBytes(bytes);
b64os.write(bytes);
b64os.flush();
@@ -122,7 +130,11 @@
bos.reset();
// DIGEST-MD5 computation, common portion (order critical)
- md5.update(md5.digest(
+ if (utf8) {
+ String up = user + ":" + realm + ":" + passwd;
+ md5.update(md5.digest(up.getBytes(StandardCharsets.UTF_8)));
+ } else
+ md5.update(md5.digest(
ASCIIUtility.getBytes(user + ":" + realm + ":" + passwd)));
md5.update(ASCIIUtility.getBytes(":" + nonce + ":" + cnonce));
clientResponse = toHex(md5.digest())
@@ -140,6 +152,8 @@
result.append(",nonce=\"" + nonce + "\"");
result.append(",cnonce=\"" + cnonce + "\"");
result.append(",digest-uri=\"" + uri + "\"");
+ if (utf8)
+ result.append(",charset=\"utf-8\"");
result.append(",response=" + toHex(md5.digest()));
if (logger.isLoggable(Level.FINE))
@@ -179,7 +193,7 @@
@SuppressWarnings("fallthrough")
private Map<String, String> tokenize(String serverResponse)
throws IOException {
- Map<String, String> map = new HashMap<String, String>();
+ Map<String, String> map = new HashMap<>();
byte[] bytes = serverResponse.getBytes("iso-8859-1"); // really ASCII?
String key = null;
int ttype;
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPAddressFailedException.java b/current/src/main/java/com/sun/mail/smtp/SMTPAddressFailedException.java
index 99e7296..8d6fe30 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPAddressFailedException.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPAddressFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPAddressSucceededException.java b/current/src/main/java/com/sun/mail/smtp/SMTPAddressSucceededException.java
index ca6c2e3..3f40a8c 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPAddressSucceededException.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPAddressSucceededException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPMessage.java b/current/src/main/java/com/sun/mail/smtp/SMTPMessage.java
index c6042a7..83fd3b5 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPMessage.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPMessage.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -186,7 +186,7 @@
return null;
if (notifyOptions == NOTIFY_NEVER)
return "NEVER";
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if ((notifyOptions & NOTIFY_SUCCESS) != 0)
sb.append("SUCCESS");
if ((notifyOptions & NOTIFY_FAILURE) != 0) {
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPOutputStream.java b/current/src/main/java/com/sun/mail/smtp/SMTPOutputStream.java
index ae0c20f..72fd380 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPOutputStream.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -57,6 +57,7 @@
super(os);
}
+ @Override
public void write(int b) throws IOException {
// if that last character was a newline, and the current
// character is ".", we always write out an extra ".".
@@ -70,6 +71,7 @@
/*
* This method has been added to improve performance.
*/
+ @Override
public void write(byte b[], int off, int len) throws IOException {
int lastc = (lastb == -1) ? '\n' : lastb;
int start = off;
@@ -99,6 +101,7 @@
* SMTPTransport will manually flush the socket before reading
* the response.
*/
+ @Override
public void flush() {
// do nothing
}
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPProvider.java b/current/src/main/java/com/sun/mail/smtp/SMTPProvider.java
new file mode 100644
index 0000000..8e752ec
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPProvider.java
@@ -0,0 +1,54 @@
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.smtp;
+
+import javax.mail.Provider;
+
+/**
+ * The SMTP protocol provider.
+ */
+public class SMTPProvider extends Provider {
+ public SMTPProvider() {
+ super(Provider.Type.TRANSPORT, "smtp", SMTPTransport.class.getName(),
+ "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPSSLProvider.java b/current/src/main/java/com/sun/mail/smtp/SMTPSSLProvider.java
new file mode 100644
index 0000000..a0ee09b
--- /dev/null
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPSSLProvider.java
@@ -0,0 +1,54 @@
+
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package com.sun.mail.smtp;
+
+import javax.mail.Provider;
+
+/**
+ * The SMTP SSL protocol provider.
+ */
+public class SMTPSSLProvider extends Provider {
+ public SMTPSSLProvider() {
+ super(Provider.Type.TRANSPORT, "smtps",
+ SMTPSSLTransport.class.getName(), "Oracle", null);
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPSSLTransport.java b/current/src/main/java/com/sun/mail/smtp/SMTPSSLTransport.java
index 2c52386..06ad2c8 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPSSLTransport.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPSSLTransport.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPSaslAuthenticator.java b/current/src/main/java/com/sun/mail/smtp/SMTPSaslAuthenticator.java
index 329fe7d..9774d04 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPSaslAuthenticator.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPSaslAuthenticator.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -47,7 +47,10 @@
import javax.security.auth.callback.*;
import javax.mail.MessagingException;
-import com.sun.mail.util.*;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BASE64DecoderStream;
/**
* This class contains a single method that does authentication using
@@ -84,6 +87,7 @@
this.host = host;
}
+ @Override
public boolean authenticate(String[] mechs, final String realm,
final String authzid, final String u,
final String p) throws MessagingException {
@@ -98,6 +102,7 @@
SaslClient sc;
CallbackHandler cbh = new CallbackHandler() {
+ @Override
public void handle(Callback[] callbacks) {
if (logger.isLoggable(Level.FINE))
logger.fine("SASL callback length: " + callbacks.length);
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPSendFailedException.java b/current/src/main/java/com/sun/mail/smtp/SMTPSendFailedException.java
index dcd02e4..95dc389 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPSendFailedException.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPSendFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPSenderFailedException.java b/current/src/main/java/com/sun/mail/smtp/SMTPSenderFailedException.java
index 9c1b52f..17ef087 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPSenderFailedException.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPSenderFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/SMTPTransport.java b/current/src/main/java/com/sun/mail/smtp/SMTPTransport.java
index b771bdc..9f39278 100644
--- a/current/src/main/java/com/sun/mail/smtp/SMTPTransport.java
+++ b/current/src/main/java/com/sun/mail/smtp/SMTPTransport.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -45,14 +45,24 @@
import java.util.*;
import java.util.logging.Level;
import java.lang.reflect.*;
+import java.nio.charset.StandardCharsets;
import javax.net.ssl.SSLSocket;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
-import com.sun.mail.util.*;
-import com.sun.mail.auth.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.MailLogger;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.SocketFetcher;
+import com.sun.mail.util.MailConnectException;
+import com.sun.mail.util.SocketConnectException;
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.LineInputStream;
+import com.sun.mail.util.TraceInputStream;
+import com.sun.mail.util.TraceOutputStream;
+import com.sun.mail.auth.Ntlm;
/**
* This class implements the Transport abstract class using SMTP for
@@ -109,7 +119,7 @@
private Hashtable<String, String> extMap;
private Map<String, Authenticator> authenticators
- = new HashMap<String, Authenticator>();
+ = new HashMap<>();
private String defaultAuthenticationMechanisms; // set in constructor
private boolean quitWait = false; // true if we should wait
@@ -140,6 +150,8 @@
private boolean noauthdebug = true; // hide auth info in debug output
private boolean debugusername; // include username in debug output?
private boolean debugpassword; // include password in debug output?
+ private boolean allowutf8; // allow UTF-8 usernames and passwords?
+ private int chunkSize; // chunk size if CHUNKING supported
/** Headers that should not be included when sending */
private static final String[] ignoreList = { "Bcc", "Content-Length" };
@@ -169,19 +181,22 @@
protected SMTPTransport(Session session, URLName urlname,
String name, boolean isSSL) {
super(session, urlname);
- logger = new MailLogger(this.getClass(), "DEBUG SMTP", session);
+ Properties props = session.getProperties();
+
+ logger = new MailLogger(this.getClass(), "DEBUG SMTP",
+ session.getDebug(), session.getDebugOut());
traceLogger = logger.getSubLogger("protocol", null);
- noauthdebug = !PropUtil.getBooleanSessionProperty(session,
+ noauthdebug = !PropUtil.getBooleanProperty(props,
"mail.debug.auth", false);
- debugusername = PropUtil.getBooleanSessionProperty(session,
+ debugusername = PropUtil.getBooleanProperty(props,
"mail.debug.auth.username", true);
- debugpassword = PropUtil.getBooleanSessionProperty(session,
+ debugpassword = PropUtil.getBooleanProperty(props,
"mail.debug.auth.password", false);
if (urlname != null)
name = urlname.getProtocol();
this.name = name;
if (!isSSL)
- isSSL = PropUtil.getBooleanSessionProperty(session,
+ isSSL = PropUtil.getBooleanProperty(props,
"mail." + name + ".ssl.enable", false);
if (isSSL)
this.defaultPort = 465;
@@ -191,40 +206,50 @@
// setting mail.smtp.quitwait to false causes us to not wait for the
// response from the QUIT command
- quitWait = PropUtil.getBooleanSessionProperty(session,
+ quitWait = PropUtil.getBooleanProperty(props,
"mail." + name + ".quitwait", true);
// mail.smtp.reportsuccess causes us to throw an exception on success
- reportSuccess = PropUtil.getBooleanSessionProperty(session,
+ reportSuccess = PropUtil.getBooleanProperty(props,
"mail." + name + ".reportsuccess", false);
// mail.smtp.starttls.enable enables use of STARTTLS command
- useStartTLS = PropUtil.getBooleanSessionProperty(session,
+ useStartTLS = PropUtil.getBooleanProperty(props,
"mail." + name + ".starttls.enable", false);
// mail.smtp.starttls.required requires use of STARTTLS command
- requireStartTLS = PropUtil.getBooleanSessionProperty(session,
+ requireStartTLS = PropUtil.getBooleanProperty(props,
"mail." + name + ".starttls.required", false);
// mail.smtp.userset causes us to use RSET instead of NOOP
// for isConnected
- useRset = PropUtil.getBooleanSessionProperty(session,
+ useRset = PropUtil.getBooleanProperty(props,
"mail." + name + ".userset", false);
// mail.smtp.noop.strict requires 250 response to indicate success
- noopStrict = PropUtil.getBooleanSessionProperty(session,
+ noopStrict = PropUtil.getBooleanProperty(props,
"mail." + name + ".noop.strict", true);
// check if SASL is enabled
- enableSASL = PropUtil.getBooleanSessionProperty(session,
+ enableSASL = PropUtil.getBooleanProperty(props,
"mail." + name + ".sasl.enable", false);
if (enableSASL)
logger.config("enable SASL");
- useCanonicalHostName = PropUtil.getBooleanSessionProperty(session,
+ useCanonicalHostName = PropUtil.getBooleanProperty(props,
"mail." + name + ".sasl.usecanonicalhostname", false);
if (useCanonicalHostName)
logger.config("use canonical host name");
+ allowutf8 = PropUtil.getBooleanProperty(props,
+ "mail.mime.allowutf8", false);
+ if (allowutf8)
+ logger.config("allow UTF-8");
+
+ chunkSize = PropUtil.getIntProperty(props,
+ "mail." + name + ".chunksize", -1);
+ if (chunkSize > 0 && logger.isLoggable(Level.CONFIG))
+ logger.config("chunk size " + chunkSize);
+
// created here, because they're inner classes that reference "this"
Authenticator[] a = new Authenticator[] {
new LoginAuthenticator(),
@@ -233,7 +258,7 @@
new NtlmAuthenticator(),
new OAuth2Authenticator()
};
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i = 0; i < a.length; i++) {
authenticators.put(a[i].getMechanism(), a[i]);
sb.append(a[i].getMechanism()).append(' ');
@@ -418,7 +443,7 @@
*/
public synchronized String[] getSASLMechanisms() {
if (saslMechanisms == UNKNOWN_SA) {
- List<String> v = new ArrayList<String>(5);
+ List<String> v = new ArrayList<>(5);
String s = session.getProperty("mail." + name + ".sasl.mechanisms");
if (s != null && s.length() > 0) {
if (logger.isLoggable(Level.FINE))
@@ -656,11 +681,14 @@
* @return true if connection successful, false if authentication failed
* @exception MessagingException for non-authentication failures
*/
+ @Override
protected synchronized boolean protocolConnect(String host, int port,
String user, String password)
throws MessagingException {
+ Properties props = session.getProperties();
+
// setting mail.smtp.auth to true enables attempts to use AUTH
- boolean useAuth = PropUtil.getBooleanSessionProperty(session,
+ boolean useAuth = PropUtil.getBooleanProperty(props,
"mail." + name + ".auth", false);
/*
@@ -681,7 +709,7 @@
}
// setting mail.smtp.ehlo to false disables attempts to use EHLO
- boolean useEhlo = PropUtil.getBooleanSessionProperty(session,
+ boolean useEhlo = PropUtil.getBooleanProperty(props,
"mail." + name + ".ehlo", true);
if (logger.isLoggable(Level.FINE))
logger.fine("useEhlo " + useEhlo + ", useAuth " + useAuth);
@@ -691,7 +719,7 @@
* property if it exists, otherwise default to 25.
*/
if (port == -1)
- port = PropUtil.getIntSessionProperty(session,
+ port = PropUtil.getIntProperty(props,
"mail." + name + ".port", -1);
if (port == -1)
port = defaultPort;
@@ -737,6 +765,10 @@
}
}
+ if (allowutf8 && !supportsExtension("SMTPUTF8"))
+ logger.log(Level.INFO, "mail.mime.allowutf8 set " +
+ "but server doesn't advertise SMTPUTF8 support");
+
if ((useAuth || (user != null && password != null)) &&
(supportsExtension("AUTH") ||
supportsExtension("AUTH=LOGIN"))) {
@@ -828,8 +860,9 @@
if (mechs == defaultAuthenticationMechanisms) {
String dprop = "mail." + name + ".auth." +
m.toLowerCase(Locale.ENGLISH) + ".disable";
- boolean disabled = PropUtil.getBooleanSessionProperty(
- session, dprop, !a.enabled());
+ boolean disabled = PropUtil.getBooleanProperty(
+ session.getProperties(),
+ dprop, !a.enabled());
if (disabled) {
if (logger.isLoggable(Level.FINE))
logger.fine("mechanism " + m +
@@ -957,15 +990,16 @@
super("LOGIN");
}
+ @Override
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
// send username
- resp = simpleCommand(
- BASE64EncoderStream.encode(ASCIIUtility.getBytes(user)));
+ resp = simpleCommand(BASE64EncoderStream.encode(
+ user.getBytes(StandardCharsets.UTF_8)));
if (resp == 334) {
// send passwd
- resp = simpleCommand(
- BASE64EncoderStream.encode(ASCIIUtility.getBytes(passwd)));
+ resp = simpleCommand(BASE64EncoderStream.encode(
+ passwd.getBytes(StandardCharsets.UTF_8)));
}
}
}
@@ -978,6 +1012,7 @@
super("PLAIN");
}
+ @Override
String getInitialResponse(String host, String authzid, String user,
String passwd) throws MessagingException, IOException {
// return "authzid<NUL>user<NUL>passwd"
@@ -985,16 +1020,17 @@
OutputStream b64os =
new BASE64EncoderStream(bos, Integer.MAX_VALUE);
if (authzid != null)
- b64os.write(ASCIIUtility.getBytes(authzid));
+ b64os.write(authzid.getBytes(StandardCharsets.UTF_8));
b64os.write(0);
- b64os.write(ASCIIUtility.getBytes(user));
+ b64os.write(user.getBytes(StandardCharsets.UTF_8));
b64os.write(0);
- b64os.write(ASCIIUtility.getBytes(passwd));
+ b64os.write(passwd.getBytes(StandardCharsets.UTF_8));
b64os.flush(); // complete the encoding
return ASCIIUtility.toString(bos.toByteArray());
}
+ @Override
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
// should never get here
@@ -1018,6 +1054,7 @@
return md5support;
}
+ @Override
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
DigestMD5 md5 = getMD5();
@@ -1049,6 +1086,7 @@
super("NTLM");
}
+ @Override
String getInitialResponse(String host, String authzid, String user,
String passwd) throws MessagingException, IOException {
ntlm = new Ntlm(getNTLMDomain(), getLocalHost(),
@@ -1062,6 +1100,7 @@
return type1;
}
+ @Override
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
assert ntlm != null;
@@ -1081,14 +1120,17 @@
super("XOAUTH2", false); // disabled by default
}
+ @Override
String getInitialResponse(String host, String authzid, String user,
String passwd) throws MessagingException, IOException {
String resp = "user=" + user + "\001auth=Bearer " +
passwd + "\001\001";
- byte[] b = BASE64EncoderStream.encode(ASCIIUtility.getBytes(resp));
+ byte[] b = BASE64EncoderStream.encode(
+ resp.getBytes(StandardCharsets.UTF_8));
return ASCIIUtility.toString(b);
}
+ @Override
void doAuth(String host, String authzid, String user, String passwd)
throws MessagingException, IOException {
// should never get here
@@ -1144,13 +1186,13 @@
List<String> v;
if (allowed != null && allowed.length > 0) {
// remove anything not supported by the server
- v = new ArrayList<String>(allowed.length);
+ v = new ArrayList<>(allowed.length);
for (int i = 0; i < allowed.length; i++)
if (supportsAuthentication(allowed[i])) // XXX - case must match
v.add(allowed[i]);
} else {
// everything is allowed
- v = new ArrayList<String>();
+ v = new ArrayList<>();
if (extMap != null) {
String a = extMap.get("AUTH");
if (a != null) {
@@ -1207,6 +1249,7 @@
* or not in the connected state or if the message is
* not a MimeMessage.
*/
+ @Override
public synchronized void sendMessage(Message message, Address[] addresses)
throws MessagingException, SendFailedException {
@@ -1237,7 +1280,7 @@
if (message instanceof SMTPMessage)
use8bit = ((SMTPMessage)message).getAllow8bitMIME();
if (!use8bit)
- use8bit = PropUtil.getBooleanSessionProperty(session,
+ use8bit = PropUtil.getBooleanProperty(session.getProperties(),
"mail." + name + ".allow8bitmime", false);
if (logger.isLoggable(Level.FINE))
logger.fine("use8bit " + use8bit);
@@ -1256,8 +1299,22 @@
try {
mailFrom();
rcptTo();
- this.message.writeTo(data(), ignoreList);
- finishData();
+ if (chunkSize > 0 && supportsExtension("CHUNKING")) {
+ /*
+ * Use BDAT to send the data in chunks.
+ * Note that even though the BDAT command is able to send
+ * messages that contain binary data, we can't use it to
+ * do that because a) we still need to canonicalize the
+ * line terminators for text data, which we can't tell apart
+ * from the message content, and b) the message content is
+ * encoded before we even know that we can use BDAT.
+ */
+ this.message.writeTo(bdat(), ignoreList);
+ finishBdat();
+ } else {
+ this.message.writeTo(data(), ignoreList);
+ finishData();
+ }
if (sendPartiallyFailed) {
// throw the exception,
// fire TransportEvent.MESSAGE_PARTIALLY_DELIVERED event
@@ -1343,6 +1400,7 @@
/**
* Close the Transport and terminate the connection to the server.
*/
+ @Override
public synchronized void close() throws MessagingException {
if (!super.isConnected()) // Already closed.
return;
@@ -1381,6 +1439,7 @@
* Check whether the transport is connected. Override superclass
* method, to actually ping our server connection.
*/
+ @Override
public synchronized boolean isConnected() {
if (!super.isConnected())
// if we haven't been connected at all, don't bother with NOOP
@@ -1438,6 +1497,7 @@
*
* @since JavaMail 1.4.2
*/
+ @Override
protected void notifyTransportListeners(int type, Address[] validSent,
Address[] validUnsent,
Address[] invalid, Message msg) {
@@ -1459,7 +1519,7 @@
if (a.isGroup()) {
if (groups == null) {
// first group, catch up with where we are
- groups = new ArrayList<Address>();
+ groups = new ArrayList<>();
for (int k = 0; k < i; k++)
groups.add(addresses[k]);
}
@@ -1585,6 +1645,7 @@
return need8bit;
}
+ @Override
protected void finalize() throws Throwable {
try {
closeConnection();
@@ -1641,7 +1702,7 @@
BufferedReader rd =
new BufferedReader(new StringReader(lastServerResponse));
String line;
- extMap = new Hashtable<String, String>();
+ extMap = new Hashtable<>();
try {
boolean first = true;
while ((line = rd.readLine()) != null) {
@@ -1707,6 +1768,9 @@
String cmd = "MAIL FROM:" + normalizeAddress(from);
+ if (allowutf8 && supportsExtension("SMTPUTF8"))
+ cmd += " SMTPUTF8";
+
// request delivery status notification?
if (supportsExtension("DSN")) {
String ret = null;
@@ -1733,7 +1797,8 @@
// XXX - check for legal syntax?
if (submitter != null) {
try {
- String s = xtext(submitter);
+ String s = xtext(submitter,
+ allowutf8 && supportsExtension("SMTPUTF8"));
cmd += " AUTH=" + s;
} catch (IllegalArgumentException ex) {
if (logger.isLoggable(Level.FINE))
@@ -1799,9 +1864,9 @@
* valid addr: 552 (quota), 450, 451, 452 (quota), 421 (srvr abort)
*/
protected void rcptTo() throws MessagingException {
- List<InternetAddress> valid = new ArrayList<InternetAddress>();
- List<InternetAddress> validUnsent = new ArrayList<InternetAddress>();
- List<InternetAddress> invalid = new ArrayList<InternetAddress>();
+ List<InternetAddress> valid = new ArrayList<>();
+ List<InternetAddress> validUnsent = new ArrayList<>();
+ List<InternetAddress> invalid = new ArrayList<>();
int retCode = -1;
MessagingException mex = null;
boolean sendFailed = false;
@@ -1811,7 +1876,7 @@
if (message instanceof SMTPMessage)
sendPartial = ((SMTPMessage)message).getSendPartial();
if (!sendPartial)
- sendPartial = PropUtil.getBooleanSessionProperty(session,
+ sendPartial = PropUtil.getBooleanProperty(session.getProperties(),
"mail." + name + ".sendpartial", false);
if (sendPartial)
logger.fine("sendPartial set");
@@ -2046,6 +2111,32 @@
}
/**
+ * Return a stream that will use the SMTP BDAT command to send data.
+ *
+ * @return the stream to write to
+ * @exception MessagingException for failures
+ * @since JavaMail 1.6.0
+ */
+ protected OutputStream bdat() throws MessagingException {
+ assert Thread.holdsLock(this);
+ dataStream = new BDATOutputStream(serverOutput, chunkSize);
+ return dataStream;
+ }
+
+ /**
+ * Terminate the sent data.
+ *
+ * @exception IOException for I/O errors
+ * @exception MessagingException for other failures
+ * @since JavaMail 1.6.0
+ */
+ protected void finishBdat() throws IOException, MessagingException {
+ assert Thread.holdsLock(this);
+ dataStream.ensureAtBOL();
+ dataStream.close(); // doesn't close underlying socket
+ }
+
+ /**
* Issue the <code>STARTTLS</code> command and switch the socket to
* TLS mode if it succeeds.
*
@@ -2102,7 +2193,7 @@
if (logger.isLoggable(Level.FINE))
logger.fine("could not connect to host \"" +
host + "\", port: " + port +
- ", response: " + r + "\n");
+ ", response: " + r);
throw new MessagingException(
"Could not connect to SMTP host: " + host +
", port: " + port +
@@ -2110,7 +2201,7 @@
} else {
if (logger.isLoggable(Level.FINE))
logger.fine("connected to host \"" +
- host + "\", port: " + port + "\n");
+ host + "\", port: " + port);
}
} catch (UnknownHostException uhex) {
throw new MessagingException("Unknown SMTP host: " + host, uhex);
@@ -2148,7 +2239,7 @@
if (logger.isLoggable(Level.FINE))
logger.fine("got bad greeting from host \"" +
host + "\", port: " + port +
- ", response: " + r + "\n");
+ ", response: " + r);
throw new MessagingException(
"Got bad greeting from SMTP host: " + host +
", port: " + port +
@@ -2156,7 +2247,7 @@
} else {
if (logger.isLoggable(Level.FINE))
logger.fine("protocol started to host \"" +
- host + "\", port: " + port + "\n");
+ host + "\", port: " + port);
}
} catch (IOException ioe) {
throw new MessagingException(
@@ -2167,7 +2258,7 @@
private void initStreams() throws IOException {
- boolean quote = PropUtil.getBooleanSessionProperty(session,
+ boolean quote = PropUtil.getBooleanProperty(session.getProperties(),
"mail.debug.quote", false);
traceInput =
@@ -2308,7 +2399,7 @@
* @since JavaMail 1.4.1
*/
protected void sendCommand(String cmd) throws MessagingException {
- sendCommand(ASCIIUtility.getBytes(cmd));
+ sendCommand(toBytes(cmd));
}
private void sendCommand(byte[] cmdBytes) throws MessagingException {
@@ -2338,7 +2429,7 @@
assert Thread.holdsLock(this);
String serverResponse = "";
int returnCode = 0;
- StringBuffer buf = new StringBuffer(100);
+ StringBuilder buf = new StringBuilder(100);
// read the server response line(s) and add them to the buffer
// that stores the response
@@ -2519,16 +2610,35 @@
* @return the xtext format string
* @since JavaMail 1.4.1
*/
+ // XXX - keeping this around only for compatibility
protected static String xtext(String s) {
- StringBuffer sb = null;
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c >= 128) // not ASCII
+ return xtext(s, false);
+ }
+
+ /**
+ * Like xtext(s), but allow UTF-8 strings.
+ *
+ * @param s the string to convert
+ * @param utf8 convert string to UTF-8 first?
+ * @return the xtext format string
+ * @since JavaMail 1.6.0
+ */
+ protected static String xtext(String s, boolean utf8) {
+ StringBuilder sb = null;
+ byte[] bytes;
+ if (utf8)
+ bytes = s.getBytes(StandardCharsets.UTF_8);
+ else
+ bytes = ASCIIUtility.getBytes(s);
+ for (int i = 0; i < bytes.length; i++) {
+ char c = (char)(((int)bytes[i])&0xff);
+ if (!utf8 && c >= 128) // not ASCII
throw new IllegalArgumentException(
- "Non-ASCII character in SMTP submitter: " + s);
+ "Non-ASCII character in SMTP submitter: " + s);
if (c < '!' || c > '~' || c == '+' || c == '=') {
+ // not printable ASCII
if (sb == null) {
- sb = new StringBuffer(s.length() + 4);
+ sb = new StringBuilder(s.length() + 4);
sb.append(s.substring(0, i));
}
sb.append('+');
@@ -2551,9 +2661,155 @@
(password == null ? "<null>" : "<non-null>");
}
+ /**
+ * Convert the String to either ASCII or UTF-8 bytes
+ * depending on allowutf8.
+ */
+ private byte[] toBytes(String s) {
+ if (allowutf8)
+ return s.getBytes(StandardCharsets.UTF_8);
+ else
+ // don't use StandardCharsets.US_ASCII because it rejects non-ASCII
+ return ASCIIUtility.getBytes(s);
+ }
+
/*
* Probe points for GlassFish monitoring.
*/
private void sendMessageStart(String subject) { }
private void sendMessageEnd() { }
+
+
+ /**
+ * An SMTPOutputStream that wraps a ChunkedOutputStream.
+ */
+ private class BDATOutputStream extends SMTPOutputStream {
+
+ /**
+ * Create a BDATOutputStream that wraps a ChunkedOutputStream
+ * of the given size and built on top of the specified
+ * underlying output stream.
+ *
+ * @param out the underlying output stream
+ * @param size the chunk size
+ */
+ public BDATOutputStream(OutputStream out, int size) {
+ super(new ChunkedOutputStream(out, size));
+ }
+
+ /**
+ * Close this output stream.
+ *
+ * @exception IOException for I/O errors
+ */
+ @Override
+ public void close() throws IOException {
+ out.close();
+ }
+ }
+
+ /**
+ * An OutputStream that buffers data in chunks and uses the
+ * RFC 3030 BDAT SMTP command to send each chunk.
+ */
+ private class ChunkedOutputStream extends OutputStream {
+ private final OutputStream out;
+ private final byte[] buf;
+ private int count = 0;
+
+ /**
+ * Create a ChunkedOutputStream built on top of the specified
+ * underlying output stream.
+ *
+ * @param out the underlying output stream
+ * @param size the chunk size
+ */
+ public ChunkedOutputStream(OutputStream out, int size) {
+ this.out = out;
+ buf = new byte[size];
+ }
+
+ /**
+ * Writes the specified <code>byte</code> to this output stream.
+ *
+ * @param b the byte to write
+ * @exception IOException for I/O errors
+ */
+ @Override
+ public void write(int b) throws IOException {
+ buf[count++] = (byte)b;
+ if (count >= buf.length)
+ flush();
+ }
+
+ /**
+ * Writes len bytes to this output stream starting at off.
+ *
+ * @param b bytes to write
+ * @param off offset in array
+ * @param len number of bytes to write
+ * @exception IOException for I/O errors
+ */
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ while (len > 0) {
+ int size = Math.min(buf.length - count, len);
+ if (size == buf.length) {
+ // avoid the copy
+ bdat(b, off, size, false);
+ } else {
+ System.arraycopy(b, off, buf, count, size);
+ count += size;
+ }
+ off += size;
+ len -= size;
+ if (count >= buf.length)
+ flush();
+ }
+ }
+
+ /**
+ * Flush this output stream.
+ *
+ * @exception IOException for I/O errors
+ */
+ @Override
+ public void flush() throws IOException {
+ bdat(buf, 0, count, false);
+ count = 0;
+ }
+
+ /**
+ * Close this output stream.
+ *
+ * @exception IOException for I/O errors
+ */
+ @Override
+ public void close() throws IOException {
+ bdat(buf, 0, count, true);
+ count = 0;
+ }
+
+ /**
+ * Send the specified bytes using the BDAT command.
+ */
+ private void bdat(byte[] b, int off, int len, boolean last)
+ throws IOException {
+ if (len > 0 || last) {
+ try {
+ if (last)
+ sendCommand("BDAT " + len + " LAST");
+ else
+ sendCommand("BDAT " + len);
+ out.write(b, off, len);
+ out.flush();
+ int ret = readServerResponse();
+ if (ret != 250)
+ throw new IOException(lastServerResponse);
+ } catch (MessagingException mex) {
+ throw new IOException("BDAT write exception", mex);
+ }
+ }
+ }
+ }
}
diff --git a/current/src/main/java/com/sun/mail/smtp/SaslAuthenticator.java b/current/src/main/java/com/sun/mail/smtp/SaslAuthenticator.java
index 3300831..f3486ac 100644
--- a/current/src/main/java/com/sun/mail/smtp/SaslAuthenticator.java
+++ b/current/src/main/java/com/sun/mail/smtp/SaslAuthenticator.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/smtp/package.html b/current/src/main/java/com/sun/mail/smtp/package.html
deleted file mode 100644
index 3ba3f68..0000000
--- a/current/src/main/java/com/sun/mail/smtp/package.html
+++ /dev/null
@@ -1,833 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-An SMTP protocol provider for the JavaMail API
-that provides access to an SMTP server.
-Refer to <A HREF="http://www.ietf.org/rfc/rfc821.txt" TARGET="_top">RFC 821</A>
-for more information.
-<P>
-When sending a message, detailed information on each address that
-fails is available in an
-{@link com.sun.mail.smtp.SMTPAddressFailedException SMTPAddressFailedException}
-chained off the top level
-{@link javax.mail.SendFailedException SendFailedException}
-that is thrown.
-In addition, if the <code>mail.smtp.reportsuccess</code> property
-is set, an
-{@link com.sun.mail.smtp.SMTPAddressSucceededException
-SMTPAddressSucceededException}
-will be included in the list for each address that is successful.
-Note that this will cause a top level
-{@link javax.mail.SendFailedException SendFailedException}
-to be thrown even though the send was successful.
-<P>
-The SMTP provider also supports ESMTP
-(<A HREF="http://www.ietf.org/rfc/rfc1651.txt" TARGET="_top">RFC 1651</A>).
-It can optionally use SMTP Authentication
-(<A HREF="http://www.ietf.org/rfc/rfc2554.txt" TARGET="_top">RFC 2554</A>)
-using the LOGIN, PLAIN, DIGEST-MD5, and NTLM mechanisms
-(<A HREF="http://www.ietf.org/rfc/rfc2595.txt" TARGET="_top">RFC 2595</A>
-and <A HREF="http://www.ietf.org/rfc/rfc2831.txt" TARGET="_top">RFC 2831</A>).
-<P>
-To use SMTP authentication you'll need to set the <code>mail.smtp.auth</code>
-property (see below) or provide the SMTP Transport
-with a username and password when connecting to the SMTP server. You
-can do this using one of the following approaches:
-<P>
-<UL>
-<LI>
-Provide an Authenticator object when creating your mail Session
-and provide the username and password information during the
-Authenticator callback.
-<P>
-Note that the <code>mail.smtp.user</code> property can be set to provide a
-default username for the callback, but the password will still need to be
-supplied explicitly.
-<P>
-This approach allows you to use the static Transport <code>send</code> method
-to send messages.
-</LI>
-<P>
-<LI>
-Call the Transport <code>connect</code> method explicitly with username and
-password arguments.
-<P>
-This approach requires you to explicitly manage a Transport object
-and use the Transport <code>sendMessage</code> method to send the message.
-The transport.java demo program demonstrates how to manage a Transport
-object. The following is roughly equivalent to the static
-Transport <code>send</code> method, but supplies the needed username and
-password:
-<P>
-<BLOCKQUOTE><PRE>
-Transport tr = session.getTransport("smtp");
-tr.connect(smtphost, username, password);
-msg.saveChanges(); // don't forget this
-tr.sendMessage(msg, msg.getAllRecipients());
-tr.close();
-</PRE></BLOCKQUOTE>
-</LI>
-</UL>
-<P>
-When using DIGEST-MD5 authentication,
-you'll also need to supply an appropriate realm;
-your mail server administrator can supply this information.
-You can set this using the <code>mail.smtp.sasl.realm</code> property,
-or the <code>setSASLRealm</code> method on <code>SMTPTransport</code>.
-<P>
-The SMTP protocol provider can use SASL
-(<A HREF="http://www.ietf.org/rfc/rfc2222.txt" TARGET="_top">RFC 2222</A>)
-authentication mechanisms on systems that support the
-<CODE>javax.security.sasl</CODE> APIs, such as J2SE 5.0.
-In addition to the SASL mechanisms that are built into
-the SASL implementation, users can also provide additional
-SASL mechanisms of their own design to support custom authentication
-schemes. See the
-<A HREF="http://java.sun.com/j2se/1.5.0/docs/guide/security/sasl/sasl-refguide.html" TARGET="_top">
-Java SASL API Programming and Deployment Guide</A> for details.
-Note that the current implementation doesn't support SASL mechanisms
-that provide their own integrity or confidentiality layer.
-<P>
-Support for OAuth 2.0 authentication via the
-<A HREF="https://developers.google.com/gmail/xoauth2_protocol" TARGET="_top">
-XOAUTH2 authentication mechanism</A> is provided either through the SASL
-support described above or as a built-in authentication mechanism in the
-SMTP provider.
-The OAuth 2.0 Access Token should be passed as the password for this mechanism.
-See <A HREF="https://java.net/projects/javamail/pages/OAuth2" TARGET="_top">
-OAuth2 Support</A> for details.
-<P>
-SMTP can also optionally request Delivery Status Notifications
-(<A HREF="http://www.ietf.org/rfc/rfc1891.txt" TARGET="_top">RFC 1891</A>).
-The delivery status will typically be reported using
-a "multipart/report"
-(<A HREF="http://www.ietf.org/rfc/rfc1892.txt" TARGET="_top">RFC 1892</A>)
-message type with a "message/delivery-status"
-(<A HREF="http://www.ietf.org/rfc/rfc1894.txt" TARGET="_top">RFC 1894</A>)
-part.
-You can use the classes in the {@link com.sun.mail.dsn} package to
-handle these MIME types.
-Note that you'll need to include <code>dsn.jar</code> in your CLASSPATH
-as this support is not included in <code>mail.jar</code>.
-<P>
-See below for the properties to enable these features.
-<P>
-Note also that <strong>THERE IS NOT SUFFICIENT DOCUMENTATION HERE TO USE THESE
-FEATURES!!!</strong> You will need to read the appropriate RFCs mentioned above
-to understand what these features do and how to use them. Don't just
-start setting properties and then complain to us when it doesn't work
-like you expect it to work. <strong>READ THE RFCs FIRST!!!</strong>
-<P>
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-The SMTP protocol provider supports the following properties,
-which may be set in the JavaMail <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- props.put("mail.smtp.port", "888");
-</PRE>
-to set the <CODE>mail.smtp.port</CODE> property, which is of type int.
-<P>
-Note that if you're using the "smtps" protocol to access SMTP over SSL,
-all the properties would be named "mail.smtps.*".
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.smtp.user"></A>
-<TR id="mail.smtp.user">
-<TD>mail.smtp.user</TD>
-<TD>String</TD>
-<TD>Default user name for SMTP.</TD>
-</TR>
-
-<A NAME="mail.smtp.host"></A>
-<TR id="mail.smtp.host">
-<TD>mail.smtp.host</TD>
-<TD>String</TD>
-<TD>The SMTP server to connect to.</TD>
-</TR>
-
-<A NAME="mail.smtp.port"></A>
-<TR id="mail.smtp.port">
-<TD>mail.smtp.port</TD>
-<TD>int</TD>
-<TD>The SMTP server port to connect to, if the connect() method doesn't
-explicitly specify one. Defaults to 25.</TD>
-</TR>
-
-<A NAME="mail.smtp.connectiontimeout"></A>
-<TR id="mail.smtp.connectiontimeout">
-<TD>mail.smtp.connectiontimeout</TD>
-<TD>int</TD>
-<TD>Socket connection timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.smtp.timeout"></A>
-<TR id="mail.smtp.timeout">
-<TD>mail.smtp.timeout</TD>
-<TD>int</TD>
-<TD>Socket read timeout value in milliseconds.
-This timeout is implemented by java.net.Socket.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.smtp.writetimeout"></A>
-<TR id="mail.smtp.writetimeout">
-<TD>mail.smtp.writetimeout</TD>
-<TD>int</TD>
-<TD>Socket write timeout value in milliseconds.
-This timeout is implemented by using a
-java.util.concurrent.ScheduledExecutorService per connection
-that schedules a thread to close the socket if the timeout expires.
-Thus, the overhead of using this timeout is one thread per connection.
-Default is infinite timeout.</TD>
-</TR>
-
-<A NAME="mail.smtp.from"></A>
-<TR id="mail.smtp.from">
-<TD>mail.smtp.from</TD>
-<TD>String</TD>
-<TD>
-Email address to use for SMTP MAIL command. This sets the envelope
-return address. Defaults to msg.getFrom() or
-InternetAddress.getLocalAddress(). NOTE: mail.smtp.user was previously
-used for this.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.localhost"></A>
-<TR id="mail.smtp.localhost">
-<TD>mail.smtp.localhost</TD>
-<TD>String</TD>
-<TD>
-Local host name used in the SMTP HELO or EHLO command.
-Defaults to <code>InetAddress.getLocalHost().getHostName()</code>.
-Should not normally need to
-be set if your JDK and your name service are configured properly.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.localaddress"></A>
-<TR id="mail.smtp.localaddress">
-<TD>mail.smtp.localaddress</TD>
-<TD>String</TD>
-<TD>
-Local address (host name) to bind to when creating the SMTP socket.
-Defaults to the address picked by the Socket class.
-Should not normally need to be set, but useful with multi-homed hosts
-where it's important to pick a particular local address to bind to.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.localport"></A>
-<TR id="mail.smtp.localport">
-<TD>mail.smtp.localport</TD>
-<TD>int</TD>
-<TD>
-Local port number to bind to when creating the SMTP socket.
-Defaults to the port number picked by the Socket class.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ehlo"></A>
-<TR id="mail.smtp.ehlo">
-<TD>mail.smtp.ehlo</TD>
-<TD>boolean</TD>
-<TD>
-If false, do not attempt to sign on with the EHLO command. Defaults to
-true. Normally failure of the EHLO command will fallback to the HELO
-command; this property exists only for servers that don't fail EHLO
-properly or don't implement EHLO properly.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.auth"></A>
-<TR id="mail.smtp.auth">
-<TD>mail.smtp.auth</TD>
-<TD>boolean</TD>
-<TD>If true, attempt to authenticate the user using the AUTH command.
-Defaults to false.</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.mechanisms"></A>
-<TR id="mail.smtp.auth.mechanisms">
-<TD>mail.smtp.auth.mechanisms</TD>
-<TD>String</TD>
-<TD>
-If set, lists the authentication mechanisms to consider, and the order
-in which to consider them. Only mechanisms supported by the server and
-supported by the current implementation will be used.
-The default is <code>"LOGIN PLAIN DIGEST-MD5 NTLM"</code>, which includes all
-the authentication mechanisms supported by the current implementation
-except XOAUTH2.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.login.disable"></A>
-<TR id="mail.smtp.auth.login.disable">
-<TD>mail.smtp.auth.login.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTH LOGIN</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.plain.disable"></A>
-<TR id="mail.smtp.auth.plain.disable">
-<TD>mail.smtp.auth.plain.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTH PLAIN</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.digest-md5.disable"></A>
-<TR id="mail.smtp.auth.digest-md5.disable">
-<TD>mail.smtp.auth.digest-md5.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTH DIGEST-MD5</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.ntlm.disable"></A>
-<TR id="mail.smtp.auth.ntlm.disable">
-<TD>mail.smtp.auth.ntlm.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTH NTLM</code> command.
-Default is false.</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.ntlm.domain"></A>
-<TR id="mail.smtp.auth.ntlm.domain">
-<TD>mail.smtp.auth.ntlm.domain</TD>
-<TD>String</TD>
-<TD>
-The NTLM authentication domain.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.ntlm.flags"></A>
-<TR id="mail.smtp.auth.ntlm.flags">
-<TD>mail.smtp.auth.ntlm.flags</TD>
-<TD>int</TD>
-<TD>
-NTLM protocol-specific flags.
-See <A HREF="http://curl.haxx.se/rfc/ntlm.html#theNtlmFlags" TARGET="_top">
-http://curl.haxx.se/rfc/ntlm.html#theNtlmFlags</A> for details.
-</TD>
-</TR>
-
-<!--
-<A NAME="mail.smtp.auth.ntlm.unicode"></A>
-<TR id="mail.smtp.auth.ntlm.unicode">
-<TD>mail.smtp.auth.ntlm.unicode</TD>
-<TD>boolean</TD>
-<TD>
-Set this to "true" if the username or password may use
-Unicode UTF-8 encoded characters. Default is "true".
-Currently has no effect.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.auth.ntlm.lmcompat"></A>
-<TR id="mail.smtp.auth.ntlm.lmcompat">
-<TD>mail.smtp.auth.ntlm.lmcompat</TD>
-<TD>int</TD>
-<TD>
-Sets the LM compatibility level, as described here:
-<A HREF="http://curl.haxx.se/rfc/ntlm.html#ntlmVersion2" TARGET="_top">
-http://curl.haxx.se/rfc/ntlm.html#ntlmVersion2</A>
-Defaults to "3". Currently not used.
-</TD>
-</TR>
--->
-
-<A NAME="mail.smtp.auth.xoauth2.disable"></A>
-<TR id="mail.smtp.auth.xoauth2.disable">
-<TD>mail.smtp.auth.xoauth2.disable</TD>
-<TD>boolean</TD>
-<TD>If true, prevents use of the <code>AUTHENTICATE XOAUTH2</code> command.
-Because the OAuth 2.0 protocol requires a special access token instead of
-a password, this mechanism is disabled by default. Enable it by explicitly
-setting this property to "false" or by setting the "mail.smtp.auth.mechanisms"
-property to "XOAUTH2".</TD>
-</TR>
-
-<A NAME="mail.smtp.submitter"></A>
-<TR id="mail.smtp.submitter">
-<TD>mail.smtp.submitter</TD>
-<TD>String</TD>
-<TD>The submitter to use in the AUTH tag in the MAIL FROM command.
-Typically used by a mail relay to pass along information about the
-original submitter of the message.
-See also the {@link com.sun.mail.smtp.SMTPMessage#setSubmitter setSubmitter}
-method of {@link com.sun.mail.smtp.SMTPMessage SMTPMessage}.
-Mail clients typically do not use this.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.dsn.notify"></A>
-<TR id="mail.smtp.dsn.notify">
-<TD>mail.smtp.dsn.notify</TD>
-<TD>String</TD>
-<TD>The NOTIFY option to the RCPT command. Either NEVER, or some
-combination of SUCCESS, FAILURE, and DELAY (separated by commas).</TD>
-</TR>
-
-<A NAME="mail.smtp.dsn.ret"></A>
-<TR id="mail.smtp.dsn.ret">
-<TD>mail.smtp.dsn.ret</TD>
-<TD>String</TD>
-<TD>The RET option to the MAIL command. Either FULL or HDRS.</TD>
-</TR>
-
-<A NAME="mail.smtp.allow8bitmime"></A>
-<TR id="mail.smtp.allow8bitmime">
-<TD>mail.smtp.allow8bitmime</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, and the server supports the 8BITMIME extension, text
-parts of messages that use the "quoted-printable" or "base64" encodings
-are converted to use "8bit" encoding if they follow the RFC2045 rules
-for 8bit text.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.sendpartial"></A>
-<TR id="mail.smtp.sendpartial">
-<TD>mail.smtp.sendpartial</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, and a message has some valid and some invalid
-addresses, send the message anyway, reporting the partial failure with
-a SendFailedException. If set to false (the default), the message is
-not sent to any of the recipients if there is an invalid recipient
-address.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.sasl.enable"></A>
-<TR id="mail.smtp.sasl.enable">
-<TD>mail.smtp.sasl.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, attempt to use the javax.security.sasl package to
-choose an authentication mechanism for login.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.sasl.mechanisms"></A>
-<TR id="mail.smtp.sasl.mechanisms">
-<TD>mail.smtp.sasl.mechanisms</TD>
-<TD>String</TD>
-<TD>
-A space or comma separated list of SASL mechanism names to try
-to use.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.sasl.authorizationid"></A>
-<TR id="mail.smtp.sasl.authorizationid">
-<TD>mail.smtp.sasl.authorizationid</TD>
-<TD>String</TD>
-<TD>
-The authorization ID to use in the SASL authentication.
-If not set, the authentication ID (user name) is used.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.sasl.realm"></A>
-<TR id="mail.smtp.sasl.realm">
-<TD>mail.smtp.sasl.realm</TD>
-<TD>String</TD>
-<TD>The realm to use with DIGEST-MD5 authentication.</TD>
-</TR>
-
-<A NAME="mail.smtp.sasl.usecanonicalhostname"></A>
-<TR id="mail.smtp.sasl.usecanonicalhostname">
-<TD>mail.smtp.sasl.usecanonicalhostname</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, the canonical host name returned by
-{@link java.net.InetAddress#getCanonicalHostName InetAddress.getCanonicalHostName}
-is passed to the SASL mechanism, instead of the host name used to connect.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.quitwait"></A>
-<TR id="mail.smtp.quitwait">
-<TD>mail.smtp.quitwait</TD>
-<TD>boolean</TD>
-<TD>
-If set to false, the QUIT command is sent
-and the connection is immediately closed.
-If set to true (the default), causes the transport to wait
-for the response to the QUIT command.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.reportsuccess"></A>
-<TR id="mail.smtp.reportsuccess">
-<TD>mail.smtp.reportsuccess</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, causes the transport to include an
-{@link com.sun.mail.smtp.SMTPAddressSucceededException
-SMTPAddressSucceededException}
-for each address that is successful.
-Note also that this will cause a
-{@link javax.mail.SendFailedException SendFailedException}
-to be thrown from the
-{@link com.sun.mail.smtp.SMTPTransport#sendMessage sendMessage}
-method of
-{@link com.sun.mail.smtp.SMTPTransport SMTPTransport}
-even if all addresses were correct and the message was sent
-successfully.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socketFactory"></A>
-<TR id="mail.smtp.socketFactory">
-<TD>mail.smtp.socketFactory</TD>
-<TD>SocketFactory</TD>
-<TD>
-If set to a class that implements the
-<code>javax.net.SocketFactory</code> interface, this class
-will be used to create SMTP sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socketFactory.class"></A>
-<TR id="mail.smtp.socketFactory.class">
-<TD>mail.smtp.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that implements the
-<code>javax.net.SocketFactory</code> interface. This class
-will be used to create SMTP sockets.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socketFactory.fallback"></A>
-<TR id="mail.smtp.socketFactory.fallback">
-<TD>mail.smtp.socketFactory.fallback</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, failure to create a socket using the specified
-socket factory class will cause the socket to be created using
-the <code>java.net.Socket</code> class.
-Defaults to true.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socketFactory.port"></A>
-<TR id="mail.smtp.socketFactory.port">
-<TD>mail.smtp.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.enable"></A>
-<TR id="mail.smtp.ssl.enable">
-<TD>mail.smtp.ssl.enable</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use SSL to connect and use the SSL port by default.
-Defaults to false for the "smtp" protocol and true for the "smtps" protocol.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.checkserveridentity"></A>
-<TR id="mail.smtp.ssl.checkserveridentity">
-<TD>mail.smtp.ssl.checkserveridentity</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, check the server identity as specified by
-<A HREF="http://www.ietf.org/rfc/rfc2595.txt" TARGET="_top">RFC 2595</A>.
-These additional checks based on the content of the server's certificate
-are intended to prevent man-in-the-middle attacks.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.trust"></A>
-<TR id="mail.smtp.ssl.trust">
-<TD>mail.smtp.ssl.trust</TD>
-<TD>String</TD>
-<TD>
-If set, and a socket factory hasn't been specified, enables use of a
-{@link com.sun.mail.util.MailSSLSocketFactory MailSSLSocketFactory}.
-If set to "*", all hosts are trusted.
-If set to a whitespace separated list of hosts, those hosts are trusted.
-Otherwise, trust depends on the certificate the server presents.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.socketFactory"></A>
-<TR id="mail.smtp.ssl.socketFactory">
-<TD>mail.smtp.ssl.socketFactory</TD>
-<TD>SSLSocketFactory</TD>
-<TD>
-If set to a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class, this class
-will be used to create SMTP SSL sockets. Note that this is an
-instance of a class, not a name, and must be set using the
-<code>put</code> method, not the <code>setProperty</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.socketFactory.class"></A>
-<TR id="mail.smtp.ssl.socketFactory.class">
-<TD>mail.smtp.ssl.socketFactory.class</TD>
-<TD>String</TD>
-<TD>
-If set, specifies the name of a class that extends the
-<code>javax.net.ssl.SSLSocketFactory</code> class. This class
-will be used to create SMTP SSL sockets.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.socketFactory.port"></A>
-<TR id="mail.smtp.ssl.socketFactory.port">
-<TD>mail.smtp.ssl.socketFactory.port</TD>
-<TD>int</TD>
-<TD>
-Specifies the port to connect to when using the specified socket
-factory.
-If not set, the default port will be used.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.protocols"></A>
-<TR id="mail.smtp.ssl.protocols">
-<TD>mail.smtp.ssl.protocols</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL protocols that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledProtocols</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.ssl.ciphersuites"></A>
-<TR id="mail.smtp.ssl.ciphersuites">
-<TD>mail.smtp.ssl.ciphersuites</TD>
-<TD>string</TD>
-<TD>
-Specifies the SSL cipher suites that will be enabled for SSL connections.
-The property value is a whitespace separated list of tokens acceptable
-to the <code>javax.net.ssl.SSLSocket.setEnabledCipherSuites</code> method.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.starttls.enable"></A>
-<TR id="mail.smtp.starttls.enable">
-<TD>mail.smtp.starttls.enable</TD>
-<TD>boolean</TD>
-<TD>
-If true, enables the use of the <code>STARTTLS</code> command (if
-supported by the server) to switch the connection to a TLS-protected
-connection before issuing any login commands. Note that an appropriate
-trust store must configured so that the client will trust the server's
-certificate.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.starttls.required"></A>
-<TR id="mail.smtp.starttls.required">
-<TD>mail.smtp.starttls.required</TD>
-<TD>boolean</TD>
-<TD>
-If true, requires the use of the <code>STARTTLS</code> command.
-If the server doesn't support the STARTTLS command, or the command
-fails, the connect method will fail.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socks.host"></A>
-<TR id="mail.smtp.socks.host">
-<TD>mail.smtp.socks.host</TD>
-<TD>string</TD>
-<TD>
-Specifies the host name of a SOCKS5 proxy server that will be used for
-connections to the mail server.
-(Note that this only works on JDK 1.5 or newer.)
-</TD>
-</TR>
-
-<A NAME="mail.smtp.socks.port"></A>
-<TR id="mail.smtp.socks.port">
-<TD>mail.smtp.socks.port</TD>
-<TD>string</TD>
-<TD>
-Specifies the port number for the SOCKS5 proxy server.
-This should only need to be used if the proxy server is not using
-the standard port number of 1080.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.mailextension"></A>
-<TR id="mail.smtp.mailextension">
-<TD>mail.smtp.mailextension</TD>
-<TD>String</TD>
-<TD>
-Extension string to append to the MAIL command.
-The extension string can be used to specify standard SMTP
-service extensions as well as vendor-specific extensions.
-Typically the application should use the
-{@link com.sun.mail.smtp.SMTPTransport SMTPTransport}
-method {@link com.sun.mail.smtp.SMTPTransport#supportsExtension
-supportsExtension}
-to verify that the server supports the desired service extension.
-See <A HREF="http://www.ietf.org/rfc/rfc1869.txt" TARGET="_top">RFC 1869</A>
-and other RFCs that define specific extensions.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.userset"></A>
-<TR id="mail.smtp.userset">
-<TD>mail.smtp.userset</TD>
-<TD>boolean</TD>
-<TD>
-If set to true, use the RSET command instead of the NOOP command
-in the {@link javax.mail.Transport#isConnected isConnected} method.
-In some cases sendmail will respond slowly after many NOOP commands;
-use of RSET avoids this sendmail issue.
-Defaults to false.
-</TD>
-</TR>
-
-<A NAME="mail.smtp.noop.strict"></A>
-<TR id="mail.smtp.noop.strict">
-<TD>mail.smtp.noop.strict</TD>
-<TD>boolean</TD>
-<TD>
-If set to true (the default), insist on a 250 response code from the NOOP
-command to indicate success. The NOOP command is used by the
-{@link javax.mail.Transport#isConnected isConnected} method to determine
-if the connection is still alive.
-Some older servers return the wrong response code on success, some
-servers don't implement the NOOP command at all and so always return
-a failure code. Set this property to false to handle servers
-that are broken in this way.
-Normally, when a server times out a connection, it will send a 421
-response code, which the client will see as the response to the next
-command it issues.
-Some servers send the wrong failure response code when timing out a
-connection.
-Do not set this property to false when dealing with servers that are
-broken in this way.
-</TD>
-</TR>
-
-</TABLE>
-<P>
-In general, applications should not need to use the classes in this
-package directly. Instead, they should use the APIs defined by
-<code>javax.mail</code> package (and subpackages). Applications should
-never construct instances of <code>SMTPTransport</code> directly.
-Instead, they should use the
-<code>Session</code> method <code>getTransport</code> to acquire an
-appropriate <code>Transport</code> object.
-<P>
-In addition to printing debugging output as controlled by the
-{@link javax.mail.Session Session} configuration,
-the com.sun.mail.smtp provider logs the same information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>com.sun.mail.smtp</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the SMTPTransport</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.smtp</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-
-<TR>
-<TD>com.sun.mail.smtp.protocol</TD>
-<TD>FINEST</TD>
-<TD>Complete protocol trace</TD>
-</TR>
-</TABLE>
-
-<P>
-<strong>WARNING:</strong> The APIs unique to this package should be
-considered <strong>EXPERIMENTAL</strong>. They may be changed in the
-future in ways that are incompatible with applications using the
-current APIs.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/com/sun/mail/util/ASCIIUtility.java b/current/src/main/java/com/sun/mail/util/ASCIIUtility.java
index 2fc9690..1c050a9 100644
--- a/current/src/main/java/com/sun/mail/util/ASCIIUtility.java
+++ b/current/src/main/java/com/sun/mail/util/ASCIIUtility.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/BASE64DecoderStream.java b/current/src/main/java/com/sun/mail/util/BASE64DecoderStream.java
index 5a9a162..8a65b6e 100644
--- a/current/src/main/java/com/sun/mail/util/BASE64DecoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/BASE64DecoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -105,6 +105,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
+ @Override
public int read() throws IOException {
if (index >= bufsize) {
bufsize = decode(buffer, 0, buffer.length);
@@ -129,6 +130,7 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public int read(byte[] buf, int off, int len) throws IOException {
// empty out single byte read buffer
int off0 = off;
@@ -170,6 +172,7 @@
/**
* Skips over and discards n bytes of data from this stream.
*/
+ @Override
public long skip(long n) throws IOException {
long skipped = 0;
while (n-- > 0 && read() >= 0)
@@ -181,6 +184,7 @@
* Tests if this input stream supports marks. Currently this class
* does not support marks
*/
+ @Override
public boolean markSupported() {
return false; // Maybe later ..
}
@@ -191,6 +195,7 @@
* a close approximation in case the original encoded stream
* contains embedded CRLFs; since the CRLFs are discarded, not decoded
*/
+ @Override
public int available() throws IOException {
// This is only an estimate, since in.available()
// might include CRLFs too ..
diff --git a/current/src/main/java/com/sun/mail/util/BASE64EncoderStream.java b/current/src/main/java/com/sun/mail/util/BASE64EncoderStream.java
index 00834b6..f17862e 100644
--- a/current/src/main/java/com/sun/mail/util/BASE64EncoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/BASE64EncoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -113,6 +113,7 @@
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized void write(byte[] b, int off, int len)
throws IOException {
int end = off + len;
@@ -161,6 +162,7 @@
* @param b the data to be written.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
@@ -171,6 +173,7 @@
* @param c the <code>byte</code>.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized void write(int c) throws IOException {
buffer[bufsize++] = (byte)c;
if (bufsize == 3) { // Encoding unit = 3 bytes
@@ -185,6 +188,7 @@
*
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized void flush() throws IOException {
if (bufsize > 0) { // If there's unencoded characters in the buffer ..
encode(); // .. encode them
@@ -197,6 +201,7 @@
* Forces any buffered output bytes to be encoded out to the stream
* and closes this output stream
*/
+ @Override
public synchronized void close() throws IOException {
flush();
if (count > 0 && !noCRLF) {
diff --git a/current/src/main/java/com/sun/mail/util/BEncoderStream.java b/current/src/main/java/com/sun/mail/util/BEncoderStream.java
index abab3ba..b6bf565 100644
--- a/current/src/main/java/com/sun/mail/util/BEncoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/BEncoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/CRLFOutputStream.java b/current/src/main/java/com/sun/mail/util/CRLFOutputStream.java
index f685b18..4af3459 100644
--- a/current/src/main/java/com/sun/mail/util/CRLFOutputStream.java
+++ b/current/src/main/java/com/sun/mail/util/CRLFOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -58,6 +58,7 @@
super(os);
}
+ @Override
public void write(int b) throws IOException {
if (b == '\r') {
writeln();
@@ -71,10 +72,12 @@
lastb = b;
}
+ @Override
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
+ @Override
public void write(byte b[], int off, int len) throws IOException {
int start = off;
diff --git a/current/src/main/java/com/sun/mail/util/DecodingException.java b/current/src/main/java/com/sun/mail/util/DecodingException.java
index a42d960..32bbc42 100644
--- a/current/src/main/java/com/sun/mail/util/DecodingException.java
+++ b/current/src/main/java/com/sun/mail/util/DecodingException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/FolderClosedIOException.java b/current/src/main/java/com/sun/mail/util/FolderClosedIOException.java
index 945f74d..e61a694 100644
--- a/current/src/main/java/com/sun/mail/util/FolderClosedIOException.java
+++ b/current/src/main/java/com/sun/mail/util/FolderClosedIOException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/LineInputStream.java b/current/src/main/java/com/sun/mail/util/LineInputStream.java
index 1dec1f3..7cec94d 100644
--- a/current/src/main/java/com/sun/mail/util/LineInputStream.java
+++ b/current/src/main/java/com/sun/mail/util/LineInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -41,6 +41,7 @@
package com.sun.mail.util;
import java.io.*;
+import java.nio.charset.StandardCharsets;
/**
* This class is to support reading CRLF terminated lines that
@@ -53,15 +54,27 @@
* this class around any input stream and read bytes from this filter.
*
* @author John Mani
+ * @author Bill Shannon
*/
public class LineInputStream extends FilterInputStream {
- private char[] lineBuffer = null; // reusable byte buffer
+ private boolean allowutf8;
+ private byte[] lineBuffer = null; // reusable byte buffer
private static int MAX_INCR = 1024*1024; // 1MB
public LineInputStream(InputStream in) {
+ this(in, false);
+ }
+
+ /**
+ * @param in the InputStream
+ * @param allowutf8 allow UTF-8 characters?
+ * @since JavaMail 1.6
+ */
+ public LineInputStream(InputStream in, boolean allowutf8) {
super(in);
+ this.allowutf8 = allowutf8;
}
/**
@@ -78,12 +91,13 @@
* @return the line
* @exception IOException for I/O errors
*/
+ @SuppressWarnings("deprecation") // for old String constructor
public String readLine() throws IOException {
//InputStream in = this.in;
- char[] buf = lineBuffer;
+ byte[] buf = lineBuffer;
if (buf == null)
- buf = lineBuffer = new char[128];
+ buf = lineBuffer = new byte[128];
int c1;
int room = buf.length;
@@ -132,19 +146,22 @@
// .. Insert the byte into our byte buffer
if (--room < 0) { // No room, need to grow.
if (buf.length < MAX_INCR)
- buf = new char[buf.length * 2];
+ buf = new byte[buf.length * 2];
else
- buf = new char[buf.length + MAX_INCR];
+ buf = new byte[buf.length + MAX_INCR];
room = buf.length - offset - 1;
System.arraycopy(lineBuffer, 0, buf, 0, offset);
lineBuffer = buf;
}
- buf[offset++] = (char)c1;
+ buf[offset++] = (byte)c1;
}
if ((c1 == -1) && (offset == 0))
return null;
-
- return String.copyValueOf(buf, 0, offset);
+
+ if (allowutf8)
+ return new String(buf, 0, offset, StandardCharsets.UTF_8);
+ else
+ return new String(buf, 0, 0, offset);
}
}
diff --git a/current/src/main/java/com/sun/mail/util/LineOutputStream.java b/current/src/main/java/com/sun/mail/util/LineOutputStream.java
index 6586f68..2e14792 100644
--- a/current/src/main/java/com/sun/mail/util/LineOutputStream.java
+++ b/current/src/main/java/com/sun/mail/util/LineOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -41,6 +41,7 @@
package com.sun.mail.util;
import java.io.*;
+import java.nio.charset.StandardCharsets;
/**
* This class is to support writing out Strings as a sequence of bytes
@@ -51,9 +52,12 @@
* stream. <p>
*
* @author John Mani
+ * @author Bill Shannon
*/
public class LineOutputStream extends FilterOutputStream {
+ private boolean allowutf8;
+
private static byte[] newline;
static {
@@ -63,11 +67,25 @@
}
public LineOutputStream(OutputStream out) {
+ this(out, false);
+ }
+
+ /**
+ * @param out the OutputStream
+ * @param allowutf8 allow UTF-8 characters?
+ * @since JavaMail 1.6
+ */
+ public LineOutputStream(OutputStream out, boolean allowutf8) {
super(out);
+ this.allowutf8 = allowutf8;
}
public void writeln(String s) throws IOException {
- byte[] bytes = ASCIIUtility.getBytes(s);
+ byte[] bytes;
+ if (allowutf8)
+ bytes = s.getBytes(StandardCharsets.UTF_8);
+ else
+ bytes = ASCIIUtility.getBytes(s);
out.write(bytes);
out.write(newline);
}
diff --git a/current/src/main/java/com/sun/mail/util/LogOutputStream.java b/current/src/main/java/com/sun/mail/util/LogOutputStream.java
index b91e061..7c58484 100644
--- a/current/src/main/java/com/sun/mail/util/LogOutputStream.java
+++ b/current/src/main/java/com/sun/mail/util/LogOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2008-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -65,6 +65,7 @@
this.level = Level.FINEST;
}
+ @Override
public void write(int b) throws IOException {
if (!logger.isLoggable(level))
return;
@@ -81,10 +82,12 @@
lastb = b;
}
+ @Override
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
+ @Override
public void write(byte b[], int off, int len) throws IOException {
int start = off;
diff --git a/current/src/main/java/com/sun/mail/util/MailConnectException.java b/current/src/main/java/com/sun/mail/util/MailConnectException.java
index 4b83293..1c5c96a 100644
--- a/current/src/main/java/com/sun/mail/util/MailConnectException.java
+++ b/current/src/main/java/com/sun/mail/util/MailConnectException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/MailLogger.java b/current/src/main/java/com/sun/mail/util/MailLogger.java
index b68d07f..f7d9fab 100644
--- a/current/src/main/java/com/sun/mail/util/MailLogger.java
+++ b/current/src/main/java/com/sun/mail/util/MailLogger.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -147,6 +147,7 @@
* @param prefix the prefix for debug output, or null for none
* @param session where to get the debug flag and PrintStream
*/
+ @Deprecated
public MailLogger(String name, String prefix, Session session) {
this(name, prefix, session.getDebug(), session.getDebugOut());
}
@@ -161,6 +162,7 @@
* @param prefix the prefix for debug output, or null for none
* @param session where to get the debug flag and PrintStream
*/
+ @Deprecated
public MailLogger(Class<?> clazz, String prefix, Session session) {
this(clazz, prefix, session.getDebug(), session.getDebugOut());
}
@@ -263,7 +265,7 @@
* @param msg the message.
* @param params the message parameters.
*/
- public void log(Level level, String msg, Object params[]) {
+ public void log(Level level, String msg, Object... params) {
if (debug) {
msg = MessageFormat.format(msg, params);
debugOut(msg);
diff --git a/current/src/main/java/com/sun/mail/util/MailSSLSocketFactory.java b/current/src/main/java/com/sun/mail/util/MailSSLSocketFactory.java
index 4691da8..dfb2081 100644
--- a/current/src/main/java/com/sun/mail/util/MailSSLSocketFactory.java
+++ b/current/src/main/java/com/sun/mail/util/MailSSLSocketFactory.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -350,6 +350,7 @@
* @see javax.net.ssl.X509TrustManager#checkClientTrusted(
* java.security.cert.X509Certificate[], java.lang.String)
*/
+ @Override
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
if (!(isTrustAllHosts() || getTrustedHosts() != null))
@@ -360,6 +361,7 @@
* @see javax.net.ssl.X509TrustManager#checkServerTrusted(
* java.security.cert.X509Certificate[], java.lang.String)
*/
+ @Override
public void checkServerTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
@@ -370,6 +372,7 @@
/* (non-Javadoc)
* @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
*/
+ @Override
public X509Certificate[] getAcceptedIssuers() {
return adapteeTrustManager.getAcceptedIssuers();
}
diff --git a/current/src/main/java/com/sun/mail/util/MessageRemovedIOException.java b/current/src/main/java/com/sun/mail/util/MessageRemovedIOException.java
index c4e6519..a4e9e81 100644
--- a/current/src/main/java/com/sun/mail/util/MessageRemovedIOException.java
+++ b/current/src/main/java/com/sun/mail/util/MessageRemovedIOException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/MimeUtil.java b/current/src/main/java/com/sun/mail/util/MimeUtil.java
index ca45db1..3f0d2d2 100644
--- a/current/src/main/java/com/sun/mail/util/MimeUtil.java
+++ b/current/src/main/java/com/sun/mail/util/MimeUtil.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -115,6 +115,7 @@
private static ClassLoader getContextClassLoader() {
return
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ @Override
public ClassLoader run() {
ClassLoader cl = null;
try {
diff --git a/current/src/main/java/com/sun/mail/util/PropUtil.java b/current/src/main/java/com/sun/mail/util/PropUtil.java
index d92d405..87ce85a 100644
--- a/current/src/main/java/com/sun/mail/util/PropUtil.java
+++ b/current/src/main/java/com/sun/mail/util/PropUtil.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -88,6 +88,7 @@
* @param def default value if property not found
* @return the property value
*/
+ @Deprecated
public static int getIntSessionProperty(Session session,
String name, int def) {
return getInt(getProp(session.getProperties(), name), def);
@@ -101,6 +102,7 @@
* @param def default value if property not found
* @return the property value
*/
+ @Deprecated
public static boolean getBooleanSessionProperty(Session session,
String name, boolean def) {
return getBoolean(getProp(session.getProperties(), name), def);
diff --git a/current/src/main/java/com/sun/mail/util/QDecoderStream.java b/current/src/main/java/com/sun/mail/util/QDecoderStream.java
index a0654d9..6ea8a0f 100644
--- a/current/src/main/java/com/sun/mail/util/QDecoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/QDecoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -71,6 +71,7 @@
* stream is reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public int read() throws IOException {
int c = in.read();
diff --git a/current/src/main/java/com/sun/mail/util/QEncoderStream.java b/current/src/main/java/com/sun/mail/util/QEncoderStream.java
index b118f7e..cb9d31d 100644
--- a/current/src/main/java/com/sun/mail/util/QEncoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/QEncoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -77,6 +77,7 @@
* @param c the <code>byte</code>.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(int c) throws IOException {
c = c & 0xff; // Turn off the MSB.
if (c == ' ')
diff --git a/current/src/main/java/com/sun/mail/util/QPDecoderStream.java b/current/src/main/java/com/sun/mail/util/QPDecoderStream.java
index 8760cd6..20cd140 100644
--- a/current/src/main/java/com/sun/mail/util/QPDecoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/QPDecoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -76,6 +76,7 @@
* stream is reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public int read() throws IOException {
if (spaces > 0) {
// We have cached space characters, return one
@@ -159,6 +160,7 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public int read(byte[] buf, int off, int len) throws IOException {
int i, c;
for (i = 0; i < len; i++) {
@@ -175,6 +177,7 @@
/**
* Skips over and discards n bytes of data from this stream.
*/
+ @Override
public long skip(long n) throws IOException {
long skipped = 0;
while (n-- > 0 && read() >= 0)
@@ -186,6 +189,7 @@
* Tests if this input stream supports marks. Currently this class
* does not support marks
*/
+ @Override
public boolean markSupported() {
return false;
}
@@ -197,6 +201,7 @@
* this method just invokes the <code>available</code> method
* of the original input stream.
*/
+ @Override
public int available() throws IOException {
// This is bogus ! We don't really know how much
// bytes are available *after* decoding
diff --git a/current/src/main/java/com/sun/mail/util/QPEncoderStream.java b/current/src/main/java/com/sun/mail/util/QPEncoderStream.java
index 7c62606..b518658 100644
--- a/current/src/main/java/com/sun/mail/util/QPEncoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/QPEncoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -90,6 +90,7 @@
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; i++)
write(b[off + i]);
@@ -100,6 +101,7 @@
* @param b the data to be written.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(byte[] b) throws IOException {
write(b, 0, b.length);
}
@@ -109,6 +111,7 @@
* @param c the <code>byte</code>.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(int c) throws IOException {
c = c & 0xff; // Turn off the MSB.
if (gotSpace) { // previous character was <SPACE>
@@ -148,6 +151,7 @@
* to be encoded out to the stream.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void flush() throws IOException {
if (gotSpace) {
output(' ', true);
@@ -162,6 +166,7 @@
*
* @exception IOException for I/O errors
*/
+ @Override
public void close() throws IOException {
flush();
out.close();
diff --git a/current/src/main/java/com/sun/mail/util/ReadableMime.java b/current/src/main/java/com/sun/mail/util/ReadableMime.java
index 2b09787..d8a4c06 100644
--- a/current/src/main/java/com/sun/mail/util/ReadableMime.java
+++ b/current/src/main/java/com/sun/mail/util/ReadableMime.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/SharedByteArrayOutputStream.java b/current/src/main/java/com/sun/mail/util/SharedByteArrayOutputStream.java
index 521b126..4bb9fd3 100644
--- a/current/src/main/java/com/sun/mail/util/SharedByteArrayOutputStream.java
+++ b/current/src/main/java/com/sun/mail/util/SharedByteArrayOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/SocketConnectException.java b/current/src/main/java/com/sun/mail/util/SocketConnectException.java
index 7540ca4..a55c1ed 100644
--- a/current/src/main/java/com/sun/mail/util/SocketConnectException.java
+++ b/current/src/main/java/com/sun/mail/util/SocketConnectException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/com/sun/mail/util/SocketFetcher.java b/current/src/main/java/com/sun/mail/util/SocketFetcher.java
index 41958a1..1693cc5 100644
--- a/current/src/main/java/com/sun/mail/util/SocketFetcher.java
+++ b/current/src/main/java/com/sun/mail/util/SocketFetcher.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,6 +44,7 @@
import java.net.*;
import java.io.*;
import java.nio.channels.SocketChannel;
+import java.nio.charset.StandardCharsets;
import java.lang.reflect.*;
import java.util.*;
import java.util.regex.*;
@@ -51,7 +52,6 @@
import java.security.cert.*;
import javax.net.*;
import javax.net.ssl.*;
-import javax.security.auth.x500.X500Principal;
/**
* This class is used to get Sockets. Depending on the arguments passed
@@ -274,19 +274,44 @@
", host " + host + ", port " + port +
", connection timeout " + cto + ", timeout " + to +
", socket factory " + sf + ", useSSL " + useSSL);
-
- String socksHost = props.getProperty(prefix + ".socks.host", null);
+
+ String proxyHost = props.getProperty(prefix + ".proxy.host", null);
+ String proxyUser = props.getProperty(prefix + ".proxy.user", null);
+ String proxyPassword = props.getProperty(prefix + ".proxy.password", null);
+ int proxyPort = 80;
+ String socksHost = null;
int socksPort = 1080;
String err = null;
- if (socksHost != null) {
+
+ if (proxyHost != null) {
+ int i = proxyHost.indexOf(':');
+ if (i >= 0) {
+ try {
+ proxyPort = Integer.parseInt(proxyHost.substring(i + 1));
+ } catch (NumberFormatException ex) {
+ // ignore it
+ }
+ proxyHost = proxyHost.substring(0, i);
+ }
+ proxyPort = PropUtil.getIntProperty(props,
+ prefix + ".proxy.port", proxyPort);
+ err = "Using web proxy host, port: " + proxyHost + ", " + proxyPort;
+ if (logger.isLoggable(Level.FINER)) {
+ logger.finer("web proxy host " + proxyHost + ", port " + proxyPort);
+ if (proxyUser != null)
+ logger.finer("web proxy user " + proxyUser + ", password " +
+ (proxyPassword == null ? "<null>" : "<non-null>"));
+ }
+ } else if ((socksHost =
+ props.getProperty(prefix + ".socks.host", null)) != null) {
int i = socksHost.indexOf(':');
if (i >= 0) {
- socksHost = socksHost.substring(0, i);
try {
socksPort = Integer.parseInt(socksHost.substring(i + 1));
} catch (NumberFormatException ex) {
// ignore it
}
+ socksHost = socksHost.substring(0, i);
}
socksPort = PropUtil.getIntProperty(props,
prefix + ".socks.port", socksPort);
@@ -325,7 +350,10 @@
socket.bind(new InetSocketAddress(localaddr, localport));
try {
logger.finest("connecting...");
- if (cto >= 0)
+ if (proxyHost != null)
+ proxyConnect(socket, proxyHost, proxyPort,
+ proxyUser, proxyPassword, host, port, cto);
+ else if (cto >= 0)
socket.connect(new InetSocketAddress(host, port), cto);
else
socket.connect(new InetSocketAddress(host, port));
@@ -385,7 +413,7 @@
if (sfClass == null || sfClass.length() == 0)
return null;
- // dynamically load the class
+ // dynamically load the class
ClassLoader cl = getContextClassLoader();
Class<?> clsSockFact = null;
@@ -397,7 +425,7 @@
if (clsSockFact == null)
clsSockFact = Class.forName(sfClass);
// get & invoke the getDefault() method
- Method mthGetDefault = clsSockFact.getMethod("getDefault",
+ Method mthGetDefault = clsSockFact.getMethod("getDefault",
new Class<?>[]{});
SocketFactory sf = (SocketFactory)
mthGetDefault.invoke(new Object(), new Object[]{});
@@ -572,7 +600,7 @@
if (logger.isLoggable(Level.FINER))
logger.finer("SSL enabled protocols before " +
Arrays.asList(prots));
- List<String> eprots = new ArrayList<String>();
+ List<String> eprots = new ArrayList<>();
for (int i = 0; i < prots.length; i++) {
if (prots[i] != null && !prots[i].startsWith("SSL"))
eprots.add(prots[i]);
@@ -607,19 +635,40 @@
if (sf instanceof MailSSLSocketFactory) {
MailSSLSocketFactory msf = (MailSSLSocketFactory)sf;
if (!msf.isServerTrusted(host, sslsocket)) {
- try {
- sslsocket.close();
- } finally {
- throw new IOException("Server is not trusted: " + host);
- }
+ throw cleanupAndThrow(sslsocket,
+ new IOException("Server is not trusted: " + host));
}
}
}
+ private static IOException cleanupAndThrow(Socket socket, IOException ife) {
+ try {
+ socket.close();
+ } catch (Throwable thr) {
+ if (isRecoverable(thr)) {
+ ife.addSuppressed(thr);
+ } else {
+ thr.addSuppressed(ife);
+ if (thr instanceof Error) {
+ throw (Error) thr;
+ }
+ if (thr instanceof RuntimeException) {
+ throw (RuntimeException) thr;
+ }
+ throw new RuntimeException("unexpected exception", thr);
+ }
+ }
+ return ife;
+ }
+
+ private static boolean isRecoverable(Throwable t) {
+ return (t instanceof Exception) || (t instanceof LinkageError);
+ }
+
/**
* Check the server from the Socket connection against the server name(s)
* as expressed in the server certificate (RFC 2595 check).
- *
+ *
* @param server name of the server expected
* @param sslSocket SSLSocket connected to the server
* @exception IOException if we can't verify identity of server
@@ -650,7 +699,7 @@
/**
* Do any of the names in the cert match the server name?
- *
+ *
* @param server name of the server expected
* @param cert X509Certificate to get the subject's name from
* @return true if it matches
@@ -671,7 +720,7 @@
// invoke HostnameChecker.getInstance(HostnameChecker.TYPE_LDAP)
// HostnameChecker.TYPE_LDAP == 2
// LDAP requires the same regex handling as we need
- Method getInstance = hnc.getMethod("getInstance",
+ Method getInstance = hnc.getMethod("getInstance",
new Class<?>[] { byte.class });
Object hostnameChecker = getInstance.invoke(new Object(),
new Object[] { Byte.valueOf((byte)2) });
@@ -761,12 +810,89 @@
}
/**
+ * Use the HTTP CONNECT protocol to connect to a
+ * site through an HTTP proxy server. <p>
+ *
+ * Protocol is roughly:
+ * <pre>
+ * CONNECT <host>:<port> HTTP/1.1
+ * Host: <host>:<port>
+ * <blank line>
+ *
+ * HTTP/1.1 200 Connect established
+ * <headers>
+ * <blank line>
+ * </pre>
+ */
+ private static void proxyConnect(Socket socket,
+ String proxyHost, int proxyPort,
+ String proxyUser, String proxyPassword,
+ String host, int port, int cto)
+ throws IOException {
+ if (logger.isLoggable(Level.FINE))
+ logger.fine("connecting through proxy " +
+ proxyHost + ":" + proxyPort + " to " +
+ host + ":" + port);
+ if (cto >= 0)
+ socket.connect(new InetSocketAddress(proxyHost, proxyPort), cto);
+ else
+ socket.connect(new InetSocketAddress(proxyHost, proxyPort));
+ PrintStream os = new PrintStream(socket.getOutputStream(), false,
+ StandardCharsets.UTF_8.name());
+ StringBuilder requestBuilder = new StringBuilder();
+ requestBuilder.append("CONNECT ").append(host).append(":").append(port).
+ append(" HTTP/1.1\r\n");
+ requestBuilder.append("Host: ").append(host).append(":").append(port).
+ append("\r\n");
+ if (proxyUser != null && proxyPassword != null) {
+ byte[] upbytes = (proxyUser + ':' + proxyPassword).
+ getBytes(StandardCharsets.UTF_8);
+ String proxyHeaderValue = new String(
+ BASE64EncoderStream.encode(upbytes),
+ StandardCharsets.US_ASCII);
+ requestBuilder.append("Proxy-Authorization: Basic ").
+ append(proxyHeaderValue).append("\r\n");
+ }
+ requestBuilder.append("Proxy-Connection: keep-alive\r\n\r\n");
+ os.print(requestBuilder.toString());
+ os.flush();
+ BufferedReader r = new BufferedReader(new InputStreamReader(
+ socket.getInputStream(), StandardCharsets.UTF_8));
+ String line;
+ boolean first = true;
+ while ((line = r.readLine()) != null) {
+ if (line.length() == 0)
+ break;
+ logger.finest(line);
+ if (first) {
+ StringTokenizer st = new StringTokenizer(line);
+ String http = st.nextToken();
+ String code = st.nextToken();
+ if (!code.equals("200")) {
+ try {
+ socket.close();
+ } catch (IOException ioex) {
+ // ignored
+ }
+ ConnectException ex = new ConnectException(
+ "connection through proxy " +
+ proxyHost + ":" + proxyPort + " to " +
+ host + ":" + port + " failed: " + line);
+ logger.log(Level.FINE, "connect failed", ex);
+ throw ex;
+ }
+ first = false;
+ }
+ }
+ }
+
+ /**
* Parse a string into whitespace separated tokens
* and return the tokens in an array.
*/
private static String[] stringArray(String s) {
StringTokenizer st = new StringTokenizer(s);
- List<String> tokens = new ArrayList<String>();
+ List<String> tokens = new ArrayList<>();
while (st.hasMoreTokens())
tokens.add(st.nextToken());
return tokens.toArray(new String[tokens.size()]);
@@ -780,6 +906,7 @@
private static ClassLoader getContextClassLoader() {
return
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ @Override
public ClassLoader run() {
ClassLoader cl = null;
try {
diff --git a/current/src/main/java/com/sun/mail/util/TraceInputStream.java b/current/src/main/java/com/sun/mail/util/TraceInputStream.java
index 27c6754..576b801 100644
--- a/current/src/main/java/com/sun/mail/util/TraceInputStream.java
+++ b/current/src/main/java/com/sun/mail/util/TraceInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -103,6 +103,7 @@
* <code>-1</code> if no data is available. Writes out the read
* byte into the trace stream, if trace mode is <code>true</code>
*/
+ @Override
public int read() throws IOException {
int b = in.read();
if (trace && b != -1) {
@@ -120,6 +121,7 @@
* is available. Writes out the read bytes into the trace stream, if
* trace mode is <code>true</code>
*/
+ @Override
public int read(byte b[], int off, int len) throws IOException {
int count = in.read(b, off, len);
if (trace && count != -1) {
diff --git a/current/src/main/java/com/sun/mail/util/TraceOutputStream.java b/current/src/main/java/com/sun/mail/util/TraceOutputStream.java
index 1c0c3c7..95595d4 100644
--- a/current/src/main/java/com/sun/mail/util/TraceOutputStream.java
+++ b/current/src/main/java/com/sun/mail/util/TraceOutputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -107,6 +107,7 @@
* @param b the byte to write
* @exception IOException for I/O errors
*/
+ @Override
public void write(int b) throws IOException {
if (trace) {
if (quote)
@@ -127,6 +128,7 @@
* @param len number of bytes to write
* @exception IOException for I/O errors
*/
+ @Override
public void write(byte b[], int off, int len) throws IOException {
if (trace) {
if (quote) {
diff --git a/current/src/main/java/com/sun/mail/util/UUDecoderStream.java b/current/src/main/java/com/sun/mail/util/UUDecoderStream.java
index 0f25ab6..8717ae9 100644
--- a/current/src/main/java/com/sun/mail/util/UUDecoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/UUDecoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -114,6 +114,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
+ @Override
public int read() throws IOException {
if (index >= bufsize) {
readPrefix();
@@ -124,6 +125,7 @@
return buffer[index++] & 0xff; // return lower byte
}
+ @Override
public int read(byte[] buf, int off, int len) throws IOException {
int i, c;
for (i = 0; i < len; i++) {
@@ -137,10 +139,12 @@
return i;
}
+ @Override
public boolean markSupported() {
return false;
}
+ @Override
public int available() throws IOException {
// This is only an estimate, since in.available()
// might include CRLFs too ..
diff --git a/current/src/main/java/com/sun/mail/util/UUEncoderStream.java b/current/src/main/java/com/sun/mail/util/UUEncoderStream.java
index 2faa852..76e5d0c 100644
--- a/current/src/main/java/com/sun/mail/util/UUEncoderStream.java
+++ b/current/src/main/java/com/sun/mail/util/UUEncoderStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -103,15 +103,18 @@
this.mode = mode;
}
+ @Override
public void write(byte[] b, int off, int len) throws IOException {
for (int i = 0; i < len; i++)
write(b[off + i]);
}
+ @Override
public void write(byte[] data) throws IOException {
write(data, 0, data.length);
}
+ @Override
public void write(int c) throws IOException {
/* buffer up characters till we get a line's worth, then encode
* and write them out. Max number of characters allowed per
@@ -125,6 +128,7 @@
}
}
+ @Override
public void flush() throws IOException {
if (bufsize > 0) { // If there's unencoded characters in the buffer
writePrefix();
@@ -135,6 +139,7 @@
out.flush();
}
+ @Override
public void close() throws IOException {
flush();
out.close();
diff --git a/current/src/main/java/com/sun/mail/util/WriteTimeoutSocket.java b/current/src/main/java/com/sun/mail/util/WriteTimeoutSocket.java
index a2953d7..01884f1 100644
--- a/current/src/main/java/com/sun/mail/util/WriteTimeoutSocket.java
+++ b/current/src/main/java/com/sun/mail/util/WriteTimeoutSocket.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2013-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -43,6 +43,8 @@
import java.io.*;
import java.net.*;
import java.util.concurrent.*;
+import java.util.Collections;
+import java.util.Set;
import java.nio.channels.SocketChannel;
import java.lang.reflect.*;
@@ -314,8 +316,34 @@
return socket.isOutputShutdown();
}
+ /*
+ * The following three methods were added to java.net.Socket in Java SE 9.
+ * Since they're not supported on Android, and since we know that we
+ * never use them in JavaMail, we just stub them out here.
+ */
+ //@Override
+ public <T> Socket setOption(SocketOption<T> so, T val) throws IOException {
+ // socket.setOption(so, val);
+ // return this;
+ throw new UnsupportedOperationException("WriteTimeoutSocket.setOption");
+ }
+
+ //@Override
+ public <T> T getOption(SocketOption<T> so) throws IOException {
+ // return socket.getOption(so);
+ throw new UnsupportedOperationException("WriteTimeoutSocket.getOption");
+ }
+
+ //@Override
+ public Set<SocketOption<?>> supportedOptions() {
+ // return socket.supportedOptions();
+ return Collections.emptySet();
+ }
+
/**
* KLUDGE for Android, which has this illegal non-Java Compatible method.
+ *
+ * @return the FileDescriptor object
*/
public FileDescriptor getFileDescriptor$() {
try {
@@ -346,6 +374,7 @@
this.ses = ses;
this.timeout = timeout;
timeoutTask = new Callable<Object>() {
+ @Override
public Object call() throws Exception {
os.close(); // close the stream to abort the write
return null;
diff --git a/current/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java b/current/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
index b7c8f74..ee8591c 100644
--- a/current/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
+++ b/current/src/main/java/com/sun/mail/util/logging/CollectorFormatter.java
@@ -1,625 +1,625 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2013-2015 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013-2015 Jason Mehrens. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package com.sun.mail.util.logging;
-
-import static com.sun.mail.util.logging.LogManagerProperties.fromLogManager;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-/**
- * A LogRecord formatter that takes a sequence of LogRecords and combines them
- * into a single summary result. Formating of the head, LogRecord, and tail are
- * delegated to the wrapped formatter.
- *
- * <p>
- * By default each <tt>CollectorFormatter</tt> is initialized using the
- * following LogManager configuration properties where
- * <tt><formatter-name></tt> refers to the fully qualified class name or
- * the fully qualified derived class name of the formatter. If properties are
- * not defined, or contain invalid values, then the specified default values are
- * used.
- * <ul>
- * <li><formatter-name>.comparator name of a
- * {@linkplain java.util.Comparator} class used to choose the collected
- * <tt>LogRecord</tt>. If a comparator is specified then the max
- * <tt>LogRecord</tt> is chosen. If comparator is set to the string literal
- * null, then the last record is chosen. (defaults to
- * {@linkplain SeverityComparator})
- *
- * <li><formatter-name>.comparator.reverse a boolean
- * <tt>true</tt> to collect the min <tt>LogRecord</tt> or <tt>false</tt> to
- * collect the max <tt>LogRecord</tt>. (defaults to <tt>false</tt>)
- *
- * <li><formatter-name>.format the
- * {@linkplain java.text.MessageFormat MessageFormat} string used to format the
- * collected summary statistics. The arguments are explained in detail in the
- * {@linkplain #getTail(java.util.logging.Handler) getTail} documentation.
- * (defaults to <tt>{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer}
- * more}\n</tt>)
- *
- * <li><formatter-name>.formatter name of a <tt>Formatter</tt> class used
- * to format the collected LogRecord. (defaults to {@linkplain CompactFormatter})
- *
- * </ul>
- *
- * @author Jason Mehrens
- * @since JavaMail 1.5.2
- */
-public class CollectorFormatter extends Formatter {
- /**
- * Avoid depending on JMX runtime bean to get the start time.
- */
- private static final long INIT_TIME = System.currentTimeMillis();
- /**
- * The message format string used as the formatted output.
- */
- private final String fmt;
- /**
- * The formatter used to format the chosen log record.
- */
- private final Formatter formatter;
- /**
- * The comparator used to pick the log record to format.
- */
- private final Comparator<? super LogRecord> comparator;
- /**
- * The last accepted record. Synchronized access is preferred over volatile
- * for this class.
- */
- private LogRecord last;
- /**
- * The number of log records that have been formatted.
- */
- private long count;
- /**
- * The number of log produced containing at least one log record.
- * Only incremented when this formatter is reset.
- */
- private long generation = 1L;
- /**
- * The number of log records that have been formatted with a thrown object.
- */
- private long thrown;
- /**
- * The eldest log record time or eldest time possible for this instance.
- */
- private long minMillis = INIT_TIME;
- /**
- * The newest log record time.
- */
- private long maxMillis = Long.MIN_VALUE;
-
- /**
- * Creates the formatter using the LogManager defaults.
- *
- * @throws SecurityException if a security manager exists and the caller
- * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems loading from
- * the LogManager.
- */
- public CollectorFormatter() {
- final String p = getClass().getName();
- this.fmt = initFormat(p);
- this.formatter = initFormatter(p);
- this.comparator = initComparator(p);
- }
-
- /**
- * Creates the formatter using the given format.
- *
- * @param format the message format or null to use the LogManager default.
- * @throws SecurityException if a security manager exists and the caller
- * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems loading from
- * the LogManager.
- */
- public CollectorFormatter(String format) {
- final String p = getClass().getName();
- this.fmt = format == null ? initFormat(p) : format;
- this.formatter = initFormatter(p);
- this.comparator = initComparator(p);
- }
-
- /**
- * Creates the formatter using the given values.
- *
- * @param format the format string or null to use the LogManager default.
- * @param f the formatter used on the collected log record or null to
- * specify no formatter.
- * @param c the comparator used to determine which log record to format or
- * null to specify no comparator.
- * @throws SecurityException if a security manager exists and the caller
- * does not have <tt>LoggingPermission("control")</tt>.
- * @throws UndeclaredThrowableException if there are problems loading from
- * the LogManager.
- */
- public CollectorFormatter(String format, Formatter f,
- Comparator<? super LogRecord> c) {
- final String p = getClass().getName();
- this.fmt = format == null ? initFormat(p) : format;
- this.formatter = f;
- this.comparator = c;
- }
-
- /**
- * Accumulates log records which will be used to produce the final output.
- * The output is generated using the {@link #getTail} method which also
- * resets this formatter back to its original state.
- *
- * @param record the record to store.
- * @return an empty string.
- * @throws NullPointerException if the given record is null.
- */
- @Override
- public String format(final LogRecord record) {
- if (record == null) {
- throw new NullPointerException();
- }
-
- boolean accepted;
- do {
- final LogRecord peek = peek();
- //The self compare of the first record acts like a type check.
- LogRecord update = apply(peek != null ? peek : record, record);
- if (peek != update) { //Not identical.
- update.getSourceMethodName(); //Infer caller, null check.
- accepted = acceptAndUpdate(peek, update);
- } else {
- accepted = accept(peek, record);
- }
- } while (!accepted);
- return "";
- }
-
- /**
- * Formats the collected LogRecord and summary statistics. The collected
- * results are reset after calling this method. The
- * {@linkplain java.text.MessageFormat java.text} argument indexes are assigned
- * to the following properties:
- *
- * <ol start='0'>
- * <li>{@code head} the
- * {@linkplain Formatter#getHead(java.util.logging.Handler) head} string
- * returned from the target formatter and
- * {@linkplain #finish(java.lang.String) finished} by this formatter.
- * <li>{@code formatted} the current log record
- * {@linkplain Formatter#format(java.util.logging.LogRecord) formatted} by
- * the target formatter and {@linkplain #finish(java.lang.String) finished}
- * by this formatter. If the formatter is null then record is formatted by
- * this {@linkplain #formatMessage(java.util.logging.LogRecord) formatter}.
- * <li>{@code tail} the
- * {@linkplain Formatter#getTail(java.util.logging.Handler) tail} string
- * returned from the target formatter and
- * {@linkplain #finish(java.lang.String) finished} by this formatter.
- * <li>{@code count} the total number of log records
- * {@linkplain #format consumed} by this formatter.
- * <li>{@code remaining} the count minus one.
- * <li>{@code thrown} the total number of log records
- * {@linkplain #format consumed} by this formatter with an assigned
- * {@linkplain java.util.logging.LogRecord#getThrown throwable}.
- * <li>{@code normal messages} the count minus the thrown.
- * <li>{@code minMillis} the eldest log record
- * {@linkplain java.util.logging.LogRecord#getMillis event time}
- * {@linkplain #format consumed} by this formatter. If the count is zero
- * then this is set to the previous max or approximate start time if there
- * was no previous max. By default this parameter is defined as a number.
- * The format type and format style rules from the
- * {@linkplain java.text.MessageFormat} should be used to convert this from
- * milliseconds to a date or time.
- * <li>{@code maxMillis} the most recent log record
- * {@linkplain java.util.logging.LogRecord#getMillis event time}
- * {@linkplain #format consumed} by this formatter. If the count is zero
- * then this is set to the {@linkplain System#currentTimeMillis() current time}.
- * By default this parameter is defined as a number. The format type and
- * format style rules from the {@linkplain java.text.MessageFormat} should be
- * used to convert this from milliseconds to a date or time.
- * <li>{@code elapsed} the elapsed time in milliseconds between the
- * {@code maxMillis} and {@code minMillis}.
- * <li>{@code startTime} the approximate start time in milliseconds. By
- * default this parameter is defined as a number. The format type and format
- * style rules from the {@linkplain java.text.MessageFormat} should be used to
- * convert this from milliseconds to a date or time.
- * <li>{@code currentTime} the
- * {@linkplain System#currentTimeMillis() current time} in milliseconds. By
- * default this parameter is defined as a number. The format type and format
- * style rules from the {@linkplain java.text.MessageFormat} should be used to
- * convert this from milliseconds to a date or time.
- * <li>{@code uptime} the elapsed time in milliseconds between the
- * {@code currentTime} and {@code startTime}.
- * <li>{@code generation} the number times this method produced output with
- * at least one {@linkplain #format consumed} log record. This can be used
- * to track the number of complete reports this formatter has produced.
- * </ol>
- *
- * <p>
- * Some example formats:<br>
- * <ul>
- * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format={0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}\n}
- * <p>
- * This prints the head ({@code {0}}), format ({@code {1}}), and tail
- * ({@code {2}}) from the target formatter followed by the number of
- * remaining ({@code {4}}) log records consumed by this formatter if there
- * are any remaining records.
- * <pre>
- * Encoding failed.|NullPointerException: null String.getBytes(:913)... 3 more
- * </pre>
- * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format=These {3} messages occurred between\n{7,date,EEE, MMM dd HH:mm:ss:S ZZZ yyyy} and {8,time,EEE, MMM dd HH:mm:ss:S ZZZ yyyy}\n}
- * <p>
- * This prints the count ({@code {3}}) followed by the date and time of the
- * eldest log record ({@code {7}}) and the date and time of the most recent
- * log record ({@code {8}}).
- * <pre>
- * These 292 messages occurred between
- * Tue, Jul 21 14:11:42:449 -0500 2009 and Fri, Nov 20 07:29:24:0 -0600 2009
- * </pre>
- * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format=These {3} messages occurred between {9,choice,86400000#{7,date} {7,time} and {8,time}|86400000<{7,date} and {8,date}}\n}
- * <p>
- * This prints the count ({@code {3}}) and then chooses the format based on
- * the elapsed time ({@code {9}}). If the elapsed time is less than one day
- * then the eldest log record ({@code {7}}) date and time is formatted
- * followed by just the time of the most recent log record ({@code {8}}.
- * Otherwise, the just the date of the eldest log record ({@code {7}}) and
- * just the date of most recent log record ({@code {8}} is formatted.
- * <pre>
- * These 73 messages occurred between Jul 21, 2009 2:11:42 PM and 2:13:32 PM
- *
- * These 116 messages occurred between Jul 21, 2009 and Aug 20, 2009
- * </pre>
- * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format={13} alert reports since {10,date}.\n}
- * <p>
- * This prints the generation ({@code {13}}) followed by the start time
- * ({@code {10}}) formatted as a date.
- * <pre>
- * 4,320 alert reports since Jul 21, 2012.
- * </pre>
- * </ul>
- *
- * @param h the handler or null.
- * @return the output string.
- */
- @Override
- public String getTail(final Handler h) {
- super.getTail(h); //Be forward compatible with super.getHead.
- return formatRecord(h, true);
- }
-
- /**
- * Formats the collected LogRecord and summary statistics. The LogRecord and
- * summary statistics are not changed by calling this method.
- *
- * @return the current record formatted or the default toString.
- * @see #getTail(java.util.logging.Handler)
- */
- @Override
- public String toString() {
- String result;
- try {
- result = formatRecord((Handler) null, false);
- } catch (final RuntimeException ignore) {
- result = super.toString();
- }
- return result;
- }
-
- /**
- * Used to choose the collected LogRecord. This implementation returns the
- * greater of two LogRecords.
- *
- * @param t the current record.
- * @param u the record that could replace the current.
- * @return the greater of the given log records.
- * @throws NullPointerException may occur if either record is null.
- */
- protected LogRecord apply(final LogRecord t, final LogRecord u) {
- if (t == null || u == null) {
- throw new NullPointerException();
- }
-
- if (comparator != null) {
- return comparator.compare(t, u) >= 0 ? t : u;
- } else {
- return u;
- }
- }
-
- /**
- * Updates the summary statistics only if the expected record matches the
- * last record. The update record is not stored.
- *
- * @param e the LogRecord that is expected.
- * @param u the LogRecord used to collect statistics.
- * @return true if the last record was the expected record.
- * @throws NullPointerException if the update record is null.
- */
- private synchronized boolean accept(final LogRecord e, final LogRecord u) {
- /**
- * LogRecord methods must be called before the check of the last stored
- * record to guard against subclasses of LogRecord that might attempt to
- * reset the state by triggering a call to getTail.
- */
- final long millis = u.getMillis(); //Null check.
- final Throwable ex = u.getThrown();
- if (last == e) { //Only if the exact same reference.
- if (++count != 1L) {
- minMillis = Math.min(minMillis, millis);
- } else { //Show single records as instant and not a time period.
- minMillis = millis;
- }
- maxMillis = Math.max(maxMillis, millis);
-
- if (ex != null) {
- ++thrown;
- }
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Resets all of the collected summary statistics including the LogRecord.
- * @param min the current min milliseconds.
- */
- private synchronized void reset(final long min) {
- if (last != null) {
- last = null;
- ++generation;
- }
-
- count = 0L;
- thrown = 0L;
- minMillis = min;
- maxMillis = Long.MIN_VALUE;
- }
-
- /**
- * Formats the given record with the head and tail.
- *
- * @param h the Handler or null.
- * @param reset true if the summary statistics and LogRecord should be reset
- * back to initial values.
- * @return the formatted string.
- * @see #getTail(java.util.logging.Handler)
- */
- private String formatRecord(final Handler h, final boolean reset) {
- final LogRecord record;
- final long c;
- final long t;
- final long g;
- long msl;
- long msh;
- long now;
- synchronized (this) {
- record = last;
- c = count;
- g = generation;
- t = thrown;
- msl = minMillis;
- msh = maxMillis;
- now = System.currentTimeMillis();
- if (c == 0L) {
- msh = now;
- }
-
- if (reset) { //BUG ID 6351685
- reset(msh);
- }
- }
-
- final String head;
- final String msg;
- final String tail;
- final Formatter f = this.formatter;
- if (f != null) {
- synchronized (f) {
- head = f.getHead(h);
- msg = record != null ? f.format(record) : "";
- tail = f.getTail(h);
- }
- } else {
- head = "";
- msg = record != null ? formatMessage(record) : "";
- tail = "";
- }
-
- Locale l = null;
- if (record != null) {
- ResourceBundle rb = record.getResourceBundle();
- l = rb == null ? null : rb.getLocale();
- }
-
- final MessageFormat mf;
- if (l == null) { //BUG ID 8039165
- mf = new MessageFormat(fmt);
- } else {
- mf = new MessageFormat(fmt, l);
- }
-
- /**
- * These arguments are described in the getTail documentation.
- */
- return mf.format(new Object[]{finish(head), finish(msg), finish(tail),
- c, (c - 1L), t, (c - t), msl, msh, (msh - msl), INIT_TIME, now,
- (now - INIT_TIME), g});
- }
-
- /**
- * Applied to the head, format, and tail returned by the target formatter.
- * This implementation trims all input strings.
- *
- * @param s the string to transform.
- * @return the transformed string.
- * @throws NullPointerException if the given string is null.
- */
- protected String finish(String s) {
- return s.trim();
- }
-
- /**
- * Peek at the current log record.
- *
- * @return null or the current log record.
- */
- private synchronized LogRecord peek() {
- return this.last;
- }
-
- /**
- * Updates the summary statistics and stores given LogRecord if the expected
- * record matches the current record.
- *
- * @param e the expected record.
- * @param u the update record.
- * @return true if the update was performed.
- * @throws NullPointerException if the update record is null.
- */
- private synchronized boolean acceptAndUpdate(LogRecord e, LogRecord u) {
- if (accept(e, u)) {
- this.last = u;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Gets the message format string from the LogManager or creates the default
- * message format string.
- *
- * @param p the class name prefix.
- * @return the format string.
- * @throws NullPointerException if the given argument is null.
- */
- private String initFormat(final String p) {
- String v = fromLogManager(p.concat(".format"));
- if (v == null || v.length() == 0) {
- v = "{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}\n";
- }
- return v;
- }
-
- /**
- * Gets and creates the formatter from the LogManager or creates the default
- * formatter.
- *
- * @param p the class name prefix.
- * @return the formatter.
- * @throws NullPointerException if the given argument is null.
- * @throws UndeclaredThrowableException if the formatter can not be created.
- */
- private Formatter initFormatter(final String p) {
- Formatter f;
- String v = fromLogManager(p.concat(".formatter"));
- if (v != null && v.length() != 0) {
- if (!"null".equalsIgnoreCase(v)) {
- try {
- f = LogManagerProperties.newFormatter(v);
- } catch (final RuntimeException re) {
- throw re;
- } catch (final Exception e) {
- throw new UndeclaredThrowableException(e);
- }
- } else {
- f = null;
- }
- } else {
- //Don't force the byte code verifier to load the formatter.
- f = Formatter.class.cast(new CompactFormatter());
- }
- return f;
- }
-
- /**
- * Gets and creates the comparator from the LogManager or returns the
- * default comparator.
- *
- * @param p the class name prefix.
- * @return the comparator or null.
- * @throws IllegalArgumentException if it was specified that the comparator
- * should be reversed but no initial comparator was specified.
- * @throws NullPointerException if the given argument is null.
- * @throws UndeclaredThrowableException if the comparator can not be
- * created.
- */
- @SuppressWarnings("unchecked")
- private Comparator<? super LogRecord> initComparator(final String p) {
- Comparator<? super LogRecord> c;
- final String name = fromLogManager(p.concat(".comparator"));
- final String reverse = fromLogManager(p.concat(".comparator.reverse"));
- try {
- if (name != null && name.length() != 0) {
- if (!"null".equalsIgnoreCase(name)) {
- c = LogManagerProperties.newComparator(name);
- if (Boolean.parseBoolean(reverse)) {
- assert c != null;
- c = LogManagerProperties.reverseOrder(c);
- }
- } else {
- if (reverse != null) {
- throw new IllegalArgumentException(
- "No comparator to reverse.");
- } else {
- c = null; //No ordering.
- }
- }
- } else {
- if (reverse != null) {
- throw new IllegalArgumentException(
- "No comparator to reverse.");
- } else {
- //Don't force the byte code verifier to load the comparator.
- c = Comparator.class.cast(SeverityComparator.getInstance());
- }
- }
- } catch (final RuntimeException re) {
- throw re; //Avoid catch all.
- } catch (final Exception e) {
- throw new UndeclaredThrowableException(e);
- }
- return c;
- }
-}
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2017 Jason Mehrens. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package com.sun.mail.util.logging;
+
+import static com.sun.mail.util.logging.LogManagerProperties.fromLogManager;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+/**
+ * A LogRecord formatter that takes a sequence of LogRecords and combines them
+ * into a single summary result. Formating of the head, LogRecord, and tail are
+ * delegated to the wrapped formatter.
+ *
+ * <p>
+ * By default each <tt>CollectorFormatter</tt> is initialized using the
+ * following LogManager configuration properties where
+ * <tt><formatter-name></tt> refers to the fully qualified class name or
+ * the fully qualified derived class name of the formatter. If properties are
+ * not defined, or contain invalid values, then the specified default values are
+ * used.
+ * <ul>
+ * <li><formatter-name>.comparator name of a
+ * {@linkplain java.util.Comparator} class used to choose the collected
+ * <tt>LogRecord</tt>. If a comparator is specified then the max
+ * <tt>LogRecord</tt> is chosen. If comparator is set to the string literal
+ * null, then the last record is chosen. (defaults to
+ * {@linkplain SeverityComparator})
+ *
+ * <li><formatter-name>.comparator.reverse a boolean
+ * <tt>true</tt> to collect the min <tt>LogRecord</tt> or <tt>false</tt> to
+ * collect the max <tt>LogRecord</tt>. (defaults to <tt>false</tt>)
+ *
+ * <li><formatter-name>.format the
+ * {@linkplain java.text.MessageFormat MessageFormat} string used to format the
+ * collected summary statistics. The arguments are explained in detail in the
+ * {@linkplain #getTail(java.util.logging.Handler) getTail} documentation.
+ * (defaults to <tt>{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer}
+ * more}\n</tt>)
+ *
+ * <li><formatter-name>.formatter name of a <tt>Formatter</tt> class used
+ * to format the collected LogRecord. (defaults to {@linkplain CompactFormatter})
+ *
+ * </ul>
+ *
+ * @author Jason Mehrens
+ * @since JavaMail 1.5.2
+ */
+public class CollectorFormatter extends Formatter {
+ /**
+ * Avoid depending on JMX runtime bean to get the start time.
+ */
+ private static final long INIT_TIME = System.currentTimeMillis();
+ /**
+ * The message format string used as the formatted output.
+ */
+ private final String fmt;
+ /**
+ * The formatter used to format the chosen log record.
+ */
+ private final Formatter formatter;
+ /**
+ * The comparator used to pick the log record to format.
+ */
+ private final Comparator<? super LogRecord> comparator;
+ /**
+ * The last accepted record. Synchronized access is preferred over volatile
+ * for this class.
+ */
+ private LogRecord last;
+ /**
+ * The number of log records that have been formatted.
+ */
+ private long count;
+ /**
+ * The number of log produced containing at least one log record.
+ * Only incremented when this formatter is reset.
+ */
+ private long generation = 1L;
+ /**
+ * The number of log records that have been formatted with a thrown object.
+ */
+ private long thrown;
+ /**
+ * The eldest log record time or eldest time possible for this instance.
+ */
+ private long minMillis = INIT_TIME;
+ /**
+ * The newest log record time.
+ */
+ private long maxMillis = Long.MIN_VALUE;
+
+ /**
+ * Creates the formatter using the LogManager defaults.
+ *
+ * @throws SecurityException if a security manager exists and the caller
+ * does not have <tt>LoggingPermission("control")</tt>.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
+ */
+ public CollectorFormatter() {
+ final String p = getClass().getName();
+ this.fmt = initFormat(p);
+ this.formatter = initFormatter(p);
+ this.comparator = initComparator(p);
+ }
+
+ /**
+ * Creates the formatter using the given format.
+ *
+ * @param format the message format or null to use the LogManager default.
+ * @throws SecurityException if a security manager exists and the caller
+ * does not have <tt>LoggingPermission("control")</tt>.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
+ */
+ public CollectorFormatter(String format) {
+ final String p = getClass().getName();
+ this.fmt = format == null ? initFormat(p) : format;
+ this.formatter = initFormatter(p);
+ this.comparator = initComparator(p);
+ }
+
+ /**
+ * Creates the formatter using the given values.
+ *
+ * @param format the format string or null to use the LogManager default.
+ * @param f the formatter used on the collected log record or null to
+ * specify no formatter.
+ * @param c the comparator used to determine which log record to format or
+ * null to specify no comparator.
+ * @throws SecurityException if a security manager exists and the caller
+ * does not have <tt>LoggingPermission("control")</tt>.
+ * @throws UndeclaredThrowableException if there are problems loading from
+ * the LogManager.
+ */
+ public CollectorFormatter(String format, Formatter f,
+ Comparator<? super LogRecord> c) {
+ final String p = getClass().getName();
+ this.fmt = format == null ? initFormat(p) : format;
+ this.formatter = f;
+ this.comparator = c;
+ }
+
+ /**
+ * Accumulates log records which will be used to produce the final output.
+ * The output is generated using the {@link #getTail} method which also
+ * resets this formatter back to its original state.
+ *
+ * @param record the record to store.
+ * @return an empty string.
+ * @throws NullPointerException if the given record is null.
+ */
+ @Override
+ public String format(final LogRecord record) {
+ if (record == null) {
+ throw new NullPointerException();
+ }
+
+ boolean accepted;
+ do {
+ final LogRecord peek = peek();
+ //The self compare of the first record acts like a type check.
+ LogRecord update = apply(peek != null ? peek : record, record);
+ if (peek != update) { //Not identical.
+ update.getSourceMethodName(); //Infer caller, null check.
+ accepted = acceptAndUpdate(peek, update);
+ } else {
+ accepted = accept(peek, record);
+ }
+ } while (!accepted);
+ return "";
+ }
+
+ /**
+ * Formats the collected LogRecord and summary statistics. The collected
+ * results are reset after calling this method. The
+ * {@linkplain java.text.MessageFormat java.text} argument indexes are assigned
+ * to the following properties:
+ *
+ * <ol start='0'>
+ * <li>{@code head} the
+ * {@linkplain Formatter#getHead(java.util.logging.Handler) head} string
+ * returned from the target formatter and
+ * {@linkplain #finish(java.lang.String) finished} by this formatter.
+ * <li>{@code formatted} the current log record
+ * {@linkplain Formatter#format(java.util.logging.LogRecord) formatted} by
+ * the target formatter and {@linkplain #finish(java.lang.String) finished}
+ * by this formatter. If the formatter is null then record is formatted by
+ * this {@linkplain #formatMessage(java.util.logging.LogRecord) formatter}.
+ * <li>{@code tail} the
+ * {@linkplain Formatter#getTail(java.util.logging.Handler) tail} string
+ * returned from the target formatter and
+ * {@linkplain #finish(java.lang.String) finished} by this formatter.
+ * <li>{@code count} the total number of log records
+ * {@linkplain #format consumed} by this formatter.
+ * <li>{@code remaining} the count minus one.
+ * <li>{@code thrown} the total number of log records
+ * {@linkplain #format consumed} by this formatter with an assigned
+ * {@linkplain java.util.logging.LogRecord#getThrown throwable}.
+ * <li>{@code normal messages} the count minus the thrown.
+ * <li>{@code minMillis} the eldest log record
+ * {@linkplain java.util.logging.LogRecord#getMillis event time}
+ * {@linkplain #format consumed} by this formatter. If the count is zero
+ * then this is set to the previous max or approximate start time if there
+ * was no previous max. By default this parameter is defined as a number.
+ * The format type and format style rules from the
+ * {@linkplain java.text.MessageFormat} should be used to convert this from
+ * milliseconds to a date or time.
+ * <li>{@code maxMillis} the most recent log record
+ * {@linkplain java.util.logging.LogRecord#getMillis event time}
+ * {@linkplain #format consumed} by this formatter. If the count is zero
+ * then this is set to the {@linkplain System#currentTimeMillis() current time}.
+ * By default this parameter is defined as a number. The format type and
+ * format style rules from the {@linkplain java.text.MessageFormat} should be
+ * used to convert this from milliseconds to a date or time.
+ * <li>{@code elapsed} the elapsed time in milliseconds between the
+ * {@code maxMillis} and {@code minMillis}.
+ * <li>{@code startTime} the approximate start time in milliseconds. By
+ * default this parameter is defined as a number. The format type and format
+ * style rules from the {@linkplain java.text.MessageFormat} should be used to
+ * convert this from milliseconds to a date or time.
+ * <li>{@code currentTime} the
+ * {@linkplain System#currentTimeMillis() current time} in milliseconds. By
+ * default this parameter is defined as a number. The format type and format
+ * style rules from the {@linkplain java.text.MessageFormat} should be used to
+ * convert this from milliseconds to a date or time.
+ * <li>{@code uptime} the elapsed time in milliseconds between the
+ * {@code currentTime} and {@code startTime}.
+ * <li>{@code generation} the number times this method produced output with
+ * at least one {@linkplain #format consumed} log record. This can be used
+ * to track the number of complete reports this formatter has produced.
+ * </ol>
+ *
+ * <p>
+ * Some example formats:<br>
+ * <ul>
+ * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format={0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}\n}
+ * <p>
+ * This prints the head ({@code {0}}), format ({@code {1}}), and tail
+ * ({@code {2}}) from the target formatter followed by the number of
+ * remaining ({@code {4}}) log records consumed by this formatter if there
+ * are any remaining records.
+ * <pre>
+ * Encoding failed.|NullPointerException: null String.getBytes(:913)... 3 more
+ * </pre>
+ * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format=These {3} messages occurred between\n{7,date,EEE, MMM dd HH:mm:ss:S ZZZ yyyy} and {8,time,EEE, MMM dd HH:mm:ss:S ZZZ yyyy}\n}
+ * <p>
+ * This prints the count ({@code {3}}) followed by the date and time of the
+ * eldest log record ({@code {7}}) and the date and time of the most recent
+ * log record ({@code {8}}).
+ * <pre>
+ * These 292 messages occurred between
+ * Tue, Jul 21 14:11:42:449 -0500 2009 and Fri, Nov 20 07:29:24:0 -0600 2009
+ * </pre>
+ * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format=These {3} messages occurred between {9,choice,86400000#{7,date} {7,time} and {8,time}|86400000<{7,date} and {8,date}}\n}
+ * <p>
+ * This prints the count ({@code {3}}) and then chooses the format based on
+ * the elapsed time ({@code {9}}). If the elapsed time is less than one day
+ * then the eldest log record ({@code {7}}) date and time is formatted
+ * followed by just the time of the most recent log record ({@code {8}}.
+ * Otherwise, the just the date of the eldest log record ({@code {7}}) and
+ * just the date of most recent log record ({@code {8}} is formatted.
+ * <pre>
+ * These 73 messages occurred between Jul 21, 2009 2:11:42 PM and 2:13:32 PM
+ *
+ * These 116 messages occurred between Jul 21, 2009 and Aug 20, 2009
+ * </pre>
+ * <li>{@code com.sun.mail.util.logging.CollectorFormatter.format={13} alert reports since {10,date}.\n}
+ * <p>
+ * This prints the generation ({@code {13}}) followed by the start time
+ * ({@code {10}}) formatted as a date.
+ * <pre>
+ * 4,320 alert reports since Jul 21, 2012.
+ * </pre>
+ * </ul>
+ *
+ * @param h the handler or null.
+ * @return the output string.
+ */
+ @Override
+ public String getTail(final Handler h) {
+ super.getTail(h); //Be forward compatible with super.getHead.
+ return formatRecord(h, true);
+ }
+
+ /**
+ * Formats the collected LogRecord and summary statistics. The LogRecord and
+ * summary statistics are not changed by calling this method.
+ *
+ * @return the current record formatted or the default toString.
+ * @see #getTail(java.util.logging.Handler)
+ */
+ @Override
+ public String toString() {
+ String result;
+ try {
+ result = formatRecord((Handler) null, false);
+ } catch (final RuntimeException ignore) {
+ result = super.toString();
+ }
+ return result;
+ }
+
+ /**
+ * Used to choose the collected LogRecord. This implementation returns the
+ * greater of two LogRecords.
+ *
+ * @param t the current record.
+ * @param u the record that could replace the current.
+ * @return the greater of the given log records.
+ * @throws NullPointerException may occur if either record is null.
+ */
+ protected LogRecord apply(final LogRecord t, final LogRecord u) {
+ if (t == null || u == null) {
+ throw new NullPointerException();
+ }
+
+ if (comparator != null) {
+ return comparator.compare(t, u) >= 0 ? t : u;
+ } else {
+ return u;
+ }
+ }
+
+ /**
+ * Updates the summary statistics only if the expected record matches the
+ * last record. The update record is not stored.
+ *
+ * @param e the LogRecord that is expected.
+ * @param u the LogRecord used to collect statistics.
+ * @return true if the last record was the expected record.
+ * @throws NullPointerException if the update record is null.
+ */
+ private synchronized boolean accept(final LogRecord e, final LogRecord u) {
+ /**
+ * LogRecord methods must be called before the check of the last stored
+ * record to guard against subclasses of LogRecord that might attempt to
+ * reset the state by triggering a call to getTail.
+ */
+ final long millis = u.getMillis(); //Null check.
+ final Throwable ex = u.getThrown();
+ if (last == e) { //Only if the exact same reference.
+ if (++count != 1L) {
+ minMillis = Math.min(minMillis, millis);
+ } else { //Show single records as instant and not a time period.
+ minMillis = millis;
+ }
+ maxMillis = Math.max(maxMillis, millis);
+
+ if (ex != null) {
+ ++thrown;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Resets all of the collected summary statistics including the LogRecord.
+ * @param min the current min milliseconds.
+ */
+ private synchronized void reset(final long min) {
+ if (last != null) {
+ last = null;
+ ++generation;
+ }
+
+ count = 0L;
+ thrown = 0L;
+ minMillis = min;
+ maxMillis = Long.MIN_VALUE;
+ }
+
+ /**
+ * Formats the given record with the head and tail.
+ *
+ * @param h the Handler or null.
+ * @param reset true if the summary statistics and LogRecord should be reset
+ * back to initial values.
+ * @return the formatted string.
+ * @see #getTail(java.util.logging.Handler)
+ */
+ private String formatRecord(final Handler h, final boolean reset) {
+ final LogRecord record;
+ final long c;
+ final long t;
+ final long g;
+ long msl;
+ long msh;
+ long now;
+ synchronized (this) {
+ record = last;
+ c = count;
+ g = generation;
+ t = thrown;
+ msl = minMillis;
+ msh = maxMillis;
+ now = System.currentTimeMillis();
+ if (c == 0L) {
+ msh = now;
+ }
+
+ if (reset) { //BUG ID 6351685
+ reset(msh);
+ }
+ }
+
+ final String head;
+ final String msg;
+ final String tail;
+ final Formatter f = this.formatter;
+ if (f != null) {
+ synchronized (f) {
+ head = f.getHead(h);
+ msg = record != null ? f.format(record) : "";
+ tail = f.getTail(h);
+ }
+ } else {
+ head = "";
+ msg = record != null ? formatMessage(record) : "";
+ tail = "";
+ }
+
+ Locale l = null;
+ if (record != null) {
+ ResourceBundle rb = record.getResourceBundle();
+ l = rb == null ? null : rb.getLocale();
+ }
+
+ final MessageFormat mf;
+ if (l == null) { //BUG ID 8039165
+ mf = new MessageFormat(fmt);
+ } else {
+ mf = new MessageFormat(fmt, l);
+ }
+
+ /**
+ * These arguments are described in the getTail documentation.
+ */
+ return mf.format(new Object[]{finish(head), finish(msg), finish(tail),
+ c, (c - 1L), t, (c - t), msl, msh, (msh - msl), INIT_TIME, now,
+ (now - INIT_TIME), g});
+ }
+
+ /**
+ * Applied to the head, format, and tail returned by the target formatter.
+ * This implementation trims all input strings.
+ *
+ * @param s the string to transform.
+ * @return the transformed string.
+ * @throws NullPointerException if the given string is null.
+ */
+ protected String finish(String s) {
+ return s.trim();
+ }
+
+ /**
+ * Peek at the current log record.
+ *
+ * @return null or the current log record.
+ */
+ private synchronized LogRecord peek() {
+ return this.last;
+ }
+
+ /**
+ * Updates the summary statistics and stores given LogRecord if the expected
+ * record matches the current record.
+ *
+ * @param e the expected record.
+ * @param u the update record.
+ * @return true if the update was performed.
+ * @throws NullPointerException if the update record is null.
+ */
+ private synchronized boolean acceptAndUpdate(LogRecord e, LogRecord u) {
+ if (accept(e, u)) {
+ this.last = u;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the message format string from the LogManager or creates the default
+ * message format string.
+ *
+ * @param p the class name prefix.
+ * @return the format string.
+ * @throws NullPointerException if the given argument is null.
+ */
+ private String initFormat(final String p) {
+ String v = fromLogManager(p.concat(".format"));
+ if (v == null || v.length() == 0) {
+ v = "{0}{1}{2}{4,choice,-1#|0#|0<... {4,number,integer} more}\n";
+ }
+ return v;
+ }
+
+ /**
+ * Gets and creates the formatter from the LogManager or creates the default
+ * formatter.
+ *
+ * @param p the class name prefix.
+ * @return the formatter.
+ * @throws NullPointerException if the given argument is null.
+ * @throws UndeclaredThrowableException if the formatter can not be created.
+ */
+ private Formatter initFormatter(final String p) {
+ Formatter f;
+ String v = fromLogManager(p.concat(".formatter"));
+ if (v != null && v.length() != 0) {
+ if (!"null".equalsIgnoreCase(v)) {
+ try {
+ f = LogManagerProperties.newFormatter(v);
+ } catch (final RuntimeException re) {
+ throw re;
+ } catch (final Exception e) {
+ throw new UndeclaredThrowableException(e);
+ }
+ } else {
+ f = null;
+ }
+ } else {
+ //Don't force the byte code verifier to load the formatter.
+ f = Formatter.class.cast(new CompactFormatter());
+ }
+ return f;
+ }
+
+ /**
+ * Gets and creates the comparator from the LogManager or returns the
+ * default comparator.
+ *
+ * @param p the class name prefix.
+ * @return the comparator or null.
+ * @throws IllegalArgumentException if it was specified that the comparator
+ * should be reversed but no initial comparator was specified.
+ * @throws NullPointerException if the given argument is null.
+ * @throws UndeclaredThrowableException if the comparator can not be
+ * created.
+ */
+ @SuppressWarnings("unchecked")
+ private Comparator<? super LogRecord> initComparator(final String p) {
+ Comparator<? super LogRecord> c;
+ final String name = fromLogManager(p.concat(".comparator"));
+ final String reverse = fromLogManager(p.concat(".comparator.reverse"));
+ try {
+ if (name != null && name.length() != 0) {
+ if (!"null".equalsIgnoreCase(name)) {
+ c = LogManagerProperties.newComparator(name);
+ if (Boolean.parseBoolean(reverse)) {
+ assert c != null;
+ c = LogManagerProperties.reverseOrder(c);
+ }
+ } else {
+ if (reverse != null) {
+ throw new IllegalArgumentException(
+ "No comparator to reverse.");
+ } else {
+ c = null; //No ordering.
+ }
+ }
+ } else {
+ if (reverse != null) {
+ throw new IllegalArgumentException(
+ "No comparator to reverse.");
+ } else {
+ //Don't force the byte code verifier to load the comparator.
+ c = Comparator.class.cast(SeverityComparator.getInstance());
+ }
+ }
+ } catch (final RuntimeException re) {
+ throw re; //Avoid catch all.
+ } catch (final Exception e) {
+ throw new UndeclaredThrowableException(e);
+ }
+ return c;
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/util/logging/CompactFormatter.java b/current/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
index d504219..5c38463 100644
--- a/current/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
+++ b/current/src/main/java/com/sun/mail/util/logging/CompactFormatter.java
@@ -1,839 +1,889 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2013-2016 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013-2016 Jason Mehrens. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package com.sun.mail.util.logging;
-
-import java.util.*;
-import java.util.logging.LogRecord;
-
-/**
- * A plain text formatter that can produce fixed width output. By default this
- * formatter will produce output no greater than 160 characters wide plus the
- * separator and newline characters. Only specified fields support an
- * {@linkplain #toAlternate(java.lang.String) alternate} fixed width format.
- * <p>
- * By default each <tt>CompactFormatter</tt> is initialized using the
- * following LogManager configuration properties where
- * <tt><formatter-name></tt> refers to the fully qualified class name or
- * the fully qualified derived class name of the formatter. If properties are
- * not defined, or contain invalid values, then the specified default values are
- * used.
- * <ul>
- * <li><formatter-name>.format - the {@linkplain java.util.Formatter
- * format} string used to transform the output. The format string can be
- * used to fix the output size. (defaults to <tt>%7$#.160s%n</tt>)</li>
- * </ul>
- *
- * @author Jason Mehrens
- * @since JavaMail 1.5.2
- */
-public class CompactFormatter extends java.util.logging.Formatter {
- /**
- * Load any declared classes to workaround GLASSFISH-21258.
- */
- static {
- loadDeclaredClasses();
- }
-
- /**
- * Used to load declared classes encase class loader doesn't allow loading
- * during JVM termination. This method is used with unit testing.
- *
- * @return an array of classes never null.
- */
- private static Class<?>[] loadDeclaredClasses() {
- return new Class<?>[]{Alternate.class};
- }
-
- /**
- * Holds the java.util.Formatter pattern.
- */
- private final String fmt;
-
- /**
- * Creates an instance with a default format pattern.
- */
- public CompactFormatter() {
- String p = getClass().getName();
- this.fmt = initFormat(p);
- }
-
- /**
- * Creates an instance with the given format pattern.
- *
- * @param format the {@linkplain java.util.Formatter pattern} or null to use
- * the LogManager default. The arguments are described in the
- * {@linkplain #format(java.util.logging.LogRecord) format} method.
- */
- public CompactFormatter(final String format) {
- String p = getClass().getName();
- this.fmt = format == null ? initFormat(p) : format;
- }
-
- /**
- * Format the given log record and returns the formatted string. The
- * {@linkplain java.util.Formatter#format(java.lang.String, java.lang.Object...)
- * java.util} argument indexes are assigned to the following properties:
- *
- * <ol start='0'>
- * <li>{@code format} - the {@linkplain java.util.Formatter
- * java.util.Formatter} format string specified in the
- * <formatter-name>.format property or the format that was given when
- * this formatter was created.</li>
- * <li>{@code date} - if the log record supports nanoseconds then a
- * ZonedDateTime object representing the event time of the log record in
- * the system time zone. Otherwise, a {@linkplain Date} object
- * representing {@linkplain LogRecord#getMillis event time} of the log
- * record.</li>
- * <li>{@code source} - a string representing the caller, if available;
- * otherwise, the logger's name.</li>
- * <li>{@code logger} - the logger's
- * {@linkplain LogRecord#getLoggerName() name}.</li>
- * <li>{@code level} - the
- * {@linkplain java.util.logging.Level#getLocalizedName log level}.</li>
- * <li>{@code message} - the formatted log message returned from the
- * {@linkplain #formatMessage(LogRecord)} method.</li>
- * <li>{@code thrown} - a string representing the
- * {@linkplain LogRecord#getThrown throwable} associated with the log record
- * and a relevant stack trace element if available; otherwise, an empty
- * string is used.</li>
- * <li>{@code message|thrown} The message and the thrown properties joined
- * as one parameter. This parameter supports
- * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
- * <li>{@code thrown|message} The thrown and message properties joined as
- * one parameter. This parameter supports
- * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
- * <li>{@code sequence} the
- * {@linkplain LogRecord#getSequenceNumber() sequence number} if the given
- * log record.</li>
- * <li>{@code thread id} the {@linkplain LogRecord#getThreadID() thread id}
- * of the given log record. By default this is formatted as a {@code long}
- * by an unsigned conversion.</li>
- * <li>{@code error} the throwable simple class name and
- * {@linkplain #formatError(LogRecord) error message} without any
- * stack trace.</li>
- * <li>{@code message|error} The message and error properties joined as
- * one parameter. This parameter supports
- * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
- * <li>{@code error|message} The error and message properties joined as
- * one parameter. This parameter supports
- * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
- * <li>{@code backtrace} only the
- * {@linkplain #formatBackTrace(LogRecord) stack trace} of the given
- * throwable.</li>
- * <li>{@code bundlename} the resource bundle
- * {@linkplain LogRecord#getResourceBundleName() name} of the given log
- * record.</li>
- * <li>{@code key} the {@linkplain LogRecord#getMessage() raw message}
- * before localization or formatting.</li>
- * </ol>
- *
- * <p>
- * Some example formats:<br>
- * <ul>
- * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%7$#.160s%n}
- * <p>
- * This prints only 160 characters of the message|thrown ({@code 7$}) using
- * the {@linkplain #toAlternate(java.lang.String) alternate} form. The
- * separator is not included as part of the total width.
- * <pre>
- * Encoding failed.|NullPointerException: null String.getBytes(:913)
- * </pre>
- *
- * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%7$#.20s%n}
- * <p>
- * This prints only 20 characters of the message|thrown ({@code 7$}) using
- * the {@linkplain #toAlternate(java.lang.String) alternate} form. This
- * will perform a weighted truncation of both the message and thrown
- * properties of the log record. The separator is not included as part of
- * the total width.
- * <pre>
- * Encoding|NullPointerE
- * </pre>
- *
- * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%1$tc %2$s%n%4$s: %5$s%6$s%n}
- * <p>
- * This prints the timestamp ({@code 1$}) and the source ({@code 2$}) on the
- * first line. The second line is the log level ({@code 4$}), log message
- * ({@code 5$}), and the throwable with a relevant stack trace element
- * ({@code 6$}) if one is available.
- * <pre>
- * Fri Nov 20 07:29:24 CST 2009 MyClass fatal
- * SEVERE: Encoding failed.NullPointerException: null String.getBytes(:913)
- * </pre>
- *
- * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%4$s: %12$#.160s%n}
- * <p>
- * This prints the log level ({@code 4$}) and only 160 characters of the
- * message|error ({@code 12$}) using the alternate form.
- * <pre>
- * SEVERE: Unable to send notification.|SocketException: Permission denied: connect
- * </pre>
- *
- * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=[%9$d][%1$tT][%10$d][%2$s] %5$s%n%6$s%n}
- * <p>
- * This prints the sequence ({@code 9$}), event time ({@code 1$}) as
- * 24 hour time, thread id ({@code 10$}), source ({@code 2$}), log message
- * ({@code 5$}), and the throwable with back trace ({@code 6$}).
- * <pre>
- * [125][14:11:42][38][MyClass fatal] Unable to send notification.
- * SocketException: Permission denied: connect SMTPTransport.openServer(:1949)
- * </pre>
- *
- * </ul>
- *
- * @param record the log record to format.
- * @return the formatted record.
- * @throws NullPointerException if the given record is null.
- */
- @Override
- public String format(final LogRecord record) {
- //LogRecord is mutable so define local vars.
- ResourceBundle rb = record.getResourceBundle();
- Locale l = rb == null ? null : rb.getLocale();
-
- String msg = formatMessage(record);
- String thrown = formatThrown(record);
- String err = formatError(record);
- Object[] params = {
- formatZonedDateTime(record),
- formatSource(record),
- formatLoggerName(record),
- formatLevel(record),
- msg,
- thrown,
- new Alternate(msg, thrown),
- new Alternate(thrown, msg),
- record.getSequenceNumber(),
- formatThreadID(record),
- err,
- new Alternate(msg, err),
- new Alternate(err, msg),
- formatBackTrace(record),
- record.getResourceBundleName(),
- record.getMessage()};
-
- if (l == null) { //BUG ID 6282094
- return String.format(fmt, params);
- } else {
- return String.format(l, fmt, params);
- }
- }
-
- /**
- * Formats message for the log record. This method removes any fully
- * qualified throwable class names from the message.
- *
- * @param record the log record.
- * @return the formatted message string.
- */
- @Override
- public String formatMessage(final LogRecord record) {
- String msg = super.formatMessage(record);
- msg = replaceClassName(msg, record.getThrown());
- msg = replaceClassName(msg, record.getParameters());
- return msg;
- }
-
- /**
- * Formats the message from the thrown property of the log record. This
- * method removes any fully qualified throwable class names from the message
- * cause chain.
- *
- * @param t the throwable to format or null.
- * @return the empty string if null was given or the formatted message
- * string from the throwable which may be null.
- */
- public String formatMessage(final Throwable t) {
- return t != null ? replaceClassName(apply(t).getMessage(), t) : "";
- }
-
- /**
- * Formats the level property of the given log record.
- *
- * @param record the record.
- * @return the formatted logger name.
- * @throws NullPointerException if the given record is null.
- */
- public String formatLevel(final LogRecord record) {
- return record.getLevel().getLocalizedName();
- }
-
- /**
- * Formats the source from the given log record.
- *
- * @param record the record.
- * @return the formatted source of the log record.
- * @throws NullPointerException if the given record is null.
- */
- public String formatSource(final LogRecord record) {
- String source = record.getSourceClassName();
- if (source != null) {
- if (record.getSourceMethodName() != null) {
- source = simpleClassName(source) + " "
- + record.getSourceMethodName();
- } else {
- source = simpleClassName(source);
- }
- } else {
- source = simpleClassName(record.getLoggerName());
- }
- return source;
- }
-
- /**
- * Formats the logger name property of the given log record.
- *
- * @param record the record.
- * @return the formatted logger name.
- * @throws NullPointerException if the given record is null.
- */
- public String formatLoggerName(final LogRecord record) {
- return simpleClassName(record.getLoggerName());
- }
-
- /**
- * Formats the thread id property of the given log record. By default this
- * is formatted as a {@code long} by an unsigned conversion.
- *
- * @param record the record.
- * @return the formatted thread id as a number.
- * @throws NullPointerException if the given record is null.
- * @since JavaMail 1.5.4
- */
- public Number formatThreadID(final LogRecord record) {
- /**
- * Thread.getID is defined as long and LogRecord.getThreadID is defined
- * as int. Convert to unsigned as a means to better map the two types
- * of thread identifiers.
- */
- return (((long) record.getThreadID()) & 0xffffffffL);
- }
-
- /**
- * Formats the thrown property of a LogRecord. The returned string will
- * contain a throwable message with a back trace.
- *
- * @param record the record.
- * @return empty string if nothing was thrown or formatted string.
- * @throws NullPointerException if the given record is null.
- * @see #apply(java.lang.Throwable)
- * @see #formatBackTrace(java.util.logging.LogRecord)
- */
- public String formatThrown(final LogRecord record) {
- String msg;
- final Throwable t = record.getThrown();
- if (t != null) {
- String site = formatBackTrace(record);
- msg = formatToString(t) + (isNullOrSpaces(site) ? "" : ' ' + site);
- } else {
- msg = "";
- }
- return msg;
- }
-
- /**
- * Formats the thrown property of a LogRecord as an error message. The
- * returned string will not contain a back trace.
- *
- * @param record the record.
- * @return empty string if nothing was thrown or formatted string.
- * @throws NullPointerException if the given record is null.
- * @see Throwable#toString()
- * @see #apply(java.lang.Throwable)
- * @see #formatMessage(java.lang.Throwable)
- * @since JavaMail 1.5.4
- */
- public String formatError(final LogRecord record) {
- Throwable t = record.getThrown();
- if (t != null) {
- return formatToString(t);
- } else {
- return "";
- }
- }
-
- /**
- * Gets the simple class name of the reduced throwable and message of
- * the reduced throwable.
- *
- * @param t the given throwable.
- * @return the formatted throwable.
- * @since JavaMail 1.5.4
- * @throws NullPointerException if given throwable is null.
- */
- private String formatToString(Throwable t) {
- return simpleClassName(apply(t).getClass()) + ": " + formatMessage(t);
- }
-
- /**
- * Formats the back trace for the given log record.
- *
- * @param record the log record to format.
- * @return the formatted back trace.
- * @throws NullPointerException if the given record is null.
- * @see #apply(java.lang.Throwable)
- * @see #formatThrown(java.util.logging.LogRecord)
- * @see #ignore(java.lang.StackTraceElement)
- */
- public String formatBackTrace(LogRecord record) {
- String site = "";
- final Throwable t = record.getThrown();
- if (t != null) {
- final Throwable root = apply(t);
- site = findAndFormat(root.getStackTrace());
- if (isNullOrSpaces(site)) {
- int limit = 0;
- for (Throwable c = t; c != null; c = c.getCause()) {
- site = findAndFormat(c.getStackTrace());
- if (!isNullOrSpaces(site)) {
- break;
- }
-
- //Deal with excessive cause chains
- //and cyclic throwables.
- if (++limit == (1 << 16)) {
- break; //Give up.
- }
- }
- }
- }
- return site;
- }
-
- /**
- * Finds and formats the first stack frame of interest.
- *
- * @param trace the fill stack to examine.
- * @return a String that best describes the call site.
- * @throws NullPointerException if stack trace element array is null.
- */
- private String findAndFormat(StackTraceElement[] trace) {
- String site = "";
- for (StackTraceElement s : trace) {
- if (!ignore(s)) {
- site = formatStackTraceElement(s);
- break;
- }
- }
-
- //Check if all code was compiled with no debugging info.
- if (isNullOrSpaces(site)) {
- for (StackTraceElement s : trace) {
- if (!defaultIgnore(s)) {
- site = formatStackTraceElement(s);
- break;
- }
- }
- }
- return site;
- }
-
- /**
- * Formats a stack trace element into a simple call site.
- *
- * @param s the stack trace element to format.
- * @return the formatted stack trace element.
- * @throws NullPointerException if stack trace element is null.
- * @see #formatThrown(java.util.logging.LogRecord)
- */
- private String formatStackTraceElement(final StackTraceElement s) {
- String v = simpleClassName(s.getClassName());
- String result;
- if (v != null) {
- result = s.toString().replace(s.getClassName(), v);
- } else {
- result = s.toString();
- }
-
- //If the class name contains the simple file name then remove file name.
- v = simpleFileName(s.getFileName());
- if (v != null && result.startsWith(v)) {
- result = result.replace(s.getFileName(), "");
- }
- return result;
- }
-
- /**
- * Chooses a single throwable from the cause chain that will be formatted.
- * This implementation chooses the throwable that best describes the chain.
- * Subclasses can override this method to choose an alternate throwable for
- * formatting.
- *
- * @param t the throwable from the log record.
- * @return the chosen throwable or null only if the given argument is null.
- * @see #formatThrown(java.util.logging.LogRecord)
- */
- protected Throwable apply(final Throwable t) {
- return SeverityComparator.getInstance().apply(t);
- }
-
- /**
- * Determines if a stack frame should be ignored as the cause of an error.
- *
- * @param s the stack trace element.
- * @return true if this frame should be ignored.
- * @see #formatThrown(java.util.logging.LogRecord)
- */
- protected boolean ignore(StackTraceElement s) {
- return isUnknown(s) || defaultIgnore(s);
- }
-
- /**
- * Defines the alternate format. This implementation removes all control
- * characters from the given string.
- *
- * @param s any string or null.
- * @return null if the argument was null otherwise, an alternate string.
- */
- protected String toAlternate(final String s) {
- return s != null ? s.replaceAll("[\\x00-\\x1F\\x7F]+", "") : null;
- }
-
- /**
- * Gets the zoned date time from the given log record.
- *
- * @param record the current log record.
- * @return a zoned date time or a legacy date object.
- * @throws NullPointerException if the given record is null.
- * @since JavaMail 1.5.6
- */
- private Comparable<?> formatZonedDateTime(final LogRecord record) {
- Comparable<?> zdt = LogManagerProperties.getZonedDateTime(record);
- if (zdt == null) {
- zdt = new java.util.Date(record.getMillis());
- }
- return zdt;
- }
-
- /**
- * Determines if a stack frame should be ignored as the cause of an error.
- * This does not check for unknown line numbers because code can be compiled
- * without debugging info.
- *
- * @param s the stack trace element.
- * @return true if this frame should be ignored.
- */
- private boolean defaultIgnore(StackTraceElement s) {
- return isSynthetic(s) || isStaticUtility(s) || isReflection(s);
- }
-
- /**
- * Determines if a stack frame is for a static utility class.
- *
- * @param s the stack trace element.
- * @return true if this frame should be ignored.
- */
- private boolean isStaticUtility(final StackTraceElement s) {
- try {
- return LogManagerProperties.isStaticUtilityClass(s.getClassName());
- } catch (RuntimeException ignore) {
- } catch (Exception ignore) {
- } catch (LinkageError ignore) {
- }
- final String cn = s.getClassName();
- return (cn.endsWith("s") && !cn.endsWith("es"))
- || cn.contains("Util") || cn.endsWith("Throwables");
- }
-
- /**
- * Determines if a stack trace element is for a synthetic method.
- *
- * @param s the stack trace element.
- * @return true if synthetic.
- * @throws NullPointerException if stack trace element is null.
- */
- private boolean isSynthetic(final StackTraceElement s) {
- return s.getMethodName().indexOf('$') > -1;
- }
-
- /**
- * Determines if a stack trace element has an unknown line number or a
- * native line number.
- *
- * @param s the stack trace element.
- * @return true if the line number is unknown.
- * @throws NullPointerException if stack trace element is null.
- */
- private boolean isUnknown(final StackTraceElement s) {
- return s.getLineNumber() < 0;
- }
-
- /**
- * Determines if a stack trace element represents a reflection frame.
- *
- * @param s the stack trace element.
- * @return true if the line number is unknown.
- * @throws NullPointerException if stack trace element is null.
- */
- private boolean isReflection(final StackTraceElement s) {
- try {
- return LogManagerProperties.isReflectionClass(s.getClassName());
- } catch (RuntimeException ignore) {
- } catch (Exception ignore) {
- } catch (LinkageError ignore) {
- }
- return s.getClassName().startsWith("java.lang.reflect.")
- || s.getClassName().startsWith("sun.reflect.");
- }
-
- /**
- * Creates the format pattern for this formatter.
- *
- * @param p the class name prefix.
- * @return the java.util.Formatter format string.
- * @throws NullPointerException if the given class name is null.
- */
- private String initFormat(final String p) {
- String v = LogManagerProperties.fromLogManager(p.concat(".format"));
- if (isNullOrSpaces(v)) {
- v = "%7$#.160s%n"; //160 chars split between message and thrown.
- }
- return v;
- }
-
- /**
- * Searches the given message for all instances fully qualified class name
- * with simple class name based off of the types contained in the given
- * parameter array.
- *
- * @param msg the message.
- * @param t the throwable cause chain to search or null.
- * @return the modified message string.
- */
- private static String replaceClassName(String msg, Throwable t) {
- if (!isNullOrSpaces(msg)) {
- int limit = 0;
- for (Throwable c = t; c != null; c = c.getCause()) {
- final Class<?> k = c.getClass();
- msg = msg.replace(k.getName(), simpleClassName(k));
-
- //Deal with excessive cause chains and cyclic throwables.
- if (++limit == (1 << 16)) {
- break; //Give up.
- }
- }
- }
- return msg;
- }
-
- /**
- * Searches the given message for all instances fully qualified class name
- * with simple class name based off of the types contained in the given
- * parameter array.
- *
- * @param msg the message or null.
- * @param p the parameter array or null.
- * @return the modified message string.
- */
- private static String replaceClassName(String msg, Object[] p) {
- if (!isNullOrSpaces(msg) && p != null) {
- for (Object o : p) {
- if (o != null) {
- final Class<?> k = o.getClass();
- msg = msg.replace(k.getName(), simpleClassName(k));
- }
- }
- }
- return msg;
- }
-
- /**
- * Gets the simple class name from the given class. This is a workaround for
- * BUG ID JDK-8057919.
- *
- * @param k the class object.
- * @return the simple class name or null.
- * @since JavaMail 1.5.3
- */
- private static String simpleClassName(final Class<?> k) {
- try {
- return k.getSimpleName();
- } catch (final InternalError JDK8057919) {
- }
- return simpleClassName(k.getName());
- }
-
- /**
- * Converts a fully qualified class name to a simple class name.
- *
- * @param name the fully qualified class name or null.
- * @return the simple class name or null.
- */
- private static String simpleClassName(String name) {
- if (name != null) {
- final int index = name.lastIndexOf('.');
- name = index > -1 ? name.substring(index + 1) : name;
- }
- return name;
- }
-
- /**
- * Converts a file name with an extension to a file name without an
- * extension.
- *
- * @param name the full file name or null.
- * @return the simple file name or null.
- */
- private static String simpleFileName(String name) {
- if (name != null) {
- final int index = name.lastIndexOf('.');
- name = index > -1 ? name.substring(0, index) : name;
- }
- return name;
- }
-
- /**
- * Determines is the given string is null or spaces.
- *
- * @param s the string or null.
- * @return true if null or spaces.
- */
- private static boolean isNullOrSpaces(final String s) {
- return s == null || s.trim().length() == 0;
- }
-
- /**
- * Used to format two arguments as fixed length message.
- */
- private class Alternate implements java.util.Formattable {
-
- /**
- * The left side of the output.
- */
- private final String left;
- /**
- * The right side of the output.
- */
- private final String right;
-
- /**
- * Creates an alternate output.
- *
- * @param left the left side or null.
- * @param right the right side or null.
- */
- Alternate(final String left, final String right) {
- this.left = String.valueOf(left);
- this.right = String.valueOf(right);
- }
-
- @SuppressWarnings("override") //JDK-6954234
- public void formatTo(java.util.Formatter formatter, int flags,
- int width, int precision) {
-
- String l = left;
- String r = right;
- if ((flags & java.util.FormattableFlags.UPPERCASE)
- == java.util.FormattableFlags.UPPERCASE) {
- l = l.toUpperCase(formatter.locale());
- r = r.toUpperCase(formatter.locale());
- }
-
- if ((flags & java.util.FormattableFlags.ALTERNATE)
- == java.util.FormattableFlags.ALTERNATE) {
- l = toAlternate(l);
- r = toAlternate(r);
- }
-
- if (precision <= 0) {
- precision = Integer.MAX_VALUE;
- }
-
- int fence = Math.min(l.length(), precision);
- if (fence > (precision >> 1)) {
- fence = Math.max(fence - r.length(), fence >> 1);
- }
-
- if (fence > 0) {
- if (fence > l.length()
- && Character.isHighSurrogate(l.charAt(fence - 1))) {
- --fence;
- }
- l = l.substring(0, fence);
- }
- r = r.substring(0, Math.min(precision - fence, r.length()));
-
- if (width > 0) {
- final int half = width >> 1;
- if (l.length() < half) {
- l = pad(flags, l, half);
- }
-
- if (r.length() < half) {
- r = pad(flags, r, half);
- }
- }
-
- Object[] empty = Collections.emptySet().toArray();
- formatter.format(l, empty);
- if (l.length() != 0 && r.length() != 0) {
- formatter.format("|", empty);
- }
- formatter.format(r, empty);
- }
-
- /**
- * Pad the given input string.
- *
- * @param flags the formatter flags.
- * @param s the string to pad.
- * @param length the final string length.
- * @return the padded string.
- */
- private String pad(int flags, String s, int length) {
- final int padding = length - s.length();
- final StringBuilder b = new StringBuilder(length);
- if ((flags & java.util.FormattableFlags.LEFT_JUSTIFY)
- == java.util.FormattableFlags.LEFT_JUSTIFY) {
- for (int i = 0; i < padding; ++i) {
- b.append('\u0020');
- }
- b.append(s);
- } else {
- b.append(s);
- for (int i = 0; i < padding; ++i) {
- b.append('\u0020');
- }
- }
- return b.toString();
- }
- }
-}
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2017 Jason Mehrens. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package com.sun.mail.util.logging;
+
+import java.util.*;
+import java.util.logging.LogRecord;
+
+/**
+ * A plain text formatter that can produce fixed width output. By default this
+ * formatter will produce output no greater than 160 characters wide plus the
+ * separator and newline characters. Only specified fields support an
+ * {@linkplain #toAlternate(java.lang.String) alternate} fixed width format.
+ * <p>
+ * By default each <tt>CompactFormatter</tt> is initialized using the following
+ * LogManager configuration properties where
+ * <tt><formatter-name></tt> refers to the fully qualified class name or
+ * the fully qualified derived class name of the formatter. If properties are
+ * not defined, or contain invalid values, then the specified default values are
+ * used.
+ * <ul>
+ * <li><formatter-name>.format - the {@linkplain java.util.Formatter
+ * format} string used to transform the output. The format string can be
+ * used to fix the output size. (defaults to <tt>%7$#.160s%n</tt>)</li>
+ * </ul>
+ *
+ * @author Jason Mehrens
+ * @since JavaMail 1.5.2
+ */
+public class CompactFormatter extends java.util.logging.Formatter {
+
+ /**
+ * Load any declared classes to workaround GLASSFISH-21258.
+ */
+ static {
+ loadDeclaredClasses();
+ }
+
+ /**
+ * Used to load declared classes encase class loader doesn't allow loading
+ * during JVM termination. This method is used with unit testing.
+ *
+ * @return an array of classes never null.
+ */
+ private static Class<?>[] loadDeclaredClasses() {
+ return new Class<?>[]{Alternate.class};
+ }
+
+ /**
+ * Holds the java.util.Formatter pattern.
+ */
+ private final String fmt;
+
+ /**
+ * Creates an instance with a default format pattern.
+ */
+ public CompactFormatter() {
+ String p = getClass().getName();
+ this.fmt = initFormat(p);
+ }
+
+ /**
+ * Creates an instance with the given format pattern.
+ *
+ * @param format the {@linkplain java.util.Formatter pattern} or null to use
+ * the LogManager default. The arguments are described in the
+ * {@linkplain #format(java.util.logging.LogRecord) format} method.
+ */
+ public CompactFormatter(final String format) {
+ String p = getClass().getName();
+ this.fmt = format == null ? initFormat(p) : format;
+ }
+
+ /**
+ * Format the given log record and returns the formatted string. The
+ * {@linkplain java.util.Formatter#format(java.lang.String, java.lang.Object...)
+ * java.util} argument indexes are assigned to the following properties:
+ *
+ * <ol start='0'>
+ * <li>{@code format} - the {@linkplain java.util.Formatter
+ * java.util.Formatter} format string specified in the
+ * <formatter-name>.format property or the format that was given when
+ * this formatter was created.</li>
+ * <li>{@code date} - if the log record supports nanoseconds then a
+ * ZonedDateTime object representing the event time of the log record in the
+ * system time zone. Otherwise, a {@linkplain Date} object representing
+ * {@linkplain LogRecord#getMillis event time} of the log record.</li>
+ * <li>{@code source} - a string representing the caller, if available;
+ * otherwise, the logger's name.</li>
+ * <li>{@code logger} - the logger's
+ * {@linkplain Class#getSimpleName() simple}
+ * {@linkplain LogRecord#getLoggerName() name}.</li>
+ * <li>{@code level} - the
+ * {@linkplain java.util.logging.Level#getLocalizedName log level}.</li>
+ * <li>{@code message} - the formatted log message returned from the
+ * {@linkplain #formatMessage(LogRecord)} method.</li>
+ * <li>{@code thrown} - a string representing the
+ * {@linkplain LogRecord#getThrown throwable} associated with the log record
+ * and a relevant stack trace element if available; otherwise, an empty
+ * string is used.</li>
+ * <li>{@code message|thrown} The message and the thrown properties joined
+ * as one parameter. This parameter supports
+ * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
+ * <li>{@code thrown|message} The thrown and message properties joined as
+ * one parameter. This parameter supports
+ * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
+ * <li>{@code sequence} the
+ * {@linkplain LogRecord#getSequenceNumber() sequence number} if the given
+ * log record.</li>
+ * <li>{@code thread id} the {@linkplain LogRecord#getThreadID() thread id}
+ * of the given log record. By default this is formatted as a {@code long}
+ * by an unsigned conversion.</li>
+ * <li>{@code error} the throwable
+ * {@linkplain Class#getSimpleName() simple class name} and
+ * {@linkplain #formatError(LogRecord) error message} without any stack
+ * trace.</li>
+ * <li>{@code message|error} The message and error properties joined as one
+ * parameter. This parameter supports
+ * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
+ * <li>{@code error|message} The error and message properties joined as one
+ * parameter. This parameter supports
+ * {@linkplain #toAlternate(java.lang.String) alternate} form.</li>
+ * <li>{@code backtrace} only the
+ * {@linkplain #formatBackTrace(LogRecord) stack trace} of the given
+ * throwable.</li>
+ * <li>{@code bundlename} the resource bundle
+ * {@linkplain LogRecord#getResourceBundleName() name} of the given log
+ * record.</li>
+ * <li>{@code key} the {@linkplain LogRecord#getMessage() raw message}
+ * before localization or formatting.</li>
+ * </ol>
+ *
+ * <p>
+ * Some example formats:<br>
+ * <ul>
+ * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%7$#.160s%n}
+ * <p>
+ * This prints only 160 characters of the message|thrown ({@code 7$}) using
+ * the {@linkplain #toAlternate(java.lang.String) alternate} form. The
+ * separator is not included as part of the total width.
+ * <pre>
+ * Encoding failed.|NullPointerException: null String.getBytes(:913)
+ * </pre>
+ *
+ * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%7$#.20s%n}
+ * <p>
+ * This prints only 20 characters of the message|thrown ({@code 7$}) using
+ * the {@linkplain #toAlternate(java.lang.String) alternate} form. This will
+ * perform a weighted truncation of both the message and thrown properties
+ * of the log record. The separator is not included as part of the total
+ * width.
+ * <pre>
+ * Encoding|NullPointerE
+ * </pre>
+ *
+ * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%1$tc %2$s%n%4$s: %5$s%6$s%n}
+ * <p>
+ * This prints the timestamp ({@code 1$}) and the source ({@code 2$}) on the
+ * first line. The second line is the log level ({@code 4$}), log message
+ * ({@code 5$}), and the throwable with a relevant stack trace element
+ * ({@code 6$}) if one is available.
+ * <pre>
+ * Fri Nov 20 07:29:24 CST 2009 MyClass fatal
+ * SEVERE: Encoding failed.NullPointerException: null String.getBytes(:913)
+ * </pre>
+ *
+ * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=%4$s: %12$#.160s%n}
+ * <p>
+ * This prints the log level ({@code 4$}) and only 160 characters of the
+ * message|error ({@code 12$}) using the alternate form.
+ * <pre>
+ * SEVERE: Unable to send notification.|SocketException: Permission denied: connect
+ * </pre>
+ *
+ * <li>{@code com.sun.mail.util.logging.CompactFormatter.format=[%9$d][%1$tT][%10$d][%2$s] %5$s%n%6$s%n}
+ * <p>
+ * This prints the sequence ({@code 9$}), event time ({@code 1$}) as 24 hour
+ * time, thread id ({@code 10$}), source ({@code 2$}), log message
+ * ({@code 5$}), and the throwable with back trace ({@code 6$}).
+ * <pre>
+ * [125][14:11:42][38][MyClass fatal] Unable to send notification.
+ * SocketException: Permission denied: connect SMTPTransport.openServer(:1949)
+ * </pre>
+ *
+ * </ul>
+ *
+ * @param record the log record to format.
+ * @return the formatted record.
+ * @throws NullPointerException if the given record is null.
+ */
+ @Override
+ public String format(final LogRecord record) {
+ //LogRecord is mutable so define local vars.
+ ResourceBundle rb = record.getResourceBundle();
+ Locale l = rb == null ? null : rb.getLocale();
+
+ String msg = formatMessage(record);
+ String thrown = formatThrown(record);
+ String err = formatError(record);
+ Object[] params = {
+ formatZonedDateTime(record),
+ formatSource(record),
+ formatLoggerName(record),
+ formatLevel(record),
+ msg,
+ thrown,
+ new Alternate(msg, thrown),
+ new Alternate(thrown, msg),
+ record.getSequenceNumber(),
+ formatThreadID(record),
+ err,
+ new Alternate(msg, err),
+ new Alternate(err, msg),
+ formatBackTrace(record),
+ record.getResourceBundleName(),
+ record.getMessage()};
+
+ if (l == null) { //BUG ID 6282094
+ return String.format(fmt, params);
+ } else {
+ return String.format(l, fmt, params);
+ }
+ }
+
+ /**
+ * Formats message for the log record. This method removes any fully
+ * qualified throwable class names from the message.
+ *
+ * @param record the log record.
+ * @return the formatted message string.
+ */
+ @Override
+ public String formatMessage(final LogRecord record) {
+ String msg = super.formatMessage(record);
+ msg = replaceClassName(msg, record.getThrown());
+ msg = replaceClassName(msg, record.getParameters());
+ return msg;
+ }
+
+ /**
+ * Formats the message from the thrown property of the log record. This
+ * method replaces fully qualified throwable class names from the message
+ * cause chain with simple class names.
+ *
+ * @param t the throwable to format or null.
+ * @return the empty string if null was given or the formatted message
+ * string from the throwable which may be null.
+ */
+ public String formatMessage(final Throwable t) {
+ String r;
+ if (t != null) {
+ final Throwable apply = apply(t);
+ final String m = apply.getLocalizedMessage();
+ final String s = apply.toString();
+ final String sn = simpleClassName(apply.getClass());
+ if (!isNullOrSpaces(m)) {
+ if (s.contains(m)) {
+ if (s.startsWith(apply.getClass().getName())
+ || s.startsWith(sn)) {
+ r = replaceClassName(m, t);
+ } else {
+ r = replaceClassName(simpleClassName(s), t);
+ }
+ } else {
+ r = replaceClassName(simpleClassName(s) + ": " + m, t);
+ }
+ } else {
+ r = replaceClassName(simpleClassName(s), t);
+ }
+
+ if (!r.contains(sn)) {
+ r = sn + ": " + r;
+ }
+ } else {
+ r = "";
+ }
+ return r;
+ }
+
+ /**
+ * Formats the level property of the given log record.
+ *
+ * @param record the record.
+ * @return the formatted logger name.
+ * @throws NullPointerException if the given record is null.
+ */
+ public String formatLevel(final LogRecord record) {
+ return record.getLevel().getLocalizedName();
+ }
+
+ /**
+ * Formats the source from the given log record.
+ *
+ * @param record the record.
+ * @return the formatted source of the log record.
+ * @throws NullPointerException if the given record is null.
+ */
+ public String formatSource(final LogRecord record) {
+ String source = record.getSourceClassName();
+ if (source != null) {
+ if (record.getSourceMethodName() != null) {
+ source = simpleClassName(source) + " "
+ + record.getSourceMethodName();
+ } else {
+ source = simpleClassName(source);
+ }
+ } else {
+ source = simpleClassName(record.getLoggerName());
+ }
+ return source;
+ }
+
+ /**
+ * Formats the logger name property of the given log record.
+ *
+ * @param record the record.
+ * @return the formatted logger name.
+ * @throws NullPointerException if the given record is null.
+ */
+ public String formatLoggerName(final LogRecord record) {
+ return simpleClassName(record.getLoggerName());
+ }
+
+ /**
+ * Formats the thread id property of the given log record. By default this
+ * is formatted as a {@code long} by an unsigned conversion.
+ *
+ * @param record the record.
+ * @return the formatted thread id as a number.
+ * @throws NullPointerException if the given record is null.
+ * @since JavaMail 1.5.4
+ */
+ public Number formatThreadID(final LogRecord record) {
+ /**
+ * Thread.getID is defined as long and LogRecord.getThreadID is defined
+ * as int. Convert to unsigned as a means to better map the two types of
+ * thread identifiers.
+ */
+ return (((long) record.getThreadID()) & 0xffffffffL);
+ }
+
+ /**
+ * Formats the thrown property of a LogRecord. The returned string will
+ * contain a throwable message with a back trace.
+ *
+ * @param record the record.
+ * @return empty string if nothing was thrown or formatted string.
+ * @throws NullPointerException if the given record is null.
+ * @see #apply(java.lang.Throwable)
+ * @see #formatBackTrace(java.util.logging.LogRecord)
+ */
+ public String formatThrown(final LogRecord record) {
+ String msg;
+ final Throwable t = record.getThrown();
+ if (t != null) {
+ String site = formatBackTrace(record);
+ msg = formatMessage(t) + (isNullOrSpaces(site) ? "" : ' ' + site);
+ } else {
+ msg = "";
+ }
+ return msg;
+ }
+
+ /**
+ * Formats the thrown property of a LogRecord as an error message. The
+ * returned string will not contain a back trace.
+ *
+ * @param record the record.
+ * @return empty string if nothing was thrown or formatted string.
+ * @throws NullPointerException if the given record is null.
+ * @see Throwable#toString()
+ * @see #apply(java.lang.Throwable)
+ * @see #formatMessage(java.lang.Throwable)
+ * @since JavaMail 1.5.4
+ */
+ public String formatError(final LogRecord record) {
+ return formatMessage(record.getThrown());
+ }
+
+ /**
+ * Formats the back trace for the given log record.
+ *
+ * @param record the log record to format.
+ * @return the formatted back trace.
+ * @throws NullPointerException if the given record is null.
+ * @see #apply(java.lang.Throwable)
+ * @see #formatThrown(java.util.logging.LogRecord)
+ * @see #ignore(java.lang.StackTraceElement)
+ */
+ public String formatBackTrace(final LogRecord record) {
+ String site = "";
+ final Throwable t = record.getThrown();
+ if (t != null) {
+ final Throwable root = apply(t);
+ StackTraceElement[] trace = root.getStackTrace();
+ site = findAndFormat(trace);
+ if (isNullOrSpaces(site)) {
+ int limit = 0;
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ StackTraceElement[] ste = c.getStackTrace();
+ site = findAndFormat(ste);
+ if (!isNullOrSpaces(site)) {
+ break;
+ } else {
+ if (trace.length == 0) {
+ trace = ste;
+ }
+ }
+
+ //Deal with excessive cause chains
+ //and cyclic throwables.
+ if (++limit == (1 << 16)) {
+ break; //Give up.
+ }
+ }
+
+ //Punt.
+ if (isNullOrSpaces(site) && trace.length != 0) {
+ site = formatStackTraceElement(trace[0]);
+ }
+ }
+ }
+ return site;
+ }
+
+ /**
+ * Finds and formats the first stack frame of interest.
+ *
+ * @param trace the fill stack to examine.
+ * @return a String that best describes the call site.
+ * @throws NullPointerException if stack trace element array is null.
+ */
+ private String findAndFormat(final StackTraceElement[] trace) {
+ String site = "";
+ for (StackTraceElement s : trace) {
+ if (!ignore(s)) {
+ site = formatStackTraceElement(s);
+ break;
+ }
+ }
+
+ //Check if all code was compiled with no debugging info.
+ if (isNullOrSpaces(site)) {
+ for (StackTraceElement s : trace) {
+ if (!defaultIgnore(s)) {
+ site = formatStackTraceElement(s);
+ break;
+ }
+ }
+ }
+ return site;
+ }
+
+ /**
+ * Formats a stack trace element into a simple call site.
+ *
+ * @param s the stack trace element to format.
+ * @return the formatted stack trace element.
+ * @throws NullPointerException if stack trace element is null.
+ * @see #formatThrown(java.util.logging.LogRecord)
+ */
+ private String formatStackTraceElement(final StackTraceElement s) {
+ String v = simpleClassName(s.getClassName());
+ String result;
+ if (v != null) {
+ result = s.toString().replace(s.getClassName(), v);
+ } else {
+ result = s.toString();
+ }
+
+ //If the class name contains the simple file name then remove file name.
+ v = simpleFileName(s.getFileName());
+ if (v != null && result.startsWith(v)) {
+ result = result.replace(s.getFileName(), "");
+ }
+ return result;
+ }
+
+ /**
+ * Chooses a single throwable from the cause chain that will be formatted.
+ * This implementation chooses the throwable that best describes the chain.
+ * Subclasses can override this method to choose an alternate throwable for
+ * formatting.
+ *
+ * @param t the throwable from the log record.
+ * @return the chosen throwable or null only if the given argument is null.
+ * @see #formatThrown(java.util.logging.LogRecord)
+ */
+ protected Throwable apply(final Throwable t) {
+ return SeverityComparator.getInstance().apply(t);
+ }
+
+ /**
+ * Determines if a stack frame should be ignored as the cause of an error.
+ *
+ * @param s the stack trace element.
+ * @return true if this frame should be ignored.
+ * @see #formatThrown(java.util.logging.LogRecord)
+ */
+ protected boolean ignore(final StackTraceElement s) {
+ return isUnknown(s) || defaultIgnore(s);
+ }
+
+ /**
+ * Defines the alternate format. This implementation removes all control
+ * characters from the given string.
+ *
+ * @param s any string or null.
+ * @return null if the argument was null otherwise, an alternate string.
+ */
+ protected String toAlternate(final String s) {
+ return s != null ? s.replaceAll("[\\x00-\\x1F\\x7F]+", "") : null;
+ }
+
+ /**
+ * Gets the zoned date time from the given log record.
+ *
+ * @param record the current log record.
+ * @return a zoned date time or a legacy date object.
+ * @throws NullPointerException if the given record is null.
+ * @since JavaMail 1.5.6
+ */
+ private Comparable<?> formatZonedDateTime(final LogRecord record) {
+ Comparable<?> zdt = LogManagerProperties.getZonedDateTime(record);
+ if (zdt == null) {
+ zdt = new java.util.Date(record.getMillis());
+ }
+ return zdt;
+ }
+
+ /**
+ * Determines if a stack frame should be ignored as the cause of an error.
+ * This does not check for unknown line numbers because code can be compiled
+ * without debugging info.
+ *
+ * @param s the stack trace element.
+ * @return true if this frame should be ignored.
+ */
+ private boolean defaultIgnore(final StackTraceElement s) {
+ return isSynthetic(s) || isStaticUtility(s) || isReflection(s);
+ }
+
+ /**
+ * Determines if a stack frame is for a static utility class.
+ *
+ * @param s the stack trace element.
+ * @return true if this frame should be ignored.
+ */
+ private boolean isStaticUtility(final StackTraceElement s) {
+ try {
+ return LogManagerProperties.isStaticUtilityClass(s.getClassName());
+ } catch (RuntimeException ignore) {
+ } catch (Exception | LinkageError ignore) {
+ }
+ final String cn = s.getClassName();
+ return (cn.endsWith("s") && !cn.endsWith("es"))
+ || cn.contains("Util") || cn.endsWith("Throwables");
+ }
+
+ /**
+ * Determines if a stack trace element is for a synthetic method.
+ *
+ * @param s the stack trace element.
+ * @return true if synthetic.
+ * @throws NullPointerException if stack trace element is null.
+ */
+ private boolean isSynthetic(final StackTraceElement s) {
+ return s.getMethodName().indexOf('$') > -1;
+ }
+
+ /**
+ * Determines if a stack trace element has an unknown line number or a
+ * native line number.
+ *
+ * @param s the stack trace element.
+ * @return true if the line number is unknown.
+ * @throws NullPointerException if stack trace element is null.
+ */
+ private boolean isUnknown(final StackTraceElement s) {
+ return s.getLineNumber() < 0;
+ }
+
+ /**
+ * Determines if a stack trace element represents a reflection frame.
+ *
+ * @param s the stack trace element.
+ * @return true if the line number is unknown.
+ * @throws NullPointerException if stack trace element is null.
+ */
+ private boolean isReflection(final StackTraceElement s) {
+ try {
+ return LogManagerProperties.isReflectionClass(s.getClassName());
+ } catch (RuntimeException ignore) {
+ } catch (Exception | LinkageError ignore) {
+ }
+ return s.getClassName().startsWith("java.lang.reflect.")
+ || s.getClassName().startsWith("sun.reflect.");
+ }
+
+ /**
+ * Creates the format pattern for this formatter.
+ *
+ * @param p the class name prefix.
+ * @return the java.util.Formatter format string.
+ * @throws NullPointerException if the given class name is null.
+ */
+ private String initFormat(final String p) {
+ String v = LogManagerProperties.fromLogManager(p.concat(".format"));
+ if (isNullOrSpaces(v)) {
+ v = "%7$#.160s%n"; //160 chars split between message and thrown.
+ }
+ return v;
+ }
+
+ /**
+ * Searches the given message for all instances fully qualified class name
+ * with simple class name based off of the types contained in the given
+ * parameter array.
+ *
+ * @param msg the message.
+ * @param t the throwable cause chain to search or null.
+ * @return the modified message string.
+ */
+ private static String replaceClassName(String msg, Throwable t) {
+ if (!isNullOrSpaces(msg)) {
+ int limit = 0;
+ for (Throwable c = t; c != null; c = c.getCause()) {
+ final Class<?> k = c.getClass();
+ msg = msg.replace(k.getName(), simpleClassName(k));
+
+ //Deal with excessive cause chains and cyclic throwables.
+ if (++limit == (1 << 16)) {
+ break; //Give up.
+ }
+ }
+ }
+ return msg;
+ }
+
+ /**
+ * Searches the given message for all instances fully qualified class name
+ * with simple class name based off of the types contained in the given
+ * parameter array.
+ *
+ * @param msg the message or null.
+ * @param p the parameter array or null.
+ * @return the modified message string.
+ */
+ private static String replaceClassName(String msg, Object[] p) {
+ if (!isNullOrSpaces(msg) && p != null) {
+ for (Object o : p) {
+ if (o != null) {
+ final Class<?> k = o.getClass();
+ msg = msg.replace(k.getName(), simpleClassName(k));
+ }
+ }
+ }
+ return msg;
+ }
+
+ /**
+ * Gets the simple class name from the given class. This is a workaround for
+ * BUG ID JDK-8057919.
+ *
+ * @param k the class object.
+ * @return the simple class name or null.
+ * @since JavaMail 1.5.3
+ */
+ private static String simpleClassName(final Class<?> k) {
+ try {
+ return k.getSimpleName();
+ } catch (final InternalError JDK8057919) {
+ }
+ return simpleClassName(k.getName());
+ }
+
+ /**
+ * Converts a fully qualified class name to a simple class name. If the
+ * leading part of the given string is not a legal class name then the given
+ * string is returned.
+ *
+ * @param name the fully qualified class name prefix or null.
+ * @return the simple class name or given input.
+ */
+ private static String simpleClassName(String name) {
+ if (name != null) {
+ int cursor = 0;
+ int sign = -1;
+ int dot = -1;
+ for (int c, prev = dot; cursor < name.length();
+ cursor += Character.charCount(c)) {
+ c = name.codePointAt(cursor);
+ if (!Character.isJavaIdentifierPart(c)) {
+ if (c == ((int) '.')) {
+ if ((dot + 1) != cursor && (dot + 1) != sign) {
+ prev = dot;
+ dot = cursor;
+ } else {
+ return name;
+ }
+ } else {
+ if ((dot + 1) == cursor) {
+ dot = prev;
+ }
+ break;
+ }
+ } else {
+ if (c == ((int) '$')) {
+ sign = cursor;
+ }
+ }
+ }
+
+ if (dot > -1 && ++dot < cursor && ++sign < cursor) {
+ name = name.substring(sign > dot ? sign : dot);
+ }
+ }
+ return name;
+ }
+
+ /**
+ * Converts a file name with an extension to a file name without an
+ * extension.
+ *
+ * @param name the full file name or null.
+ * @return the simple file name or null.
+ */
+ private static String simpleFileName(String name) {
+ if (name != null) {
+ final int index = name.lastIndexOf('.');
+ name = index > -1 ? name.substring(0, index) : name;
+ }
+ return name;
+ }
+
+ /**
+ * Determines is the given string is null or spaces.
+ *
+ * @param s the string or null.
+ * @return true if null or spaces.
+ */
+ private static boolean isNullOrSpaces(final String s) {
+ return s == null || s.trim().length() == 0;
+ }
+
+ /**
+ * Used to format two arguments as fixed length message.
+ */
+ private class Alternate implements java.util.Formattable {
+
+ /**
+ * The left side of the output.
+ */
+ private final String left;
+ /**
+ * The right side of the output.
+ */
+ private final String right;
+
+ /**
+ * Creates an alternate output.
+ *
+ * @param left the left side or null.
+ * @param right the right side or null.
+ */
+ Alternate(final String left, final String right) {
+ this.left = String.valueOf(left);
+ this.right = String.valueOf(right);
+ }
+
+ @SuppressWarnings("override") //JDK-6954234
+ public void formatTo(java.util.Formatter formatter, int flags,
+ int width, int precision) {
+
+ String l = left;
+ String r = right;
+ if ((flags & java.util.FormattableFlags.UPPERCASE)
+ == java.util.FormattableFlags.UPPERCASE) {
+ l = l.toUpperCase(formatter.locale());
+ r = r.toUpperCase(formatter.locale());
+ }
+
+ if ((flags & java.util.FormattableFlags.ALTERNATE)
+ == java.util.FormattableFlags.ALTERNATE) {
+ l = toAlternate(l);
+ r = toAlternate(r);
+ }
+
+ if (precision <= 0) {
+ precision = Integer.MAX_VALUE;
+ }
+
+ int fence = Math.min(l.length(), precision);
+ if (fence > (precision >> 1)) {
+ fence = Math.max(fence - r.length(), fence >> 1);
+ }
+
+ if (fence > 0) {
+ if (fence > l.length()
+ && Character.isHighSurrogate(l.charAt(fence - 1))) {
+ --fence;
+ }
+ l = l.substring(0, fence);
+ }
+ r = r.substring(0, Math.min(precision - fence, r.length()));
+
+ if (width > 0) {
+ final int half = width >> 1;
+ if (l.length() < half) {
+ l = pad(flags, l, half);
+ }
+
+ if (r.length() < half) {
+ r = pad(flags, r, half);
+ }
+ }
+
+ Object[] empty = Collections.emptySet().toArray();
+ formatter.format(l, empty);
+ if (l.length() != 0 && r.length() != 0) {
+ formatter.format("|", empty);
+ }
+ formatter.format(r, empty);
+ }
+
+ /**
+ * Pad the given input string.
+ *
+ * @param flags the formatter flags.
+ * @param s the string to pad.
+ * @param length the final string length.
+ * @return the padded string.
+ */
+ private String pad(int flags, String s, int length) {
+ final int padding = length - s.length();
+ final StringBuilder b = new StringBuilder(length);
+ if ((flags & java.util.FormattableFlags.LEFT_JUSTIFY)
+ == java.util.FormattableFlags.LEFT_JUSTIFY) {
+ for (int i = 0; i < padding; ++i) {
+ b.append('\u0020');
+ }
+ b.append(s);
+ } else {
+ b.append(s);
+ for (int i = 0; i < padding; ++i) {
+ b.append('\u0020');
+ }
+ }
+ return b.toString();
+ }
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/util/logging/DurationFilter.java b/current/src/main/java/com/sun/mail/util/logging/DurationFilter.java
index 673c25a..f74c30d 100644
--- a/current/src/main/java/com/sun/mail/util/logging/DurationFilter.java
+++ b/current/src/main/java/com/sun/mail/util/logging/DurationFilter.java
@@ -1,468 +1,468 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2015-2016 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015-2016 Jason Mehrens. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package com.sun.mail.util.logging;
-
-import static com.sun.mail.util.logging.LogManagerProperties.fromLogManager;
-import java.util.logging.*;
-
-/**
- * A filter used to limit log records based on a maximum generation rate.
- *
- * The duration specified is used to compute the record rate and the amount of
- * time the filter will reject records once the rate has been exceeded. Once the
- * rate is exceeded records are not allowed until the duration has elapsed.
- *
- * <p>
- * By default each {@code DurationFilter} is initialized using the following
- * LogManager configuration properties where {@code <filter-name>} refers to the
- * fully qualified class name of the handler. If properties are not defined, or
- * contain invalid values, then the specified default values are used.
- *
- * <ul>
- * <li>{@literal <filter-name>}.records the max number of records per duration.
- * A numeric long integer or a multiplication expression can be used as the
- * value. (defaults to {@code 1000})
- *
- * <li>{@literal <filter-name>}.duration the number of milliseconds to suppress
- * log records from being published. This is also used as duration to determine
- * the log record rate. A numeric long integer or a multiplication expression
- * can be used as the value. If the {@code java.time} package is available then
- * an ISO-8601 duration format of {@code PnDTnHnMn.nS} can be used as the value.
- * The suffixes of "D", "H", "M" and "S" are for days, hours, minutes and
- * seconds. The suffixes must occur in order. The seconds can be specified with
- * a fractional component to declare milliseconds. (defaults to {@code PT15M})
- * </ul>
- *
- * <p>
- * For example, the settings to limit {@code MailHandler} with a default
- * capacity to only send a maximum of two email messages every six minutes would
- * be as follows:
- * <pre>
- * {@code
- * com.sun.mail.util.logging.MailHandler.filter = com.sun.mail.util.logging.DurationFilter
- * com.sun.mail.util.logging.MailHandler.capacity = 1000
- * com.sun.mail.util.logging.DurationFilter.records = 2L * 1000L
- * com.sun.mail.util.logging.DurationFilter.duration = PT6M
- * }
- * </pre>
- *
- *
- * @author Jason Mehrens
- * @since JavaMail 1.5.5
- */
-public class DurationFilter implements Filter {
-
- /**
- * The number of expected records per duration.
- */
- private final long records;
- /**
- * The duration in milliseconds used to determine the rate. The duration is
- * also used as the amount of time that the filter will not allow records
- * when saturated.
- */
- private final long duration;
- /**
- * The number of records seen for the current duration. This value negative
- * if saturated. Zero is considered saturated but is reserved for recording
- * the first duration.
- */
- private long count;
- /**
- * The most recent record time seen for the current duration.
- */
- private long peak;
- /**
- * The start time for the current duration.
- */
- private long start;
-
- /**
- * Creates the filter using the default properties.
- */
- public DurationFilter() {
- this.records = checkRecords(initLong(".records"));
- this.duration = checkDuration(initLong(".duration"));
- }
-
- /**
- * Creates the filter using the given properties. Default values are used if
- * any of the given values are outside the allowed range.
- *
- * @param records the number of records per duration.
- * @param duration the number of milliseconds to suppress log records from
- * being published.
- */
- public DurationFilter(final long records, final long duration) {
- this.records = checkRecords(records);
- this.duration = checkDuration(duration);
- }
-
- /**
- * Determines if this filter is equal to another filter.
- *
- * @param obj the given object.
- * @return true if equal otherwise false.
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) { //Avoid locks and deal with rapid state changes.
- return true;
- }
-
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
-
- final DurationFilter other = (DurationFilter) obj;
- if (this.records != other.records) {
- return false;
- }
-
- if (this.duration != other.duration) {
- return false;
- }
-
- final long c;
- final long p;
- final long s;
- synchronized (this) {
- c = this.count;
- p = this.peak;
- s = this.start;
- }
-
- synchronized (other) {
- if (c != other.count || p != other.peak || s != other.start) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Determines if this filter is able to accept the maximum number of log
- * records for this instant in time. The result is a best-effort estimate
- * and should be considered out of date as soon as it is produced. This
- * method is designed for use in monitoring the state of this filter.
- *
- * @return true if the filter is idle; false otherwise.
- */
- public boolean isIdle() {
- return test(0L, System.currentTimeMillis());
- }
-
- /**
- * Returns a hash code value for this filter.
- *
- * @return hash code for this filter.
- */
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 89 * hash + (int) (this.records ^ (this.records >>> 32));
- hash = 89 * hash + (int) (this.duration ^ (this.duration >>> 32));
- return hash;
- }
-
- /**
- * Check if the given log record should be published. This method will
- * modify the internal state of this filter.
- *
- * @param record the log record to check.
- * @return true if allowed; false otherwise.
- * @throws NullPointerException if given record is null.
- */
- @SuppressWarnings("override") //JDK-6954234
- public boolean isLoggable(final LogRecord record) {
- return accept(record.getMillis());
- }
-
- /**
- * Determines if this filter will accept log records for this instant in
- * time. The result is a best-effort estimate and should be considered out
- * of date as soon as it is produced. This method is designed for use in
- * monitoring the state of this filter.
- *
- * @return true if the filter is not saturated; false otherwise.
- */
- public boolean isLoggable() {
- return test(records, System.currentTimeMillis());
- }
-
- /**
- * Returns a string representation of this filter. The result is a
- * best-effort estimate and should be considered out of date as soon as it
- * is produced.
- *
- * @return a string representation of this filter.
- */
- @Override
- public String toString() {
- boolean idle;
- boolean loggable;
- synchronized (this) {
- final long millis = System.currentTimeMillis();
- idle = test(0L, millis);
- loggable = test(records, millis);
- }
-
- return getClass().getName() + "{records=" + records
- + ", duration=" + duration
- + ", idle=" + idle
- + ", loggable=" + loggable + '}';
- }
-
- /**
- * Creates a copy of this filter that retains the filter settings but does
- * not include the current filter state. The newly create clone acts as if
- * it has never seen any records.
- *
- * @return a copy of this filter.
- * @throws CloneNotSupportedException if this filter is not allowed to be
- * cloned.
- */
- @Override
- protected DurationFilter clone() throws CloneNotSupportedException {
- final DurationFilter clone = (DurationFilter) super.clone();
- clone.count = 0L; //Reset the filter state.
- clone.peak = 0L;
- clone.start = 0L;
- return clone;
- }
-
- /**
- * Checks if this filter is not saturated or bellow a maximum rate.
- *
- * @param limit the number of records allowed to be under the rate.
- * @param millis the current time in milliseconds.
- * @return true if not saturated or bellow the rate.
- */
- private boolean test(final long limit, final long millis) {
- assert limit >= 0L : limit;
- final long c;
- final long s;
- synchronized (this) {
- c = count;
- s = start;
- }
-
- if (c > 0L) { //If not saturated.
- if ((millis - s) >= duration || c < limit) {
- return true;
- }
- } else { //Subtraction is used to deal with numeric overflow.
- if ((millis - s) >= 0L || c == 0L) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Determines if the record is loggable by time.
- *
- * @param millis the log record milliseconds.
- * @return true if accepted false otherwise.
- */
- private synchronized boolean accept(final long millis) {
- //Subtraction is used to deal with numeric overflow of millis.
- boolean allow;
- if (count > 0L) { //If not saturated.
- if ((millis - peak) > 0L) {
- peak = millis; //Record the new peak.
- }
-
- //Under the rate if the count has not been reached.
- if (count != records) {
- ++count;
- allow = true;
- } else {
- if ((peak - start) >= duration) {
- count = 1L; //Start a new duration.
- start = peak;
- allow = true;
- } else {
- count = -1L; //Saturate for the duration.
- start = peak + duration;
- allow = false;
- }
- }
- } else {
- //If the saturation period has expired or this is the first record
- //then start a new duration and allow records.
- if ((millis - start) >= 0L || count == 0L) {
- count = 1L;
- start = millis;
- peak = millis;
- allow = true;
- } else {
- allow = false; //Remain in a saturated state.
- }
- }
- return allow;
- }
-
- /**
- * Reads a long value or multiplication expression from the LogManager. If
- * the value can not be parsed or is not defined then Long.MIN_VALUE is
- * returned.
- *
- * @param suffix a dot character followed by the key name.
- * @return a long value or Long.MIN_VALUE if unable to parse or undefined.
- * @throws NullPointerException if suffix is null.
- */
- private long initLong(final String suffix) {
- long result = 0L;
- final String p = getClass().getName();
- String value = fromLogManager(p.concat(suffix));
- if (value != null && value.length() != 0) {
- value = value.trim();
- if (isTimeEntry(suffix, value)) {
- try {
- result = LogManagerProperties.parseDurationToMillis(value);
- } catch (final RuntimeException ignore) {
- } catch (final Exception ignore) {
- } catch (final LinkageError ignore) {
- }
- }
-
- if (result == 0L) { //Zero is invalid.
- try {
- result = 1L;
- for (String s : tokenizeLongs(value)) {
- if (s.endsWith("L") || s.endsWith("l")) {
- s = s.substring(0, s.length() - 1);
- }
- result = multiplyExact(result, Long.parseLong(s));
- }
- } catch (final RuntimeException ignore) {
- result = Long.MIN_VALUE;
- }
- }
- } else {
- result = Long.MIN_VALUE;
- }
- return result;
- }
-
- /**
- * Determines if the given suffix can be a time unit and the value is
- * encoded as an ISO ISO-8601 duration format.
- *
- * @param suffix the suffix property.
- * @param value the value of the property.
- * @return true if the entry is a time entry.
- * @throws IndexOutOfBoundsException if value is empty.
- * @throws NullPointerException if either argument is null.
- */
- private boolean isTimeEntry(final String suffix, final String value) {
- return (value.charAt(0) == 'P' || value.charAt(0) == 'p')
- && suffix.equals(".duration");
- }
-
- /**
- * Parse any long value or multiplication expressions into tokens.
- *
- * @param value the expression or value.
- * @return an array of long tokens, never empty.
- * @throws NullPointerException if the given value is null.
- * @throws NumberFormatException if the expression is invalid.
- */
- private static String[] tokenizeLongs(final String value) {
- String[] e;
- final int i = value.indexOf('*');
- if (i > -1 && (e = value.split("\\s*\\*\\s*")).length != 0) {
- if (i == 0 || value.charAt(value.length() - 1) == '*') {
- throw new NumberFormatException(value);
- }
-
- if (e.length == 1) {
- throw new NumberFormatException(e[0]);
- }
- } else {
- e = new String[]{value};
- }
- return e;
- }
-
- /**
- * Multiply and check for overflow. This can be replaced with
- * {@code java.lang.Math.multiplyExact} when JavaMail requires JDK 8.
- *
- * @param x the first value.
- * @param y the second value.
- * @return x times y.
- * @throws ArithmeticException if overflow is detected.
- */
- private static long multiplyExact(final long x, final long y) {
- long r = x * y;
- if (((Math.abs(x) | Math.abs(y)) >>> 31L != 0L)) {
- if (((y != 0L) && (r / y != x))
- || (x == Long.MIN_VALUE && y == -1L)) {
- throw new ArithmeticException();
- }
- }
- return r;
- }
-
- /**
- * Converts record count to a valid record count. If the value is out of
- * bounds then the default record count is used.
- *
- * @param records the record count.
- * @return a valid number of record count.
- */
- private static long checkRecords(final long records) {
- return records > 0L ? records : 1000L;
- }
-
- /**
- * Converts the duration to a valid duration. If the value is out of bounds
- * then the default duration is used.
- *
- * @param duration the duration to check.
- * @return a valid duration.
- */
- private static long checkDuration(final long duration) {
- return duration > 0L ? duration : 15L * 60L * 1000L;
- }
-}
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015-2017 Jason Mehrens. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package com.sun.mail.util.logging;
+
+import static com.sun.mail.util.logging.LogManagerProperties.fromLogManager;
+import java.util.logging.*;
+
+/**
+ * A filter used to limit log records based on a maximum generation rate.
+ *
+ * The duration specified is used to compute the record rate and the amount of
+ * time the filter will reject records once the rate has been exceeded. Once the
+ * rate is exceeded records are not allowed until the duration has elapsed.
+ *
+ * <p>
+ * By default each {@code DurationFilter} is initialized using the following
+ * LogManager configuration properties where {@code <filter-name>} refers to the
+ * fully qualified class name of the handler. If properties are not defined, or
+ * contain invalid values, then the specified default values are used.
+ *
+ * <ul>
+ * <li>{@literal <filter-name>}.records the max number of records per duration.
+ * A numeric long integer or a multiplication expression can be used as the
+ * value. (defaults to {@code 1000})
+ *
+ * <li>{@literal <filter-name>}.duration the number of milliseconds to suppress
+ * log records from being published. This is also used as duration to determine
+ * the log record rate. A numeric long integer or a multiplication expression
+ * can be used as the value. If the {@code java.time} package is available then
+ * an ISO-8601 duration format of {@code PnDTnHnMn.nS} can be used as the value.
+ * The suffixes of "D", "H", "M" and "S" are for days, hours, minutes and
+ * seconds. The suffixes must occur in order. The seconds can be specified with
+ * a fractional component to declare milliseconds. (defaults to {@code PT15M})
+ * </ul>
+ *
+ * <p>
+ * For example, the settings to limit {@code MailHandler} with a default
+ * capacity to only send a maximum of two email messages every six minutes would
+ * be as follows:
+ * <pre>
+ * {@code
+ * com.sun.mail.util.logging.MailHandler.filter = com.sun.mail.util.logging.DurationFilter
+ * com.sun.mail.util.logging.MailHandler.capacity = 1000
+ * com.sun.mail.util.logging.DurationFilter.records = 2L * 1000L
+ * com.sun.mail.util.logging.DurationFilter.duration = PT6M
+ * }
+ * </pre>
+ *
+ *
+ * @author Jason Mehrens
+ * @since JavaMail 1.5.5
+ */
+public class DurationFilter implements Filter {
+
+ /**
+ * The number of expected records per duration.
+ */
+ private final long records;
+ /**
+ * The duration in milliseconds used to determine the rate. The duration is
+ * also used as the amount of time that the filter will not allow records
+ * when saturated.
+ */
+ private final long duration;
+ /**
+ * The number of records seen for the current duration. This value negative
+ * if saturated. Zero is considered saturated but is reserved for recording
+ * the first duration.
+ */
+ private long count;
+ /**
+ * The most recent record time seen for the current duration.
+ */
+ private long peak;
+ /**
+ * The start time for the current duration.
+ */
+ private long start;
+
+ /**
+ * Creates the filter using the default properties.
+ */
+ public DurationFilter() {
+ this.records = checkRecords(initLong(".records"));
+ this.duration = checkDuration(initLong(".duration"));
+ }
+
+ /**
+ * Creates the filter using the given properties. Default values are used if
+ * any of the given values are outside the allowed range.
+ *
+ * @param records the number of records per duration.
+ * @param duration the number of milliseconds to suppress log records from
+ * being published.
+ */
+ public DurationFilter(final long records, final long duration) {
+ this.records = checkRecords(records);
+ this.duration = checkDuration(duration);
+ }
+
+ /**
+ * Determines if this filter is equal to another filter.
+ *
+ * @param obj the given object.
+ * @return true if equal otherwise false.
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) { //Avoid locks and deal with rapid state changes.
+ return true;
+ }
+
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final DurationFilter other = (DurationFilter) obj;
+ if (this.records != other.records) {
+ return false;
+ }
+
+ if (this.duration != other.duration) {
+ return false;
+ }
+
+ final long c;
+ final long p;
+ final long s;
+ synchronized (this) {
+ c = this.count;
+ p = this.peak;
+ s = this.start;
+ }
+
+ synchronized (other) {
+ if (c != other.count || p != other.peak || s != other.start) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Determines if this filter is able to accept the maximum number of log
+ * records for this instant in time. The result is a best-effort estimate
+ * and should be considered out of date as soon as it is produced. This
+ * method is designed for use in monitoring the state of this filter.
+ *
+ * @return true if the filter is idle; false otherwise.
+ */
+ public boolean isIdle() {
+ return test(0L, System.currentTimeMillis());
+ }
+
+ /**
+ * Returns a hash code value for this filter.
+ *
+ * @return hash code for this filter.
+ */
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 89 * hash + (int) (this.records ^ (this.records >>> 32));
+ hash = 89 * hash + (int) (this.duration ^ (this.duration >>> 32));
+ return hash;
+ }
+
+ /**
+ * Check if the given log record should be published. This method will
+ * modify the internal state of this filter.
+ *
+ * @param record the log record to check.
+ * @return true if allowed; false otherwise.
+ * @throws NullPointerException if given record is null.
+ */
+ @SuppressWarnings("override") //JDK-6954234
+ public boolean isLoggable(final LogRecord record) {
+ return accept(record.getMillis());
+ }
+
+ /**
+ * Determines if this filter will accept log records for this instant in
+ * time. The result is a best-effort estimate and should be considered out
+ * of date as soon as it is produced. This method is designed for use in
+ * monitoring the state of this filter.
+ *
+ * @return true if the filter is not saturated; false otherwise.
+ */
+ public boolean isLoggable() {
+ return test(records, System.currentTimeMillis());
+ }
+
+ /**
+ * Returns a string representation of this filter. The result is a
+ * best-effort estimate and should be considered out of date as soon as it
+ * is produced.
+ *
+ * @return a string representation of this filter.
+ */
+ @Override
+ public String toString() {
+ boolean idle;
+ boolean loggable;
+ synchronized (this) {
+ final long millis = System.currentTimeMillis();
+ idle = test(0L, millis);
+ loggable = test(records, millis);
+ }
+
+ return getClass().getName() + "{records=" + records
+ + ", duration=" + duration
+ + ", idle=" + idle
+ + ", loggable=" + loggable + '}';
+ }
+
+ /**
+ * Creates a copy of this filter that retains the filter settings but does
+ * not include the current filter state. The newly create clone acts as if
+ * it has never seen any records.
+ *
+ * @return a copy of this filter.
+ * @throws CloneNotSupportedException if this filter is not allowed to be
+ * cloned.
+ */
+ @Override
+ protected DurationFilter clone() throws CloneNotSupportedException {
+ final DurationFilter clone = (DurationFilter) super.clone();
+ clone.count = 0L; //Reset the filter state.
+ clone.peak = 0L;
+ clone.start = 0L;
+ return clone;
+ }
+
+ /**
+ * Checks if this filter is not saturated or bellow a maximum rate.
+ *
+ * @param limit the number of records allowed to be under the rate.
+ * @param millis the current time in milliseconds.
+ * @return true if not saturated or bellow the rate.
+ */
+ private boolean test(final long limit, final long millis) {
+ assert limit >= 0L : limit;
+ final long c;
+ final long s;
+ synchronized (this) {
+ c = count;
+ s = start;
+ }
+
+ if (c > 0L) { //If not saturated.
+ if ((millis - s) >= duration || c < limit) {
+ return true;
+ }
+ } else { //Subtraction is used to deal with numeric overflow.
+ if ((millis - s) >= 0L || c == 0L) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determines if the record is loggable by time.
+ *
+ * @param millis the log record milliseconds.
+ * @return true if accepted false otherwise.
+ */
+ private synchronized boolean accept(final long millis) {
+ //Subtraction is used to deal with numeric overflow of millis.
+ boolean allow;
+ if (count > 0L) { //If not saturated.
+ if ((millis - peak) > 0L) {
+ peak = millis; //Record the new peak.
+ }
+
+ //Under the rate if the count has not been reached.
+ if (count != records) {
+ ++count;
+ allow = true;
+ } else {
+ if ((peak - start) >= duration) {
+ count = 1L; //Start a new duration.
+ start = peak;
+ allow = true;
+ } else {
+ count = -1L; //Saturate for the duration.
+ start = peak + duration;
+ allow = false;
+ }
+ }
+ } else {
+ //If the saturation period has expired or this is the first record
+ //then start a new duration and allow records.
+ if ((millis - start) >= 0L || count == 0L) {
+ count = 1L;
+ start = millis;
+ peak = millis;
+ allow = true;
+ } else {
+ allow = false; //Remain in a saturated state.
+ }
+ }
+ return allow;
+ }
+
+ /**
+ * Reads a long value or multiplication expression from the LogManager. If
+ * the value can not be parsed or is not defined then Long.MIN_VALUE is
+ * returned.
+ *
+ * @param suffix a dot character followed by the key name.
+ * @return a long value or Long.MIN_VALUE if unable to parse or undefined.
+ * @throws NullPointerException if suffix is null.
+ */
+ private long initLong(final String suffix) {
+ long result = 0L;
+ final String p = getClass().getName();
+ String value = fromLogManager(p.concat(suffix));
+ if (value != null && value.length() != 0) {
+ value = value.trim();
+ if (isTimeEntry(suffix, value)) {
+ try {
+ result = LogManagerProperties.parseDurationToMillis(value);
+ } catch (final RuntimeException ignore) {
+ } catch (final Exception ignore) {
+ } catch (final LinkageError ignore) {
+ }
+ }
+
+ if (result == 0L) { //Zero is invalid.
+ try {
+ result = 1L;
+ for (String s : tokenizeLongs(value)) {
+ if (s.endsWith("L") || s.endsWith("l")) {
+ s = s.substring(0, s.length() - 1);
+ }
+ result = multiplyExact(result, Long.parseLong(s));
+ }
+ } catch (final RuntimeException ignore) {
+ result = Long.MIN_VALUE;
+ }
+ }
+ } else {
+ result = Long.MIN_VALUE;
+ }
+ return result;
+ }
+
+ /**
+ * Determines if the given suffix can be a time unit and the value is
+ * encoded as an ISO ISO-8601 duration format.
+ *
+ * @param suffix the suffix property.
+ * @param value the value of the property.
+ * @return true if the entry is a time entry.
+ * @throws IndexOutOfBoundsException if value is empty.
+ * @throws NullPointerException if either argument is null.
+ */
+ private boolean isTimeEntry(final String suffix, final String value) {
+ return (value.charAt(0) == 'P' || value.charAt(0) == 'p')
+ && suffix.equals(".duration");
+ }
+
+ /**
+ * Parse any long value or multiplication expressions into tokens.
+ *
+ * @param value the expression or value.
+ * @return an array of long tokens, never empty.
+ * @throws NullPointerException if the given value is null.
+ * @throws NumberFormatException if the expression is invalid.
+ */
+ private static String[] tokenizeLongs(final String value) {
+ String[] e;
+ final int i = value.indexOf('*');
+ if (i > -1 && (e = value.split("\\s*\\*\\s*")).length != 0) {
+ if (i == 0 || value.charAt(value.length() - 1) == '*') {
+ throw new NumberFormatException(value);
+ }
+
+ if (e.length == 1) {
+ throw new NumberFormatException(e[0]);
+ }
+ } else {
+ e = new String[]{value};
+ }
+ return e;
+ }
+
+ /**
+ * Multiply and check for overflow. This can be replaced with
+ * {@code java.lang.Math.multiplyExact} when JavaMail requires JDK 8.
+ *
+ * @param x the first value.
+ * @param y the second value.
+ * @return x times y.
+ * @throws ArithmeticException if overflow is detected.
+ */
+ private static long multiplyExact(final long x, final long y) {
+ long r = x * y;
+ if (((Math.abs(x) | Math.abs(y)) >>> 31L != 0L)) {
+ if (((y != 0L) && (r / y != x))
+ || (x == Long.MIN_VALUE && y == -1L)) {
+ throw new ArithmeticException();
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Converts record count to a valid record count. If the value is out of
+ * bounds then the default record count is used.
+ *
+ * @param records the record count.
+ * @return a valid number of record count.
+ */
+ private static long checkRecords(final long records) {
+ return records > 0L ? records : 1000L;
+ }
+
+ /**
+ * Converts the duration to a valid duration. If the value is out of bounds
+ * then the default duration is used.
+ *
+ * @param duration the duration to check.
+ * @return a valid duration.
+ */
+ private static long checkDuration(final long duration) {
+ return duration > 0L ? duration : 15L * 60L * 1000L;
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java b/current/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
index a71ff1e..25b2072 100644
--- a/current/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
+++ b/current/src/main/java/com/sun/mail/util/logging/LogManagerProperties.java
@@ -1,20 +1,20 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2009-2016 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2009-2016 Jason Mehrens. All rights reserved.
+ * Copyright (c) 2009-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2017 Jason Mehrens. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -666,7 +666,7 @@
final Class<?> thisClass = LogManagerProperties.class;
assert Modifier.isFinal(thisClass.getModifiers()) : thisClass;
try {
- final HashSet<String> traces = new HashSet<String>();
+ final HashSet<String> traces = new HashSet<>();
Throwable t = Throwable.class.getConstructor().newInstance();
for (StackTraceElement ste : t.getStackTrace()) {
if (!thisClass.getName().equals(ste.getClassName())) {
diff --git a/current/src/main/java/com/sun/mail/util/logging/MailHandler.java b/current/src/main/java/com/sun/mail/util/logging/MailHandler.java
index 18c36bd..e6879ba 100644
--- a/current/src/main/java/com/sun/mail/util/logging/MailHandler.java
+++ b/current/src/main/java/com/sun/mail/util/logging/MailHandler.java
@@ -1,20 +1,20 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2009-2016 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2009-2016 Jason Mehrens. All rights reserved.
+ * Copyright (c) 2009-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2017 Jason Mehrens. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -43,7 +43,6 @@
import static com.sun.mail.util.logging.LogManagerProperties.fromLogManager;
import java.io.*;
-import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.URLConnection;
@@ -125,8 +124,8 @@
* attachment. (default is no attachments)
*
* <li><handler-name>.attachment.names a comma separated
- * list of names or <tt>Formatter</tt> class names of each attachment. The
- * attachment file names must not contain any line breaks.
+ * list of names or <tt>Formatter</tt> class names of each attachment. All
+ * control characters are removed from the attachment names.
* (default is {@linkplain java.util.logging.Formatter#toString() toString}
* of the attachment formatter)
*
@@ -216,8 +215,9 @@
*
* <li><handler-name>.subject the name of a
* <tt>Formatter</tt> class or string literal used to create the subject line.
- * The empty string can be used to specify no subject. The subject line must
- * not contain any line breaks. (defaults to the empty string)
+ * The empty string can be used to specify no subject. All control characters
+ * are removed from the subject line. (defaults to {@linkplain
+ * com.sun.mail.util.logging.CollectorFormatter CollectorFormatter}.)
*
* <li><handler-name>.pushFilter the name of a
* <tt>Filter</tt> class used to trigger an early push.
@@ -238,9 +238,12 @@
* <li>If set to a value of <tt>resolve</tt>, the <tt>Handler</tt> will
* verify all local settings and try to resolve the remote host name with
* the domain name server.
+ * <li>If set to a value of <tt>login</tt>, the <tt>Handler</tt> will
+ * verify all local settings and try to establish a connection with
+ * the email server.
* <li>If set to a value of <tt>remote</tt>, the <tt>Handler</tt> will
- * verify all local settings and try to establish a connection with the
- * email server.
+ * verify all local settings, try to establish a connection with the
+ * email server, and try to verify the envelope of the email message.
* </ul>
* If this <tt>Handler</tt> is only implicitly closed by the
* <tt>LogManager</tt>, then verification should be turned on.
@@ -295,17 +298,18 @@
*
* <p>
* <b>Attachments:</b>
- * This <tt>Handler</tt> allows multiple attachments per each email.
- * The attachment order maps directly to the array index order in this
- * <tt>Handler</tt> with zero index being the first attachment. The number of
- * attachment formatters controls the number of attachments per email and
- * the content type of each attachment. The attachment filters determine if a
- * <tt>LogRecord</tt> will be included in an attachment. If an attachment
- * filter is <tt>null</tt> then all records are included for that attachment.
- * Attachments without content will be omitted from email message. The
- * attachment name formatters create the file name for an attachment.
- * Custom attachment name formatters can be used to generate an attachment name
- * based on the contents of the attachment.
+ * This <tt>Handler</tt> allows multiple attachments per each email message.
+ * The presence of an attachment formatter will change the content type of the
+ * email message to a multi-part message. The attachment order maps directly to
+ * the array index order in this <tt>Handler</tt> with zero index being the
+ * first attachment. The number of attachment formatters controls the number of
+ * attachments per email and the content type of each attachment. The
+ * attachment filters determine if a <tt>LogRecord</tt> will be included in an
+ * attachment. If an attachment filter is <tt>null</tt> then all records are
+ * included for that attachment. Attachments without content will be omitted
+ * from email message. The attachment name formatters create the file name for
+ * an attachment. Custom attachment name formatters can be used to generate an
+ * attachment name based on the contents of the attachment.
*
* <p>
* <b>Push Level and Push Filter:</b>
@@ -391,7 +395,7 @@
* 4. MUTEX_REPORT when cycle of records is detected.
* 5. MUTEXT_LINKAGE when a linkage error is reported.
*/
- private static final ThreadLocal<Integer> MUTEX = new ThreadLocal<Integer>();
+ private static final ThreadLocal<Integer> MUTEX = new ThreadLocal<>();
/**
* The marker object used to report a publishing state.
* This must be less than the body filter index (-1).
@@ -427,7 +431,7 @@
/**
* Holds the session object used to generate emails.
* Sessions can be shared by multiple threads.
- * See BUGID 6228391 and K 6278.
+ * See JDK-6228391 and K 6278.
*/
private Session session;
/**
@@ -970,8 +974,7 @@
this.errorManager = em;
super.setErrorManager(em); //Try to free super error manager.
}
- } catch (final RuntimeException ignore) {
- } catch (final LinkageError ignore) {
+ } catch (RuntimeException | LinkageError ignore) {
}
}
@@ -1003,7 +1006,7 @@
if (newFilter != filter) {
clearMatches(-1);
}
- this.filter = newFilter;
+ this.filter = newFilter; //Volatile access.
}
}
@@ -1210,7 +1213,9 @@
/**
* Sets the <tt>Authenticator</tt> used to login to the email server.
- * @param password a password or null if none is required.
+ * @param password a password, empty array can be used to only supply a
+ * user name set by <tt>mail.user</tt> property, or null if no credentials
+ * are required.
* @throws SecurityException if a security manager exists and the
* caller does not have <tt>LoggingPermission("control")</tt>.
* @throws IllegalStateException if called from inside a push.
@@ -1228,6 +1233,9 @@
/**
* A private hook to handle possible future overrides. See public method.
* @param auth see public method.
+ * @throws SecurityException if a security manager exists and the
+ * caller does not have <tt>LoggingPermission("control")</tt>.
+ * @throws IllegalStateException if called from inside a push.
*/
private void setAuthenticator0(final Authenticator auth) {
checkAccess();
@@ -1319,7 +1327,7 @@
if (filters.length == 0) {
filters = emptyFilterArray();
} else {
- filters = copyOf(filters, filters.length, Filter[].class);
+ filters = Arrays.copyOf(filters, filters.length, Filter[].class);
}
synchronized (this) {
if (this.attachmentFormatters.length != filters.length) {
@@ -1372,7 +1380,7 @@
if (formatters.length == 0) { //Null check and length check.
formatters = emptyFormatterArray();
} else {
- formatters = copyOf(formatters,
+ formatters = Arrays.copyOf(formatters,
formatters.length, Formatter[].class);
for (int i = 0; i < formatters.length; ++i) {
if (formatters[i] == null) {
@@ -1408,8 +1416,8 @@
}
/**
- * Sets the attachment file name for each attachment. The caller must
- * ensure that the attachment file names do not contain any line breaks.
+ * Sets the attachment file name for each attachment. All control
+ * characters are removed from the attachment names.
* This method will create a set of custom formatters.
* @param names an array of names.
* @throws SecurityException if a security manager exists and the
@@ -1464,10 +1472,10 @@
* typically return an empty string. Instead of being used to format
* records, it is used to gather information about the contents of an
* attachment. The <tt>getTail</tt> method should be used to construct the
- * attachment file name and reset any formatter collected state. The
- * formatter must ensure that the attachment file name does not contain any
- * line breaks. The <tt>toString</tt> method of the given formatter should
- * be overridden to provide a useful attachment file name, if possible.
+ * attachment file name and reset any formatter collected state. All
+ * control characters will be removed from the output of the formatter. The
+ * <tt>toString</tt> method of the given formatter should be overridden to
+ * provide a useful attachment file name, if possible.
* @param formatters and array of attachment name formatters.
* @throws SecurityException if a security manager exists and the
* caller does not have <tt>LoggingPermission("control")</tt>.
@@ -1484,7 +1492,8 @@
if (formatters.length == 0) {
formatters = emptyFormatterArray();
} else {
- formatters = copyOf(formatters, formatters.length, Formatter[].class);
+ formatters = Arrays.copyOf(formatters, formatters.length,
+ Formatter[].class);
}
for (int i = 0; i < formatters.length; ++i) {
@@ -1495,7 +1504,8 @@
synchronized (this) {
if (this.attachmentFormatters.length != formatters.length) {
- throw attachmentMismatch(this.attachmentFormatters.length, formatters.length);
+ throw attachmentMismatch(this.attachmentFormatters.length,
+ formatters.length);
}
if (isWriting) {
@@ -1517,8 +1527,8 @@
}
/**
- * Sets a literal string for the email subject. The caller must ensure that
- * the subject line does not contain any line breaks.
+ * Sets a literal string for the email subject. All control characters are
+ * removed from the subject line.
* @param subject a non <tt>null</tt> string.
* @throws SecurityException if a security manager exists and the
* caller does not have <tt>LoggingPermission("control")</tt>.
@@ -1543,8 +1553,8 @@
* empty string. This formatter is used to gather information to create a
* summary about what information is contained in the email. The
* <tt>getTail</tt> method should be used to construct the subject and reset
- * any formatter collected state. The formatter must ensure that the
- * subject line does not contain any line breaks. The <tt>toString</tt>
+ * any formatter collected state. All control characters
+ * will be removed from the formatter output. The <tt>toString</tt>
* method of the given formatter should be overridden to provide a useful
* subject, if possible.
* @param format the subject formatter.
@@ -1588,9 +1598,7 @@
} else {
errorManager.error(null, ex, code);
}
- } catch (final RuntimeException GLASSFISH_21258) {
- reportLinkageError(GLASSFISH_21258, code);
- } catch (final LinkageError GLASSFISH_21258) {
+ } catch (RuntimeException | LinkageError GLASSFISH_21258) {
reportLinkageError(GLASSFISH_21258, code);
}
}
@@ -1610,20 +1618,19 @@
* this type of conversion. Currently, this is only used for the body
* since the attachments are computed by filename.
* Package-private for unit testing.
- * @param head any head string.
+ * @param chunk any char sequence or null.
* @return return the mime type or null for text/plain.
*/
- final String contentTypeOf(String head) {
- if (!isEmpty(head)) {
+ final String contentTypeOf(CharSequence chunk) {
+ if (!isEmpty(chunk)) {
final int MAX_CHARS = 25;
- if (head.length() > MAX_CHARS) {
- head = head.substring(0, MAX_CHARS);
+ if (chunk.length() > MAX_CHARS) {
+ chunk = chunk.subSequence(0, MAX_CHARS);
}
try {
final String charset = getEncodingName();
- final ByteArrayInputStream in
- = new ByteArrayInputStream(head.getBytes(charset));
-
+ final byte[] b = chunk.toString().getBytes(charset);
+ final ByteArrayInputStream in = new ByteArrayInputStream(b);
assert in.markSupported() : in.getClass().getName();
return URLConnection.guessContentTypeFromStream(in);
} catch (final IOException IOE) {
@@ -1641,14 +1648,26 @@
* Package-private for unit testing.
*
* @param f the formatter or null.
- * @return return the mime type or text/plain.
+ * @return return the mime type or null, meaning text/plain.
* @since JavaMail 1.5.6
*/
final String contentTypeOf(final Formatter f) {
+ assert Thread.holdsLock(this);
if (f != null) {
+ String type = getContentType(f.getClass().getName());
+ if (type != null) {
+ return type;
+ }
+
for (Class<?> k = f.getClass(); k != Formatter.class;
k = k.getSuperclass()) {
- String name = k.getName().toLowerCase(Locale.ENGLISH);
+ String name;
+ try {
+ name = k.getSimpleName();
+ } catch (final InternalError JDK8057919) {
+ name = k.getName();
+ }
+ name = name.toLowerCase(Locale.ENGLISH);
for (int idx = name.indexOf('$') + 1;
(idx = name.indexOf("ml", idx)) > -1; idx += 2) {
if (idx > 0) {
@@ -1663,7 +1682,7 @@
}
}
}
- return "text/plain";
+ return null;
}
/**
@@ -1688,11 +1707,26 @@
} catch (final Exception noContent) {
final String txt = noContent.getMessage();
if (!isEmpty(txt)) {
- for (; t != null; t = t.getCause()) {
+ int limit = 0;
+ while (t != null) {
if (noContent.getClass() == t.getClass()
&& txt.equals(t.getMessage())) {
return true;
}
+
+ //Not all JavaMail implementations support JDK 1.4 exception
+ //chaining.
+ final Throwable cause = t.getCause();
+ if (cause == null && t instanceof MessagingException) {
+ t = ((MessagingException) t).getNextException();
+ } else {
+ t = cause;
+ }
+
+ //Deal with excessive cause chains and cyclic throwables.
+ if (++limit == (1 << 16)) {
+ break; //Give up.
+ }
}
}
} finally {
@@ -1746,8 +1780,7 @@
try {
Thread.currentThread().getUncaughtExceptionHandler()
.uncaughtException(Thread.currentThread(), le);
- } catch (final RuntimeException ignore) {
- } catch (final LinkageError ignore) {
+ } catch (RuntimeException | LinkageError ignore) {
} finally {
if (idx != null) {
MUTEX.set(idx);
@@ -1790,10 +1823,10 @@
* Set the content for a part using the encoding assigned to the handler.
* @param part the part to assign.
* @param buf the formatted data.
- * @param type the mime type.
+ * @param type the mime type or null, meaning text/plain.
* @throws MessagingException if there is a problem.
*/
- private void setContent(MimeBodyPart part, CharSequence buf, String type) throws MessagingException {
+ private void setContent(MimePart part, CharSequence buf, String type) throws MessagingException {
final String charset = getEncodingName();
if (type != null && !"text/plain".equalsIgnoreCase(type)) {
type = contentWithEncoding(type, charset);
@@ -1821,7 +1854,7 @@
final ContentType ct = new ContentType(type);
ct.setParameter("charset", MimeUtility.mimeCharset(encoding));
encoding = ct.toString(); //See javax.mail.internet.ContentType.
- if (!isEmpty(encoding)) {
+ if (!isEmpty(encoding)) { //Support pre K5687.
type = encoding;
}
} catch (final MessagingException ME) {
@@ -1895,7 +1928,7 @@
final int expect = this.attachmentFormatters.length;
final int current = this.attachmentNames.length;
if (current != expect) {
- this.attachmentNames = copyOf(attachmentNames, expect,
+ this.attachmentNames = Arrays.copyOf(attachmentNames, expect,
Formatter[].class);
fixed = current != 0;
}
@@ -1926,7 +1959,7 @@
final int expect = this.attachmentFormatters.length;
final int current = this.attachmentFilters.length;
if (current != expect) {
- this.attachmentFilters = copyOf(attachmentFilters, expect,
+ this.attachmentFilters = Arrays.copyOf(attachmentFilters, expect,
Filter[].class);
clearMatches(current);
fixed = current != 0;
@@ -1950,36 +1983,6 @@
}
/**
- * Copies the given array. Can be removed when Java Mail requires Java 1.6.
- * @param a the original array.
- * @param len the new size.
- * @return new copy
- * @since JavaMail 1.5.5
- */
- private static int[] copyOf(final int[] a, final int len) {
- final int[] copy = new int[len];
- System.arraycopy(a, 0, copy, 0, Math.min(len, a.length));
- return copy;
- }
-
- /**
- * Copies the given array to a new array type.
- * Can be removed when Java Mail requires Java 1.6.
- * @param <U> the class of the objects in the original array
- * @param <T> the class of the objects in the returned array
- * @param a the original array.
- * @param len the new size.
- * @param type the array type.
- * @return new copy
- */
- @SuppressWarnings("unchecked")
- private static <T,U> T[] copyOf(U[] a, int len, Class<? extends T[]> type) {
- final T[] copy = (T[]) Array.newInstance(type.getComponentType(), len);
- System.arraycopy(a, 0, copy, 0, Math.min(len, a.length));
- return copy;
- }
-
- /**
* Sets the size to zero and clears the current buffer.
*/
private void reset() {
@@ -2003,8 +2006,8 @@
newCapacity = capacity;
}
assert len != capacity : len;
- this.data = copyOf(data, newCapacity, LogRecord[].class);
- this.matched = copyOf(matched, newCapacity);
+ this.data = Arrays.copyOf(data, newCapacity, LogRecord[].class);
+ this.matched = Arrays.copyOf(matched, newCapacity);
}
/**
@@ -2063,7 +2066,7 @@
try {
Object canidate;
Object result;
- final Map<Object, Object> seen = new HashMap<Object, Object>();
+ final Map<Object, Object> seen = new HashMap<>();
try {
intern(seen, this.errorManager);
} catch (final SecurityException se) {
@@ -2216,11 +2219,11 @@
}
/**
- * Checks a string value for null or empty.
- * @param s the string.
+ * Checks a char sequence value for null or empty.
+ * @param s the char sequence.
* @return true if the given string is null or zero length.
*/
- private static boolean isEmpty(final String s) {
+ private static boolean isEmpty(final CharSequence s) {
return s == null || s.length() == 0;
}
@@ -2337,9 +2340,8 @@
try {
try {
a[i] = LogManagerProperties.newFormatter(names[i]);
- } catch (final ClassNotFoundException literal) {
- a[i] = TailNameFormatter.of(names[i]);
- } catch (final ClassCastException literal) {
+ } catch (ClassNotFoundException
+ | ClassCastException literal) {
a[i] = TailNameFormatter.of(names[i]);
}
} catch (final SecurityException SE) {
@@ -2380,9 +2382,8 @@
.newObjectFrom(name, Authenticator.class);
} catch (final SecurityException SE) {
throw SE;
- } catch (final ClassNotFoundException literalAuth) {
- this.auth = DefaultAuthenticator.of(name);
- } catch (final ClassCastException literalAuth) {
+ } catch (final ClassNotFoundException
+ | ClassCastException literalAuth) {
this.auth = DefaultAuthenticator.of(name);
} catch (final Exception E) {
reportError(E.getMessage(), E, ErrorManager.OPEN_FAILURE);
@@ -2481,10 +2482,8 @@
}
} catch (final SecurityException SE) {
throw SE; //Avoid catch all.
- } catch (final UnsupportedEncodingException UEE) {
+ } catch (UnsupportedEncodingException | RuntimeException UEE) {
reportError(UEE.getMessage(), UEE, ErrorManager.OPEN_FAILURE);
- } catch (final RuntimeException RE) {
- reportError(RE.getMessage(), RE, ErrorManager.OPEN_FAILURE);
}
}
@@ -2497,9 +2496,7 @@
ErrorManager em;
try { //Try to share the super error manager.
em = super.getErrorManager();
- } catch (final RuntimeException ignore) {
- em = null;
- } catch (final LinkageError ignore) {
+ } catch (RuntimeException | LinkageError ignore) {
em = null;
}
@@ -2641,27 +2638,24 @@
private void initSubject(final String p) {
assert Thread.holdsLock(this);
String name = fromLogManager(p.concat(".subject"));
+ if (name == null) { //Soft dependency on CollectorFormatter.
+ name = "com.sun.mail.util.logging.CollectorFormatter";
+ }
+
if (hasValue(name)) {
try {
this.subjectFormatter = LogManagerProperties.newFormatter(name);
} catch (final SecurityException SE) {
throw SE; //Avoid catch all.
- } catch (final ClassNotFoundException literalSubject) {
- this.subjectFormatter = TailNameFormatter.of(name);
- } catch (final ClassCastException literalSubject) {
+ } catch (ClassNotFoundException
+ | ClassCastException literalSubject) {
this.subjectFormatter = TailNameFormatter.of(name);
} catch (final Exception E) {
this.subjectFormatter = TailNameFormatter.of(name);
reportError(E.getMessage(), E, ErrorManager.OPEN_FAILURE);
}
- } else {
- if (name != null) {
- this.subjectFormatter = TailNameFormatter.of(name);
- }
- }
-
- if (this.subjectFormatter == null) { //Ensure not null.
- this.subjectFormatter = TailNameFormatter.of("");
+ } else { //User has forced empty or literal null.
+ this.subjectFormatter = TailNameFormatter.of(name);
}
}
@@ -2748,7 +2742,7 @@
try {
envelopeFor(msg, priority);
final Object ccl = getAndSetContextClassLoader(MAILHANDLER_LOADER);
- try { //BUGID 8025251
+ try { //JDK-8025251
Transport.send(msg); //Calls save changes.
} finally {
getAndSetContextClassLoader(ccl);
@@ -2833,7 +2827,6 @@
initSession();
}
MimeMessage msg = new MimeMessage(session);
- msg.setDescription(descriptionFrom(comparator, pushLevel, pushFilter));
/**
* Parts are lazily created when an attachment performs a getHead
@@ -2846,13 +2839,19 @@
* The buffers are lazily created when the part requires a getHead.
*/
StringBuilder[] buffers = new StringBuilder[parts.length];
-
- String contentType = null;
StringBuilder buf = null;
+ final MimePart body;
+ if (parts.length == 0) {
+ msg.setDescription(descriptionFrom(
+ getFormatter(), getFilter(), subjectFormatter));
+ body = msg;
+ } else {
+ msg.setDescription(descriptionFrom(
+ comparator, pushLevel, pushFilter));
+ body = createBodyPart();
+ }
appendSubject(msg, head(subjectFormatter));
-
- final MimeBodyPart body = createBodyPart();
final Formatter bodyFormat = getFormatter();
final Filter bodyFilter = getFilter();
@@ -2871,9 +2870,7 @@
lmf = bodyFilter;
if (buf == null) {
buf = new StringBuilder();
- final String head = head(bodyFormat);
- buf.append(head);
- contentType = contentTypeOf(head);
+ buf.append(head(bodyFormat));
}
formatted = true;
buf.append(format(bodyFormat, r));
@@ -2907,7 +2904,8 @@
}
if (formatted) {
- if (locale != null && !locale.equals(lastLocale)) {
+ if (body != msg && locale != null
+ && !locale.equals(lastLocale)) {
appendContentLang(msg, locale);
}
} else { //Belongs to no mime part.
@@ -2947,18 +2945,22 @@
appendSubject(msg, tail(subjectFormatter, ""));
- MimeMultipart multipart = new MimeMultipart();
- String altType = getContentType(bodyFormat.getClass().getName());
+ String contentType = contentTypeOf(buf);
+ String altType = contentTypeOf(bodyFormat);
setContent(body, buf, altType == null ? contentType : altType);
- multipart.addBodyPart(body);
+ if (body != msg) {
+ final MimeMultipart multipart = new MimeMultipart();
+ //assert body instanceof BodyPart : body;
+ multipart.addBodyPart((BodyPart) body);
- for (int i = 0; i < parts.length; ++i) {
- if (parts[i] != null) {
- multipart.addBodyPart(parts[i]);
+ for (int i = 0; i < parts.length; ++i) {
+ if (parts[i] != null) {
+ multipart.addBodyPart(parts[i]);
+ }
}
+ msg.setContent(multipart);
}
- msg.setContent(multipart);
return msg;
}
@@ -2983,7 +2985,7 @@
verifySettings0(session, value);
}
} else {
- if (check != null) { //This call will fail.
+ if (check != null) { //Pass some invalid string.
verifySettings0(session, check.getClass().toString());
}
}
@@ -3007,9 +3009,10 @@
private void verifySettings0(Session session, String verify) {
assert verify != null : (String) null;
if (!"local".equals(verify) && !"remote".equals(verify)
- && !"limited".equals(verify) && !"resolve".equals(verify)) {
+ && !"limited".equals(verify) && !"resolve".equals(verify)
+ && !"login".equals(verify)) {
reportError("Verify must be 'limited', local', "
- + "'resolve' or 'remote'.",
+ + "'resolve', 'login', or 'remote'.",
new IllegalArgumentException(verify),
ErrorManager.OPEN_FAILURE);
return;
@@ -3051,12 +3054,7 @@
setIncompleteCopy(abort); //Original body part is never added.
envelopeFor(abort, true);
- try {
- abort.saveChanges();
- } catch (final MessagingException ME) {
- reportError(msg, ME, ErrorManager.FORMAT_FAILURE);
- }
-
+ saveChangesNoContent(abort, msg);
try {
//Ensure transport provider is installed.
Address[] all = abort.getAllRecipients();
@@ -3088,7 +3086,7 @@
}
String local = null;
- if ("remote".equals(verify)) {
+ if ("remote".equals(verify) || "login".equals(verify)) {
MessagingException closed = null;
t.connect();
try {
@@ -3099,15 +3097,23 @@
//A message without content will fail at message writeTo
//when sendMessage is called. This allows the handler
//to capture all mail properties set in the LogManager.
- t.sendMessage(abort, all);
+ if ("remote".equals(verify)) {
+ t.sendMessage(abort, all);
+ }
} finally {
- try { //Close the transport before reporting errors.
+ try {
t.close();
} catch (final MessagingException ME) {
closed = ME;
}
}
- reportUnexpectedSend(abort, verify, null);
+ //Close the transport before reporting errors.
+ if ("remote".equals(verify)) {
+ reportUnexpectedSend(abort, verify, null);
+ } else {
+ final String protocol = t.getURLName().getProtocol();
+ verifyProperties(session, protocol);
+ }
} catch (final SendFailedException sfe) {
Address[] recip = sfe.getInvalidAddresses();
if (recip != null && recip.length != 0) {
@@ -3131,8 +3137,9 @@
reportError(abort, closed, ErrorManager.CLOSE_FAILURE);
}
} else {
- //Force a property copy.
+ //Force a property copy, JDK-7092981.
final String protocol = t.getURLName().getProtocol();
+ verifyProperties(session, protocol);
String mailHost = session.getProperty("mail."
+ protocol + ".host");
if (isEmpty(mailHost)) {
@@ -3140,10 +3147,7 @@
} else {
session.getProperty("mail.host");
}
- session.getProperty("mail." + protocol + ".port");
- session.getProperty("mail." + protocol + ".user");
- session.getProperty("mail.user");
- session.getProperty("mail." + protocol + ".localport");
+
local = session.getProperty("mail." + protocol + ".localhost");
if (isEmpty(local)) {
local = session.getProperty("mail."
@@ -3163,40 +3167,31 @@
} else {
verifyHost(mailHost);
}
- } catch (final IOException IOE) {
+ } catch (final RuntimeException | IOException IOE) {
MessagingException ME =
new MessagingException(msg, IOE);
setErrorContent(abort, verify, ME);
reportError(abort, ME, ErrorManager.OPEN_FAILURE);
- } catch (final RuntimeException RE) {
- MessagingException ME =
- new MessagingException(msg, RE);
- setErrorContent(abort, verify, RE);
- reportError(abort, ME, ErrorManager.OPEN_FAILURE);
}
}
}
if (!"limited".equals(verify)) {
try { //Verify host name and hit the host name cache.
- if (!"remote".equals(verify)) {
+ if (!"remote".equals(verify) && !"login".equals(verify)) {
local = getLocalHost(t);
}
verifyHost(local);
- } catch (final IOException IOE) {
+ } catch (final RuntimeException | IOException IOE) {
MessagingException ME = new MessagingException(msg, IOE);
setErrorContent(abort, verify, ME);
reportError(abort, ME, ErrorManager.OPEN_FAILURE);
- } catch (final RuntimeException RE) {
- MessagingException ME = new MessagingException(msg, RE);
- setErrorContent(abort, verify, ME);
- reportError(abort, ME, ErrorManager.OPEN_FAILURE);
}
-
try { //Verify that the DataHandler can be loaded.
Object ccl = getAndSetContextClassLoader(MAILHANDLER_LOADER);
try {
+ //Always load the multipart classes.
MimeMultipart multipart = new MimeMultipart();
MimeBodyPart[] ambp = new MimeBodyPart[atn.length];
final MimeBodyPart body;
@@ -3207,7 +3202,7 @@
for (int i = 0; i < atn.length; ++i) {
ambp[i] = createBodyPart(i);
ambp[i].setFileName(atn[i]);
- //Convert names to mime type.
+ //Convert names to mime type under lock.
atn[i] = getContentType(atn[i]);
}
}
@@ -3278,6 +3273,65 @@
}
/**
+ * Handles all exceptions thrown when save changes is called on a message
+ * that doesn't have any content.
+ *
+ * @param abort the message requiring save changes.
+ * @param msg the error description.
+ * @since JavaMail 1.6.0
+ */
+ private void saveChangesNoContent(final Message abort, final String msg) {
+ if (abort != null) {
+ try {
+ try {
+ abort.saveChanges();
+ } catch (final NullPointerException xferEncoding) {
+ //Workaround GNU JavaMail bug in MimeUtility.getEncoding
+ //when the mime message has no content.
+ try {
+ String cte = "Content-Transfer-Encoding";
+ if (abort.getHeader(cte) == null) {
+ abort.setHeader(cte, "base64");
+ abort.saveChanges();
+ } else {
+ throw xferEncoding;
+ }
+ } catch (RuntimeException | MessagingException e) {
+ if (e != xferEncoding) {
+ e.addSuppressed(xferEncoding);
+ }
+ throw e;
+ }
+ }
+ } catch (RuntimeException | MessagingException ME) {
+ reportError(msg, ME, ErrorManager.FORMAT_FAILURE);
+ }
+ }
+ }
+
+ /**
+ * Cache common session properties into the LogManagerProperties. This is
+ * a workaround for JDK-7092981.
+ *
+ * @param session the session.
+ * @param protocol the mail protocol.
+ * @throws NullPointerException if session is null.
+ * @since JavaMail 1.6.0
+ */
+ private static void verifyProperties(Session session, String protocol) {
+ session.getProperty("mail.from");
+ session.getProperty("mail." + protocol + ".from");
+ session.getProperty("mail.dsn.ret");
+ session.getProperty("mail." + protocol + ".dsn.ret");
+ session.getProperty("mail.dsn.notify");
+ session.getProperty("mail." + protocol + ".dsn.notify");
+ session.getProperty("mail." + protocol + ".port");
+ session.getProperty("mail.user");
+ session.getProperty("mail." + protocol + ".user");
+ session.getProperty("mail." + protocol + ".localport");
+ }
+
+ /**
* Perform a lookup of the host address or FQDN.
* @param host the host or null.
* @return the address.
@@ -3364,10 +3418,8 @@
msg.setDescription(msgDesc);
setAcceptLang(msg);
msg.saveChanges();
- } catch (final MessagingException ME) {
+ } catch (MessagingException | RuntimeException ME) {
reportError("Unable to create body.", ME, ErrorManager.OPEN_FAILURE);
- } catch (final RuntimeException RE) {
- reportError("Unable to create body.", RE, ErrorManager.OPEN_FAILURE);
}
}
@@ -3934,12 +3986,9 @@
throw new MessagingException("No local address.");
}
}
- } catch (final MessagingException ME) {
+ } catch (MessagingException | RuntimeException ME) {
reportError("Unable to compute a default recipient.",
ME, ErrorManager.FORMAT_FAILURE);
- } catch (final RuntimeException RE) {
- reportError("Unable to compute a default recipient.",
- RE, ErrorManager.FORMAT_FAILURE);
}
}
@@ -4034,11 +4083,11 @@
private String toRawString(final Message msg) throws MessagingException, IOException {
if (msg != null) {
Object ccl = getAndSetContextClassLoader(MAILHANDLER_LOADER);
- try { //BUGID 8025251
+ try { //JDK-8025251
int nbytes = Math.max(msg.getSize() + MIN_HEADER_SIZE, MIN_HEADER_SIZE);
ByteArrayOutputStream out = new ByteArrayOutputStream(nbytes);
- msg.writeTo(out);
- return out.toString("US-ASCII"); //Raw message is always ASCII.
+ msg.writeTo(out); //Headers can be UTF-8 or US-ASCII.
+ return out.toString("UTF-8");
} finally {
getAndSetContextClassLoader(ccl);
}
@@ -4063,12 +4112,12 @@
new ByteArrayOutputStream(MIN_HEADER_SIZE);
//Create an output stream writer so streams are not double buffered.
- final PrintWriter pw =
- new PrintWriter(new OutputStreamWriter(out, charset));
- pw.println(t.getMessage());
- t.printStackTrace(pw);
- pw.flush();
- pw.close(); //BUG ID 6995537
+ try (OutputStreamWriter ows = new OutputStreamWriter(out, charset);
+ PrintWriter pw = new PrintWriter(ows)) {
+ pw.println(t.getMessage());
+ t.printStackTrace(pw);
+ pw.flush();
+ } //Close OSW before generating string. JDK-6995537
return out.toString(charset);
} catch (final RuntimeException unexpected) {
return t.toString() + ' ' + unexpected.toString();
@@ -4137,6 +4186,10 @@
return head;
}
}
+
+ if (optional != required) {
+ required.addSuppressed(optional);
+ }
}
return required;
}
@@ -4150,9 +4203,8 @@
private String getLocalHost(final Service s) {
try {
return LogManagerProperties.getLocalHost(s);
- } catch (final SecurityException ignore) {
- } catch (final NoSuchMethodException ignore) {
- } catch (final LinkageError ignore) {
+ } catch (SecurityException | NoSuchMethodException
+ | LinkageError ignore) {
} catch (final Exception ex) {
reportError(s.toString(), ex, ErrorManager.OPEN_FAILURE);
}
@@ -4187,7 +4239,7 @@
}
/**
- * Outline the creation of the index error message. See BUG ID 6533165.
+ * Outline the creation of the index error message. See JDK-6533165.
* @param i the index.
* @return the error message.
*/
diff --git a/current/src/main/java/com/sun/mail/util/logging/SeverityComparator.java b/current/src/main/java/com/sun/mail/util/logging/SeverityComparator.java
index 781733f..2f779c4 100644
--- a/current/src/main/java/com/sun/mail/util/logging/SeverityComparator.java
+++ b/current/src/main/java/com/sun/mail/util/logging/SeverityComparator.java
@@ -1,356 +1,356 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2013-2016 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013-2016 Jason Mehrens. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common Development
- * and Distribution License("CDDL") (collectively, the "License"). You
- * may not use this file except in compliance with the License. You can
- * obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- * When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
- *
- * GPL Classpath Exception:
- * Oracle designates this particular file as subject to the "Classpath"
- * exception as provided by Oracle in the GPL Version 2 section of the License
- * file that accompanied this code.
- *
- * Modifications:
- * If applicable, add the following below the License Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyright [year] [name of copyright owner]"
- *
- * Contributor(s):
- * If you wish your version of this file to be governed by only the CDDL or
- * only the GPL Version 2, indicate your decision by adding "[Contributor]
- * elects to include this software in this distribution under the [CDDL or GPL
- * Version 2] license." If you don't indicate a single choice of license, a
- * recipient has the option to distribute your version of this file under
- * either the CDDL, the GPL Version 2 or to extend the choice of license to
- * its licensees as provided above. However, if you add GPL Version 2 code
- * and therefore, elected the GPL Version 2 license, then the option applies
- * only if the new code is made subject to such option by the copyright
- * holder.
- */
-package com.sun.mail.util.logging;
-
-import java.io.Serializable;
-import java.util.Comparator;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * Orders log records by level, thrown, sequence, and time.
- *
- * This comparator orders LogRecords by how severely each is attributed to
- * failures in a program. The primary ordering is determined by the use of the
- * logging API throughout a program by specifying a level to each log message.
- * The secondary ordering is determined at runtime by the type of errors and
- * exceptions generated by the program. The remaining ordering assumes that
- * older log records are less severe than newer log records.
- *
- * <p>
- * The following LogRecord properties determine severity ordering:
- * <ol>
- * <li> The natural comparison of the LogRecord
- * {@linkplain Level#intValue level}.
- * <li> The expected recovery order of {@linkplain LogRecord#getThrown() thrown}
- * property of a LogRecord and its cause chain. This ordering is derived from
- * the JLS 11.1.1. The Kinds of Exceptions and JLS 11.5 The Exception Hierarchy.
- * This is performed by {@linkplain #apply(java.lang.Throwable) finding} the
- * throwable that best describes the entire cause chain. Once a specific
- * throwable of each chain is identified it is then ranked lowest to highest by
- * the following rules:
- *
- * <ul>
- * <li>All LogRecords with a {@code Throwable} defined as
- * "{@link #isNormal(java.lang.Throwable) normal occurrence}".
- * <li>All LogRecords that do not have a thrown object.
- * <li>All checked exceptions. This is any class that is assignable to the
- * {@code java.lang.Throwable} class and is not a
- * {@code java.lang.RuntimeException} or a {@code java.lang.Error}.
- * <li>All unchecked exceptions. This is all {@code java.lang.RuntimeException}
- * objects.
- * <li>All errors that indicate a serious problem. This is all
- * {@code java.lang.Error} objects.
- * </ul>
- * <li> The natural comparison of the LogRecord
- * {@linkplain LogRecord#getSequenceNumber() sequence}.
- * <li> The natural comparison of the LogRecord
- * {@linkplain LogRecord#getMillis() millis}.
- * </ol>
- *
- * @author Jason Mehrens
- * @since JavaMail 1.5.2
- */
-public class SeverityComparator implements Comparator<LogRecord>, Serializable {
-
- /**
- * The generated serial version UID.
- */
- private static final long serialVersionUID = -2620442245251791965L;
-
- /**
- * A single instance that is shared among the logging package.
- * The field is declared as java.util.Comparator so
- * WebappClassLoader.clearReferencesStaticFinal() method will ignore this
- * field.
- */
- private static final Comparator<LogRecord> INSTANCE
- = new SeverityComparator();
-
- /**
- * A shared instance of a SeverityComparator. This is package private so the
- * public API is not polluted with more methods.
- *
- * @return a shared instance of a SeverityComparator.
- */
- static SeverityComparator getInstance() {
- return (SeverityComparator) INSTANCE;
- }
-
- /**
- * Identifies a single throwable that best describes the given throwable and
- * the entire {@linkplain Throwable#getCause() cause} chain. This method can
- * be overridden to change the behavior of
- * {@link #compare(java.util.logging.LogRecord, java.util.logging.LogRecord)}.
- *
- * @param chain the throwable or null.
- * @return null if null was given, otherwise the throwable that best
- * describes the entire chain.
- * @see #isNormal(java.lang.Throwable)
- */
- public Throwable apply(final Throwable chain) {
- //Matches the j.u.f.UnaryOperator<Throwable> interface.
- int limit = 0;
- Throwable root = chain;
- Throwable high = null;
- Throwable normal = null;
- for (Throwable cause = chain; cause != null; cause = cause.getCause()) {
- root = cause; //Find the deepest cause.
-
- //Find the deepest nomral occurrance.
- if (isNormal(cause)) {
- normal = cause;
- }
-
- //Find the deepest error that happened before a normal occurance.
- if (normal == null && cause instanceof Error) {
- high = cause;
- }
-
- //Deal with excessive cause chains and cyclic throwables.
- if (++limit == (1 << 16)) {
- break; //Give up.
- }
- }
- return high != null ? high : normal != null ? normal : root;
- }
-
- /**
- * {@link #apply(java.lang.Throwable) Reduces} each throwable chain argument
- * then compare each throwable result.
- *
- * @param tc1 the first throwable chain or null.
- * @param tc2 the second throwable chain or null.
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- * @see #apply(java.lang.Throwable)
- * @see #compareThrowable(java.lang.Throwable, java.lang.Throwable)
- */
- public final int applyThenCompare(Throwable tc1, Throwable tc2) {
- return tc1 == tc2 ? 0 : compareThrowable(apply(tc1), apply(tc2));
- }
-
- /**
- * Compares two throwable objects or null. This method does not
- * {@link #apply(java.lang.Throwable) reduce} each argument before
- * comparing. This is method can be overridden to change the behavior of
- * {@linkplain #compare(LogRecord, LogRecord)}.
- *
- * @param t1 the first throwable or null.
- * @param t2 the second throwable or null.
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- * @see #isNormal(java.lang.Throwable)
- */
- public int compareThrowable(final Throwable t1, final Throwable t2) {
- if (t1 == t2) { //Reflexive test including null.
- return 0;
- } else {
- //Only one or the other is null at this point.
- //Force normal occurrence to be lower than null.
- if (t1 == null) {
- return isNormal(t2) ? 1 : -1;
- } else {
- if (t2 == null) {
- return isNormal(t1) ? -1 : 1;
- }
- }
-
- //From this point on neither are null.
- //Follow the shortcut if we can.
- if (t1.getClass() == t2.getClass()) {
- return 0;
- }
-
- //Ensure normal occurrence flow control is ordered low.
- if (isNormal(t1)) {
- return isNormal(t2) ? 0 : -1;
- } else {
- if (isNormal(t2)) {
- return 1;
- }
- }
-
- //Rank the two unidenticial throwables using the rules from
- //JLS 11.1.1. The Kinds of Exceptions and
- //JLS 11.5 The Exception Hierarchy.
- if (t1 instanceof Error) {
- return t2 instanceof Error ? 0 : 1;
- } else if (t1 instanceof RuntimeException) {
- return t2 instanceof Error ? -1
- : t2 instanceof RuntimeException ? 0 : 1;
- } else {
- return t2 instanceof Error
- || t2 instanceof RuntimeException ? -1 : 0;
- }
- }
- }
-
- /**
- * Compares two log records based on severity.
- *
- * @param o1 the first log record.
- * @param o2 the second log record.
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- * @throws NullPointerException if either argument is null.
- */
- @SuppressWarnings("override") //JDK-6954234
- public int compare(final LogRecord o1, final LogRecord o2) {
- if (o1 == null || o2 == null) { //Don't allow null.
- throw new NullPointerException(toString(o1, o2));
- }
-
- /**
- * LogRecords are mutable so a reflexive relationship test is a safety
- * requirement.
- */
- if (o1 == o2) {
- return 0;
- }
-
- int cmp = compare(o1.getLevel(), o2.getLevel());
- if (cmp == 0) {
- cmp = applyThenCompare(o1.getThrown(), o2.getThrown());
- if (cmp == 0) {
- cmp = compare(o1.getSequenceNumber(), o2.getSequenceNumber());
- if (cmp == 0) {
- cmp = compare(o1.getMillis(), o2.getMillis());
- }
- }
- }
- return cmp;
- }
-
- /**
- * Determines if the given object is also a comparator and it imposes the
- * same ordering as this comparator.
- *
- * @param o the reference object with which to compare.
- * @return true if this object equal to the argument; false otherwise.
- */
- @Override
- public boolean equals(final Object o) {
- return o == null ? false : o.getClass() == getClass();
- }
-
- /**
- * Returns a hash code value for the object.
- *
- * @return Returns a hash code value for the object.
- */
- @Override
- public int hashCode() {
- return 31 * getClass().hashCode();
- }
-
- /**
- * Determines if the given throwable instance is "normal occurrence". This
- * is any checked or unchecked exception with 'Interrupt' in the class name
- * or ancestral class name. Any {@code java.lang.ThreadDeath} object or
- * subclasses.
- *
- * This method can be overridden to change the behavior of the
- * {@linkplain #apply(java.lang.Throwable)} method.
- *
- * @param t a throwable or null.
- * @return true the given throwable is a "normal occurrence".
- */
- public boolean isNormal(final Throwable t) {
- if (t == null) { //This is only needed when called directly.
- return false;
- }
-
- /**
- * Use the class names to avoid loading more classes.
- */
- final Class<?> root = Throwable.class;
- final Class<?> error = Error.class;
- for (Class<?> c = t.getClass(); c != root; c = c.getSuperclass()) {
- if (error.isAssignableFrom(c)) {
- if (c.getName().equals("java.lang.ThreadDeath")) {
- return true;
- }
- } else {
- //Interrupt, Interrupted or Interruption.
- if (c.getName().contains("Interrupt")) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Compare two level objects.
- *
- * @param a the first level.
- * @param b the second level.
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- */
- private int compare(final Level a, final Level b) {
- return a == b ? 0 : compare(a.intValue(), b.intValue());
- }
-
- /**
- * Outline the message create string.
- *
- * @param o1 argument one.
- * @param o2 argument two.
- * @return the message string.
- */
- private static String toString(final Object o1, final Object o2) {
- return o1 + ", " + o2;
- }
-
- /**
- * Compare two longs. Can be removed when JDK 1.7 is required.
- *
- * @param x the first long.
- * @param y the second long.
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- */
- private int compare(final long x, final long y) {
- return x < y ? -1 : x > y ? 1 : 0;
- }
-}
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013-2017 Jason Mehrens. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can
+ * obtain a copy of the License at
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at LICENSE.txt.
+ *
+ * GPL Classpath Exception:
+ * Oracle designates this particular file as subject to the "Classpath"
+ * exception as provided by Oracle in the GPL Version 2 section of the License
+ * file that accompanied this code.
+ *
+ * Modifications:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+package com.sun.mail.util.logging;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * Orders log records by level, thrown, sequence, and time.
+ *
+ * This comparator orders LogRecords by how severely each is attributed to
+ * failures in a program. The primary ordering is determined by the use of the
+ * logging API throughout a program by specifying a level to each log message.
+ * The secondary ordering is determined at runtime by the type of errors and
+ * exceptions generated by the program. The remaining ordering assumes that
+ * older log records are less severe than newer log records.
+ *
+ * <p>
+ * The following LogRecord properties determine severity ordering:
+ * <ol>
+ * <li> The natural comparison of the LogRecord
+ * {@linkplain Level#intValue level}.
+ * <li> The expected recovery order of {@linkplain LogRecord#getThrown() thrown}
+ * property of a LogRecord and its cause chain. This ordering is derived from
+ * the JLS 11.1.1. The Kinds of Exceptions and JLS 11.5 The Exception Hierarchy.
+ * This is performed by {@linkplain #apply(java.lang.Throwable) finding} the
+ * throwable that best describes the entire cause chain. Once a specific
+ * throwable of each chain is identified it is then ranked lowest to highest by
+ * the following rules:
+ *
+ * <ul>
+ * <li>All LogRecords with a {@code Throwable} defined as
+ * "{@link #isNormal(java.lang.Throwable) normal occurrence}".
+ * <li>All LogRecords that do not have a thrown object.
+ * <li>All checked exceptions. This is any class that is assignable to the
+ * {@code java.lang.Throwable} class and is not a
+ * {@code java.lang.RuntimeException} or a {@code java.lang.Error}.
+ * <li>All unchecked exceptions. This is all {@code java.lang.RuntimeException}
+ * objects.
+ * <li>All errors that indicate a serious problem. This is all
+ * {@code java.lang.Error} objects.
+ * </ul>
+ * <li> The natural comparison of the LogRecord
+ * {@linkplain LogRecord#getSequenceNumber() sequence}.
+ * <li> The natural comparison of the LogRecord
+ * {@linkplain LogRecord#getMillis() millis}.
+ * </ol>
+ *
+ * @author Jason Mehrens
+ * @since JavaMail 1.5.2
+ */
+public class SeverityComparator implements Comparator<LogRecord>, Serializable {
+
+ /**
+ * The generated serial version UID.
+ */
+ private static final long serialVersionUID = -2620442245251791965L;
+
+ /**
+ * A single instance that is shared among the logging package.
+ * The field is declared as java.util.Comparator so
+ * WebappClassLoader.clearReferencesStaticFinal() method will ignore this
+ * field.
+ */
+ private static final Comparator<LogRecord> INSTANCE
+ = new SeverityComparator();
+
+ /**
+ * A shared instance of a SeverityComparator. This is package private so the
+ * public API is not polluted with more methods.
+ *
+ * @return a shared instance of a SeverityComparator.
+ */
+ static SeverityComparator getInstance() {
+ return (SeverityComparator) INSTANCE;
+ }
+
+ /**
+ * Identifies a single throwable that best describes the given throwable and
+ * the entire {@linkplain Throwable#getCause() cause} chain. This method can
+ * be overridden to change the behavior of
+ * {@link #compare(java.util.logging.LogRecord, java.util.logging.LogRecord)}.
+ *
+ * @param chain the throwable or null.
+ * @return null if null was given, otherwise the throwable that best
+ * describes the entire chain.
+ * @see #isNormal(java.lang.Throwable)
+ */
+ public Throwable apply(final Throwable chain) {
+ //Matches the j.u.f.UnaryOperator<Throwable> interface.
+ int limit = 0;
+ Throwable root = chain;
+ Throwable high = null;
+ Throwable normal = null;
+ for (Throwable cause = chain; cause != null; cause = cause.getCause()) {
+ root = cause; //Find the deepest cause.
+
+ //Find the deepest nomral occurrance.
+ if (isNormal(cause)) {
+ normal = cause;
+ }
+
+ //Find the deepest error that happened before a normal occurance.
+ if (normal == null && cause instanceof Error) {
+ high = cause;
+ }
+
+ //Deal with excessive cause chains and cyclic throwables.
+ if (++limit == (1 << 16)) {
+ break; //Give up.
+ }
+ }
+ return high != null ? high : normal != null ? normal : root;
+ }
+
+ /**
+ * {@link #apply(java.lang.Throwable) Reduces} each throwable chain argument
+ * then compare each throwable result.
+ *
+ * @param tc1 the first throwable chain or null.
+ * @param tc2 the second throwable chain or null.
+ * @return a negative integer, zero, or a positive integer as the first
+ * argument is less than, equal to, or greater than the second.
+ * @see #apply(java.lang.Throwable)
+ * @see #compareThrowable(java.lang.Throwable, java.lang.Throwable)
+ */
+ public final int applyThenCompare(Throwable tc1, Throwable tc2) {
+ return tc1 == tc2 ? 0 : compareThrowable(apply(tc1), apply(tc2));
+ }
+
+ /**
+ * Compares two throwable objects or null. This method does not
+ * {@link #apply(java.lang.Throwable) reduce} each argument before
+ * comparing. This is method can be overridden to change the behavior of
+ * {@linkplain #compare(LogRecord, LogRecord)}.
+ *
+ * @param t1 the first throwable or null.
+ * @param t2 the second throwable or null.
+ * @return a negative integer, zero, or a positive integer as the first
+ * argument is less than, equal to, or greater than the second.
+ * @see #isNormal(java.lang.Throwable)
+ */
+ public int compareThrowable(final Throwable t1, final Throwable t2) {
+ if (t1 == t2) { //Reflexive test including null.
+ return 0;
+ } else {
+ //Only one or the other is null at this point.
+ //Force normal occurrence to be lower than null.
+ if (t1 == null) {
+ return isNormal(t2) ? 1 : -1;
+ } else {
+ if (t2 == null) {
+ return isNormal(t1) ? -1 : 1;
+ }
+ }
+
+ //From this point on neither are null.
+ //Follow the shortcut if we can.
+ if (t1.getClass() == t2.getClass()) {
+ return 0;
+ }
+
+ //Ensure normal occurrence flow control is ordered low.
+ if (isNormal(t1)) {
+ return isNormal(t2) ? 0 : -1;
+ } else {
+ if (isNormal(t2)) {
+ return 1;
+ }
+ }
+
+ //Rank the two unidenticial throwables using the rules from
+ //JLS 11.1.1. The Kinds of Exceptions and
+ //JLS 11.5 The Exception Hierarchy.
+ if (t1 instanceof Error) {
+ return t2 instanceof Error ? 0 : 1;
+ } else if (t1 instanceof RuntimeException) {
+ return t2 instanceof Error ? -1
+ : t2 instanceof RuntimeException ? 0 : 1;
+ } else {
+ return t2 instanceof Error
+ || t2 instanceof RuntimeException ? -1 : 0;
+ }
+ }
+ }
+
+ /**
+ * Compares two log records based on severity.
+ *
+ * @param o1 the first log record.
+ * @param o2 the second log record.
+ * @return a negative integer, zero, or a positive integer as the first
+ * argument is less than, equal to, or greater than the second.
+ * @throws NullPointerException if either argument is null.
+ */
+ @SuppressWarnings("override") //JDK-6954234
+ public int compare(final LogRecord o1, final LogRecord o2) {
+ if (o1 == null || o2 == null) { //Don't allow null.
+ throw new NullPointerException(toString(o1, o2));
+ }
+
+ /**
+ * LogRecords are mutable so a reflexive relationship test is a safety
+ * requirement.
+ */
+ if (o1 == o2) {
+ return 0;
+ }
+
+ int cmp = compare(o1.getLevel(), o2.getLevel());
+ if (cmp == 0) {
+ cmp = applyThenCompare(o1.getThrown(), o2.getThrown());
+ if (cmp == 0) {
+ cmp = compare(o1.getSequenceNumber(), o2.getSequenceNumber());
+ if (cmp == 0) {
+ cmp = compare(o1.getMillis(), o2.getMillis());
+ }
+ }
+ }
+ return cmp;
+ }
+
+ /**
+ * Determines if the given object is also a comparator and it imposes the
+ * same ordering as this comparator.
+ *
+ * @param o the reference object with which to compare.
+ * @return true if this object equal to the argument; false otherwise.
+ */
+ @Override
+ public boolean equals(final Object o) {
+ return o == null ? false : o.getClass() == getClass();
+ }
+
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return Returns a hash code value for the object.
+ */
+ @Override
+ public int hashCode() {
+ return 31 * getClass().hashCode();
+ }
+
+ /**
+ * Determines if the given throwable instance is "normal occurrence". This
+ * is any checked or unchecked exception with 'Interrupt' in the class name
+ * or ancestral class name. Any {@code java.lang.ThreadDeath} object or
+ * subclasses.
+ *
+ * This method can be overridden to change the behavior of the
+ * {@linkplain #apply(java.lang.Throwable)} method.
+ *
+ * @param t a throwable or null.
+ * @return true the given throwable is a "normal occurrence".
+ */
+ public boolean isNormal(final Throwable t) {
+ if (t == null) { //This is only needed when called directly.
+ return false;
+ }
+
+ /**
+ * Use the class names to avoid loading more classes.
+ */
+ final Class<?> root = Throwable.class;
+ final Class<?> error = Error.class;
+ for (Class<?> c = t.getClass(); c != root; c = c.getSuperclass()) {
+ if (error.isAssignableFrom(c)) {
+ if (c.getName().equals("java.lang.ThreadDeath")) {
+ return true;
+ }
+ } else {
+ //Interrupt, Interrupted or Interruption.
+ if (c.getName().contains("Interrupt")) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Compare two level objects.
+ *
+ * @param a the first level.
+ * @param b the second level.
+ * @return a negative integer, zero, or a positive integer as the first
+ * argument is less than, equal to, or greater than the second.
+ */
+ private int compare(final Level a, final Level b) {
+ return a == b ? 0 : compare(a.intValue(), b.intValue());
+ }
+
+ /**
+ * Outline the message create string.
+ *
+ * @param o1 argument one.
+ * @param o2 argument two.
+ * @return the message string.
+ */
+ private static String toString(final Object o1, final Object o2) {
+ return o1 + ", " + o2;
+ }
+
+ /**
+ * Compare two longs. Can be removed when JDK 1.7 is required.
+ *
+ * @param x the first long.
+ * @param y the second long.
+ * @return a negative integer, zero, or a positive integer as the first
+ * argument is less than, equal to, or greater than the second.
+ */
+ private int compare(final long x, final long y) {
+ return x < y ? -1 : x > y ? 1 : 0;
+ }
+}
diff --git a/current/src/main/java/com/sun/mail/util/logging/package.html b/current/src/main/java/com/sun/mail/util/logging/package.html
deleted file mode 100644
index cfdac1a..0000000
--- a/current/src/main/java/com/sun/mail/util/logging/package.html
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 2009-2010 Oracle and/or its affiliates. All rights reserved.
- Copyright (c) 2009-2010 Jason Mehrens. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- </head>
- <body>
- Contains JavaMail<sup><font size="-2">TM</font></sup> extensions for
- the Java<SUP><FONT SIZE="-2">TM</FONT></SUP> platform's core logging
- facilities. This package contains classes used to export log messages
- as a formatted email message. Classes in this package typically use
- LogManager properties to set default values; see the specific
- documentation for each concrete class.
- </body>
-</html>
diff --git a/current/src/main/java/com/sun/mail/util/package.html b/current/src/main/java/com/sun/mail/util/package.html
deleted file mode 100644
index 8663745..0000000
--- a/current/src/main/java/com/sun/mail/util/package.html
+++ /dev/null
@@ -1,79 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-Utility classes for use with the JavaMail API.
-These utility classes are not part of the JavaMail specification.
-While this package contains many classes used by the JavaMail implementation
-and not intended for direct use by applications, the classes documented
-here may be of use to applications.
-<P>
-Classes in this package log debugging information using
-{@link java.util.logging} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>com.sun.mail.util.socket</TD>
-<TD>FINER</TD>
-<TD>Debugging output related to creating sockets</TD>
-</TR>
-</TABLE>
-
-<P>
-<strong>WARNING:</strong> The APIs in this package should be
-considered <strong>EXPERIMENTAL</strong>. They may be changed in the
-future in ways that are incompatible with applications using the
-current APIs.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/doc-files/speclicense.html b/current/src/main/java/doc-files/speclicense.html
deleted file mode 100644
index 719ab39..0000000
--- a/current/src/main/java/doc-files/speclicense.html
+++ /dev/null
@@ -1,215 +0,0 @@
-<html>
-<head>
-<title>Specification License</title>
-</head>
-<body>
-Specification: JSR-919 JavaMail API Specification ("Specification")
-<br/>
-Version: 1.5
-<br/>
-Status: Final Release
-<br/>
-Specification Lead: Oracle America, Inc. ("Specification Lead")
-<br/>
-Release: March 18, 2013
-<br/>
-
-<br/>
-Copyright © 2013 Oracle America, Inc.
-<br/>
-All rights reserved.
-<br/>
-<p>
-LIMITED LICENSE GRANTS
-<br/>
-1. License for Evaluation Purposes. Specification Lead hereby grants
-you a fully-paid, non-exclusive, non-transferable, worldwide, limited
-license (without the right to sublicense), under Specification Lead's
-applicable intellectual property rights to view, download, use and
-reproduce the Specification only for the purpose of internal
-evaluation. This includes (i) developing applications intended to run
-on an implementation of the Specification, provided that such
-applications do not themselves implement any portion(s) of the
-Specification, and (ii) discussing the Specification with any third
-party; and (iii) excerpting brief portions of the Specification in oral
-or written communications which discuss the Specification provided that
-such excerpts do not in the aggregate constitute a significant portion
-of the Specification.
-</p>
-<p>
-2. License for the Distribution of Compliant Implementations.
-Specification Lead also grants you a perpetual, non-exclusive,
-non-transferable, worldwide, fully paid-up, royalty free, limited
-license (without the right to sublicense) under any applicable
-copyrights or, subject to the provisions of subsection 4 below, patent
-rights it may have covering the Specification to create and/or
-distribute an Independent Implementation of the Specification that: (a)
-fully implements the Specification including all its required
-interfaces and functionality; (b) does not modify, subset, superset or
-otherwise extend the Licensor Name Space, or include any public or
-protected packages, classes, Java interfaces, fields or methods within
-the Licensor Name Space other than those required/authorized by the
-Specification or Specifications being implemented; and (c) passes the
-Technology Compatibility Kit (including satisfying the requirements of
-the applicable TCK Users Guide) for such Specification ("Compliant
-Implementation"). In addition, the foregoing license is expressly
-conditioned on your not acting outside its scope. No license is
-granted hereunder for any other purpose (including, for example,
-modifying the Specification, other than to the extent of your fair use
-rights, or distributing the Specification to third parties). Also, no
-right, title, or interest in or to any trademarks, service marks, or
-trade names of Specification Lead or Specification Lead's licensors is
-granted hereunder. Java, and Java-related logos, marks and names are
-trademarks or registered trademarks of Oracle America, Inc. in the U.S.
-and other countries.
-</p>
-<p>
-3. Pass-through Conditions. You need not include limitations (a)-(c)
-from the previous paragraph or any other particular "pass through"
-requirements in any license You grant concerning the use of your
-Independent Implementation or products derived from it. However,
-except with respect to Independent Implementations (and products
-derived from them) that satisfy limitations (a)-(c) from the previous
-paragraph, You may neither: (a) grant or otherwise pass through to
-your licensees any licenses under Specification Lead's applicable
-intellectual property rights; nor (b) authorize your licensees to make
-any claims concerning their implementation's compliance with the
-Specification in question.
-</p>
-<p>
-4. Reciprocity Concerning Patent Licenses.
-<br/>
-a. With respect to any patent claims covered by the license granted
-under subparagraph 2 above that would be infringed by all technically
-feasible implementations of the Specification, such license is
-conditioned upon your offering on fair, reasonable and
-non-discriminatory terms, to any party seeking it from You, a
-perpetual, non-exclusive, non-transferable, worldwide license under
-Your patent rights which are or would be infringed by all technically
-feasible implementations of the Specification to develop, distribute
-and use a Compliant Implementation.
-<br/>
-b. With respect to any patent claims owned by Specification Lead and
-covered by the license granted under subparagraph 2, whether or not
-their infringement can be avoided in a technically feasible manner when
-implementing the Specification, such license shall terminate with
-respect to such claims if You initiate a claim against Specification
-Lead that it has, in the course of performing its responsibilities as
-the Specification Lead, induced any other entity to infringe Your
-patent rights.
-<br/>
-c. Also with respect to any patent claims owned by Specification Lead
-and covered by the license granted under subparagraph 2 above, where
-the infringement of such claims can be avoided in a technically
-feasible manner when implementing the Specification such license, with
-respect to such claims, shall terminate if You initiate a claim against
-Specification Lead that its making, having made, using, offering to
-sell, selling or importing a Compliant Implementation infringes Your
-patent rights.
-</p>
-<p>
-5. Definitions. For the purposes of this Agreement: "Independent
-Implementation" shall mean an implementation of the Specification that
-neither derives from any of Specification Lead's source code or binary
-code materials nor, except with an appropriate and separate license
-from Specification Lead, includes any of Specification Lead's source
-code or binary code materials; "Licensor Name Space" shall mean the
-public class or interface declarations whose names begin with "java",
-"javax", "com.sun" and "com.oracle" or their equivalents in any
-subsequent naming convention adopted by Oracle America, Inc. through
-the Java Community Process, or any recognized successors or
-replacements thereof; and "Technology Compatibility Kit" or "TCK" shall
-mean the test suite and accompanying TCK User's Guide provided by
-Specification Lead which corresponds to the Specification and that was
-available either (i) from Specification Lead's 120 days before the
-first release of Your Independent Implementation that allows its use
-for commercial purposes, or (ii) more recently than 120 days from such
-release but against which You elect to test Your implementation of the
-Specification.
-</p>
-<p>
-This Agreement will terminate immediately without notice from
-Specification Lead if you breach the Agreement or act outside the scope
-of the licenses granted above.
-</p>
-<p>
-DISCLAIMER OF WARRANTIES
-<br/>
-THE SPECIFICATION IS PROVIDED "AS IS". SPECIFICATION LEAD MAKES NO
-REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
-NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE, NON-INFRINGEMENT (INCLUDING AS A CONSEQUENCE OF ANY PRACTICE
-OR IMPLEMENTATION OF THE SPECIFICATION), OR THAT THE CONTENTS OF THE
-SPECIFICATION ARE SUITABLE FOR ANY PURPOSE. This document does not
-represent any commitment to release or implement any portion of the
-Specification in any product. In addition, the Specification could
-include technical inaccuracies or typographical errors.
-</p>
-<p>
-LIMITATION OF LIABILITY
-<br/>
-TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SPECIFICATION
-LEAD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT
-LIMITATION, LOST REVENUE, PROFITS OR DATA, OR FOR SPECIAL, INDIRECT,
-CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
-REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED IN ANY
-WAY TO YOUR HAVING, IMPELEMENTING OR OTHERWISE USING USING THE
-SPECIFICATION, EVEN IF SPECIFICATION LEAD AND/OR ITS LICENSORS HAVE
-BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You will indemnify,
-hold harmless, and defend Specification Lead and its licensors from any
-claims arising or resulting from: (i) your use of the Specification;
-(ii) the use or distribution of your Java application, applet and/or
-implementation; and/or (iii) any claims that later versions or releases
-of any Specification furnished to you are incompatible with the
-Specification provided to you under this license.
-</p>
-<p>
-RESTRICTED RIGHTS LEGEND
-<br/>
-U.S. Government: If this Specification is being acquired by or on
-behalf of the U.S. Government or by a U.S. Government prime contractor
-or subcontractor (at any tier), then the Government's rights in the
-Software and accompanying documentation shall be only as set forth in
-this license; this is in accordance with 48 C.F.R. 227.7201 through
-227.7202-4 (for Department of Defense (DoD) acquisitions) and with 48
-C.F.R. 2.101 and 12.212 (for non-DoD acquisitions).
-</p>
-<p>
-REPORT
-<br/>
-If you provide Specification Lead with any comments or suggestions
-concerning the Specification ("Feedback"), you hereby: (i) agree that
-such Feedback is provided on a non-proprietary and non-confidential
-basis, and (ii) grant Specification Lead a perpetual, non-exclusive,
-worldwide, fully paid-up, irrevocable license, with the right to
-sublicense through multiple levels of sublicensees, to incorporate,
-disclose, and use without limitation the Feedback for any purpose.
-</p>
-<p>
-GENERAL TERMS
-<br/>
-Any action related to this Agreement will be governed by California law
-and controlling U.S. federal law. The U.N. Convention for the
-International Sale of Goods and the choice of law rules of any
-jurisdiction will not apply.
-</p>
-<p>
-The Specification is subject to U.S. export control laws and may be
-subject to export or import regulations in other countries. Licensee
-agrees to comply strictly with all such laws and regulations and
-acknowledges that it has the responsibility to obtain such licenses to
-export, re-export or import as may be required after delivery to
-Licensee.
-</p>
-<p>
-This Agreement is the parties' entire agreement relating to its subject
-matter. It supersedes all prior or contemporaneous oral or written
-communications, proposals, conditions, representations and warranties
-and prevails over any conflicting or additional terms of any quote,
-order, acknowledgment, or other communication between the parties
-relating to its subject matter during the term of this Agreement. No
-modification to this Agreement will be binding, unless in writing and
-signed by an authorized representative of each party.
-</p>
-</body>
-</html>
diff --git a/current/src/main/java/javax/mail/Address.java b/current/src/main/java/javax/mail/Address.java
index ae449e3..2c8a6e7 100644
--- a/current/src/main/java/javax/mail/Address.java
+++ b/current/src/main/java/javax/mail/Address.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -70,6 +70,7 @@
*
* @return string representation of this address
*/
+ @Override
public abstract String toString();
/**
@@ -84,5 +85,6 @@
*
* @param address Address object
*/
+ @Override
public abstract boolean equals(Object address);
}
diff --git a/current/src/main/java/javax/mail/AuthenticationFailedException.java b/current/src/main/java/javax/mail/AuthenticationFailedException.java
index 1477fa8..cd34e7e 100644
--- a/current/src/main/java/javax/mail/AuthenticationFailedException.java
+++ b/current/src/main/java/javax/mail/AuthenticationFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Authenticator.java b/current/src/main/java/javax/mail/Authenticator.java
index a9f7e57..6886523 100644
--- a/current/src/main/java/javax/mail/Authenticator.java
+++ b/current/src/main/java/javax/mail/Authenticator.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/BodyPart.java b/current/src/main/java/javax/mail/BodyPart.java
index 5ff54ad..1cb95be 100644
--- a/current/src/main/java/javax/mail/BodyPart.java
+++ b/current/src/main/java/javax/mail/BodyPart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/EncodingAware.java b/current/src/main/java/javax/mail/EncodingAware.java
index 2a814a2..167da71 100644
--- a/current/src/main/java/javax/mail/EncodingAware.java
+++ b/current/src/main/java/javax/mail/EncodingAware.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/EventQueue.java b/current/src/main/java/javax/mail/EventQueue.java
index d65acb9..938aa1e 100644
--- a/current/src/main/java/javax/mail/EventQueue.java
+++ b/current/src/main/java/javax/mail/EventQueue.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -73,6 +73,7 @@
super(new Object());
}
+ @Override
public void dispatch(Object listener) {
// Kill the event dispatching thread.
Thread.currentThread().interrupt();
@@ -107,7 +108,7 @@
Vector<? extends EventListener> vector) {
// if this is the first event, create the queue and start the event task
if (q == null) {
- q = new LinkedBlockingQueue<QueueElement>();
+ q = new LinkedBlockingQueue<>();
if (executor != null) {
executor.execute(this);
} else {
@@ -124,7 +125,7 @@
*/
synchronized void terminateQueue() {
if (q != null) {
- Vector<EventListener> dummyListeners = new Vector<EventListener>();
+ Vector<EventListener> dummyListeners = new Vector<>();
dummyListeners.setSize(1); // need atleast one listener
q.add(new QueueElement(new TerminatorEvent(), dummyListeners));
q = null;
@@ -138,7 +139,7 @@
static synchronized EventQueue getApplicationEventQueue(Executor ex) {
ClassLoader cl = Session.getContextClassLoader();
if (appq == null)
- appq = new WeakHashMap<ClassLoader,EventQueue>();
+ appq = new WeakHashMap<>();
EventQueue q = appq.get(cl);
if (q == null) {
q = new EventQueue(ex);
@@ -150,6 +151,7 @@
/**
* Pull events off the queue and dispatch them.
*/
+ @Override
public void run() {
BlockingQueue<QueueElement> bq = q;
diff --git a/current/src/main/java/javax/mail/FetchProfile.java b/current/src/main/java/javax/mail/FetchProfile.java
index f8cc6cf..c93f78c 100644
--- a/current/src/main/java/javax/mail/FetchProfile.java
+++ b/current/src/main/java/javax/mail/FetchProfile.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -156,6 +156,7 @@
/**
* Include the name in the toString return value for debugging.
*/
+ @Override
public String toString() {
return getClass().getName() + "[" + name + "]";
}
@@ -180,7 +181,7 @@
*/
public void add(Item item) {
if (specials == null)
- specials = new Vector<Item>();
+ specials = new Vector<>();
specials.addElement(item);
}
@@ -192,7 +193,7 @@
*/
public void add(String headerName) {
if (headers == null)
- headers = new Vector<String>();
+ headers = new Vector<>();
headers.addElement(headerName);
}
diff --git a/current/src/main/java/javax/mail/Flags.java b/current/src/main/java/javax/mail/Flags.java
index 7ddd58f..bcc0921 100644
--- a/current/src/main/java/javax/mail/Flags.java
+++ b/current/src/main/java/javax/mail/Flags.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -100,6 +100,8 @@
public class Flags implements Cloneable, Serializable {
private int system_flags = 0;
+ // used as a case-independent Set that preserves the original case,
+ // the key is the lowercase flag name and the value is the original
private Hashtable<String, String> user_flags = null;
private final static int ANSWERED_BIT = 0x01;
@@ -153,7 +155,7 @@
/**
* This message is seen. This flag is implicitly set by the
- * implementation when the this Message's content is returned
+ * implementation when this Message's content is returned
* to the client in some form. The <code>getInputStream</code>
* and <code>getContent</code> methods on Message cause this
* flag to be set. <p>
@@ -213,7 +215,7 @@
* @param flag the flag for initialization
*/
public Flags(String flag) {
- user_flags = new Hashtable<String, String>(1);
+ user_flags = new Hashtable<>(1);
user_flags.put(flag.toLowerCase(Locale.ENGLISH), flag);
}
@@ -233,7 +235,7 @@
*/
public void add(String flag) {
if (user_flags == null)
- user_flags = new Hashtable<String, String>(1);
+ user_flags = new Hashtable<>(1);
user_flags.put(flag.toLowerCase(Locale.ENGLISH), flag);
}
@@ -248,7 +250,7 @@
if (f.user_flags != null) { // add user-defined flags
if (user_flags == null)
- user_flags = new Hashtable<String, String>(1);
+ user_flags = new Hashtable<>(1);
Enumeration<String> e = f.user_flags.keys();
@@ -298,6 +300,45 @@
}
/**
+ * Remove any flags <strong>not</strong> in the given Flags object.
+ * Useful for clearing flags not supported by a server. If the
+ * given Flags object includes the Flags.Flag.USER flag, all user
+ * flags in this Flags object are retained.
+ *
+ * @param f the flags to keep
+ * @return true if this Flags object changed
+ * @since JavaMail 1.6
+ */
+ public boolean retainAll(Flags f) {
+ boolean changed = false;
+ int sf = system_flags & f.system_flags;
+ if (system_flags != sf) {
+ system_flags = sf;
+ changed = true;
+ }
+
+ // if we have user flags, and the USER flag is not set in "f",
+ // determine which user flags to clear
+ if (user_flags != null && (f.system_flags & USER_BIT) == 0) {
+ if (f.user_flags != null) {
+ Enumeration<String> e = user_flags.keys();
+ while (e.hasMoreElements()) {
+ String key = e.nextElement();
+ if (!f.user_flags.containsKey(key)) {
+ user_flags.remove(key);
+ changed = true;
+ }
+ }
+ } else {
+ // if anything in user_flags, throw them away
+ changed = user_flags.size() > 0;
+ user_flags = null;
+ }
+ }
+ return changed;
+ }
+
+ /**
* Check whether the specified system flag is present in this Flags object.
*
* @param flag the flag to test
@@ -354,6 +395,7 @@
*
* @return true if they're equal
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof Flags))
return false;
@@ -365,18 +407,12 @@
return false;
// Check user flags
- if (f.user_flags == null && this.user_flags == null)
+ int size = this.user_flags == null ? 0 : this.user_flags.size();
+ int fsize = f.user_flags == null ? 0 : f.user_flags.size();
+ if (size == 0 && fsize == 0)
return true;
- if (f.user_flags != null && this.user_flags != null &&
- f.user_flags.size() == this.user_flags.size()) {
- Enumeration<String> e = f.user_flags.keys();
-
- while (e.hasMoreElements()) {
- if (!this.user_flags.containsKey(e.nextElement()))
- return false;
- }
- return true;
- }
+ if (f.user_flags != null && this.user_flags != null && fsize == size)
+ return user_flags.keySet().equals(f.user_flags.keySet());
return false;
}
@@ -386,6 +422,7 @@
*
* @return the hash code
*/
+ @Override
public int hashCode() {
int hash = system_flags;
if (user_flags != null) {
@@ -403,7 +440,7 @@
* @return array of Flags.Flag objects representing system flags
*/
public Flag[] getSystemFlags() {
- Vector<Flag> v = new Vector<Flag>();
+ Vector<Flag> v = new Vector<>();
if ((system_flags & ANSWERED_BIT) != 0)
v.addElement(Flag.ANSWERED);
if ((system_flags & DELETED_BIT) != 0)
@@ -431,7 +468,7 @@
* @return array of Strings, each String represents a flag.
*/
public String[] getUserFlags() {
- Vector<String> v = new Vector<String>();
+ Vector<String> v = new Vector<>();
if (user_flags != null) {
Enumeration<String> e = user_flags.elements();
@@ -445,9 +482,28 @@
}
/**
+ * Clear all of the system flags.
+ *
+ * @since JavaMail 1.6
+ */
+ public void clearSystemFlags() {
+ system_flags = 0;
+ }
+
+ /**
+ * Clear all of the user flags.
+ *
+ * @since JavaMail 1.6
+ */
+ public void clearUserFlags() {
+ user_flags = null;
+ }
+
+ /**
* Returns a clone of this Flags object.
*/
@SuppressWarnings("unchecked")
+ @Override
public Object clone() {
Flags f = null;
try {
@@ -460,6 +516,47 @@
return f;
}
+ /**
+ * Return a string representation of this Flags object.
+ * Note that the exact format of the string is subject to change.
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ if ((system_flags & ANSWERED_BIT) != 0)
+ sb.append("\\Answered ");
+ if ((system_flags & DELETED_BIT) != 0)
+ sb.append("\\Deleted ");
+ if ((system_flags & DRAFT_BIT) != 0)
+ sb.append("\\Draft ");
+ if ((system_flags & FLAGGED_BIT) != 0)
+ sb.append("\\Flagged ");
+ if ((system_flags & RECENT_BIT) != 0)
+ sb.append("\\Recent ");
+ if ((system_flags & SEEN_BIT) != 0)
+ sb.append("\\Seen ");
+ if ((system_flags & USER_BIT) != 0)
+ sb.append("\\* ");
+
+ boolean first = true;
+ if (user_flags != null) {
+ Enumeration<String> e = user_flags.elements();
+
+ while (e.hasMoreElements()) {
+ if (first)
+ first = false;
+ else
+ sb.append(' ');
+ sb.append(e.nextElement());
+ }
+ }
+
+ if (first && sb.length() > 0)
+ sb.setLength(sb.length() - 1); // smash trailing space
+
+ return sb.toString();
+ }
+
/*****
public static void main(String argv[]) throws Exception {
// a new flags object
diff --git a/current/src/main/java/javax/mail/Folder.java b/current/src/main/java/javax/mail/Folder.java
index 64a476a..74383c3 100644
--- a/current/src/main/java/javax/mail/Folder.java
+++ b/current/src/main/java/javax/mail/Folder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -104,7 +104,7 @@
* Note that a Message's message number can change within a
* session if the containing Folder is expunged using the expunge
* method. Clients that use message numbers as references to messages
- * should be aware of this and should be prepared to deal with
+ * should be aware of this and should be prepared to deal with this
* situation (probably by flushing out existing message number references
* and reloading them). Because of this complexity, it is better for
* clients to use Message objects as references to messages, rather than
@@ -116,7 +116,7 @@
* @author Bill Shannon
*/
-public abstract class Folder {
+public abstract class Folder implements AutoCloseable {
/**
* The parent store.
@@ -193,7 +193,7 @@
public URLName getURLName() throws MessagingException {
URLName storeURL = getStore().getURLName();
String fullname = getFullName();
- StringBuffer encodedName = new StringBuffer();
+ StringBuilder encodedName = new StringBuilder();
if (fullname != null) {
/*
@@ -647,6 +647,29 @@
public abstract void close(boolean expunge) throws MessagingException;
/**
+ * Close this Folder and expunge deleted messages. <p>
+ *
+ * A CLOSED ConnectionEvent is delivered to any ConnectionListeners
+ * registered on this Folder. Note that the folder is closed even
+ * if this method terminates abnormally by throwing a
+ * MessagingException. <p>
+ *
+ * This method supports the {@link java.lang.AutoCloseable AutoCloseable}
+ * interface. <p>
+ *
+ * This implementation calls <code>close(true)</code>.
+ *
+ * @exception IllegalStateException if this folder is not opened
+ * @exception MessagingException for other failures
+ * @see javax.mail.event.ConnectionEvent
+ * @since JavaMail 1.6
+ */
+ @Override
+ public void close() throws MessagingException {
+ close(true);
+ }
+
+ /**
* Indicates whether this Folder is in the 'open' state.
* @return true if this Folder is in the 'open' state.
*/
@@ -1288,7 +1311,7 @@
*/
public Message[] search(SearchTerm term, Message[] msgs)
throws MessagingException {
- List<Message> matchedMsgs = new ArrayList<Message>();
+ List<Message> matchedMsgs = new ArrayList<>();
// Run thru the given messages
for (Message msg : msgs) {
@@ -1337,7 +1360,7 @@
public synchronized void
addConnectionListener(ConnectionListener l) {
if (connectionListeners == null)
- connectionListeners = new Vector<ConnectionListener>();
+ connectionListeners = new Vector<>();
connectionListeners.addElement(l);
}
@@ -1403,7 +1426,7 @@
*/
public synchronized void addFolderListener(FolderListener l) {
if (folderListeners == null)
- folderListeners = new Vector<FolderListener>();
+ folderListeners = new Vector<>();
folderListeners.addElement(l);
}
@@ -1484,7 +1507,7 @@
*/
public synchronized void addMessageCountListener(MessageCountListener l) {
if (messageCountListeners == null)
- messageCountListeners = new Vector<MessageCountListener>();
+ messageCountListeners = new Vector<>();
messageCountListeners.addElement(l);
}
@@ -1574,7 +1597,7 @@
public synchronized void
addMessageChangedListener(MessageChangedListener l) {
if (messageChangedListeners == null)
- messageChangedListeners = new Vector<MessageChangedListener>();
+ messageChangedListeners = new Vector<>();
messageChangedListeners.addElement(l);
}
@@ -1632,6 +1655,7 @@
q.enqueue(event, v);
}
+ @Override
protected void finalize() throws Throwable {
try {
q.terminateQueue();
@@ -1646,6 +1670,7 @@
* the default toString() behavior.
*/
+ @Override
public String toString() {
String s = getFullName();
if (s != null)
diff --git a/current/src/main/java/javax/mail/FolderClosedException.java b/current/src/main/java/javax/mail/FolderClosedException.java
index 3abe28e..cc2b58a 100644
--- a/current/src/main/java/javax/mail/FolderClosedException.java
+++ b/current/src/main/java/javax/mail/FolderClosedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/FolderNotFoundException.java b/current/src/main/java/javax/mail/FolderNotFoundException.java
index bc00eb0..6d46abd 100644
--- a/current/src/main/java/javax/mail/FolderNotFoundException.java
+++ b/current/src/main/java/javax/mail/FolderNotFoundException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Header.java b/current/src/main/java/javax/mail/Header.java
index 1236229..ad3c625 100644
--- a/current/src/main/java/javax/mail/Header.java
+++ b/current/src/main/java/javax/mail/Header.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/IllegalWriteException.java b/current/src/main/java/javax/mail/IllegalWriteException.java
index ea0b7d3..762e392 100644
--- a/current/src/main/java/javax/mail/IllegalWriteException.java
+++ b/current/src/main/java/javax/mail/IllegalWriteException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/MailSessionDefinition.java b/current/src/main/java/javax/mail/MailSessionDefinition.java
index 6f6cfd4..2cdf975 100644
--- a/current/src/main/java/javax/mail/MailSessionDefinition.java
+++ b/current/src/main/java/javax/mail/MailSessionDefinition.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2012-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,6 +44,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.lang.annotation.Repeatable;
/**
* Annotation used by Java EE applications to define a <code>MailSession</code>
@@ -61,6 +62,7 @@
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
+@Repeatable(MailSessionDefinitions.class)
public @interface MailSessionDefinition {
/**
diff --git a/current/src/main/java/javax/mail/MailSessionDefinitions.java b/current/src/main/java/javax/mail/MailSessionDefinitions.java
index 77ea3e4..e6cb46f 100644
--- a/current/src/main/java/javax/mail/MailSessionDefinitions.java
+++ b/current/src/main/java/javax/mail/MailSessionDefinitions.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Message.java b/current/src/main/java/javax/mail/Message.java
index deeb409..254e43b 100644
--- a/current/src/main/java/javax/mail/Message.java
+++ b/current/src/main/java/javax/mail/Message.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -276,6 +276,7 @@
"Attempt to resolve unknown RecipientType: " + type);
}
+ @Override
public String toString() {
return type;
}
diff --git a/current/src/main/java/javax/mail/MessageAware.java b/current/src/main/java/javax/mail/MessageAware.java
index 9642ad2..f48b671 100644
--- a/current/src/main/java/javax/mail/MessageAware.java
+++ b/current/src/main/java/javax/mail/MessageAware.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/MessageContext.java b/current/src/main/java/javax/mail/MessageContext.java
index ed369f2..b7247ea 100644
--- a/current/src/main/java/javax/mail/MessageContext.java
+++ b/current/src/main/java/javax/mail/MessageContext.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/MessageRemovedException.java b/current/src/main/java/javax/mail/MessageRemovedException.java
index 90f4e81..edad8dd 100644
--- a/current/src/main/java/javax/mail/MessageRemovedException.java
+++ b/current/src/main/java/javax/mail/MessageRemovedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/MessagingException.java b/current/src/main/java/javax/mail/MessagingException.java
index 2055c31..3212e6b 100644
--- a/current/src/main/java/javax/mail/MessagingException.java
+++ b/current/src/main/java/javax/mail/MessagingException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -112,6 +112,7 @@
*
* @return next Exception, null if none.
*/
+ @Override
public synchronized Throwable getCause() {
return next;
}
@@ -144,12 +145,13 @@
* Override toString method to provide information on
* nested exceptions.
*/
+ @Override
public synchronized String toString() {
String s = super.toString();
Exception n = next;
if (n == null)
return s;
- StringBuffer sb = new StringBuffer(s == null ? "" : s);
+ StringBuilder sb = new StringBuilder(s == null ? "" : s);
while (n != null) {
sb.append(";\n nested exception is:\n\t");
if (n instanceof MessagingException) {
diff --git a/current/src/main/java/javax/mail/MethodNotSupportedException.java b/current/src/main/java/javax/mail/MethodNotSupportedException.java
index f23b937..c1f360e 100644
--- a/current/src/main/java/javax/mail/MethodNotSupportedException.java
+++ b/current/src/main/java/javax/mail/MethodNotSupportedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Multipart.java b/current/src/main/java/javax/mail/Multipart.java
index bb7dc74..0c99a6f 100644
--- a/current/src/main/java/javax/mail/Multipart.java
+++ b/current/src/main/java/javax/mail/Multipart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -69,8 +69,7 @@
/**
* Vector of BodyPart objects.
*/
- @SuppressWarnings("rawtypes")
- protected Vector parts = new Vector(); // Holds BodyParts
+ protected Vector<BodyPart> parts = new Vector<>(); // Holds BodyParts
/**
* This field specifies the content-type of this multipart
@@ -156,7 +155,7 @@
if (parts == null)
throw new IndexOutOfBoundsException("No such BodyPart");
- return (BodyPart)parts.elementAt(index);
+ return parts.elementAt(index);
}
/**
@@ -197,7 +196,7 @@
if (parts == null)
throw new IndexOutOfBoundsException("No such BodyPart");
- BodyPart part = (BodyPart)parts.elementAt(index);
+ BodyPart part = parts.elementAt(index);
parts.removeElementAt(index);
part.setParent(null);
}
@@ -212,11 +211,10 @@
* of existing values
* @exception MessagingException for other failures
*/
- @SuppressWarnings("unchecked")
public synchronized void addBodyPart(BodyPart part)
throws MessagingException {
if (parts == null)
- parts = new Vector<BodyPart>();
+ parts = new Vector<>();
parts.addElement(part);
part.setParent(this);
@@ -236,11 +234,10 @@
* of existing values
* @exception MessagingException for other failures
*/
- @SuppressWarnings("unchecked")
public synchronized void addBodyPart(BodyPart part, int index)
throws MessagingException {
if (parts == null)
- parts = new Vector<BodyPart>();
+ parts = new Vector<>();
parts.insertElementAt(part, index);
part.setParent(this);
diff --git a/current/src/main/java/javax/mail/MultipartDataSource.java b/current/src/main/java/javax/mail/MultipartDataSource.java
index 8654dde..1eb2cf1 100644
--- a/current/src/main/java/javax/mail/MultipartDataSource.java
+++ b/current/src/main/java/javax/mail/MultipartDataSource.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/NoSuchProviderException.java b/current/src/main/java/javax/mail/NoSuchProviderException.java
index b453c58..6794d9c 100644
--- a/current/src/main/java/javax/mail/NoSuchProviderException.java
+++ b/current/src/main/java/javax/mail/NoSuchProviderException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Part.java b/current/src/main/java/javax/mail/Part.java
index 3227d7f..10727f2 100644
--- a/current/src/main/java/javax/mail/Part.java
+++ b/current/src/main/java/javax/mail/Part.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -449,8 +449,7 @@
* @return enumeration of Header objects
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaders() throws MessagingException;
+ public Enumeration<Header> getAllHeaders() throws MessagingException;
/**
* Return matching headers from this part as an Enumeration of
@@ -460,8 +459,7 @@
* @return enumeration of Header objects
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaders(String[] header_names)
+ public Enumeration<Header> getMatchingHeaders(String[] header_names)
throws MessagingException;
/**
@@ -472,7 +470,6 @@
* @return enumeration of Header objects
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaders(String[] header_names)
+ public Enumeration<Header> getNonMatchingHeaders(String[] header_names)
throws MessagingException;
}
diff --git a/current/src/main/java/javax/mail/PasswordAuthentication.java b/current/src/main/java/javax/mail/PasswordAuthentication.java
index 1a358a3..0b1d631 100644
--- a/current/src/main/java/javax/mail/PasswordAuthentication.java
+++ b/current/src/main/java/javax/mail/PasswordAuthentication.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Provider.java b/current/src/main/java/javax/mail/Provider.java
index 6d3960d..788a599 100644
--- a/current/src/main/java/javax/mail/Provider.java
+++ b/current/src/main/java/javax/mail/Provider.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -69,6 +69,7 @@
this.type = type;
}
+ @Override
public String toString() {
return type;
}
@@ -144,6 +145,7 @@
}
/** Overrides Object.toString() */
+ @Override
public String toString() {
String s = "javax.mail.Provider[" + type + "," +
protocol + "," + className;
diff --git a/current/src/main/java/javax/mail/Quota.java b/current/src/main/java/javax/mail/Quota.java
index 6c6b451..83516aa 100644
--- a/current/src/main/java/javax/mail/Quota.java
+++ b/current/src/main/java/javax/mail/Quota.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/QuotaAwareStore.java b/current/src/main/java/javax/mail/QuotaAwareStore.java
index 1ff1b23..a5c196f 100644
--- a/current/src/main/java/javax/mail/QuotaAwareStore.java
+++ b/current/src/main/java/javax/mail/QuotaAwareStore.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/ReadOnlyFolderException.java b/current/src/main/java/javax/mail/ReadOnlyFolderException.java
index 3cca9e0..fe7b1ab 100644
--- a/current/src/main/java/javax/mail/ReadOnlyFolderException.java
+++ b/current/src/main/java/javax/mail/ReadOnlyFolderException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/SendFailedException.java b/current/src/main/java/javax/mail/SendFailedException.java
index e121a1a..8e5d66a 100644
--- a/current/src/main/java/javax/mail/SendFailedException.java
+++ b/current/src/main/java/javax/mail/SendFailedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Service.java b/current/src/main/java/javax/mail/Service.java
index 0ff3364..b2815e7 100644
--- a/current/src/main/java/javax/mail/Service.java
+++ b/current/src/main/java/javax/mail/Service.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -59,7 +59,7 @@
* @author Kanwar Oberoi
*/
-public abstract class Service {
+public abstract class Service implements AutoCloseable {
/**
* The session from which this service was created.
@@ -87,7 +87,7 @@
* deadlocks when notifying listeners.)
*/
private final Vector<ConnectionListener> connectionListeners
- = new Vector<ConnectionListener>();
+ = new Vector<>();
/**
* The queue of events to be delivered.
@@ -623,6 +623,7 @@
* Return <code>getURLName.toString()</code> if this service has a URLName,
* otherwise it will return the default <code>toString</code>.
*/
+ @Override
public String toString() {
URLName url = getURLName();
if (url != null)
@@ -637,8 +638,8 @@
* @param event the event
* @param vector the vector of listeners
*/
- @SuppressWarnings("rawtypes")
- protected void queueEvent(MailEvent event, Vector vector) {
+ protected void queueEvent(MailEvent event,
+ Vector<? extends EventListener> vector) {
/*
* Copy the vector in order to freeze the state of the set
* of EventListeners the event should be delivered to prior
@@ -655,6 +656,7 @@
/**
* Stop the event dispatcher thread so the queue can be garbage collected.
*/
+ @Override
protected void finalize() throws Throwable {
try {
q.terminateQueue();
diff --git a/current/src/main/java/javax/mail/Session.java b/current/src/main/java/javax/mail/Session.java
index 24cdc19..16e757e 100644
--- a/current/src/main/java/javax/mail/Session.java
+++ b/current/src/main/java/javax/mail/Session.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,19 +44,20 @@
import java.io.*;
import java.net.*;
import java.security.*;
-import java.util.Enumeration;
+import java.util.Collections;
import java.util.Hashtable;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
-import java.util.Vector;
+import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.concurrent.Executor;
-
import com.sun.mail.util.LineInputStream;
import com.sun.mail.util.MailLogger;
-import java.util.Collections;
-import java.util.List;
/**
* The Session class represents a mail session and is not subclassed.
@@ -77,18 +78,24 @@
* Each <code>javamail.</code><i>X</i> resource file is searched for using
* three methods in the following order:
* <ol>
- * <li> <code>java.home/lib/javamail.</code><i>X</i> </li>
+ * <li> <code><i>java.home</i>/<i>conf</i>/javamail.</code><i>X</i> </li>
* <li> <code>META-INF/javamail.</code><i>X</i> </li>
* <li> <code>META-INF/javamail.default.</code><i>X</i> </li>
* </ol>
* <p>
+ * (Where <i>java.home</i> is the value of the "java.home" System property
+ * and <i>conf</i> is the directory named "conf" if it exists,
+ * otherwise the directory named "lib"; the "conf" directory was
+ * introduced in JDK 1.9.)
+ * <p>
* The first method allows the user to include their own version of the
- * resource file by placing it in the <code>lib</code> directory where the
+ * resource file by placing it in the <i>conf</i> directory where the
* <code>java.home</code> property points. The second method allows an
* application that uses the JavaMail APIs to include their own resource
* files in their application's or jar file's <code>META-INF</code>
* directory. The <code>javamail.default.</code><i>X</i> default files
- * are part of the JavaMail <code>mail.jar</code> file. <p>
+ * are part of the JavaMail <code>mail.jar</code> file and should not be
+ * supplied by users. <p>
*
* File location depends upon how the <code>ClassLoader</code> method
* <code>getResource</code> is implemented. Usually, the
@@ -152,6 +159,29 @@
* protocol=smtp; type=transport; class=com.sun.mail.smtp.SMTPTransport; vendor=Oracle;
* </pre><p>
*
+ * The current implementation also supports configuring providers using
+ * the Java SE {@link java.util.ServiceLoader ServiceLoader} mechanism.
+ * When creating your own provider, create a {@link Provider} subclass,
+ * for example:
+ * <pre>
+ * package com.example;
+ *
+ * import javax.mail.Provider;
+ *
+ * public class MyProvider extends Provider {
+ * public MyProvider() {
+ * super(Provider.Type.STORE, "myprot", MyStore.class.getName(),
+ * "Example", null);
+ * }
+ * }
+ * </pre>
+ * Then include a file named <code>META-INF/services/javax.mail.Provider</code>
+ * in your jar file that lists the name of your Provider class:
+ * <pre>
+ * com.example.MyProvider
+ * </pre>
+ * <p>
+ *
* <b><code>javamail.address.map</code></b> and
* <b><code>javamail.default.address.map</code></b><p>
*
@@ -186,23 +216,47 @@
private final Properties props;
private final Authenticator authenticator;
private final Hashtable<URLName, PasswordAuthentication> authTable
- = new Hashtable<URLName, PasswordAuthentication>();
+ = new Hashtable<>();
private boolean debug = false;
private PrintStream out; // debug output stream
private MailLogger logger;
- private final Vector<Provider> providers = new Vector<Provider>();
- private final Hashtable<String, Provider> providersByProtocol
- = new Hashtable<String, Provider>();
- private final Hashtable<String, Provider> providersByClassName
- = new Hashtable<String, Provider>();
+ private List<Provider> providers;
+ private final Map<String, Provider> providersByProtocol = new HashMap<>();
+ private final Map<String, Provider> providersByClassName = new HashMap<>();
private final Properties addressMap = new Properties();
// maps type to protocol
+ private boolean loadedProviders; // javamail.[default.]providers loaded?
// the queue of events to be delivered, if mail.event.scope===session
private final EventQueue q;
// The default session.
private static Session defaultSession = null;
+ private static final String confDir;
+
+ static {
+ String dir = null;
+ try {
+ dir = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ String home = System.getProperty("java.home");
+ String newdir = home + File.separator + "conf";
+ File conf = new File(newdir);
+ if (conf.exists())
+ return newdir + File.separator;
+ else
+ return home + File.separator +
+ "lib" + File.separator;
+ }
+ });
+ } catch (Exception ex) {
+ // ignore any exceptions
+ }
+ confDir = dir;
+ }
+
// Constructor is not public
private Session(Properties props, Authenticator authenticator) {
this.props = props;
@@ -221,7 +275,6 @@
else
cl = this.getClass();
// load the resources
- loadProviders(cl);
loadAddressMap(cl);
q = new EventQueue((Executor)props.get("mail.event.executor"));
}
@@ -433,8 +486,21 @@
* @return Array of configured providers
*/
public synchronized Provider[] getProviders() {
- Provider[] _providers = new Provider[providers.size()];
- providers.copyInto(_providers);
+ List<Provider> plist = new ArrayList<Provider>();
+ boolean needFallback = true;
+ // first, add all the services
+ ServiceLoader<Provider> loader = ServiceLoader.load(Provider.class);
+ for (Provider p : loader) {
+ plist.add(p);
+ needFallback = false;
+ }
+ // then, add all the providers from config files
+ if (!loadedProviders)
+ loadProviders(needFallback);
+ if (providers != null)
+ plist.addAll(providers);
+ Provider[] _providers = new Provider[plist.size()];
+ plist.toArray(_providers);
return _providers;
}
@@ -469,15 +535,11 @@
".class property exists and points to " +
_className);
}
- _provider = providersByClassName.get(_className);
+ _provider = getProviderByClassName(_className);
}
- if (_provider != null) {
- return _provider;
- } else {
- // returning currently default protocol in providersByProtocol
- _provider = providersByProtocol.get(protocol);
- }
+ if (_provider == null)
+ _provider = getProviderByProtocol(protocol);
if (_provider == null) {
throw new NoSuchProviderException("No provider for " + protocol);
@@ -504,6 +566,7 @@
throw new NoSuchProviderException("Can't set null provider");
}
providersByProtocol.put(provider.getProtocol(), provider);
+ providersByClassName.put(provider.getClassName(), provider);
props.put("mail." + provider.getProtocol() + ".class",
provider.getClassName());
}
@@ -911,32 +974,96 @@
}
/**
- * Load the protocol providers config files.
+ * Get the Provider that uses the specified class name.
+ *
+ * @param className the class name
+ * @return the Provider
*/
- private void loadProviders(Class<?> cl) {
+ private Provider getProviderByClassName(String className) {
+ // first, try our local list of providers
+ Provider p = providersByClassName.get(className);
+ if (p != null)
+ return p;
+
+ // now, try services
+ ServiceLoader<Provider> loader = ServiceLoader.load(Provider.class);
+ for (Provider pp : loader) {
+ if (className.equals(pp.getClassName()))
+ return pp;
+ }
+
+ // finally, if we haven't loaded our config, load it and try again
+ if (!loadedProviders) {
+ loadProviders(true);
+ p = providersByClassName.get(className);
+ }
+ return p;
+ }
+
+ /**
+ * Get the Provider for the specified protocol.
+ *
+ * @param protocol the protocol
+ * @return the Provider
+ */
+ private Provider getProviderByProtocol(String protocol) {
+ // first, try our local list of providers
+ Provider p = providersByProtocol.get(protocol);
+ if (p != null)
+ return p;
+
+ // now, try services
+ ServiceLoader<Provider> loader = ServiceLoader.load(Provider.class);
+ for (Provider pp : loader) {
+ if (protocol.equals(pp.getProtocol()))
+ return pp;
+ }
+
+ // finally, if we haven't loaded our config, load it and try again
+ if (!loadedProviders) {
+ loadProviders(true);
+ p = providersByProtocol.get(protocol);
+ }
+ return p;
+ }
+
+ /**
+ * Load the protocol providers config files.
+ * If fallback is true, provide built in defaults if nothing is loaded.
+ */
+ private void loadProviders(boolean fallback) {
StreamLoader loader = new StreamLoader() {
+ @Override
public void load(InputStream is) throws IOException {
loadProvidersFromStream(is);
}
};
- // load system-wide javamail.providers from the <java.home>/lib dir
+ // load system-wide javamail.providers from the
+ // <java.home>/{conf,lib} directory
try {
- String res = System.getProperty("java.home") +
- File.separator + "lib" +
- File.separator + "javamail.providers";
- loadFile(res, loader);
- } catch (SecurityException sex) {
- logger.log(Level.CONFIG, "can't get java.home", sex);
- }
+ if (confDir != null)
+ loadFile(confDir + "javamail.providers", loader);
+ } catch (SecurityException ex) {}
+
+ // get the Class associated with the Authenticator
+ Class<?> cl;
+ if (authenticator != null)
+ cl = authenticator.getClass();
+ else
+ cl = this.getClass();
// load the META-INF/javamail.providers file supplied by an application
loadAllResources("META-INF/javamail.providers", cl, loader);
// load default META-INF/javamail.default.providers from mail.jar file
- loadResource("/META-INF/javamail.default.providers", cl, loader);
+ loadResource("/META-INF/javamail.default.providers", cl, loader, false);
- if (providers.size() == 0) {
+ /*
+ * If we haven't loaded any providers and the fallback configuration
+ * is needed, fake it.
+ */
+ if ((providers == null || providers.size() == 0) && fallback) {
logger.config("failed to load any providers, using defaults");
// failed to load any providers, initialize with our defaults
addProvider(new Provider(Provider.Type.STORE,
@@ -961,12 +1088,13 @@
if (logger.isLoggable(Level.CONFIG)) {
// dump the output of the tables for debugging
- logger.config("Tables of loaded providers");
+ logger.config("Tables of loaded providers from javamail.providers");
logger.config("Providers Listed By Class Name: " +
providersByClassName.toString());
logger.config("Providers Listed By Protocol: " +
providersByProtocol.toString());
}
+ loadedProviders = true;
}
private void loadProvidersFromStream(InputStream is)
@@ -980,6 +1108,8 @@
if (currLine.startsWith("#"))
continue;
+ if (currLine.trim().length() == 0)
+ continue; // skip blank line
Provider.Type type = null;
String protocol = null, className = null;
String vendor = null, version = null;
@@ -1033,7 +1163,9 @@
* @since JavaMail 1.4
*/
public synchronized void addProvider(Provider provider) {
- providers.addElement(provider);
+ if (providers == null)
+ providers = new ArrayList<Provider>();
+ providers.add(provider);
providersByClassName.put(provider.getClassName(), provider);
if (!providersByProtocol.containsKey(provider.getProtocol()))
providersByProtocol.put(provider.getProtocol(), provider);
@@ -1043,26 +1175,24 @@
// map is loaded last since its entries will override the previous ones
private void loadAddressMap(Class<?> cl) {
StreamLoader loader = new StreamLoader() {
+ @Override
public void load(InputStream is) throws IOException {
addressMap.load(is);
}
};
// load default META-INF/javamail.default.address.map from mail.jar
- loadResource("/META-INF/javamail.default.address.map", cl, loader);
+ loadResource("/META-INF/javamail.default.address.map", cl, loader, true);
// load the META-INF/javamail.address.map file supplied by an app
loadAllResources("META-INF/javamail.address.map", cl, loader);
- // load system-wide javamail.address.map from the <java.home>/lib dir
+ // load system-wide javamail.address.map from the
+ // <java.home>/{conf,lib} directory
try {
- String res = System.getProperty("java.home") +
- File.separator + "lib" +
- File.separator + "javamail.address.map";
- loadFile(res, loader);
- } catch (SecurityException sex) {
- logger.log(Level.CONFIG, "can't get java.home", sex);
- }
+ if (confDir != null)
+ loadFile(confDir + "javamail.address.map", loader);
+ } catch (SecurityException ex) {}
if (addressMap.isEmpty()) {
logger.config("failed to load address map, using defaults");
@@ -1117,7 +1247,8 @@
/**
* Load from the named resource.
*/
- private void loadResource(String name, Class<?> cl, StreamLoader loader) {
+ private void loadResource(String name, Class<?> cl, StreamLoader loader,
+ boolean expected) {
InputStream clis = null;
try {
clis = getResourceAsStream(cl, name);
@@ -1126,9 +1257,9 @@
logger.log(Level.CONFIG, "successfully loaded resource: {0}",
name);
} else {
- /*
- logger.log(Level.CONFIG, "not loading resource: {0}", name);
- */
+ if (expected)
+ logger.log(Level.WARNING,
+ "expected resource not found: {0}", name);
}
} catch (IOException e) {
logger.log(Level.CONFIG, "Exception loading resource", e);
@@ -1200,7 +1331,7 @@
/*
logger.config("!anyLoaded");
*/
- loadResource("/" + name, cl, loader);
+ loadResource("/" + name, cl, loader, false);
}
}
@@ -1211,6 +1342,7 @@
static ClassLoader getContextClassLoader() {
return AccessController.doPrivileged(
new PrivilegedAction<ClassLoader>() {
+ @Override
public ClassLoader run() {
ClassLoader cl = null;
try {
@@ -1228,6 +1360,7 @@
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<InputStream>() {
+ @Override
public InputStream run() throws IOException {
try {
return c.getResourceAsStream(name);
@@ -1248,6 +1381,7 @@
private static URL[] getResources(final ClassLoader cl, final String name) {
return AccessController.doPrivileged(new PrivilegedAction<URL[]>() {
+ @Override
public URL[] run() {
URL[] ret = null;
try {
@@ -1265,6 +1399,7 @@
private static URL[] getSystemResources(final String name) {
return AccessController.doPrivileged(new PrivilegedAction<URL[]>() {
+ @Override
public URL[] run() {
URL[] ret = null;
try {
@@ -1285,6 +1420,7 @@
try {
return AccessController.doPrivileged(
new PrivilegedExceptionAction<InputStream>() {
+ @Override
public InputStream run() throws IOException {
return url.openStream();
}
diff --git a/current/src/main/java/javax/mail/Store.java b/current/src/main/java/javax/mail/Store.java
index 6dc70c4..3e769c4 100644
--- a/current/src/main/java/javax/mail/Store.java
+++ b/current/src/main/java/javax/mail/Store.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -204,7 +204,7 @@
*/
public synchronized void addStoreListener(StoreListener l) {
if (storeListeners == null)
- storeListeners = new Vector<StoreListener>();
+ storeListeners = new Vector<>();
storeListeners.addElement(l);
}
@@ -260,7 +260,7 @@
*/
public synchronized void addFolderListener(FolderListener l) {
if (folderListeners == null)
- folderListeners = new Vector<FolderListener>();
+ folderListeners = new Vector<>();
folderListeners.addElement(l);
}
diff --git a/current/src/main/java/javax/mail/StoreClosedException.java b/current/src/main/java/javax/mail/StoreClosedException.java
index 2a79d2b..5559fad 100644
--- a/current/src/main/java/javax/mail/StoreClosedException.java
+++ b/current/src/main/java/javax/mail/StoreClosedException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/Transport.java b/current/src/main/java/javax/mail/Transport.java
index e51248b..8ee10c6 100644
--- a/current/src/main/java/javax/mail/Transport.java
+++ b/current/src/main/java/javax/mail/Transport.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -214,12 +214,12 @@
* indexed by address type
*/
Map<String, List<Address>> protocols
- = new HashMap<String, List<Address>>();
+ = new HashMap<>();
// Lists of addresses
- List<Address> invalid = new ArrayList<Address>();
- List<Address> validSent = new ArrayList<Address>();
- List<Address> validUnsent = new ArrayList<Address>();
+ List<Address> invalid = new ArrayList<>();
+ List<Address> validSent = new ArrayList<>();
+ List<Address> validUnsent = new ArrayList<>();
for (int i = 0; i < addresses.length; i++) {
// is this address type already in the map?
@@ -228,7 +228,7 @@
v.add(addresses[i]);
} else {
// need to add a new protocol
- List<Address> w = new ArrayList<Address>();
+ List<Address> w = new ArrayList<>();
w.add(addresses[i]);
protocols.put(addresses[i].getType(), w);
}
@@ -377,7 +377,7 @@
*/
public synchronized void addTransportListener(TransportListener l) {
if (transportListeners == null)
- transportListeners = new Vector<TransportListener>();
+ transportListeners = new Vector<>();
transportListeners.addElement(l);
}
diff --git a/current/src/main/java/javax/mail/UIDFolder.java b/current/src/main/java/javax/mail/UIDFolder.java
index fd3e9e2..bbe3d01 100644
--- a/current/src/main/java/javax/mail/UIDFolder.java
+++ b/current/src/main/java/javax/mail/UIDFolder.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -75,6 +75,7 @@
*
* </pre></blockquote><p>
*
+ * @author Bill Shannon
* @author John Mani
*/
@@ -119,7 +120,24 @@
*
* @see #getMessagesByUID
*/
- public final static long LASTUID = -1;
+ public static final long LASTUID = -1;
+
+ /**
+ * The largest value possible for a UID, a 32-bit unsigned integer.
+ * This can be used to fetch all new messages by keeping track of the
+ * last UID that was seen and using:
+ * <blockquote><pre>
+ *
+ * Folder f = store.getFolder("whatever");
+ * UIDFolder uf = (UIDFolder)f;
+ * Message[] newMsgs =
+ * uf.getMessagesByUID(lastSeenUID + 1, UIDFolder.MAXUID);
+ *
+ * </pre></blockquote><p>
+ *
+ * @since JavaMail 1.6
+ */
+ public static final long MAXUID = 0xffffffffL; // max 32-bit unsigned int
/**
* Returns the UIDValidity value associated with this folder. <p>
@@ -191,4 +209,22 @@
* @exception MessagingException for other failures
*/
public long getUID(Message message) throws MessagingException;
+
+ /**
+ * Returns the predicted UID that will be assigned to the
+ * next message that is appended to this folder.
+ * Messages might be appended to the folder after this value
+ * is retrieved, causing this value to be out of date.
+ * This value might only be updated when a folder is first opened.
+ * Note that messages may have been appended to the folder
+ * while it was open and thus this value may be out of
+ * date. <p>
+ *
+ * If the value is unknown, -1 is returned. <p>
+ *
+ * @return the UIDNEXT value, or -1 if unknown
+ * @exception MessagingException for failures
+ * @since JavaMail 1.6
+ */
+ public long getUIDNext() throws MessagingException;
}
diff --git a/current/src/main/java/javax/mail/URLName.java b/current/src/main/java/javax/mail/URLName.java
index 92a8b5c..1e28a32 100644
--- a/current/src/main/java/javax/mail/URLName.java
+++ b/current/src/main/java/javax/mail/URLName.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -189,10 +189,11 @@
/**
* Constructs a string representation of this URLName.
*/
+ @Override
public String toString() {
if (fullURL == null) {
// add the "protocol:"
- StringBuffer tempURL = new StringBuffer();
+ StringBuilder tempURL = new StringBuilder();
if (protocol != null) {
tempURL.append(protocol);
tempURL.append(":");
@@ -409,7 +410,13 @@
* @exception MalformedURLException if the URL is malformed
*/
public URL getURL() throws MalformedURLException {
- return new URL(getProtocol(), getHost(), getPort(), getFile());
+ // URL expects the file to include the separating "/"
+ String f = getFile();
+ if (f == null)
+ f = "";
+ else
+ f = "/" + f;
+ return new URL(getProtocol(), getHost(), getPort(), f);
}
/**
@@ -433,6 +440,7 @@
* Note also that the password field is not included in the comparison,
* nor is any reference field appended to the filename.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof URLName))
return false;
@@ -485,6 +493,7 @@
/**
* Compute the hash code for this URLName.
*/
+ @Override
public int hashCode() {
if (hashCode != 0)
return hashCode;
@@ -589,7 +598,7 @@
private static String _encode(String s) {
int maxBytesPerChar = 10;
- StringBuffer out = new StringBuffer(s.length());
+ StringBuilder out = new StringBuilder(s.length());
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
OutputStreamWriter writer = new OutputStreamWriter(buf);
@@ -668,7 +677,7 @@
if (indexOfAny(s, "+%") == -1)
return s; // the common case
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
switch (c) {
diff --git a/current/src/main/java/javax/mail/event/ConnectionAdapter.java b/current/src/main/java/javax/mail/event/ConnectionAdapter.java
index bba2da9..eff1b2c 100644
--- a/current/src/main/java/javax/mail/event/ConnectionAdapter.java
+++ b/current/src/main/java/javax/mail/event/ConnectionAdapter.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -49,7 +49,10 @@
* @author John Mani
*/
public abstract class ConnectionAdapter implements ConnectionListener {
+ @Override
public void opened(ConnectionEvent e) {}
+ @Override
public void disconnected(ConnectionEvent e) {}
+ @Override
public void closed(ConnectionEvent e) {}
}
diff --git a/current/src/main/java/javax/mail/event/ConnectionEvent.java b/current/src/main/java/javax/mail/event/ConnectionEvent.java
index b9f2e58..38f3356 100644
--- a/current/src/main/java/javax/mail/event/ConnectionEvent.java
+++ b/current/src/main/java/javax/mail/event/ConnectionEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -89,6 +89,7 @@
/**
* Invokes the appropriate ConnectionListener method
*/
+ @Override
public void dispatch(Object listener) {
if (type == OPENED)
((ConnectionListener)listener).opened(this);
diff --git a/current/src/main/java/javax/mail/event/ConnectionListener.java b/current/src/main/java/javax/mail/event/ConnectionListener.java
index db59c24..d6f96b5 100644
--- a/current/src/main/java/javax/mail/event/ConnectionListener.java
+++ b/current/src/main/java/javax/mail/event/ConnectionListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/FolderAdapter.java b/current/src/main/java/javax/mail/event/FolderAdapter.java
index ae9cbda..057bad5 100644
--- a/current/src/main/java/javax/mail/event/FolderAdapter.java
+++ b/current/src/main/java/javax/mail/event/FolderAdapter.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -49,7 +49,10 @@
* @author John Mani
*/
public abstract class FolderAdapter implements FolderListener {
+ @Override
public void folderCreated(FolderEvent e) {}
+ @Override
public void folderRenamed(FolderEvent e) {}
+ @Override
public void folderDeleted(FolderEvent e) {}
}
diff --git a/current/src/main/java/javax/mail/event/FolderEvent.java b/current/src/main/java/javax/mail/event/FolderEvent.java
index 1d48fa1..f637db4 100644
--- a/current/src/main/java/javax/mail/event/FolderEvent.java
+++ b/current/src/main/java/javax/mail/event/FolderEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -156,6 +156,7 @@
/**
* Invokes the appropriate FolderListener method
*/
+ @Override
public void dispatch(Object listener) {
if (type == CREATED)
((FolderListener)listener).folderCreated(this);
diff --git a/current/src/main/java/javax/mail/event/FolderListener.java b/current/src/main/java/javax/mail/event/FolderListener.java
index 196d7ac..d5ca4b6 100644
--- a/current/src/main/java/javax/mail/event/FolderListener.java
+++ b/current/src/main/java/javax/mail/event/FolderListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/MailEvent.java b/current/src/main/java/javax/mail/event/MailEvent.java
index e2b9ba4..682b8e0 100644
--- a/current/src/main/java/javax/mail/event/MailEvent.java
+++ b/current/src/main/java/javax/mail/event/MailEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/MessageChangedEvent.java b/current/src/main/java/javax/mail/event/MessageChangedEvent.java
index bdfff17..be9f1ec 100644
--- a/current/src/main/java/javax/mail/event/MessageChangedEvent.java
+++ b/current/src/main/java/javax/mail/event/MessageChangedEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -101,6 +101,7 @@
/**
* Invokes the appropriate MessageChangedListener method.
*/
+ @Override
public void dispatch(Object listener) {
((MessageChangedListener)listener).messageChanged(this);
}
diff --git a/current/src/main/java/javax/mail/event/MessageChangedListener.java b/current/src/main/java/javax/mail/event/MessageChangedListener.java
index 65fda16..608d3af 100644
--- a/current/src/main/java/javax/mail/event/MessageChangedListener.java
+++ b/current/src/main/java/javax/mail/event/MessageChangedListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/MessageCountAdapter.java b/current/src/main/java/javax/mail/event/MessageCountAdapter.java
index 2795b13..8972dd5 100644
--- a/current/src/main/java/javax/mail/event/MessageCountAdapter.java
+++ b/current/src/main/java/javax/mail/event/MessageCountAdapter.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -49,6 +49,8 @@
* @author John Mani
*/
public abstract class MessageCountAdapter implements MessageCountListener {
+ @Override
public void messagesAdded(MessageCountEvent e) {}
+ @Override
public void messagesRemoved(MessageCountEvent e) {}
}
diff --git a/current/src/main/java/javax/mail/event/MessageCountEvent.java b/current/src/main/java/javax/mail/event/MessageCountEvent.java
index 5167b86..0feac7e 100644
--- a/current/src/main/java/javax/mail/event/MessageCountEvent.java
+++ b/current/src/main/java/javax/mail/event/MessageCountEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -148,6 +148,7 @@
/**
* Invokes the appropriate MessageCountListener method.
*/
+ @Override
public void dispatch(Object listener) {
if (type == ADDED)
((MessageCountListener)listener).messagesAdded(this);
diff --git a/current/src/main/java/javax/mail/event/MessageCountListener.java b/current/src/main/java/javax/mail/event/MessageCountListener.java
index 1470e5c..40e38e5 100644
--- a/current/src/main/java/javax/mail/event/MessageCountListener.java
+++ b/current/src/main/java/javax/mail/event/MessageCountListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/StoreEvent.java b/current/src/main/java/javax/mail/event/StoreEvent.java
index 5aca40e..288483f 100644
--- a/current/src/main/java/javax/mail/event/StoreEvent.java
+++ b/current/src/main/java/javax/mail/event/StoreEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -116,6 +116,7 @@
/**
* Invokes the appropriate StoreListener method.
*/
+ @Override
public void dispatch(Object listener) {
((StoreListener)listener).notification(this);
}
diff --git a/current/src/main/java/javax/mail/event/StoreListener.java b/current/src/main/java/javax/mail/event/StoreListener.java
index 5c3c807..47ca884 100644
--- a/current/src/main/java/javax/mail/event/StoreListener.java
+++ b/current/src/main/java/javax/mail/event/StoreListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/TransportAdapter.java b/current/src/main/java/javax/mail/event/TransportAdapter.java
index 155fc71..4f2ba8a 100644
--- a/current/src/main/java/javax/mail/event/TransportAdapter.java
+++ b/current/src/main/java/javax/mail/event/TransportAdapter.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -49,7 +49,10 @@
* @author John Mani
*/
public abstract class TransportAdapter implements TransportListener {
+ @Override
public void messageDelivered(TransportEvent e) {}
+ @Override
public void messageNotDelivered(TransportEvent e) {}
+ @Override
public void messagePartiallyDelivered(TransportEvent e) {}
}
diff --git a/current/src/main/java/javax/mail/event/TransportEvent.java b/current/src/main/java/javax/mail/event/TransportEvent.java
index c32ba02..96fca48 100644
--- a/current/src/main/java/javax/mail/event/TransportEvent.java
+++ b/current/src/main/java/javax/mail/event/TransportEvent.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -166,6 +166,7 @@
/**
* Invokes the appropriate TransportListener method.
*/
+ @Override
public void dispatch(Object listener) {
if (type == MESSAGE_DELIVERED)
((TransportListener)listener).messageDelivered(this);
diff --git a/current/src/main/java/javax/mail/event/TransportListener.java b/current/src/main/java/javax/mail/event/TransportListener.java
index 2b90b07..86e8628 100644
--- a/current/src/main/java/javax/mail/event/TransportListener.java
+++ b/current/src/main/java/javax/mail/event/TransportListener.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/event/package.html b/current/src/main/java/javax/mail/event/package.html
deleted file mode 100644
index 05dfb07..0000000
--- a/current/src/main/java/javax/mail/event/package.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-Listeners and events for the JavaMail API.
-This package defines listener classes and event classes used by the classes
-defined in the <code>javax.mail</code> package.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/javax/mail/internet/AddressException.java b/current/src/main/java/javax/mail/internet/AddressException.java
index 93afa08..9a2e0ef 100644
--- a/current/src/main/java/javax/mail/internet/AddressException.java
+++ b/current/src/main/java/javax/mail/internet/AddressException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -125,6 +125,7 @@
return pos;
}
+ @Override
public String toString() {
String s = super.toString();
if (ref == null)
diff --git a/current/src/main/java/javax/mail/internet/ContentDisposition.java b/current/src/main/java/javax/mail/internet/ContentDisposition.java
index 1e50433..36c4aba 100644
--- a/current/src/main/java/javax/mail/internet/ContentDisposition.java
+++ b/current/src/main/java/javax/mail/internet/ContentDisposition.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -43,6 +43,7 @@
import javax.mail.*;
import java.util.*;
import java.io.*;
+import com.sun.mail.util.PropUtil;
/**
* This class represents a MIME ContentDisposition value. It provides
@@ -54,6 +55,9 @@
public class ContentDisposition {
+ private static final boolean contentDispositionStrict =
+ PropUtil.getBooleanSystemProperty("mail.mime.contentdisposition.strict", true);
+
private String disposition; // disposition
private ParameterList list; // parameter list
@@ -89,15 +93,26 @@
// First "disposition" ..
tk = h.next();
- if (tk.getType() != HeaderTokenizer.Token.ATOM)
- throw new ParseException("Expected disposition, got " +
- tk.getValue());
- disposition = tk.getValue();
+ if (tk.getType() != HeaderTokenizer.Token.ATOM) {
+ if (contentDispositionStrict) {
+ throw new ParseException("Expected disposition, got " +
+ tk.getValue());
+ }
+ } else {
+ disposition = tk.getValue();
+ }
// Then parameters ..
String rem = h.getRemainder();
- if (rem != null)
- list = new ParameterList(rem);
+ if (rem != null) {
+ try {
+ list = new ParameterList(rem);
+ } catch (ParseException px) {
+ if (contentDispositionStrict) {
+ throw px;
+ }
+ }
+ }
}
/**
@@ -176,6 +191,7 @@
* @return RFC2045 style string
* @since JavaMail 1.2
*/
+ @Override
public String toString() {
if (disposition == null)
return "";
@@ -183,7 +199,7 @@
if (list == null)
return disposition;
- StringBuffer sb = new StringBuffer(disposition);
+ StringBuilder sb = new StringBuilder(disposition);
// append the parameter list
// use the length of the string buffer + the length of
diff --git a/current/src/main/java/javax/mail/internet/ContentType.java b/current/src/main/java/javax/mail/internet/ContentType.java
index c736945..c561574 100644
--- a/current/src/main/java/javax/mail/internet/ContentType.java
+++ b/current/src/main/java/javax/mail/internet/ContentType.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -215,11 +215,12 @@
*
* @return RFC2045 style string
*/
+ @Override
public String toString() {
if (primaryType == null || subType == null) // need both
return "";
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(primaryType).append('/').append(subType);
if (list != null)
// append the parameter list
diff --git a/current/src/main/java/javax/mail/internet/HeaderTokenizer.java b/current/src/main/java/javax/mail/internet/HeaderTokenizer.java
index a3251c0..c694644 100644
--- a/current/src/main/java/javax/mail/internet/HeaderTokenizer.java
+++ b/current/src/main/java/javax/mail/internet/HeaderTokenizer.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -454,7 +454,7 @@
*/
private static String filterToken(String s, int start, int end,
boolean keepEscapes) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
char c;
boolean gotEscape = false;
boolean gotCR = false;
diff --git a/current/src/main/java/javax/mail/internet/InternetAddress.java b/current/src/main/java/javax/mail/internet/InternetAddress.java
index b166a00..0d2f81c 100644
--- a/current/src/main/java/javax/mail/internet/InternetAddress.java
+++ b/current/src/main/java/javax/mail/internet/InternetAddress.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -47,6 +47,7 @@
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Locale;
+import java.nio.charset.StandardCharsets;
import javax.mail.*;
import com.sun.mail.util.PropUtil;
@@ -89,6 +90,9 @@
PropUtil.getBooleanSystemProperty(
"mail.mime.address.usecanonicalhostname", true);
+ private static final boolean allowUtf8 =
+ PropUtil.getBooleanSystemProperty("mail.mime.allowutf8", false);
+
/**
* Default constructor.
*/
@@ -183,6 +187,7 @@
* Return a copy of this InternetAddress object.
* @since JavaMail 1.2
*/
+ @Override
public Object clone() {
InternetAddress a = null;
try {
@@ -195,6 +200,7 @@
* Return the type of this address. The type of an InternetAddress
* is "rfc822".
*/
+ @Override
public String getType() {
return "rfc822";
}
@@ -291,6 +297,7 @@
*
* @return possibly encoded address string
*/
+ @Override
public String toString() {
String a = address == null ? "" : address;
if (encodedPersonal == null && personal != null)
@@ -350,7 +357,7 @@
char c = phrase.charAt(i);
if (c == '"' || c == '\\') {
// need to escape them and then quote the whole string
- StringBuffer sb = new StringBuffer(len + 3);
+ StringBuilder sb = new StringBuilder(len + 3);
sb.append('"');
for (int j = 0; j < len; j++) {
char cc = phrase.charAt(j);
@@ -362,13 +369,13 @@
sb.append('"');
return sb.toString();
} else if ((c < 040 && c != '\r' && c != '\n' && c != '\t') ||
- c >= 0177 || rfc822phrase.indexOf(c) >= 0)
- // These characters cause the string to be quoted
+ (c >= 0177 && !allowUtf8) || rfc822phrase.indexOf(c) >= 0)
+ // These characters cause the string to be quoted
needQuoting = true;
}
if (needQuoting) {
- StringBuffer sb = new StringBuffer(len + 2);
+ StringBuilder sb = new StringBuilder(len + 2);
sb.append('"').append(phrase).append('"');
return sb.toString();
} else
@@ -380,7 +387,7 @@
s = s.substring(1, s.length() - 1);
// check for any escaped characters
if (s.indexOf('\\') >= 0) {
- StringBuffer sb = new StringBuffer(s.length()); // approx
+ StringBuilder sb = new StringBuilder(s.length()); // approx
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '\\' && i < s.length() - 1)
@@ -396,6 +403,7 @@
/**
* The equality operator.
*/
+ @Override
public boolean equals(Object a) {
if (!(a instanceof InternetAddress))
return false;
@@ -412,6 +420,7 @@
/**
* Compute a hash code for the address.
*/
+ @Override
public int hashCode() {
if (address == null)
return 0;
@@ -438,6 +447,22 @@
/**
* Convert the given array of InternetAddress objects into
* a comma separated sequence of address strings. The
+ * resulting string contains Unicode characters. <p>
+ *
+ * @param addresses array of InternetAddress objects
+ * @exception ClassCastException if any address object in the
+ * given array is not an InternetAddress object. Note
+ * that this is a RuntimeException.
+ * @return comma separated string of addresses
+ * @since JavaMail 1.6
+ */
+ public static String toUnicodeString(Address[] addresses) {
+ return toUnicodeString(addresses, 0);
+ }
+
+ /**
+ * Convert the given array of InternetAddress objects into
+ * a comma separated sequence of address strings. The
* resulting string contains only US-ASCII characters, and
* hence is mail-safe. <p>
*
@@ -485,6 +510,78 @@
return sb.toString();
}
+ /**
+ * Convert the given array of InternetAddress objects into
+ * a comma separated sequence of address strings. The
+ * resulting string contains Unicode characters. <p>
+ *
+ * The 'used' parameter specifies the number of character positions
+ * already taken up in the field into which the resulting address
+ * sequence string is to be inserted. It is used to determine the
+ * line-break positions in the resulting address sequence string.
+ *
+ * @param addresses array of InternetAddress objects
+ * @param used number of character positions already used, in
+ * the field into which the address string is to
+ * be inserted.
+ * @exception ClassCastException if any address object in the
+ * given array is not an InternetAddress object. Note
+ * that this is a RuntimeException.
+ * @return comma separated string of addresses
+ * @since JavaMail 1.6
+ */
+ /*
+ * XXX - This is exactly the same as the above, except it uses
+ * toUnicodeString instead of toString.
+ * XXX - Since the line length restrictions are in bytes, not characters,
+ * we convert all non-ASCII addresses to UTF-8 byte strings,
+ * which we then convert to ISO-8859-1 Strings where every
+ * character respresents one UTF-8 byte. At the end we reverse
+ * the conversion to get back to a correct Unicode string.
+ * This is a hack to allow all the other character-based methods
+ * to work properly with UTF-8 bytes.
+ */
+ public static String toUnicodeString(Address[] addresses, int used) {
+ if (addresses == null || addresses.length == 0)
+ return null;
+
+ StringBuilder sb = new StringBuilder();
+
+ boolean sawNonAscii = false;
+ for (int i = 0; i < addresses.length; i++) {
+ if (i != 0) { // need to append comma
+ sb.append(", ");
+ used += 2;
+ }
+
+ // prefer not to split a single address across lines so used=0 below
+ String as = ((InternetAddress)addresses[i]).toUnicodeString();
+ if (MimeUtility.checkAscii(as) != MimeUtility.ALL_ASCII) {
+ sawNonAscii = true;
+ as = new String(as.getBytes(StandardCharsets.UTF_8),
+ StandardCharsets.ISO_8859_1);
+ }
+ String s = MimeUtility.fold(0, as);
+ int len = lengthOfFirstSegment(s); // length till CRLF
+ if (used + len > 76) { // overflows ...
+ // smash trailing space from ", " above
+ int curlen = sb.length();
+ if (curlen > 0 && sb.charAt(curlen - 1) == ' ')
+ sb.setLength(curlen - 1);
+ sb.append("\r\n\t"); // .. start new continuation line
+ used = 8; // account for the starting <tab> char
+ }
+ sb.append(s);
+ used = lengthOfLastSegment(s, used);
+ }
+
+ String ret = sb.toString();
+ if (sawNonAscii)
+ ret = new String(ret.getBytes(StandardCharsets.ISO_8859_1),
+ StandardCharsets.UTF_8);
+ return ret;
+ }
+
/*
* Return the length of the first segment within this string.
* If no segments exist, the length of the whole line is returned.
@@ -699,7 +796,7 @@
boolean route_addr = false; // address came from route-addr term
boolean rfc822 = false; // looks like an RFC822 address
char c;
- List<InternetAddress> v = new ArrayList<InternetAddress>();
+ List<InternetAddress> v = new ArrayList<>();
InternetAddress ma;
for (start = end = -1, index = 0; index < length; index++) {
@@ -889,8 +986,10 @@
break;
case '[': // a domain-literal, probably
- rfc822 = true;
int lindex = index;
+ rfc822 = true;
+ if (start == -1)
+ start = index;
outb:
for (index++; index < length; index++) {
c = s.charAt(index);
@@ -1244,12 +1343,22 @@
throw new AddressException(
"Quoted local address contains newline without whitespace",
addr);
+ } else if (c == '.') {
+ if (i == start)
+ throw new AddressException(
+ "Local address starts with dot", addr);
+ if (lastc == '.')
+ throw new AddressException(
+ "Local address contains dot-dot", addr);
}
if (inquote)
continue;
if (c == '@') {
if (i == 0)
throw new AddressException("Missing local name", addr);
+ if (lastc == '.')
+ throw new AddressException(
+ "Local address ends with dot", addr);
break; // done with local part
}
if (c <= 040 || c >= 0177)
diff --git a/current/src/main/java/javax/mail/internet/InternetHeaders.java b/current/src/main/java/javax/mail/internet/InternetHeaders.java
index 2772523..2216222 100644
--- a/current/src/main/java/javax/mail/internet/InternetHeaders.java
+++ b/current/src/main/java/javax/mail/internet/InternetHeaders.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -145,6 +145,7 @@
/**
* Return the "value" part of the header line.
*/
+ @Override
public String getValue() {
int i = line.indexOf(':');
if (i < 0)
@@ -297,16 +298,14 @@
*
* @since JavaMail 1.4
*/
- @SuppressWarnings("rawtypes")
- protected List headers;
+ protected List<InternetHeader> headers;
/**
* Create an empty InternetHeaders object. Placeholder entries
* are inserted to indicate the preferred order of headers.
*/
- @SuppressWarnings("unchecked")
public InternetHeaders() {
- headers = new ArrayList<InternetHeader>(40);
+ headers = new ArrayList<>(40);
headers.add(new InternetHeader("Return-Path", null));
headers.add(new InternetHeader("Received", null));
headers.add(new InternetHeader("Resent-Date", null));
@@ -355,8 +354,30 @@
* @exception MessagingException for any I/O error reading the stream
*/
public InternetHeaders(InputStream is) throws MessagingException {
- headers = new ArrayList<InternetHeader>(40);
- load(is);
+ this(is, false);
+ }
+
+ /**
+ * Read and parse the given RFC822 message stream till the
+ * blank line separating the header from the body. The input
+ * stream is left positioned at the start of the body. The
+ * header lines are stored internally. <p>
+ *
+ * For efficiency, wrap a BufferedInputStream around the actual
+ * input stream and pass it as the parameter. <p>
+ *
+ * No placeholder entries are inserted; the original order of
+ * the headers is preserved.
+ *
+ * @param is RFC822 input stream
+ * @param allowutf8 if UTF-8 encoded headers are allowed
+ * @exception MessagingException for any I/O error reading the stream
+ * @since JavaMail 1.6
+ */
+ public InternetHeaders(InputStream is, boolean allowutf8)
+ throws MessagingException {
+ headers = new ArrayList<>(40);
+ load(is, allowutf8);
}
/**
@@ -374,13 +395,34 @@
* @exception MessagingException for any I/O error reading the stream
*/
public void load(InputStream is) throws MessagingException {
+ load(is, false);
+ }
+
+ /**
+ * Read and parse the given RFC822 message stream till the
+ * blank line separating the header from the body. Store the
+ * header lines inside this InternetHeaders object. The order
+ * of header lines is preserved. <p>
+ *
+ * Note that the header lines are added into this InternetHeaders
+ * object, so any existing headers in this object will not be
+ * affected. Headers are added to the end of the existing list
+ * of headers, in order.
+ *
+ * @param is RFC822 input stream
+ * @param allowutf8 if UTF-8 encoded headers are allowed
+ * @exception MessagingException for any I/O error reading the stream
+ * @since JavaMail 1.6
+ */
+ public void load(InputStream is, boolean allowutf8)
+ throws MessagingException {
// Read header lines until a blank line. It is valid
// to have BodyParts with no header lines.
String line;
- LineInputStream lis = new LineInputStream(is);
+ LineInputStream lis = new LineInputStream(is, allowutf8);
String prevline = null; // the previous header line, as a string
// a buffer to accumulate the header in, when we know it's needed
- StringBuffer lineBuffer = new StringBuffer();
+ StringBuilder lineBuffer = new StringBuilder();
try {
// if the first line being read is a continuation line,
@@ -440,10 +482,9 @@
* @return array of header values, or null if none
*/
public String[] getHeader(String name) {
- @SuppressWarnings("unchecked")
Iterator<InternetHeader> e = headers.iterator();
// XXX - should we just step through in index order?
- List<String> v = new ArrayList<String>(); // accumulate return values
+ List<String> v = new ArrayList<>(); // accumulate return values
while (e.hasNext()) {
InternetHeader h = e.next();
@@ -480,7 +521,7 @@
if ((s.length == 1) || delimiter == null)
return s[0];
- StringBuffer r = new StringBuffer(s[0]);
+ StringBuilder r = new StringBuilder(s[0]);
for (int i = 1; i < s.length; i++) {
r.append(delimiter);
r.append(s[i]);
@@ -502,7 +543,7 @@
boolean found = false;
for (int i = 0; i < headers.size(); i++) {
- InternetHeader h = (InternetHeader)headers.get(i);
+ InternetHeader h = headers.get(i);
if (name.equalsIgnoreCase(h.getName())) {
if (!found) {
int j;
@@ -540,7 +581,6 @@
* @param name header name
* @param value header value
*/
- @SuppressWarnings("unchecked")
public void addHeader(String name, String value) {
int pos = headers.size();
boolean addReverse =
@@ -549,7 +589,7 @@
if (addReverse)
pos = 0;
for (int i = headers.size() - 1; i >= 0; i--) {
- InternetHeader h = (InternetHeader)headers.get(i);
+ InternetHeader h = headers.get(i);
if (name.equalsIgnoreCase(h.getName())) {
if (addReverse) {
pos = i;
@@ -571,7 +611,7 @@
*/
public void removeHeader(String name) {
for (int i = 0; i < headers.size(); i++) {
- InternetHeader h = (InternetHeader)headers.get(i);
+ InternetHeader h = headers.get(i);
if (name.equalsIgnoreCase(h.getName())) {
h.line = null;
//headers.remove(i);
@@ -586,8 +626,7 @@
*
* @return Enumeration of Header objects
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
- public Enumeration getAllHeaders() {
+ public Enumeration<Header> getAllHeaders() {
return (new MatchHeaderEnum(headers, null, false));
}
@@ -597,8 +636,7 @@
* @param names the headers to return
* @return Enumeration of matching Header objects
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
- public Enumeration getMatchingHeaders(String[] names) {
+ public Enumeration<Header> getMatchingHeaders(String[] names) {
return (new MatchHeaderEnum(headers, names, true));
}
@@ -608,8 +646,7 @@
* @param names the headers to not return
* @return Enumeration of non-matching Header objects
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
- public Enumeration getNonMatchingHeaders(String[] names) {
+ public Enumeration<Header> getNonMatchingHeaders(String[] names) {
return (new MatchHeaderEnum(headers, names, false));
}
@@ -623,13 +660,11 @@
*
* @param line raw RFC822 header line
*/
- @SuppressWarnings("unchecked")
public void addHeaderLine(String line) {
try {
char c = line.charAt(0);
if (c == ' ' || c == '\t') {
- InternetHeader h =
- (InternetHeader)headers.get(headers.size() - 1);
+ InternetHeader h = headers.get(headers.size() - 1);
h.line += "\r\n" + line;
} else
headers.add(new InternetHeader(line));
@@ -646,8 +681,7 @@
*
* @return Enumeration of Strings of all header lines
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaderLines() {
+ public Enumeration<String> getAllHeaderLines() {
return (getNonMatchingHeaderLines(null));
}
@@ -657,8 +691,7 @@
* @param names the headers to return
* @return Enumeration of Strings of all matching header lines
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
- public Enumeration getMatchingHeaderLines(String[] names) {
+ public Enumeration<String> getMatchingHeaderLines(String[] names) {
return (new MatchStringEnum(headers, names, true));
}
@@ -668,8 +701,7 @@
* @param names the headers to not return
* @return Enumeration of Strings of all non-matching header lines
*/
- @SuppressWarnings({"rawtypes", "unchecked"})
- public Enumeration getNonMatchingHeaderLines(String[] names) {
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names) {
return (new MatchStringEnum(headers, names, false));
}
}
diff --git a/current/src/main/java/javax/mail/internet/MailDateFormat.java b/current/src/main/java/javax/mail/internet/MailDateFormat.java
index e3cc414..d2771ab 100644
--- a/current/src/main/java/javax/mail/internet/MailDateFormat.java
+++ b/current/src/main/java/javax/mail/internet/MailDateFormat.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -48,6 +48,7 @@
import java.util.Locale;
import java.util.TimeZone;
import java.util.logging.Level;
+import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.text.NumberFormat;
import java.text.FieldPosition;
@@ -197,11 +198,12 @@
* Overrides Cloneable.
*
* @return a clone of this instance
+ * @since JavaMail 1.6
*/
-// @Override
-// public MailDateFormat clone() {
-// return (MailDateFormat) super.clone();
-// }
+ @Override
+ public MailDateFormat clone() {
+ return (MailDateFormat) super.clone();
+ }
/**
* Formats the given date in the format specified by
@@ -279,24 +281,26 @@
* be used because RFC 2822 mandates a specific pattern.
*
* @throws UnsupportedOperationException if this method is invoked
+ * @since JavaMail 1.6
*/
-// @Override
-// public void applyLocalizedPattern(String pattern) {
-// throw new UnsupportedOperationException("Method "
-// + "applyLocalizedPattern() shouldn't be called");
-// }
+ @Override
+ public void applyLocalizedPattern(String pattern) {
+ throw new UnsupportedOperationException("Method "
+ + "applyLocalizedPattern() shouldn't be called");
+ }
/**
* This method always throws an UnsupportedOperationException and should not
* be used because RFC 2822 mandates a specific pattern.
*
* @throws UnsupportedOperationException if this method is invoked
+ * @since JavaMail 1.6
*/
-// @Override
-// public void applyPattern(String pattern) {
-// throw new UnsupportedOperationException("Method "
-// + "applyPattern() shouldn't be called");
-// }
+ @Override
+ public void applyPattern(String pattern) {
+ throw new UnsupportedOperationException("Method "
+ + "applyPattern() shouldn't be called");
+ }
/**
* This method allows serialization to change the pattern.
@@ -313,12 +317,13 @@
* @return the start of the 100-year period into which two digit years are
* parsed
* @throws UnsupportedOperationException if this method is invoked
+ * @since JavaMail 1.6
*/
-// @Override
-// public Date get2DigitYearStart() {
-// throw new UnsupportedOperationException("Method "
-// + "get2DigitYearStart() shouldn't be called");
-// }
+ @Override
+ public Date get2DigitYearStart() {
+ throw new UnsupportedOperationException("Method "
+ + "get2DigitYearStart() shouldn't be called");
+ }
/**
* This method always throws an UnsupportedOperationException and should not
@@ -326,24 +331,26 @@
* 2-digits years.
*
* @throws UnsupportedOperationException if this method is invoked
+ * @since JavaMail 1.6
*/
-// @Override
-// public void set2DigitYearStart(Date startDate) {
-// throw new UnsupportedOperationException("Method "
-// + "set2DigitYearStart() shouldn't be called");
-// }
+ @Override
+ public void set2DigitYearStart(Date startDate) {
+ throw new UnsupportedOperationException("Method "
+ + "set2DigitYearStart() shouldn't be called");
+ }
/**
* This method always throws an UnsupportedOperationException and should not
* be used because RFC 2822 mandates specific date format symbols.
*
* @throws UnsupportedOperationException if this method is invoked
+ * @since JavaMail 1.6
*/
-// @Override
-// public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) {
-// throw new UnsupportedOperationException("Method "
-// + "setDateFormatSymbols() shouldn't be called");
-// }
+ @Override
+ public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols) {
+ throw new UnsupportedOperationException("Method "
+ + "setDateFormatSymbols() shouldn't be called");
+ }
/**
* Returns the date, as specified by the parameters.
@@ -420,8 +427,7 @@
LOGGER.log(Level.FINE, "Bad date: '" + text + "'", e);
}
pos.setErrorIndex(pos.getIndex());
- // to prevent DateFormat::parse from throwing ParseException:
- pos.setIndex(startPosition + 1);
+ pos.setIndex(startPosition);
return null;
}
}
diff --git a/current/src/main/java/javax/mail/internet/MimeBodyPart.java b/current/src/main/java/javax/mail/internet/MimeBodyPart.java
index ccf492a..e04cbe9 100644
--- a/current/src/main/java/javax/mail/internet/MimeBodyPart.java
+++ b/current/src/main/java/javax/mail/internet/MimeBodyPart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,7 +44,12 @@
import javax.activation.*;
import java.io.*;
import java.util.*;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.MimeUtil;
+import com.sun.mail.util.MessageRemovedIOException;
+import com.sun.mail.util.FolderClosedIOException;
+import com.sun.mail.util.LineOutputStream;
/**
* This class represents a MIME body part. It implements the
@@ -97,6 +102,8 @@
private static final boolean ignoreMultipartEncoding =
PropUtil.getBooleanSystemProperty(
"mail.mime.ignoremultipartencoding", true);
+ private static final boolean allowutf8 =
+ PropUtil.getBooleanSystemProperty("mail.mime.allowutf8", true);
// Paranoia:
// allow this last minute change to be disabled if it causes problems
@@ -225,6 +232,7 @@
*
* @return size in bytes, or -1 if not known
*/
+ @Override
public int getSize() throws MessagingException {
if (content != null)
return content.length;
@@ -254,6 +262,7 @@
*
* @return number of lines, or -1 if not known
*/
+ @Override
public int getLineCount() throws MessagingException {
return -1;
}
@@ -269,6 +278,7 @@
*
* @return Content-Type of this body part
*/
+ @Override
public String getContentType() throws MessagingException {
String s = getHeader("Content-Type", null);
s = MimeUtil.cleanContentType(this, s);
@@ -293,6 +303,7 @@
*
* @exception MessagingException for failures
*/
+ @Override
public boolean isMimeType(String mimeType) throws MessagingException {
return isMimeType(this, mimeType);
}
@@ -311,6 +322,7 @@
* @exception MessagingException for failures
* @see #headers
*/
+ @Override
public String getDisposition() throws MessagingException {
return getDisposition(this);
}
@@ -326,6 +338,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setDisposition(String disposition) throws MessagingException {
setDisposition(this, disposition);
}
@@ -341,6 +354,7 @@
*
* @see #headers
*/
+ @Override
public String getEncoding() throws MessagingException {
return getEncoding(this);
}
@@ -353,6 +367,7 @@
* This implementation uses <code>getHeader(name)</code>
* to obtain the requisite header field.
*/
+ @Override
public String getContentID() throws MessagingException {
return getHeader("Content-Id", null);
}
@@ -385,6 +400,7 @@
* This implementation uses <code>getHeader(name)</code>
* to obtain the requisite header field.
*/
+ @Override
public String getContentMD5() throws MessagingException {
return getHeader("Content-MD5", null);
}
@@ -397,6 +413,7 @@
* @exception IllegalStateException if this body part is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void setContentMD5(String md5) throws MessagingException {
setHeader("Content-MD5", md5);
}
@@ -410,6 +427,7 @@
* This implementation uses <code>getHeader(name)</code>
* to obtain the requisite header field.
*/
+ @Override
public String[] getContentLanguage() throws MessagingException {
return getContentLanguage(this);
}
@@ -420,6 +438,7 @@
*
* @param languages array of language tags
*/
+ @Override
public void setContentLanguage(String[] languages)
throws MessagingException {
setContentLanguage(this, languages);
@@ -440,6 +459,7 @@
*
* @return content description
*/
+ @Override
public String getDescription() throws MessagingException {
return getDescription(this);
}
@@ -469,6 +489,7 @@
* in the exception chain if the charset
* conversion fails.
*/
+ @Override
public void setDescription(String description) throws MessagingException {
setDescription(description, null);
}
@@ -523,6 +544,7 @@
*
* @return filename
*/
+ @Override
public String getFileName() throws MessagingException {
return getFileName(this);
}
@@ -550,6 +572,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setFileName(String filename) throws MessagingException {
setFileName(this, filename);
}
@@ -569,6 +592,7 @@
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
+ @Override
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
@@ -622,6 +646,7 @@
* the implementation in MimeMessage.
* @see MimeMessage#getDataHandler
*/
+ @Override
public DataHandler getDataHandler() throws MessagingException {
if (dh == null)
dh = new MimePartDataHandler(this);
@@ -649,6 +674,7 @@
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*/
+ @Override
public Object getContent() throws IOException, MessagingException {
if (cachedContent != null)
return cachedContent;
@@ -684,6 +710,7 @@
* @exception IllegalStateException if this body part is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void setDataHandler(DataHandler dh)
throws MessagingException {
this.dh = dh;
@@ -709,6 +736,7 @@
* @exception IllegalStateException if this body part is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void setContent(Object o, String type)
throws MessagingException {
if (o instanceof Multipart) {
@@ -737,6 +765,7 @@
* @exception MessagingException if an error occurs
* @see #setText(String text, String charset)
*/
+ @Override
public void setText(String text) throws MessagingException {
setText(text, null);
}
@@ -752,6 +781,7 @@
* @param charset the charset to use for the text
* @exception MessagingException if an error occurs
*/
+ @Override
public void setText(String text, String charset)
throws MessagingException {
setText(this, text, charset, "plain");
@@ -770,6 +800,7 @@
* @exception MessagingException if an error occurs
* @since JavaMail 1.4
*/
+ @Override
public void setText(String text, String charset, String subtype)
throws MessagingException {
setText(this, text, charset, subtype);
@@ -785,6 +816,7 @@
* @exception IllegalStateException if this body part is
* obtained from a READ_ONLY folder.
*/
+ @Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
@@ -891,11 +923,13 @@
}
// overrides DataSource.getContentType()
+ @Override
public String getContentType() {
return contentType != null ? contentType : super.getContentType();
}
// implements EncodingAware.getEncoding()
+ @Override
public String getEncoding() {
return encoding;
}
@@ -956,6 +990,7 @@
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
+ @Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
writeTo(this, os, null);
@@ -970,6 +1005,7 @@
* @return array of headers
* @see javax.mail.internet.MimeUtility
*/
+ @Override
public String[] getHeader(String name) throws MessagingException {
return headers.getHeader(name);
}
@@ -986,6 +1022,7 @@
* this name
* @exception MessagingException for failures
*/
+ @Override
public String getHeader(String name, String delimiter)
throws MessagingException {
return headers.getHeader(name, delimiter);
@@ -1002,6 +1039,7 @@
* @param value header value
* @see javax.mail.internet.MimeUtility
*/
+ @Override
public void setHeader(String name, String value)
throws MessagingException {
headers.setHeader(name, value);
@@ -1017,6 +1055,7 @@
* @param value header value
* @see javax.mail.internet.MimeUtility
*/
+ @Override
public void addHeader(String name, String value)
throws MessagingException {
headers.addHeader(name, value);
@@ -1025,6 +1064,7 @@
/**
* Remove all headers with this name.
*/
+ @Override
public void removeHeader(String name) throws MessagingException {
headers.removeHeader(name);
}
@@ -1033,8 +1073,8 @@
* Return all the headers from this Message as an Enumeration of
* Header objects.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaders() throws MessagingException {
+ @Override
+ public Enumeration<Header> getAllHeaders() throws MessagingException {
return headers.getAllHeaders();
}
@@ -1042,8 +1082,8 @@
* Return matching headers from this Message as an Enumeration of
* Header objects.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaders(String[] names)
+ @Override
+ public Enumeration<Header> getMatchingHeaders(String[] names)
throws MessagingException {
return headers.getMatchingHeaders(names);
}
@@ -1052,8 +1092,8 @@
* Return non-matching headers from this Message as an
* Enumeration of Header objects.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaders(String[] names)
+ @Override
+ public Enumeration<Header> getNonMatchingHeaders(String[] names)
throws MessagingException {
return headers.getNonMatchingHeaders(names);
}
@@ -1061,6 +1101,7 @@
/**
* Add a header line to this body part
*/
+ @Override
public void addHeaderLine(String line) throws MessagingException {
headers.addHeaderLine(line);
}
@@ -1070,8 +1111,8 @@
* line is a raw RFC 822 header line, containing both the "name"
* and "value" field.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaderLines() throws MessagingException {
+ @Override
+ public Enumeration<String> getAllHeaderLines() throws MessagingException {
return headers.getAllHeaderLines();
}
@@ -1080,8 +1121,8 @@
* A Header line is a raw RFC 822 header line, containing both
* the "name" and "value" field.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaderLines(String[] names)
+ @Override
+ public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException {
return headers.getMatchingHeaderLines(names);
}
@@ -1091,8 +1132,8 @@
* A Header line is a raw RFC 822 header line, containing both
* the "name" and "value" field.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaderLines(String[] names)
+ @Override
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException {
return headers.getNonMatchingHeaderLines(names);
}
@@ -1336,7 +1377,7 @@
// Tokenize the header to obtain the Language-tags (skip comments)
HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME);
- List<String> v = new ArrayList<String>();
+ List<String> v = new ArrayList<>();
HeaderTokenizer.Token tk;
int tkType;
@@ -1362,7 +1403,7 @@
static void setContentLanguage(MimePart part, String[] languages)
throws MessagingException {
- StringBuffer sb = new StringBuffer(languages[0]);
+ StringBuilder sb = new StringBuilder(languages[0]);
int len = "Content-Language".length() + 2 + languages[0].length();
for (int i = 1; i < languages.length; i++) {
sb.append(',');
@@ -1384,6 +1425,8 @@
return null;
s = s.trim(); // get rid of trailing spaces
+ if (s.length() == 0)
+ return null;
// quick check for known values to avoid unnecessary use
// of tokenizer.
if (s.equalsIgnoreCase("7bit") || s.equalsIgnoreCase("8bit") ||
@@ -1609,11 +1652,10 @@
if (os instanceof LineOutputStream) {
los = (LineOutputStream) os;
} else {
- los = new LineOutputStream(os);
+ los = new LineOutputStream(os, allowutf8);
}
// First, write out the header
- @SuppressWarnings("unchecked")
Enumeration<String> hdrLines
= part.getNonMatchingHeaderLines(ignoreList);
while (hdrLines.hasMoreElements())
diff --git a/current/src/main/java/javax/mail/internet/MimeMessage.java b/current/src/main/java/javax/mail/internet/MimeMessage.java
index 70ffae6..46c9528 100644
--- a/current/src/main/java/javax/mail/internet/MimeMessage.java
+++ b/current/src/main/java/javax/mail/internet/MimeMessage.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -46,7 +46,12 @@
import java.io.*;
import java.util.*;
import java.text.ParseException;
-import com.sun.mail.util.*;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.MimeUtil;
+import com.sun.mail.util.MessageRemovedIOException;
+import com.sun.mail.util.FolderClosedIOException;
+import com.sun.mail.util.LineOutputStream;
import javax.mail.util.SharedByteArrayInputStream;
/**
@@ -178,6 +183,8 @@
// Should addresses in headers be parsed in "strict" mode?
private boolean strict = true;
+ // Is UTF-8 allowed in headers?
+ private boolean allowutf8 = false;
/**
* Default constructor. An empty message object is created.
@@ -316,9 +323,13 @@
* Set the strict flag based on property.
*/
private void initStrict() {
- if (session != null)
- strict = PropUtil.getBooleanSessionProperty(session,
+ if (session != null) {
+ Properties props = session.getProperties();
+ strict = PropUtil.getBooleanProperty(props,
"mail.mime.address.strict", true);
+ allowutf8 = PropUtil.getBooleanProperty(props,
+ "mail.mime.allowutf8", false);
+ }
}
/**
@@ -368,6 +379,7 @@
* @exception MessagingException for failures
* @see #headers
*/
+ @Override
public Address[] getFrom() throws MessagingException {
Address[] a = getAddressHeader("From");
if (a == null)
@@ -389,6 +401,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setFrom(Address address) throws MessagingException {
if (address == null)
removeHeader("From");
@@ -428,6 +441,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setFrom() throws MessagingException {
InternetAddress me = null;
try {
@@ -455,6 +469,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void addFrom(Address[] addresses) throws MessagingException {
addAddressHeader("From", addresses);
}
@@ -520,6 +535,7 @@
super(type);
}
+ @Override
protected Object readResolve() throws ObjectStreamException {
if (type.equals("Newsgroups"))
return NEWSGROUPS;
@@ -556,6 +572,7 @@
* @see javax.mail.Message.RecipientType#BCC
* @see javax.mail.internet.MimeMessage.RecipientType#NEWSGROUPS
*/
+ @Override
public Address[] getRecipients(Message.RecipientType type)
throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
@@ -576,6 +593,7 @@
* @see javax.mail.Message.RecipientType#BCC
* @see javax.mail.internet.MimeMessage.RecipientType#NEWSGROUPS
*/
+ @Override
public Address[] getAllRecipients() throws MessagingException {
Address[] all = super.getAllRecipients();
Address[] ng = getRecipients(RecipientType.NEWSGROUPS);
@@ -606,6 +624,7 @@
* @exception MessagingException for other failures
* @see #getRecipients
*/
+ @Override
public void setRecipients(Message.RecipientType type, Address[] addresses)
throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
@@ -659,6 +678,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void addRecipients(Message.RecipientType type, Address[] addresses)
throws MessagingException {
if (type == RecipientType.NEWSGROUPS) {
@@ -705,6 +725,7 @@
* @exception MessagingException for failures
* @see #headers
*/
+ @Override
public Address[] getReplyTo() throws MessagingException {
Address[] a = getAddressHeader("Reply-To");
if (a == null || a.length == 0)
@@ -723,6 +744,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setReplyTo(Address[] addresses) throws MessagingException {
setAddressHeader("Reply-To", addresses);
}
@@ -737,7 +759,11 @@
// Convenience method to set addresses
private void setAddressHeader(String name, Address[] addresses)
throws MessagingException {
- String s = InternetAddress.toString(addresses, name.length() + 2);
+ String s;
+ if (allowutf8)
+ s = InternetAddress.toUnicodeString(addresses, name.length() + 2);
+ else
+ s = InternetAddress.toString(addresses, name.length() + 2);
if (s == null)
removeHeader(name);
else
@@ -757,7 +783,11 @@
System.arraycopy(a, 0, anew, 0, a.length);
System.arraycopy(addresses, 0, anew, a.length, addresses.length);
}
- String s = InternetAddress.toString(anew, name.length() + 2);
+ String s;
+ if (allowutf8)
+ s = InternetAddress.toUnicodeString(anew, name.length() + 2);
+ else
+ s = InternetAddress.toString(anew, name.length() + 2);
if (s == null)
return;
setHeader(name, s);
@@ -778,6 +808,7 @@
* @exception MessagingException for failures
* @see #headers
*/
+ @Override
public String getSubject() throws MessagingException {
String rawvalue = getHeader("Subject", null);
@@ -815,6 +846,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setSubject(String subject) throws MessagingException {
setSubject(subject, null);
}
@@ -868,6 +900,7 @@
* @return The sent Date
* @exception MessagingException for failures
*/
+ @Override
public Date getSentDate() throws MessagingException {
String s = getHeader("Date", null);
if (s != null) {
@@ -895,6 +928,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setSentDate(Date d) throws MessagingException {
if (d == null)
removeHeader("Date");
@@ -918,6 +952,7 @@
* @return the date this message was received
* @exception MessagingException for failures
*/
+ @Override
public Date getReceivedDate() throws MessagingException {
return null;
}
@@ -939,6 +974,7 @@
* @return size of content in bytes
* @exception MessagingException for failures
*/
+ @Override
public int getSize() throws MessagingException {
if (content != null)
return content.length;
@@ -969,9 +1005,10 @@
* @return number of lines in the content.
* @exception MessagingException for failures
*/
- public int getLineCount() throws MessagingException {
+ @Override
+ public int getLineCount() throws MessagingException {
return -1;
- }
+ }
/**
* Returns the value of the RFC 822 "Content-Type" header field.
@@ -986,6 +1023,7 @@
* @exception MessagingException for failures
* @see javax.activation.DataHandler
*/
+ @Override
public String getContentType() throws MessagingException {
String s = getHeader("Content-Type", null);
s = MimeUtil.cleanContentType(this, s);
@@ -1012,6 +1050,7 @@
* @return true if it matches the MIME type
* @exception MessagingException for failures
*/
+ @Override
public boolean isMimeType(String mimeType) throws MessagingException {
return MimeBodyPart.isMimeType(this, mimeType);
}
@@ -1030,6 +1069,7 @@
* @return disposition of this part, or null if unknown
* @exception MessagingException for failures
*/
+ @Override
public String getDisposition() throws MessagingException {
return MimeBodyPart.getDisposition(this);
}
@@ -1045,6 +1085,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setDisposition(String disposition) throws MessagingException {
MimeBodyPart.setDisposition(this, disposition);
}
@@ -1061,6 +1102,7 @@
* @return content-transfer-encoding
* @exception MessagingException for failures
*/
+ @Override
public String getEncoding() throws MessagingException {
return MimeBodyPart.getEncoding(this);
}
@@ -1076,6 +1118,7 @@
* @return content-ID
* @exception MessagingException for failures
*/
+ @Override
public String getContentID() throws MessagingException {
return getHeader("Content-Id", null);
}
@@ -1110,6 +1153,7 @@
* @return content-MD5
* @exception MessagingException for failures
*/
+ @Override
public String getContentMD5() throws MessagingException {
return getHeader("Content-MD5", null);
}
@@ -1123,6 +1167,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setContentMD5(String md5) throws MessagingException {
setHeader("Content-MD5", md5);
}
@@ -1143,6 +1188,7 @@
* @return content-description
* @exception MessagingException for failures
*/
+ @Override
public String getDescription() throws MessagingException {
return MimeBodyPart.getDescription(this);
}
@@ -1172,6 +1218,7 @@
* in the exception chain if the charset
* conversion fails.
*/
+ @Override
public void setDescription(String description) throws MessagingException {
setDescription(description, null);
}
@@ -1219,6 +1266,7 @@
* @return value of content-language header.
* @exception MessagingException for failures
*/
+ @Override
public String[] getContentLanguage() throws MessagingException {
return MimeBodyPart.getContentLanguage(this);
}
@@ -1234,6 +1282,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setContentLanguage(String[] languages)
throws MessagingException {
MimeBodyPart.setContentLanguage(this, languages);
@@ -1277,6 +1326,7 @@
* @return filename
* @exception MessagingException for failures
*/
+ @Override
public String getFileName() throws MessagingException {
return MimeBodyPart.getFileName(this);
}
@@ -1301,6 +1351,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setFileName(String filename) throws MessagingException {
MimeBodyPart.setFileName(this, filename);
}
@@ -1338,6 +1389,7 @@
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
+ @Override
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
@@ -1416,6 +1468,7 @@
*
* @exception MessagingException for failures
*/
+ @Override
public synchronized DataHandler getDataHandler()
throws MessagingException {
if (dh == null)
@@ -1446,6 +1499,7 @@
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*/
+ @Override
public Object getContent() throws IOException, MessagingException {
if (cachedContent != null)
return cachedContent;
@@ -1482,6 +1536,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public synchronized void setDataHandler(DataHandler dh)
throws MessagingException {
this.dh = dh;
@@ -1508,6 +1563,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setContent(Object o, String type)
throws MessagingException {
if (o instanceof Multipart)
@@ -1535,6 +1591,7 @@
* @exception MessagingException if an error occurs
* @see #setText(String text, String charset)
*/
+ @Override
public void setText(String text) throws MessagingException {
setText(text, null);
}
@@ -1550,6 +1607,7 @@
* @param charset the charset to use for the text
* @exception MessagingException if an error occurs
*/
+ @Override
public void setText(String text, String charset)
throws MessagingException {
MimeBodyPart.setText(this, text, charset, "plain");
@@ -1568,6 +1626,7 @@
* @exception MessagingException if an error occurs
* @since JavaMail 1.4
*/
+ @Override
public void setText(String text, String charset, String subtype)
throws MessagingException {
MimeBodyPart.setText(this, text, charset, subtype);
@@ -1584,6 +1643,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setContent(Multipart mp) throws MessagingException {
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
@@ -1618,6 +1678,7 @@
* @return the reply Message
* @exception MessagingException for failures
*/
+ @Override
public Message reply(boolean replyToAll) throws MessagingException {
return reply(replyToAll, true);
}
@@ -1675,7 +1736,7 @@
Address a[] = getReplyTo();
reply.setRecipients(Message.RecipientType.TO, a);
if (replyToAll) {
- List<Address> v = new ArrayList<Address>();
+ List<Address> v = new ArrayList<>();
// add my own address to list
InternetAddress me = InternetAddress.getLocalAddress(session);
if (me != null)
@@ -1691,7 +1752,8 @@
String replyallccStr = null;
boolean replyallcc = false;
if (session != null)
- replyallcc = PropUtil.getBooleanSessionProperty(session,
+ replyallcc = PropUtil.getBooleanProperty(
+ session.getProperties(),
"mail.replyallcc", false);
// add the recipients from the To field so far
eliminateDuplicates(v, a);
@@ -1819,6 +1881,7 @@
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
+ @Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
writeTo(os, null);
@@ -1853,9 +1916,8 @@
// Else, the content is untouched, so we can just output it
// First, write out the header
- @SuppressWarnings("unchecked")
Enumeration<String> hdrLines = getNonMatchingHeaderLines(ignoreList);
- LineOutputStream los = new LineOutputStream(os);
+ LineOutputStream los = new LineOutputStream(os, allowutf8);
while (hdrLines.hasMoreElements())
los.writeln(hdrLines.nextElement());
@@ -1898,6 +1960,7 @@
* @exception MessagingException for failures
* @see javax.mail.internet.MimeUtility
*/
+ @Override
public String[] getHeader(String name)
throws MessagingException {
return headers.getHeader(name);
@@ -1915,6 +1978,7 @@
* this name
* @exception MessagingException for failures
*/
+ @Override
public String getHeader(String name, String delimiter)
throws MessagingException {
return headers.getHeader(name, delimiter);
@@ -1936,6 +2000,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void setHeader(String name, String value)
throws MessagingException {
headers.setHeader(name, value);
@@ -1956,6 +2021,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void addHeader(String name, String value)
throws MessagingException {
headers.addHeader(name, value);
@@ -1969,6 +2035,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void removeHeader(String name)
throws MessagingException {
headers.removeHeader(name);
@@ -1989,8 +2056,8 @@
* @exception MessagingException for failures
* @see javax.mail.internet.MimeUtility
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaders() throws MessagingException {
+ @Override
+ public Enumeration<Header> getAllHeaders() throws MessagingException {
return headers.getAllHeaders();
}
@@ -2001,8 +2068,8 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaders(String[] names)
+ @Override
+ public Enumeration<Header> getMatchingHeaders(String[] names)
throws MessagingException {
return headers.getMatchingHeaders(names);
}
@@ -2014,8 +2081,8 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaders(String[] names)
+ @Override
+ public Enumeration<Header> getNonMatchingHeaders(String[] names)
throws MessagingException {
return headers.getNonMatchingHeaders(names);
}
@@ -2029,6 +2096,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void addHeaderLine(String line) throws MessagingException {
headers.addHeaderLine(line);
}
@@ -2040,8 +2108,8 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaderLines() throws MessagingException {
+ @Override
+ public Enumeration<String> getAllHeaderLines() throws MessagingException {
return headers.getAllHeaderLines();
}
@@ -2052,8 +2120,8 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaderLines(String[] names)
+ @Override
+ public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException {
return headers.getMatchingHeaderLines(names);
}
@@ -2065,8 +2133,8 @@
*
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaderLines(String[] names)
+ @Override
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException {
return headers.getNonMatchingHeaderLines(names);
}
@@ -2083,6 +2151,7 @@
* @exception MessagingException for failures
* @see javax.mail.Flags
*/
+ @Override
public synchronized Flags getFlags() throws MessagingException {
return (Flags)flags.clone();
}
@@ -2105,6 +2174,7 @@
* @see javax.mail.Flags.Flag#RECENT
* @see javax.mail.Flags.Flag#SEEN
*/
+ @Override
public synchronized boolean isSet(Flags.Flag flag)
throws MessagingException {
return (flags.contains(flag));
@@ -2121,6 +2191,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public synchronized void setFlags(Flags flag, boolean set)
throws MessagingException {
if (set)
@@ -2153,6 +2224,7 @@
* obtained from a READ_ONLY folder.
* @exception MessagingException for other failures
*/
+ @Override
public void saveChanges() throws MessagingException {
modified = true;
saved = true;
@@ -2177,7 +2249,8 @@
* Called by the <code>saveChanges</code> method to actually
* update the MIME headers. The implementation here sets the
* <code>Content-Transfer-Encoding</code> header (if needed
- * and not already set), the <code>MIME-Version</code> header
+ * and not already set), the <code>Date</code> header (if
+ * not already set), the <code>MIME-Version</code> header
* and the <code>Message-ID</code> header. Also, if the content
* of this message is a <code>MimeMultipart</code>, its
* <code>updateHeaders</code> method is called. <p>
@@ -2197,6 +2270,8 @@
protected synchronized void updateHeaders() throws MessagingException {
MimeBodyPart.updateHeaders(this);
setHeader("MIME-Version", "1.0");
+ if (getHeader("Date") == null)
+ setSentDate(new Date());
updateMessageID();
if (cachedContent != null) {
@@ -2226,7 +2301,7 @@
*/
protected InternetHeaders createInternetHeaders(InputStream is)
throws MessagingException {
- return new InternetHeaders(is);
+ return new InternetHeaders(is, allowutf8);
}
/**
diff --git a/current/src/main/java/javax/mail/internet/MimeMultipart.java b/current/src/main/java/javax/mail/internet/MimeMultipart.java
index 8533809..0fc8630 100644
--- a/current/src/main/java/javax/mail/internet/MimeMultipart.java
+++ b/current/src/main/java/javax/mail/internet/MimeMultipart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -263,7 +263,8 @@
* boundary and creates MimeBodyParts for each part of the stream.
*
* @param ds DataSource, can be a MultipartDataSource
- * @exception MessagingException for failures
+ * @exception ParseException for failures parsing the message
+ * @exception MessagingException for other failures
*/
public MimeMultipart(DataSource ds) throws MessagingException {
super();
@@ -330,6 +331,7 @@
*
* @return number of parts
*/
+ @Override
public synchronized int getCount() throws MessagingException {
parse();
return super.getCount();
@@ -342,6 +344,7 @@
* @return the Part
* @exception MessagingException if no such BodyPart exists
*/
+ @Override
public synchronized BodyPart getBodyPart(int index)
throws MessagingException {
parse();
@@ -381,6 +384,7 @@
* implementation does not support modification
* of existing values
*/
+ @Override
public boolean removeBodyPart(BodyPart part) throws MessagingException {
parse();
return super.removeBodyPart(part);
@@ -398,6 +402,7 @@
* of existing values
* @exception MessagingException for other failures
*/
+ @Override
public void removeBodyPart(int index) throws MessagingException {
parse();
super.removeBodyPart(index);
@@ -413,6 +418,7 @@
* of existing values
* @exception MessagingException for other failures
*/
+ @Override
public synchronized void addBodyPart(BodyPart part)
throws MessagingException {
parse();
@@ -433,6 +439,7 @@
* of existing values
* @exception MessagingException for other failures
*/
+ @Override
public synchronized void addBodyPart(BodyPart part, int index)
throws MessagingException {
parse();
@@ -519,6 +526,7 @@
* Iterates through all the parts and outputs each MIME part
* separated by a boundary.
*/
+ @Override
public synchronized void writeTo(OutputStream os)
throws IOException, MessagingException {
parse();
@@ -568,7 +576,8 @@
* The {@link #initializeProperties} method is called before
* parsing the data.
*
- * @exception MessagingException for failures
+ * @exception ParseException for failures parsing the message
+ * @exception MessagingException for other failures
* @since JavaMail 1.2
*/
protected synchronized void parse() throws MessagingException {
@@ -602,14 +611,13 @@
}
if (boundary == null && !ignoreMissingBoundaryParameter &&
!ignoreExistingBoundaryParameter)
- throw new MessagingException("Missing boundary parameter");
+ throw new ParseException("Missing boundary parameter");
try {
// Skip and save the preamble
LineInputStream lin = new LineInputStream(in);
- StringBuffer preamblesb = null;
+ StringBuilder preamblesb = null;
String line;
- String lineSeparator = null;
while ((line = lin.readLine()) != null) {
/*
* Strip trailing whitespace. Can't use trim method
@@ -655,20 +663,10 @@
// save the preamble after skipping blank lines
if (line.length() > 0) {
- // if we haven't figured out what the line separator
- // is, do it now
- if (lineSeparator == null) {
- try {
- lineSeparator =
- System.getProperty("line.separator", "\n");
- } catch (SecurityException ex) {
- lineSeparator = "\n";
- }
- }
// accumulate the preamble
if (preamblesb == null)
- preamblesb = new StringBuffer(line.length() + 2);
- preamblesb.append(line).append(lineSeparator);
+ preamblesb = new StringBuilder(line.length() + 2);
+ preamblesb.append(line).append(System.lineSeparator());
}
}
@@ -679,7 +677,7 @@
if (allowEmpty)
return;
else
- throw new MessagingException("Missing start boundary");
+ throw new ParseException("Missing start boundary");
}
// save individual boundary bytes for comparison later
@@ -731,7 +729,7 @@
;
if (line == null) {
if (!ignoreMissingEndBoundary)
- throw new MessagingException(
+ throw new ParseException(
"missing multipart end boundary");
// assume there's just a missing end boundary
complete = false;
@@ -779,7 +777,7 @@
if (inSize < bl) {
// hit EOF
if (!ignoreMissingEndBoundary)
- throw new MessagingException(
+ throw new ParseException(
"missing multipart end boundary");
if (sin != null)
end = sin.getPosition();
diff --git a/current/src/main/java/javax/mail/internet/MimePart.java b/current/src/main/java/javax/mail/internet/MimePart.java
index 99b1186..6f1099f 100644
--- a/current/src/main/java/javax/mail/internet/MimePart.java
+++ b/current/src/main/java/javax/mail/internet/MimePart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -108,8 +108,7 @@
* @return an Enumeration of Strings
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getAllHeaderLines() throws MessagingException;
+ public Enumeration<String> getAllHeaderLines() throws MessagingException;
/**
* Get matching header lines as an Enumeration of Strings.
@@ -120,8 +119,7 @@
* @return an Enumeration of Strings
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getMatchingHeaderLines(String[] names)
+ public Enumeration<String> getMatchingHeaderLines(String[] names)
throws MessagingException;
/**
@@ -133,8 +131,7 @@
* @return an Enumeration of Strings
* @exception MessagingException for failures
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNonMatchingHeaderLines(String[] names)
+ public Enumeration<String> getNonMatchingHeaderLines(String[] names)
throws MessagingException;
/**
@@ -216,6 +213,7 @@
* @exception MessagingException if an error occurs
* @see #setText(String text, String charset)
*/
+ @Override
public void setText(String text) throws MessagingException;
/**
diff --git a/current/src/main/java/javax/mail/internet/MimePartDataSource.java b/current/src/main/java/javax/mail/internet/MimePartDataSource.java
index 963fefe..90236e0 100644
--- a/current/src/main/java/javax/mail/internet/MimePartDataSource.java
+++ b/current/src/main/java/javax/mail/internet/MimePartDataSource.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -91,6 +91,7 @@
* @see javax.mail.internet.MimeUtility#decode
* @return decoded input stream
*/
+ @Override
public InputStream getInputStream() throws IOException {
InputStream is;
@@ -123,6 +124,7 @@
*
* This implementation throws the UnknownServiceException.
*/
+ @Override
public OutputStream getOutputStream() throws IOException {
throw new UnknownServiceException("Writing not supported");
}
@@ -133,6 +135,7 @@
* This implementation just invokes the <code>getContentType</code>
* method on the MimePart.
*/
+ @Override
public String getContentType() {
try {
return part.getContentType();
@@ -150,6 +153,7 @@
*
* This implementation just returns an empty string.
*/
+ @Override
public String getName() {
try {
if (part instanceof MimeBodyPart)
@@ -164,6 +168,7 @@
* Return the <code>MessageContext</code> for the current part.
* @since JavaMail 1.1
*/
+ @Override
public synchronized MessageContext getMessageContext() {
if (context == null)
context = new MessageContext(part);
diff --git a/current/src/main/java/javax/mail/internet/MimeUtility.java b/current/src/main/java/javax/mail/internet/MimeUtility.java
index 99d91ec..50e839c 100644
--- a/current/src/main/java/javax/mail/internet/MimeUtility.java
+++ b/current/src/main/java/javax/mail/internet/MimeUtility.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -45,7 +45,21 @@
import javax.activation.*;
import java.util.*;
import java.io.*;
-import com.sun.mail.util.*;
+import java.nio.charset.Charset;
+import com.sun.mail.util.PropUtil;
+import com.sun.mail.util.ASCIIUtility;
+import com.sun.mail.util.BASE64DecoderStream;
+import com.sun.mail.util.BASE64EncoderStream;
+import com.sun.mail.util.BEncoderStream;
+import com.sun.mail.util.LineInputStream;
+import com.sun.mail.util.LineOutputStream;
+import com.sun.mail.util.LogOutputStream;
+import com.sun.mail.util.QDecoderStream;
+import com.sun.mail.util.QEncoderStream;
+import com.sun.mail.util.QPDecoderStream;
+import com.sun.mail.util.QPEncoderStream;
+import com.sun.mail.util.UUDecoderStream;
+import com.sun.mail.util.UUEncoderStream;
/**
* This is a utility class that provides various MIME related
@@ -149,7 +163,7 @@
// cached map of whether a charset is compatible with ASCII
// Map<String,Boolean>
private static final Map<String, Boolean> nonAsciiCharsetMap
- = new HashMap<String, Boolean>();
+ = new HashMap<>();
private static final boolean decodeStrict =
PropUtil.getBooleanSystemProperty("mail.mime.decodetext.strict", true);
@@ -158,6 +172,8 @@
private static final boolean ignoreUnknownEncoding =
PropUtil.getBooleanSystemProperty(
"mail.mime.ignoreunknownencoding", false);
+ private static final boolean allowUtf8 =
+ PropUtil.getBooleanSystemProperty("mail.mime.allowutf8", false);
/*
* The following two properties allow disabling the fold()
* and unfold() methods and reverting to the previous behavior.
@@ -593,8 +609,8 @@
// Encoded words found. Start decoding ...
st = new StringTokenizer(etext, lwsp, true);
- StringBuffer sb = new StringBuffer(); // decode buffer
- StringBuffer wsb = new StringBuffer(); // white space buffer
+ StringBuilder sb = new StringBuilder(); // decode buffer
+ StringBuilder wsb = new StringBuilder(); // white space buffer
boolean prevWasEncoded = false;
while (st.hasMoreTokens()) {
@@ -754,7 +770,7 @@
throw new UnsupportedEncodingException(
"Unknown transfer encoding: " + encoding);
- StringBuffer outb = new StringBuffer(); // the output buffer
+ StringBuilder outb = new StringBuilder(); // the output buffer
doEncode(string, b64, jcharset,
// As per RFC 2047, size of an encoded string should not
// exceed 75 bytes.
@@ -768,7 +784,7 @@
private static void doEncode(String string, boolean b64,
String jcharset, int avail, String prefix,
- boolean first, boolean encodingWord, StringBuffer buf)
+ boolean first, boolean encodingWord, StringBuilder buf)
throws UnsupportedEncodingException {
// First find out what the length of the encoded version of
@@ -809,7 +825,7 @@
byte[] encodedBytes = os.toByteArray(); // the encoded stuff
// Now write out the encoded (all ASCII) bytes into our
- // StringBuffer
+ // StringBuilder
if (!first) // not the first line of this sequence
if (foldEncodedWords)
buf.append("\r\n "); // start a continuation line
@@ -946,7 +962,7 @@
private static String decodeInnerWords(String word)
throws UnsupportedEncodingException {
int start = 0, i;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
while ((i = word.indexOf("=?", start)) >= 0) {
buf.append(word.substring(start, i));
// find first '?' after opening '=?' - end of charset
@@ -1007,7 +1023,7 @@
char c = word.charAt(i);
if (c == '"' || c == '\\' || c == '\r' || c == '\n') {
// need to escape them and then quote the whole string
- StringBuffer sb = new StringBuffer(len + 3);
+ StringBuilder sb = new StringBuilder(len + 3);
sb.append('"');
sb.append(word.substring(0, i));
int lastc = 0;
@@ -1024,13 +1040,14 @@
}
sb.append('"');
return sb.toString();
- } else if (c < 040 || c >= 0177 || specials.indexOf(c) >= 0)
+ } else if (c < 040 || (c >= 0177 && !allowUtf8) ||
+ specials.indexOf(c) >= 0)
// These characters cause the string to be quoted
needQuoting = true;
}
if (needQuoting) {
- StringBuffer sb = new StringBuffer(len + 2);
+ StringBuilder sb = new StringBuilder(len + 2);
sb.append('"').append(word).append('"');
return sb.toString();
} else
@@ -1156,44 +1173,39 @@
if (!foldText)
return s;
- StringBuffer sb = null;
+ StringBuilder sb = null;
int i;
while ((i = indexOfAny(s, "\r\n")) >= 0) {
int start = i;
- int l = s.length();
+ int slen = s.length();
i++; // skip CR or NL
- if (i < l && s.charAt(i - 1) == '\r' && s.charAt(i) == '\n')
+ if (i < slen && s.charAt(i - 1) == '\r' && s.charAt(i) == '\n')
i++; // skip LF
- if (start == 0 || s.charAt(start - 1) != '\\') {
- char c;
- // if next line starts with whitespace, skip all of it
- // XXX - always has to be true?
- if (i < l && ((c = s.charAt(i)) == ' ' || c == '\t')) {
- i++; // skip whitespace
- while (i < l && ((c = s.charAt(i)) == ' ' || c == '\t'))
- i++;
- if (sb == null)
- sb = new StringBuffer(s.length());
- if (start != 0) {
- sb.append(s.substring(0, start));
- sb.append(' ');
- }
- s = s.substring(i);
- continue;
- }
- // it's not a continuation line, just leave it in
- if (sb == null)
- sb = new StringBuffer(s.length());
- sb.append(s.substring(0, i));
- s = s.substring(i);
- } else {
- // there's a backslash at "start - 1"
+ if (start > 0 && s.charAt(start - 1) == '\\') {
+ // there's a backslash before the line break
// strip it out, but leave in the line break
if (sb == null)
- sb = new StringBuffer(s.length());
+ sb = new StringBuilder(s.length());
sb.append(s.substring(0, start - 1));
sb.append(s.substring(start, i));
s = s.substring(i);
+ } else {
+ char c;
+ // if next line starts with whitespace,
+ // or at the end of the string, remove the line break
+ // XXX - next line should always start with whitespace
+ if (i >= slen || (c = s.charAt(i)) == ' ' || c == '\t') {
+ if (sb == null)
+ sb = new StringBuilder(s.length());
+ sb.append(s.substring(0, start));
+ s = s.substring(i);
+ } else {
+ // it's not a continuation line, just leave in the newline
+ if (sb == null)
+ sb = new StringBuilder(s.length());
+ sb.append(s.substring(0, i));
+ s = s.substring(i);
+ }
}
}
if (sb != null) {
@@ -1239,6 +1251,14 @@
return charset;
String alias = mime2java.get(charset.toLowerCase(Locale.ENGLISH));
+ if (alias != null) {
+ // verify that the mapped name is valid before trying to use it
+ try {
+ Charset.forName(alias);
+ } catch (Exception ex) {
+ alias = null; // charset alias not valid, use original name
+ }
+ }
return alias == null ? charset : alias;
}
@@ -1298,6 +1318,7 @@
} catch (SecurityException sex) {
class NullInputStream extends InputStream {
+ @Override
public int read() {
return 0;
}
@@ -1333,8 +1354,8 @@
private static Map<String, String> java2mime;
static {
- java2mime = new HashMap<String, String>(40);
- mime2java = new HashMap<String, String>(10);
+ java2mime = new HashMap<>(40);
+ mime2java = new HashMap<>(14);
try {
// Use this class's classloader to load the mapping file
@@ -1422,6 +1443,10 @@
mime2java.put("euckr", "KSC5601");
mime2java.put("us-ascii", "ISO-8859-1");
mime2java.put("x-us-ascii", "ISO-8859-1");
+ mime2java.put("gb2312", "GB18030");
+ mime2java.put("cp936", "GB18030");
+ mime2java.put("ms936", "GB18030");
+ mime2java.put("gbk", "GB18030");
}
}
@@ -1641,14 +1666,17 @@
checkEOL = encodeEolStrict && breakOnNonAscii;
}
+ @Override
public void write(int b) throws IOException {
check(b);
}
+ @Override
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
+ @Override
public void write(byte b[], int off, int len) throws IOException {
len += off;
for (int i = off; i < len ; i++)
diff --git a/current/src/main/java/javax/mail/internet/NewsAddress.java b/current/src/main/java/javax/mail/internet/NewsAddress.java
index b0ba003..3af8843 100644
--- a/current/src/main/java/javax/mail/internet/NewsAddress.java
+++ b/current/src/main/java/javax/mail/internet/NewsAddress.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -91,6 +91,7 @@
* Return the type of this address. The type of a NewsAddress
* is "news".
*/
+ @Override
public String getType() {
return "news";
}
@@ -136,6 +137,7 @@
*
* @return newsgroup
*/
+ @Override
public String toString() {
return newsgroup;
}
@@ -143,6 +145,7 @@
/**
* The equality operator.
*/
+ @Override
public boolean equals(Object a) {
if (!(a instanceof NewsAddress))
return false;
@@ -157,6 +160,7 @@
/**
* Compute a hash code for the address.
*/
+ @Override
public int hashCode() {
int hash = 0;
if (newsgroup != null)
@@ -182,8 +186,8 @@
if (addresses == null || addresses.length == 0)
return null;
- StringBuffer s =
- new StringBuffer(((NewsAddress)addresses[0]).toString());
+ StringBuilder s =
+ new StringBuilder(((NewsAddress)addresses[0]).toString());
int used = s.length();
for (int i = 1; i < addresses.length; i++) {
s.append(",");
@@ -212,7 +216,7 @@
throws AddressException {
// XXX - verify format of newsgroup name?
StringTokenizer st = new StringTokenizer(newsgroups, ",");
- List<NewsAddress> nglist = new ArrayList<NewsAddress>();
+ List<NewsAddress> nglist = new ArrayList<>();
while (st.hasMoreTokens()) {
String ng = st.nextToken();
nglist.add(new NewsAddress(ng));
diff --git a/current/src/main/java/javax/mail/internet/ParameterList.java b/current/src/main/java/javax/mail/internet/ParameterList.java
index 74892a4..c1f07c7 100644
--- a/current/src/main/java/javax/mail/internet/ParameterList.java
+++ b/current/src/main/java/javax/mail/internet/ParameterList.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -89,7 +89,7 @@
* will all move to the end.
*/
// keep parameters in order
- private Map<String, Object> list = new LinkedHashMap<String, Object>();
+ private Map<String, Object> list = new LinkedHashMap<>();
/**
* A set of names for multi-segment parameters that we
@@ -205,10 +205,12 @@
this.it = it;
}
+ @Override
public boolean hasMoreElements() {
return it.hasNext();
}
+ @Override
public String nextElement() {
return it.next();
}
@@ -220,8 +222,8 @@
public ParameterList() {
// initialize other collections only if they'll be needed
if (decodeParameters) {
- multisegmentNames = new HashSet<String>();
- slist = new HashMap<String, Object>();
+ multisegmentNames = new HashSet<>();
+ slist = new HashMap<>();
}
}
@@ -624,8 +626,7 @@
*
* @return Enumeration of all parameter names in this list.
*/
- @SuppressWarnings("rawtypes")
- public Enumeration getNames() {
+ public Enumeration<String> getNames() {
return new ParamEnum(list.keySet().iterator());
}
@@ -635,6 +636,7 @@
*
* @return String
*/
+ @Override
public String toString() {
return toString(0);
}
@@ -728,7 +730,7 @@
*/
private static class ToStringBuffer {
private int used; // keep track of how much used on current line
- private StringBuffer sb = new StringBuffer();
+ private StringBuilder sb = new StringBuilder();
public ToStringBuffer(int used) {
this.used = used;
@@ -759,6 +761,7 @@
}
}
+ @Override
public String toString() {
return sb.toString();
}
diff --git a/current/src/main/java/javax/mail/internet/ParseException.java b/current/src/main/java/javax/mail/internet/ParseException.java
index d7e42be..d3d7bb6 100644
--- a/current/src/main/java/javax/mail/internet/ParseException.java
+++ b/current/src/main/java/javax/mail/internet/ParseException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -44,7 +44,7 @@
/**
* The exception thrown due to an error in parsing RFC822
- * or MIME headers
+ * or MIME headers, including multipart bodies.
*
* @author John Mani
*/
diff --git a/current/src/main/java/javax/mail/internet/PreencodedMimeBodyPart.java b/current/src/main/java/javax/mail/internet/PreencodedMimeBodyPart.java
index dec6548..2ee6a6e 100644
--- a/current/src/main/java/javax/mail/internet/PreencodedMimeBodyPart.java
+++ b/current/src/main/java/javax/mail/internet/PreencodedMimeBodyPart.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -78,6 +78,7 @@
* Returns the content transfer encoding specified when
* this object was created.
*/
+ @Override
public String getEncoding() throws MessagingException {
return encoding;
}
@@ -91,6 +92,7 @@
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
+ @Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
@@ -103,7 +105,6 @@
}
// First, write out the header
- @SuppressWarnings("unchecked")
Enumeration<String> hdrLines = getAllHeaderLines();
while (hdrLines.hasMoreElements())
los.writeln(hdrLines.nextElement());
@@ -120,6 +121,7 @@
* Force the <code>Content-Transfer-Encoding</code> header to use
* the encoding that was specified when this object was created.
*/
+ @Override
protected void updateHeaders() throws MessagingException {
super.updateHeaders();
MimeBodyPart.setEncoding(this, encoding);
diff --git a/current/src/main/java/javax/mail/internet/SharedInputStream.java b/current/src/main/java/javax/mail/internet/SharedInputStream.java
index c9f26b8..115c77b 100644
--- a/current/src/main/java/javax/mail/internet/SharedInputStream.java
+++ b/current/src/main/java/javax/mail/internet/SharedInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/internet/UniqueValue.java b/current/src/main/java/javax/mail/internet/UniqueValue.java
index 395fe84..6ff5f15 100644
--- a/current/src/main/java/javax/mail/internet/UniqueValue.java
+++ b/current/src/main/java/javax/mail/internet/UniqueValue.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -70,7 +70,7 @@
* and the current time (in milliseconds).
*/
public static String getUniqueBoundaryValue() {
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
long hash = s.hashCode();
// Unique string is ----=_Part_<part>_<hashcode>.<currentTime>
@@ -107,7 +107,7 @@
if (at >= 0)
suffix = suffix.substring(at);
- StringBuffer s = new StringBuffer();
+ StringBuilder s = new StringBuilder();
// Unique string is <hashcode>.<id>.<currentTime><suffix>
s.append(s.hashCode()).append('.').
diff --git a/current/src/main/java/javax/mail/internet/package.html b/current/src/main/java/javax/mail/internet/package.html
deleted file mode 100644
index a9aace2..0000000
--- a/current/src/main/java/javax/mail/internet/package.html
+++ /dev/null
@@ -1,585 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-Classes specific to Internet mail systems.
-This package supports features that are specific to Internet mail systems
-based on the MIME standard
-(<A HREF="http://www.ietf.org/rfc/rfc2045.txt" TARGET="_top">RFC 2045</A>,
-<A HREF="http://www.ietf.org/rfc/rfc2045.txt" TARGET="_top">RFC 2046</A>, and
-<A HREF="http://www.ietf.org/rfc/rfc2045.txt" TARGET="_top">RFC 2047</A>).
-The IMAP, SMTP, and POP3 protocols use
-{@link javax.mail.internet.MimeMessage MimeMessages}.
-<P>
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-The JavaMail API supports the following standard properties,
-which may be set in the <code>Session</code> object, or in the
-<code>Properties</code> object used to create the <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- session.setProperty("mail.mime.address.strict", "false");
-</PRE>
-to set the <CODE>mail.mime.address.strict</CODE> property,
-which is of type boolean.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.mime.address.strict"></A>
-<TR id="mail.mime.address.strict">
-<TD>mail.mime.address.strict</TD>
-<TD>boolean</TD>
-<TD>
-The <code>mail.mime.address.strict</code> session property controls
-the parsing of address headers. By default, strict parsing of address
-headers is done. If this property is set to <code>"false"</code>,
-strict parsing is not done and many illegal addresses that sometimes
-occur in real messages are allowed. See the <code>InternetAddress</code>
-class for details.
-</TD>
-</TR>
-</TABLE>
-<P>
-The JavaMail API specification requires support for the following properties,
-which must be set in the <code>System</code> properties.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- System.setProperty("mail.mime.decodetext.strict", "false");
-</PRE>
-to set the <CODE>mail.mime.decodetext.strict</CODE> property,
-which is of type boolean.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.mime.charset"></A>
-<TR id="mail.mime.charset">
-<TD>mail.mime.charset</TD>
-<TD>String</TD>
-<TD>
-The <code>mail.mime.charset</code> System property can
-be used to specify the default MIME charset to use for encoded words
-and text parts that don't otherwise specify a charset. Normally, the
-default MIME charset is derived from the default Java charset, as
-specified in the <code>file.encoding</code> System property. Most
-applications will have no need to explicitly set the default MIME
-charset. In cases where the default MIME charset to be used for
-mail messages is different than the charset used for files stored on
-the system, this property should be set.
-</TD>
-</TR>
-
-<A NAME="mail.mime.decodetext.strict"></A>
-<TR id="mail.mime.decodetext.strict">
-<TD>mail.mime.decodetext.strict</TD>
-<TD>boolean</TD>
-<TD>
-The <code>mail.mime.decodetext.strict</code> property controls
-decoding of MIME encoded words. The MIME spec requires that encoded
-words start at the beginning of a whitespace separated word. Some
-mailers incorrectly include encoded words in the middle of a word.
-If the <code>mail.mime.decodetext.strict</code> System property is
-set to <code>"false"</code>, an attempt will be made to decode these
-illegal encoded words. The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.encodeeol.strict"></A>
-<TR id="mail.mime.encodeeol.strict">
-<TD>mail.mime.encodeeol.strict</TD>
-<TD>boolean</TD>
-<TD>
-The <code>mail.mime.encodeeol.strict</code> property controls the
-choice of Content-Transfer-Encoding for MIME parts that are not of
-type "text". Often such parts will contain textual data for which
-an encoding that allows normal end of line conventions is appropriate.
-In rare cases, such a part will appear to contain entirely textual
-data, but will require an encoding that preserves CR and LF characters
-without change. If the <code>mail.mime.encodeeol.strict</code>
-System property is set to <code>"true"</code>, such an encoding will
-be used when necessary. The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.decodefilename"></A>
-<TR id="mail.mime.decodefilename">
-<TD>mail.mime.decodefilename</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, the <code>getFileName</code> method
-uses the <code>MimeUtility</code>
-method <code>decodeText</code> to decode any
-non-ASCII characters in the filename. Note that this decoding
-violates the MIME specification, but is useful for interoperating
-with some mail clients that use this convention.
-The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.encodefilename"></A>
-<TR id="mail.mime.encodefilename">
-<TD>mail.mime.encodefilename</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, the <code>setFileName</code> method
-uses the <code>MimeUtility</code>
-method <code>encodeText</code> to encode any
-non-ASCII characters in the filename. Note that this encoding
-violates the MIME specification, but is useful for interoperating
-with some mail clients that use this convention.
-The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.decodeparameters"></A>
-<TR id="mail.mime.decodeparameters">
-<TD>mail.mime.decodeparameters</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"false"</code>, non-ASCII parameters in a
-<code>ParameterList</code>, e.g., in a Content-Type header,
-will <b>not</b> be decoded as specified by
-<A HREF="http://www.ietf.org/rfc/rfc2231.txt" TARGET="_top">RFC 2231</A>.
-The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.encodeparameters"></A>
-<TR id="mail.mime.encodeparameters">
-<TD>mail.mime.encodeparameters</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"false"</code>, non-ASCII parameters in a
-<code>ParameterList</code>, e.g., in a Content-Type header,
-will <b>not</b> be encoded as specified by
-<A HREF="http://www.ietf.org/rfc/rfc2231.txt" TARGET="_top">RFC 2231</A>.
-The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.multipart.ignoremissingendboundary"></A>
-<TR id="mail.mime.multipart.ignoremissingendboundary">
-<TD>mail.mime.multipart. ignoremissingendboundary</TD>
-<TD>boolean</TD>
-<TD>
-Normally, when parsing a multipart MIME message, a message that is
-missing the final end boundary line is not considered an error.
-The data simply ends at the end of the input. Note that messages
-of this form violate the MIME specification. If the property
-<code>mail.mime.multipart.ignoremissingendboundary</code> is set
-to <code>false</code>, such messages are considered an error and a
-<code>MesagingException</code> will be thrown when parsing such a
-message.
-</TD>
-</TR>
-
-<A NAME="mail.mime.multipart.ignoremissingboundaryparameter"></A>
-<TR id="mail.mime.multipart.ignoremissingboundaryparameter">
-<TD>mail.mime.multipart. ignoremissingboundaryparameter</TD>
-<TD>boolean</TD>
-<TD>
-If the Content-Type header for a multipart content does not have
-a <code>boundary</code> parameter, the multipart parsing code
-will look for the first line in the content that looks like a
-boundary line and extract the boundary parameter from the line.
-If this property is set to <code>"false"</code>, a
-<code>MessagingException</code> will be thrown if the Content-Type
-header doesn't specify a boundary parameter.
-The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.multipart.ignoreexistingboundaryparameter"></A>
-<TR id="mail.mime.multipart.ignoreexistingboundaryparameter">
-<TD>mail.mime.multipart. ignoreexistingboundaryparameter</TD>
-<TD>boolean</TD>
-<TD>
-Normally the boundary parameter in the Content-Type header of a multipart
-body part is used to specify the separator between parts of the multipart
-body. This System property may be set to <code>"true"</code> to cause
-the parser to look for a line in the multipart body that looks like a
-boundary line and use that value as the separator between subsequent parts.
-This may be useful in cases where a broken anti-virus product has rewritten
-the message incorrectly such that the boundary parameter and the actual
-boundary value no longer match.
-The default value of this property is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.multipart.allowempty"></A>
-<TR id="mail.mime.multipart.allowempty">
-<TD>mail.mime.multipart. allowempty</TD>
-<TD>boolean</TD>
-<TD>
-Normally, when writing out a MimeMultipart that contains no body
-parts, or when trying to parse a multipart message with no body parts,
-a <code>MessagingException</code> is thrown. The MIME spec does not allow
-multipart content with no body parts. This
-System property may be set to <code>"true"</code> to override this behavior.
-When writing out such a MimeMultipart, a single empty part will be
-included. When reading such a multipart, a MimeMultipart will be created
-with no body parts.
-The default value of this property is false.
-</TD>
-</TR>
-
-</TABLE>
-
-
-<P>
-The following properties are supported by the reference implementation (RI) of
-JavaMail, but are not currently a required part of the specification.
-These must be set as <CODE>Session</CODE> properties.
-The names, types, defaults, and semantics of these properties may
-change in future releases.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.alternates"></A>
-<TR id="mail.alternates">
-<TD>mail.alternates</TD>
-<TD>String</TD>
-<TD>
-A string containing other email addresses that the current user is known by.
-The <code>MimeMessage</code> <code>reply</code> method will eliminate any
-of these addresses from the recipient list in the message it constructs,
-to avoid sending the reply back to the sender.
-</TD>
-</TR>
-
-<A NAME="mail.replyallcc"></A>
-<TR id="mail.replyallcc">
-<TD>mail.replyallcc</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, the <code>MimeMessage</code>
-<code>reply</code> method will put all recipients except the original
-sender in the <code>Cc</code> list of the newly constructed message.
-Normally, recipients in the <code>To</code> header of the original
-message will also appear in the <code>To</code> list of the newly
-constructed message.
-</TD>
-</TR>
-</TABLE>
-
-<P>
-The following properties are supported by the reference implementation (RI) of
-JavaMail, but are not currently a required part of the specification.
-These must be set as <CODE>System</CODE> properties.
-The names, types, defaults, and semantics of these properties may
-change in future releases.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.mime.base64.ignoreerrors"></A>
-<TR id="mail.mime.base64.ignoreerrors">
-<TD>mail.mime.base64.ignoreerrors</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, the BASE64 decoder will ignore errors
-in the encoded data, returning EOF. This may be useful when dealing
-with improperly encoded messages that contain extraneous data at the
-end of the encoded stream. Note however that errors anywhere in the
-stream will cause the decoder to stop decoding so this should be used
-with extreme caution. The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.foldtext"></A>
-<TR id="mail.mime.foldtext">
-<TD>mail.mime.foldtext</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, header fields containing just text
-such as the <code>Subject</code> and <code>Content-Description</code>
-header fields, and long parameter values in structured headers such
-as <code>Content-Type</code> will be folded (broken into 76 character lines)
-when set and unfolded when read. The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.setcontenttypefilename"></A>
-<TR id="mail.mime.setcontenttypefilename">
-<TD>mail.mime.setcontenttypefilename</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, the <code>setFileName</code> method
-will also set the <code>name</code> parameter on the <code>Content-Type</code>
-header to the specified filename. This supports interoperability with
-some old mail clients. The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.setdefaulttextcharset"></A>
-<TR id="mail.mime.setdefaulttextcharset">
-<TD>mail.mime.setdefaulttextcharset</TD>
-<TD>boolean</TD>
-<TD>
-When updating the headers of a message, a body
-part with a <code>text</code> content type but no <code>charset</code>
-parameter will have a <code>charset</code> parameter added to it
-if this property is set to <code>"true"</code>.
-The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.parameters.strict"></A>
-<TR id="mail.mime.parameters.strict">
-<TD>mail.mime.parameters.strict</TD>
-<TD>boolean</TD>
-<TD>
-If set to false, when reading a message, parameter values in header fields
-such as <code>Content-Type</code> and <code>Content-Disposition</code>
-are allowed to contain whitespace and other special characters without
-being quoted; the parameter value ends at the next semicolon.
-If set to true (the default), parameter values are required to conform
-to the MIME specification and must be quoted if they contain whitespace
-or special characters.
-</TD>
-</TR>
-
-<A NAME="mail.mime.applefilenames"></A>
-<TR id="mail.mime.applefilenames">
-<TD>mail.mime.applefilenames</TD>
-<TD>boolean</TD>
-<TD>
-Apple Mail incorrectly encodes filenames that contain spaces,
-forgetting to quote the parameter value. If this property is
-set to <code>"true"</code>, JavaMail will try to detect this
-situation when parsing parameters and work around it.
-The default is false.
-Note that this property handles a subset of the cases handled
-by setting the mail.mime.parameters.strict property to false.
-This property will likely be removed in a future release.
-</TD>
-</TR>
-
-<A NAME="mail.mime.windowsfilenames"></A>
-<TR id="mail.mime.windowsfilenames">
-<TD>mail.mime.windowsfilenames</TD>
-<TD>boolean</TD>
-<TD>
-Internet Explorer 6 incorrectly includes a complete pathname
-in the filename parameter of the Content-Disposition header
-for uploaded files, and fails to properly escape the backslashes
-in the pathname. If this property is
-set to <code>"true"</code>, JavaMail will preserve all backslashes
-in the "filename" and "name" parameters of any MIME header.
-The default is false.
-Note that this is a violation of the MIME specification but may
-be useful when using JavaMail to parse HTTP messages for uploaded
-files sent by IE6.
-</TD>
-</TR>
-
-<A NAME="mail.mime.ignoreunknownencoding"></A>
-<TR id="mail.mime.ignoreunknownencoding">
-<TD>mail.mime. ignoreunknownencoding</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, an unknown value in the
-<code>Content-Transfer-Encoding</code> header will be ignored
-when reading a message and an encoding of "8bit" will be assumed.
-If set to <code>"false"</code>, an exception is thrown for an
-unknown encoding value. The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.uudecode.ignoreerrors"></A>
-<TR id="mail.mime.uudecode.ignoreerrors">
-<TD>mail.mime.uudecode. ignoreerrors</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, errors in the encoded format of a
-uuencoded document will be ignored when reading a message part.
-If set to <code>"false"</code>, an exception is thrown for an
-incorrectly encoded message part. The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.uudecode.ignoremissingbeginend"></A>
-<TR id="mail.mime.uudecode.ignoremissingbeginend">
-<TD>mail.mime.uudecode. ignoremissingbeginend</TD>
-<TD>boolean</TD>
-<TD>
-If set to <code>"true"</code>, a missing "being" or "end" line in a
-uuencoded document will be ignored when reading a message part.
-If set to <code>"false"</code>, an exception is thrown for a
-uuencoded message part without the required "begin" and "end" lines.
-The default is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.ignorewhitespacelines"></A>
-<TR id="mail.mime.ignorewhitespacelines">
-<TD>mail.mime. ignorewhitespacelines</TD>
-<TD>boolean</TD>
-<TD>
-Normally the header of a MIME part is separated from the body by an empty
-line. This System property may be set to <code>"true"</code> to cause
-the parser to consider a line containing only whitespace to be an empty
-line. The default value of this property is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.ignoremultipartencoding"></A>
-<TR id="mail.mime.ignoremultipartencoding">
-<TD>mail.mime. ignoremultipartencoding</TD>
-<TD>boolean</TD>
-<TD>
-The MIME spec does not allow body parts of type multipart/* to be encoded.
-The Content-Transfer-Encoding header is ignored in this case.
-Setting this System property to <code>"false"</code> will
-cause the Content-Transfer-Encoding header to be honored for multipart
-content.
-The default value of this property is true.
-</TD>
-</TR>
-
-<A NAME="mail.mime.allowencodedmessages"></A>
-<TR id="mail.mime.allowencodedmessages">
-<TD>mail.mime.allowencodedmessages</TD>
-<TD>boolean</TD>
-<TD>
-The MIME spec does not allow body parts of type message/* to be encoded.
-The Content-Transfer-Encoding header is ignored in this case.
-Some versions of Microsoft Outlook will incorrectly encode message
-attachments. Setting this System property to <code>"true"</code> will
-cause the Content-Transfer-Encoding header to be honored for message
-attachments.
-The default value of this property is false.
-</TD>
-</TR>
-
-<A NAME="mail.mime.contenttypehandler"></A>
-<TR id="mail.mime.contenttypehandler">
-<TD>mail.mime.contenttypehandler</TD>
-<TD>String</TD>
-<TD>
-In some cases JavaMail is unable to process messages with an invalid
-Content-Type header. The header may have incorrect syntax or other
-problems. This property specifies the name of a class that will be
-used to clean up the Content-Type header value before JavaMail uses it.
-The class must have a method with this signature:
-<CODE>public static String cleanContentType(MimePart mp, String contentType)</CODE>
-Whenever JavaMail accesses the Content-Type header of a message, it
-will pass the value to this method and use the returned value instead.
-The value may be null if the Content-Type header isn't present.
-Returning null will cause the default Content-Type to be used.
-The MimePart may be used to access other headers of the message part
-to determine how to correct the Content-Type.
-Note that the Content-Type handler doesn't affect the
-<CODE>getHeader</CODE> method, which still returns the raw header value.
-Note also that the handler doesn't affect the IMAP provider; the IMAP
-server is responsible for returning pre-parsed, syntactically correct
-Content-Type information.
-</TD>
-</TR>
-
-<A NAME="mail.mime.address.usecanonicalhostname"></A>
-<TR id="mail.mime.address.usecanonicalhostname">
-<TD>mail.mime.address.usecanonicalhostname</TD>
-<TD>boolean</TD>
-<TD>
-Use the
-{@link java.net.InetAddress#getCanonicalHostName InetAddress.getCanonicalHostName}
-method to determine the host name in the
-{@link javax.mail.internet.InternetAddress#getLocalAddress InternetAddress.getLocalAddress}
-method.
-With some network configurations, InetAddress.getCanonicalHostName may be
-slow or may return an address instead of a host name.
-In that case, setting this System property to false will cause the
-{@link java.net.InetAddress#getHostName InetAddress.getHostName}
-method to be used instead.
-The default is true.
-</TD>
-</TR>
-
-</TABLE>
-<P>
-The current
-implementation of classes in this package log debugging information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>javax.mail.internet</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-</TABLE>
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/javax/mail/package.html b/current/src/main/java/javax/mail/package.html
deleted file mode 100644
index 0fe7dce..0000000
--- a/current/src/main/java/javax/mail/package.html
+++ /dev/null
@@ -1,376 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-The JavaMail<sup><font size="-2">TM</font></sup> API
-provides classes that model a mail system.
-The <code>javax.mail</code> package defines classes that are common to
-all mail systems.
-The <code>javax.mail.internet</code> package defines classes that are specific
-to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
-The JavaMail API includes the <code>javax.mail</code> package and subpackages.
-<P>
-For an overview of the JavaMail API, read the
-<A HREF="http://javamail.java.net/nonav/docs/JavaMail-1.5.pdf" TARGET="_top">
-JavaMail specification</A>.
-<P>
-The code to send a plain text message can be as simple as the following:
-<PRE>
- Properties props = new Properties();
- props.put("mail.smtp.host", "my-mail-server");
- Session session = Session.getInstance(props, null);
-
- try {
- MimeMessage msg = new MimeMessage(session);
- msg.setFrom("me@example.com");
- msg.setRecipients(Message.RecipientType.TO,
- "you@example.com");
- msg.setSubject("JavaMail hello world example");
- msg.setSentDate(new Date());
- msg.setText("Hello, world!\n");
- Transport.send(msg, "me@example.com", "my-password");
- } catch (MessagingException mex) {
- System.out.println("send failed, exception: " + mex);
- }
-</PRE>
-The JavaMail download bundle contains many more complete examples
-in the "demo" directory.
-<P>
-Don't forget to see the
-<A HREF="http://www.oracle.com/technetwork/java/javamail/faq/" TARGET="_top">
-JavaMail API FAQ</A>
-for answers to the most common questions.
-The <A HREF="http://www.oracle.com/technetwork/java/javamail/" TARGET="_top">
-JavaMail web site</A>
-contains many additional resources.
-<P>
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-The JavaMail API supports the following standard properties,
-which may be set in the <code>Session</code> object, or in the
-<code>Properties</code> object used to create the <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- props.put("mail.debug", "true");
-</PRE>
-to set the <code>mail.debug</code> property, which is of type boolean.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.debug"></A>
-<TR id="mail.debug">
-<TD>mail.debug</TD>
-<TD>boolean</TD>
-<TD>
-The initial debug mode.
-Default is false.
-</TD>
-</TR>
-
-<A NAME="mail.from"></A>
-<TR id="mail.from">
-<TD>mail.from</TD>
-<TD>String</TD>
-<TD>
-The return email address of the current user, used by the
-<code>InternetAddress</code> method <code>getLocalAddress</code>.
-</TD>
-</TR>
-
-<A NAME="mail.mime.address.strict"></A>
-<TR id="mail.mime.address.strict">
-<TD>mail.mime.address.strict</TD>
-<TD>boolean</TD>
-<TD>
-The MimeMessage class uses the <code>InternetAddress</code> method
-<code>parseHeader</code> to parse headers in messages. This property
-controls the strict flag passed to the <code>parseHeader</code>
-method. The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.host"></A>
-<TR id="mail.host">
-<TD>mail.host</TD>
-<TD>String</TD>
-<TD>
-The default host name of the mail server for both Stores and Transports.
-Used if the <code>mail.<i>protocol</i>.host</code> property isn't set.
-</TD>
-</TR>
-
-<A NAME="mail.store.protocol"></A>
-<TR id="mail.store.protocol">
-<TD>mail.store.protocol</TD>
-<TD>String</TD>
-<TD>
-Specifies the default message access protocol. The
-<code>Session</code> method <code>getStore()</code> returns a Store
-object that implements this protocol. By default the first Store
-provider in the configuration files is returned.
-</TD>
-</TR>
-
-<A NAME="mail.transport.protocol"></A>
-<TR id="mail.transport.protocol">
-<TD>mail.transport.protocol</TD>
-<TD>String</TD>
-<TD>
-Specifies the default message transport protocol. The
-<code>Session</code> method <code>getTransport()</code> returns a Transport
-object that implements this protocol. By default the first Transport
-provider in the configuration files is returned.
-</TD>
-</TR>
-
-<A NAME="mail.user"></A>
-<TR id="mail.user">
-<TD>mail.user</TD>
-<TD>String</TD>
-<TD>
-The default user name to use when connecting to the mail server.
-Used if the <code>mail.<i>protocol</i>.user</code> property isn't set.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.class"></A>
-<TR id="mail.protocol.class">
-<TD>mail.<i>protocol</i>.class</TD>
-<TD>String</TD>
-<TD>
-Specifies the fully qualified class name of the provider for the
-specified protocol. Used in cases where more than one provider
-for a given protocol exists; this property can be used to specify
-which provider to use by default. The provider must still be listed
-in a configuration file.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.host"></A>
-<TR id="mail.protocol.host">
-<TD>mail.<i>protocol</i>.host</TD>
-<TD>String</TD>
-<TD>
-The host name of the mail server for the specified protocol.
-Overrides the <code>mail.host</code> property.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.port"></A>
-<TR id="mail.protocol.port">
-<TD>mail.<i>protocol</i>.port</TD>
-<TD>int</TD>
-<TD>
-The port number of the mail server for the specified protocol.
-If not specified the protocol's default port number is used.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.user"></A>
-<TR id="mail.protocol.user">
-<TD>mail.<i>protocol</i>.user</TD>
-<TD>String</TD>
-<TD>
-The user name to use when connecting to mail servers
-using the specified protocol.
-Overrides the <code>mail.user</code> property.
-</TD>
-</TR>
-
-</TABLE>
-
-<P>
-The following properties are supported by the reference implementation (RI) of
-JavaMail, but are not currently a required part of the specification.
-The names, types, defaults, and semantics of these properties may
-change in future releases.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.debug.auth"></A>
-<TR id="mail.debug.auth">
-<TD>mail.debug.auth</TD>
-<TD>boolean</TD>
-<TD>
-Include protocol authentication commands (including usernames and passwords)
-in the debug output.
-Default is false.
-</TD>
-</TR>
-
-<A NAME="mail.debug.auth.username"></A>
-<TR id="mail.debug.auth.username">
-<TD>mail.debug.auth.username</TD>
-<TD>boolean</TD>
-<TD>
-Include the user name in non-protocol debug output.
-Default is true.
-</TD>
-</TR>
-
-<A NAME="mail.debug.auth.password"></A>
-<TR id="mail.debug.auth.password">
-<TD>mail.debug.auth.password</TD>
-<TD>boolean</TD>
-<TD>
-Include the password in non-protocol debug output.
-Default is false.
-</TD>
-</TR>
-
-<A NAME="mail.transport.protocol.address-type"></A>
-<TR id="mail.transport.protocol.address-type">
-<TD>mail.transport.protocol.<i>address-type</i></TD>
-<TD>String</TD>
-<TD>
-Specifies the default message transport protocol for the specified address type.
-The <code>Session</code> method <code>getTransport(Address)</code> returns a
-Transport object that implements this protocol when the address is of the
-specified type (e.g., "rfc822" for standard internet addresses).
-By default the first Transport configured for that address type is used.
-This property can be used to override the behavior of the
-{@link javax.mail.Transport#send send} method of the
-{@link javax.mail.Transport Transport} class so that (for example) the "smtps"
-protocol is used instead of the "smtp" protocol by setting the property
-<code>mail.transport.protocol.rfc822</code> to <code>"smtps"</code>.
-</TD>
-</TR>
-
-<A NAME="mail.event.scope"></A>
-<TR id="mail.event.scope">
-<TD>mail.event.scope</TD>
-<TD>String</TD>
-<TD>
-Controls the scope of events. (See the javax.mail.event package.)
-By default, a separate event queue and thread is used for events for each
-Store, Transport, or Folder.
-If this property is set to "session", all such events are put in a single
-event queue processed by a single thread for the current session.
-If this property is set to "application", all such events are put in a single
-event queue processed by a single thread for the current application.
-(Applications are distinguished by their context class loader.)
-</TD>
-</TR>
-
-<A NAME="mail.event.executor"></A>
-<TR id="mail.event.executor">
-<TD>mail.event.executor</TD>
-<TD>java.util.concurrent.Executor</TD>
-<TD>
-By default, a new Thread is created for each event queue.
-This thread is used to call the listeners for these events.
-If this property is set to an instance of an Executor, the
-Executor.execute method is used to run the event dispatcher
-for an event queue. The event dispatcher runs until the
-event queue is no longer in use.
-</TD>
-</TR>
-
-</TABLE>
-
-<P>
-The JavaMail API also supports several System properties;
-see the {@link javax.mail.internet} package documentation
-for details.
-
-<P>
-The JavaMail reference
-implementation includes protocol providers in subpackages of
-<code>com.sun.mail</code>. Note that the APIs to these protocol
-providers are not part of the standard JavaMail API. Portable
-programs will not use these APIs.
-<P>
-Nonportable programs may use the APIs of the protocol providers
-by (for example) casting a returned <code>Folder</code> object to a
-<code>com.sun.mail.imap.IMAPFolder</code> object. Similarly for
-<code>Store</code> and <code>Message</code> objects returned from the
-standard JavaMail APIs.
-<P>
-The protocol providers also support properties that are specific to
-those providers. The package documentation for the
-{@link com.sun.mail.imap IMAP}, {@link com.sun.mail.pop3 POP3},
-and {@link com.sun.mail.smtp SMTP} packages provide details.
-<P>
-In addition to printing debugging output as controlled by the
-{@link javax.mail.Session Session} configuration, the current
-implementation of classes in this package log the same information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>javax.mail</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the Session</TD>
-</TR>
-
-<TR>
-<TD>javax.mail</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-</TABLE>
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/javax/mail/search/AddressStringTerm.java b/current/src/main/java/javax/mail/search/AddressStringTerm.java
index 9b6d00e..13233bd 100644
--- a/current/src/main/java/javax/mail/search/AddressStringTerm.java
+++ b/current/src/main/java/javax/mail/search/AddressStringTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -95,6 +95,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof AddressStringTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/AddressTerm.java b/current/src/main/java/javax/mail/search/AddressTerm.java
index 547a9f8..211fc5c 100644
--- a/current/src/main/java/javax/mail/search/AddressTerm.java
+++ b/current/src/main/java/javax/mail/search/AddressTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -85,6 +85,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof AddressTerm))
return false;
@@ -95,6 +96,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return address.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/AndTerm.java b/current/src/main/java/javax/mail/search/AndTerm.java
index 54b43ec..27a8868 100644
--- a/current/src/main/java/javax/mail/search/AndTerm.java
+++ b/current/src/main/java/javax/mail/search/AndTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -103,6 +103,7 @@
* and the AND operator is applied to their results.
* @return true if the AND succeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
for (int i=0; i < terms.length; i++)
if (!terms[i].match(msg))
@@ -113,6 +114,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof AndTerm))
return false;
@@ -128,6 +130,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
int hash = 0;
for (int i=0; i < terms.length; i++)
diff --git a/current/src/main/java/javax/mail/search/BodyTerm.java b/current/src/main/java/javax/mail/search/BodyTerm.java
index 90dcfb4..3633fac 100644
--- a/current/src/main/java/javax/mail/search/BodyTerm.java
+++ b/current/src/main/java/javax/mail/search/BodyTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -71,6 +71,7 @@
* @param msg The pattern search is applied on this Message's body
* @return true if the pattern is found; otherwise false
*/
+ @Override
public boolean match(Message msg) {
return matchPart(msg);
}
@@ -117,6 +118,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof BodyTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/ComparisonTerm.java b/current/src/main/java/javax/mail/search/ComparisonTerm.java
index f7148e1..7b1cd2e 100644
--- a/current/src/main/java/javax/mail/search/ComparisonTerm.java
+++ b/current/src/main/java/javax/mail/search/ComparisonTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -67,6 +67,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof ComparisonTerm))
return false;
@@ -77,6 +78,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return comparison;
}
diff --git a/current/src/main/java/javax/mail/search/DateTerm.java b/current/src/main/java/javax/mail/search/DateTerm.java
index c5bde30..5da1933 100644
--- a/current/src/main/java/javax/mail/search/DateTerm.java
+++ b/current/src/main/java/javax/mail/search/DateTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -114,6 +114,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof DateTerm))
return false;
@@ -124,6 +125,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return date.hashCode() + super.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/FlagTerm.java b/current/src/main/java/javax/mail/search/FlagTerm.java
index 81f000f..d4bd269 100644
--- a/current/src/main/java/javax/mail/search/FlagTerm.java
+++ b/current/src/main/java/javax/mail/search/FlagTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -104,6 +104,7 @@
* @param msg The flag comparison is applied to this Message
* @return true if the comparson succeeds, otherwise false.
*/
+ @Override
public boolean match(Message msg) {
try {
@@ -149,6 +150,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof FlagTerm))
return false;
@@ -159,6 +161,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return set ? flags.hashCode() : ~flags.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/FromStringTerm.java b/current/src/main/java/javax/mail/search/FromStringTerm.java
index 488687c..07981d8 100644
--- a/current/src/main/java/javax/mail/search/FromStringTerm.java
+++ b/current/src/main/java/javax/mail/search/FromStringTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -75,6 +75,7 @@
* address.
* @return true if the match succeeds, otherwise false.
*/
+ @Override
public boolean match(Message msg) {
Address[] from;
@@ -96,6 +97,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof FromStringTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/FromTerm.java b/current/src/main/java/javax/mail/search/FromTerm.java
index 51ea223..5ae2a35 100644
--- a/current/src/main/java/javax/mail/search/FromTerm.java
+++ b/current/src/main/java/javax/mail/search/FromTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -67,6 +67,7 @@
* @param msg The address comparison is applied to this Message
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Address[] from;
@@ -88,6 +89,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof FromTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/HeaderTerm.java b/current/src/main/java/javax/mail/search/HeaderTerm.java
index f1926cc..2d5f8d1 100644
--- a/current/src/main/java/javax/mail/search/HeaderTerm.java
+++ b/current/src/main/java/javax/mail/search/HeaderTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -86,6 +86,7 @@
* @param msg The match is applied to this Message's header
* @return true if the match succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
String[] headers;
@@ -107,6 +108,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof HeaderTerm))
return false;
@@ -118,6 +120,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
// XXX - depends on header comparisons being case independent
return headerName.toLowerCase(Locale.ENGLISH).hashCode() +
diff --git a/current/src/main/java/javax/mail/search/IntegerComparisonTerm.java b/current/src/main/java/javax/mail/search/IntegerComparisonTerm.java
index fe01841..ce2e8e5 100644
--- a/current/src/main/java/javax/mail/search/IntegerComparisonTerm.java
+++ b/current/src/main/java/javax/mail/search/IntegerComparisonTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -101,6 +101,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof IntegerComparisonTerm))
return false;
@@ -111,6 +112,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return number + super.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/MessageIDTerm.java b/current/src/main/java/javax/mail/search/MessageIDTerm.java
index 587d3da..cee4317 100644
--- a/current/src/main/java/javax/mail/search/MessageIDTerm.java
+++ b/current/src/main/java/javax/mail/search/MessageIDTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -74,6 +74,7 @@
* Message-ID header
* @return true if the match succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
String[] s;
@@ -95,6 +96,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof MessageIDTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/MessageNumberTerm.java b/current/src/main/java/javax/mail/search/MessageNumberTerm.java
index 1c1fe99..576062d 100644
--- a/current/src/main/java/javax/mail/search/MessageNumberTerm.java
+++ b/current/src/main/java/javax/mail/search/MessageNumberTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -67,6 +67,7 @@
* @param msg the Message number is matched with this Message
* @return true if the match succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
int msgno;
@@ -82,6 +83,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof MessageNumberTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/NotTerm.java b/current/src/main/java/javax/mail/search/NotTerm.java
index b04d371..5db52fb 100644
--- a/current/src/main/java/javax/mail/search/NotTerm.java
+++ b/current/src/main/java/javax/mail/search/NotTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -72,6 +72,7 @@
}
/* The NOT operation */
+ @Override
public boolean match(Message msg) {
return !term.match(msg);
}
@@ -79,6 +80,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof NotTerm))
return false;
@@ -89,6 +91,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return term.hashCode() << 1;
}
diff --git a/current/src/main/java/javax/mail/search/OrTerm.java b/current/src/main/java/javax/mail/search/OrTerm.java
index 9d4e0af..a4a46d1 100644
--- a/current/src/main/java/javax/mail/search/OrTerm.java
+++ b/current/src/main/java/javax/mail/search/OrTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -103,6 +103,7 @@
* @return true if the OR succeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
for (int i=0; i < terms.length; i++)
if (terms[i].match(msg))
@@ -113,6 +114,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof OrTerm))
return false;
@@ -128,6 +130,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
int hash = 0;
for (int i=0; i < terms.length; i++)
diff --git a/current/src/main/java/javax/mail/search/ReceivedDateTerm.java b/current/src/main/java/javax/mail/search/ReceivedDateTerm.java
index dea45f1..c676093 100644
--- a/current/src/main/java/javax/mail/search/ReceivedDateTerm.java
+++ b/current/src/main/java/javax/mail/search/ReceivedDateTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -70,6 +70,7 @@
* received date
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Date d;
@@ -88,6 +89,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof ReceivedDateTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/RecipientStringTerm.java b/current/src/main/java/javax/mail/search/RecipientStringTerm.java
index 3e8220f..d464c00 100644
--- a/current/src/main/java/javax/mail/search/RecipientStringTerm.java
+++ b/current/src/main/java/javax/mail/search/RecipientStringTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -93,6 +93,7 @@
* address.
* @return true if the match succeeds, otherwise false.
*/
+ @Override
public boolean match(Message msg) {
Address[] recipients;
@@ -114,6 +115,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof RecipientStringTerm))
return false;
@@ -124,6 +126,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return type.hashCode() + super.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/RecipientTerm.java b/current/src/main/java/javax/mail/search/RecipientTerm.java
index 6cc1f43..de4f598 100644
--- a/current/src/main/java/javax/mail/search/RecipientTerm.java
+++ b/current/src/main/java/javax/mail/search/RecipientTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -87,6 +87,7 @@
* address
* @return true if the match succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Address[] recipients;
@@ -108,6 +109,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof RecipientTerm))
return false;
@@ -118,6 +120,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return type.hashCode() + super.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/SearchException.java b/current/src/main/java/javax/mail/search/SearchException.java
index 79e9707..c678569 100644
--- a/current/src/main/java/javax/mail/search/SearchException.java
+++ b/current/src/main/java/javax/mail/search/SearchException.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/search/SearchTerm.java b/current/src/main/java/javax/mail/search/SearchTerm.java
index f8b4373..e569bd2 100644
--- a/current/src/main/java/javax/mail/search/SearchTerm.java
+++ b/current/src/main/java/javax/mail/search/SearchTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/java/javax/mail/search/SentDateTerm.java b/current/src/main/java/javax/mail/search/SentDateTerm.java
index e298d09..470bdc5 100644
--- a/current/src/main/java/javax/mail/search/SentDateTerm.java
+++ b/current/src/main/java/javax/mail/search/SentDateTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -70,6 +70,7 @@
* sent date
* @return true if the comparison succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
Date d;
@@ -88,6 +89,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof SentDateTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/SizeTerm.java b/current/src/main/java/javax/mail/search/SizeTerm.java
index 9aab46d..c3ae21d 100644
--- a/current/src/main/java/javax/mail/search/SizeTerm.java
+++ b/current/src/main/java/javax/mail/search/SizeTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -68,6 +68,7 @@
* @param msg the size comparator is applied to this Message's size
* @return true if the size is equal, otherwise false
*/
+ @Override
public boolean match(Message msg) {
int size;
@@ -86,6 +87,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof SizeTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/StringTerm.java b/current/src/main/java/javax/mail/search/StringTerm.java
index c489b77..ab2fdf4 100644
--- a/current/src/main/java/javax/mail/search/StringTerm.java
+++ b/current/src/main/java/javax/mail/search/StringTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -118,6 +118,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof StringTerm))
return false;
@@ -133,6 +134,7 @@
/**
* Compute a hashCode for this object.
*/
+ @Override
public int hashCode() {
return ignoreCase ? pattern.hashCode() : ~pattern.hashCode();
}
diff --git a/current/src/main/java/javax/mail/search/SubjectTerm.java b/current/src/main/java/javax/mail/search/SubjectTerm.java
index 238f64c..b2473d4 100644
--- a/current/src/main/java/javax/mail/search/SubjectTerm.java
+++ b/current/src/main/java/javax/mail/search/SubjectTerm.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -71,6 +71,7 @@
* subject header
* @return true if the pattern match succeeds, otherwise false
*/
+ @Override
public boolean match(Message msg) {
String subj;
@@ -89,6 +90,7 @@
/**
* Equality comparison.
*/
+ @Override
public boolean equals(Object obj) {
if (!(obj instanceof SubjectTerm))
return false;
diff --git a/current/src/main/java/javax/mail/search/package.html b/current/src/main/java/javax/mail/search/package.html
deleted file mode 100644
index 960ea28..0000000
--- a/current/src/main/java/javax/mail/search/package.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-Message search terms for the JavaMail API.
-This package defines classes that can be used to construct a search
-expression to search a folder for messages matching the expression;
-see the {@link javax.mail.Folder#search search} method on
-{@link javax.mail.Folder javax.mail.Folder}.
-See {@link javax.mail.search.SearchTerm SearchTerm}.
-<P>
-Note that the exact search capabilities depend on the protocol,
-provider, and server in use. For the POP3 protocol, all searching is
-done on the client side using the JavaMail classes. For IMAP, all
-searching is done on the server side and is limited by the search
-capabilities of the IMAP protocol and the IMAP server being used.
-For example, IMAP date based searches have only day granularity.
-<P>
-In general, all of the string patterns supported by search terms are
-just simple strings; no regular expressions are supported.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/javax/mail/util/ByteArrayDataSource.java b/current/src/main/java/javax/mail/util/ByteArrayDataSource.java
index 0b25fe8..1342540 100644
--- a/current/src/main/java/javax/mail/util/ByteArrayDataSource.java
+++ b/current/src/main/java/javax/mail/util/ByteArrayDataSource.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -151,6 +151,7 @@
* @return the InputStream
* @exception IOException if no data has been set
*/
+ @Override
public InputStream getInputStream() throws IOException {
if (data == null)
throw new IOException("no data");
@@ -166,6 +167,7 @@
*
* @exception IOException always
*/
+ @Override
public OutputStream getOutputStream() throws IOException {
throw new IOException("cannot do this");
}
@@ -175,6 +177,7 @@
*
* @return the MIME type
*/
+ @Override
public String getContentType() {
return type;
}
@@ -185,6 +188,7 @@
*
* @return the name of this data
*/
+ @Override
public String getName() {
return name;
}
diff --git a/current/src/main/java/javax/mail/util/SharedByteArrayInputStream.java b/current/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
index ca0f0a6..f6c056d 100644
--- a/current/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
+++ b/current/src/main/java/javax/mail/util/SharedByteArrayInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -88,6 +88,7 @@
*
* @return the current position
*/
+ @Override
public long getPosition() {
return pos - start;
}
@@ -104,6 +105,7 @@
* @param end the ending position + 1
* @return the new stream
*/
+ @Override
public InputStream newStream(long start, long end) {
if (start < 0)
throw new IllegalArgumentException("start < 0");
diff --git a/current/src/main/java/javax/mail/util/SharedFileInputStream.java b/current/src/main/java/javax/mail/util/SharedFileInputStream.java
index fa75c74..93ecc80 100644
--- a/current/src/main/java/javax/mail/util/SharedFileInputStream.java
+++ b/current/src/main/java/javax/mail/util/SharedFileInputStream.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
@@ -143,6 +143,7 @@
}
}
+ @Override
protected void finalize() throws Throwable {
try {
in.close();
@@ -292,6 +293,7 @@
* stream is reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized int read() throws IOException {
ensureOpen();
if (pos >= count) {
@@ -344,6 +346,7 @@
* the stream has been reached.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized int read(byte b[], int off, int len)
throws IOException
{
@@ -372,6 +375,7 @@
* @return the actual number of bytes skipped.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized long skip(long n) throws IOException {
ensureOpen();
if (n <= 0) {
@@ -406,6 +410,7 @@
* stream without blocking.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public synchronized int available() throws IOException {
ensureOpen();
return (count - pos) + in_available();
@@ -424,6 +429,7 @@
* the mark position becomes invalid.
* @see #reset()
*/
+ @Override
public synchronized void mark(int readlimit) {
marklimit = readlimit;
markpos = pos;
@@ -443,6 +449,7 @@
* if the mark has been invalidated.
* @see #mark(int)
*/
+ @Override
public synchronized void reset() throws IOException {
ensureOpen();
if (markpos < 0)
@@ -461,6 +468,7 @@
* @see java.io.InputStream#mark(int)
* @see java.io.InputStream#reset()
*/
+ @Override
public boolean markSupported() {
return true;
}
@@ -471,6 +479,7 @@
*
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void close() throws IOException {
if (in == null)
return;
@@ -492,6 +501,7 @@
*
* @return the current position
*/
+ @Override
public long getPosition() {
//System.out.println("getPosition: start " + start + " pos " + pos
// + " bufpos " + bufpos + " = " + (bufpos + pos - start));
@@ -512,6 +522,7 @@
* @param end the ending position + 1
* @return the new stream
*/
+ @Override
public synchronized InputStream newStream(long start, long end) {
if (in == null)
throw new RuntimeException("Stream closed");
@@ -544,6 +555,7 @@
/**
* Force this stream to close.
*/
+ @Override
protected void finalize() throws Throwable {
super.finalize();
close();
diff --git a/current/src/main/java/javax/mail/util/package.html b/current/src/main/java/javax/mail/util/package.html
deleted file mode 100644
index 6b51aa1..0000000
--- a/current/src/main/java/javax/mail/util/package.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-JavaMail API utility classes.
-This package specifies utility classes that are useful with
-other JavaMail APIs.
-
-</BODY>
-</HTML>
diff --git a/current/src/main/java/overview.html b/current/src/main/java/overview.html
deleted file mode 100644
index ec6b425..0000000
--- a/current/src/main/java/overview.html
+++ /dev/null
@@ -1,356 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<!--
-
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
-
- Copyright (c) 1997-2015 Oracle and/or its affiliates. All rights reserved.
-
- The contents of this file are subject to the terms of either the GNU
- General Public License Version 2 only ("GPL") or the Common Development
- and Distribution License("CDDL") (collectively, the "License"). You
- may not use this file except in compliance with the License. You can
- obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
- language governing permissions and limitations under the License.
-
- When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
-
- GPL Classpath Exception:
- Oracle designates this particular file as subject to the "Classpath"
- exception as provided by Oracle in the GPL Version 2 section of the License
- file that accompanied this code.
-
- Modifications:
- If applicable, add the following below the License Header, with the fields
- enclosed by brackets [] replaced by your own identifying information:
- "Portions Copyright [year] [name of copyright owner]"
-
- Contributor(s):
- If you wish your version of this file to be governed by only the CDDL or
- only the GPL Version 2, indicate your decision by adding "[Contributor]
- elects to include this software in this distribution under the [CDDL or GPL
- Version 2] license." If you don't indicate a single choice of license, a
- recipient has the option to distribute your version of this file under
- either the CDDL, the GPL Version 2 or to extend the choice of license to
- its licensees as provided above. However, if you add GPL Version 2 code
- and therefore, elected the GPL Version 2 license, then the option applies
- only if the new code is made subject to such option by the copyright
- holder.
-
--->
-
-</HEAD>
-<BODY BGCOLOR="white">
-
-The JavaMail<sup><font size="-2">TM</font></sup> API
-provides classes that model a mail system.
-The <code>javax.mail</code> package defines classes that are common to
-all mail systems.
-The <code>javax.mail.internet</code> package defines classes that are specific
-to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
-The JavaMail API includes the <code>javax.mail</code> package and subpackages.
-<P>
-For an overview of the JavaMail API, read the
-<A HREF="http://javamail.java.net/nonav/docs/JavaMail-1.5.pdf" TARGET="_top">
-JavaMail specification</A>.
-<P>
-The code to send a plain text message can be as simple as the following:
-<PRE>
- Properties props = new Properties();
- props.put("mail.smtp.host", "my-mail-server");
- Session session = Session.getInstance(props, null);
-
- try {
- MimeMessage msg = new MimeMessage(session);
- msg.setFrom("me@example.com");
- msg.setRecipients(Message.RecipientType.TO,
- "you@example.com");
- msg.setSubject("JavaMail hello world example");
- msg.setSentDate(new Date());
- msg.setText("Hello, world!\n");
- Transport.send(msg, "me@example.com", "my-password");
- } catch (MessagingException mex) {
- System.out.println("send failed, exception: " + mex);
- }
-</PRE>
-The JavaMail download bundle contains many more complete examples
-in the "demo" directory.
-<P>
-Don't forget to see the
-<A HREF="http://www.oracle.com/technetwork/java/javamail/faq/" TARGET="_top">
-JavaMail API FAQ</A>
-for answers to the most common questions.
-The <A HREF="http://www.oracle.com/technetwork/java/javamail/" TARGET="_top">
-JavaMail web site</A>
-contains many additional resources.
-<P>
-<A NAME="properties">
-<H4>Properties</H4>
-</A>
-The JavaMail API supports the following standard properties,
-which may be set in the <code>Session</code> object, or in the
-<code>Properties</code> object used to create the <code>Session</code> object.
-The properties are always set as strings; the Type column describes
-how the string is interpreted. For example, use
-<PRE>
- props.put("mail.debug", "true");
-</PRE>
-to set the <code>mail.debug</code> property, which is of type boolean.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.debug"></A>
-<TR id="mail.debug">
-<TD>mail.debug</TD>
-<TD>boolean</TD>
-<TD>
-The initial debug mode.
-Default is false.
-</TD>
-</TR>
-
-<A NAME="mail.from"></A>
-<TR id="mail.from">
-<TD>mail.from</TD>
-<TD>String</TD>
-<TD>
-The return email address of the current user, used by the
-<code>InternetAddress</code> method <code>getLocalAddress</code>.
-</TD>
-</TR>
-
-<A NAME="mail.mime.address.strict"></A>
-<TR id="mail.mime.address.strict">
-<TD>mail.mime.address.strict</TD>
-<TD>boolean</TD>
-<TD>
-The MimeMessage class uses the <code>InternetAddress</code> method
-<code>parseHeader</code> to parse headers in messages. This property
-controls the strict flag passed to the <code>parseHeader</code>
-method. The default is true.
-</TD>
-</TR>
-
-<A NAME="mail.host"></A>
-<TR id="mail.host">
-<TD>mail.host</TD>
-<TD>String</TD>
-<TD>
-The default host name of the mail server for both Stores and Transports.
-Used if the <code>mail.<i>protocol</i>.host</code> property isn't set.
-</TD>
-</TR>
-
-<A NAME="mail.store.protocol"></A>
-<TR id="mail.store.protocol">
-<TD>mail.store.protocol</TD>
-<TD>String</TD>
-<TD>
-Specifies the default message access protocol. The
-<code>Session</code> method <code>getStore()</code> returns a Store
-object that implements this protocol. By default the first Store
-provider in the configuration files is returned.
-</TD>
-</TR>
-
-<A NAME="mail.transport.protocol"></A>
-<TR id="mail.transport.protocol">
-<TD>mail.transport.protocol</TD>
-<TD>String</TD>
-<TD>
-Specifies the default message transport protocol. The
-<code>Session</code> method <code>getTransport()</code> returns a Transport
-object that implements this protocol. By default the first Transport
-provider in the configuration files is returned.
-</TD>
-</TR>
-
-<A NAME="mail.user"></A>
-<TR id="mail.user">
-<TD>mail.user</TD>
-<TD>String</TD>
-<TD>
-The default user name to use when connecting to the mail server.
-Used if the <code>mail.<i>protocol</i>.user</code> property isn't set.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.class"></A>
-<TR id="mail.protocol.class">
-<TD>mail.<i>protocol</i>.class</TD>
-<TD>String</TD>
-<TD>
-Specifies the fully qualified class name of the provider for the
-specified protocol. Used in cases where more than one provider
-for a given protocol exists; this property can be used to specify
-which provider to use by default. The provider must still be listed
-in a configuration file.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.host"></A>
-<TR id="mail.protocol.host">
-<TD>mail.<i>protocol</i>.host</TD>
-<TD>String</TD>
-<TD>
-The host name of the mail server for the specified protocol.
-Overrides the <code>mail.host</code> property.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.port"></A>
-<TR id="mail.protocol.port">
-<TD>mail.<i>protocol</i>.port</TD>
-<TD>int</TD>
-<TD>
-The port number of the mail server for the specified protocol.
-If not specified the protocol's default port number is used.
-</TD>
-</TR>
-
-<A NAME="mail.protocol.user"></A>
-<TR id="mail.protocol.user">
-<TD>mail.<i>protocol</i>.user</TD>
-<TD>String</TD>
-<TD>
-The user name to use when connecting to mail servers
-using the specified protocol.
-Overrides the <code>mail.user</code> property.
-</TD>
-</TR>
-
-</TABLE>
-
-<P>
-The following properties are supported by the reference implementation (RI) of
-JavaMail, but are not currently a required part of the specification.
-The names, types, defaults, and semantics of these properties may
-change in future releases.
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Name</TH>
-<TH>Type</TH>
-<TH>Description</TH>
-</TR>
-
-<A NAME="mail.debug.auth"></A>
-<TR id="mail.debug.auth">
-<TD>mail.debug.auth</TD>
-<TD>boolean</TD>
-<TD>
-Include protocol authentication commands (including usernames and passwords)
-in the debug output.
-Default is false.
-</TD>
-</TR>
-
-<A NAME="mail.transport.protocol.address-type"></A>
-<TR id="mail.transport.protocol.address-type">
-<TD>mail.transport.protocol.<i>address-type</i></TD>
-<TD>String</TD>
-<TD>
-Specifies the default message transport protocol for the specified address type.
-The <code>Session</code> method <code>getTransport(Address)</code> returns a
-Transport object that implements this protocol when the address is of the
-specified type (e.g., "rfc822" for standard internet addresses).
-By default the first Transport configured for that address type is used.
-This property can be used to override the behavior of the
-{@link javax.mail.Transport#send send} method of the
-{@link javax.mail.Transport Transport} class so that (for example) the "smtps"
-protocol is used instead of the "smtp" protocol by setting the property
-<code>mail.transport.protocol.rfc822</code> to <code>"smtps"</code>.
-</TD>
-</TR>
-
-<A NAME="mail.event.scope"></A>
-<TR id="mail.event.scope">
-<TD>mail.event.scope</TD>
-<TD>String</TD>
-<TD>
-Controls the scope of events. (See the javax.mail.event package.)
-By default, a separate event queue and thread is used for events for each
-Store, Transport, or Folder.
-If this property is set to "session", all such events are put in a single
-event queue processed by a single thread for the current session.
-If this property is set to "application", all such events are put in a single
-event queue processed by a single thread for the current application.
-(Applications are distinguished by their context class loader.)
-</TD>
-</TR>
-
-<A NAME="mail.event.executor"></A>
-<TR id="mail.event.executor">
-<TD>mail.event.executor</TD>
-<TD>java.util.concurrent.Executor</TD>
-<TD>
-By default, a new Thread is created for each event queue.
-This thread is used to call the listeners for these events.
-If this property is set to an instance of an Executor, the
-Executor.execute method is used to run the event dispatcher
-for an event queue. The event dispatcher runs until the
-event queue is no longer in use.
-</TD>
-</TR>
-
-</TABLE>
-
-<P>
-The JavaMail API also supports several System properties;
-see the {@link javax.mail.internet} package documentation
-for details.
-
-<P>
-The JavaMail reference
-implementation includes protocol providers in subpackages of
-<code>com.sun.mail</code>. Note that the APIs to these protocol
-providers are not part of the standard JavaMail API. Portable
-programs will not use these APIs.
-<P>
-Nonportable programs may use the APIs of the protocol providers
-by (for example) casting a returned <code>Folder</code> object to a
-<code>com.sun.mail.imap.IMAPFolder</code> object. Similarly for
-<code>Store</code> and <code>Message</code> objects returned from the
-standard JavaMail APIs.
-<P>
-The protocol providers also support properties that are specific to
-those providers. The package documentation for the
-{@link com.sun.mail.imap IMAP}, {@link com.sun.mail.pop3 POP3},
-and {@link com.sun.mail.smtp SMTP} packages provide details.
-<P>
-In addition to printing debugging output as controlled by the
-{@link javax.mail.Session Session} configuration, the current
-implementation of classes in this package log the same information using
-{@link java.util.logging.Logger} as described in the following table:
-<P>
-<TABLE BORDER>
-<TR>
-<TH>Logger Name</TH>
-<TH>Logging Level</TH>
-<TH>Purpose</TH>
-</TR>
-
-<TR>
-<TD>javax.mail</TD>
-<TD>CONFIG</TD>
-<TD>Configuration of the Session</TD>
-</TR>
-
-<TR>
-<TD>javax.mail</TD>
-<TD>FINE</TD>
-<TD>General debugging output</TD>
-</TR>
-</TABLE>
-
-</BODY>
-</HTML>
diff --git a/current/src/main/resources/META-INF/LICENSE.txt b/current/src/main/resources/META-INF/LICENSE.txt
index 4aea537..5ad62c4 100644
--- a/current/src/main/resources/META-INF/LICENSE.txt
+++ b/current/src/main/resources/META-INF/LICENSE.txt
@@ -1,263 +1,759 @@
-COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1
1. Definitions.
- 1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
+ 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.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.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.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.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.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.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.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:
+ 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;
+ 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
+ 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.
+ 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.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.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.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.
+ 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.
+ 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:
+ 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
+ (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).
+ (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.
+ (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.
+ (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:
+ 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
+ (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).
+ (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.
+ (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.
+ (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.1. Availability of Source Code.
- 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.
+ 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.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.2. Modifications.
- 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.
+ 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.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.3. Required Notices.
- 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.
+ 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.1. New Versions.
- 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.
+ Oracle 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.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.
+ 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.
+ 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.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.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.
+ 6.3. If You assert a patent infringement claim against Participant
+ alleging that the Participant Software directly or indirectly
+ infringes any patent where such claim is resolved (such as by
+ license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 6.4. 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.
+ 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 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.
+ 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.
+ 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.
+ 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.
+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.
-The GNU General Public License (GPL) Version 2, June 1991
+ The GNU General Public License (GPL) Version 2, June 1991
-Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+51 Franklin Street, Fifth Floor
+Boston, MA 02110-1335
+USA
-Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
Preamble
-The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public
+License applies to most of the Free Software Foundation's software and
+to any other program whose authors commit to using it. (Some other Free
+Software Foundation software is covered by the GNU Library General
+Public License instead.) You can apply it to your programs, too.
-When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+When we speak of free software, we are referring to freedom, not price.
+Our General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this
+service if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs; and that you know you can do these things.
-To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+To protect your rights, we need to make restrictions that forbid anyone
+to deny you these rights or to ask you to surrender the rights. These
+restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
-For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+For example, if you distribute copies of such a program, whether gratis
+or for a fee, you must give the recipients all the rights that you have.
+You must make sure that they, too, receive or can get the source code.
+And you must show them these terms so they know their rights.
-We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
-Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
-Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+Finally, any free program is threatened constantly by software patents.
+We wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program
+proprietary. To prevent this, we have made it clear that any patent must
+be licensed for everyone's free use or not licensed at all.
-The precise terms and conditions for copying, distribution and modification follow.
-
+The precise terms and conditions for copying, distribution and
+modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+0. This License applies to any program or other work which contains a
+notice placed by the copyright holder saying it may be distributed under
+the terms of this General Public License. The "Program", below, refers
+to any such program or work, and a "work based on the Program" means
+either the Program or any derivative work under copyright law: that is
+to say, a work containing the Program or a portion of it, either
+verbatim or with modifications and/or translated into another language.
+(Hereinafter, translation is included without limitation in the term
+"modification".) Each licensee is addressed as "you".
-Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of running
+the Program is not restricted, and the output from the Program is
+covered only if its contents constitute a work based on the Program
+(independent of having been made by running the Program). Whether that
+is true depends on what the Program does.
-1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously
+and appropriately publish on each copy an appropriate copyright notice
+and disclaimer of warranty; keep intact all the notices that refer to
+this License and to the absence of any warranty; and give any other
+recipients of the Program a copy of this License along with the Program.
-You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
-2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+2. You may modify your copy or copies of the Program or any portion of
+it, thus forming a work based on the Program, and copy and distribute
+such modifications or work under the terms of Section 1 above, provided
+that you also meet all of these conditions:
- a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
- b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any part
+ thereof, to be licensed as a whole at no charge to all third parties
+ under the terms of this License.
- c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a notice
+ that there is no warranty (or else, saying that you provide a
+ warranty) and that users may redistribute the program under these
+ conditions, and telling the user how to view a copy of this License.
+ (Exception: if the Program itself is interactive but does not
+ normally print such an announcement, your work based on the Program
+ is not required to print an announcement.)
-These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program, and
+can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based on
+the Program, the distribution of the whole must be on the terms of this
+License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
-Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
-In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the
+scope of this License.
-3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
- a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections 1
+ and 2 above on a medium customarily used for software interchange; or,
- b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your cost
+ of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
- c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+ c) Accompany it with the information you received as to the offer to
+ distribute corresponding source code. (This alternative is allowed
+ only for noncommercial distribution and only if you received the
+ program in object code or executable form with such an offer, in
+ accord with Subsection b above.)
-The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to control
+compilation and installation of the executable. However, as a special
+exception, the source code distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies the
+executable.
-If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+If distribution of executable or object code is made by offering access
+to copy from a designated place, then offering equivalent access to copy
+the source code from the same place counts as distribution of the source
+code, even though third parties are not compelled to copy the source
+along with the object code.
-4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt otherwise
+to copy, modify, sublicense or distribute the Program is void, and will
+automatically terminate your rights under this License. However, parties
+who have received copies, or rights, from you under this License will
+not have their licenses terminated so long as such parties remain in
+full compliance.
-5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and all
+its terms and conditions for copying, distributing or modifying the
+Program or works based on it.
-6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further restrictions
+on the recipients' exercise of the rights granted herein. You are not
+responsible for enforcing compliance by third parties to this License.
-7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot distribute
+so as to satisfy simultaneously your obligations under this License and
+any other pertinent obligations, then as a consequence you may not
+distribute the Program at all. For example, if a patent license would
+not permit royalty-free redistribution of the Program by all those who
+receive copies directly or indirectly through you, then the only way you
+could satisfy both it and this License would be to refrain entirely from
+distribution of the Program.
-If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
-It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is implemented
+by public license practices. Many people have made generous
+contributions to the wide range of software distributed through that
+system in reliance on consistent application of that system; it is up to
+the author/donor to decide if he or she is willing to distribute
+software through any other system and a licensee cannot impose that choice.
-This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+This section is intended to make thoroughly clear what is believed to be
+a consequence of the rest of this License.
-8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License may
+add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among countries
+not thus excluded. In such case, this License incorporates the
+limitation as if written in the body of this License.
-9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+9. The Free Software Foundation may publish revised and/or new
+versions of the General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
-Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Program does not specify a version
+number of this License, you may choose any version ever published by the
+Free Software Foundation.
-10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the
+author to ask for permission. For software which is copyrighted by the
+Free Software Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be guided by the
+two goals of preserving the free status of all derivatives of our free
+software and of promoting the sharing and reuse of software generally.
NO WARRANTY
-11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND,
+EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH
+YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
-12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM
+(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
+INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
+THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR
+OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
-
How to Apply These Terms to Your New Programs
-If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
-To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
+To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey
+the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
- One line to give the program's name and a brief idea of what it does.
+ One line to give the program's name and a brief idea of what it does.
+ Copyright (C) <year> <name of author>
- Copyright (C)
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
Also add information on how to contact you by electronic and paper mail.
-If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type
+ `show w'. This is free software, and you are welcome to redistribute
+ it under certain conditions; type `show c' for details.
-The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
+The hypothetical commands `show w' and `show c' should show the
+appropriate parts of the General Public License. Of course, the commands
+you use may be called something other than `show w' and `show c'; they
+could even be mouse-clicks or menu items--whatever suits your program.
-You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program `Gnomovision' (which makes passes at compilers) written by
+ James Hacker.
- signature of Ty Coon, 1 April 1989
- Ty Coon, President of Vice
+ signature of Ty Coon, 1 April 1989
+ Ty Coon, President of Vice
-This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
+This General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications
+with the library. If this is what you want to do, use the GNU Library
+General Public License instead of this License.
+#
-"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+Certain source files distributed by Oracle America, Inc. and/or its
+affiliates are subject to the following clarification and special
+exception to the GPLv2, based on the GNU Project exception for its
+Classpath libraries, known as the GNU Classpath Exception, but only
+where Oracle has expressly included in the particular source file's
+header the words "Oracle designates this particular file as subject to
+the "Classpath" exception as provided by Oracle in the LICENSE file
+that accompanied this code."
-Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
+You should also note that Oracle includes multiple, independent
+programs in this software package. Some of those programs are provided
+under licenses deemed incompatible with the GPLv2 by the Free Software
+Foundation and others. For example, the package includes programs
+licensed under the Apache License, Version 2.0. Such programs are
+licensed to you under their original licenses.
-"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
+Oracle facilitates your further distribution of this package by adding
+the Classpath Exception to the necessary parts of its GPLv2 code, which
+permits you to use that code in combination with other independent
+modules not licensed under the GPLv2. However, note that this would
+not permit you to commingle code under an incompatible license with
+Oracle's GPLv2 licensed code by, for example, cutting and pasting such
+code into a file also containing Oracle's GPLv2 licensed code and then
+distributing the result. Additionally, if you were to remove the
+Classpath Exception from any of the files to which it applies and
+distribute the result, you would likely be required to license some or
+all of the other code in that distribution under the GPLv2 as well, and
+since the GPLv2 is incompatible with the license terms of some items
+included in the distribution by Oracle, removing the Classpath
+Exception could therefore effectively compromise your ability to
+further distribute the package.
-Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
+Proceed with caution and we recommend that you obtain the advice of a
+lawyer skilled in open source matters before removing the Classpath
+Exception or making modifications to this package which may
+subsequently be redistributed and/or involve the use of third party
+software.
-As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
+CLASSPATH EXCEPTION
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License version 2 cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from or
+based on this library. If you modify this library, you may extend this
+exception to your version of the library, but you are not obligated to
+do so. If you do not wish to do so, delete this exception statement
+from your version.
diff --git a/current/src/main/resources/META-INF/gfprobe-provider.xml b/current/src/main/resources/META-INF/gfprobe-provider.xml
index b304521..ba14209 100644
--- a/current/src/main/resources/META-INF/gfprobe-provider.xml
+++ b/current/src/main/resources/META-INF/gfprobe-provider.xml
@@ -3,19 +3,19 @@
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
- https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- or packager/legal/LICENSE.txt. See the License for the specific
+ https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ or LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
- file and include the License file at packager/legal/LICENSE.txt.
+ file and include the License file at LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
diff --git a/current/src/main/resources/META-INF/javamail.charset.map b/current/src/main/resources/META-INF/javamail.charset.map
index fcc692e..cc58d4f 100644
--- a/current/src/main/resources/META-INF/javamail.charset.map
+++ b/current/src/main/resources/META-INF/javamail.charset.map
@@ -65,3 +65,13 @@
# in JDK 1.1.6 we will no longer need the "us-ascii" convert
us-ascii ISO-8859-1
x-us-ascii ISO-8859-1
+
+# Chinese charsets are a mess and widely misrepresented.
+# gb18030 is a superset of gbk, which is a supserset of cp936/ms936,
+# which is a superset of gb2312.
+# https://bugzilla.gnome.org/show_bug.cgi?id=446783
+# map all of these to gb18030.
+gb2312 GB18030
+cp936 GB18030
+ms936 GB18030
+gbk GB18030
diff --git a/current/src/main/resources/META-INF/services/javax.mail.Provider b/current/src/main/resources/META-INF/services/javax.mail.Provider
new file mode 100644
index 0000000..4688e5a
--- /dev/null
+++ b/current/src/main/resources/META-INF/services/javax.mail.Provider
@@ -0,0 +1,6 @@
+com.sun.mail.imap.IMAPProvider
+com.sun.mail.imap.IMAPSSLProvider
+com.sun.mail.smtp.SMTPProvider
+com.sun.mail.smtp.SMTPSSLProvider
+com.sun.mail.pop3.POP3Provider
+com.sun.mail.pop3.POP3SSLProvider
diff --git a/current/src/main/resources/javax/mail/Version.java b/current/src/main/resources/javax/mail/Version.java
index 8ac7099..7dc5b11 100644
--- a/current/src/main/resources/javax/mail/Version.java
+++ b/current/src/main/resources/javax/mail/Version.java
@@ -1,19 +1,19 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
- * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
- * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
- * or packager/legal/LICENSE.txt. See the License for the specific
+ * https://oss.oracle.com/licenses/CDDL+GPL-1.1
+ * or LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
- * file and include the License file at packager/legal/LICENSE.txt.
+ * file and include the License file at LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"