KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > AuthenticationSchemeSequenceItem


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.security;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27 import com.sslexplorer.core.CoreUtil;
28 import com.sslexplorer.policyframework.ResourceItem;
29
30 /**
31  * Implementation of a {@link com.sslexplorer.table.TableItem} that is used to
32  * wrap {@link com.sslexplorer.security.AuthenticationScheme} objects for
33  * display.
34  *
35  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
36  */

37 public class AuthenticationSchemeSequenceItem extends ResourceItem {
38
39     /**
40      * Constructor
41      *
42      * @param sequence sequence
43      * @param policies
44      */

45     public AuthenticationSchemeSequenceItem(AuthenticationScheme sequence, List JavaDoc policies) {
46         super(sequence, policies);
47     }
48
49     /**
50      * Get the authentication scheme sequence object this item wraps
51      *
52      * @return authentication scheme sequence
53      */

54     public AuthenticationScheme getSequence() {
55         return (AuthenticationScheme) getResource();
56     }
57
58     /* (non-Javadoc)
59      * @see com.sslexplorer.policyframework.ResourceItem#getSmallIconPath(javax.servlet.http.HttpServletRequest)
60      */

61     public String JavaDoc getSmallIconPath(HttpServletRequest JavaDoc request) {
62         return ((AuthenticationScheme) getResource()).getEnabled() ? CoreUtil.getThemePath(request.getSession())
63                         + "/images/actions/start.gif" : CoreUtil.getThemePath(request.getSession()) + "/images/actions/stop.gif";
64     }
65
66     /**
67      * Verifies if this item can be moved up the list.
68      *
69      * @return true if it is not the default route item and not already the
70      * first in the list.
71      */

72     public boolean isCanMoveUp() {
73         AuthenticationScheme route = (AuthenticationScheme) getResource();
74         return route.getPriorityInt() != 1;
75     }
76
77     /**
78      * Verifies if this item can be moved down the list.
79      *
80      * @return true if it is not the default route item.
81      */

82     public boolean isCanMoveDown() {
83         return true;
84     }
85     
86     /**
87      * Get a description of the modules that the scheme consists of.
88      *
89      * @return description of the modules that the scheme consists of.
90      *
91      * TODO This needs to be done in a language neutral way
92      */

93     public String JavaDoc getDescription() {
94         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
95         buf.append("Consists of ");
96         buf.append(getSequence().getModuleCount());
97         if (getSequence().getModuleCount() == 1) {
98             buf.append(" module");
99         } else {
100             buf.append(" modules");
101         }
102         buf.append(".<br/>");
103         for (Iterator JavaDoc i = getSequence().modules(); i.hasNext();) {
104             buf.append("&nbsp;&nbsp;<b>");
105             buf.append(i.next());
106             buf.append("</b><br/>");
107         }
108         return buf.toString();
109     }
110
111     /* (non-Javadoc)
112      * @see com.sslexplorer.table.TableItem#getColumnValue(int)
113      */

114     public Object JavaDoc getColumnValue(int col) {
115         switch (col) {
116             case 0:
117                 return getSequence().getSchemeName();
118             case 1:
119                 return Boolean.valueOf(getSequence().getEnabled());
120             default:
121                 return new Integer JavaDoc(getSequence().getPriority());
122         }
123     }
124 }
125
Popular Tags