%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.security.SecurityPolicies |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.security; |
|
18 | ||
19 | import java.security.Policy; |
|
20 | import java.util.ArrayList; |
|
21 | import java.util.List; |
|
22 | ||
23 | /** |
|
24 | * <p> |
|
25 | * This class is used to hold the security that will be used when applying security policies. It |
|
26 | * uses a singleton pattern to maintain state of the policies configured in the consuming engine. |
|
27 | * </p> |
|
28 | * |
|
29 | * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a> |
|
30 | */ |
|
31 | public class SecurityPolicies |
|
32 | { |
|
33 | /** The singleton instance. */ |
|
34 | 0 | private static SecurityPolicies instance = null; |
35 | ||
36 | /** The list of wrapped policies. */ |
|
37 | 0 | private List wrappedPolicies = new ArrayList(); |
38 | ||
39 | /** The list of policies. */ |
|
40 | 0 | private List policies = new ArrayList(); |
41 | ||
42 | /** The list of used policies. */ |
|
43 | 0 | private List usedPolicies = new ArrayList(); |
44 | ||
45 | /** |
|
46 | * Default contructor. Private to force singleton. |
|
47 | */ |
|
48 | private SecurityPolicies() |
|
49 | 0 | { |
50 | 0 | } |
51 | ||
52 | /** |
|
53 | * <p> |
|
54 | * Returns the singleton instance for SecurityPolicies. |
|
55 | * </p> |
|
56 | * |
|
57 | * @return The instance of SecurityPolicies |
|
58 | */ |
|
59 | public static SecurityPolicies getInstance() |
|
60 | { |
|
61 | 0 | if (instance == null) |
62 | { |
|
63 | 0 | instance = new SecurityPolicies(); |
64 | } |
|
65 | 0 | return instance; |
66 | } |
|
67 | ||
68 | /** |
|
69 | * <p> |
|
70 | * Adds a policy to the list of policies to enforces. |
|
71 | * </p> |
|
72 | * |
|
73 | * @param wrappedPolicy The {@link PolicyWrapper} to add. |
|
74 | */ |
|
75 | public void addPolicy(PolicyWrapper wrappedPolicy) |
|
76 | { |
|
77 | 0 | if (null != wrappedPolicy) |
78 | { |
|
79 | 0 | wrappedPolicies.add(wrappedPolicy); |
80 | 0 | policies.add(wrappedPolicy.getPolicy()); |
81 | 0 | if (wrappedPolicy.isUseAsPolicy()) |
82 | { |
|
83 | 0 | usedPolicies.add(wrappedPolicy.getPolicy()); |
84 | } |
|
85 | } |
|
86 | ||
87 | 0 | } |
88 | ||
89 | /** |
|
90 | * <p> |
|
91 | * Returns the security policies to enforce as list of {@link Policy}. |
|
92 | * </p> |
|
93 | * |
|
94 | * @return The policies. |
|
95 | */ |
|
96 | public List getPolicies() |
|
97 | { |
|
98 | 0 | return policies; |
99 | } |
|
100 | ||
101 | /** |
|
102 | * <p> |
|
103 | * Returns the security policies to be enforced as list of {@link Policy}. |
|
104 | * </p> |
|
105 | * |
|
106 | * @return The used policies. |
|
107 | */ |
|
108 | public List getUsedPolicies() |
|
109 | { |
|
110 | 0 | return usedPolicies; |
111 | } |
|
112 | ||
113 | /** |
|
114 | * <p> |
|
115 | * Returns the security policies to enforce as list of {@link PolicyWrapper}. |
|
116 | * </p> |
|
117 | * |
|
118 | * @return The policies. |
|
119 | */ |
|
120 | public List getWrappedPolicies() |
|
121 | { |
|
122 | 0 | return wrappedPolicies; |
123 | } |
|
124 | ||
125 | /** |
|
126 | * <p> |
|
127 | * Removes a policy from the list of policies to enforces. |
|
128 | * </p> |
|
129 | * |
|
130 | * @param policy The {@link Policy} to add. |
|
131 | */ |
|
132 | public void removePolicy(PolicyWrapper policy) |
|
133 | { |
|
134 | 0 | wrappedPolicies.remove(policy); |
135 | 0 | } |
136 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |