[jboss-cvs] Picketlink SVN: r440 - trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 7 11:14:24 EDT 2010


Author: mmoyses
Date: 2010-10-07 11:14:24 -0400 (Thu, 07 Oct 2010)
New Revision: 440

Added:
   trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SecurityActions.java
Log:


Added: trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SecurityActions.java
===================================================================
--- trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SecurityActions.java	                        (rev 0)
+++ trust/trunk/jbossws-native/src/main/java/org/picketlink/trust/jbossws/handler/SecurityActions.java	2010-10-07 15:14:24 UTC (rev 440)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.picketlink.trust.jbossws.handler;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+
+/**
+ * Privileged actions.
+ * 
+ * @author <a href="mmoyses at redhat.com">Marcus Moyses</a>
+ * @version $Revision: 1 $
+ */
+class SecurityActions
+{
+
+   static SecurityContext createSecurityContext(final Principal p, final Object cred, final Subject subject)
+   {
+      return (SecurityContext) AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
+      {
+         public SecurityContext run()
+         {
+            SecurityContext sc = null;
+            try
+            {
+               sc = SecurityContextFactory.createSecurityContext(p, cred, subject, "SAML2_HANDLER");
+            }
+            catch (Exception e)
+            {
+               throw new RuntimeException(e);
+            }
+            return sc;
+         }
+      });
+   }
+
+   static void setSecurityContext(final SecurityContext sc)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            SecurityContextAssociation.setSecurityContext(sc);
+            return null;
+         }
+      });
+   }
+}



More information about the jboss-cvs-commits mailing list