List of usage examples for org.apache.commons.codec.binary Base64 Base64
public Base64()
From source file:com.globalsight.everest.usermgr.UserManagerLocal.java
static String encyptMD5Password(String passwd) { try {//from ww w.j a va 2 s. co m byte[] md5Msg = MessageDigest.getInstance(LDAP_PWD_MD5).digest(passwd.getBytes()); return LDAP_PREFIX_MD5 + new String(new Base64().encode(md5Msg)); } catch (NoSuchAlgorithmException e) { CATEGORY.error("The system didn't support the Md5 ALGORITHM", e); } return passwd; }
From source file:Install.java
private static String encodeMD5(String msg) { try {/*from w w w . j ava 2 s .c om*/ byte[] md5Msg = MessageDigest.getInstance("MD5").digest(msg.getBytes()); return "{MD5}" + new String(new Base64().encode(md5Msg)); } catch (NoSuchAlgorithmException e) { System.err.println("Can not find the MD5 ALGORITHM."); return null; } }
From source file:ca.sqlpower.wabit.dao.WorkspaceSAXHandler.java
private void endElementImpl(final String uri, final String localName, final String name, ByteArrayOutputStream stream) throws SAXException { if (isCancelled()) return;//from ww w.j av a2 s. co m if (name.equals("project")) { //XXX uncomment the code below when we are confident that Wabit runs all //of its queries and other intensive operations on a separate thread. //See bug 2040. session.getWorkspace().setEditorPanelModel(session.getWorkspace()); // session.getWorkspace().setEditorPanelModel(initialView); } else if (name.equals("layout")) { isInLayout = false; } else if (name.equals("table")) { TableContainer table = new TableContainer(container.getUUID(), cache.getDatabase(), container.getName(), ((TableContainer) container).getSchema(), ((TableContainer) container).getCatalog(), containerItems); table.setPosition(container.getPosition()); table.setAlias(container.getAlias()); cache.addTable(table); } else if (name.equals("image-renderer")) { //This was loading an image for 1.1.2 and older. byte[] byteArray = new Base64().decode(stream.toByteArray()); if (byteArray.length > 0) { logger.debug("Decoding byte stream: Stream has " + stream.toString().length() + " and array has " + Arrays.toString(byteArray)); try { BufferedImage img = ImageIO.read(new ByteArrayInputStream(byteArray)); WabitImage wabitImage = new WabitImage(); wabitImage.setImage(img); wabitImage.setName(imageRenderer.getName()); session.getWorkspace().addImage(wabitImage); imageRenderer.setImage(wabitImage); } catch (IOException e) { throw new RuntimeException(e); } } imageRenderer = null; } else if (name.equals("wabit-image")) { byte[] byteArray = new Base64().decode(stream.toByteArray()); try { BufferedImage img = ImageIO.read(new ByteArrayInputStream(byteArray)); currentWabitImage.setImage(img); } catch (IOException e) { throw new RuntimeException(e); } currentWabitImage = null; } else if (name.equals("missing-columns")) { readingMissingChartCols = false; } else if (name.equals("chart")) { //XXX Fix for broken references in chart columns. The chart columns x axis references //are actual new chart columns and therefore have the wrong uuid. The chart column //uuids should be stored and used to reference each other instead of name. for (ChartColumn column : chart.getColumns()) { if (column.getXAxisIdentifier() != null) { for (ChartColumn otherColumn : chart.getColumns()) { if (column.getXAxisIdentifier().getColumnName().equals(otherColumn.getColumnName())) { column.setXAxisIdentifier(otherColumn); break; } } } } } else if (name.equals("text") && parentIs("content-label")) { ((WabitLabel) contentBox.getContentRenderer()).setText(stream.toString()); } else if (name.equals("text") && parentIs("query")) { cache.setUserModifiedQuery(stream.toString()); } xmlContext.pop(); }
From source file:com.viettel.hqmc.DAO.FilesDAO.java
public String onReviewManyFiles() { List resultMessage = new ArrayList(); jsonDataGrid.setItems(resultMessage); FilesDAOHE fdhe = new FilesDAOHE(); int nSuccess = 0; int nError = 0; String sid = ""; Long id = getRequest().getParameter("leaderId") == null ? 0L : Long.parseLong(getRequest().getParameter("leaderId")); String name = ""; try {//from w w w . j ava2 s. c o m Base64 decoder = new Base64(); name = new String(decoder.decode(getRequest().getParameter("leaderName").replace("_", "+").getBytes()), "UTF-8"); } catch (UnsupportedEncodingException ex) { LogUtil.addLog(ex);//binhnt sonar a160901 // Logger.getLogger(FilesDAO.class.getName()).log(Level.SEVERE, null, ex); } for (int i = 0; i < lstItemOnGrid.size(); i++) { FilesForm form = lstItemOnGrid.get(i); if (form != null && form.getFileId() != null && form.getFileId() != 0L) { boolean check = fdhe.validateRoleUser(form.getFileId(), form, getDepartmentId(), getDepartment().getDeptName(), getUserId(), getUserName()); if (check) { form.setStatus(Constants.FILE_STATUS.REVIEWED); form.setLeaderStaffRequest("Lnh o phng xem xt h s t."); form.setLeaderApproveId(id); form.setLeaderApproveName(name); boolean bReturn = fdhe.onReviewManyFiles(form, getDepartmentId(), getDepartment().getDeptName(), getUserId(), getUserName()); sid += form.getFileId() + ","; if (bReturn) { nSuccess++; } else { nError++; } } else { resultMessage.add("3"); resultMessage.add("Lu d liu khng thnh cng - Li phn quy?n ng?i dng"); } } } String strAlert = "Xem xt nhi?u h s thnh cng, c " + nSuccess + " h s thnh cng v " + nError + " h s xem xt khng thnh cng"; resultMessage.add("1"); resultMessage.add(strAlert); EventLogDAOHE edhe = new EventLogDAOHE(); edhe.insertEventLog("Thm mi h s", "Hy h s c id=" + sid, getRequest()); jsonDataGrid.setItems(resultMessage); return GRID_DATA; }
From source file:com.viettel.hqmc.DAO.FilesDAO.java
/** * load file attach cua user/* w w w .j a va 2 s .co m*/ * * @return */ public String loadUserAttachs() { try { Base64 decoder = new Base64(); String UserAttachArr = new String( decoder.decode(getRequest().getParameter("lstUserAttach").replace("_", "+").getBytes()), "UTF-8"); FilesDAOHE fdhe = new FilesDAOHE(); List lst = fdhe.getAttachsOfUserAttach(UserAttachArr, getUserId()); List lstAttach = new ArrayList(); VoAttachsDAOHE daoHe = new VoAttachsDAOHE(); for (int i = 0; i < lst.size(); i++) { VoAttachs bo = new VoAttachs(); bo.setCategoryName(((UserAttachs) lst.get(i)).getAttachName()); bo.setAttachDes(((UserAttachs) lst.get(i)).getDescription()); bo.setAttachName(((UserAttachs) lst.get(i)).getFileName()); bo.setAttachPath(((UserAttachs) lst.get(i)).getAttachPath()); bo.setIsActive(Constants.ACTIVE_STATUS.ACTIVE); bo.setUserCreateId(this.getUserId()); bo.setCreateDate(daoHe.getSysdate()); Long id = daoHe.create(bo); getRequest().setAttribute("attachId", id); getRequest().setAttribute("fileName", ((UserAttachs) lst.get(i)).getFileName()); lstAttach.add(bo); String idSession = (String) getRequest().getSession().getAttribute("idSession"); if (idSession == null) { idSession = ""; } idSession += id.toString() + ";"; getRequest().getSession().setAttribute("idSession", idSession); } jsonDataGrid.setItems(lstAttach); } catch (Exception ex) { LogUtil.addLog(ex);//binhnt sonar a160901 // log.error(ex.getMessage()); } return GRID_DATA; }