KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > RealmName


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.tools.verifier.tests.web;
24
25 import com.sun.enterprise.tools.verifier.tests.web.WebTest;
26 import java.util.*;
27 import java.io.*;
28 import com.sun.enterprise.deployment.*;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32
33 /**
34  * The Web realm name specifies the realm name to use in HTTP Basic
35  * authentication
36  */

37 public class RealmName extends WebTest implements WebCheck {
38
39     
40     /**
41      * The Web realm name specifies the realm name to use in HTTP Basic
42      * authentication
43      *
44      * @param descriptor the Web deployment descriptor
45      *
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(WebBundleDescriptor descriptor) {
49
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53     if (descriptor.getLoginConfiguration() != null) {
54         String JavaDoc realmName = descriptor.getLoginConfiguration().getRealmName();
55         if (realmName.length() > 0) {
56         result.addGoodDetails(smh.getLocalString
57                        ("tests.componentNameConstructor",
58                     "For [ {0} ]",
59                     new Object JavaDoc[] {compName.toString()}));
60         result.passed(smh.getLocalString
61                       (getClass().getName() + ".passed",
62                        "The realm name [ {0} ] value specifies the realm name to use in HTTP Basic authentication within web application [ {1} ]",
63                        new Object JavaDoc[] {realmName, descriptor.getName()}));
64         } else {
65         result.addNaDetails(smh.getLocalString
66                        ("tests.componentNameConstructor",
67                     "For [ {0} ]",
68                     new Object JavaDoc[] {compName.toString()}));
69         result.notApplicable(smh.getLocalString
70                        (getClass().getName() + ".notApplicable1",
71                     "Not Applicable: The realm name [ {0} ] value does not specify the realm name to use in HTTP Basic authentication within web application [ {1} ]",
72                     new Object JavaDoc[] {realmName, descriptor.getName()}));
73         }
74     } else {
75         result.addNaDetails(smh.getLocalString
76                        ("tests.componentNameConstructor",
77                     "For [ {0} ]",
78                     new Object JavaDoc[] {compName.toString()}));
79         result.notApplicable(smh.getLocalString
80                  (getClass().getName() + ".notApplicable",
81                   "There are no realm name elements within this web archive [ {0} ]",
82                   new Object JavaDoc[] {descriptor.getName()}));
83     }
84
85     return result;
86     }
87 }
88
Popular Tags