summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@vaadin.com>2014-04-30 13:26:32 +0200
committerVaadin Code Review <review@vaadin.com>2014-06-26 08:30:46 +0000
commit9a84fb14f2b7fc3c405f1446a007d5b9cd796c97 (patch)
tree40f1a0420f22fa70b91f7d59d064fe9975c2c33f /client
parent0ff4e15b96b91becdd6c8e38ad20d8272c5455b7 (diff)
downloadvaadin-framework-9a84fb14f2b7fc3c405f1446a007d5b9cd796c97.tar.gz
vaadin-framework-9a84fb14f2b7fc3c405f1446a007d5b9cd796c97.zip
License Checker for vaadin cval products (#13696 #13474)
- This patch includes four elements: 1.- A class able to validate a licensed product against Vaadin license server. It can be used in any vaadin product (thought for non addons like TB) just adding vaadin dependency, or copying the class. 2.- A class able to inspect all addons in the classpath and figure out, based on the MANIFEST.MF info, whether we have to check developer license. 3.- A modification to Vaadin connector generator to use the classes above and to stop compilation in case. 4.- A modification to ConnectorBundleLoader, so as when a new connector is instatiated, we check whether it is using an evaluation license and show a notice. We only show the notice once. - In addition to validating developer licenses, the checker caches the server response for using it when there are connection problems. - This stuff is in Vaadin core, so as we dont maintain license code in each addon. For checking an addon license we just add the license type to the manifest when packaging the artefact. - It checks expiration time, product name and major version. Fixes: #13696 In some-way related with: #13474 Change-Id: Ib61b1c2e9c3cacd463a1ce5db02c2cfbc06851c2
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java51
-rw-r--r--client/src/com/vaadin/client/metadata/Type.java17
2 files changed, 59 insertions, 9 deletions
diff --git a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java
index 7d2078061e..846bfd4671 100644
--- a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java
+++ b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* 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
@@ -15,13 +15,35 @@
*/
package com.vaadin.client.metadata;
+import java.util.ArrayList;
import java.util.List;
import com.google.gwt.core.shared.GWT;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ApplicationConfiguration;
import com.vaadin.client.FastStringMap;
import com.vaadin.client.metadata.AsyncBundleLoader.State;
+import com.vaadin.client.ui.VNotification;
+import com.vaadin.shared.Position;
public abstract class ConnectorBundleLoader {
+
+ public static class CValUiInfo {
+ public final String widgetset;
+ public final String product;
+ public final String version;
+ public final String type;
+
+ public CValUiInfo(String product, String version, String widgetset,
+ String type) {
+ this.product = product;
+ this.version = version;
+ this.widgetset = widgetset;
+ this.type = type;
+ }
+ }
+
public static final String EAGER_BUNDLE_NAME = "__eager";
public static final String DEFERRED_BUNDLE_NAME = "__deferred";
@@ -113,4 +135,27 @@ public abstract class ConnectorBundleLoader {
public abstract void init();
+ protected List<CValUiInfo> cvals = new ArrayList<CValUiInfo>();
+
+ public void cval(String typeName) {
+ if (!cvals.isEmpty()) {
+ String msg = "";
+ for (CValUiInfo c : cvals) {
+ String ns = c.widgetset.replaceFirst("\\.[^\\.]+$", "");
+ if (typeName.startsWith(ns)) {
+ cvals.remove(c);
+ msg += c.product + " " + c.version + "<br/>";
+ }
+ }
+ if (!msg.isEmpty()) {
+ // We need a widget for using VNotification, using the
+ // context-menu parent. Is there an easy way?
+ Widget w = ApplicationConfiguration.getRunningApplications()
+ .get(0).getContextMenu().getParent();
+ VNotification n = VNotification.createNotification(0, w);
+ n.setWidget(new HTML("Using Evaluation License of:<br/>" + msg));
+ n.show(Position.BOTTOM_RIGHT);
+ }
+ }
+ }
}
diff --git a/client/src/com/vaadin/client/metadata/Type.java b/client/src/com/vaadin/client/metadata/Type.java
index cc185dff96..15617ffe3c 100644
--- a/client/src/com/vaadin/client/metadata/Type.java
+++ b/client/src/com/vaadin/client/metadata/Type.java
@@ -1,12 +1,12 @@
/*
* Copyright 2000-2014 Vaadin Ltd.
- *
+ *
* 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
@@ -19,6 +19,7 @@ import java.util.Collection;
import com.google.gwt.core.client.JsArrayString;
import com.vaadin.client.JsArrayObject;
+import com.vaadin.client.ServerConnector;
import com.vaadin.client.communication.JSONSerializer;
public class Type {
@@ -47,7 +48,11 @@ public class Type {
public Object createInstance() throws NoDataException {
Invoker invoker = TypeDataStore.getConstructor(this);
- return invoker.invoke(null);
+ Object ret = invoker.invoke(null);
+ if (ret instanceof ServerConnector) {
+ ConnectorBundleLoader.get().cval(name);
+ }
+ return ret;
}
public Method getMethod(String name) {
@@ -57,7 +62,7 @@ public class Type {
/**
* @return
* @throws NoDataException
- *
+ *
* @deprecated As of 7.0.1, use {@link #getPropertiesAsArray()} instead for
* improved performance
*/
@@ -96,7 +101,7 @@ public class Type {
* returned string may change without notice and should not be used for any
* other purpose than identification. The signature is currently based on
* the fully qualified name of the type.
- *
+ *
* @return the unique signature of this type
*/
public String getSignature() {