File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\security\csrf\CrumbIssuerDescriptor.java.html

1 /**
2 * Copyright (c) 2008-2009 Yahoo! Inc.
3 * All rights reserved.
4 * The copyrights to the contents of this file are licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
5 */
6 package hudson.security.csrf;
7
8 import hudson.Util;
9 import hudson.model.Descriptor;
10
11 /**
12 * Describes global configuration for crumb issuers. Create subclasses to specify
13 * additional global configuration for custom crumb issuers.
14 *
15 * @author dty
16 */
17 public abstract class CrumbIssuerDescriptor<T extends CrumbIssuer> extends Descriptor<CrumbIssuer> {
18
19 private String crumbSalt;
20 private String crumbRequestField;
21
22 /**
23 * Crumb issuers always take a salt and a request field name.
24 *
25 * @param salt Salt value
26 * @param crumbRequestField Request parameter name containing crumb from previous response
27 */
28 protected CrumbIssuerDescriptor(String salt, String crumbRequestField) {
29 setCrumbSalt(salt);
30 setCrumbRequestField(crumbRequestField);
31 }
32
33 /**
34 * Get the salt value.
35 * @return
36 */
37 public String getCrumbSalt() {
38 return crumbSalt;
39 }
40
41 /**
42 * Set the salt value. Must not be null.
43 * @param salt
44 */
45 public void setCrumbSalt(String salt) {
46 if (Util.fixEmptyAndTrim(salt) == null) {
47 crumbSalt = "hudson.crumb";
48 } else {
49 crumbSalt = salt;
50 }
51 }
52
53 /**
54 * Gets the request parameter name that contains the crumb generated from a
55 * previous response.
56 *
57 * @return
58 */
59 public String getCrumbRequestField() {
60 return crumbRequestField;
61 }
62
63 /**
64 * Set the request parameter name. Must not be null.
65 *
66 * @param requestField
67 */
68 public void setCrumbRequestField(String requestField) {
69 if (Util.fixEmptyAndTrim(requestField) == null) {
70 crumbRequestField = ".crumb";
71 } else {
72 crumbRequestField = requestField;
73 }
74 }
75 }
76