KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > deploy > SecurityConstraintDecorator


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.web.deploy;
24
25 import org.apache.catalina.deploy.SecurityCollection;
26 import com.sun.enterprise.deployment.web.SecurityConstraint;
27 import com.sun.enterprise.deployment.web.SecurityRole;
28 import com.sun.enterprise.web.WebModule;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.Collections JavaDoc;
32 import java.util.Enumeration JavaDoc;
33 /**
34  * Decorator of class <code>org.apache.catalina.deploy.SecurityConstraint</code>
35  *
36  * @author Jean-Francois Arcand
37  */

38 public class SecurityConstraintDecorator
39                     extends org.apache.catalina.deploy.SecurityConstraint {
40
41     private SecurityConstraint securityConstraint;
42     
43     public SecurityConstraintDecorator(SecurityConstraint securityConstraint,
44                                        WebModule webModule){
45         this.securityConstraint = securityConstraint;
46         
47         if (securityConstraint.getAuthorizationConstraint() != null){
48             setAuthConstraint(true);
49             Enumeration JavaDoc enumeration = securityConstraint
50                             .getAuthorizationConstraint().getSecurityRoles();
51
52             SecurityRole securityRole;
53             while (enumeration.hasMoreElements()){
54                 securityRole = (SecurityRole)enumeration.nextElement();
55                 super.addAuthRole(securityRole.getName());
56                 if ( !securityRole.getName().equals("*")){
57                     webModule.addSecurityRole(securityRole.getName());
58                 }
59             }
60             setDisplayName(securityConstraint.getAuthorizationConstraint().getName());
61         }
62  
63         if (securityConstraint.getUserDataConstraint() != null){
64             setUserConstraint(securityConstraint.getUserDataConstraint()
65                                                     .getTransportGuarantee());
66         }
67         
68     }
69
70 }
71
72
73
74
Popular Tags