List of usage examples for java.lang SecurityException SecurityException
public SecurityException(Throwable cause)
From source file:de.fosd.jdime.Main.java
/** * Dumps the given <code>FileArtifact</code> using the <code>mode</code>. * * @param artifact//from w w w . ja va2s .c om * the <code>Artifact</code> to dump * @param mode * the dump format */ private static void dump(FileArtifact artifact, DumpMode mode) { if (mode == DumpMode.NONE) { return; } if (mode == DumpMode.FILE_DUMP || artifact.isDirectory()) { System.out.println(artifact.dump(mode)); } else { SecurityManager prevSecManager = System.getSecurityManager(); SecurityManager noExitManager = new SecurityManager() { @Override public void checkPermission(Permission perm) { // allow anything. } @Override public void checkPermission(Permission perm, Object context) { // allow anything. } @Override public void checkExit(int status) { super.checkExit(status); throw new SecurityException("Captured attempt to exit JVM."); } }; ASTNodeArtifact astArtifact; System.setSecurityManager(noExitManager); try { astArtifact = new ASTNodeArtifact(artifact); } catch (RuntimeException e) { LOG.log(Level.WARNING, e, () -> "Could not parse " + artifact + " to an ASTNodeArtifact."); return; } finally { System.setSecurityManager(prevSecManager); } System.out.println(astArtifact.dump(mode)); } }
From source file:org.oscarehr.fax.admin.ManageFaxes.java
public ActionForward SetCompleted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {//from w ww . ja v a 2s.c o m if (!securityInfoManager.hasPrivilege(LoggedInInfo.getLoggedInInfoFromSession(request), "_admin", "w", null)) { throw new SecurityException("missing required security object (_admin)"); } String id = request.getParameter("jobId"); FaxJobDao faxJobDao = SpringUtils.getBean(FaxJobDao.class); FaxJob faxJob = faxJobDao.find(Integer.parseInt(id)); faxJob.setStatus(FaxJob.STATUS.RESOLVED); faxJobDao.merge(faxJob); return null; }
From source file:org.fao.geonet.api.records.attachments.FilesystemStore.java
private void canEdit(ServiceContext context, String metadataUuid, MetadataResourceVisibility visibility) throws Exception { ApplicationContext _appContext = ApplicationContextHolder.get(); String metadataId = getAndCheckMetadataId(metadataUuid); AccessManager accessManager = _appContext.getBean(AccessManager.class); boolean canEdit = accessManager.canEdit(context, metadataId); if ((visibility == null && !canEdit) || (visibility == MetadataResourceVisibility.PRIVATE && !canEdit)) { throw new SecurityException( String.format("User does not have privileges to access '%s' resources for metadata '%s'.", visibility == null ? "any" : visibility, metadataUuid)); }/* w ww . j a v a 2 s . c om*/ }
From source file:jenkins.security.ClassFilterImpl.java
private void notifyRejected(@CheckForNull Class<?> clazz, @CheckForNull String clazzName, String message) { Throwable cause = null;/*from ww w . j a v a2s .c om*/ if (LOGGER.isLoggable(Level.FINE)) { cause = new SecurityException( "Class rejected by the class filter: " + (clazz != null ? clazz.getName() : clazzName)); } LOGGER.log(Level.WARNING, message, cause); // TODO: add a Telemetry implementation (JEP-304) }
From source file:org.pentaho.pat.server.services.impl.SessionServiceImpl.java
public void validateSession(final String userId, final String sessionId) throws SecurityException { this.validateUser(userId); if (!sessions.containsKey(userId) || !sessions.get(userId).containsKey(sessionId)) { throw new SecurityException(Messages.getString("Services.InvalidSessionOrUserId")); //$NON-NLS-1$ }//w w w. j a v a2s . c om }
From source file:org.microg.gms.maps.GoogleMapImpl.java
@Override public void setMyLocationEnabled(boolean myLocation) throws RemoteException { Log.w(TAG, "MyLocation not yet supported"); boolean hasPermission = ContextCompat.checkSelfPermission(context, ACCESS_COARSE_LOCATION) == PERMISSION_GRANTED || ContextCompat.checkSelfPermission(context, ACCESS_FINE_LOCATION) == PERMISSION_GRANTED; if (!hasPermission) { throw new SecurityException( "Neither " + ACCESS_COARSE_LOCATION + " nor " + ACCESS_FINE_LOCATION + " granted."); }/*from ww w . ja v a 2 s . c om*/ LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); if (myLocation) { locationManager.requestLocationUpdates(5000, 10, criteria, listener, Looper.getMainLooper()); } else { locationManager.removeUpdates(listener); } }
From source file:org.onecmdb.core.utils.wsdl.OneCMDBWebServiceImpl.java
public String newInstanceAlias(String auth, String templateAlias) { // Update all beans. ISession session = onecmdb.getSession(auth); if (session == null) { throw new SecurityException("No Session found! Try to do auth() first!"); }/*from w ww . ja va 2 s . com*/ // For now use the file system. File file = new File(DATA_PATH + "/" + templateAlias + "/"); if (!file.exists()) { file.mkdirs(); } // Make sure we are alone. synchronized (this) { String files[] = file.list(); int offset = 0; if (files.length == 0) { // Validate offset... offset = 1; } else { offset = Integer.parseInt(files[0]); } offset = validateInstanceOffset(session, offset, templateAlias); if (files.length == 0) { // Create new offset. File index = new File(file, "" + offset); try { if (!index.createNewFile()) { } } catch (Exception e) { throw new IllegalArgumentException("Can't create index file path " + file.getPath()); } } else { File newIndex = new File(file, "" + offset); File oldFile = new File(file, files[0]); oldFile.renameTo(newIndex); } return (templateAlias + "-" + offset); } }
From source file:com.ikanow.aleph2.security.service.SecuredCrudManagementDbService.java
protected void checkWritePermissions(T new_object) { //boolean permitted = securityService.hasRole(principalName,ROLE_ADMIN); boolean permitted = securityService.isUserPermitted(principalName, new_object, Optional.of(ISecurityService.ACTION_WRITE)); //still not permitted, we are out of luck if (!permitted) { //String msg = "principalName "+principalName+" has no write permissions ("+permissions+")for "+new_object.getClass(); String msg = "Subject " + principalName + " has no write permissions for " + new_object.getClass(); logger.error(msg);//ww w .j ava2s. c o m throw new SecurityException(msg); } }
From source file:org.pentaho.pat.server.services.impl.SessionServiceImpl.java
public void validateUser(final String userId) throws SecurityException { User user = this.userManager.getUser(userId); if (user == null) { throw new SecurityException(Messages.getString("Services.InvalidSessionOrUserId")); //$NON-NLS-1$ }/*from ww w . j av a 2 s . c o m*/ }
From source file:info.magnolia.cms.security.SecurityUtil.java
private static void checkPrivateKeyStoreExistence(final String path) throws SecurityException { if (StringUtils.isBlank(path)) { throw new SecurityException("Private key store path is either null or empty. Please, check [" + KEY_LOCATION_PROPERTY + "] value in magnolia.properties"); }/*from w ww.jav a2s.co m*/ String absPath = Path.getAbsoluteFileSystemPath(path); File keypair = new File(absPath); if (!keypair.exists()) { throw new SecurityException( "Private key store doesn't exist at [" + keypair.getAbsolutePath() + "]. Please, ensure that [" + KEY_LOCATION_PROPERTY + "] actually points to the correct location"); } }