List of usage examples for java.util UUID randomUUID
public static UUID randomUUID()
From source file:com.chaosinmotion.securechat.server.commands.ForgotPassword.java
/** * Process a forgot password request. This generates a token that the * client is expected to return with the change password request. * @param requestParams//from w ww . jav a 2s . c o m * @throws SQLException * @throws IOException * @throws ClassNotFoundException * @throws JSONException * @throws NoSuchAlgorithmException */ public static void processRequest(JSONObject requestParams) throws SQLException, ClassNotFoundException, IOException, NoSuchAlgorithmException, JSONException { String username = requestParams.optString("username"); /* * Step 1: Convert username to the userid for this */ Connection c = null; PreparedStatement ps = null; ResultSet rs = null; int userID = 0; String retryID = UUID.randomUUID().toString(); try { c = Database.get(); ps = c.prepareStatement("SELECT userid " + "FROM Users " + "WHERE username = ?"); ps.setString(1, username); rs = ps.executeQuery(); if (rs.next()) { userID = rs.getInt(1); } if (userID == 0) return; ps.close(); rs.close(); /* * Step 2: Generate the retry token and insert into the forgot * database with an expiration date 1 hour from now. */ Timestamp ts = new Timestamp(System.currentTimeMillis() + 3600000); ps = c.prepareStatement("INSERT INTO ForgotPassword " + " ( userid, token, expires ) " + "VALUES " + " ( ?, ?, ?)"); ps.setInt(1, userID); ps.setString(2, retryID); ps.setTimestamp(3, ts); ps.execute(); } finally { if (rs != null) rs.close(); if (ps != null) ps.close(); if (c != null) c.close(); } /* * Step 3: formulate a JSON string with the retry and send * to the user. The format of the command we send is: * * { "cmd": "forgotpassword", "token": token } */ JSONObject obj = new JSONObject(); obj.put("cmd", "forgotpassword"); obj.put("token", retryID); MessageQueue.getInstance().enqueueAdmin(userID, obj.toString(4)); }
From source file:jodtemplate.resource.factory.FileResourcesFactory.java
@Override public Resources createResources() throws IOException { final File targetFolder = new File(tempPath, UUID.randomUUID().toString()); try {// w w w . j a v a 2 s. c o m Utils.createRequiredFolders(targetFolder); return new FileResources(targetFolder); } catch (IOException e) { FileUtils.deleteQuietly(targetFolder); throw e; } }
From source file:nl.mawoo.wcmmanager.services.WCMScriptService.java
public ExecutionResult run(String content) throws ScriptException { ExecutionResult result = new ExecutionResult(UUID.randomUUID()); WCMScript wcmScript = new WCMScript(result.getExecutionId(), new LoggingConfig(new ScriptLoggerImpl(result))); result.initDone();// w w w .j av a 2 s .c o m try { wcmScript.eval(content); } catch (Exception e) { String message = e.getLocalizedMessage(); if (message == null) { message = e.getClass().getSimpleName(); } result.setError(message); } result.executionDone(); return result; }
From source file:com.rdsic.pcm.service.impl.ReportImpl.java
/** * Implementation method for operation ExecReport * * @param req/*w ww. ja v a2 s. c o m*/ * @return */ public static ExecReportRes execReport(ExecReportReq req) { String key = UUID.randomUUID().toString(); String opr = "Report/ExecReport"; Logger.LogReq(key, opr, req); Date now = new Date(); ExecReportRes res = new ExecReportRes(); if (!Util.validateRequest(req, opr, Constant.FUNCTIONALITY_ACTION.WS_INVOKE, res)) { Logger.LogRes(key, opr, res); return res; } try { // TODO: implementation code here String rptName = req.getReportName(); String rptParam = req.getParameter(); String rptData = execProc(rptName, rptParam); res.setData(rptData); res.setStatus(Constant.STATUS_CODE.OK); } catch (Exception e) { Util.handleException(e, res); } res.setResponseDateTime(Util.toXmlGregorianCalendar(now)); Logger.LogRes(key, opr, res); return res; }
From source file:com.josue.lottery.eap.persistence.entity.rest.Resource.java
@PrePersist public void generateUuid() { if (StringUtils.isBlank(uuid)) { this.uuid = UUID.randomUUID().toString(); this.dateCreated = new Timestamp(new Date().getTime()); } else {/* w ww . j a va2s. co m*/ this.dateUpdated = new Timestamp(new Date().getTime()); } }
From source file:com.labimo.licensor.LicenseUtilsTest.java
public static String getUuid() { UUID uuid = UUID.randomUUID(); return uuid.toString(); }
From source file:com.nigelsmall.geoff.AbstractNode.java
public AbstractNode(String name, Set<String> labels, Map<String, Object> properties) { if (name == null) { this.name = UUID.randomUUID().toString(); this.named = false; } else {// w w w.ja v a 2 s. com this.name = name; this.named = true; } this.mergeLabels(labels); this.mergeProperties(properties); }
From source file:com.inmobi.grill.server.AuthenticationFilter.java
@Override public void filter(ContainerRequestContext requestContext) throws IOException { final SecurityContext securityContext = requestContext.getSecurityContext(); String requestId = UUID.randomUUID().toString(); String user = securityContext.getUserPrincipal() != null ? securityContext.getUserPrincipal().getName() : null;//from w w w .j av a2 s .co m requestContext.getHeaders().add("requestId", requestId); LOG.info("Request from user: " + user + ", path=" + requestContext.getUriInfo().getPath()); }
From source file:es.us.isa.sedl.module.statcharts.renderer.HighChartsRenderer.java
protected String render(StatisticalChartResult result, String chartType) { String identifier = UUID.randomUUID().toString().replace("-", ""); StringBuilder sb = new StringBuilder("<div id=\"" + identifier + "\"/>\n"); sb.append("<script type=\"text/javascript\">\n"); // This line tells Chrome to interpret this dinamically loaded javascrit // as a file (useful for debugging). sb.append("//@ sourceURL=renderChart" + identifier + ".js \n"); sb.append(generateDinamicLoadingFunction(identifier)); sb.append(generateRenderingFunction(result, identifier, chartType)); sb.append("\nloadHighCharts" + identifier + "();\n"); sb.append("</script>\n"); return sb.toString(); }