Created
July 9, 2012 11:36
-
-
Save aviramsegal/3075970 to your computer and use it in GitHub Desktop.
WebSphere Application Server run as server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Run code with the server subject | |
* (having the authorization to do any administration operation) | |
*/ | |
PrivilegedExceptionAction<Void> action = new PrivilegedExceptionAction<Void>() { | |
@Override | |
public Void run() { | |
// YOUR CODE HERE | |
return null; | |
} | |
}; | |
try { | |
// run the priviledged action as the system | |
ContextManagerFactory.getInstance().runAsSystem(action); | |
/* | |
Also possible: | |
Subject serverSubject = ContextManagerFactory.getInstance().getServerSubject(); | |
WSSubject.doAs(serverSubject, action); | |
*/ | |
} catch (PrivilegedActionException e) { | |
Throable thrownException = e.getCause(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment