01: /*
02: jGuard is a security framework based on top of jaas (java authentication and authorization security).
03: it is written for web applications, to resolve simply, access control problems.
04: version $Name: $
05: http://sourceforge.net/projects/jguard/
06:
07: Copyright (C) 2004 Charles GAY
08:
09: This library is free software; you can redistribute it and/or
10: modify it under the terms of the GNU Lesser General Public
11: License as published by the Free Software Foundation; either
12: version 2.1 of the License, or (at your option) any later version.
13:
14: This library is distributed in the hope that it will be useful,
15: but WITHOUT ANY WARRANTY; without even the implied warranty of
16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: Lesser General Public License for more details.
18:
19: You should have received a copy of the GNU Lesser General Public
20: License along with this library; if not, write to the Free Software
21: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22:
23:
24: jGuard project home page:
25: http://sourceforge.net/projects/jguard/
26:
27: */
28: package net.sf.jguard.core.principals;
29:
30: import java.security.Permission;
31: import java.security.ProtectionDomain;
32:
33: /**
34: * This principal is added in JMX connection to keep a reference of the objectID used in Policy.
35: * @author <a href="mailto:vberetti@users.sourceforge.net">Vincent Beretti</a>
36: * @see net.sf.jguard.core.authorization.policy.MultipleAppPolicy#implies(ProtectionDomain, Permission)
37: */
38: public class JMXPrincipal implements BasePrincipal {
39:
40: private static final long serialVersionUID = -7340042412040356992L;
41:
42: private String applicationName;
43: private Object objectID;
44:
45: public JMXPrincipal(String applicationName, Object objectID) {
46: this .applicationName = applicationName;
47: this .objectID = objectID;
48: }
49:
50: public Object clone() {
51: JMXPrincipal clone = new JMXPrincipal(this .applicationName,
52: this .objectID);
53: return clone;
54: }
55:
56: public int compareTo(Object arg) {
57:
58: JMXPrincipal cmpPpal = (JMXPrincipal) arg;
59:
60: if (this .applicationName.equals(cmpPpal.getApplicationName())
61: && this .objectID.equals(cmpPpal.getObjectID())) {
62: return 0;
63: }
64: return 1;
65: }
66:
67: public String getName() {
68: return new String(applicationName
69: + objectID.getClass().getName());
70: }
71:
72: public String getApplicationName() {
73: return applicationName;
74: }
75:
76: public void setApplicationName(String applicationName) {
77: this .applicationName = applicationName;
78: }
79:
80: public Object getObjectID() {
81: return objectID;
82: }
83:
84: public void setObjectID(Object objectID) {
85: this.objectID = objectID;
86: }
87:
88: }
|