1 /*
2 * Copyright 2003 - 2013 The eFaps Team
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Revision: $Rev$
17 * Last Changed: $Date$
18 * Last Changed By: $Author$
19 */
20
21 package org.efaps.jaas.xml;
22
23 import java.security.Principal;
24
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26
27 /**
28 * The abstract class is used to implement the person, role and group principal
29 * instances used by class {@link XMLUserLoginModule}.
30 *
31 * @author The eFaps Team
32 * @version $Id$
33 */
34 public abstract class AbstractXMLPrincipal
35 implements Principal
36 {
37 /**
38 * The instance variable stores the name of the principal.
39 *
40 * @see #getName
41 * @see #setName
42 */
43 private String name = null;
44
45 /**
46 * Returns the name of this principal stored in instance variable
47 * {@link #name}.
48 *
49 * @return name of this principal
50 * @see #name
51 * @see #setName
52 */
53 public String getName()
54 {
55 return this.name;
56 }
57
58 /**
59 * Sets the name of this principal stored in instance variable
60 * {@link #name}. The method must be public, because it is set from the XML
61 * to bean converter in {@link XMLUserLoginModule}.
62 *
63 * @param _name new name to set for this principal
64 * @see #name
65 * @see #getName
66 */
67 public void setName(final String _name)
68 {
69 this.name = _name;
70 }
71
72 /**
73 * Returns a string representation of this principal.
74 *
75 * @return string representation of this principal
76 */
77 @Override
78 public String toString()
79 {
80 return new ToStringBuilder(this)
81 .append("name", getName())
82 .toString();
83 }
84 }