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());
}
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();
}
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);
}
}
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));
}
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();
}
Aggregations