List of usage examples for java.lang SecurityException SecurityException
public SecurityException(Throwable cause)
From source file:com.auditbucket.engine.service.TrackService.java
public MetaHeader getHeader(Company company, @NotEmpty String headerKey, boolean inflate) { if (company == null) return getHeader(headerKey); MetaHeader ah = trackDao.findHeader(headerKey, inflate); if (ah == null) return null; if (!(ah.getFortress().getCompany().getId().equals(company.getId()))) throw new SecurityException( "CompanyNode mismatch. [" + headerKey + "] working for [" + company.getName() + "] cannot write meta records for [" + ah.getFortress().getCompany().getName() + "]"); return ah;//from ww w . j a va2 s . c o m }
From source file:org.lnicholls.galleon.server.Server.java
public static void setup(ArrayList errors) { System.setProperty("os.user.home", System.getProperty("user.home")); System.setProperty("http.agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); try {/*from w w w . j av a 2 s . c o m*/ File file = new File("."); String root = file.getAbsolutePath() + "/.."; if (System.getProperty("root") == null) System.setProperty("root", root); else root = System.getProperty("root"); File check = new File(System.getProperty("root")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: root=" + System.getProperty("root")); System.setProperty("user.home", System.getProperty("root")); if (System.getProperty("bin") == null) System.setProperty("bin", root + "/bin"); check = new File(System.getProperty("bin")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: bin=" + System.getProperty("bin")); if (System.getProperty("conf") == null) System.setProperty("conf", root + "/conf"); check = new File(System.getProperty("conf")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: conf=" + System.getProperty("conf")); if (System.getProperty("cache") == null) System.setProperty("cache", root + "/data"); check = new File(System.getProperty("cache")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: cache=" + System.getProperty("cache")); if (System.getProperty("data") == null) System.setProperty("data", root + "/data"); check = new File(System.getProperty("data")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: data=" + System.getProperty("data")); if (System.getProperty("apps") == null) System.setProperty("apps", root + "/apps"); check = new File(System.getProperty("apps")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: apps=" + System.getProperty("apps")); if (System.getProperty("hme") == null) System.setProperty("hme", root + "/hme"); check = new File(System.getProperty("hme")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: hme=" + System.getProperty("hme")); if (System.getProperty("skins") == null) System.setProperty("skins", root + "/skins"); check = new File(System.getProperty("skins")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: skins=" + System.getProperty("skins")); if (System.getProperty("logs") == null) System.setProperty("logs", root + "/logs"); check = new File(System.getProperty("logs")); if (!check.exists() || !check.isDirectory()) errors.add("Invalid system propery: logs=" + System.getProperty("logs")); if (System.getProperty("demo") != null) mDemoMode = Boolean.valueOf(System.getProperty("demo")).booleanValue(); if (System.getProperty("remoteHost") != null) { System.setSecurityManager(new RMISecurityManager() { public void checkConnect(String host, int port) { if (host != null && host.equals(System.getProperty("remoteHost"))) return; throw new SecurityException("Invalid remote host: " + host); } public void checkConnect(String host, int port, Object context) { if (host != null && host.equals(System.getProperty("remoteHost"))) return; throw new SecurityException("Invalid remote host: " + host); } }); } } catch (Exception ex) { Tools.logException(Server.class, ex); } }
From source file:be.e_contract.mycarenet.certra.CertRAClient.java
public static String getSSIN(X509Certificate certificate) { X500Principal userPrincipal = certificate.getSubjectX500Principal(); String name = userPrincipal.toString(); int serialNumberBeginIdx = name.indexOf("SERIALNUMBER="); if (-1 == serialNumberBeginIdx) { throw new SecurityException("SERIALNUMBER not found in X509 CN"); }/*from w w w . j av a 2s . co m*/ int serialNumberValueBeginIdx = serialNumberBeginIdx + "SERIALNUMBER=".length(); int serialNumberValueEndIdx = name.indexOf(",", serialNumberValueBeginIdx); if (-1 == serialNumberValueEndIdx) { serialNumberValueEndIdx = name.length(); } String userId = name.substring(serialNumberValueBeginIdx, serialNumberValueEndIdx); return userId; }
From source file:eu.trentorise.smartcampus.communicatorservice.storage.CommunicatorStorage.java
private void checkObject(String user, String id, String app, BasicObject o) throws NotFoundException, DataException { Notification n;/*from w w w . j a v a 2 s . com*/ try { n = getObjectById(id, Notification.class); } catch (Exception e) { // this should not happen ... return; } // this should not be the case; just take into account legacy messages if (n.getUser() == null) n.setUser(user); if (n.getType() == null) n.setType(app); if (!user.equals(n.getUser())) throw new SecurityException("wrong user: expected " + n.getUser() + " found " + user); if (app != null && !app.equals(n.getType())) throw new SecurityException("wrong app: expected " + n.getType() + " found " + app); if (o != null) { o.setUser(user); } }
From source file:org.sakaiproject.poll.service.impl.PollListManagerImpl.java
public boolean deletePoll(Poll t) throws SecurityException, IllegalArgumentException { if (t == null) { throw new IllegalArgumentException("Poll can't be null"); }//from w w w. jav a2 s .com if (t.getPollId() == null) { throw new IllegalArgumentException("Poll id can't be null"); } if (!pollCanDelete(t)) { throw new SecurityException( "user:" + externalLogic.getCurrentuserReference() + " can't delete poll: " + t.getId()); } //Delete the Votes List<Vote> vote = t.getVotes(); //We could have a partially populate item if (vote == null || vote.isEmpty()) { log.debug("getting votes as they where null"); vote = pollVoteManager.getAllVotesForPoll(t); log.debug("got " + vote.size() + " vote"); } Set<Vote> voteSet = new HashSet<Vote>(vote); dao.deleteSet(voteSet); //Delete the Options List<Option> options = t.getPollOptions(); //as above we could have a partialy populate item if (options == null || options.isEmpty()) { options = getOptionsForPoll(t); } Set<Option> optionSet = new HashSet<Option>(options); dao.deleteSet(optionSet); dao.delete(t); log.info("Poll id " + t.getId() + " deleted"); externalLogic.postEvent("poll.delete", "poll/site/" + t.getSiteId() + "/poll/" + t.getId(), true); return true; }
From source file:org.broadleafcommerce.core.web.controller.account.BroadleafManageCustomerAddressesController.java
protected void validateCustomerOwnedData(CustomerAddress customerAddress) { if (validateCustomerOwnedData) { Customer activeCustomer = CustomerState.getCustomer(); if (activeCustomer != null && !(activeCustomer.equals(customerAddress.getCustomer()))) { throw new SecurityException( "The active customer does not own the object that they are trying to view, edit, or remove."); }/* ww w.j av a2 s .c o m*/ if (activeCustomer == null && customerAddress.getCustomer() != null) { throw new SecurityException( "The active customer does not own the object that they are trying to view, edit, or remove."); } } }
From source file:org.madsonic.service.MediaFileService.java
public MediaFile getMediaFile(int id, int user_group_id) { MediaFile mediaFile = mediaFileDao.getMediaFile(id); if (mediaFile == null) { return null; }// www.ja va 2 s.c o m if (securityService.isAccessAllowed(mediaFile.getFile(), user_group_id) == false) { return null; } else { if (!securityService.isReadAllowed(mediaFile.getFile(), user_group_id)) { throw new SecurityException("Access denied to file " + mediaFile); } } return checkLastModified(mediaFile, settingsService.isFastCacheEnabled()); }
From source file:org.onecmdb.core.utils.wsdl.OneCMDBWebServiceImpl.java
public RFCBean[] history(String auth, CiBean bean, RfcQueryCriteria criteria) { long start = System.currentTimeMillis(); log.info("WSDL: history(" + auth + ", " + criteria + ")"); // Update all beans. ISession session = onecmdb.getSession(auth); if (session == null) { throw new SecurityException("No Session found! Try to do auth() first!"); }/*w ww.j a v a2s.c o m*/ // Find the ci if provided. IModelService modelSvc = (IModelService) session.getService(IModelService.class); ICi ci = null; if (bean != null) { if (bean.getId() != null) { ci = modelSvc.find(new ItemId(bean.getId())); if (ci == null) { throw new IllegalArgumentException("CI with id <" + bean.getId() + "> not found"); } } else if (bean.getAlias() != null) { ci = modelSvc.findCi(new Path<String>(bean.getAlias())); if (ci == null) { throw new IllegalArgumentException("CI with alias <" + bean.getAlias() + "> not found"); } } } ICcb ccbSvc = (ICcb) session.getService(ICcb.class); List<IRFC> rfcs = ccbSvc.queryRFCForCi(ci, criteria); long stop = System.currentTimeMillis(); log.info("WSDL: history completed in " + (stop - start) + "ms returned + " + rfcs.size() + " objects"); start = stop; stop = System.currentTimeMillis(); log.info( "WSDL: history convert completed in " + (stop - start) + "ms returned + " + rfcs.size() + " beans"); List<RFCBean> rfcBeans = convert(session, rfcs); return (rfcBeans.toArray(new RFCBean[0])); }
From source file:net.es.netshell.kernel.users.Users.java
@SysCall(name = "do_setPassword") public void do_setPassword(String userName, String newPassword) throws NonExistentUserException, IOException { if (BootStrap.getBootStrap().isStandAlone()) { throw new SecurityException("not allowed"); }//from w ww. j av a 2 s . c o m logger.info("do_setPassword entry"); try { this.readUserFile(); } catch (IOException e) { logger.error("Cannot read password file"); } // Make sure the user exists. if (!this.passwords.containsKey(userName)) { throw new NonExistentUserException(userName); } UserProfile userProfile = Users.getUsers().passwords.get(userName); // Encrypt new password and write out the users file userProfile.setPassword(crypt(newPassword)); this.writeUserFile(); }
From source file:org.oscarehr.fax.admin.ManageFaxes.java
public ActionForward ResendFax(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {/*from www .j av a 2 s . c om*/ String JobId = request.getParameter("jobId"); String faxNumber = request.getParameter("faxNumber"); JSONObject jsonObject; if (!securityInfoManager.hasPrivilege(LoggedInInfo.getLoggedInInfoFromSession(request), "_admin", "w", null)) { throw new SecurityException("missing required security object (_admin)"); } try { FaxJobDao faxJobDao = SpringUtils.getBean(FaxJobDao.class); FaxJob faxJob = faxJobDao.find(Integer.parseInt(JobId)); faxJob.setDestination(faxNumber); faxJob.setStatus(FaxJob.STATUS.SENT); faxJob.setStamp(new Date()); faxJob.setJobId(null); faxJobDao.merge(faxJob); jsonObject = JSONObject.fromObject("{success:true}"); } catch (Exception e) { jsonObject = JSONObject.fromObject("{success:false}"); log.error("ERROR RESEND FAX " + JobId); } try { jsonObject.write(response.getWriter()); } catch (IOException e) { MiscUtils.getLogger().error("JSON WRITER ERROR", e); } return null; }