KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > security > interfaces > CallerInfo


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 /*
24  * JBoss, Home of Professional Open Source
25  *
26  * Distributable under LGPL license.
27  * See terms of license at gnu.org.
28  */

29
30 package org.jboss.test.security.interfaces;
31
32 import java.io.Serializable JavaDoc;
33 import java.security.Principal JavaDoc;
34 import java.util.HashSet JavaDoc;
35 import java.util.Set JavaDoc;
36
37 /**
38  A representation of the expected principal identity and roles.
39
40  @author Scott.Stark@jboss.org
41  @version $Revision: 40160 $
42  */

43 public class CallerInfo implements Serializable JavaDoc
44 {
45    private static final long serialVersionUID = 1;
46
47    /** The expected caller for non-run-as contexts */
48    private Principal JavaDoc callerIdentity;
49    /** The expected caller for run-as contexts */
50    private Principal JavaDoc runAsIdentity;
51    /** HashSet<String> expected role names for isCallerInRole for non-run-as contexts */
52    private HashSet JavaDoc expectedCallerRoles = new HashSet JavaDoc();
53    /** HashSet<String> expected role names for isCallerInRole for non-run-as contexts */
54    private HashSet JavaDoc expectedRunAsRoles = new HashSet JavaDoc();
55
56    public CallerInfo()
57    {
58       
59    }
60    public CallerInfo(Principal JavaDoc callerIdentity, Principal JavaDoc runAsIdentity,
61       Set JavaDoc expectedCallerRoles, Set JavaDoc expectedRunAsRoles)
62    {
63       this.callerIdentity = callerIdentity;
64       this.runAsIdentity = runAsIdentity;
65       this.expectedCallerRoles.addAll(expectedCallerRoles);
66       this.expectedRunAsRoles.addAll(expectedRunAsRoles);
67    }
68
69    public Principal JavaDoc getCallerIdentity()
70    {
71       return callerIdentity;
72    }
73
74    public void setCallerIdentity(Principal JavaDoc callerIdentity)
75    {
76       this.callerIdentity = callerIdentity;
77    }
78
79    public Principal JavaDoc getRunAsIdentity()
80    {
81       return runAsIdentity;
82    }
83
84    public void setRunAsIdentity(Principal JavaDoc runAsIdentity)
85    {
86       this.runAsIdentity = runAsIdentity;
87    }
88
89    public Set JavaDoc getExpectedCallerRoles()
90    {
91       return expectedCallerRoles;
92    }
93
94    public void setExpectedCallerRoles(Set JavaDoc expectedCallerRoles)
95    {
96       this.expectedCallerRoles.clear();
97       this.expectedCallerRoles.addAll(expectedCallerRoles);
98    }
99
100    public Set JavaDoc getExpectedRunAsRoles()
101    {
102       return expectedRunAsRoles;
103    }
104
105    public void setExpectedRunAsRoles(Set JavaDoc expectedRunAsRoles)
106    {
107       this.expectedRunAsRoles.clear();
108       this.expectedRunAsRoles.addAll(expectedRunAsRoles);
109    }
110 }
111
Popular Tags