Search in sources :

Example 61 with AccessControlException

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;
}
Also used : WriteAccessRecord(org.apache.poi.hssf.record.WriteAccessRecord) AccessControlException(java.security.AccessControlException) UnicodeString(org.apache.poi.hssf.record.common.UnicodeString)

Example 62 with AccessControlException

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;
}
Also used : BeanContext(org.apache.openejb.BeanContext) ThreadContext(org.apache.openejb.core.ThreadContext) AccessControlException(java.security.AccessControlException) EJBMethodPermission(javax.security.jacc.EJBMethodPermission)

Aggregations

AccessControlException (java.security.AccessControlException)62 IOException (java.io.IOException)23 Test (org.junit.Test)12 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)9 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)8 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)7 File (java.io.File)6 InputStream (java.io.InputStream)6 Permission (java.security.Permission)6 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)5 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)4 HashSet (java.util.HashSet)4 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)4 FileNotFoundException (java.io.FileNotFoundException)3 ArrayList (java.util.ArrayList)3 UnsafeCharArrayWriter (jetbrick.template.utils.UnsafeCharArrayWriter)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 BufferedInputStream (java.io.BufferedInputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileInputStream (java.io.FileInputStream)2