KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > SecurityConstraintImpl


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.deployment;
24
25 import com.sun.enterprise.deployment.web.SecurityConstraint;
26 import com.sun.enterprise.deployment.web.UserDataConstraint;
27 import com.sun.enterprise.deployment.web.AuthorizationConstraint;
28 import com.sun.enterprise.deployment.web.WebResourceCollection;
29
30 import java.util.*;
31
32
33     /**
34     * Objects exhibiting this interface represent a security constraint on the web application
35     * that owns them.
36     * @author Danny Coward
37     */

38
39 public class SecurityConstraintImpl extends Descriptor implements SecurityConstraint, java.io.Serializable JavaDoc {
40     private Set webResourceCollections;
41     private AuthorizationConstraint authorizationConstraint;
42     private UserDataConstraint userDataConstraint;
43     
44     /** Default constructor.*/
45     public SecurityConstraintImpl() {
46     
47     }
48     
49     /** Copy constructor.*/
50     public SecurityConstraintImpl(SecurityConstraintImpl other) {
51     this.webResourceCollections = new HashSet(other.webResourceCollections);
52     if (other.authorizationConstraint != null) {
53         this.authorizationConstraint = new AuthorizationConstraintImpl((AuthorizationConstraintImpl) other.authorizationConstraint);
54     }
55     if (other.userDataConstraint != null) {
56         this.userDataConstraint = new UserDataConstraintImpl();
57         this.userDataConstraint.setTransportGuarantee(other.userDataConstraint.getTransportGuarantee());
58     }
59     }
60     
61     
62     /** Return all the web resource collection.
63     */

64     public Set getWebResourceCollectionSet() {
65     if (this.webResourceCollections == null) {
66         this.webResourceCollections = new HashSet();
67     }
68     return this.webResourceCollections;
69     }
70     
71     /** The collection of URL pattern plus HTTP methods that are constrained. */
72     public Enumeration getWebResourceCollections() {
73     return (new Vector(this.getWebResourceCollectionSet())).elements();
74     }
75     
76     /** Adds a web resource collection to this constraint.*/
77     public void addWebResourceCollection(WebResourceCollection webResourceCollection) {
78     this.getWebResourceCollectionSet().add(webResourceCollection);
79     }
80     
81     public void addWebResourceCollection(WebResourceCollectionImpl webResourceCollection) {
82         addWebResourceCollection((WebResourceCollection) webResourceCollection);
83     }
84     
85     /** Removes the given web resource collection from this constraint.*/
86     public void removeWebResourceCollection(WebResourceCollection webResourceCollection) {
87     this.getWebResourceCollectionSet().remove(webResourceCollection);
88     }
89     
90     /** The authorization constraint. */
91     public AuthorizationConstraint getAuthorizationConstraint() {
92     return this.authorizationConstraint;
93     }
94     
95     /** Sets the authorization constraint.*/
96     public void setAuthorizationConstraint(AuthorizationConstraint authorizationConstraint) {
97     this.authorizationConstraint = authorizationConstraint;
98     }
99     
100     /** Sets the authorization constraint.*/
101     public void setAuthorizationConstraint(AuthorizationConstraintImpl authorizationConstraint) {
102     setAuthorizationConstraint((AuthorizationConstraint) authorizationConstraint);
103     }
104     
105     /** The user data constraint. */
106     public UserDataConstraint getUserDataConstraint() {
107     return this.userDataConstraint;
108     }
109     /** Sets the user data constraint. */
110     public void setUserDataConstraint(UserDataConstraint userDataConstraint) {
111     this.userDataConstraint = userDataConstraint;
112     }
113     
114     public void setUserDataConstraint(UserDataConstraintImpl userDataConstraint) {
115     setUserDataConstraint((UserDataConstraint) userDataConstraint);
116     }
117     
118     /** Returns a formatted String representing of my state.*/
119     public void print(StringBuffer JavaDoc toStringBuffer) {
120     toStringBuffer.append("SecurityConstraint: ");
121     toStringBuffer.append(" webResourceCollections: ").append(webResourceCollections);
122     toStringBuffer.append(" authorizationConstraint ").append(authorizationConstraint);
123     toStringBuffer.append(" userDataConstraint ").append(userDataConstraint);
124     
125     }
126     
127 }
128
Popular Tags