KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > jndi > SecurityAssociationActions


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.security.jndi;
8
9 import java.security.PrivilegedAction JavaDoc;
10 import java.security.Principal JavaDoc;
11 import java.security.AccessController JavaDoc;
12
13 import javax.security.auth.Subject JavaDoc;
14
15 import org.jboss.security.SecurityAssociation;
16
17 /** A PrivilegedAction implementation for setting the SecurityAssociation
18  * principal and credential
19  *
20  * @author Scott.Stark@jboss.org
21  * @version $Revison:$
22  */

23 class SecurityAssociationActions
24 {
25    private static class SetPrincipalInfoAction implements PrivilegedAction JavaDoc
26    {
27       Principal JavaDoc principal;
28       Object JavaDoc credential;
29       SetPrincipalInfoAction(Principal JavaDoc principal, Object JavaDoc credential)
30       {
31          this.principal = principal;
32          this.credential = credential;
33       }
34       public Object JavaDoc run()
35       {
36          SecurityAssociation.setCredential(credential);
37          credential = null;
38          SecurityAssociation.setPrincipal(principal);
39          principal = null;
40          return null;
41       }
42    }
43
44    static void setPrincipalInfo(Principal JavaDoc principal, Object JavaDoc credential)
45    {
46       SetPrincipalInfoAction action = new SetPrincipalInfoAction(principal, credential);
47       AccessController.doPrivileged(action);
48    }
49
50 }
51
Popular Tags