List of usage examples for java.lang SecurityException printStackTrace
public void printStackTrace()
From source file:org.sakaiproject.poll.logic.test.PollListManagerTest.java
@Test public void testSavePoll() { externalLogicStubb.currentUserId = TestDataPreload.USER_UPDATE; Poll poll1 = new Poll(); poll1.setCreationDate(new Date()); poll1.setVoteOpen(new Date()); poll1.setVoteClose(new Date()); poll1.setDescription("this is some text"); poll1.setText("something"); poll1.setOwner(TestDataPreload.USER_UPDATE); poll1.setSiteId(TestDataPreload.LOCATION1_ID); //If this has a value something is wrong without POJO Assert.assertNull(poll1.getPollId()); pollListManager.savePoll(poll1);/*from w w w .j a v a 2s .c o m*/ //if this is null we have a problem Assert.assertNotNull(poll1.getPollId()); Poll poll2 = pollListManager.getPollById(poll1.getPollId()); Assert.assertNotNull(poll2); Assert.assertEquals(poll1.getPollText(), poll2.getPollText()); //TODO add failure cases - null parameters //we should not be able to save empty polls //a user needs privileges to save the poll try { pollListManager.savePoll(null); Assert.fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); } //a user needs privileges to save the poll try { Poll poll = new Poll(); poll.setText("sdfgsdf"); pollListManager.savePoll(poll); Assert.fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); } externalLogicStubb.currentUserId = TestDataPreload.USER_NO_ACCEESS; try { pollListManager.savePoll(poll1); Assert.fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException se) { se.printStackTrace(); } }
From source file:main.java.org.ros.robot.SensorListener.java
@SuppressWarnings("rawtypes") public void publishData(SensorData message) { // so go through and publish data based on names Class theMessage = message.getClass(); Field messField;/* w w w . j a v a2s . co m*/ Set<String> keys = publisher.keySet(); Iterator<String> itr = keys.iterator(); while (itr.hasNext()) { String fieldName = itr.next(); try { // get the field name messField = theMessage.getField(fieldName); // get the current time for the time stamps //Time timeStamp = node.getCurrentTime(); if (fieldName.contains("infrared")) { // get the field data float rangeData = (Float) messField.get(message); pubRange.get(fieldName).range = (float) (rangeData * .01); // I am using secs in the header to be the key // since timestamp secs couldn't keep up (neither could nsecs) // I define my own secs in terms of when it leaves here pubRange.get(fieldName).header.stamp.secs = (int) count; // now publish it! publisher.get(fieldName).publish(pubRange.get(fieldName)); } else if (fieldName.contains("ultrasonic")) { // get field data // must do this because java doesn't have unsigned bytes... int rangeData = ((Byte) messField.get(message)) & 0xff; log.debug(rangeData); pubRange.get(fieldName).range = (float) ((float) rangeData * .01); // I am using secs in the header to be the key // since timestamp secs couldn't keep up (neither could nsecs) // I define my own secs in terms of when it leaves here pubRange.get(fieldName).header.stamp.secs = (int) count; publisher.get(fieldName).publish(pubRange.get(fieldName)); } else if (fieldName.contains("human")) { // this outputs the human data as range messages // get the range int rangeData = (Integer) messField.get(message); // put in the data pubRange.get(fieldName).range = (float) rangeData; // I am using secs in the header to be the key // since timestamp secs couldn't keep up (neither could nsecs) // I define my own secs in terms of when it leaves here pubRange.get(fieldName).header.stamp.secs = (int) count; //log.info("Recieved Message from " + fieldName + " range is " + pubRange.range); publisher.get(fieldName).publish(pubRange.get(fieldName)); } } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
From source file:org.sakaiproject.kernel.webapp.filter.SakaiRequestFilter.java
/** * {@inheritDoc}//w ww . j ava 2 s .c o m * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest hrequest = (HttpServletRequest) request; String requestedSessionID = hrequest.getRequestedSessionId(); if (noSession) { request.setAttribute(SakaiServletRequest.NO_SESSION_USE, "true"); } SakaiServletRequest wrequest = new SakaiServletRequest(request, response, userResolverService, sessionManagerService); SakaiServletResponse wresponse = new SakaiServletResponse(response); sessionManagerService.bindRequest(wrequest); try { begin(); if (timeOn) { long start = System.currentTimeMillis(); try { chain.doFilter(wrequest, wresponse); } finally { long end = System.currentTimeMillis(); LOG.info("Request took " + hrequest.getMethod() + " " + hrequest.getPathInfo() + " " + (end - start) + " ms"); } } else { chain.doFilter(wrequest, wresponse); } try { if (jcrService.hasActiveSession()) { Session session = jcrService.getSession(); session.save(); } } catch (AccessDeniedException e) { throw new SecurityException(e.getMessage(), e); } catch (Exception e) { LOG.warn(e); } commit(); } catch (SecurityException se) { se.printStackTrace(); rollback(); // catch any Security exceptions and send a 401 wresponse.reset(); wresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, se.getMessage()); } catch (UnauthorizedException ape) { rollback(); // catch any Unauthorized exceptions and send a 401 wresponse.reset(); wresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, ape.getMessage()); } catch (PermissionDeniedException pde) { rollback(); // catch any permission denied exceptions, and send a 403 wresponse.reset(); wresponse.sendError(HttpServletResponse.SC_FORBIDDEN, pde.getMessage()); } catch (RuntimeException e) { rollback(); throw e; } catch (IOException e) { rollback(); throw e; } catch (ServletException e) { rollback(); throw e; } catch (Throwable t) { rollback(); throw new ServletException(t.getMessage(), t); } finally { wresponse.commitStatus(sessionManagerService); cacheManagerService.unbind(CacheScope.REQUEST); } if (debug) { HttpSession hsession = hrequest.getSession(false); if (hsession != null && !hsession.getId().equals(requestedSessionID)) { LOG.debug("New Session Created with ID " + hsession.getId()); } } }
From source file:blue.orchestra.blueSynthBuilder.BSBCloneTest.java
public void testLoadSave() { BSBObjectEntry[] bsbObjects = BSBObjectRegistry.getBSBObjects(); for (int i = 0; i < bsbObjects.length; i++) { BSBObjectEntry entry = bsbObjects[i]; Class class1 = entry.bsbObjectClass; BSBObject bsbObj = null;/*from w w w. ja va2 s . c om*/ try { bsbObj = (BSBObject) class1.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } assertNotNull(bsbObj); if (bsbObj == null) { continue; } Element elem1 = bsbObj.saveAsXML(); Method m = null; try { m = class1.getMethod("loadFromXML", new Class[] { Element.class }); } catch (SecurityException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NoSuchMethodException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BSBObject bsbObj2 = null; assertNotNull(m); if (m == null) { continue; } try { bsbObj2 = (BSBObject) m.invoke(bsbObj, new Object[] { elem1 }); } catch (IllegalArgumentException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (IllegalAccessException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (InvocationTargetException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } boolean isEqual = EqualsBuilder.reflectionEquals(bsbObj, bsbObj2); if (!isEqual) { StringBuilder buffer = new StringBuilder(); buffer.append("Problem with class: ").append(class1.getName()).append("\n"); buffer.append("Original Object\n"); buffer.append(ToStringBuilder.reflectionToString(bsbObj)).append("\n"); buffer.append("Cloned Object\n"); buffer.append(ToStringBuilder.reflectionToString(bsbObj2)).append("\n"); System.out.println(buffer.toString()); } assertTrue(isEqual); } }
From source file:com.allmycode.flags.other.MyActivityOther.java
public void go(View view) { Intent intent = new Intent(); String targetActivityName = "com.allmycode.flags"; String fromEditText = targetActivity.getText().toString().trim(); String other = (fromEditText.contains("Other")) ? ".other" : ""; targetActivityName += other;//from ww w . ja v a2 s . co m targetActivityName += ".FlagsDemoActivity"; targetActivityName += fromEditText; Log.i(CLASSNAME, "Target activity: >>" + targetActivityName + "<<"); intent.setClassName("com.allmycode.flags" + other, targetActivityName); String allFlags = flags.getText().toString(); int flagsValue = 0; if (allFlags != "" && allFlags != null) { TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter('|'); splitter.setString(allFlags); boolean existErrors = false; for (String flagName : splitter) { Log.i(CLASSNAME, ">>" + flagName + "<<"); flagName = flagName.trim(); if (!flagName.equals("") && flagName != null) { // BARRY // need // both? if (isHex(flagName)) { Log.i(CLASSNAME, flagName + " is hex"); flagsValue |= Integer.parseInt(flagName.substring(2), 16); } else if (isDec(flagName)) { Log.i(CLASSNAME, flagName + " is decimal"); flagsValue |= Integer.parseInt(flagName); } else { Field flagsField = null; try { Log.i(CLASSNAME, "About to do reflection>>" + flagName + "<<"); flagsField = Intent.class.getField(flagName); Log.i(CLASSNAME, Integer.toString(flagsField.getInt(this))); flagsValue |= flagsField.getInt(this); } catch (SecurityException ex) { existErrors = true; ex.printStackTrace(); } catch (NoSuchFieldException ex) { existErrors = true; ex.printStackTrace(); } catch (IllegalAccessException ex) { existErrors = true; ex.printStackTrace(); } try { Log.i(CLASSNAME, Integer.toHexString(flagsValue)); if (flagsValue != 0) { intent.addFlags(flagsValue); } } catch (IllegalArgumentException e) { existErrors = true; e.printStackTrace(); } } } } if (flagsValue != 0) { intent.addFlags(flagsValue); } intent.putExtra("existErrors", existErrors); Log.i(CLASSNAME, "About to start " + intent.toString()); startActivity(intent); } }
From source file:com.allmycode.flags.MyActivity.java
public void go(View view) { Intent intent = null;/* w ww. j a v a 2 s .co m*/ String targetActivityName = "com.allmycode.flags"; intent = new Intent(); String fromEditText = targetActivity.getText().toString().trim(); String other = (fromEditText.contains("Other")) ? ".other" : ""; targetActivityName += other; targetActivityName += ".FlagsDemoActivity"; targetActivityName += fromEditText; Log.i(CLASSNAME, "Target activity: >>" + targetActivityName + "<<"); intent.setClassName("com.allmycode.flags" + other, targetActivityName); String allFlags = flags.getText().toString(); int flagsValue = 0; if (allFlags != "" && allFlags != null) { TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter('|'); splitter.setString(allFlags); boolean existErrors = false; for (String flagName : splitter) { Log.i(CLASSNAME, ">>" + flagName + "<<"); flagName = flagName.trim(); if (!flagName.equals("") && flagName != null) { // BARRY // need // both? if (isHex(flagName)) { Log.i(CLASSNAME, flagName + " is hex"); flagsValue |= Integer.parseInt(flagName.substring(2), 16); } else if (isDec(flagName)) { Log.i(CLASSNAME, flagName + " is decimal"); flagsValue |= Integer.parseInt(flagName); } else { Field flagsField = null; try { Log.i(CLASSNAME, "About to do reflection>>" + flagName + "<<"); flagsField = Intent.class.getField(flagName); Log.i(CLASSNAME, Integer.toString(flagsField.getInt(this))); flagsValue |= flagsField.getInt(this); } catch (SecurityException ex) { existErrors = true; ex.printStackTrace(); } catch (NoSuchFieldException ex) { existErrors = true; ex.printStackTrace(); } catch (IllegalAccessException ex) { existErrors = true; ex.printStackTrace(); } try { Log.i(CLASSNAME, Integer.toHexString(flagsValue)); if (flagsValue != 0) { intent.addFlags(flagsValue); } } catch (IllegalArgumentException e) { existErrors = true; e.printStackTrace(); } } } } if (flagsValue != 0) { intent.addFlags(flagsValue); } intent.putExtra("existErrors", existErrors); Log.i(CLASSNAME, "About to start " + intent.toString()); startActivity(intent); } }
From source file:node.Mailbox.java
/** * set up the mailbox/*from w ww . j a v a2 s . c om*/ * * @param _msgsSend * @param _evolveMsgsRecv * @param _ctrlMsgsRecv * @param reportSend2 */ public Mailbox(int _port, NodeList _nodeList, BlockingQueue<ControlMessage> _ctrlMsgsRecv, BlockingQueue<EvolveMessage> _evolveMsgsRecv, BlockingQueue<MessageWrapper<AbstractMessage>> _msgsSend, BlockingQueue<JSONObject> _reportSend) { // for now, hard-code REPORT to false REPORT = false; ctrlMsgsRecv = _ctrlMsgsRecv; evolveMsgsRecv = _evolveMsgsRecv; msgsSend = _msgsSend; reportSend = _reportSend; port = _port; nodeList = _nodeList; shutdown = false; try { log.setUseParentHandlers(false); Handler fh = new FileHandler("mailbox.log"); fh.setFormatter(new TextFormatter()); log.addHandler(fh); log.setLevel(Level.ALL); } catch (SecurityException e) { e.printStackTrace(); log.severe(ExceptionUtils.getStackTrace(e)); } catch (IOException e) { e.printStackTrace(); log.severe(ExceptionUtils.getStackTrace(e)); } Control.logOneTime("Mailbox started up"); }
From source file:org.sakaiproject.kernel.webapp.RestServlet.java
/** * {@inheritDoc}//from w w w .ja v a 2s .co m * * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String requestPath = request.getPathInfo(); if (requestPath == null) { requestPath = ""; } String[] elements = StringUtils.split(requestPath, '/'); String locator = "default"; if (elements != null && elements.length > 0) { locator = elements[0]; } Map<String, RestProvider> restProviders = registry.getMap(); if (locator == null) { locator = "default"; } if ("__describe__".equals(locator)) { locator = "default"; } RestProvider restProvider = restProviders.get(locator); if (restProvider == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { try { if (requestPath.endsWith("__describe__")) { RestDescription description = restProvider.getDescription(); String format = request.getParameter("fmt"); if ("xml".equals(format)) { response.setContentType("text/xml"); response.getWriter().print(description.toXml()); } else if ("json".equals(format)) { response.setContentType(RestProvider.CONTENT_TYPE); response.getWriter().print(description.toJson()); } else { response.setContentType("text/html"); response.getWriter().print(description.toHtml()); } } else { restProvider.dispatch(elements, request, response); } } catch (SecurityException ex) { response.reset(); response.sendError(HttpServletResponse.SC_FORBIDDEN, ex.getMessage()); } catch (RestServiceFaultException ex) { ex.printStackTrace(); response.reset(); response.sendError(ex.getStatusCode(), ex.getMessage()); } } }
From source file:org.squale.welcom.struts.action.WRequestProcessor.java
/** * effectue un populate en conction des dates * //from w ww .j av a 2s . co m * @param form : fomulaire * @param request : request * @parem element : Nom du champs */ private void processPopulateDate(final HttpServletRequest request, final ActionForm form, final String element) { if (element.endsWith("WDate") && !element.equals("WDate")) { final String field = element.substring(0, element.lastIndexOf("WDate")); String formattedDate = TagUtils.getDateHeureFromDateTag(request, field); final HashMap formatMaps = (HashMap) request.getSession().getAttribute(DATE_FORMAT_KEY); try { final Class propertyType = PropertyUtils.getPropertyType(form, field); if (propertyType != null) { boolean isTypeDate = propertyType.equals(Date.class); Object emptyValue = null; if (!isTypeDate) { emptyValue = ""; } if ((formatMaps != null) && (formatMaps.get(field + "WDate") != null)) { String pattern = (String) formatMaps.get(field + "WDate"); if (formatMaps.get(field + "WHour") != null) { pattern = pattern + " " + formatMaps.get(field + "WHour"); } if (GenericValidator.isBlankOrNull(formattedDate)) { BeanUtils.setProperty(form, field, emptyValue); } else { Locale locale = (Locale) request.getSession().getAttribute(Globals.LOCALE_KEY); SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, locale); dateFormat.setLenient(false); try { Date newDate = dateFormat.parse(formattedDate); if (dateFormat.format(newDate).equals(formattedDate)) { try { if (isTypeDate) { LayoutUtils.setProperty(form, field, newDate); } else { LayoutUtils.setProperty(form, field, String.valueOf(newDate.getTime())); } } catch (SecurityException e1) { e1.printStackTrace(); } } else { BeanUtils.setProperty(form, field, emptyValue); } } catch (ParseException e) { e.printStackTrace(); LayoutUtils.setProperty(form, field, emptyValue); } } } else { if (formattedDate == null) { formattedDate = ""; } BeanUtils.setProperty(form, field, formattedDate); } } } catch (final JspException e1) { e1.printStackTrace(); } catch (final IllegalAccessException e3) { e3.printStackTrace(); } catch (final InvocationTargetException e3) { e3.printStackTrace(); } catch (final NoSuchMethodException e3) { e3.printStackTrace(); } } }
From source file:gwap.game.quiz.PlayNHighscoreCommunicationResource.java
private void doWork(HttpServletRequest request, HttpServletResponse response) throws IOException { this.response = response; QuizHighscore quizHighscore = readOutJSONData(request); try {/*from w w w .j av a 2 s. c o m*/ Transaction.instance().begin(); QuizHighscoreBean quizHighscoreBean = (QuizHighscoreBean) Component.getInstance("quizHighscoreBean"); int placeAllTime = 0; int placeThisWeek = 0; List<QuizHighscore> highscores = new ArrayList<QuizHighscore>(); if (action.equals("GetEvaluation")) { placeAllTime = quizHighscoreBean.getPlaceAllTime(quizHighscore.getScore()) + 1; placeThisWeek = quizHighscoreBean.getPlaceThisWeek(quizHighscore.getScore()) + 1; } else if (action.equals("Store")) { if (quizHighscore != null) { quizHighscoreBean.addHighscore(quizHighscore); } } else if (action.equals("GetHighscores")) { if (mode.equals("All Time")) { highscores = quizHighscoreBean.getHighScoresAllTime(); } else { highscores = quizHighscoreBean.getHighScoresThisWeek(); } } JSONObject jsonObject = createJSONForFeedback(highscores, placeAllTime, placeThisWeek); sendJSONObject(jsonObject); Transaction.instance().commit(); } catch (NotSupportedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (RollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicMixedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } }