equals(s2));
}
private final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// Returns a random number from 0 to n-1 inclusive.
private int randomInt(int n) {
return((int)(Math.random() * n));
}
// A random letter from the alphabet.
private char randomLetter() {
return(ALPHABET.charAt(randomInt(ALPHABET.length())));
}
}
Listing 4.5 web.xml (from stocks Web app)
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
StockTip
stocks.StockTip
StockTip
/stockTip
Listing 4.4 StockTip.java (continued)
Chapter 4 ?– Programmatic Security 194
Figure 4??“3 When the browser first receives the 401 (Unauthorized) status code, it
opens a dialog box to collect the username and password.
Figure 4??“4 Result of cancelled authorization attempt with Tomcat??”Tomcat returns an
error page along with the 401 (Unauthorized) status code.
Figure 4??“5 Result of successful authorization attempt. Invest now!
4.5 Using Programmatic Security with SSL 195
4.5 Using Programmatic
Security with SSL
SSL can be used with security that is entirely servlet managed, just as it can be with
container-managed security (see Section 3.
Pages:
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243