KickJava   Java API By Example, From Geeks To Geeks.

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


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.UserDataConstraint;
26 import com.sun.enterprise.util.LocalStringManagerImpl;
27
28
29     /**
30     * I represent the information about how the web application's data should be protected.
31     *
32     * @author Danny Coward
33     */

34     
35 public class UserDataConstraintImpl extends Descriptor implements UserDataConstraint {
36     /** The transport is unspecified.*/
37     public static final String JavaDoc TRANSPORT_GUARANTEE_NONE = UserDataConstraint.NONE_TRANSPORT;
38     /** HTTP.*/
39     public static final String JavaDoc TRANSPORT_GUARANTEE_INTEGRAL = UserDataConstraint.INTEGRAL_TRANSPORT;
40     /** HTTPS */
41     public static final String JavaDoc TRANSPORT_GUARANTEE_CONFIDENTIAL = UserDataConstraint.CONFIDENTIAL_TRANSPORT;
42
43     /** JACC Specific **/
44     public static final String JavaDoc TRANSPORT_GUARANTEE_CLEAR = UserDataConstraint.CLEAR;
45     private static final String JavaDoc[] transportGuaranteeChoices = {
46     TRANSPORT_GUARANTEE_NONE,
47     TRANSPORT_GUARANTEE_INTEGRAL,
48     TRANSPORT_GUARANTEE_CONFIDENTIAL,
49     };
50     private String JavaDoc transportGuarantee;
51     private static LocalStringManagerImpl localStrings =
52         new LocalStringManagerImpl(UserDataConstraintImpl.class);
53
54     /**
55     * Return a String array of my static transport types.
56     */

57     public static final String JavaDoc[] getTransportGuaranteeChoices() {
58     return transportGuaranteeChoices;
59     }
60     
61     /**
62     * Return my transport type.
63     */

64     public String JavaDoc getTransportGuarantee() {
65     if (transportGuarantee == null) {
66        transportGuarantee = TRANSPORT_GUARANTEE_NONE;
67     }
68     return transportGuarantee;
69     }
70
71     public String JavaDoc[] getUnacceptableTransportGuarantees(){
72     String JavaDoc acceptable = getTransportGuarantee();
73     if(acceptable.equals(TRANSPORT_GUARANTEE_NONE))
74        return (String JavaDoc[]) null;
75     else if (acceptable.equals(TRANSPORT_GUARANTEE_INTEGRAL)){
76         String JavaDoc[] ret = new String JavaDoc[] {TRANSPORT_GUARANTEE_CLEAR, TRANSPORT_GUARANTEE_CONFIDENTIAL };
77         return ret;
78     } else if (acceptable.equals(TRANSPORT_GUARANTEE_CONFIDENTIAL)){
79         String JavaDoc[] ret = new String JavaDoc[] {TRANSPORT_GUARANTEE_CLEAR, TRANSPORT_GUARANTEE_INTEGRAL };
80         return ret;
81     }
82     return (String JavaDoc[]) null;
83     }
84     /**
85     * Sets my transport type to the given value. Throws an illegal argument exception
86     * if the value is not allowed.
87     */

88     public void setTransportGuarantee(String JavaDoc transportGuarantee) {
89     if (this.isBoundsChecking()) {
90         if ( !UserDataConstraint.NONE_TRANSPORT.equals(transportGuarantee)
91         && !UserDataConstraint.INTEGRAL_TRANSPORT.equals(transportGuarantee)
92             && !UserDataConstraint.CONFIDENTIAL_TRANSPORT.equals(transportGuarantee)) {
93         throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
94                                            "enterprise.deployment.exceptiontransportguarentee",
95                                            "{0} is not a valid transport guarantee", new Object JavaDoc[] {transportGuarantee}));
96         }
97     }
98     this.transportGuarantee = transportGuarantee;
99     }
100     
101     /**
102     * Returns a formatted String of my state.
103     */

104     public void print(StringBuffer JavaDoc toStringBuffer) {
105     toStringBuffer.append("UserDataConstraint ");
106     toStringBuffer.append(" description ").append(super.getDescription());
107     toStringBuffer.append(" transportGuarantee ").append(getTransportGuarantee());
108     }
109 }
110
Popular Tags