| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
package org.globus.gsi.gssapi.jaas; |
| 16 |
|
| 17 |
import java.security.AccessController; |
| 18 |
import java.security.PrivilegedAction; |
| 19 |
import java.security.PrivilegedExceptionAction; |
| 20 |
import java.security.PrivilegedActionException; |
| 21 |
|
| 22 |
import javax.security.auth.Subject; |
| 23 |
|
| 24 |
/** |
| 25 |
* Standard JAAS implementation of the JAAS Subject helper API. |
| 26 |
* This implementation (because of a problem in JAAS) can cut off |
| 27 |
* the Subject object from the thread context. |
| 28 |
*/ |
| 29 |
public class StandardSubject extends JaasSubject { |
| 30 |
|
| 31 |
protected StandardSubject() { |
| 32 |
super(); |
| 33 |
} |
| 34 |
|
| 35 |
public Subject getSubject() { |
| 36 |
return Subject.getSubject(AccessController.getContext()); |
| 37 |
} |
| 38 |
|
| 39 |
public Object runAs(Subject subject, PrivilegedAction action) { |
| 40 |
return Subject.doAs(subject, action); |
| 41 |
} |
| 42 |
|
| 43 |
public Object runAs(Subject subject, PrivilegedExceptionAction action) |
| 44 |
throws PrivilegedActionException { |
| 45 |
return Subject.doAs(subject, action); |
| 46 |
} |
| 47 |
} |