[jboss-cvs] JBossAS SVN: r62529 - projects/security/security-spi/trunk/src/main/org/jboss/security.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 24 23:35:25 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-04-24 23:35:25 -0400 (Tue, 24 Apr 2007)
New Revision: 62529
Added:
projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityIdentity.java
Modified:
projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java
Log:
Introduce the concept of security identity that is used to cache and revert the security identity associated with a call
Modified: projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java 2007-04-25 03:32:51 UTC (rev 62528)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityContextUtil.java 2007-04-25 03:35:25 UTC (rev 62529)
@@ -82,6 +82,20 @@
public abstract void setCallerRunAs(RunAs runAs);
/**
+ * Get a holder of subject, runAs and caller RunAs
+ * @return
+ */
+ public abstract SecurityIdentity getSecurityIdentity();
+
+ /**
+ * Inject subject, runAs and callerRunAs into the security context
+ * Mainly used by integration code base to cache the security identity
+ * and put back to the security context
+ * @param si The SecurityIdentity Object
+ */
+ public abstract void setSecurityIdentity(SecurityIdentity si);
+
+ /**
* Get the Roles associated with the user for the
* current security context
* @param <T>
Added: projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityIdentity.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityIdentity.java (rev 0)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/SecurityIdentity.java 2007-04-25 03:35:25 UTC (rev 62529)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+//$Id$
+
+/**
+ * Represents an Identity of an agent interacting with the
+ * security service. It can be an user or a process. It
+ * consists of a subject and various run-as
+ * @author Anil.Saldhana at redhat.com
+ * @since Apr 22, 2007
+ * @version $Revision$
+ */
+public class SecurityIdentity
+{
+ SubjectInfo theSubject = null;
+ RunAs runAs = null;
+ RunAs callerRunAs = null;
+
+ public SecurityIdentity(SubjectInfo subject, RunAs runAs, RunAs callerRunAs)
+ {
+ this.theSubject = subject;
+ this.runAs = runAs;
+ this.callerRunAs = callerRunAs;
+ }
+
+ public Principal getPrincipal()
+ {
+ return theSubject != null ? theSubject.getAuthenticationPrincipal() : null;
+ }
+
+ public Object getCredential()
+ {
+ return theSubject != null ? theSubject.getAuthenticationCredential(): null;
+ }
+
+ public Subject getSubject()
+ {
+ return theSubject != null ? theSubject.getAuthenticatedSubject() : null;
+ }
+
+ public RunAs getRunAs()
+ {
+ return runAs;
+ }
+
+ public RunAs getCallerRunAs()
+ {
+ return callerRunAs;
+ }
+}
More information about the jboss-cvs-commits
mailing list