KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > propertyeditor > PrincipalEditor


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9 package org.jboss.security.propertyeditor;
10
11 import java.beans.PropertyEditorSupport JavaDoc;
12 import java.security.Principal JavaDoc;
13
14 import org.jboss.security.SimplePrincipal;
15
16 /** A property editor for java.security.Principals that uses the
17  * org.jboss.security.SimplePrincipal
18  *
19  * @version <tt>$Revision: 1.2 $</tt>
20  * @author Scott.Stark@jboss.org
21  */

22 public class PrincipalEditor
23    extends PropertyEditorSupport JavaDoc
24 {
25    /** Build a SimplePrincipal
26     * @param text, the name of the Principal
27     */

28    public void setAsText(final String JavaDoc text)
29    {
30       SimplePrincipal principal = new SimplePrincipal(text);
31       setValue(principal);
32    }
33
34    /**
35     * @return the name of the Principal
36     */

37    public String JavaDoc getAsText()
38    {
39       Principal JavaDoc principal = (Principal JavaDoc) getValue();
40       return principal.getName();
41    }
42 }
43
Popular Tags