Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
XacmlStatus |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch) | |
3 | * All rights reserved. | |
4 | * | |
5 | * Licensed under the Open Permis License which accompanies this distribution, | |
6 | * and is available at http://www.openpermis.org/BSDlicenceKent.txt | |
7 | */ | |
8 | package org.openpermis.xacml.io; | |
9 | ||
10 | ||
11 | /** | |
12 | * | |
13 | * @since 0.4.0 | |
14 | */ | |
15 | public class XacmlStatus { | |
16 | ||
17 | //---- Static | |
18 | ||
19 | /** | |
20 | * Status header. | |
21 | * @since 0.4.0 | |
22 | */ | |
23 | public static final String STATUS = "urn:oasis:names:tc:xacml:1.0:status:"; | |
24 | ||
25 | /** | |
26 | * Indicates success. | |
27 | * @since 0.4.0 | |
28 | */ | |
29 | public static final String OK = STATUS + "ok"; | |
30 | ||
31 | /** | |
32 | * Indicates that all the attributes necessary to make a policy decision were not available. | |
33 | * @since 0.4.0 | |
34 | */ | |
35 | public static final String MISSING_ATTRIBUTE = STATUS + "missing-attribute"; | |
36 | ||
37 | /** | |
38 | * Indicates that some attribute value contained a syntax error. | |
39 | * @since 0.4.0 | |
40 | */ | |
41 | public static final String SYNTAX_ERROR = STATUS + "syntax-error"; | |
42 | ||
43 | /** | |
44 | * Indicates that an error occurred during policy evaluation. An example would be division by | |
45 | * zero. | |
46 | * @since 0.4.0 | |
47 | */ | |
48 | public static final String PROCESSING_ERROR = STATUS + "processing-error"; | |
49 | ||
50 | //---- State | |
51 | ||
52 | private String code; | |
53 | ||
54 | private String message; | |
55 | ||
56 | //---- Constructors | |
57 | ||
58 | /** | |
59 | * Creates a new status with code. | |
60 | * @param code the status code. | |
61 | * @since 0.4.0 | |
62 | */ | |
63 | 4 | public XacmlStatus (String code) { |
64 | 4 | if (code == null) { |
65 | 0 | throw new IllegalArgumentException("Code is null."); |
66 | } | |
67 | 4 | this.code = code; |
68 | 4 | this.message = null; |
69 | 4 | } |
70 | ||
71 | /** | |
72 | * Creates a new status with code and detailed message. | |
73 | * @param code the status code. | |
74 | * @param message the status message. | |
75 | * @since 0.4.0 | |
76 | */ | |
77 | public XacmlStatus (String code, String message) { | |
78 | 2 | this(code); |
79 | 2 | if (message == null) { |
80 | 0 | throw new IllegalArgumentException("Message is null"); |
81 | } | |
82 | 2 | this.message = message; |
83 | 2 | } |
84 | ||
85 | //---- Methods | |
86 | ||
87 | /** | |
88 | * Returns the code. | |
89 | * @return the code. | |
90 | * @since 0.4.0 | |
91 | */ | |
92 | public String getCode () { | |
93 | 4 | return this.code; |
94 | } | |
95 | ||
96 | /** | |
97 | * Returns the message. | |
98 | * @return the message. | |
99 | * @since 0.4.0 | |
100 | */ | |
101 | public String getMessage () { | |
102 | 6 | return this.message; |
103 | } | |
104 | ||
105 | } |