-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas Timm
committed
Dec 14, 2018
1 parent
82ddc98
commit 914829a
Showing
225 changed files
with
9,435 additions
and
10,782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
version=9.0.0 | ||
version=9.1.0 | ||
group=com.rapidminer.studio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/main/java/com/rapidminer/core/license/ProductLinkRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* Copyright (C) 2001-2018 by RapidMiner and the contributors | ||
* | ||
* Complete list of developers available at our web site: | ||
* | ||
* http://rapidminer.com | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU Affero General Public License as published by the Free Software Foundation, either version 3 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along with this program. | ||
* If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.rapidminer.core.license; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.security.AccessControlException; | ||
import java.security.AccessController; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import com.rapidminer.license.StudioLicenseConstants; | ||
import com.rapidminer.license.product.Product; | ||
import com.rapidminer.security.PluginSandboxPolicy; | ||
|
||
|
||
/** | ||
* Registry for custom product links | ||
* | ||
* @author Jonas Wilms-Pfau | ||
* @since 9.1.0 | ||
*/ | ||
public enum ProductLinkRegistry { | ||
/** | ||
* Links used for purchase | ||
*/ | ||
PURCHASE; | ||
|
||
private final Map<String, String> productLinkMap = new HashMap<>(0); | ||
|
||
/** | ||
* Registers a link for a product. Any existing mapping for the same productId is overwritten. | ||
* | ||
* <p>Internal, do not use. | ||
* | ||
* @param productId | ||
* the {@link Product#getProductId() product id} | ||
* @param link | ||
* the link for the product | ||
* @throws NullPointerException | ||
* if one of the parameters is {@code null} | ||
* @throws UnsupportedOperationException | ||
* if used by 3rd parties, or if {@link StudioLicenseConstants#PRODUCT_ID} is used as a product id | ||
* @throws IllegalArgumentException | ||
* if the link is not a valid url | ||
*/ | ||
public void register(String productId, String link) { | ||
checkAccess(); | ||
Objects.requireNonNull(productId, "productId must not be null"); | ||
Objects.requireNonNull(link, "link must not be null"); | ||
try { | ||
new URL(link); | ||
} catch (MalformedURLException mue) { | ||
throw new IllegalArgumentException(mue.getMessage(), mue); | ||
} | ||
if (StudioLicenseConstants.PRODUCT_ID.equals(productId)) { | ||
throw new UnsupportedOperationException("Modifications of " + StudioLicenseConstants.PRODUCT_ID + " links are not allowed."); | ||
} | ||
productLinkMap.put(productId, link); | ||
} | ||
|
||
/** | ||
* Returns the link to which the specified licenseProductKey is mapped, or defaultUrl if this registry contains no | ||
* mapping for the key. | ||
* | ||
* @param productId | ||
* the {@link Product#getProductId() product id} | ||
* @param defaultLink | ||
* the default link | ||
* @return the link for the product, or the {@code defaultLink} | ||
**/ | ||
public String get(String productId, String defaultLink) { | ||
if (productId == null || StudioLicenseConstants.PRODUCT_ID.equals(productId)) { | ||
return defaultLink; | ||
} | ||
return productLinkMap.getOrDefault(productId, defaultLink); | ||
} | ||
|
||
/** | ||
* Checks if the caller has the {@link PluginSandboxPolicy#RAPIDMINER_INTERNAL_PERMISSION} | ||
* | ||
* @throws UnsupportedOperationException | ||
* if the caller is not signed | ||
*/ | ||
private static void checkAccess() { | ||
try { | ||
if (System.getSecurityManager() != null) { | ||
AccessController.checkPermission(new RuntimePermission(PluginSandboxPolicy.RAPIDMINER_INTERNAL_PERMISSION)); | ||
} | ||
} catch (AccessControlException e) { | ||
throw new UnsupportedOperationException("Internal API, cannot be called by unauthorized sources."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.