| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package javax.security.auth.message; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
public class MessagePolicy { |
| 23 | |
|
| 24 | |
private final TargetPolicy[] targetPolicies; |
| 25 | |
private final boolean mandatory; |
| 26 | |
|
| 27 | 0 | public MessagePolicy(TargetPolicy[] targetPolicies, boolean mandatory) throws IllegalArgumentException { |
| 28 | 0 | if (targetPolicies == null) { |
| 29 | 0 | throw new IllegalArgumentException("targetPolicies is null"); |
| 30 | |
} |
| 31 | 0 | this.targetPolicies = targetPolicies; |
| 32 | 0 | this.mandatory = mandatory; |
| 33 | 0 | } |
| 34 | |
|
| 35 | |
public TargetPolicy[] getTargetPolicies() { |
| 36 | 0 | if (targetPolicies.length == 0) { |
| 37 | 0 | return null; |
| 38 | |
} |
| 39 | 0 | return targetPolicies; |
| 40 | |
} |
| 41 | |
|
| 42 | |
public boolean isMandatory() { |
| 43 | 0 | return mandatory; |
| 44 | |
} |
| 45 | |
|
| 46 | |
public static interface ProtectionPolicy { |
| 47 | |
|
| 48 | |
static String AUTHENTICATE_CONTENT = "#authenticateContent"; |
| 49 | |
static String AUTHENTICATE_RECIPIENT = "#authenticateRecipient"; |
| 50 | |
static String AUTHENTICATE_SENDER = "#authenticateSender"; |
| 51 | |
|
| 52 | |
String getID(); |
| 53 | |
} |
| 54 | |
|
| 55 | |
public static interface Target { |
| 56 | |
|
| 57 | |
Object get(MessageInfo messageInfo); |
| 58 | |
|
| 59 | |
void put(MessageInfo messageInfo, Object data); |
| 60 | |
|
| 61 | |
void remove(MessageInfo messageInfo); |
| 62 | |
} |
| 63 | |
|
| 64 | |
public static class TargetPolicy { |
| 65 | |
|
| 66 | |
private final Target[] targets; |
| 67 | |
private final ProtectionPolicy protectionPolicy; |
| 68 | |
|
| 69 | 0 | public TargetPolicy(Target[] targets, ProtectionPolicy protectionPolicy) throws IllegalArgumentException { |
| 70 | 0 | if (protectionPolicy == null) { |
| 71 | 0 | throw new IllegalArgumentException("protectionPolicy is null"); |
| 72 | |
} |
| 73 | 0 | this.targets = targets; |
| 74 | 0 | this.protectionPolicy = protectionPolicy; |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
public Target[] getTargets() { |
| 78 | 0 | if (targets == null || targets.length == 0) { |
| 79 | 0 | return null; |
| 80 | |
} |
| 81 | 0 | return targets; |
| 82 | |
} |
| 83 | |
|
| 84 | |
public ProtectionPolicy getProtectionPolicy() { |
| 85 | 0 | return protectionPolicy; |
| 86 | |
} |
| 87 | |
} |
| 88 | |
} |