KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > SecurityIdentityMetaData


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 package org.jboss.metadata;
23
24 import org.jboss.deployment.DeploymentException;
25 import org.w3c.dom.Element JavaDoc;
26
27 /**
28  * The meta data object for the security-identity element.
29  * The security-identity element specifies whether the caller�s security
30  * identity is to be used for the execution of the methods of the enterprise
31  * bean or whether a specific run-as role is to be used. It
32  * contains an optional description and a specification of the security
33  * identity to be used.
34  * <p/>
35  * Used in: session, entity, message-driven
36  *
37  * @author Scott.Stark@jboss.org
38  * @author <a HREF="mailto:Thomas.Diesler@jboss.org">Thomas Diesler</a>.
39  * @version $Revision: 58146 $
40  */

41 public class SecurityIdentityMetaData extends MetaData
42 {
43    private String JavaDoc description;
44    /**
45     * The use-caller-identity element specifies that the caller�s security
46     * identity be used as the security identity for the execution of the
47     * enterprise bean�s methods.
48     */

49    private boolean useCallerIdentity;
50    /**
51     * The run-as/role-name element specifies the run-as security role name
52     * to be used for the execution of the methods of an enterprise bean.
53     */

54    private String JavaDoc runAsRoleName;
55    /**
56     * The principal that corresponds to run-as role
57     */

58    private String JavaDoc runAsPrincipalName;
59
60    public String JavaDoc getDescription()
61    {
62       return description;
63    }
64
65    public boolean getUseCallerIdentity()
66    {
67       return useCallerIdentity;
68    }
69    public void setUseCallerIdentity(boolean flag)
70    {
71       this.useCallerIdentity = flag;
72    }
73
74    public String JavaDoc getRunAsRoleName()
75    {
76       return runAsRoleName;
77    }
78    public void setRunAsRoleName(String JavaDoc runAsRoleName)
79    {
80       this.runAsRoleName = runAsRoleName;
81    }
82
83    public String JavaDoc getRunAsPrincipalName()
84    {
85       return runAsPrincipalName;
86    }
87
88    public void setRunAsPrincipalName(String JavaDoc principalName)
89    {
90       this.runAsPrincipalName = principalName;
91    }
92
93    /**
94     * @param element the security-identity element from the ejb-jar
95     */

96    public void importEjbJarXml(Element JavaDoc element) throws DeploymentException
97    {
98       description = getElementContent(getOptionalChild(element, "description"));
99       Element JavaDoc callerIdent = getOptionalChild(element, "use-caller-identity");
100       Element JavaDoc runAs = getOptionalChild(element, "run-as");
101       if (callerIdent == null && runAs == null)
102          throw new DeploymentException("security-identity: either use-caller-identity or run-as must be specified");
103       if (callerIdent != null && runAs != null)
104          throw new DeploymentException("security-identity: only one of use-caller-identity or run-as can be specified");
105       if (callerIdent != null)
106       {
107          useCallerIdentity = true;
108       }
109       else
110       {
111          runAsRoleName = getElementContent(getUniqueChild(runAs, "role-name"));
112       }
113    }
114 }
115
Popular Tags