use of java.security.AccessControlException in project poi by apache.
the class InternalWorkbook method createWriteAccess.
/**
* creates the WriteAccess record containing the logged in user's name
*/
private static WriteAccessRecord createWriteAccess() {
WriteAccessRecord retval = new WriteAccessRecord();
String defaultUserName = "POI";
try {
String username = System.getProperty("user.name");
// Google App engine returns null for user.name, see Bug 53974
if (username == null) {
username = defaultUserName;
}
retval.setUsername(username);
} catch (AccessControlException e) {
LOG.log(POILogger.WARN, "can't determine user.name", e);
// AccessControlException can occur in a restricted context
// (client applet/jws application or restricted security server)
retval.setUsername(defaultUserName);
}
return retval;
}
use of java.security.AccessControlException in project tomee by apache.
the class AbstractSecurityService method isCallerAuthorized.
@Override
public boolean isCallerAuthorized(final Method method, final InterfaceType type) {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final BeanContext beanContext = threadContext.getBeanContext();
try {
final String ejbName = beanContext.getEjbName();
String name = type == null ? null : type.getSpecName();
if ("LocalBean".equals(name) || "LocalBeanHome".equals(name)) {
name = null;
}
final Identity currentIdentity = clientIdentity.get();
final SecurityContext securityContext;
if (currentIdentity == null) {
securityContext = threadContext.get(SecurityContext.class);
} else {
securityContext = new SecurityContext(currentIdentity.getSubject());
}
securityContext.acc.checkPermission(new EJBMethodPermission(ejbName, name, method));
} catch (final AccessControlException e) {
return false;
}
return true;
}
Aggregations