public SystemPlatypusPrincipal() { super("system-" + IdGenerator.genId(), null, null, null); }
public Object generateValue() { Object value; if (type != null) { switch (type) { case Scripts.NUMBER_TYPE_NAME: value = IdGenerator.genId(); break; case Scripts.STRING_TYPE_NAME: value = IdGenerator.genStringId(); break; case Scripts.DATE_TYPE_NAME: value = new Date(); break; case Scripts.BOOLEAN_TYPE_NAME: value = false; break; default: value = null; break; } } else { value = null; } return value; }
public static String genStringId() { return String.valueOf(genLongId()); }
@Override public DynaClass getDynaClass() { if (dynaClass == null) { dynaClass = new JSDynaClass(delegate, REPORT_DYNA_CLASS_PREFIX + IdGenerator.genStringId()); } return dynaClass; }
public static long genLongId() { return generate(LONG_ID, LONG_COUNTER_DIGITS); }
public DatabasesClientWithResource(DbConnectionSettings aSettings) throws Exception { super(); resourceName = "TestDb-" + IdGenerator.genStringId(); GeneralResourceProvider.getInstance().registerDatasource(resourceName, aSettings); client = new DatabasesClient(resourceName, true, BearResourcePool.DEFAULT_MAXIMUM_SIZE); }
public static long genId() { return generate(ID, COUNTER_DIGITS); }
public Form() throws Exception { this("form-" + IdGenerator.genId()); }
public static void authorize(PlatypusServer aServer, String aUserName, String aPassword, Scripts.Space aSpace, Consumer<PlatypusPrincipal> onSuccess, Consumer<Exception> onFailure) { try { if (aUserName != null && !aUserName.isEmpty()) { String passwordMd5 = MD5Generator.generate(aPassword != null ? aPassword : ""); DatabasesClient.credentialsToPrincipalWithBasicAuthentication(aServer.getDatabasesClient(), aUserName, passwordMd5, aSpace, (PlatypusPrincipal principal) -> { if (principal != null) { onSuccess.accept(principal); } else { onFailure.accept(new AccessControlException(LOGIN_INCORRECT_MSG, new AuthPermission("*"))); } }, onFailure); } else { PlatypusPrincipal principal = new AnonymousPlatypusPrincipal("anonymous-" + IdGenerator.genStringId()); onSuccess.accept(principal); } } catch (Exception ex) { onFailure.accept(ex); } } }
public void regenerateId() { entityId = IdGenerator.genId(); }
@ScriptFunction(jsDoc = CREATE_ENTITY_JSDOC, params = {"sqlText", "datasourceName"}) public ApplicationDbEntity createEntity(String aSqlText, String aDatasourceName) throws Exception { if (basesProxy == null) { throw new NullPointerException("null basesProxy detected while creating a query"); } ApplicationDbEntity created = newGenericEntity(); created.setName(USER_DATASOURCE_NAME); SqlQuery query = new SqlQuery(basesProxy, aDatasourceName, aSqlText); query.setEntityName(IdGenerator.genStringId()); StoredQueryFactory factory = new StoredQueryFactory(basesProxy, null, null); factory.putTableFieldsMetadata(query);// only select will be filled with output columns created.setQuery(query); // .schema collection will be empty if query is not a select return created; }
public AnonymousPlatypusPrincipal() { this("anonymous-" + IdGenerator.genId()); }
if (requestEnv.ticket == null) { try { Session session = server.getSessionManager().create(IdGenerator.genStringId()); DatabaseAuthorizer.authorize(server, requestEnv.userName, requestEnv.password, session.getSpace(), (PlatypusPrincipal aPrincipal) -> { requestEnv.ticket = session.getId();
public Form(JComponent aView) throws Exception { this(aView, "form-" + IdGenerator.genId()); }
protected static String generateReportPath(String aFileName, String aFormat) { String reportPath = System.getProperty(ClientConstants.USER_HOME_PROP_NAME); if (!reportPath.endsWith(File.separator)) { reportPath += File.separator; } reportPath += ClientConstants.USER_HOME_PLATYPUS_DIRECTORY_NAME; File newDir = new File(reportPath); if (!newDir.exists()) { newDir.mkdir(); } reportPath += File.separator + "reports"; newDir = new File(reportPath); if (!newDir.exists()) { newDir.mkdir(); } String suffix = "." + (aFormat != null ? aFormat : PlatypusFiles.REPORT_LAYOUT_EXTENSION_X); String reportName = aFileName; if (reportName.toLowerCase().endsWith(suffix.toLowerCase())) { reportName = reportName.substring(0, reportName.length() - suffix.length()); } reportName += "-" + IdGenerator.genId() + suffix; reportPath += File.separator + reportName; return reportPath; }
protected void writeReportResponse(Report report) throws URISyntaxException, IOException { String docsRoot = servletRequest.getServletContext().getRealPath("/"); String userHomeInApplication = "/reports/" + userName + "/"; File userDir = new File(docsRoot + userHomeInApplication); if (!userDir.exists()) { userDir.mkdirs(); } String suffix = "." + report.getFormat(); String reportName = report.getName(); if (reportName.toLowerCase().endsWith(suffix.toLowerCase())) { reportName = reportName.substring(0, reportName.length() - suffix.length()); } reportName += "-" + IdGenerator.genId() + suffix; File rep = new File(docsRoot + userHomeInApplication + reportName); try (FileOutputStream out = new FileOutputStream(rep)) { out.write(report.getBody()); out.flush(); } String reportLocation = userHomeInApplication + reportName; if (!"/".equals(servletRequest.getContextPath())) { reportLocation = servletRequest.getContextPath() + reportLocation; } reportLocation = new URI(null, null, reportLocation, null).toASCIIString(); writeResponse(reportLocation, servletResponse, PlatypusHttpResponseReader.REPORT_LOCATION_CONTENT_TYPE, async); }
uploadedFileName.append(IdGenerator.genId()).append("-").append(fileName); try { try {
try { Session created = SessionManager.Singleton.instance.create(platypusSessionId == null ? IdGenerator.genId() + "" : platypusSessionId); if (dataContext == null) { httpSession.removeAttribute(PLATYPUS_USER_CONTEXT_ATTR_NAME);
try { com.eas.server.Session created = SessionManager.Singleton.instance.create(platypusSessionId == null ? IdGenerator.genId() + "" : platypusSessionId); if (dataContext == null) { websocketSession.getUserProperties().remove(PlatypusHttpServlet.PLATYPUS_USER_CONTEXT_ATTR_NAME);
public String getAppElementId() throws IOException { Integer appElementType = getAppElementType(); if (appElementType != null) { switch (appElementType) { case ClientConstants.ET_COMPONENT: case ClientConstants.ET_FORM: case ClientConstants.ET_REPORT: { return null; } case ClientConstants.ET_QUERY: { File sqlFile = findFileByExtension(PlatypusFiles.SQL_EXTENSION); String fileContent = FileUtils.readString(sqlFile, PlatypusFiles.DEFAULT_ENCODING); return PlatypusFilesSupport.getAnnotationValue(fileContent, JsDoc.Tag.NAME_TAG); } case ClientConstants.ET_DB_SCHEME: return IdGenerator.genId() + ""; default: return null; } } else { return null; } }