Search in sources :

Example 41 with AccessControlException

use of java.security.AccessControlException in project hadoop by apache.

the class ClientRMService method forceKillApplication.

@SuppressWarnings("unchecked")
@Override
public KillApplicationResponse forceKillApplication(KillApplicationRequest request) throws YarnException {
    ApplicationId applicationId = request.getApplicationId();
    CallerContext callerContext = CallerContext.getCurrent();
    UserGroupInformation callerUGI;
    try {
        callerUGI = UserGroupInformation.getCurrentUser();
    } catch (IOException ie) {
        LOG.info("Error getting UGI ", ie);
        RMAuditLogger.logFailure("UNKNOWN", AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "ClientRMService", "Error getting UGI", applicationId, callerContext);
        throw RPCUtil.getRemoteException(ie);
    }
    RMApp application = this.rmContext.getRMApps().get(applicationId);
    if (application == null) {
        RMAuditLogger.logFailure(callerUGI.getUserName(), AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "ClientRMService", "Trying to kill an absent application", applicationId, callerContext);
        throw new ApplicationNotFoundException("Trying to kill an absent" + " application " + applicationId);
    }
    if (!checkAccess(callerUGI, application.getUser(), ApplicationAccessType.MODIFY_APP, application)) {
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.KILL_APP_REQUEST, "User doesn't have permissions to " + ApplicationAccessType.MODIFY_APP.toString(), "ClientRMService", AuditConstants.UNAUTHORIZED_USER, applicationId, callerContext);
        throw RPCUtil.getRemoteException(new AccessControlException("User " + callerUGI.getShortUserName() + " cannot perform operation " + ApplicationAccessType.MODIFY_APP.name() + " on " + applicationId));
    }
    if (application.isAppFinalStateStored()) {
        return KillApplicationResponse.newInstance(true);
    }
    StringBuilder message = new StringBuilder();
    message.append("Application ").append(applicationId).append(" was killed by user ").append(callerUGI.getShortUserName());
    InetAddress remoteAddress = Server.getRemoteIp();
    if (null != remoteAddress) {
        message.append(" at ").append(remoteAddress.getHostAddress());
    }
    String diagnostics = org.apache.commons.lang.StringUtils.trimToNull(request.getDiagnostics());
    if (diagnostics != null) {
        message.append(" with diagnostic message: ");
        message.append(diagnostics);
    }
    this.rmContext.getDispatcher().getEventHandler().handle(new RMAppKillByClientEvent(applicationId, message.toString(), callerUGI, remoteAddress));
    // For UnmanagedAMs, return true so they don't retry
    return KillApplicationResponse.newInstance(application.getApplicationSubmissionContext().getUnmanagedAM());
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) CallerContext(org.apache.hadoop.ipc.CallerContext) RMAppKillByClientEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppKillByClientEvent) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) AccessControlException(java.security.AccessControlException) IOException(java.io.IOException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) InetAddress(java.net.InetAddress) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 42 with AccessControlException

use of java.security.AccessControlException in project javatari by ppeccin.

the class Monitor method loadCartridgeFromFile.

private void loadCartridgeFromFile(boolean autoPower) {
    if (cartridgeChangeDisabledWarning())
        return;
    display.displayLeaveFullscreen();
    Cartridge cart = null;
    try {
        File file = FileROMChooser.chooseFileToLoad();
        if (file != null)
            cart = ROMLoader.load(file);
    } catch (AccessControlException e) {
        // Automatically tries FileServiceChooser if access is denied
        FileContents fileContents = FileServiceROMChooser.chooseFileToLoad();
        if (fileContents != null)
            cart = ROMLoader.load(fileContents);
    }
    if (cart != null)
        cartridgeInsert(cart, autoPower);
    else
        display.displayRequestFocus();
}
Also used : Cartridge(org.javatari.atari.cartridge.Cartridge) FileContents(javax.jnlp.FileContents) AccessControlException(java.security.AccessControlException) File(java.io.File)

Example 43 with AccessControlException

use of java.security.AccessControlException in project spock by spockframework.

the class ConfigurationScriptLoader method loadScriptFromFileSystemLocation.

@Nullable
private DelegatingScript loadScriptFromFileSystemLocation(String location) {
    File file = new File(location);
    try {
        if (!file.exists())
            return null;
    } catch (AccessControlException e) {
        // so let's just assume it's not there and continue
        return null;
    }
    GroovyShell shell = createShell();
    try {
        return (DelegatingScript) shell.parse(file);
    } catch (IOException e) {
        throw new ConfigurationException("Error reading configuration script '%s'", location);
    } catch (CompilationFailedException e) {
        throw new ConfigurationException("Error compiling configuration script '%s'", location);
    }
}
Also used : ConfigurationException(spock.config.ConfigurationException) DelegatingScript(org.spockframework.builder.DelegatingScript) AccessControlException(java.security.AccessControlException) CompilationFailedException(org.codehaus.groovy.control.CompilationFailedException) IOException(java.io.IOException) File(java.io.File) Nullable(org.spockframework.util.Nullable)

Example 44 with AccessControlException

use of java.security.AccessControlException in project spring-framework by spring-projects.

the class EnvironmentSecurityManagerIntegrationTests method securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys.

@Test
public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() {
    SecurityManager securityManager = new SecurityManager() {

        @Override
        public void checkPermission(Permission perm) {
            // ReadOnlySystemAttributesMap will come into play.
            if ("getenv.*".equals(perm.getName())) {
                throw new AccessControlException("Accessing the system environment is disallowed");
            }
        }
    };
    System.setSecurityManager(securityManager);
    DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
    AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
    reader.register(C1.class);
    assertThat(bf.containsBean("c1"), is(true));
}
Also used : Permission(java.security.Permission) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) AccessControlException(java.security.AccessControlException) AnnotatedBeanDefinitionReader(org.springframework.context.annotation.AnnotatedBeanDefinitionReader) Test(org.junit.Test)

Example 45 with AccessControlException

use of java.security.AccessControlException in project jetbrick-template-1x by subchen.

the class SecurityManagerTestCase method methodAccess.

@Test
public void methodAccess() throws Exception {
    try {
        JetTemplate template = engine.createTemplate("${new Date().time}");
        UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
        template.render(new JetContext(), out);
    } catch (AccessControlException e) {
        return;
    }
    Assert.fail();
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) AccessControlException(java.security.AccessControlException) Test(org.junit.Test)

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