Dataset Viewer
cve
large_string | desc
large_string | repo
large_string | commit_id
large_string | commit_message
large_string | diff
large_string | label
int64 | rank
uint32 |
|---|---|---|---|---|---|---|---|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
4927240d1f8fca0806df1e48e5b09ef067bd3930
|
automatic post-release commit for mutt-2.2.7
|
commit 4927240d1f8fca0806df1e48e5b09ef067bd3930
Author: Kevin McCarthy <[email protected]>
Date: Sun Aug 7 10:20:17 2022 -0700
automatic post-release commit for mutt-2.2.7
diff --git a/ChangeLog b/ChangeLog
index 9a356c55..1665b5c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,151 @@
+2022-08-07 10:15:32 -0700 Kevin McCarthy <[email protected]> (7b41537e)
+
+ * Update UPDATING file for 2.2.7 release.
+
+M UPDATING
+
+2022-08-02 20:51:17 -0700 Kevin McCarthy <[email protected]> (40228035)
+
+ * Fix mutt_read_rfc822_line() to use is_email_wsp().
+
+ ISSPACE() uses isspace() which is locale-dependent. On some
+ platforms, unexpected 8-bit chars, such as 0xa0 or 0x85 return true.
+
+ When using $edit_headers, this can result in Subject: lines being
+ truncated if a multi-byte character ending in one of these values is
+ at the end of a line.
+
+ There are probably other bugs that could be triggered by this, such as
+ in IMAP parsing. However, I need more time to investigate before
+ making large-scale changes that could introduce new bugs.
+
+M parse.c
+
+2022-08-04 10:25:26 +0200 Matthias Andree <[email protected]> (4d2b33ba)
+
+ * Drop X509 *cert from sslsockdata, unused.
+
+ Signed-off-by: Matthias Andree <[email protected]>
+ (cherry picked from commit 0d03501ac9ddd1a4a62a7274651d64da0c4c3865)
+
+M mutt_ssl.c
+
+2022-07-29 19:52:45 -0700 Kevin McCarthy <[email protected]> (a1a08067)
+
+ * Change mutt_display_message() $pager to use %s if present.
+
+ Other places in the code all use mutt_do_pager(), which uses
+ mutt_expand_file_fmt().
+
+ The use of %s was not documented (and likely not used since it's
+ broken when displaying messages), so add documentation to the $pager
+ option.
+
+M commands.c
+M init.h
+
+2022-07-29 10:40:33 -0700 Kevin McCarthy <[email protected]> (4f672027)
+
+ * Overide SSL_CTX min/max protocol versions.
+
+ Newer versions of OpenSSL disable old (insecure) protocols by default.
+ Reset the allowed versions, so that Mutt's configuration variables
+ enabling old protocols actually work if needed.
+
+ Thanks to Matthias Andree for the patch, which this commit is based
+ upon.
+
+M mutt_ssl.c
+
+2022-03-04 15:26:56 -0800 Kevin McCarthy <[email protected]> (b022931d)
+
+ * Tighten $query_command parsing to allow empty name field.
+
+ The documentation writes the output should be "each line containing a
+ tab separated address then name then some other optional information".
+ The wiki page at
+ <https://gitlab.com/muttmua/mutt/-/wikis/MuttGuide/Aliases> also
+ implies a single tab between each field.
+
+ Since the function used strtok, consecutive tab delimeters were
+ treated as a single delimiter. This caused a missing name field to
+ use the comment field as the name.
+
+ Change the function to use strchr instead. This is not without risk,
+ as the functionality is old. Who knows what all programs have been
+ written that might assume initial, or multiple delimiters are
+ acceptable...
+
+ Thanks to Magnus Groß for reporting the problem along with a patch,
+ which this commit is derived from.
+
+M query.c
+
+2022-07-10 14:58:40 +0200 Matthias Andree <[email protected]> (135fb67e)
+
+ * version.sh: fix robustness on git failure
+
+ for instance, with untrusted directory under sudo.
+
+ Signed-off-by: Matthias Andree <[email protected]>
+
+M version.sh
+
+2022-07-17 22:20:12 +0200 Matthias Andree <[email protected]> (607efef7)
+
+ * de.po: Fix German certificate dialog translation.
+
+ Remove the full-stop to ensure reader will continue reading rather
+ than mistake this as a conclusion.
+
+ Also, from: to: here translate to von: bis: (not an: which would be
+ spatial not temporal).
+
+ Finally, fix a mistranslation where SHA256 was translated as SHA1
+
+ Reviewed by: Helge Kreutzmann <[email protected]>
+ Signed-off-by: Matthias Andree <[email protected]>
+
+M po/de.po
+
+2022-07-06 14:39:42 -0700 Kevin McCarthy <[email protected]> (0614c38c)
+
+ * Comment out undesirable default settings in smime.rc.
+
+ Some distributions, such as Debian, use the contrib/smime.rc as a
+ default system configuration file (under /etc/Muttrc.d). However
+ settings such as $smime_is_default and $crypt_autosign should not be
+ enabled by default for everyone.
+
+ Debian previously maintained a patch against the file, commenting out
+ those settings, but the patch somehow got dropped and is causing
+ confusion for Debian users.
+
+ Since the settings aren't necessarily desirable for anyone who wants
+ to use S/MIME, comment them out in the contrib file.
+
+M contrib/smime.rc
+
+2022-06-09 09:22:03 -0700 Kevin McCarthy <[email protected]> (97f8eee2)
+
+ * Decrypt S/MIME when mime-forwarding with $forward_decrypt set.
+
+ The code was performing a decode for S/MIME, but this had the effect
+ of running attachments through the autoview routines.
+
+ Change so it only performs a decrypt. This is also how copying is
+ handled in set_copy_flags(), so I believe the decode was just a
+ mistake.
+
+M sendlib.c
+
+2022-06-05 11:20:00 -0700 Kevin McCarthy <[email protected]> (d1ee1314)
+
+ * automatic post-release commit for mutt-2.2.6
+
+M ChangeLog
+M VERSION
+
2022-06-05 11:13:47 -0700 Kevin McCarthy <[email protected]> (42c9d1ea)
* Update UPDATING file for 2.2.6 release.
diff --git a/VERSION b/VERSION
index bda8fbec..5bc1cc43 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.6
+2.2.7
| 0
| 7
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
848834424235c850947c164ff782d4b8292e084d
|
Fix next_token() oob read. (closes #3787)
With specially crafted input to 'mutt -H', the line "Return-Path:<() "
is read and passed to mutt_parse_rfc822_line(). "<() " is then passed
through to rfc822_parse_adrlist().
Eventually, inside next_token(), is_special(*s) is called when s
points to the end of the string ('\0'). This macro calls strchr,
which will actually match and return a pointer to the trailing '\0' in
RFC822Specials! This causes "s + 1" to be returned, skipping past the
end of string inside parse_mailboxdomain().
This patch adds a check to make sure *s is non-null before calling
is_special(*s).
|
commit 848834424235c850947c164ff782d4b8292e084d
Author: Kevin McCarthy <[email protected]>
Date: Sun Oct 18 19:45:51 2015 +0800
Fix next_token() oob read. (closes #3787)
With specially crafted input to 'mutt -H', the line "Return-Path:<() "
is read and passed to mutt_parse_rfc822_line(). "<() " is then passed
through to rfc822_parse_adrlist().
Eventually, inside next_token(), is_special(*s) is called when s
points to the end of the string ('\0'). This macro calls strchr,
which will actually match and return a pointer to the trailing '\0' in
RFC822Specials! This causes "s + 1" to be returned, skipping past the
end of string inside parse_mailboxdomain().
This patch adds a check to make sure *s is non-null before calling
is_special(*s).
diff --git a/rfc822.c b/rfc822.c
index 884c00b1..80347824 100644
--- a/rfc822.c
+++ b/rfc822.c
@@ -202,7 +202,7 @@ next_token (const char *s, char *token, size_t *tokenlen, size_t tokenmax)
return (parse_comment (s + 1, token, tokenlen, tokenmax));
if (*s == '"')
return (parse_quote (s + 1, token, tokenlen, tokenmax));
- if (is_special (*s))
+ if (*s && is_special (*s))
{
if (*tokenlen < tokenmax)
token[(*tokenlen)++] = *s;
| 0
| 6
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
85a0ec8505d8cf9ab29765a07fc721f6018f59ea
|
Fix pgp_application_pgp_handler to remove all tempfiles.
If multiple PGP blocks are present in an email, Mutt only cleans up the
tempfiles for the last block. Thanks to Dennis Preiser for the patch
and sample mbox file demonstrating the problem.
This patch also fixes the argument to mutt_perror for the pgpout
tempfile.
|
commit 85a0ec8505d8cf9ab29765a07fc721f6018f59ea
Author: Kevin McCarthy <[email protected]>
Date: Wed Mar 4 19:24:31 2015 -0800
Fix pgp_application_pgp_handler to remove all tempfiles.
If multiple PGP blocks are present in an email, Mutt only cleans up the
tempfiles for the last block. Thanks to Dennis Preiser for the patch
and sample mbox file demonstrating the problem.
This patch also fixes the argument to mutt_perror for the pgpout
tempfile.
diff --git a/pgp.c b/pgp.c
index ee9751f0..65507771 100644
--- a/pgp.c
+++ b/pgp.c
@@ -373,7 +373,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
mutt_mktemp (outfile, sizeof (outfile));
if ((pgpout = safe_fopen (outfile, "w+")) == NULL)
{
- mutt_perror (tmpfname);
+ mutt_perror (outfile);
return -1;
}
@@ -485,6 +485,18 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
fgetconv_close (&fc);
}
+ /*
+ * Multiple PGP blocks can exist, so these need to be closed and
+ * unlinked inside the loop.
+ */
+ safe_fclose (&tmpfp);
+ mutt_unlink (tmpfname);
+ if (pgpout)
+ {
+ safe_fclose (&pgpout);
+ mutt_unlink (outfile);
+ }
+
if (s->flags & M_DISPLAY)
{
state_putc ('\n', s);
| 0
| 2
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
4fc97a2026f671a35e3d296bbfdeb3794d6313c7
|
Display error if no imap authenticators are available.
Without SASL enabled, and with an explicit value in
$imap_authenticators not natively implemented by Mutt, no calls to
authenticator->authenticate() were occuring.
This resulted in the default r value of -1 passing through, which did
not trigger the mutt_error() message after the loop.
Without that message, an empty index would display with the
"connecting" message still on the bottom, giving the appearance that
Mutt is hung.
|
commit 4fc97a2026f671a35e3d296bbfdeb3794d6313c7
Author: Kevin McCarthy <[email protected]>
Date: Wed Apr 8 09:20:54 2020 -0700
Display error if no imap authenticators are available.
Without SASL enabled, and with an explicit value in
$imap_authenticators not natively implemented by Mutt, no calls to
authenticator->authenticate() were occuring.
This resulted in the default r value of -1 passing through, which did
not trigger the mutt_error() message after the loop.
Without that message, an empty index would display with the
"connecting" message still on the bottom, giving the appearance that
Mutt is hung.
diff --git a/imap/auth.c b/imap/auth.c
index e32b5ab4..48909cd8 100644
--- a/imap/auth.c
+++ b/imap/auth.c
@@ -55,7 +55,7 @@ int imap_authenticate (IMAP_DATA* idata)
char* methods;
char* method;
char* delim;
- int r = -1;
+ int r = IMAP_AUTH_UNAVAIL;
if (ImapAuthenticators)
{
| 0
| 5
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
c160ca1d74915f7b6a2fa18a5f4bdfc1663b7c88
|
Reset invalid parsed received dates to 0. (closes #3878)
The actual problem in the ticket would be solved by d3f31cf9239e (see
#3798). However there is still the bug that Mutt considers a
(hdr->received != 0) to be set and usable, despite not checking the
return value of mutt_parse_date().
Change mutt_read_rfc822_header() to unset an invalid received value
back to 0. We don't do this inside mutt_read_rfc822_line() because
that would cause the next received line to be parsed.
|
commit c160ca1d74915f7b6a2fa18a5f4bdfc1663b7c88
Author: Kevin McCarthy <[email protected]>
Date: Sun Sep 25 13:11:03 2016 -0700
Reset invalid parsed received dates to 0. (closes #3878)
The actual problem in the ticket would be solved by d3f31cf9239e (see
#3798). However there is still the bug that Mutt considers a
(hdr->received != 0) to be set and usable, despite not checking the
return value of mutt_parse_date().
Change mutt_read_rfc822_header() to unset an invalid received value
back to 0. We don't do this inside mutt_read_rfc822_line() because
that would cause the next received line to be parsed.
diff --git a/parse.c b/parse.c
index 92cfeb0f..0ae55940 100644
--- a/parse.c
+++ b/parse.c
@@ -1455,6 +1455,12 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
e->real_subj = e->subject;
}
+ if (hdr->received < 0)
+ {
+ dprint(1,(debugfile,"read_rfc822_header(): resetting invalid received time to 0\n"));
+ hdr->received = 0;
+ }
+
/* check for missing or invalid date */
if (hdr->date_sent <= 0)
{
| 0
| 1
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
3d8baab528e370cabb12baf9102d668cead809a7
|
I've attached a patch for bug number 1036, as reported at
http://bugs.guug.de/db/pa/lmutt.html ("segfault when more than one
msg is postponed"). This is a patch against mutt 1.4.1.
As it was previously left, no one could reproduce it. The problem
occurs because sorting is disabled when opening the postponed
folder, but the Sort global variable still tells mutt to use
whatever sorting algorithm the $sort config option indicates.
Eventually, the code would get to mutt_messages_in_thread and try to
dereference a NULL thread object, causing the segfault.
|
commit 3d8baab528e370cabb12baf9102d668cead809a7
Author: Dan Fandrich <[email protected]>
Date: Wed Sep 3 17:22:09 2003 +0000
I've attached a patch for bug number 1036, as reported at
http://bugs.guug.de/db/pa/lmutt.html ("segfault when more than one
msg is postponed"). This is a patch against mutt 1.4.1.
As it was previously left, no one could reproduce it. The problem
occurs because sorting is disabled when opening the postponed
folder, but the Sort global variable still tells mutt to use
whatever sorting algorithm the $sort config option indicates.
Eventually, the code would get to mutt_messages_in_thread and try to
dereference a NULL thread object, causing the segfault.
diff --git a/postpone.c b/postpone.c
index 53a42300..ac611079 100644
--- a/postpone.c
+++ b/postpone.c
@@ -23,6 +23,7 @@
#include "mime.h"
#include "mailbox.h"
#include "mapping.h"
+#include "sort.h"
#ifdef USE_IMAP
#include "mx.h"
#include "imap.h"
@@ -153,6 +154,7 @@ static HEADER *select_msg (void)
MUTTMENU *menu;
int i, done=0, r=-1;
char helpstr[SHORT_STRING];
+ short orig_sort;
menu = mutt_new_menu ();
menu->make_entry = post_entry;
@@ -162,6 +164,12 @@ static HEADER *select_msg (void)
menu->data = PostContext;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_POST, PostponeHelp);
+ /* The postponed mailbox is setup to have sorting disabled, but the global
+ * Sort variable may indicate something different. Sorting has to be
+ * disabled while the postpone menu is being displayed. */
+ orig_sort = Sort;
+ Sort = SORT_ORDER;
+
while (!done)
{
switch (i = mutt_menuLoop (menu))
@@ -197,6 +205,7 @@ static HEADER *select_msg (void)
}
}
+ Sort = orig_sort;
mutt_menuDestroy (&menu);
return (r > -1 ? PostContext->hdrs[r] : NULL);
}
| 0
| 8
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
356ef5a5f9a508c8f935eb0839b1cc574672057d
|
Pause for a moment when a hostname fails to resolve. Closes #1942.
There are a number of cases where mutt cascades error messages. It might
be nice if there were an error stack so that low level functions could
push_error instead of displaying it right away, and the higher level ones
could eg mutt_message(_("Failed to write FCC: %s"), pop_error ())...
|
commit 356ef5a5f9a508c8f935eb0839b1cc574672057d
Author: Brendan Cully <[email protected]>
Date: Mon Aug 8 18:59:43 2005 +0000
Pause for a moment when a hostname fails to resolve. Closes #1942.
There are a number of cases where mutt cascades error messages. It might
be nice if there were an error stack so that low level functions could
push_error instead of displaying it right away, and the higher level ones
could eg mutt_message(_("Failed to write FCC: %s"), pop_error ())...
diff --git a/mutt_socket.c b/mutt_socket.c
index 8d9f8391..bc859f5d 100644
--- a/mutt_socket.c
+++ b/mutt_socket.c
@@ -440,6 +440,7 @@ int raw_socket_open (CONNECTION* conn)
if (rc)
{
mutt_error (_("Could not find the host \"%s\""), conn->account.host);
+ mutt_sleep (2);
return -1;
}
| 0
| 3
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
50e6f343e055dd32be1e3080de4bc9a7e560e685
|
Manual: Add a short chapter summarizing security considerations
|
commit 50e6f343e055dd32be1e3080de4bc9a7e560e685
Author: Rocco Rutte <[email protected]>
Date: Sat Apr 4 14:28:58 2009 +0200
Manual: Add a short chapter summarizing security considerations
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 65d01765..eb568769 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -31,7 +31,7 @@ EXTRA_DIST = dotlock.man \
HTML_DOCFILES = manual.html index.html intro.html gettingstarted.html \
configuration.html mimesupport.html advancedusage.html \
- optionalfeatures.html tuning.html reference.html miscellany.html
+ optionalfeatures.html security.html tuning.html reference.html miscellany.html
BUILT_DISTFILES = stamp-doc-xml stamp-doc-chunked manual.txt $(HTML_DOCFILES)
diff --git a/doc/manual.xml.head b/doc/manual.xml.head
index 61f2e8c2..6b4f12d5 100644
--- a/doc/manual.xml.head
+++ b/doc/manual.xml.head
@@ -7191,6 +7191,178 @@ for the latter syntax. <literal>EXACT_ADDRESS</literal> in the output of
</chapter>
+<chapter id="security">
+<title>Security Considerations</title>
+
+<para>
+First of all, Mutt contains no security holes included by intention but
+may contain unknown security holes. As a consequence, please run Mutt
+only with as few permissions as possible. Especially, do not run Mutt as
+the super user.
+</para>
+
+<para>
+When configuring Mutt, there're some points to note about secure setups
+so please read this chapter carefully.
+</para>
+
+<sect1 id="security-passwords">
+<title>Passwords</title>
+
+<para>
+Although Mutt can be told the various passwords for accounts, please
+never store passwords in configuration files. Besides the fact that the
+system's operator can always read them, you could forget to mask it out
+when reporting a bug or asking for help via a mailing list. Even worse,
+your mail including your password could be archived by internet search
+engines, mail-to-news gateways etc. It may already too late before you
+notice your mistake.
+</para>
+
+</sect1>
+
+<sect1 id="security-tempfiles">
+<title>Temporary Files</title>
+
+<para>
+Mutt uses many temporary files for viewing messages, verifying digital
+signatures, etc. As long as being used, these files are visible by other
+users and maybe even readable in case of misconfiguration. Also, a
+different location for these files may be desired which can be changed
+via the <link linkend="tmpdir">$tmpdir</link> variable.
+</para>
+
+</sect1>
+
+<sect1 id="security-leaks">
+<title>Information Leaks</title>
+
+<sect2 id="security-leaks-mid">
+<title>Message-ID: headers</title>
+
+<para>
+Message-Id: headers contain a local part that is to be created in a
+unique fashion. In order to do so, Mutt will <quote>leak</quote> some
+information to the outside world when sending messages: the generation
+of this header includes a step counter which is increased (and rotated)
+with every message sent. In a longer running mutt session, others can
+make assumptions about your mailing habbits depending on the number of
+messages sent. If this is not desired, the header can be manually
+provided using <link
+linkend="edit-headers">$edit_headers</link> (though not
+recommended).
+</para>
+
+</sect2>
+
+<sect2 id="security-leaks-mailto">
+<title><literal>mailto:</literal>-style links</title>
+
+<para>
+As Mutt be can be set up to be the mail client to handle
+<literal>mailto:</literal> style links in websites, there're security
+considerations, too. Arbitrary header fields can be embedded in these
+links which could override existing header fields or attach arbitrary
+files using <link linkend="attach-header">the Attach:
+psuedoheader</link>. This may be problematic if the <link
+linkend="edit-headers">$edit-headers</link> variable is
+<emphasis>unset</emphasis>, i.e. the user doesn't want to see header
+fields while editing the message and doesn't pay enough attention to the
+compose menu's listing of attachments.
+</para>
+
+<para>
+For example, following a link like
+</para>
+
+<screen>
+mailto:joe@host?Attach=~/.gnupg/secring.gpg</screen>
+
+<para>
+will send out the user's private gnupg keyring to
+<literal>joe@host</literal> if the user doesn't follow the information
+on screen carefully enough.
+</para>
+
+</sect2>
+
+</sect1>
+
+<sect1 id="security-external">
+<title>External applications</title>
+
+<para>
+Mutt in many places has to rely on external applications or for
+convenience supports mechanisms involving external applications.
+</para>
+
+<sect2 id="security-external-mailcap">
+<title>mailcap</title>
+
+<para>
+One of these is the <literal>mailcap</literal> mechanism as defined by
+RfC1524. Mutt can be set up to <emphasis>automatically</emphasis>
+execute any given utility as listed in one of the mailcap files (see the
+<link linkend="mailcap-path">$mailcap_path</link> variable
+for details.)
+</para>
+
+<para>
+These utilities may have a variety of security vulnerabilities,
+including overwriting of arbitrary files, information leaks or other
+exploitable bugs. These vulnerabilities may go unnoticed by the user,
+especially when they are called automatically (and without interactive
+prompting) from the mailcap file(s). When using Mutt's autoview
+mechanism in combination with mailcap files, please be sure to...
+</para>
+
+<itemizedlist>
+<listitem>
+<para>
+manually select trustworth applications with a reasonable calling
+sequence
+</para>
+</listitem>
+<listitem>
+<para>
+periodically check the contents of mailcap files, especially after
+software installations or upgrades
+</para>
+</listitem>
+<listitem>
+<para>
+keep the software packages referenced in the mailcap file up to date
+</para>
+</listitem>
+<listitem>
+<para>
+leave the <link linkend="mailcap-sanitize">$mailcap-sanitize</link>
+variable with its default value to restrict mailcap expandos to a safe set of
+characters
+</para>
+</listitem>
+</itemizedlist>
+
+</sect2>
+
+<sect2 id="security-external-other">
+<title>Other</title>
+
+<para>
+Besides the mailcap mechanism, Mutt uses a number of other external
+utilities for operation, for example to provide crypto support, in
+backtick expansion in configuration files or format string filters. The
+same security considerations apply for these as for tools involved via
+mailcap.
+</para>
+
+</sect2>
+
+</sect1>
+
+</chapter>
+
+
<chapter id="tuning">
<title>Performance tuning</title>
| 0
| 10
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
829db35b1a61f9642e9c9857ecd0d0a9bfde6029
|
Use fgets_unlocked and fgetc_unlocked if available.
Since mutt does not use threads, there is no reason it should use the
locked variants of the FILE* IO functions. This checks if the unlocked
functions are available, and if so enables them globally via mutt.h.
Cuts load time for a 56k message, 1.8GB /var/mail mailbox from 14
seconds to ~6 seconds, since we avoid acquiring and releasing a mutex
for every character of input read.
Before: 0m14.376s
74.98% mutt libc-2.18.so [.] _IO_getc
11.87% mutt mutt [.] mbox_parse_mailbox
0.94% mutt [kernel.kallsyms] [k] copy_user_generic_string
0.83% mutt libc-2.18.so [.] __strchr_sse2
0.53% mutt libc-2.18.so [.] __memcpy_sse2
0.44% mutt libc-2.18.so [.] _int_malloc
After: 6 seconds
68.92% mutt mutt [.] mbox_parse_mailbox
2.25% mutt [kernel.kallsyms] [k] copy_user_generic_string
1.73% mutt libc-2.18.so [.] __strchr_sse2
1.24% mutt libc-2.18.so [.] __memcpy_sse2
1.17% mutt libc-2.18.so [.] _int_malloc
0.87% mutt libc-2.18.so [.] __strspn_sse42
|
commit 829db35b1a61f9642e9c9857ecd0d0a9bfde6029
Author: David Wilson <[email protected]>
Date: Wed Nov 8 13:40:34 2017 -0800
Use fgets_unlocked and fgetc_unlocked if available.
Since mutt does not use threads, there is no reason it should use the
locked variants of the FILE* IO functions. This checks if the unlocked
functions are available, and if so enables them globally via mutt.h.
Cuts load time for a 56k message, 1.8GB /var/mail mailbox from 14
seconds to ~6 seconds, since we avoid acquiring and releasing a mutex
for every character of input read.
Before: 0m14.376s
74.98% mutt libc-2.18.so [.] _IO_getc
11.87% mutt mutt [.] mbox_parse_mailbox
0.94% mutt [kernel.kallsyms] [k] copy_user_generic_string
0.83% mutt libc-2.18.so [.] __strchr_sse2
0.53% mutt libc-2.18.so [.] __memcpy_sse2
0.44% mutt libc-2.18.so [.] _int_malloc
After: 6 seconds
68.92% mutt mutt [.] mbox_parse_mailbox
2.25% mutt [kernel.kallsyms] [k] copy_user_generic_string
1.73% mutt libc-2.18.so [.] __strchr_sse2
1.24% mutt libc-2.18.so [.] __memcpy_sse2
1.17% mutt libc-2.18.so [.] _int_malloc
0.87% mutt libc-2.18.so [.] __strspn_sse42
diff --git a/configure.ac b/configure.ac
index a9c32068..8618ddc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -333,6 +333,7 @@ AC_CHECK_HEADERS(sys/time.h sys/resource.h)
AC_CHECK_HEADERS(unix.h)
AC_CHECK_FUNCS(setrlimit getsid)
+AC_CHECK_FUNCS(fgets_unlocked fgetc_unlocked)
AC_MSG_CHECKING(for sig_atomic_t in signal.h)
AC_EGREP_HEADER(sig_atomic_t,signal.h,
diff --git a/mutt.h b/mutt.h
index 54a807fa..9d318302 100644
--- a/mutt.h
+++ b/mutt.h
@@ -71,6 +71,14 @@
# define MB_LEN_MAX 16
#endif
+#ifdef HAVE_FGETS_UNLOCKED
+# define fgets fgets_unlocked
+#endif
+
+#ifdef HAVE_FGETC_UNLOCKED
+# define fgetc fgetc_unlocked
+#endif
+
/* nifty trick I stole from ELM 2.5alpha. */
#ifdef MAIN_C
#define WHERE
| 0
| 9
|
CVE-2005-2351
|
Mutt before 1.5.20 patch 7 allows an attacker to cause a denial of service via a series of requests to mutt temporary files.
|
muttmua/mutt
|
781acdf0601fca98aadf1bbfdaae743084cb5f88
|
With SASL, expect the server to prompt for additional auth data if
we have some to send (#129961, upstream #1845)
|
commit 781acdf0601fca98aadf1bbfdaae743084cb5f88
Author: Bill Nottingham <[email protected]>
Date: Thu Jan 27 18:48:41 2005 +0000
With SASL, expect the server to prompt for additional auth data if
we have some to send (#129961, upstream #1845)
diff --git a/mutt_sasl.c b/mutt_sasl.c
index aa41f2c8..efe7e146 100644
--- a/mutt_sasl.c
+++ b/mutt_sasl.c
@@ -190,7 +190,7 @@ int mutt_sasl_client_new (CONNECTION* conn, sasl_conn_t** saslconn)
service = "imap";
break;
case M_ACCT_TYPE_POP:
- service = "pop-3";
+ service = "pop";
break;
default:
dprint (1, (debugfile, "mutt_sasl_client_new: account type unset\n"));
| 0
| 4
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
e387b6df99b7ea797814a8b233ae48df12f68763
|
Added storeException() method that takes an ActionMessage instead of
ActionError.
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@50964 13f79535-47bb-0310-9956-ffa450edef68
|
commit e387b6df99b7ea797814a8b233ae48df12f68763
Author: David Graham <[email protected]>
Date: Sat Aug 16 17:50:10 2003 +0000
Added storeException() method that takes an ActionMessage instead of
ActionError.
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@50964 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/share/org/apache/struts/action/ExceptionHandler.java b/src/share/org/apache/struts/action/ExceptionHandler.java
index 163abda2f..c7e471b04 100644
--- a/src/share/org/apache/struts/action/ExceptionHandler.java
+++ b/src/share/org/apache/struts/action/ExceptionHandler.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ExceptionHandler.java,v 1.20 2003/08/07 00:39:05 dgraham Exp $
- * $Revision: 1.20 $
- * $Date: 2003/08/07 00:39:05 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ExceptionHandler.java,v 1.21 2003/08/16 17:50:10 dgraham Exp $
+ * $Revision: 1.21 $
+ * $Date: 2003/08/16 17:50:10 $
*
* ====================================================================
*
@@ -168,17 +168,45 @@ public class ExceptionHandler {
* @param error - The error generated from the exception mapping
* @param forward - The forward generated from the input path (from the form or exception mapping)
* @param scope - The scope of the exception mapping.
+ * @deprecated Use storeException(HttpServletRequest, String, ActionMessage, ActionForward, String)
+ * instead. This will be removed after Struts 1.2.
*/
- protected void storeException(HttpServletRequest request,
- String property,
- ActionError error,
- ActionForward forward,
- String scope) {
-
+ protected void storeException(
+ HttpServletRequest request,
+ String property,
+ ActionError error,
+ ActionForward forward,
+ String scope) {
+
+ this.storeException(request, property, error, forward, scope);
+ }
+
+ /**
+ * Default implementation for handling an <b>ActionMessage</b> generated
+ * from an Exception during <b>Action</b> delegation. The default
+ * implementation is to set an attribute of the request or session, as
+ * defined by the scope provided (the scope from the exception mapping). An
+ * <b>ActionErrors</b> instance is created, the error is added to the
+ * collection and the collection is set under the Globals.ERROR_KEY.
+ *
+ * @param request - The request we are handling
+ * @param property - The property name to use for this error
+ * @param error - The error generated from the exception mapping
+ * @param forward - The forward generated from the input path (from the form or exception mapping)
+ * @param scope - The scope of the exception mapping.
+ * @since Struts 1.2
+ */
+ protected void storeException(
+ HttpServletRequest request,
+ String property,
+ ActionMessage error,
+ ActionForward forward,
+ String scope) {
+
ActionErrors errors = new ActionErrors();
errors.add(property, error);
- if ("request".equals(scope)){
+ if ("request".equals(scope)) {
request.setAttribute(Globals.ERROR_KEY, errors);
} else {
request.getSession().setAttribute(Globals.ERROR_KEY, errors);
| 0
| 10
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
fa2d79ae6b60f7c3c7b3be2c2da0b0ea361ab5c9
|
STR-3004: Delete new copy; use svn copy to retain history
git-svn-id: https://svn.apache.org/repos/asf/struts/struts1/trunk@505772 13f79535-47bb-0310-9956-ffa450edef68
|
commit fa2d79ae6b60f7c3c7b3be2c2da0b0ea361ab5c9
Author: Paul C. Benedict Jr <[email protected]>
Date: Sat Feb 10 21:44:56 2007 +0000
STR-3004: Delete new copy; use svn copy to retain history
git-svn-id: https://svn.apache.org/repos/asf/struts/struts1/trunk@505772 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/resources/org/apache/struts/resources/struts-config_1_4.dtd b/core/src/main/resources/org/apache/struts/resources/struts-config_1_4.dtd
new file mode 100644
index 000000000..9935b24e6
--- /dev/null
+++ b/core/src/main/resources/org/apache/struts/resources/struts-config_1_4.dtd
@@ -0,0 +1,740 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ DTD for the Struts Application Configuration File
+
+ To support validation of your configuration file, include the following
+ DOCTYPE element at the beginning (after the "xml" declaration):
+
+ <!DOCTYPE struts-config PUBLIC
+ "-//Apache Software Foundation//DTD Struts Configuration 1.4//EN"
+ "http://struts.apache.org/dtds/struts-config_1_4.dtd">
+
+ $Id$
+-->
+
+
+<!-- ========== Defined Types ============================================= -->
+
+
+<!-- An "AttributeName" is the identifier of a page, request, session, or
+ application scope attribute.
+-->
+<!ENTITY % AttributeName "CDATA">
+
+
+<!-- A "BeanName" is the identifier of a JavaBean, such as a form bean,
+ and also serves as the name of the corresponding scripting variable
+ and the name of the JSP attribute under which the bean is accessed.
+ Therefore, it must conform to the rules for a Java identifier.
+-->
+<!ENTITY % BeanName "CDATA">
+
+
+<!-- A "Boolean" is the string representation of a boolean (true or false)
+ variable.
+-->
+<!ENTITY % Boolean "(true|false|yes|no)">
+
+
+<!-- A "ClassName" is the fully qualified name of a Java class that is
+ instantiated to provide the functionality of the enclosing element.
+-->
+<!ENTITY % ClassName "CDATA">
+
+
+<!-- An "Integer" is a character string consisting solely of numeric digits,
+ optionally preceeded by a minus sign, that can be converted to a
+ 32-bit integer.
+-->
+<!ENTITY % Integer "CDATA">
+
+
+<!-- A "Location" is a relative path, delimited by "/" characters, that
+ defines the location of a resource relative to the location of the
+ Struts configuration file itself.
+-->
+<!ENTITY % Location "#PCDATA">
+
+
+<!-- A "PropName" is the name of a JavaBeans property, and must begin with
+ a lower case letter and contain only characters that are legal in a
+ Java identifier.
+-->
+<!ENTITY % PropName "CDATA">
+
+
+<!-- A "RequestPath" is an module-relative URI path, beginning with a
+ slash, that identifies a mapped resource (such as a JSP page or a servlet)
+ within this web application.
+-->
+<!ENTITY % RequestPath "CDATA">
+
+
+<!-- The name of a JSP bean scope within which such a form bean may be
+ accessed.
+-->
+<!ENTITY % RequestScope "(request|session)">
+
+<!-- Defines possible values for automatic form bean population -->
+<!ENTITY % PopulateStrategy "(request|forward|request-forward|none)">
+
+<!-- ========== Top Level Elements ======================================== -->
+
+
+<!-- The "struts-config" element is the root of the configuration file
+ hierarchy, and contains nested elements for all of the other
+ configuration settings.
+-->
+<!ELEMENT struts-config (display-name?, description?, form-beans?, global-exceptions?, global-forwards?, action-mappings?, controller?, message-resources*, plug-in*)>
+<!ATTLIST struts-config id ID #IMPLIED>
+
+<!-- The "form-beans" element describes the set of form bean descriptors for this
+ module. The following attributes are defined:
+
+ type Fully qualified Java class to use when instantiating
+ ActionFormBean objects. If specified, the object must be a
+ subclass of the default class type.
+
+ WARNING: For Struts 1.0, this value is ignored. You
+ can set the default implementation class name with the
+ "formBean" initialization parameter to the Struts
+ controller servlet.
+-->
+<!ELEMENT form-beans (form-bean*)>
+<!ATTLIST form-beans id ID #IMPLIED>
+<!ATTLIST form-beans type %ClassName; #IMPLIED>
+
+
+<!-- The "form-bean" element describes an ActionForm subclass
+ [org.apache.struts.action.ActionForm] that can be referenced by an "action"
+ element.
+
+
+The "form-bean" element describes a particular form bean, which is a
+ JavaBean that implements the org.apache.struts.action.ActionForm
+ class. The following attributes are defined:
+
+ className The configuration bean for this form bean object. If
+ specified, the object must be a subclass of the default
+ configuration bean.
+ ["org.apache.struts.config.FormBeanConfig"]
+
+ extends The name of the form bean that this bean will
+ inherit configuration information from.
+
+ name The unique identifier for this form bean. Referenced by the
+ <action> element to specify which form bean to use with its
+ request.
+
+ type Fully qualified Java class name of the ActionForm subclass
+ to use with this form bean.
+
+ enhanced Reserved for future use.
+-->
+<!ELEMENT form-bean (icon?, display-name?, description?, set-property*, form-property*)>
+<!ATTLIST form-bean id ID #IMPLIED>
+<!ATTLIST form-bean className %ClassName; #IMPLIED>
+<!ATTLIST form-bean enhanced %Boolean; #IMPLIED>
+<!ATTLIST form-bean extends %BeanName; #IMPLIED>
+<!ATTLIST form-bean name %BeanName; #REQUIRED>
+<!ATTLIST form-bean type %ClassName; #IMPLIED>
+
+
+<!-- The "form-property" element describes a JavaBean property that can be used to
+ configure an instance of a DynaActionForm or a subclass thereof. This element
+ is only utilized when the "type" attribute of the enclosing "form-bean" element
+ is [org.apache.struts.action.DynaActionForm] or a subclass of DynaActionForm. If
+ a custom DynaActionForm subclass is used, then the "dynamic" attribute of the
+ enclosing <form-bean> element must be set to "true". Since Struts 1.1.
+
+ className The configuration bean for this form property object. If
+ specified, the object must be a subclass of the default
+ configuration bean.
+ ["org.apache.struts.config.FormPropertyConfig"]
+
+ initial String representation of the initial value for this property.
+ If not specified, primitives will be initialized to zero and
+ objects initialized to the zero-argument instantiation of that
+ object class. For example, Strings will be initialized to ""
+
+ name The name of the JavaBean property described by this element.
+
+ reset The flag that indicates when this property should be reset
+ to its "initial" value when the form's "reset()" method is
+ called. If this is set to "true", the property is always
+ reset when "reset()" is called. This can also be set to
+ one or more HTTP methods, such as GET or POST. In such a
+ case, the property will be reset only when the HTTP method
+ used for the request being processed is included in this
+ attribute's value(s). Multiple HTTP methods can be
+ specified by separating them with whitespace or commas.
+
+ size The number of array elements to create if the value of the
+ "type" attribute specifies an array, but there is no value
+ specified for the "initial" attribute.
+
+ type Fully qualified Java class name of the field underlying this
+ property, optionally followed by "[]" to indicate that the
+ field is indexed.
+-->
+<!ELEMENT form-property (set-property*)>
+<!ATTLIST form-property className %ClassName; #IMPLIED>
+<!ATTLIST form-property initial CDATA #IMPLIED>
+<!ATTLIST form-property name %PropName; #REQUIRED>
+<!ATTLIST form-property reset %Boolean; #IMPLIED>
+<!ATTLIST form-property size %Integer; #IMPLIED>
+<!ATTLIST form-property type %ClassName; #REQUIRED>
+
+
+<!-- The "global-exceptions" element describes a set of exceptions that might be
+ thrown by an Action object. The handling of individual exception types is
+ configured through nested exception elements. An <action> element may
+ override a global exception handler by registering a local exception handler
+ for the same exception type. Since Struts 1.1.
+-->
+<!ELEMENT global-exceptions (exception*)>
+<!ATTLIST global-exceptions id ID #IMPLIED>
+
+
+<!-- The "exception" element registers an ExceptionHandler for an exception type.
+ The following attributes are defined:
+
+ bundle Servlet context attribute for the message resources bundle
+ associated with this handler. The default attribute is the
+ value specified by the string constant declared at
+ Globals.MESSAGES_KEY.
+ [org.apache.struts.Globals.MESSAGES_KEY]
+
+ className The configuration bean for this ExceptionHandler object.
+ If specified, className must be a subclass of the default
+ configuration bean
+ ["org.apache.struts.config.ExceptionConfig"]
+
+ extends The name of the exception handler that this
+ will inherit configuration information from.
+
+ handler Fully qualified Java class name for this exception handler.
+ ["org.apache.struts.action.ExceptionHandler"]
+
+ key The key to use with this handler's message resource bundle
+ that will retrieve the error message template for this
+ exception.
+
+ path The module-relative URI to the resource that will complete
+ the request/response if this exception occurs.
+
+ scope The context ("request" or "session") that is used to access
+ the ActionMessage object
+ [org.apache.struts.action.ActionMessage] for this
+ exception.
+
+ type Fully qualified Java class name of the exception type to
+ register with this handler.
+-->
+<!ELEMENT exception (icon?, display-name?, description?, set-property*)>
+<!ATTLIST exception id ID #IMPLIED>
+<!ATTLIST exception bundle %AttributeName; #IMPLIED>
+<!ATTLIST exception className %ClassName; #IMPLIED>
+<!ATTLIST exception extends %ClassName; #IMPLIED>
+<!ATTLIST exception handler %ClassName; #IMPLIED>
+<!ATTLIST exception key CDATA #IMPLIED>
+<!ATTLIST exception path %RequestPath; #IMPLIED>
+<!ATTLIST exception scope CDATA #IMPLIED>
+<!ATTLIST exception type %ClassName; #REQUIRED>
+
+
+<!-- The "global-forwards" element describes a set of ActionForward objects
+ [org.apache.struts.action.ActionForward] that are available to all Action
+ objects as a return value. The individual ActionForwards are configured
+ through nested <forward> elements. An <action> element may override a global
+ forward by defining a local <forward> of the same name.
+
+ type Fully qualified Java class to use when instantiating
+ ActionForward objects. If specified, the object must be a
+ subclass of the default class type.
+
+ WARNING: For Struts 1.0, this value is ignored. You
+ can set the default implementation class name with the
+ "forward" initialization parameter to the Struts
+ controller servlet.
+-->
+<!ELEMENT global-forwards (forward*)>
+<!ATTLIST global-forwards id ID #IMPLIED>
+<!ATTLIST global-forwards type %ClassName; #IMPLIED>
+
+
+<!-- The "forward" element describes an ActionForward that is to be made
+ available to an Action as a return value. An ActionForward is referenced by
+ a logical name and encapsulates a URI. A "forward" element may be used to
+ describe both global and local ActionForwards. Global forwards are available
+ to all the Action objects in the module. Local forwards can be
+ nested within an <action> element and only available to an Action object
+ when it is invoked through that ActionMapping.
+
+ catalog The name of a commons-chain catalog in which to look up
+ a command to be executed as part of servicing this request.
+ Only meaningful if "command" is also specified.
+
+ className Fully qualified Java class name of ActionForward
+ subclass to use for this object.
+ ["org.apache.struts.action.ActionForward"]
+
+ command The name of a commons-chain command which should be looked up
+ and executed as part of servicing this request.
+
+ extends The name of the forward configuration that this
+ will inherit configuration information from.
+
+ module The module prefix to use with this path. This value should
+ begin with a slash ("/").
+
+ name The unique identifier for this forward. Referenced by the
+ Action object at runtime to select - by its logical name -
+ the resource that should complete the request/response.
+
+ path The module-relative path to the resources that is
+ encapsulated by the logical name of this ActionForward.
+ This value should begin with a slash ("/") character.
+
+ redirect Set to "true" if a redirect instruction should be issued to
+ the user-agent so that a new request is issued for this
+ forward's resource. If true, RequestDispatcher.Redirect is
+ called. If "false", RequestDispatcher.forward is called instead.
+ [false]
+-->
+<!ELEMENT forward (icon?, display-name?, description?, set-property*)>
+<!ATTLIST forward id ID #IMPLIED>
+<!ATTLIST forward catalog CDATA #IMPLIED>
+<!ATTLIST forward className %ClassName; #IMPLIED>
+<!ATTLIST forward command CDATA #IMPLIED>
+<!ATTLIST forward extends CDATA #IMPLIED>
+<!ATTLIST forward module %RequestPath; #IMPLIED>
+<!ATTLIST forward name CDATA #REQUIRED>
+<!ATTLIST forward path %RequestPath; #IMPLIED>
+<!ATTLIST forward redirect %Boolean; #IMPLIED>
+
+
+<!-- The "action-mappings" element describes a set of ActionMapping objects
+ [org.apache.struts.action.ActionMapping] that are available to process
+ requests matching the url-pattern our ActionServlet registered with the
+ container. The individual ActionMappings are configured through nested
+ <action> elements. The following attributes are defined:
+
+ type Fully qualified Java class to use when instantiating
+ ActionMapping objects. If specified, the object must be a
+ subclass of the default class type.
+
+ WARNING: For Struts 1.0, this value is ignored. You
+ can set the default implementation class name with the
+ "mapping" initialization parameter to the Struts
+ controller servlet.
+-->
+<!ELEMENT action-mappings (action*)>
+<!ATTLIST action-mappings id ID #IMPLIED>
+<!ATTLIST action-mappings type %ClassName; #IMPLIED>
+
+
+<!-- The "action" element describes an ActionMapping object that is to be used
+ to process a request for a specific module-relative URI. The following
+ attributes are defined:
+
+ attribute Name of the request-scope or session-scope attribute that
+ is used to access our ActionForm bean, if it is other than
+ the bean's specified "name". Optional if "name" is specified,
+ else not valid.
+
+ cancellable Set to "true" if the Action can be cancelled. By default,
+ when an Action is cancelled, validation is bypassed
+ and the Action should not execute the business operation.
+ If a request tries to cancel an Action when cancellable
+ is not set, a "InvalidCancelException" is thrown.
+ [false]
+
+ catalog The name of a commons-chain catalog in which to look up
+ a command to be executed as part of servicing this request.
+ Only meaningful if "command" is also specified.
+
+ className The fully qualified Java class name of the ActionMapping
+ subclass to use for this action mapping object. Defaults to
+ the type specified by the enclosing <action-mappings>
+ element or to "org.apache.struts.action.ActionMapping" if
+ not specified.
+ ["org.apache.struts.action.ActionMapping"]
+
+ command The name of a commons-chain command which should be looked up
+ and executed as part of servicing this request.
+
+ extends The path of the action mapping configuration that this
+ will inherit configuration information from.
+
+ forward Module-relative path of the servlet or other resource that
+ will process this request, instead of the Action class
+ specified by "type". The path WILL NOT be processed
+ through the "forwardPattern" attribute that is configured
+ on the "controller" element for this module.
+ Exactly one of "forward", "include", or "type" must be
+ specified.
+
+ include Module-relative path of the servlet or other resource that
+ will process this request, instead of the Action class
+ specified by "type". The path WILL NOT be processed
+ through the "forwardPattern" attribute that is configured
+ on the "controller" element for this module.
+ Exactly one of "forward", "include", or "type" must be
+ specified.
+
+ input Module-relative path of the action or other resource to
+ which control should be returned if a validation error is
+ encountered. Valid only when "name" is specified. Required
+ if "name" is specified and the input bean returns
+ validation errors. Optional if "name" is specified and the
+ input bean does not return validation errors.
+
+ name Name of the form bean, if any, that is associated with this
+ action mapping.
+
+ parameter General-purpose configuration parameter that can be used to
+ pass extra information to the Action object selected by
+ this action mapping.
+
+ path The module-relative path of the submitted request, starting
+ with a "/" character, and without the filename extension if
+ extension mapping is used.
+
+ NOTE: Do *not* include a period in your path name,
+ because it will look like a filename extension and
+ cause your Action to not be located.
+
+ prefix Prefix used to match request parameter names to ActionForm
+ property names, if any. Optional if "name" is specified,
+ else not allowed.
+
+ roles Comma-delimited list of security role names that are allowed
+ access to this ActionMapping object. Since Struts 1.1.
+
+ scope The context ("request" or "session") that is used to
+ access our ActionForm bean, if any. Optional if "name" is
+ specified, else not valid. [session]
+
+ suffix Suffix used to match request parameter names to ActionForm
+ bean property names, if any. Optional if "name" is
+ specified, else not valid.
+
+ type Fully qualified Java class name of the Action subclass
+ [org.apache.struts.action.Action] that will process requests
+ for this action mapping. Not valid if either the "forward"
+ or "include" attribute is specified. Exactly one of
+ "forward", "include", or "type" must be specified.
+
+ unknown Set to "true" if this object should be configured as the
+ default action mapping for this module. If a request does not
+ match another object, it will be passed to the ActionMapping
+ object with unknown set to "true". Only one ActionMapping
+ can be marked as "unknown" within a module.
+ [false]
+
+ validate Set to "true" if the validate method of the ActionForm bean
+ should be called prior to calling the Action object for this
+ action mapping, or set to "false" if you do not want the
+ validate method called.
+ [true]
+
+ reset Allows to specify conditions for automatic form reset.
+ Possible values: not specified, "request", "forward",
+ "request-forward" or "none".
+ [request-forward]
+
+ populate Allows to specify conditions for automatic form population
+ with HTTP request values. Possible values: not specified,
+ "request", "forward", "request-forward" or "none".
+ [request-forward]
+-->
+<!ELEMENT action (icon?, display-name?, description?, set-property*, exception*, forward*)>
+<!ATTLIST action id ID #IMPLIED>
+<!ATTLIST action attribute %BeanName; #IMPLIED>
+<!ATTLIST action cancellable %Boolean; #IMPLIED>
+<!ATTLIST action catalog CDATA #IMPLIED>
+<!ATTLIST action className %ClassName; #IMPLIED>
+<!ATTLIST action command CDATA #IMPLIED>
+<!ATTLIST action extends %RequestPath; #IMPLIED>
+<!ATTLIST action forward %RequestPath; #IMPLIED>
+<!ATTLIST action include %RequestPath; #IMPLIED>
+<!ATTLIST action input %RequestPath; #IMPLIED>
+<!ATTLIST action name %BeanName; #IMPLIED>
+<!ATTLIST action parameter CDATA #IMPLIED>
+<!ATTLIST action path %RequestPath; #REQUIRED>
+<!ATTLIST action populate %PopulateStrategy; #IMPLIED>
+<!ATTLIST action prefix CDATA #IMPLIED>
+<!ATTLIST action reset %PopulateStrategy; #IMPLIED>
+<!ATTLIST action roles CDATA #IMPLIED>
+<!ATTLIST action scope %RequestScope; #IMPLIED>
+<!ATTLIST action suffix CDATA #IMPLIED>
+<!ATTLIST action type %ClassName; #IMPLIED>
+<!ATTLIST action unknown %Boolean; #IMPLIED>
+<!ATTLIST action validate %Boolean; #IMPLIED>
+
+
+<!-- The "controller" element describes the ControllerConfig bean
+ [org.apache.struts.config.ControllerConfig] that encapsulates
+ a module's runtime configuration. The following
+ attributes are defined:
+
+ bufferSize The size of the input buffer used when processing
+ file uploads.
+ [4096]
+
+ catalog Name of the catalog to use when processing requests
+ for this module.
+ [struts]
+
+ className Fully qualified Java class name of the
+ ControllerConfig subclass for this controller object.
+ If specified, the object must be a subclass of the
+ default class.
+ ["org.apache.struts.config.ControllerConfig"]
+
+ command Name of the command to execute to process a request.
+ [servlet-standard]
+
+ contentType Default content type (and optional character encoding) to
+ be set on each response. May be overridden by the Action,
+ JSP, or other resource to which the request is forwarded.
+ ["text/html"]
+
+ forwardPattern Replacement pattern defining how the "path" attribute of a
+ <forward> element is mapped to a context-relative URL when
+ it starts with a slash (and when the contextRelative
+ property is false). This value may consist of any
+ combination of the following:
+ - "$M" - Replaced by the module prefix of this module
+ - "$P" - Replaced by the "path" attribute of the selected
+ "forward" element
+ - "$$" - Causes a literal dollar sign to be rendered
+ - "$x" - (Where "x" is any character not defined above)
+ Silently swallowed, reserved for future use
+ If not specified, the default forwardPattern is "$M$P",
+ which is consistent with the previous behavior of
+ forwards. Since Struts 1.1. ["$M$P"]
+
+ inputForward Set to "true" if you want the "input" attribute of
+ <action> elements to be the name of a local or global
+ ActionForward, which will then be used to calculate the
+ ultimate URL. Set to "false" (the default) to treat the
+ "input" parameter of <action> elements as a
+ module-relative path to the resource
+ to be used as the input form. Since Struts 1.1.
+ [false]
+
+ locale Set to "true" if you want a Locale object stored in the
+ user's session if not already present.
+ [true]
+
+ maxFileSize The maximum size (in bytes) of a file to be accepted as a
+ file upload. Can be expressed as a number followed by a
+ "K", "M", or "G", which are interpreted to mean kilobytes,
+ megabytes, or gigabytes, respectively.
+ ["250M"]
+
+ memFileSize The maximum size (in bytes) of a file whose contents will
+ be retained in memory after uploading. Files larger than
+ this threshold will be written to some alternative storage
+ medium, typically a hard disk. Can be expressed as a number
+ followed by a "K", "M", or "G", which are interpreted to
+ mean kilobytes, megabytes, or gigabytes, respectively.
+ ["256K"]
+
+ multipartClass The fully qualified Java class name of the multipart
+ request handler class to be used with this module.
+ ["org.apache.struts.upload.CommonsMultipartRequestHandler"]
+
+ nocache Set to "true" if you want the controller to add HTTP
+ headers for defeating caching to every response from
+ this module. [false]
+
+ pagePattern Replacement pattern defining how the "page" attribute of
+ custom tags using it is mapped to a context-relative URL
+ of the corresponding resource. This value may consist of
+ any combination of the following:
+ - "$M" - Replaced by the module prefix of this module
+ - "$P" - Replaced by the value of the "page" attribute
+ - "$$" - Causes a literal dollar sign to be rendered
+ - "$x" - (Where "x" is any character not defined above)
+ Silently swallowed, reserved for future use
+ If not specified, the default forwardPattern is
+ "$M$P", which is consistent with previous hard coded
+ behavior of URL evaluation for "page" attributes.
+ ["$M$P"]
+
+ processorClass The fully qualified Java class name of the
+ RequestProcessor subclass to be used with this module.
+ ["org.apache.struts.chain.ComposableRequestProcessor"]
+
+ tempDir Temporary working directory to use when processing
+ file uploads.
+ [{Directory provided by servlet container}]
+
+-->
+<!ELEMENT controller (set-property*)>
+<!ATTLIST controller id ID #IMPLIED>
+<!ATTLIST controller bufferSize %Integer; #IMPLIED>
+<!ATTLIST controller catalog CDATA #IMPLIED>
+<!ATTLIST controller className %ClassName; #IMPLIED>
+<!ATTLIST controller command CDATA #IMPLIED>
+<!ATTLIST controller contentType CDATA #IMPLIED>
+<!ATTLIST controller forwardPattern CDATA #IMPLIED>
+<!ATTLIST controller inputForward %Boolean; #IMPLIED>
+<!ATTLIST controller locale %Boolean; #IMPLIED>
+<!ATTLIST controller maxFileSize CDATA #IMPLIED>
+<!ATTLIST controller memFileSize CDATA #IMPLIED>
+<!ATTLIST controller multipartClass %ClassName; #IMPLIED>
+<!ATTLIST controller nocache %Boolean; #IMPLIED>
+<!ATTLIST controller pagePattern CDATA #IMPLIED>
+<!ATTLIST controller processorClass %ClassName; #IMPLIED>
+<!ATTLIST controller tempDir CDATA #IMPLIED>
+
+
+<!-- The "message-resources" element describes a MessageResources object with
+ message templates for this module. The following attributes are defined:
+
+ className The configuration bean for this message resources object.
+ If specified, the object must be a subclass of the default
+ configuration bean.
+ ["org.apache.struts.config.MessageResourcesConfig"]
+
+ factory Fully qualified Java class name of the
+ MessageResourcesFactory subclass to use for this message
+ resources object.
+ ["org.apache.struts.util.PropertyMessageResourcesFactory"]
+
+ key Servlet context attribute under which this message
+ resources bundle will be stored. The default attribute is
+ the value specified by the string constant at
+ [Globals.MESSAGES_KEY]. The module prefix (if
+ any) is appended to the key (${key}${prefix}).
+ [org.apache.struts.Globals.MESSAGES_KEY]
+
+ NOTE: The module prefix includes the leading
+ slash, so the default message resource bundle for a module
+ named "foo" is stored under
+ "org.apache.struts.action.MESSAGE/foo".
+
+ null Set to "true" if you want our message resources to return a
+ null string for unknown message keys, or "false" to return a
+ message with the bad key value.
+
+ parameter Configuration parameter to be passed to the createResources
+ method of our factory object.
+-->
+<!ELEMENT message-resources (set-property*)>
+<!ATTLIST message-resources id ID #IMPLIED>
+<!ATTLIST message-resources className %ClassName; #IMPLIED>
+<!ATTLIST message-resources factory %ClassName; #IMPLIED>
+<!ATTLIST message-resources key %AttributeName; #IMPLIED>
+<!ATTLIST message-resources null %Boolean; #IMPLIED>
+<!ATTLIST message-resources parameter CDATA #REQUIRED>
+
+
+<!-- The "plug-in" element specifies the fully qualified class name of a
+ general-purpose application plug-in module that receives notification of
+ application startup and shutdown events. An instance of the specified class
+ is created for each element, and can be configured with nested <set-property>
+ elements. The following attributes are supported:
+
+ className Fully qualified Java class name of the plug-in class; must
+ implement [org.apache.struts.action.PlugIn].
+-->
+<!ELEMENT plug-in (set-property*)>
+<!ATTLIST plug-in id ID #IMPLIED>
+<!ATTLIST plug-in className %ClassName; #REQUIRED>
+
+
+<!-- ========== Subordinate Elements ====================================== -->
+
+
+<!-- The "description" element contains descriptive (paragraph length) text
+ about the surrounding element, suitable for use in GUI tools.
+-->
+<!ELEMENT description (#PCDATA)>
+<!ATTLIST description id ID #IMPLIED>
+
+
+<!-- The "display-name" element contains a short (one line) description of
+ the surrounding element, suitable for use in GUI tools.
+-->
+<!ELEMENT display-name (#PCDATA)>
+<!ATTLIST display-name id ID #IMPLIED>
+
+
+<!-- The "icon" element contains a small-icon and large-icon element which
+ specify the location, relative to the Struts configuration file, for small
+ and large images used to represent the surrounding element in GUI tools.
+-->
+<!ELEMENT icon (small-icon?, large-icon?)>
+<!ATTLIST icon id ID #IMPLIED>
+
+
+<!-- The "large-icon" element specifies the location, relative to the Struts
+ configuration file, of a resource containing a large (32x32 pixel)
+ icon image.
+-->
+<!ELEMENT large-icon (%Location;)>
+<!ATTLIST large-icon id ID #IMPLIED>
+
+
+<!-- The "set-property" element specifies the method name and initial value of
+ an additional JavaBean configuration property. When the object representing
+ the surrounding element is instantiated, the accessor for the indicated
+ property is called and passed the indicated value. The "set-property"
+ element is especially useful when a custom subclass is used with
+ <forward>, <action>, or <plug-in> elements. The subclass
+ can be passed whatever other properties may be required to configure the
+ object without changing how the struts-config is parsed.
+
+ Since Struts 1.3, an alternate syntax is supported. By using
+ the "key" attribute instead of the "property" attribute, you can set
+ arbitrary string properties on the Config object which is populated
+ based on the containing element. NOTE: the "key" attribute is NOT
+ supported for <set-property> inside a <plug-in> element.
+
+ property Name of the JavaBeans property whose setter method
+ will be called. Exactly one of
+ "property" or "key" must be specified.
+
+ key Where supported, the key which will be used to store
+ the specified value in the given config object. Exactly one of
+ "property" or "key" must be specified.
+
+ value String representation of the value to which this
+ property will be set, after suitable type conversion
+
+-->
+<!ELEMENT set-property EMPTY>
+<!ATTLIST set-property id ID #IMPLIED>
+<!ATTLIST set-property property %PropName; #IMPLIED>
+<!ATTLIST set-property key CDATA #IMPLIED>
+<!ATTLIST set-property value CDATA #REQUIRED>
+
+
+<!-- The "small-icon" element specifies the location, relative to the Struts
+ configuration file, of a resource containing a small (16x16 pixel)
+ icon image.
+-->
+<!ELEMENT small-icon (%Location;)>
+<!ATTLIST small-icon id ID #IMPLIED>
+
| 0
| 2
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
dc188fbdf90d6210937dd25d03037018c5f41a87
|
Submitted by Ted Husted. Minor changes to hilight standard
ActionForm validate methods.
<snip>
<li>Generally, there will be very little input validation logic in an
<code>ActionForm</code> bean. The primary reason such beans exist
is to save the most recent values entered by the user for the
associated form -- even if errors are detected -- so that the same
page can be reproduced, along with a set of error messages, so the
user need only correct the fields that are wrong. Validation
of user input should be performed within <code>Action</code> classes
(if it is simple), or appropriate business logic beans.</li>
</snip>
<insert>
<li>The ActionForm object also offers a standard validation mechanism.
If you override a "stub" method, and provide error messages in the
standard application resource, Struts will automatically validate the
input from the form (using your method). If validation fails, Struts
can automatically return the user to the input form, re-populate
the form from the form bean, and display your error messages (via a
custom tag), all before the Action object is ever called. This is a
quick and easy way to get simple validation out of the way, but you
might also want to provide further "business logic" validation as
part of your Action object. (See "Action Form Validation" for details.)
Of course, you can also ignore the ActionForm validation and provide
your own in the Action object</li>
</insert>
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48018 13f79535-47bb-0310-9956-ffa450edef68
|
commit dc188fbdf90d6210937dd25d03037018c5f41a87
Author: Ted Nathan Husted <[email protected]>
Date: Wed Jan 10 22:39:27 2001 +0000
Submitted by Ted Husted. Minor changes to hilight standard
ActionForm validate methods.
<snip>
<li>Generally, there will be very little input validation logic in an
<code>ActionForm</code> bean. The primary reason such beans exist
is to save the most recent values entered by the user for the
associated form -- even if errors are detected -- so that the same
page can be reproduced, along with a set of error messages, so the
user need only correct the fields that are wrong. Validation
of user input should be performed within <code>Action</code> classes
(if it is simple), or appropriate business logic beans.</li>
</snip>
<insert>
<li>The ActionForm object also offers a standard validation mechanism.
If you override a "stub" method, and provide error messages in the
standard application resource, Struts will automatically validate the
input from the form (using your method). If validation fails, Struts
can automatically return the user to the input form, re-populate
the form from the form bean, and display your error messages (via a
custom tag), all before the Action object is ever called. This is a
quick and easy way to get simple validation out of the way, but you
might also want to provide further "business logic" validation as
part of your Action object. (See "Action Form Validation" for details.)
Of course, you can also ignore the ActionForm validation and provide
your own in the Action object</li>
</insert>
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48018 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/doc/userGuide/building_model.xml b/src/doc/userGuide/building_model.xml
index 1f9b2d009..f4bfde3a1 100644
--- a/src/doc/userGuide/building_model.xml
+++ b/src/doc/userGuide/building_model.xml
@@ -10,246 +10,250 @@
<body>
<chapter name="Building Model Components" href="building_model">
- <section name="2.1 Overview" href="overview">
-
- <p>
- The application requirements document that you are using will likely
- have focused on the user interface to be created. However, you should ensure
- that the processing required for each submitted request is also clearly
- defined. In general, the developer of the <i>Model</i> components will be
- focusing on the creation of JavaBeans classes that support all of the
- functional requirements. The precise nature of the beans required by a
- particular application will vary widely depending on those requirements,
- but they can generally be classified into several categories discussed
- below. However, a brief review of the concept of "scope" as it relates
- to beans is useful first.
- </p>
- </section>
-
- <section name="2.2 JavaBeans and Scope" href="javabeans">
-
- <p>
- Within a web-based application, JavaBeans can be stored in (and accessed
- from) a number of different collections of "attributes". Each collection
- has different rules for the lifetime of that collection, and the visibility
- of the beans stored there. Together, the rules defining lifetime and
- visibility are called the <i>scope</i> of those beans. The JavaServer
- Pages (JSP) Specification defines scope choices using the following terms
- (with the equivalent servlet API concept defined in parentheses):
- </p>
-
- <ul>
- <li><b>page</b> - Beans that are visible within a single JSP page,
- for the lifetime of the current request. (Local variables of
- the <code>service()</code> method)</li>
- <li><b>request</b> - Beans that are visible within a single JSP page,
- as well as to any page or servlet that is included in this page,
- or forwarded to by this page. (Request attributes)</li>
- <li><b>session</b> - Beans that are visible to all JSP pages and
- servlets that participate in a particular user session, across one
- or more requests. (Session attributes)</li>
- <li><b>application</b> - Beans that are visible to all JSP pages and
- servlets that are part of a web application. (Servlet context
- attributes)</li>
- </ul>
-
- <p>
- It is important to remember that JSP pages and servlets in the same
- web application share the same sets of bean collections. For example,
- a bean stored as a request attribute in a servlet like this:
- </p>
-
- <pre>
- MyCart mycart = new MyCart(...);
- request.setAttribute("cart", mycart);
- </pre>
-
- <p>
- is immediately visible to a JSP page which this servlet forwards to,
- using a standard action tag like this:
- </p>
-
- <pre>
- <jsp:useBean id="cart" scope="request"
- class="com.mycompany.MyApp.MyCart"/>
- </pre>
- </section>
-
- <section name="2.3 ActionForm Beans" href="actionform">
-
- <p>
- Note: ActionForm beans are actually closer to the <i>View</i>
- than the <i>Model</i>
- </p>
- <p>
- The Struts framework generally assumes that you have created an
- <code>ActionForm</code> bean (that is, a Java class extending the
- <code>ActionForm</code> class) for each input form required in your
- application. If you define such beans in your <code>ActionMapping</code>
- configuration file (see "Building the Controller Components"), the Struts
- controller servlet will automatically perform the following services for
- you, before invoking the appropriate <code>Action</code> method:
- </p>
-
- <ul>
- <li>Check in the user's session for an instance of a bean of the
- appropriate class, under the appropriate key.</li>
- <li>If there is no such session scope bean available, a new one is
- automatically created and added to the user's session.</li>
- <li>For every request parameter whose name corresponds to the name
- of a property in the bean, the corresponding setter method will
- be called. This operates in a manner similar to the standard
- JSP action <code><jsp:setProperty></code> when you use the
- asterisk wildcard to select all properties.</li>
- <li>The updated <code>ActionForm</code> bean will be passed to the
- Action Class <code>perform()</code> method when it is called,
- making these values immediately available.</li>
- </ul>
-
- <p>
- When you code your <code>ActionForm</code> beans, keep the following
- principles in mind:
- </p>
-
- <ul>
- <li>The <code>ActionForm</code> class itself requires no specific
- methods to be implemented. It is used to identify the role these
- particular beans play in the overall architecture. Typically, an
- <code>ActionForm</code> bean will have only property getter and
- property setter methods, with no business logic.</li>
- <li>Generally, there will be very little input validation logic in an
- <code>ActionForm</code> bean. The primary reason such beans exist
- is to save the most recent values entered by the user for the
- associated form -- even if errors are detected -- so that the same
- page can be reproduced, along with a set of error messages, so the
- user need only correct the fields that are wrong. Validation
- of user input should be performed within <code>Action</code> classes
- (if it is simple), or appropriate business logic beans.</li>
- <li>Define a property (with associated <code>getXxx()</code> and
- <code>setXxx()</code> methods) for each field that is present
- in the form. The field name and property name must match according
- to the usual JavaBeans conventions. For example, an input field named
- <code>username</code> will cause the <code>setUsername()</code> method
- to be called.</li>
- </ul>
-
- <p>
- You should note that a "form", in the sense discussed here, does not
- necessarily correspond to a single JSP page in the user interface. It is
- common in many applications to have a "form" (from the user's perspective)
- that extends over multiple pages. Think, for example, of the wizard style
- user interface that is commonly used when installing new applications. Struts
- encourages you to define a single <code>ActionForm</code> bean that contains
- properties for all of the fields, no matter which page the field is actually
- displayed on. Likewise, the various pages of the same form should all be
- submitted to the same Action Class. If you follow these suggestions, the
- page designers can rearrange the fields among the various pages, with no
- changes required to the processing logic in most cases.
- </p>
- </section>
-
- <section name="2.4 System State Beans" href="system_state">
-
- <p>
- The actual state of a system is normally represented as a set of one or
- more JavaBeans classes, whose properties define the current state. A
- shopping cart system, for example, will include a bean that represents the
- cart being maintained for each individual shopper, and will (among other
- things) include the set of items that the shopper has currently selected
- for purchase. Separately, the system will also include different beans
- for the user's profile information (including their credit card and ship-to
- addresses), as well as the catalog of available items and their current
- inventory levels.
- </p>
-
- <p>
- For small scale systems, or for state information that need not be kept
- for a long period of time, a set of system state beans may contain all the
- knowledge that the system ever has of these particular details. Or, as is
- often the case, the system state beans will represent information that is
- stored permanently in some external database (such as a CustomerBean object
- that corresponds to a particular row in the CUSTOMERS table), and are
- created or removed from the server's memory as needed. Entity Enterprise
- JavaBeans are also used for this purpose in large scale applications.
- </p>
- </section>
-
- <section name="2.5 Business Logic Beans" href="business_logic">
-
- <p>
- You should encapsulate the functional logic of your application as
- method calls on JavaBeans designed for this purpose. These methods may
- be part of the same classes used for the system state beans, or they may
- be in separate classes dedicated to performing the logic. In the latter
- case, you will usually need to pass the system state beans to be manipulated
- to these methods as arguments.
- </p>
-
- <p>
- For maximum code re-use, business logic beans should be designed and
- implemented so that they do <b>not</b> know they are being executed in a
- web application environment. If you find yourself having to import a
- <code>javax.servlet.*</code> class in your bean, you
- are tying this business logic to the web application environment. Consider
- rearranging things so that your <code>Action</code> classes (part of the
- Controller role, as described below) translate all required information
- from the HTTP request being processed into property setter calls on your
- business logic beans, after which a call to an <code>execute()</code> method
- can be made. Such a business logic class can be reused in environments
- other than the web application for which they were initially constructed.
- </p>
-
- <p>
- Depending on the complexity and scope of your application, business logic
- beans might be ordinary JavaBeans that interact with system state beans
- passed as arguments, or ordinary JavaBeans that access a database using
- JDBC calls. For larger applications, these beans will often be stateful
- or stateless Enterprise JavaBeans (EJBs) instead.
- </p>
- </section>
-
- <section name="2.6 Accessing Relational Databases" href="databases">
-
- <p>
- Struts contains in it's mapping config file the ability to specify data sources.
- See <a href="building_controller.html#config">The Action Mappings Configuration File</a>
- for information on how to set up a datasource. Do that first.
- </p>
-
- <p>
- After setting up your data source in the config file, most likely you'll want
- to retrieve a connection from it. This small example nested inside of an action's
- <code>perform()</code> method will show you how to do it:
- </p>
- <p>
- <pre>
- public ActionForward perform(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) {
- try {
- javax.sql.DataSource dataSource =
- (DataSource) getServlet().getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
-
- Connection myConnection = dataSource.getConnection();
- //do what you wish with myConnection
- }
- catch (SQLException sqle) {
- sqle.printStackTrace();
- }
- finally {
- //enclose this in a finally block to make
- //sure the connection is closed
- myConnection.close();
- }
- }
- </pre>
- </p>
-
- <p align="center">
- Next: <a href="building_view.html">Building View Components</a>
- </p>
- </section>
- </chapter>
- </body>
+ <section name="2.1 Overview" href="overview">
+
+ <p>
+ The application requirements document that you are using will likely
+ have focused on the user interface to be created. However, you should ensure
+ that the processing required for each submitted request is also clearly
+ defined. In general, the developer of the <i>Model</i> components will be
+ focusing on the creation of JavaBeans classes that support all of the
+ functional requirements. The precise nature of the beans required by a
+ particular application will vary widely depending on those requirements,
+ but they can generally be classified into several categories discussed
+ below. However, a brief review of the concept of "scope" as it relates
+ to beans is useful first.
+ </p>
+ </section>
+
+ <section name="2.2 JavaBeans and Scope" href="javabeans">
+
+ <p>
+ Within a web-based application, JavaBeans can be stored in (and accessed
+ from) a number of different collections of "attributes". Each collection
+ has different rules for the lifetime of that collection, and the visibility
+ of the beans stored there. Together, the rules defining lifetime and
+ visibility are called the <i>scope</i> of those beans. The JavaServer
+ Pages (JSP) Specification defines scope choices using the following terms
+ (with the equivalent servlet API concept defined in parentheses):
+ </p>
+
+ <ul>
+ <li><b>page</b> - Beans that are visible within a single JSP page,
+ for the lifetime of the current request. (Local variables of
+ the <code>service()</code> method)</li>
+ <li><b>request</b> - Beans that are visible within a single JSP page,
+ as well as to any page or servlet that is included in this page,
+ or forwarded to by this page. (Request attributes)</li>
+ <li><b>session</b> - Beans that are visible to all JSP pages and
+ servlets that participate in a particular user session, across one
+ or more requests. (Session attributes)</li>
+ <li><b>application</b> - Beans that are visible to all JSP pages and
+ servlets that are part of a web application. (Servlet context
+ attributes)</li>
+ </ul>
+
+ <p>
+ It is important to remember that JSP pages and servlets in the same
+ web application share the same sets of bean collections. For example,
+ a bean stored as a request attribute in a servlet like this:
+ </p>
+
+ <pre>
+ MyCart mycart = new MyCart(...);
+ request.setAttribute("cart", mycart);
+ </pre>
+
+ <p>
+ is immediately visible to a JSP page which this servlet forwards to,
+ using a standard action tag like this:
+ </p>
+
+ <pre>
+ <jsp:useBean id="cart" scope="request"
+ class="com.mycompany.MyApp.MyCart"/>
+ </pre>
+ </section>
+
+ <section name="2.3 ActionForm Beans" href="actionform">
+
+ <p>
+ Note: ActionForm beans are actually closer to the <i>View</i>
+ than the <i>Model</i>
+ </p>
+ <p>
+ The Struts framework generally assumes that you have created an
+ <code>ActionForm</code> bean (that is, a Java class extending the
+ <code>ActionForm</code> class) for each input form required in your
+ application. If you define such beans in your <code>ActionMapping</code>
+ configuration file (see "Building the Controller Components"), the Struts
+ controller servlet will automatically perform the following services for
+ you, before invoking the appropriate <code>Action</code> method:
+ </p>
+
+ <ul>
+ <li>Check in the user's session for an instance of a bean of the
+ appropriate class, under the appropriate key.</li>
+ <li>If there is no such session scope bean available, a new one is
+ automatically created and added to the user's session.</li>
+ <li>For every request parameter whose name corresponds to the name
+ of a property in the bean, the corresponding setter method will
+ be called. This operates in a manner similar to the standard
+ JSP action <code><jsp:setProperty></code> when you use the
+ asterisk wildcard to select all properties.</li>
+ <li>The updated <code>ActionForm</code> bean will be passed to the
+ Action Class <code>perform()</code> method when it is called,
+ making these values immediately available.</li>
+ </ul>
+
+ <p>
+ When you code your <code>ActionForm</code> beans, keep the following
+ principles in mind:
+ </p>
+
+ <ul>
+ <li>The <code>ActionForm</code> class itself requires no specific
+ methods to be implemented. It is used to identify the role these
+ particular beans play in the overall architecture. Typically, an
+ <code>ActionForm</code> bean will have only property getter and
+ property setter methods, with no business logic.</li>
+ <li>The ActionForm object also offers a standard validation mechanism.
+ If you override a "stub" method, and provide error messages in the
+ standard application resource, Struts will automatically validate the
+ input from the form (using your method). If validation fails, Struts
+ can automatically return the user to the input form, re-populate
+ the form from the form bean, and display your error messages (via a
+ custom tag), all before the Action object is ever called. This is a
+ quick and easy way to get simple validation out of the way, but you
+ might also want to provide further "business logic" validation as
+ part of your Action object. (See "Action Form Validation" for details.)
+ Of course, you can also ignore the ActionForm validation and provide
+ your own in the Action object</li>
+ <li>Define a property (with associated <code>getXxx()</code> and
+ <code>setXxx()</code> methods) for each field that is present
+ in the form. The field name and property name must match according
+ to the usual JavaBeans conventions. For example, an input field named
+ <code>username</code> will cause the <code>setUsername()</code> method
+ to be called.</li>
+ </ul>
+
+ <p>
+ You should note that a "form", in the sense discussed here, does not
+ necessarily correspond to a single JSP page in the user interface. It is
+ common in many applications to have a "form" (from the user's perspective)
+ that extends over multiple pages. Think, for example, of the wizard style
+ user interface that is commonly used when installing new applications. Struts
+ encourages you to define a single <code>ActionForm</code> bean that contains
+ properties for all of the fields, no matter which page the field is actually
+ displayed on. Likewise, the various pages of the same form should all be
+ submitted to the same Action Class. If you follow these suggestions, the
+ page designers can rearrange the fields among the various pages, with no
+ changes required to the processing logic in most cases.
+ </p>
+ </section>
+
+ <section name="2.4 System State Beans" href="system_state">
+
+ <p>
+ The actual state of a system is normally represented as a set of one or
+ more JavaBeans classes, whose properties define the current state. A
+ shopping cart system, for example, will include a bean that represents the
+ cart being maintained for each individual shopper, and will (among other
+ things) include the set of items that the shopper has currently selected
+ for purchase. Separately, the system will also include different beans
+ for the user's profile information (including their credit card and ship-to
+ addresses), as well as the catalog of available items and their current
+ inventory levels.
+ </p>
+
+ <p>
+ For small scale systems, or for state information that need not be kept
+ for a long period of time, a set of system state beans may contain all the
+ knowledge that the system ever has of these particular details. Or, as is
+ often the case, the system state beans will represent information that is
+ stored permanently in some external database (such as a CustomerBean object
+ that corresponds to a particular row in the CUSTOMERS table), and are
+ created or removed from the server's memory as needed. Entity Enterprise
+ JavaBeans are also used for this purpose in large scale applications.
+ </p>
+ </section>
+
+ <section name="2.5 Business Logic Beans" href="business_logic">
+
+ <p>
+ You should encapsulate the functional logic of your application as
+ method calls on JavaBeans designed for this purpose. These methods may
+ be part of the same classes used for the system state beans, or they may
+ be in separate classes dedicated to performing the logic. In the latter
+ case, you will usually need to pass the system state beans to be manipulated
+ to these methods as arguments.
+ </p>
+
+ <p>
+ For maximum code re-use, business logic beans should be designed and
+ implemented so that they do <b>not</b> know they are being executed in a
+ web application environment. If you find yourself having to import a
+ <code>javax.servlet.*</code> class in your bean, you
+ are tying this business logic to the web application environment. Consider
+ rearranging things so that your <code>Action</code> classes (part of the
+ Controller role, as described below) translate all required information
+ from the HTTP request being processed into property setter calls on your
+ business logic beans, after which a call to an <code>execute()</code> method
+ can be made. Such a business logic class can be reused in environments
+ other than the web application for which they were initially constructed.
+ </p>
+
+ <p>
+ Depending on the complexity and scope of your application, business logic
+ beans might be ordinary JavaBeans that interact with system state beans
+ passed as arguments, or ordinary JavaBeans that access a database using
+ JDBC calls. For larger applications, these beans will often be stateful
+ or stateless Enterprise JavaBeans (EJBs) instead.
+ </p>
+ </section>
+
+ <section name="2.6 Accessing Relational Databases" href="databases">
+
+ <p>
+ Struts contains in it's mapping config file the ability to specify data sources.
+ See <a href="building_controller.html#config">The Action Mappings Configuration File</a>
+ for information on how to set up a datasource. Do that first.
+ </p>
+
+ <p>
+ After setting up your data source in the config file, most likely you'll want
+ to retrieve a connection from it. This small example nested inside of an action's
+ <code>perform()</code> method will show you how to do it:
+ </p>
+ <p>
+ <pre>
+ public ActionForward perform(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ try {
+ javax.sql.DataSource dataSource =
+ (DataSource) getServlet().getServletContext().getAttribute(Action.DATA_SOURCE_KEY);
+
+ Connection myConnection = dataSource.getConnection();
+ //do what you wish with myConnection
+ }
+ catch (SQLException sqle) {
+ sqle.printStackTrace();
+ }
+ finally {
+ //enclose this in a finally block to make
+ //sure the connection is closed
+ myConnection.close();
+ }
+ }
+ </pre>
+ </p>
+
+ <p align="center">
+ Next: <a href="building_view.html">Building View Components</a>
+ </p>
+ </section>
+ </chapter>
+ </body>
</document>
\ No newline at end of file
| 0
| 9
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
7ac7d6d69ac64863983b2b673aab62241b33ce8f
|
Bring the release notes for beta-2 up to date with respect to recent changes.
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48341 13f79535-47bb-0310-9956-ffa450edef68
|
commit 7ac7d6d69ac64863983b2b673aab62241b33ce8f
Author: Craig R. McClanahan <[email protected]>
Date: Sun May 13 02:56:19 2001 +0000
Bring the release notes for beta-2 up to date with respect to recent changes.
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48341 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/doc/release-notes-1.0-b2.xml b/doc/release-notes-1.0-b2.xml
index 43fdb868b..8f8c54445 100644
--- a/doc/release-notes-1.0-b2.xml
+++ b/doc/release-notes-1.0-b2.xml
@@ -107,6 +107,12 @@
deprecated, and have been replaced (and considerably enhanced) in
the various individual tag libraries.</p>
+ <p>The build procedure for compiling the Struts source distribution
+ has been revised, and now depends on having <strong>Ant 1.2</strong>
+ (or later) installed, with the <code>$ANT_HOME/bin</code> directory
+ on your path. Further information can be found in the
+ <a href="installation.html">Installation</a> documentation.</p>
+
<p>The following new features have been added to the basic controller
framework (package <code>org.apache.struts.action</code>):</p>
<ul>
@@ -117,6 +123,23 @@
processing provided by the controller is still performed first, if you
have configured it, so the included resource can benefit from this
processing if it wishes to.</li>
+ <li>The <code>initDataSources()</code> method can now throw a
+ <code>ServletException</code> to report that an initialization error
+ has occurred. Previously, such errors were logged but otherwise
+ ignored.</li>
+ <li>It is now possible to integrate business logic that is already
+ encapsulated as a servlet or JSP page, via use of two new standard
+ actions: <code>org.apache.struts.actions.ForwardAction</code> and
+ <code>org.apache.struts.actions.IncludeAction</code> These actions
+ let you take advantage of the standard processing perfomed by the
+ controller servlet (including form bean population and calling the
+ <code>validate()</code> method), but not have to write Java code to
+ perform (or wrap) the required business logic.</li>
+ <li>A wrapper class has been added around the standard
+ <code>HttpServletRequest</code> for handling multipart requests as
+ identically as possible to standard requests, including processing
+ request parameters, populating form beans, transaction tokens, and
+ checking for cancellations.</li>
</ul>
<p>The following new features have been added to the
@@ -137,6 +160,17 @@
with a value of <code>true</code>.</li>
<li>The <code><html:options></code> tag now supports Enumeration
for the <code>collection</code> property.</li>
+ <li>The <code><html:form></code> tag now creates attributes for
+ the tag itself, and the form bean, in request scope instead of
+ page scope. Among other benefits, this allows you to nest the
+ fields of a form inside a separate page that is accessed via a
+ template or a <code><jsp:include></code> tag.</li>
+ <li>The <code>styleId</code> attribute has been added to all of the
+ tags where the corresponding <code>id</code> tag is relevant, to
+ identify a specific tag for the purposes of stylesheet references.</li>
+ <li>The <code><html:file></code> tag now supports the
+ <code>size</code> attribute to set the size of the file list
+ field.</li>
</ul>
<p>The following new features have been added to the
@@ -145,6 +179,9 @@
<ul>
<li>The <code><logic:iterate></code> tag now supports Enumeration
for the <code>collection</code> property.</li>
+ <li>The <code><logic:iterate></code> tag now exposes the current
+ iteration index to nested tags, through a call to the
+ <code>getIndex()</code> method.</li>
</ul>
<p>The following new features have been added to the
@@ -153,6 +190,10 @@
<ul>
<li>Attribute getter methods have been added to all of the custom
tag implementation classes to facilitate reuse.</li>
+ <li>The <code><template:get></code> tag now has an optional
+ "flush" attribute that causes the response to be commited prior
+ to performing the include, if set to "true". This allows working
+ around problems on broken servlet containers.</li>
</ul>
<p>The following new features have been added to the Struts Documentation
@@ -168,6 +209,23 @@
<section name="Changes and Bug Fixes" href="Changes">
+ <p>The following changes and bug fixes have occurred in the basic
+ controller framework (package <code>org.apache.struts.action</code>):</p>
+ <ul>
+ <li><code>DiskMultipartRequestHandler</code> now tries to retrieve the
+ temporary directory provided by the servlet container before all other
+ possible temporary directories.</li>
+ </ul>
+
+ <p>The following changes and bug fixes have occurred in the utilities
+ (package <code>org.apache.struts.util</code>):</p>
+ <ul>
+ <li>The <code>computeURL()</code> method now returns a
+ <code>MalformedURLException</code> if a URL cannot be created.
+ Previously, this case returned <code>null</code> with no error
+ message, making some problems difficult to track down.</li>
+ </ul>
+
<p>The following changes and bug fixes have occured in the
<em>struts-html</em> custom tag library (package
<code>org.apache.struts.taglib.html</code>):</p>
@@ -193,6 +251,21 @@
number if it is the default port for the current request scheme (80
for http, or 443 for https). Among other things, this corrects
session management behavior on the standard port numbers.</li>
+ <li>The <code>focus</code> attribute of the <code><html:form></code>
+ tag now works when the corresponding input field is a radio button,
+ or is otherwise indexed.</li>
+ <li>The <code>disabled</code> and <code>readonly</code> attributes have
+ been added to all HTML-rendering tags where they are relevant.</li>
+ </ul>
+
+ <p>The following changes and bug fixes have occurred in the
+ <em>struts-logic</em> custom tag library (package
+ <code>org.apache.struts.taglib.logic</code>):</p>
+ <ul>
+ <li>Hyperlink processing in the <code><logic:forward></code>
+ tag is now identical to that performed by the Struts Controller
+ Servlet when it processes an <code>ActionForward</code> that is
+ returned by an <code>Action</code>.</li>
</ul>
<p>The following changes and bug fixes to the Struts Documentation
@@ -206,7 +279,7 @@
<code>id</code> attribute with the same value in the same page.</li>
</ul>
- <p>The following changes and bug fixes to the Struts Example Applications
+ <p>The following changes and bug fixes to the Struts Example Application
have occurred:</p>
<ul>
<li>The Java source code of these applications is now included in the
@@ -215,8 +288,24 @@
have been eliminated.</li>
<li>Calls to the deprecated <code>BeanUtils.filter()</code> have been
replaced by calls to <code>ResponseUtils.filter()</code>.</li>
+ <li>Removed any attempt to save the pseudo-database at application
+ shutdown, because there is no portable mechanism to accomplish
+ this task.</li>
</ul>
+ <p>The following changes and bug fixes to the Struts Template Example
+ Application have occurred:</p>
+ <ul>
+ <li>Refactored the example pages to eliminate the creation of redundant
+ <code><html></code>, <code><head></code>, and
+ <code><body></code> tags.</li>
+ <li>If <code><template:get></code> or
+ <code><template:insert></code> throws an exception, do not
+ overwrite any "real" exception that has already been saved.</li>
+ <li>The text of the various pages in the example has been updated so
+ that they are not identical.</li>
+ </ul>
+
</section>
| 0
| 7
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
0c52833f19f85825e04d16a3a4b8aad3595ce0e6
|
Initial checkin of the "Declarative Exception Handling" feature (sorry
this took so long). I've incorporated it as presented, based on the
original configuration mechanism, to get it in play as quickly as possible.
It will next be integrated into the new ApplicationConfig approach so that
it works in sub-applications as well.
Submitted by: Laine Donlan <[email protected]>,
Dmitri Valdin <[email protected]>
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48766 13f79535-47bb-0310-9956-ffa450edef68
|
commit 0c52833f19f85825e04d16a3a4b8aad3595ce0e6
Author: Craig R. McClanahan <[email protected]>
Date: Mon Dec 31 01:14:36 2001 +0000
Initial checkin of the "Declarative Exception Handling" feature (sorry
this took so long). I've incorporated it as presented, based on the
original configuration mechanism, to get it in play as quickly as possible.
It will next be integrated into the new ApplicationConfig approach so that
it works in sub-applications as well.
Submitted by: Laine Donlan <[email protected]>,
Dmitri Valdin <[email protected]>
git-svn-id: https://svn.apache.org/repos/asf/struts/trunk@48766 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/conf/share/struts-config_1_1.dtd b/conf/share/struts-config_1_1.dtd
index 9ee3702c4..33633d343 100644
--- a/conf/share/struts-config_1_1.dtd
+++ b/conf/share/struts-config_1_1.dtd
@@ -11,7 +11,7 @@
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
- $Id: struts-config_1_1.dtd,v 1.3 2001/12/27 16:20:59 cedric Exp $
+ $Id: struts-config_1_1.dtd,v 1.4 2001/12/31 01:14:36 craigmcc Exp $
-->
@@ -79,7 +79,7 @@
hierarchy, and contains nested elements for all of the other
configuration settings.
-->
-<!ELEMENT struts-config (data-sources?, form-beans?, global-forwards?, action-mappings?, controller?, message-resources?)>
+<!ELEMENT struts-config (data-sources?, form-beans?, global-exceptions?, global-forwards?, action-mappings?, controller?, message-resources?)>
<!ATTLIST struts-config id ID #IMPLIED>
@@ -157,6 +157,49 @@
<!ATTLIST data-source user CDATA #IMPLIED>
+<!-- The "global-exceptions" element configures the global handling of
+ exceptions thrown by Actions to mappable resources (identified by
+ context-relative URI paths). A global "exception" handler for a
+ particular exception class can be locally overridden by defining an
+ "exception" element with the same "type" attribute.
+-->
+<!ELEMENT global-exceptions (exception*)>
+<!ATTLIST global-exceptions id ID #IMPLIED>
+
+
+<!-- The "exception" element describes a mapping of an exception that may
+ occur during Action delegation and should be handled by the
+ ActionServlet.
+
+ handler Fully qualified Java class name of the exception handler
+ which should handle this exception.
+
+ hierarchical Determines if the exception's class hierarchy should be
+ used to determine the correct handler.
+
+ key Resource bundle key specifying the error message
+ associated with this exception.
+
+ path The context-relative path of the resource to
+ forward to if this exception occurs.
+
+ scope Identifier of the scope ("request" or "session")
+ within which the resulting ActionError will be
+ made accessible
+
+ type Fully qualified Java class name of the exception
+ that is to be handled.
+-->
+<!ELEMENT exception (icon?, display-name?, description?, set-property*)>
+<!ATTLIST exception id ID #IMPLIED>
+<!ATTLIST exception handler %ClassName; "org.apache.struts.action.ExceptionHandler">
+<!ATTLIST exception hierarchical %Boolean; #IMPLIED>
+<!ATTLIST exception key CDATA #IMPLIED>
+<!ATTLIST exception path %RequestPath; #IMPLIED>
+<!ATTLIST exception scope CDATA #IMPLIED>
+<!ATTLIST exception type %ClassName; #REQUIRED>
+
+
<!-- The "form-beans" element is the root of the set of form bean descriptors
for this application. The following attributes are defined:
@@ -327,7 +370,7 @@
should be called prior to calling this action, or set to
"false" if you do not want validation performed.
-->
-<!ELEMENT action (icon?, display-name?, description?, set-property*, forward*)>
+<!ELEMENT action (icon?, display-name?, description?, set-property*, exception*, forward*)>
<!ATTLIST action id ID #IMPLIED>
<!ATTLIST action attribute %BeanName; #IMPLIED>
<!ATTLIST action className %ClassName; #IMPLIED>
diff --git a/src/example/org/apache/struts/webapp/example/ApplicationResources.properties b/src/example/org/apache/struts/webapp/example/ApplicationResources.properties
index 088b07305..ce2a51bb6 100644
--- a/src/example/org/apache/struts/webapp/example/ApplicationResources.properties
+++ b/src/example/org/apache/struts/webapp/example/ApplicationResources.properties
@@ -2,6 +2,9 @@ button.cancel=Cancel
button.confirm=Confirm
button.reset=Reset
button.save=Save
+change.message=Your password has expired. Please ask the system administrator to change it.
+change.try=Try Again
+change.title=Password Has Expired
database.load=Cannot load database from {0}
error.database.missing=<li>User database is missing, cannot validate logon credentials</li>
error.fromAddress.format=<li>Invalid format for From Address</li>
diff --git a/src/example/org/apache/struts/webapp/example/ExpiredPasswordException.java b/src/example/org/apache/struts/webapp/example/ExpiredPasswordException.java
new file mode 100644
index 000000000..d39550a67
--- /dev/null
+++ b/src/example/org/apache/struts/webapp/example/ExpiredPasswordException.java
@@ -0,0 +1,87 @@
+/*
+ * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/ExpiredPasswordException.java,v 1.1 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.1 $
+ * $Date: 2001/12/31 01:14:36 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Struts", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+
+package org.apache.struts.webapp.example;
+
+import org.apache.struts.util.AppException;
+
+/**
+ * Example of an application-specific exception for which a handler
+ * can be configured.
+ */
+
+
+public class ExpiredPasswordException extends AppException {
+
+
+ /**
+ * Construct a new instance of this exception for the specified username.
+ *
+ * @param username Username whose password has expired
+ */
+ public ExpiredPasswordException(String username) {
+ super("error.password.expired", username);
+ }
+
+
+}
+
diff --git a/src/example/org/apache/struts/webapp/example/LogonAction.java b/src/example/org/apache/struts/webapp/example/LogonAction.java
index 10d5cdb28..54d3b8f1c 100644
--- a/src/example/org/apache/struts/webapp/example/LogonAction.java
+++ b/src/example/org/apache/struts/webapp/example/LogonAction.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/LogonAction.java,v 1.2 2001/04/14 12:53:08 rleland Exp $
- * $Revision: 1.2 $
- * $Date: 2001/04/14 12:53:08 $
+ * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/LogonAction.java,v 1.3 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/31 01:14:36 $
*
* ====================================================================
*
@@ -78,6 +78,7 @@ import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
+import org.apache.struts.util.AppException;
import org.apache.struts.util.MessageResources;
@@ -85,7 +86,7 @@ import org.apache.struts.util.MessageResources;
* Implementation of <strong>Action</strong> that validates a user logon.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2001/04/14 12:53:08 $
+ * @version $Revision: 1.3 $ $Date: 2001/12/31 01:14:36 $
*/
public final class LogonAction extends Action {
@@ -106,14 +107,13 @@ public final class LogonAction extends Action {
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
+ * @exception Exception if business logic throws an exception
*/
- public ActionForward perform(ActionMapping mapping,
+ public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException {
+ throws Exception {
// Extract attributes we will need
Locale locale = getLocale(request);
@@ -130,7 +130,7 @@ public final class LogonAction extends Action {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.database.missing"));
else {
- user = (User) database.get(username);
+ user = getUser(database, username, password);
if ((user != null) && !user.getPassword().equals(password))
user = null;
if (user == null)
@@ -165,4 +165,36 @@ public final class LogonAction extends Action {
}
+ // ------------------------------------------------------ Protected Methods
+
+
+ /**
+ * Look up the user, throwing an exception to simulate business logic
+ * rule exceptions.
+ *
+ * @param database Database in which to look up the user
+ * @param username Username specified on the logon form
+ * @param password Password specified on the logon form
+ *
+ * @exception AppException if a business logic rule is violated
+ */
+ public User getUser(Hashtable database, String username, String password)
+ throws AppException {
+
+ // Force an ArithmeticException which can be handled explicitly
+ if ("arithmetic".equals(username)) {
+ int a = 10 / 0;
+ }
+
+ // Force an application-specific exception which can be handled
+ if ("expired".equals(username)) {
+ throw new ExpiredPasswordException(username);
+ }
+
+ // Look up and return the specified user
+ return ((User) database.get(username));
+
+ }
+
+
}
diff --git a/src/share/org/apache/struts/action/Action.java b/src/share/org/apache/struts/action/Action.java
index 24807dec8..efaf2c5ef 100755
--- a/src/share/org/apache/struts/action/Action.java
+++ b/src/share/org/apache/struts/action/Action.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.32 2001/12/29 19:37:28 craigmcc Exp $
- * $Revision: 1.32 $
- * $Date: 2001/12/29 19:37:28 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.33 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.33 $
+ * $Date: 2001/12/31 01:14:36 $
*
* ====================================================================
*
@@ -108,7 +108,7 @@ import org.apache.struts.upload.MultipartRequestHandler;
* by this Action.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.32 $ $Date: 2001/12/29 19:37:28 $
+ * @version $Revision: 1.33 $ $Date: 2001/12/31 01:14:36 $
*/
public class Action {
@@ -320,6 +320,8 @@ public class Action {
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
+ *
+ * @deprecated Use the <code>execute()</code> method instead
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
@@ -352,6 +354,8 @@ public class Action {
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
+ *
+ * @deprecated Use the <code>execute()</code> method instead
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form,
@@ -364,6 +368,31 @@ public class Action {
}
+ /**
+ * Process the specified HTTP request, and create the corresponding HTTP
+ * response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
+ *
+ * @param mapping The ActionMapping used to select this instance
+ * @param form The optional ActionForm bean for this request (if any)
+ * @param request The HTTP request we are processing
+ * @param response The HTTP response we are creating
+ *
+ * @exception Exception if the application business logic throws
+ * an exception
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ // Call the deprecated method
+ return (perform(mapping, form, request, response));
+
+ }
+
+
// ---------------------------------------------------- Protected Methods
diff --git a/src/share/org/apache/struts/action/ActionException.java b/src/share/org/apache/struts/action/ActionException.java
new file mode 100644
index 000000000..f1cef6366
--- /dev/null
+++ b/src/share/org/apache/struts/action/ActionException.java
@@ -0,0 +1,265 @@
+/*
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Attic/ActionException.java,v 1.1 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.1 $
+ * $Date: 2001/12/31 01:14:36 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Struts", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.struts.action;
+
+import java.io.Serializable;
+
+/**
+ * An <strong>ActionException</strong> represents a potential exception
+ * that may occur during delegation to an Action class.
+ * Instances of this class may be configured in association
+ * with an <code>ActionMapping</code> instance for named lookup of potentially
+ * multiple destinations for a particular mapping instance.
+ * <p>
+ * An <code>ActionException</code> has the following minimal set of properties.
+ * Additional properties can be provided as needed by subclassses.
+ * <ul>
+ * <li><strong>type</strong> - The fully qualified class name of the
+ * exception to be associated to a particular <code>ActionMapping</code>.
+ * <li><strong>key</strong> - (Optional) Message key associated with the particular
+ * exception.
+ * <li><strong>path</strong> - (Optional) Context releative URI that should
+ * be redirected to as a result of the exception occuring. Will overide the
+ * input form of the associated ActionMapping if one is provided.
+ * <li><strong>scope</strong> - (Optional) The scope to store the exception in
+ * if a problem should occur - defaults to 'request'. Valid values are
+ * 'request' and 'session'.
+ * <li><strong>hierarchical</strong> - (Optional) Defines whether or not the
+ * Exception hierarchy should be used when determining if an occuring
+ * exception can be assigned to a mapping instance. Default is true.
+ * <li><strong>handler</strong> - (Optional) The fully qualified class name
+ * of the handler, which is responsible to handle this exception.
+ * Default is 'org.apache.struts.action.ExceptionHandler'.
+ * </ul>
+ *
+ * @author ldonlan
+ * @version $Revision: 1.1 $ $Date: 2001/12/31 01:14:36 $
+ */
+public class ActionException implements Serializable {
+
+ /** Holds value of property key. */
+ private String key;
+
+ /** Holds value of property type. */
+ private String type;
+
+ /** Holds value of property path. */
+ private String path;
+
+ /** Holds value of property exClass. */
+ private Class exClass;
+
+ /** Holds value of property hierachal. */
+ private boolean hierarchical = true;
+
+ /** Holds value of property scope. */
+ private String scope = "request";
+
+ /** Holds value of handler. */
+ private String handler;
+
+ /** Holds value of property handlerClass */
+ private Class handlerClass;
+
+ /** Creates new ActionException */
+ public ActionException() {
+
+ }
+
+ /**
+ * Returns the key associated with the exception.
+ * @return Value of property key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Setter for property key.
+ * @param key New value of property key.
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /**
+ * Returns the fully qualified type of the exception
+ * @return Value of property type.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Setter for property type.
+ * @param type New value of property type.
+ * @todo Need to clean up this logging, but don't want to die if
+ * an exception is mistyped, etc.
+ */
+ public void setType(String type){
+ this.type = type;
+ try{
+ exClass = Class.forName(type);
+ }catch(ClassNotFoundException ex){
+ System.out.println("[ActionException] - Could not instantiate: " +
+ ex.getClass() + " " + type);
+ exClass = null;
+ }
+
+ }
+
+ /**
+ * Returns the path associated with the exception.
+ * @return Value of property path.
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Setter for property path.
+ * @param path New value of property path.
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * Getter for property exClass. Will be null if the type could not
+ * be used to create a class instance.
+ * @return Value of property exClass.
+ */
+ public Class getExClass() {
+ return exClass;
+ }
+
+ /** Getter for property hierachal.
+ * @return Value of property hierachal.
+ */
+ public boolean isHierarchical() {
+ return hierarchical;
+ }
+
+ /** Setter for property hierachal.
+ * @param hierarchical */
+ public void setHierarchical(boolean hierarchical) {
+ this.hierarchical = hierarchical;
+ }
+
+ /** Getter for property scope.
+ * @return Value of property scope.
+ */
+ public String getScope() {
+ return scope;
+ }
+
+ /** Setter for property scope.
+ * @param scope New value of property scope.
+ */
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ /**
+ * Returns the fully qualified type of the exception handler
+ * @return Value of property handler.
+ */
+ public String getHandler() {
+ return handler;
+ }
+
+ /**
+ * Setter for property handler.
+ * @param type New value of property handler.
+ * @todo Need to clean up this logging, but don't want to die if
+ * an exception is mistyped, etc.
+ */
+ public void setHandler(String handler){
+ this.handler = handler;
+ try{
+ handlerClass = Class.forName(handler);
+ }catch(ClassNotFoundException ex){
+ System.out.println("[ActionException] - Could not instantiate: " +
+ ex.getClass() + " " + handler);
+ handlerClass = null;
+ }
+ }
+
+
+ /**
+ * Getter for property handler. Will be null if the handler could not
+ * be used to create a class instance.
+ * @return Value of property handlerClass.
+ */
+ public Class getHandlerClass() {
+ return handlerClass;
+ }
+
+ /**
+ *Returns an instance of an <b>ActionError</b> configured for
+ *this exception.
+ *@return ActionError
+ */
+ public ActionError getError() {
+ return new ActionError(this.key);
+ }
+
+}
diff --git a/src/share/org/apache/struts/action/ActionExceptions.java b/src/share/org/apache/struts/action/ActionExceptions.java
new file mode 100644
index 000000000..2b690a877
--- /dev/null
+++ b/src/share/org/apache/struts/action/ActionExceptions.java
@@ -0,0 +1,200 @@
+/*
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Attic/ActionExceptions.java,v 1.1 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.1 $
+ * $Date: 2001/12/31 01:14:36 $
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Struts", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.struts.action;
+
+import java.io.*;
+import java.util.*;
+import org.apache.commons.collections.FastHashMap;
+
+
+/**
+ * Encapsulate a collection of ActionException objects that can be
+ * administered and searched, while hiding the internal implementation.
+ *
+ * @author ldonlan
+ * @version $Revision: 1.1 $ $Date: 2001/12/31 01:14:36 $
+ */
+
+public class ActionExceptions implements Serializable{
+ private static final String APP_EXCEPTION_KEY =
+ "org.apache.struts.util.AppException";
+
+ private static final String APP_EXCEPTION_HANDLER_KEY =
+ "org.apache.struts.action.ExceptionHandler";
+
+ /** Creates new ActionExceptions */
+ public ActionExceptions() {
+ // Register an application exception.
+ addAppException();
+ }
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The collection of ActionForward instances, keyed by logical name.
+ */
+ private FastHashMap exceptions = new FastHashMap();
+
+
+ // ------------------------------------------------------------- Properties
+
+
+ /**
+ * Return the "fast" mode flag.
+ */
+ public boolean getFast() {
+
+ return (exceptions.getFast());
+
+ }
+
+
+ /**
+ * Set the "fast" mode flag.
+ *
+ * @param fast The new fast mode flag
+ */
+ public void setFast(boolean fast) {
+
+ exceptions.setFast(fast);
+
+ }
+
+ /**
+ * Register a logical exception that may occur processing the
+ * maping.
+ *
+ * @param exception The exception to be added
+ */
+ public void addException(ActionException ex){
+ exceptions.put(ex.getType(), ex);
+
+ }
+
+ /**
+ * Return the ActionException associated with the specified class name,
+ * if any; otherwise return <code>null</code>.<p>
+ * The search will consist of first looking for a specific match on
+ * the class provided. If one is not found, all <b>ActionException</b>
+ * objects will be examined. For all objects with the hierarchacal
+ * property set to true, a Class.isAssignableFrom() test will be performed.
+ * The first match to be made will be returned.
+ *
+ * @param name class name of the exception
+ */
+ public ActionException findException(Class type){
+ ActionException ex = null;
+
+ ex = (ActionException)exceptions.get(type.getName());
+
+ //If no exact match was made
+ if (ex == null){
+ //Look through all the A.E's
+ Iterator it = exceptions.values().iterator();
+
+ ActionException current = null;
+ while (it.hasNext()){
+ current = (ActionException)it.next();
+
+ //If there is a hierarchal match and the provided
+ //exception is assignable from it, then return it
+ if (current.isHierarchical()){
+ //Make sure that the class is not null - i.e the
+ //type could not be used to create a class.
+ if (current.getExClass() != null){
+ if (current.getExClass().isAssignableFrom(type)){
+ ex = current;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ex;
+ }
+
+
+ /**
+ *Removes the ActionException with the specified type from the
+ *collection.
+ *
+ */
+ public ActionException remove(String type){
+ return (ActionException)exceptions.remove(type);
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+ /**
+ * Register an application exception
+ */
+ private void addAppException() {
+ ActionException ae = new ActionException();
+ ae.setType(APP_EXCEPTION_KEY);
+ ae.setHandler(APP_EXCEPTION_HANDLER_KEY);
+ addException(ae);
+ }
+
+}
diff --git a/src/share/org/apache/struts/action/ActionMapping.java b/src/share/org/apache/struts/action/ActionMapping.java
index ad7fc9fa2..480c37790 100755
--- a/src/share/org/apache/struts/action/ActionMapping.java
+++ b/src/share/org/apache/struts/action/ActionMapping.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java,v 1.20 2001/11/04 07:42:21 martinc Exp $
- * $Revision: 1.20 $
- * $Date: 2001/11/04 07:42:21 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java,v 1.21 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.21 $
+ * $Date: 2001/12/31 01:14:36 $
*
* ====================================================================
*
@@ -130,7 +130,7 @@ import java.io.Serializable;
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.20 $ $Date: 2001/11/04 07:42:21 $
+ * @version $Revision: 1.21 $ $Date: 2001/12/31 01:14:36 $
*/
public class ActionMapping implements Serializable {
@@ -146,6 +146,12 @@ public class ActionMapping implements Serializable {
protected String attribute = null;
+ /**
+ * The set of ActionException objects associated with this mapping.
+ */
+ protected ActionExceptions exceptions = new ActionExceptions();
+
+
/**
* The context relative path of the servlet or JSP resource (to be called
* via <code>RequestDispatcher.forward()</code>) that will process this
@@ -594,6 +600,18 @@ public class ActionMapping implements Serializable {
// --------------------------------------------------------- Public Methods
+ /**
+ * Add a new <code>ActionException</code> associated with this mapping.
+ *
+ * @param exception The ActionException to be added
+ */
+ public void addException(ActionException exception) {
+
+ exceptions.addException(exception);
+
+ }
+
+
/**
* Add a new <code>ActionForward</code> associated with this mapping.
*
@@ -606,6 +624,35 @@ public class ActionMapping implements Serializable {
}
+ /**
+ * Return the <code>ActionException</code> handler for exceptions of the
+ * specified type.
+ *
+ * @param type Exception class for which to find a handler
+ */
+ public ActionException findException(Class type) {
+
+ // First, check our locally defined exceptions
+ ActionException ex = exceptions.findException(type);
+ if (ex != null) {
+ return (ex);
+ }
+
+ // Second, check the globally defined exceptions
+ ActionMappings mappings = getMappings();
+ if (mappings == null) {
+ return (null);
+ }
+ ActionServlet servlet = mappings.getServlet();
+ if (servlet == null) {
+ return (null);
+ } else {
+ return (servlet.findException(type));
+ }
+
+ }
+
+
/**
* Return the <code>ActionForward</code> with the specified name,
* if any; otherwise return <code>null</code>. If there is no locally
diff --git a/src/share/org/apache/struts/action/ActionServlet.java b/src/share/org/apache/struts/action/ActionServlet.java
index 638d2f51d..61508006f 100755
--- a/src/share/org/apache/struts/action/ActionServlet.java
+++ b/src/share/org/apache/struts/action/ActionServlet.java
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.81 2001/12/29 19:35:32 craigmcc Exp $
- * $Revision: 1.81 $
- * $Date: 2001/12/29 19:35:32 $
+ * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.82 2001/12/31 01:14:36 craigmcc Exp $
+ * $Revision: 1.82 $
+ * $Date: 2001/12/31 01:14:36 $
*
* ====================================================================
*
@@ -238,7 +238,7 @@ import org.xml.sax.SAXException;
*
* @author Craig R. McClanahan
* @author Ted Husted
- * @version $Revision: 1.81 $ $Date: 2001/12/29 19:35:32 $
+ * @version $Revision: 1.82 $ $Date: 2001/12/31 01:14:36 $
*/
public class ActionServlet
@@ -307,6 +307,20 @@ public class ActionServlet
protected final Locale defaultLocale = Locale.getDefault();
+ /**
+ * The Java class name of the <code>ActionException</code> implementation
+ * class to use.
+ */
+ protected String exceptionClass =
+ "org.apache.struts.action.ActionException";
+
+
+ /**
+ * The global exceptions registered with this handler.
+ */
+ protected ActionExceptions exceptions = new ActionExceptions();
+
+
/**
* The Java class name of the <code>MessageResourcesFactory</code>
* class for the application message resources bundle.
@@ -567,6 +581,20 @@ public class ActionServlet
}
+ /**
+ * Add a global exception to the set configured for this servlet.
+ *
+ * @param exception The exception to be added
+ *
+ * @deprecated Will no longer be required with multi-application support
+ */
+ public void addException(ActionException exception) {
+
+ exceptions.addException(exception);
+
+ }
+
+
/**
* Register a form bean definition to the set configured for this servlet.
*
@@ -678,6 +706,21 @@ public class ActionServlet
}
+ /**
+ * Return the exception handler for an exception of the specified
+ * class, if any; otherwise return <code>null</code>.
+ *
+ * @param ex Exception class for which to find a handler
+ *
+ * @deprecated Will no longer be required with multi-application support
+ */
+ public ActionException findException(Class ex) {
+
+ return (exceptions.findException(ex));
+
+ }
+
+
/**
* Return the forwarding associated with the specified logical name,
* if any; otherwise return <code>null</code>.
@@ -1575,6 +1618,16 @@ public class ActionServlet
"addForward",
"org.apache.struts.action.ActionForward");
+ digester.addObjectCreate
+ ("struts-config/action-mappings/action/exception",
+ exceptionClass, "className");
+ digester.addSetProperties
+ ("struts-config/action-mappings/action/exception");
+ digester.addSetNext
+ ("struts-config/action-mappings/action/exception",
+ "addException",
+ "org.apache.struts.action.ActionException");
+
digester.addSetProperty
("struts-config/action-mappings/action/forward/set-property",
"property", "value");
@@ -1590,6 +1643,17 @@ public class ActionServlet
("struts-config/form-beans/form-bean/set-property",
"property", "value");
+ digester.addObjectCreate("struts-config/global-exceptions/exception",
+ exceptionClass, "className");
+ digester.addSetProperties("struts-config/global-exceptions/exception");
+ digester.addSetNext("struts-config/global-exceptions/exception",
+ "addException",
+ "org.apache.struts.action.ActionException");
+
+ digester.addSetProperty
+ ("struts-config/global-exceptions/exception/set-property",
+ "property", "value");
+
digester.addObjectCreate("struts-config/global-forwards/forward",
forwardClass, "className");
digester.addSetProperties("struts-config/global-forwards/forward");
@@ -2160,9 +2224,24 @@ public class ActionServlet
HttpServletResponse response)
throws IOException, ServletException {
- ActionForward forward =
- action.perform(mapping, formInstance, request, response);
- return (forward);
+ // ActionForward forward =
+ // action.perform(mapping, formInstance, request, response);
+ // return (forward);
+
+ ActionError error = null;
+ Throwable cause = null;
+ try {
+ ActionForward forward =
+ action.execute(mapping, formInstance, request, response);
+ return (forward);
+ } catch (Exception ex) {
+ if (debug >= 1) {
+ log("Exception occurred", ex);
+ }
+ return (processException(ex, mapping, formInstance,
+ request, response));
+ }
+
}
@@ -2182,6 +2261,56 @@ public class ActionServlet
}
+ /**
+ * Ask our exception handler to handle the exception. Return the
+ * <code>ActionForward</code> instance (if any) returned by the called
+ * <code>ExceptionHandler</code>.
+ *
+ * @param ex The exception to handle
+ * @param maping The ActionMapping we are processing
+ * @param form The ActionForm we are processing (if any)
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are processing
+ *
+ * @exception ServletException if a servlet exception occurs
+ */
+ protected ActionForward processException(Exception ex,
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException {
+
+ // Look for an exception mapping
+ ActionException ae = mapping.findException(ex.getClass());
+
+ // If one is found, place it in the scope defined
+ if (ae != null) {
+ Class handlerClass = ae.getHandlerClass();
+ try {
+ // Ask handler to handle the exception
+ ExceptionHandler handler = (ExceptionHandler)
+ handlerClass.newInstance();
+ return (handler.execute(ex, ae, mapping, form,
+ request, response));
+ } catch (Exception e) {
+ // Yuck - the exception handler thew an exception
+ throw new ServletException(e);
+ }
+ } else {
+ if (debug >= 1) {
+ log(internal.getMessage("unhandledException", ex.getClass()));
+ }
+ if (ex instanceof ServletException) {
+ throw (ServletException) ex;
+ }
+ throw new ServletException(ex);
+ }
+
+ }
+
+
+
/**
* Process a forward requested by this mapping, if any. Return
* <code>true</code> if processing of this request should continue (i.e.
diff --git a/src/share/org/apache/struts/action/ExceptionHandler.java b/src/share/org/apache/struts/action/ExceptionHandler.java
new file mode 100644
index 000000000..d38ade9ac
--- /dev/null
+++ b/src/share/org/apache/struts/action/ExceptionHandler.java
@@ -0,0 +1,158 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Struts", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.struts.action;
+
+import java.util.Locale;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionException;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.util.AppException;
+
+
+public class ExceptionHandler {
+ /**
+ * Handle the exception.
+ * Return the <code>ActionForward</code> instance (if any) returned by
+ * the called <code>ExceptionHandler</code>.
+ *
+ * @param ex The exception to handle
+ * @param ae The ActionException corresponding to the exception
+ * @param mapping The ActionMapping we are processing
+ * @param formInstance The ActionForm we are processing
+ * @param request The servlet request we are processing
+ * @param response The servlet response we are creating
+ *
+ * @exception ServletException if a servlet exception occurs
+ */
+ protected ActionForward execute(Exception ex,
+ ActionException ae,
+ ActionMapping mapping,
+ ActionForm formInstance,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException {
+
+ ActionForward forward = null;
+ ActionError error = null;
+ String property = null;
+
+ String path;
+
+ // Build the forward from the exception mapping if it exists
+ // or from the form input
+ if (ae.getPath() != null) {
+ path = ae.getPath();
+ } else {
+ path = mapping.getInput();
+ }
+
+ // Generate the forward
+ forward = new ActionForward(path);
+
+ // Figure out the error
+ if (ex instanceof AppException) {
+ error = ((AppException) ex).getError();
+ property = ((AppException) ex).getProperty();
+ } else {
+ error = ae.getError();
+ property = error.getKey();
+ }
+
+ // Store the exception
+ storeException(request, property, error, forward, ae.getScope());
+
+ return forward;
+ }
+
+ /**
+ * Default implementation for handling an <b>ActionError</b> generated
+ * from an Exception during <b>Action</b> delegation. The default
+ * implementation is to set an attribute of the request or session, as
+ * defined by the scope provided (the scope from the exception mapping). An
+ * <b>ActionErrors</b> instance is created, the error is added to the collection
+ * and the collection is set under the Action.ERROR_KEY.
+ *
+ * @param request
+ * @param error - The error generated from the exception mapping
+ * @param input - The forward generated from the input path (from the form or exception mapping)
+ * @param scope - The scope of the exception mapping.
+ *
+ */
+ protected void storeException(HttpServletRequest request,
+ String property,
+ ActionError error,
+ ActionForward forward,
+ String scope) {
+ ActionErrors errors = new ActionErrors();
+ errors.add(property, error);
+
+ if ("request".equals(scope)){
+ request.setAttribute(Action.ERROR_KEY, errors);
+ } else {
+ request.getSession().setAttribute(Action.ERROR_KEY, errors);
+ }
+ }
+
+}
+
diff --git a/src/share/org/apache/struts/util/AppException.java b/src/share/org/apache/struts/util/AppException.java
new file mode 100644
index 000000000..8b2f29f68
--- /dev/null
+++ b/src/share/org/apache/struts/util/AppException.java
@@ -0,0 +1,154 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Struts", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact [email protected].
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.struts.util;
+
+import java.util.Locale;
+
+import org.apache.struts.action.ActionError;
+
+
+public class AppException extends Exception {
+ private String property = null;
+ private ActionError error = null;
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Construct an application exception with no replacement values.
+ *
+ * @param key Message key for this error message
+ */
+ public AppException(String key) {
+ super(key);
+ error = new ActionError(key);
+ }
+
+ /**
+ * Construct an application exception with the specified replacement values.
+ *
+ * @param key Message key for this error message
+ * @param value0 First replacement value
+ */
+ public AppException(String key, Object value) {
+ super(key);
+ error = new ActionError(key, value);
+ }
+
+ /**
+ * Construct an application exception with the specified replacement values.
+ *
+ * @param key Message key for this error message
+ * @param value0 First replacement value
+ * @param value1 Second replacement value
+ */
+ public AppException(String key, Object value0, Object value1) {
+ super(key);
+ error = new ActionError(key, value0, value1);
+ }
+
+ /**
+ * Construct an application exception with the specified replacement values.
+ *
+ * @param key Message key for this error message
+ * @param value0 First replacement value
+ * @param value1 Second replacement value
+ * @param value2 Third replacement value
+ */
+ public AppException(String key, Object value0, Object value1, Object value2) {
+ super(key);
+ error = new ActionError(key, value0, value1, value2);
+ }
+
+ /**
+ * Construct an application exception with the specified replacement values.
+ *
+ * @param key Message key for this error message
+ * @param value0 First replacement value
+ * @param value1 Second replacement value
+ * @param value2 Third replacement value
+ * @param value3 Fourth replacement value
+ */
+ public AppException(String key, Object value0, Object value1, Object value2, Object value3) {
+ super(key);
+ error = new ActionError(key, value0, value1, value2, value3);
+ }
+
+ // -------------------------------------------------------- Public Methods
+
+ /**
+ * Returns the property associated with the exception.
+ * @return Value of property.
+ */
+ public String getProperty() {
+ return (property != null) ? property : error.getKey();
+ }
+
+ /**
+ * Set the property associated with the exception.
+ * It can be a name of the edit field, which 'caused' the exception.
+ */
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ /**
+ * Returns the error associated with the exception.
+ * @return Value of property error.
+ */
+ public ActionError getError() {
+ return error;
+ }
+}
diff --git a/web/example/WEB-INF/struts-config.xml b/web/example/WEB-INF/struts-config.xml
index c2def6d44..51e77de75 100644
--- a/web/example/WEB-INF/struts-config.xml
+++ b/web/example/WEB-INF/struts-config.xml
@@ -103,6 +103,9 @@
name="logonForm"
scope="request"
input="/logon.jsp">
+ <exception
+ type="org.apache.struts.webapp.example.ExpiredPasswordException"
+ path="/changePassword.jsp"/>
</action>
<!-- Save user registration -->
diff --git a/web/example/changePassword.jsp b/web/example/changePassword.jsp
new file mode 100644
index 000000000..cf1b4d460
--- /dev/null
+++ b/web/example/changePassword.jsp
@@ -0,0 +1,18 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
+<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
+
+<html:html locale="true">
+<head>
+<title><bean:message key="change.title"/></title>
+<html:base/>
+</head>
+<body bgcolor="white">
+
+<bean:message key="change.message"/>
+<html:link page="/logon.jsp">
+ <bean:message key="change.try"/>
+</html:link>
+
+</body>
+</html:html>
| 0
| 4
|
CVE-2005-3745
|
Cross-site scripting (XSS) vulnerability in Apache Struts 1.2.7, and possibly other versions allows remote attackers to inject arbitrary web script or HTML via the query string, which is not properly quoted or filtered when the request handler generates an error message.
|
apache/struts1
|
bbacb93047499aa5694058ec5379ed7b68420662
|
Moved ssl page from taglib to core.
git-svn-id: https://svn.apache.org/repos/asf/struts/core/trunk@332197 13f79535-47bb-0310-9956-ffa450edef68
|
commit bbacb93047499aa5694058ec5379ed7b68420662
Author: Wendy Smoak <[email protected]>
Date: Thu Nov 10 02:11:47 2005 +0000
Moved ssl page from taglib to core.
git-svn-id: https://svn.apache.org/repos/asf/struts/core/trunk@332197 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/xdocs/ssl.xml b/xdocs/ssl.xml
new file mode 100644
index 000000000..6cf6264b9
--- /dev/null
+++ b/xdocs/ssl.xml
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<!--
+Copyright 1999-2005 The Apache Software Foundation
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<!--
+// ======================================================================== 78
+-->
+<document>
+
+<properties>
+ <title>Secure Socket Layer and Web Applications </title>
+</properties>
+
+<body>
+
+<section href="ssl" name="Secure Socket Layer and Web Applications">
+
+<a name="overview"/>
+<subsection name="Overview">
+
+<p>
+Many web applications, especially those deployed for e-commerce, necessitate the
+transmission of sensitive data between the web server and the client browser. This data
+may include passwords, credit card numbers, bank account numbers or any other
+information that users would not want to divulge to the general public. To protect
+sensitive data during transmission, application developers typically use the Secure
+Sockets Layer (SSL) and its companion protocol, HTTP over Secure Sockets Layer
+(HTTPS). HTTPS employs SSL to protect data by encrypting it at the source, be it the
+server or the client, and decrypting it at the destination. This prevents anyone monitoring
+Internet data transmissions from easily capturing this data. The client and server
+exchange public keys to enable encryption and decryption to occur.
+</p>
+
+<p>
+The encryption/decryption process comes at a performance price, however. The
+throughput of data for a web server transmitting via HTTPS is often as little as one-tenth
+that of data transmission via HTTP. For this reason, it is undesirable to deploy an entire
+web application under SSL. For fastest performance, it is best to deploy a web
+application under HTTP and employ HTTPS only for those pages and processes that
+transmit sensitive data.
+</p>
+
+</subsection>
+
+<a name="mixing"/>
+<subsection name="Mixing Protocols in Web Applications">
+
+<p>
+Switching back and forth between the two protocols can require hard-coding the protocol
+and full URL in every link to each resource in the web application. This creates an
+ongoing maintenance headache for developers each time a server name changes or secure
+protocol requirements change for resources in the web app.
+</p>
+
+<p>
+Another significant hazard is that there is nothing to prevent a user from specifying the
+wrong protocol by manually entering a URL into the browser. The penalty for manually
+specifying HTTPS for a page or servlet that does not require HTTPS is reduced
+performance. Far worse is the penalty for manually specifying HTTP for non-secure
+access of a page that does require HTTPS: public exposure of sensitive data.
+</p>
+
+</subsection>
+
+<a name="help"/>
+<subsection name="Help from Deployment Descriptor">
+
+<p>
+To help overcome the problem of non-secure access of sensitive data, the Java Servlet
+Specification (versions 2.2 and 2.3) defines the transport-guarantee element of the
+web.xml deployment descriptor file. The transport-guarantee element must specify one
+of three types of protection for communication between client and server: NONE,
+INTEGRAL, or CONFIDENTIAL. For most containers a specification of INTEGRAL
+or CONFIDENTIAL is treated as a requirement for SSL usage. Web application
+containers will prevent users from accessing web resources over HTTP if they have been
+so specified.
+</p>
+
+<p>
+The implementation for blocking HTTP access to web resources specified as INTEGRAL
+or CONFIDENTIAL varies from container to container. If a user attempts to access such
+a resource over HTTP, some containers will present that user with an error message
+instructing them to use the HTTPS protocol for accessing the requested resource. Other
+containers will actually redirect the request using the HTTPS protocol, but then continue
+using the HTTPS protocol for all subsequent requests, even those for resources with a
+transport-guarantee specification of NONE.
+</p>
+
+</subsection>
+
+<a name="sslext"/>
+<subsection name="The sslext Struts Extension">
+
+<p>
+An extension to Struts 1.1, named sslext, helps solve many of these issues for Struts
+developers. It extends the ActionConfig class, RequestProcessor, and Plugin classes to
+define a framework where developers may specify the transmission protocol behavior for
+Struts applications. Within the Struts configuration file, developers specify which action
+requests require HTTPS transmission and which should use HTTP. Developers can also
+specify whether to redirect "improperly-protocoled" requests to the correct protocol.
+</p>
+
+<p>
+In addition to these extensions, the <html:link> and the <html:form> tags have been
+extended. In these extensions, the Struts actions specified in either of these tags are
+analyzed to determine the protocol that should be used in requesting that action. The
+HTML generated by these tags will specify the proper protocol. An additional custom
+tag is defined for allowing users to specify the transmission protocol for an individual
+JSP. This is most often used for form-based authentication pages.
+</p>
+
+<p>
+The sslext library may be obtained from <a href="http://sslext.sourceforge.net">
+http://sslext.sourceforge.net</a>
+</p>
+
+</subsection>
+
+<a name="legacy"/>
+<subsection name="Legacy Browser Issue">
+
+<p>
+One additional complication faced by developers of web applications is that some
+browsers (e.g. pre-6.0 versions of Netscape Navigator) will treat requests to different
+protocols and ports on the same server as requests to different domains. This causes
+these browsers to initiate a new session each time a different protocol or port is specified
+in a request. This problem can only be solved at the container level. Some containers
+have a "session domain" or "cookie domain" configuration parameter to allow the session
+to be shared across different servers in the same domain. As an example, the Weblogic
+Server has a "CookieDomain" property configured in its weblogic.xml deployment
+descriptor. Thankfully, the effects of this problem are diminishing as people upgrade
+their browsers to the current versions.
+</p>
+
+</subsection>
+
+<a name="containers"/>
+<subsection name="Configuring Containers for SSL">
+
+The procedure for configuring SSL for a container will be specific to that container. The
+procedure for enabling SSL for Tomcat can be found
+<a href="http://jakarta.apache.org/tomcat/tomcat-4.1-doc/ssl-howto.html">here</a>.
+
+</subsection>
+
+</section></body></document>
| 0
| 8
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 41