Hello,
I try to create a file in a webservice. The problem is that the file has
to have the owner of the delegated credential. I thought I can do it
somehow with the JaasSubject, but the file owner is always globus.
thx pod69
public void test() throws IOException, GSSException{
SecurityManager.getManager().setServiceOwnerFromContext();
org.apache.axis.MessageContext mctx =
org.apache.axis.MessageContext.getCurrentContext();
SecurityManager manager =
SecurityManager.getManager(mctx);
Subject subject = (Subject)
mctx.getProperty(Constants.INVOCATION_SUBJECT);
System.out.println(mctx.getUsername());
JaasSubject.doAs(subject, new ExampleAction());
}
class ExampleAction implements java.security.PrivilegedAction {
public Object run() {
File file=null;
try {
file = new File("/tmp/test");
// Create file if it does not exist
boolean success = file.createNewFile();
if (success) {
// File did not exist and was
created
} else {
// File already exists
}
} catch (IOException e) {
}
return null;
}
}
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger