This is an automated email from the ASF dual-hosted git repository.
golja pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/release24.09 by this push:
new 0a3233764 Remove Janrain integration
0a3233764 is described below
commit 0a32337647b29f68278ef366fe77ab2b6edf31cf
Author: Anahita Goljahani <[email protected]>
AuthorDate: Tue Oct 20 12:32:22 2026 +0200
Remove Janrain integration
(cherry picked from commit d8a14ec5c052c81ae3b27bf54ae9e9e42cbbfb4b)
---
ecommerce/README.md | 35 ---
ecommerce/config/ecommerce.properties | 22 --
.../ofbiz/ecommerce/customer/NewCustomer.groovy | 21 +-
.../ofbiz/ecommerce/janrain/JanrainHelper.java | 285 ---------------------
ecommerce/template/Login.ftl | 66 -----
ecommerce/template/customer/NewCustomer.ftl | 8 -
ecommerce/webapp/ecommerce/WEB-INF/controller.xml | 9 -
7 files changed, 1 insertion(+), 445 deletions(-)
diff --git a/ecommerce/README.md b/ecommerce/README.md
deleted file mode 100644
index 79441e5d8..000000000
--- a/ecommerce/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-<img
src="https://camo.githubusercontent.com/b313d4ec52b77b5024e2988aaf76720258233e69/68747470733a2f2f6f6662697a2e6170616368652e6f72672f696d616765732f6f6662697a5f6c6f676f2e706e67"
alt="Apache OFBiz" />
-
-# Ecommerce component
-
-## More information
-How to use Janrain Engage Social Login.
-
-1.Get API Key from http://www.janrain.com/products/engage/social-login.
-2.Configure file setting : ecommerce.properties you can put it
- Example:
-
--------------------------------------------------------------------------------
- # -- Enable janrain engage (Y/ N) default N
- janrain.enabled=N
-
- # -- Janrain api key (secret)
- janrain.apiKey=exampleKey
-
- # -- Janrain application domain
- janrain.baseUrl=https://example.rpxnow.com
-
- # -- Janrain application name
- janrain.appName=exampleAppName
-
--------------------------------------------------------------------------------
-3.Restart the server.
-
-
-How to test Janrain Engage Social Login.
-=======================================
-
-1. Go to Login screen.
-2. Look the Social Login Widget and you can use these existing accounts to
sign-in to your website.
-3. First time if account does not exists then system will create new account.
-4. After account existing in the system you can use "Social Login Widget" to
login account.
-
-===================================================================================================
diff --git a/ecommerce/config/ecommerce.properties
b/ecommerce/config/ecommerce.properties
index 8f56a1cae..cf2110d92 100644
--- a/ecommerce/config/ecommerce.properties
+++ b/ecommerce/config/ecommerce.properties
@@ -17,28 +17,6 @@
# under the License.
###############################################################################
-
-############################################
-# Janrain Engage
-############################################
-#example config
-#janrain.apiKey=9640f5bddc863ec419067d4bd07f9d15e45c177f
-#janrain.baseUrl=https://ofbizdemo.rpxnow.com
-#janrain.appName=ofbizdemo
-############################################
-
-# -- Enabled janrain engage (Y/ N) default N
-janrain.enabled=N
-
-# -- Janrain api key (secret)
-janrain.apiKey=
-
-# -- Janrain application domain
-janrain.baseUrl=
-
-# -- Janrain application name
-janrain.appName=
-
# Tag Cloud
tagcloud.min.fontsize = 8
tagcloud.max.fontsize = 14
diff --git
a/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/customer/NewCustomer.groovy
b/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/customer/NewCustomer.groovy
index 2b7bc562c..a4850eb9f 100644
---
a/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/customer/NewCustomer.groovy
+++
b/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/customer/NewCustomer.groovy
@@ -39,23 +39,4 @@ if (previousParams) {
}
context.previousParams = previousParams
-//the parameters from janrain
-userInfoMap = request.getAttribute("userInfoMap")
-if (!userInfoMap) {
- userInfoMap = request.getSession().getAttribute("userInfoMap")
-}
-if (userInfoMap) {
- if (userInfoMap.givenName && userInfoMap.familyName) {
- requestParameters.USER_FIRST_NAME = userInfoMap.givenName
- requestParameters.USER_LAST_NAME = userInfoMap.familyName
- } else if (userInfoMap.formatted) {
- requestParameters.USER_FIRST_NAME = userInfoMap.formatted
- }
- requestParameters.CUSTOMER_EMAIL = userInfoMap.email
- requestParameters.preferredUsername = userInfoMap.preferredUsername
- requestParameters.USERNAME = userInfoMap.preferredUsername
- request.getSession().setAttribute("userInfoMap", userInfoMap)
-}
-
-donePage = "main;" + UtilHttp.getSessionId(request)
-context.donePage = donePage
+context.donePage = 'main;' + UtilHttp.getSessionId(request)
\ No newline at end of file
diff --git
a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java
b/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java
deleted file mode 100644
index a579fe7b7..000000000
---
a/ecommerce/src/main/java/org/apache/ofbiz/ecommerce/janrain/JanrainHelper.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.ofbiz.ecommerce.janrain;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.ofbiz.base.util.Debug;
-import org.apache.ofbiz.base.util.UtilHttp;
-import org.apache.ofbiz.base.util.UtilProperties;
-import org.apache.ofbiz.base.util.UtilURL;
-import org.apache.ofbiz.base.util.UtilValidate;
-import org.apache.ofbiz.base.util.UtilXml;
-import org.apache.ofbiz.entity.Delegator;
-import org.apache.ofbiz.entity.GenericEntityException;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.entity.util.EntityQuery;
-import org.apache.ofbiz.webapp.control.LoginWorker;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * Java Helper Class for Janrain Engage
- */
-public class JanrainHelper {
-
- private static final String MODULE = JanrainHelper.class.getName();
- private static String apiKey =
UtilProperties.getPropertyValue("ecommerce", "janrain.apiKey");
- private static String baseUrl =
UtilProperties.getPropertyValue("ecommerce", "janrain.baseUrl");
-
- public JanrainHelper(String apiKey, String baseUrl) {
- while (baseUrl.endsWith("/")) {
- baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
- }
- JanrainHelper.apiKey = apiKey;
- JanrainHelper.baseUrl = baseUrl;
- }
-
- /**
- * Gets API key.
- * @return the API key
- */
- public String getApiKey() {
- return apiKey;
- }
-
- /**
- * Gets base URL.
- * @return the base URL
- */
- public String getBaseUrl() {
- return baseUrl;
- }
- public static Element authInfo(String token) {
- Map<String, Object> query = new HashMap<>();
- query.put("token", token);
- return apiCall("auth_info", query);
- }
-
- /**
- * All mappings hash map.
- * @return the hash map
- */
- public HashMap<String, List<String>> allMappings() {
- Element rsp = apiCall("all_mappings", null);
- rsp.getFirstChild();
- HashMap<String, List<String>> result = new HashMap<>();
- NodeList mappings = getNodeList("/rsp/mappings/mapping", rsp);
- for (int i = 0; i < mappings.getLength(); i++) {
- Element mapping = (Element) mappings.item(i);
- List<String> identifiers = new ArrayList<>();
- NodeList rkList = getNodeList("primaryKey", mapping);
- NodeList idList = getNodeList("identifiers/identifier", mapping);
- String remoteKey = ((Element) rkList.item(0)).getTextContent();
- for (int j = 0; j < idList.getLength(); j++) {
- Element ident = (Element) idList.item(j);
- identifiers.add(ident.getTextContent());
- }
- result.put(remoteKey, identifiers);
- }
- return result;
- }
- private static NodeList getNodeList(String xpathExpr, Element root) {
- XPathFactory factory = XPathFactory.newInstance();
- XPath xpath = factory.newXPath();
- try {
- return (NodeList) xpath.evaluate(xpathExpr, root,
XPathConstants.NODESET);
- } catch (XPathExpressionException e) {
- return null;
- }
- }
-
- /**
- * Mappings list.
- * @param primaryKey the primary key
- * @return the list
- */
- public List<String> mappings(Object primaryKey) {
- Map<String, Object> query = new HashMap<>();
- query.put("primaryKey", primaryKey);
- Element rsp = apiCall("mappings", query);
- Element oids = (Element) rsp.getFirstChild();
- List<String> result = new ArrayList<>();
- NodeList nl = oids.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- Element e = (Element) nl.item(i);
- result.add(e.getTextContent());
- }
- return result;
- }
-
- /**
- * Map.
- * @param identifier the identifier
- * @param primaryKey the primary key
- */
- public void map(String identifier, Object primaryKey) {
- Map<String, Object> query = new HashMap<>();
- query.put("identifier", identifier);
- query.put("primaryKey", primaryKey);
- apiCall("map", query);
- }
-
- /**
- * Unmap.
- * @param identifier the identifier
- * @param primaryKey the primary key
- */
- public void unmap(String identifier, Object primaryKey) {
- Map<String, Object> query = new HashMap<>();
- query.put("identifier", identifier);
- query.put("primaryKey", primaryKey);
- apiCall("unmap", query);
- }
- private static Element apiCall(String methodName, Map<String, Object>
partialQuery) {
- Map<String, Object> query = null;
- if (partialQuery == null) {
- query = new HashMap<>();
- } else {
- query = new HashMap<>(partialQuery);
- }
- query.put("format", "xml");
- query.put("apiKey", apiKey);
- StringBuffer sb = new StringBuffer();
- for (Iterator<Map.Entry<String, Object>> it =
query.entrySet().iterator(); it.hasNext();) {
- if (sb.length() > 0) {
- sb.append('&');
- }
- try {
- Map.Entry<String, Object> e = it.next();
- sb.append(URLEncoder.encode(e.getKey().toString(), "UTF-8"));
- sb.append('=');
- sb.append(URLEncoder.encode(e.getValue().toString(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unexpected encoding error", e);
- }
- }
- String data = sb.toString();
- try {
- URL url = UtilURL.fromUrlString(baseUrl + "/api/v2/" + methodName);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.setDoOutput(true);
- conn.connect();
- OutputStreamWriter osw = new OutputStreamWriter(
- conn.getOutputStream(), "UTF-8");
- osw.write(data);
- osw.close();
-
- BufferedReader post = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
- String line = "";
- StringBuilder buf = new StringBuilder();
- while ((line = post.readLine()) != null) {
- buf.append(line);
- }
- post.close();
- Document tagXml = UtilXml.readXmlDocument(buf.toString());
- Element response = tagXml.getDocumentElement();
- if (!"ok".equals(response.getAttribute("stat"))) {
- throw new RuntimeException("Unexpected API error");
- }
- return response;
- } catch (MalformedURLException e) {
- throw new RuntimeException("Unexpected URL error", e);
- } catch (IOException e) {
- throw new RuntimeException("Unexpected IO error", e);
- } catch (ParserConfigurationException | SAXException e) {
- throw new RuntimeException("Unexpected XML error", e);
- }
- }
-
- public static String janrainCheckLogin(HttpServletRequest request,
HttpServletResponse response) {
- Delegator delegator = (Delegator) request.getAttribute("delegator");
- String token = request.getParameter("token");
- String errMsg = "";
- if (UtilValidate.isNotEmpty(token)) {
- Element authInfo = JanrainHelper.authInfo(token);
- Element profileElement = UtilXml.firstChildElement(authInfo,
"profile");
- Element nameElement = UtilXml.firstChildElement(profileElement,
"name");
-
- // profile element
- String displayName =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement, "displayName"));
- String email =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement, "email"));
- String identifier =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement, "identifier"));
- String preferredUsername =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement,
"preferredUsername"));
- String providerName =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement, "providerName"));
- String url =
UtilXml.elementValue(UtilXml.firstChildElement(profileElement, "url"));
-
- // name element
- String givenName =
UtilXml.elementValue(UtilXml.firstChildElement(nameElement, "givenName"));
- String familyName =
UtilXml.elementValue(UtilXml.firstChildElement(nameElement, "familyName"));
- String formatted =
UtilXml.elementValue(UtilXml.firstChildElement(nameElement, "formatted"));
-
- if (UtilValidate.isEmpty("preferredUsername")) {
- errMsg = UtilProperties.getMessage("SecurityextUiLabels",
"loginevents.username_not_found_reenter", UtilHttp.getLocale(request));
- request.setAttribute("_ERROR_MESSAGE_", errMsg);
- return "error";
- }
-
- Map<String, String> result = new HashMap<>();
- result.put("displayName", displayName);
- result.put("email", email);
- result.put("identifier", identifier);
- result.put("preferredUsername", preferredUsername);
- result.put("providerName", providerName);
- result.put("url", url);
- result.put("givenName", givenName);
- result.put("familyName", familyName);
- result.put("formatted", formatted);
- request.setAttribute("userInfoMap", result);
- try {
- GenericValue userLogin =
EntityQuery.use(delegator).from("UserLogin").where("userLoginId",
preferredUsername).cache().queryOne();
- if (userLogin != null) {
- LoginWorker.doBasicLogin(userLogin, request, response);
- LoginWorker.createSecuredLoginIdCookie(request, response);
- LoginWorker.autoLoginSet(request, response);
- return "success";
- } else {
- return "userLoginMissing";
- }
- } catch (GenericEntityException e) {
- Debug.logError(e, "Error finding the userLogin for distributed
cache clear", MODULE);
- }
- }
- return "success";
- }
-}
diff --git a/ecommerce/template/Login.ftl b/ecommerce/template/Login.ftl
index 1a35fcb5c..89da5977d 100644
--- a/ecommerce/template/Login.ftl
+++ b/ecommerce/template/Login.ftl
@@ -16,71 +16,6 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-<#assign janrainEnabled =
Static["org.apache.ofbiz.entity.util.EntityUtilProperties"].getPropertyValue("ecommerce",
"janrain.enabled", delegator)>
-<#assign appName =
Static["org.apache.ofbiz.entity.util.EntityUtilProperties"].getPropertyValue("ecommerce",
"janrain.appName", delegator)>
-<#if "Y" == janrainEnabled>
-<script type="application/javascript">
-(function() {
- if (typeof window.janrain !== 'object') window.janrain = {};
- window.janrain.settings = {};
-
- janrain.settings.tokenUrl = '<@ofbizUrl fullPath="true"
secure="true">janrainCheckLogin</@ofbizUrl>';
-
- function isReady() { janrain.ready = true; };
- if (document.addEventListener) {
- document.addEventListener("DOMContentLoaded", isReady, false);
- } else {
- window.attachEvent('onload', isReady);
- }
-
- var e = document.createElement('script');
- e.type = 'application/javascript';
- e.id = 'janrainAuthWidget';
-
- if (document.location.protocol === 'https:') {
- e.src = 'https://rpxnow.com/js/lib/${appName}/engage.js';
- } else {
- e.src = 'http://widget-cdn.rpxnow.com/js/lib/${appName}/engage.js';
- }
-
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(e, s);
-})();
-</script>
-
-
-<div class="d-flex justify-content-center">
- <div class="card p-6">
- <div class="card-header">
- <h3>${uiLabelMap.CommonRegistered}</h3>
- </div>
- <div class="card-block p-1 m-2">
- <form method="post" action="<@ofbizUrl>login</@ofbizUrl>"
name="loginform">
- <div class="form-group">
- <label for="userName">${uiLabelMap.CommonUsername}</label>
- <input type="text" class="form-control" id="userName"
name="USERNAME" value="<#if
requestParameters.USERNAME?has_content>${requestParameters.USERNAME}<#elseif
autoUserLogin?has_content>${autoUserLogin.userLoginId}</#if>"/>
- <#if autoUserLogin?has_content>
- <p>(${uiLabelMap.CommonNot} ${autoUserLogin.userLoginId}? <a
href="<@ofbizUrl>${autoLogoutUrl}</@ofbizUrl>">${uiLabelMap.CommonClickHere}</a>)</p>
- </#if>
- </div>
- <div class="form-group">
- <label for="password">${uiLabelMap.CommonPassword}</label>
- <input type="password" class="form-control" id="password"
name="PASSWORD" autocomplete="off" value=""/>
- </div>
- <div class="form-group">
- <input type="submit" class="btn btn-primary btn-block"
value="${uiLabelMap.CommonLogin}"/>
- </div>
- <div class="form-group">
- <label
for="newcustomer_submit">${uiLabelMap.CommonMayCreateNewAccountHere}:
- <a
href="<@ofbizUrl>newcustomer</@ofbizUrl>">${uiLabelMap.CommonMayCreate}</a>
- </label>
- </div>
- </form>
- <div id="janrainEngageEmbed"></div>
- </div>
- </div>
-</div>
-<#else>
<div class="d-flex justify-content-center">
<div class="card p-6">
<div class="card-header">
@@ -138,7 +73,6 @@ under the License.
</div>
</div>
</div>
-</#if>
<div class="endcolumns"> </div>
diff --git a/ecommerce/template/customer/NewCustomer.ftl
b/ecommerce/template/customer/NewCustomer.ftl
index 34075c00f..090e3f5d5 100644
--- a/ecommerce/template/customer/NewCustomer.ftl
+++ b/ecommerce/template/customer/NewCustomer.ftl
@@ -403,25 +403,17 @@ will generally always be reserved for the logo at the top
of the page.
<legend><#if getUsername>${uiLabelMap.CommonUsername}</#if></legend>
<#if getUsername>
<@fieldErrors fieldName="USERNAME"/>
- <#if !requestParameters.preferredUsername?has_content>
<div class="form-check">
<input type="checkbox" name="UNUSEEMAIL" class="form-check-input"
id="UNUSEEMAIL" value="on"
onclick="setEmailUsername();" onfocus="setLastFocused(this);"/>
<label>${uiLabelMap.EcommerceUseEmailAddress}</label>
</div>
- </#if>
<div class="row form-group">
<div class="col-12">
<label for="USERNAME">${uiLabelMap.CommonUsername}*</label>
- <#if requestParameters.preferredUsername?has_content>
- <input type="text" name="showUserName" id="showUserName"
value="${requestParameters.USERNAME!}"
- disabled="disabled"/>
- <input type="hidden" name="USERNAME" id="USERNAME"
value="${requestParameters.USERNAME!}"/>
- <#else>
<input type="text" name="USERNAME" id="USERNAME"
value="${requestParameters.USERNAME!}"
class="form-control form-control-sm" onfocus="clickUsername();"
onchange="changeEmail();"/>
- </#if>
</div>
</div>
</#if>
diff --git a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
index 2ca419326..accba03f1 100644
--- a/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
+++ b/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
@@ -1869,15 +1869,6 @@ under the License.
<response name="error" type="view-last" save-current-view="true"/>
</request-map>
- <!-- ============== Janrain Engage ============== -->
- <request-map uri="janrainCheckLogin">
- <security https="true" auth="false"/>
- <event type="java"
path="org.apache.ofbiz.ecommerce.janrain.JanrainHelper"
invoke="janrainCheckLogin"/>
- <response name="success" type="view" value="main"/>
- <response name="error" type="view" value="login"/>
- <response name="userLoginMissing" type="request" value="newcustomer"/>
- </request-map>
-
<!-- End of Request Mappings -->
<!-- View Mappings -->