helper method for better access denied to process message

This commit is contained in:
Doug MacEachern 2004-08-18 16:03:45 +00:00
parent ad85def2fb
commit bbc2a738ca
1 changed files with 20 additions and 0 deletions

View File

@ -2,5 +2,25 @@ package net.hyperic.sigar;
public class SigarPermissionDeniedException extends SigarException {
public SigarPermissionDeniedException(String s) { super(s); }
public static String getUserDeniedMessage(SigarProxy sigar, long pid) {
String user="unknown", owner="unknown";
try {
user = sigar.getProcCredName(sigar.getPid()).getUser();
} catch (SigarException e) { }
try {
owner = sigar.getProcCredName(pid).getUser();
} catch (SigarException e) { }
return
"User " + user + " denied access to process "
+ pid + " owned by " + owner;
}
public SigarPermissionDeniedException(String s) { super(s); }
public SigarPermissionDeniedException(SigarProxy sigar, long pid) {
super(getUserDeniedMessage(sigar, pid));
}
}