KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > jaas > principal > EntityImpl


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.jaas.principal;
14
15 import info.magnolia.cms.security.auth.Entity;
16
17 import java.util.Hashtable JavaDoc;
18 import java.util.Map JavaDoc;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.apache.commons.lang.builder.ToStringBuilder;
22 import org.apache.commons.lang.builder.ToStringStyle;
23
24
25 /**
26  * @author Sameer Charles $Id: EntityImpl.java 6341 2006-09-12 09:18:27Z philipp $
27  */

28 public class EntityImpl implements Entity {
29
30     /**
31      * Stable serialVersionUID.
32      */

33     private static final long serialVersionUID = 222L;
34
35     private static final String JavaDoc DEFAULT_NAME = "person";
36
37     /**
38      * properties
39      */

40     private String JavaDoc name;
41
42     private Map JavaDoc properties;
43
44     public EntityImpl() {
45         this.properties = new Hashtable JavaDoc();
46     }
47
48     /**
49      * Get name given to this principal
50      * @return name
51      */

52     public String JavaDoc getName() {
53         if (StringUtils.isEmpty(this.name)) {
54             return DEFAULT_NAME;
55         }
56         return this.name;
57     }
58
59     public void setName(String JavaDoc name) {
60         this.name = name;
61     }
62
63     public void addProperty(String JavaDoc key, Object JavaDoc value) {
64         this.properties.put(key, value);
65     }
66
67     public Object JavaDoc getProperty(String JavaDoc key) {
68         return this.properties.get(key);
69     }
70
71     /**
72      * @see java.lang.Object#toString()
73      */

74     public String JavaDoc toString() {
75         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("name", this.name).toString();
76     }
77
78 }
79
Popular Tags