From 34bc0cc89f93edb4f8510ed3c76acaf7d54036e9 Mon Sep 17 00:00:00 2001 From: Andrew Shvayka Date: Mon, 22 Feb 2016 14:01:33 +0200 Subject: [PATCH 01/13] Version set to 1.3.1-SNAPSHOT --- pom.xml | 8 ++++---- web/pom.xml | 2 +- .../org/kaaproject/kaa/sandbox/web/shared/Version.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 95017b6..4b1470d 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa sandbox-frame - 1.3.0 + 1.3.1-SNAPSHOT pom Kaa Sandbox Frame @@ -27,8 +27,8 @@ ${basedir} - 0.8.0 - 1.2.0 + 0.8.1-SNAPSHOT + 1.2.1-SNAPSHOT 2.7.0 4.0.2.RELEASE 2.8.1 @@ -37,7 +37,7 @@ 0.1.2 4.3.2 1.7.5 - 0.2.0 + 0.2.1-SNAPSHOT 0.10 diff --git a/web/pom.xml b/web/pom.xml index e9cc937..9eab6c7 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa - 1.3.0 + 1.3.1-SNAPSHOT sandbox-frame org.kaaproject.kaa.sandbox-frame diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java index 914e662..3a8cefd 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java @@ -27,13 +27,13 @@ public final class Version { /** The Constant PROJECT_VERSION. */ - public static final String PROJECT_VERSION = "1.3.0-SNAPSHOT"; + public static final String PROJECT_VERSION = "1.3.1-SNAPSHOT"; /** The Constant KAA_VERSION. */ - public static final String KAA_VERSION = "0.8.0-SNAPSHOT"; + public static final String KAA_VERSION = "0.8.1-SNAPSHOT"; /** The Constant KAA_VERSION. */ - public static final String KAA_SAMPLE_APPS_VERSION = "1.2.0-SNAPSHOT"; + public static final String KAA_SAMPLE_APPS_VERSION = "1.2.1-SNAPSHOT"; /** * Instantiates a new version. From d812d586f526775f3e1a0e4b166b6927831e90b5 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 11 Mar 2016 19:27:13 +0200 Subject: [PATCH 02/13] KSF-22: Add validation of entered hostname/ip address --- .../mvp/activity/ChangeKaaHostActivity.java | 20 ++++- .../web/client/util/DomainValidator.java | 61 ++++++++++++++ .../web/client/util/InetAddressValidator.java | 81 +++++++++++++++++++ 3 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java create mode 100644 web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java index 84cf1c0..2e8461f 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java @@ -31,6 +31,8 @@ import org.kaaproject.kaa.sandbox.web.client.mvp.view.dialog.ConsoleDialog; import org.kaaproject.kaa.sandbox.web.client.mvp.view.dialog.ConsoleDialog.ConsoleDialogListener; import org.kaaproject.kaa.sandbox.web.client.util.Analytics; +import org.kaaproject.kaa.sandbox.web.client.util.DomainValidator; +import org.kaaproject.kaa.sandbox.web.client.util.InetAddressValidator; import org.kaaproject.kaa.sandbox.web.client.util.LogLevel; import org.kaaproject.kaa.sandbox.web.client.util.Utils; @@ -166,7 +168,7 @@ public void onSuccess(LogLevel level) { private void changeKaaHost() { final String host = view.getKaaHost().getValue(); Analytics.sendEvent(Analytics.CHANGE_KAA_HOST_ACTION, host); - if (host != null && host.length() > 0) { + if (validateHost(host)) { view.clearError(); ConsoleDialog.startConsoleDialog("Going to change kaa host to '" + host + "'...\n", new ConsoleDialogListener() { @@ -194,9 +196,19 @@ public void onSuccess(Void result) { }); } }); - } else { - view.setErrorMessage(Utils.messages.emptyKaaHostError()); - } + } + } + + private boolean validateHost(String host) { + if (host == null || host.length() == 0) { + view.setErrorMessage(Utils.messages.emptyKaaHostError()); + return false; + } else if (!InetAddressValidator.getInstance().isValid(host) && + !DomainValidator.getInstance().isValid(host)) { + view.setErrorMessage("Invalid hostname/ip address format!"); + return false; + } + return true; } private void getLogs() { diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java new file mode 100644 index 0000000..ef8bf0f --- /dev/null +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java @@ -0,0 +1,61 @@ +/* + * Copyright 2014-2016 CyberVision, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.kaaproject.kaa.sandbox.web.client.util; + +import java.io.Serializable; +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; + + +public class DomainValidator implements Serializable { + + private static final long serialVersionUID = -4407125112880174009L; + + private static final String DOMAIN_LABEL_REGEX = "(^[a-zA-Z0-9-]{1,61}$|^[a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+$)"; + + private static final DomainValidator DOMAIN_VALIDATOR = new DomainValidator(); + private final RegExp domainRegex = + RegExp.compile(DOMAIN_LABEL_REGEX); + + public static DomainValidator getInstance() { + return DOMAIN_VALIDATOR; + } + + private DomainValidator() { + } + + public boolean isValid(String domain) { + if (domain == null) { + return false; + } + MatchResult matcher = domainRegex.exec(domain); + if (matcher == null) { + return false; + } + int count = matcher.getGroupCount(); + String[] groups = new String[count]; + for (int j = 0; j < count; j++) { + groups[j] = matcher.getGroup(j + 1); + } + + if (groups != null && groups.length > 0) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java new file mode 100644 index 0000000..883bc17 --- /dev/null +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java @@ -0,0 +1,81 @@ +/* + * Copyright 2014-2016 CyberVision, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.kaaproject.kaa.sandbox.web.client.util; + +import java.io.Serializable; + +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; + +public class InetAddressValidator implements Serializable { + + private static final long serialVersionUID = -919201640201914789L; + + private static final String IPV4_REGEX = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"; + + private static final InetAddressValidator VALIDATOR = new InetAddressValidator(); + + private final RegExp ipv4Pattern = RegExp.compile(IPV4_REGEX); + + public static InetAddressValidator getInstance() { + return VALIDATOR; + } + + public boolean isValid(String inetAddress) { + return isValidInet4Address(inetAddress); + } + + public boolean isValidInet4Address(String inet4Address) { + // verify that address conforms to generic IPv4 format + if (inet4Address == null) { + return false; + } + + MatchResult matcher = ipv4Pattern.exec(inet4Address); + if (matcher == null) { + return false; + } + int count = matcher.getGroupCount(); + String[] groups = new String[count]; + for (int j = 0; j < count; j++) { + groups[j] = matcher.getGroup(j + 1); + } + + // verify that address subgroups are legal + for (int i = 0; i <= 3; i++) { + String ipSegment = groups[i]; + if (ipSegment == null || ipSegment.length() <= 0) { + return false; + } + + int iIpSegment = 0; + + try { + iIpSegment = Integer.parseInt(ipSegment); + } catch (NumberFormatException e) { + return false; + } + + if (iIpSegment > 255) { + return false; + } + + } + + return true; + } +} \ No newline at end of file From 9d25daff799fe4bdce91a61b7812d9f130e3c200 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 14 Mar 2016 10:03:30 +0200 Subject: [PATCH 03/13] KSF-22: Add invalid hostname/ip message to i18n resources --- .../sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java | 2 +- .../kaa/sandbox/web/client/i18n/SandboxMessages.properties | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java index 2e8461f..d9210ad 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java @@ -205,7 +205,7 @@ private boolean validateHost(String host) { return false; } else if (!InetAddressValidator.getInstance().isValid(host) && !DomainValidator.getInstance().isValid(host)) { - view.setErrorMessage("Invalid hostname/ip address format!"); + view.setErrorMessage(Utils.messages.invalidKaaHostError()); return false; } return true; diff --git a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxMessages.properties b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxMessages.properties index 37f8a4a..68cae82 100755 --- a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxMessages.properties +++ b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxMessages.properties @@ -7,6 +7,8 @@ pagerText = Page {0} of {1} emptyKaaHostError = Kaa host field can not be empty! +invalidKaaHostError = Invalid hostname/ip address format! + changeKaaHostMessagePt1 = Kaa endpoints connect to your Kaa Sandbox by using the address built into the SDK. This address must be reachable from the network where you run your endpoints for your applications to work properly. The currently set Kaa Sandbox address is changeKaaHostMessagePt2 = Please use the form below to manually update your Kaa Sandbox address. From 1e251f07c6afb6b871c510841d3738c8005c60e3 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 14 Mar 2016 12:27:02 +0200 Subject: [PATCH 04/13] KSF-25: Update title style of project cards to have fixed height --- .../kaa/sandbox/web/client/SandboxTheme.css | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/SandboxTheme.css b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/SandboxTheme.css index e02a1ee..f55b8f2 100755 --- a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/SandboxTheme.css +++ b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/SandboxTheme.css @@ -511,15 +511,26 @@ nav.navPrimary.collapsed li.primary > a > span.icon > img { .demoProjectWidget .title { position: relative; width: 160px; + max-width: 160px; + margin: 0 auto; color: #666; - font-size: 20px; + font-size: 19px; font-variant: normal; font-weight: normal; line-height: 24px; + max-height: 48px; + height: 48px; overflow: hidden; display: block; + display: -webkit-box; white-space: normal; text-align: center; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; + margin-bottom: 0; } .demoProjectWidget .action { From 1e1a157b5a452608ae0a8762d8542737dd042bbd Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 14 Mar 2016 13:27:37 +0200 Subject: [PATCH 05/13] KSF-28: Update script to always remove old logs when specified. --- web/src/sh/bin/change_kaa_log_level.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/src/sh/bin/change_kaa_log_level.sh b/web/src/sh/bin/change_kaa_log_level.sh index 838cdbb..89bafd3 100644 --- a/web/src/sh/bin/change_kaa_log_level.sh +++ b/web/src/sh/bin/change_kaa_log_level.sh @@ -65,6 +65,25 @@ then sleep 10 +elif [ ${remove_logs} -eq 1 ] + +then + + echo "Removing old log files..." + + find /var/log/kaa -type f -name '*[0-9].log' -exec rm {} + + + FILES=/var/log/kaa/* + + for f in $FILES + do + + > $f + + done + + echo "Old log files removed!" + fi echo "Done!" From f3d5bfb66027d7c2ba5e1fa0fc38b4ceb1fa8b34 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 14 Mar 2016 14:50:23 +0200 Subject: [PATCH 06/13] KSF-28: Correct home path --- .../kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java index 0e8f23f..f203218 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java @@ -217,7 +217,7 @@ public void afterPropertiesSet() throws Exception { private void prepareAnalytics() throws IOException { if (enableAnalytics) { try { - File f = new File(ANALYTICS_USER_ID_FILE); + File f = new File(Environment.getServerHomeDir() + "/" + ANALYTICS_USER_ID_FILE); if (!f.exists()) { f.createNewFile(); } From aa7e0010672d8bed994df33a54397b4763aa4644 Mon Sep 17 00:00:00 2001 From: Andrew Shvayka Date: Mon, 14 Mar 2016 17:02:20 +0200 Subject: [PATCH 07/13] Version set to 1.3.1 --- pom.xml | 8 ++++---- web/pom.xml | 2 +- .../org/kaaproject/kaa/sandbox/web/shared/Version.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 4b1470d..58c1885 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa sandbox-frame - 1.3.1-SNAPSHOT + 1.3.1 pom Kaa Sandbox Frame @@ -27,8 +27,8 @@ ${basedir} - 0.8.1-SNAPSHOT - 1.2.1-SNAPSHOT + 0.8.1 + 1.2.1 2.7.0 4.0.2.RELEASE 2.8.1 @@ -37,7 +37,7 @@ 0.1.2 4.3.2 1.7.5 - 0.2.1-SNAPSHOT + 0.2.1 0.10 diff --git a/web/pom.xml b/web/pom.xml index 9eab6c7..d29da2a 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa - 1.3.1-SNAPSHOT + 1.3.1 sandbox-frame org.kaaproject.kaa.sandbox-frame diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java index 3a8cefd..0443154 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java @@ -27,13 +27,13 @@ public final class Version { /** The Constant PROJECT_VERSION. */ - public static final String PROJECT_VERSION = "1.3.1-SNAPSHOT"; + public static final String PROJECT_VERSION = "1.3.1"; /** The Constant KAA_VERSION. */ - public static final String KAA_VERSION = "0.8.1-SNAPSHOT"; + public static final String KAA_VERSION = "0.8.1"; /** The Constant KAA_VERSION. */ - public static final String KAA_SAMPLE_APPS_VERSION = "1.2.1-SNAPSHOT"; + public static final String KAA_SAMPLE_APPS_VERSION = "1.2.1"; /** * Instantiates a new version. From 4b2a645d310d65f1bcdc3551eb52b0d3f1ae1242 Mon Sep 17 00:00:00 2001 From: Peter Krutsiuk Date: Fri, 8 Apr 2016 16:56:33 +0300 Subject: [PATCH 08/13] KSF-30: Fix typo in raspberry pi constant --- .../kaa/sandbox/web/client/i18n/SandboxConstants.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxConstants.properties b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxConstants.properties index 0283e57..36eee8d 100755 --- a/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxConstants.properties +++ b/web/src/main/resources/org/kaaproject/kaa/sandbox/web/client/i18n/SandboxConstants.properties @@ -95,7 +95,7 @@ ios = iOS artik5 = Artik 5 -raspberryPi = Rarpberry Pi +raspberryPi = Raspberry Pi intelEdison = Intel Edison From 699485a758bc28e407116e88594da7ad5ba43b0d Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 12 Apr 2016 19:24:35 +0300 Subject: [PATCH 09/13] KSF-22: Update host/ip input verification. Domain names are evaluated according to the standards RFC1034, section 3, and RFC1123, section 2.1. --- pom.xml | 10 +- web/pom.xml | 4 + .../mvp/activity/ChangeKaaHostActivity.java | 96 +++++++++---------- .../web/client/util/DomainValidator.java | 61 ------------ .../web/client/util/InetAddressValidator.java | 81 ---------------- .../web/services/SandboxServiceImpl.java | 14 ++- .../web/shared/services/SandboxService.java | 2 + 7 files changed, 73 insertions(+), 195 deletions(-) delete mode 100644 web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java delete mode 100644 web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java diff --git a/pom.xml b/pom.xml index 58c1885..863f321 100755 --- a/pom.xml +++ b/pom.xml @@ -27,8 +27,8 @@ ${basedir} - 0.8.1 - 1.2.1 + 0.9.0-SNAPSHOT + 1.3.0-SNAPSHOT 2.7.0 4.0.2.RELEASE 2.8.1 @@ -36,6 +36,7 @@ 1.1.2 0.1.2 4.3.2 + 1.5.0 1.7.5 0.2.1 0.10 @@ -228,6 +229,11 @@ sources ${kaa-sample-apps.version} + + commons-validator + commons-validator + ${commons-validator.version} + org.slf4j slf4j-api diff --git a/web/pom.xml b/web/pom.xml index d29da2a..301a47d 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -102,6 +102,10 @@ mail 1.4 + + commons-validator + commons-validator + org.slf4j slf4j-api diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java index d9210ad..95bebcb 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/mvp/activity/ChangeKaaHostActivity.java @@ -16,13 +16,9 @@ package org.kaaproject.kaa.sandbox.web.client.mvp.activity; -import com.google.gwt.activity.shared.AbstractActivity; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.shared.EventBus; -import com.google.gwt.event.shared.HandlerRegistration; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.AcceptsOneWidget; +import java.util.ArrayList; +import java.util.List; + import org.kaaproject.avro.ui.gwt.client.util.BusyAsyncCallback; import org.kaaproject.kaa.sandbox.web.client.Sandbox; import org.kaaproject.kaa.sandbox.web.client.mvp.ClientFactory; @@ -31,13 +27,16 @@ import org.kaaproject.kaa.sandbox.web.client.mvp.view.dialog.ConsoleDialog; import org.kaaproject.kaa.sandbox.web.client.mvp.view.dialog.ConsoleDialog.ConsoleDialogListener; import org.kaaproject.kaa.sandbox.web.client.util.Analytics; -import org.kaaproject.kaa.sandbox.web.client.util.DomainValidator; -import org.kaaproject.kaa.sandbox.web.client.util.InetAddressValidator; import org.kaaproject.kaa.sandbox.web.client.util.LogLevel; import org.kaaproject.kaa.sandbox.web.client.util.Utils; -import java.util.ArrayList; -import java.util.List; +import com.google.gwt.activity.shared.AbstractActivity; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.AcceptsOneWidget; public class ChangeKaaHostActivity extends AbstractActivity { @@ -168,47 +167,44 @@ public void onSuccess(LogLevel level) { private void changeKaaHost() { final String host = view.getKaaHost().getValue(); Analytics.sendEvent(Analytics.CHANGE_KAA_HOST_ACTION, host); - if (validateHost(host)) { - view.clearError(); - ConsoleDialog.startConsoleDialog("Going to change kaa host to '" - + host + "'...\n", new ConsoleDialogListener() { + Sandbox.getSandboxService().validateKaaHost(host, new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + String message = Utils.getErrorMessage(caught); + view.setErrorMessage(message); + } - @Override - public void onOk(boolean success) { - } + @Override + public void onSuccess(Void result) { + view.clearError(); + ConsoleDialog.startConsoleDialog("Going to change kaa host to '" + + host + "'...\n", new ConsoleDialogListener() { - @Override - public void onStart(String uuid, final ConsoleDialog dialog, - final AsyncCallback callback) { - Sandbox.getSandboxService().changeKaaHost(uuid, host, - new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - - @Override - public void onSuccess(Void result) { - dialog.appendToConsoleAtFinish("Successfully changed kaa host to '" - + host + "'\n"); - callback.onSuccess(result); - } - }); - } - }); - } - } - - private boolean validateHost(String host) { - if (host == null || host.length() == 0) { - view.setErrorMessage(Utils.messages.emptyKaaHostError()); - return false; - } else if (!InetAddressValidator.getInstance().isValid(host) && - !DomainValidator.getInstance().isValid(host)) { - view.setErrorMessage(Utils.messages.invalidKaaHostError()); - return false; - } - return true; + @Override + public void onOk(boolean success) { + } + + @Override + public void onStart(String uuid, final ConsoleDialog dialog, + final AsyncCallback callback) { + Sandbox.getSandboxService().changeKaaHost(uuid, host, + new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + callback.onFailure(caught); + } + + @Override + public void onSuccess(Void result) { + dialog.appendToConsoleAtFinish("Successfully changed kaa host to '" + + host + "'\n"); + callback.onSuccess(result); + } + }); + } + }); + } + }); } private void getLogs() { diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java deleted file mode 100644 index ef8bf0f..0000000 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/DomainValidator.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kaaproject.kaa.sandbox.web.client.util; - -import java.io.Serializable; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; - - -public class DomainValidator implements Serializable { - - private static final long serialVersionUID = -4407125112880174009L; - - private static final String DOMAIN_LABEL_REGEX = "(^[a-zA-Z0-9-]{1,61}$|^[a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\\.[a-zA-Z]{2,})+$)"; - - private static final DomainValidator DOMAIN_VALIDATOR = new DomainValidator(); - private final RegExp domainRegex = - RegExp.compile(DOMAIN_LABEL_REGEX); - - public static DomainValidator getInstance() { - return DOMAIN_VALIDATOR; - } - - private DomainValidator() { - } - - public boolean isValid(String domain) { - if (domain == null) { - return false; - } - MatchResult matcher = domainRegex.exec(domain); - if (matcher == null) { - return false; - } - int count = matcher.getGroupCount(); - String[] groups = new String[count]; - for (int j = 0; j < count; j++) { - groups[j] = matcher.getGroup(j + 1); - } - - if (groups != null && groups.length > 0) { - return true; - } - return false; - } - -} \ No newline at end of file diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java deleted file mode 100644 index 883bc17..0000000 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/client/util/InetAddressValidator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kaaproject.kaa.sandbox.web.client.util; - -import java.io.Serializable; - -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; - -public class InetAddressValidator implements Serializable { - - private static final long serialVersionUID = -919201640201914789L; - - private static final String IPV4_REGEX = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$"; - - private static final InetAddressValidator VALIDATOR = new InetAddressValidator(); - - private final RegExp ipv4Pattern = RegExp.compile(IPV4_REGEX); - - public static InetAddressValidator getInstance() { - return VALIDATOR; - } - - public boolean isValid(String inetAddress) { - return isValidInet4Address(inetAddress); - } - - public boolean isValidInet4Address(String inet4Address) { - // verify that address conforms to generic IPv4 format - if (inet4Address == null) { - return false; - } - - MatchResult matcher = ipv4Pattern.exec(inet4Address); - if (matcher == null) { - return false; - } - int count = matcher.getGroupCount(); - String[] groups = new String[count]; - for (int j = 0; j < count; j++) { - groups[j] = matcher.getGroup(j + 1); - } - - // verify that address subgroups are legal - for (int i = 0; i <= 3; i++) { - String ipSegment = groups[i]; - if (ipSegment == null || ipSegment.length() <= 0) { - return false; - } - - int iIpSegment = 0; - - try { - iIpSegment = Integer.parseInt(ipSegment); - } catch (NumberFormatException e) { - return false; - } - - if (iIpSegment > 255) { - return false; - } - - } - - return true; - } -} \ No newline at end of file diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java index f203218..64028a4 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/services/SandboxServiceImpl.java @@ -41,6 +41,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.validator.routines.DomainValidator; +import org.apache.commons.validator.routines.InetAddressValidator; import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.PumpStreamHandler; import org.atmosphere.client.TrackMessageSizeInterceptor; @@ -276,6 +278,16 @@ public boolean showChangeKaaHostDialog() throws SandboxServiceException { public void changeKaaHostDialogShown() throws SandboxServiceException { cacheService.putProperty(CHANGE_KAA_HOST_DIALOG_SHOWN_PROPERTY, Boolean.TRUE); } + + @Override + public void validateKaaHost(String host) throws SandboxServiceException { + if (host == null || host.length() == 0) { + throw new SandboxServiceException("Kaa host field can not be empty!"); + } else if (!InetAddressValidator.getInstance().isValid(host) && + !DomainValidator.getInstance(true).isValid(host)) { + throw new SandboxServiceException("Invalid hostname/ip address format!"); + } + } @Override public void changeKaaHost(String uuid, String host) throws SandboxServiceException { @@ -300,7 +312,7 @@ public void changeKaaHost(String uuid, String host) throws SandboxServiceExcepti } } } - + @Override public boolean getLogsEnabled() throws SandboxServiceException { return guiGetLogsEnabled; diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/services/SandboxService.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/services/SandboxService.java index f164743..55de869 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/services/SandboxService.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/services/SandboxService.java @@ -40,6 +40,8 @@ public interface SandboxService extends RemoteService { public boolean showChangeKaaHostDialog() throws SandboxServiceException; public void changeKaaHostDialogShown() throws SandboxServiceException; + + public void validateKaaHost(String host) throws SandboxServiceException; public void changeKaaHost(String uuid, String host) throws SandboxServiceException; From db2a78ac225d04630c6a083ef16dc0f62cec8d4b Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 21 Apr 2016 18:26:24 +0300 Subject: [PATCH 10/13] Version set to 1.4.0-SNAPSHOT --- pom.xml | 2 +- web/pom.xml | 2 +- .../java/org/kaaproject/kaa/sandbox/web/shared/Version.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 863f321..7062e8a 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa sandbox-frame - 1.3.1 + 1.4.0-SNAPSHOT pom Kaa Sandbox Frame diff --git a/web/pom.xml b/web/pom.xml index 301a47d..7d9d404 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa - 1.3.1 + 1.4.0-SNAPSHOT sandbox-frame org.kaaproject.kaa.sandbox-frame diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java index 0443154..96bffb1 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java @@ -27,13 +27,13 @@ public final class Version { /** The Constant PROJECT_VERSION. */ - public static final String PROJECT_VERSION = "1.3.1"; + public static final String PROJECT_VERSION = "1.4.0-SNAPSHOT"; /** The Constant KAA_VERSION. */ - public static final String KAA_VERSION = "0.8.1"; + public static final String KAA_VERSION = "0.9.0-SNAPSHOT"; /** The Constant KAA_VERSION. */ - public static final String KAA_SAMPLE_APPS_VERSION = "1.2.1"; + public static final String KAA_SAMPLE_APPS_VERSION = "1.3.0-SNAPSHOT"; /** * Instantiates a new version. From 97b92e91ec717d7450a146fd6b0fa3368c694376 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 25 Apr 2016 17:52:29 +0300 Subject: [PATCH 11/13] Version set to 1.3.2-SNAPSHOT --- pom.xml | 2 +- web/pom.xml | 2 +- .../java/org/kaaproject/kaa/sandbox/web/shared/Version.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7062e8a..97ed530 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa sandbox-frame - 1.4.0-SNAPSHOT + 1.3.2-SNAPSHOT pom Kaa Sandbox Frame diff --git a/web/pom.xml b/web/pom.xml index 7d9d404..3c08041 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa - 1.4.0-SNAPSHOT + 1.3.2-SNAPSHOT sandbox-frame org.kaaproject.kaa.sandbox-frame diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java index 96bffb1..fe7a324 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java @@ -27,7 +27,7 @@ public final class Version { /** The Constant PROJECT_VERSION. */ - public static final String PROJECT_VERSION = "1.4.0-SNAPSHOT"; + public static final String PROJECT_VERSION = "1.3.2-SNAPSHOT"; /** The Constant KAA_VERSION. */ public static final String KAA_VERSION = "0.9.0-SNAPSHOT"; From ea899b3b03699a4dc050d4fc7b652417260a12f2 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Wed, 27 Apr 2016 14:33:37 +0300 Subject: [PATCH 12/13] KSF-33: Introduce zero exit code in create_logs_archive script to prevent fail during runtime execution --- web/src/sh/bin/create_logs_archive.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/src/sh/bin/create_logs_archive.sh b/web/src/sh/bin/create_logs_archive.sh index 5f75e5a..e1bb43b 100644 --- a/web/src/sh/bin/create_logs_archive.sh +++ b/web/src/sh/bin/create_logs_archive.sh @@ -16,4 +16,5 @@ # -tar -cvf /home/kaa/sandbox_logs.tar.gz /var/log/kaa/ \ No newline at end of file +tar -cvf /home/kaa/sandbox_logs.tar.gz /var/log/kaa/ +exit 0 From 79e7b5242d22758d4a4d2b6032fe8b5f14f8cd09 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 28 Apr 2016 02:12:23 +0300 Subject: [PATCH 13/13] Version set to 1.3.2 --- pom.xml | 6 +++--- web/pom.xml | 2 +- .../java/org/kaaproject/kaa/sandbox/web/shared/Version.java | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 97ed530..af44441 100755 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa sandbox-frame - 1.3.2-SNAPSHOT + 1.3.2 pom Kaa Sandbox Frame @@ -27,8 +27,8 @@ ${basedir} - 0.9.0-SNAPSHOT - 1.3.0-SNAPSHOT + 0.9.0 + 1.3.0 2.7.0 4.0.2.RELEASE 2.8.1 diff --git a/web/pom.xml b/web/pom.xml index 3c08041..d9c763d 100755 --- a/web/pom.xml +++ b/web/pom.xml @@ -19,7 +19,7 @@ 4.0.0 org.kaaproject.kaa - 1.3.2-SNAPSHOT + 1.3.2 sandbox-frame org.kaaproject.kaa.sandbox-frame diff --git a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java index fe7a324..111c3f2 100755 --- a/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java +++ b/web/src/main/java/org/kaaproject/kaa/sandbox/web/shared/Version.java @@ -27,13 +27,13 @@ public final class Version { /** The Constant PROJECT_VERSION. */ - public static final String PROJECT_VERSION = "1.3.2-SNAPSHOT"; + public static final String PROJECT_VERSION = "1.3.2"; /** The Constant KAA_VERSION. */ - public static final String KAA_VERSION = "0.9.0-SNAPSHOT"; + public static final String KAA_VERSION = "0.9.0"; /** The Constant KAA_VERSION. */ - public static final String KAA_SAMPLE_APPS_VERSION = "1.3.0-SNAPSHOT"; + public static final String KAA_SAMPLE_APPS_VERSION = "1.3.0"; /** * Instantiates a new version.