Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aviramsegal
Created July 9, 2012 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviramsegal/3075970 to your computer and use it in GitHub Desktop.
Save aviramsegal/3075970 to your computer and use it in GitHub Desktop.
WebSphere Application Server run as server
/**
* 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