1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */1718packageorg.apache.jetspeed.security.impl;
1920import java.security.CodeSource;
21import java.security.Permission;
22import java.security.PermissionCollection;
23import java.security.Policy;
24import java.security.ProtectionDomain;
2526/***27 * <p>28 * Provide coordination between the default policy and Jetspeed custom policy.29 * </p>30 */31publicclassJaasPolicyCoordinatorextends Policy
32 {
33privatefinal Policy defaultPolicy;
3435privatefinal Policy j2Policy;
3637/***38 * <p>39 * Constructor for coordinating the policies.40 * </p>41 * 42 * @param defaultPolicy The default policy.43 * @param j2Policy Jetspeed policy.44 */45publicJaasPolicyCoordinator(Policy defaultPolicy, Policy j2Policy)
46 {
47this.defaultPolicy = defaultPolicy;
48this.j2Policy = j2Policy;
49 }
5051/***52 * @see java.security.Policy#getPermissions(java.security.CodeSource)53 */54public PermissionCollection getPermissions(CodeSource codeSource)
55 {
56return defaultPolicy.getPermissions(codeSource);
57 }
5859/***60 * @see java.security.Policy#refresh()61 */62publicvoid refresh()
63 {
64 defaultPolicy.refresh();
65 j2Policy.refresh();
66 }
6768/***69 * @see java.security.Policy#implies(java.security.ProtectionDomain, java.security.Permission)70 */71publicboolean implies(ProtectionDomain domain, Permission permission)
72 {
73if (permission.getClass().getName().startsWith("java"))
74 {
75return defaultPolicy.implies(domain, permission);
76 }
77else78 {
79return j2Policy.implies(domain, permission);
80 }
81 }
82 }