From 66e34c2da6d7c52e1c4349e04ada692d65f476fd Mon Sep 17 00:00:00 2001 From: Salvatore La Manna Date: Thu, 8 Oct 2020 14:57:14 +0200 Subject: [PATCH 1/2] Spostato login hook --- .../hooks/sicilia-login-hook/.classpath | 27 ---- .../hooks/sicilia-login-hook/.project | 37 ----- .../sicilia-login-hook/.settings/.jsdtscope | 12 -- .../.settings/org.eclipse.jdt.core.prefs | 7 - .../org.eclipse.wst.common.component | 8 -- ...se.wst.common.project.facet.core.prefs.xml | 7 - ....eclipse.wst.common.project.facet.core.xml | 11 -- ...rg.eclipse.wst.jsdt.ui.superType.container | 1 - .../org.eclipse.wst.jsdt.ui.superType.name | 1 - .../hooks/sicilia-login-hook/build.xml | 6 - .../docroot/META-INF/MANIFEST.MF | 3 - .../docroot/WEB-INF/.gitignore | 1 - .../docroot/WEB-INF/liferay-hook.xml | 16 --- .../WEB-INF/liferay-plugin-package.properties | 11 -- .../mwg/sicilia/constants/ApiConstants.java | 46 ------- .../mwg/sicilia/login/SiciliaAutoLogin.java | 113 ---------------- .../mwg/sicilia/login/SiciliaLoginFilter.java | 76 ----------- .../src/it/mwg/sicilia/util/ApiUtil.java | 126 ------------------ .../docroot/WEB-INF/src/portal.properties | 2 - .../docroot/WEB-INF/web.xml | 5 - .../hooks/sicilia-login-hook/ivy.xml | 18 --- .../hooks/sicilia-login-hook/ivy.xml.MD5 | 1 - .../test/integration/arquillian.xml | 15 --- 23 files changed, 550 deletions(-) delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.classpath delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.project delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/.jsdtscope delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.jdt.core.prefs delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.component delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/build.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/META-INF/MANIFEST.MF delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/.gitignore delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-hook.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-plugin-package.properties delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/constants/ApiConstants.java delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaAutoLogin.java delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaLoginFilter.java delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/util/ApiUtil.java delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/portal.properties delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/web.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml.MD5 delete mode 100644 liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/test/integration/arquillian.xml diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.classpath b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.classpath deleted file mode 100644 index 81819043..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.classpath +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.project b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.project deleted file mode 100644 index c5c939f3..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.project +++ /dev/null @@ -1,37 +0,0 @@ - - - sicilia-login-hook - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.jdt.core.javanature - org.apache.ivyde.eclipse.ivynature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/.jsdtscope b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/.jsdtscope deleted file mode 100644 index 840a01d5..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/.jsdtscope +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.jdt.core.prefs b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f42de363..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.component b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.component deleted file mode 100644 index bacfbb69..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml deleted file mode 100644 index 1f9ee534..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 02ccc82b..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container deleted file mode 100644 index 3bd5d0a4..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.container +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name deleted file mode 100644 index 05bd71b6..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/.settings/org.eclipse.wst.jsdt.ui.superType.name +++ /dev/null @@ -1 +0,0 @@ -Window \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/build.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/build.xml deleted file mode 100644 index c2d19b37..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/build.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/META-INF/MANIFEST.MF b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/META-INF/MANIFEST.MF deleted file mode 100644 index 5e949512..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/.gitignore b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/.gitignore deleted file mode 100644 index 840e7d31..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/classes/ diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-hook.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-hook.xml deleted file mode 100644 index 4ba27c04..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-hook.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - portal.properties - - Sicilia SSO - it.mwg.sicilia.login.SiciliaLoginFilter - - - Sicilia SSO - /c/portal/login - FORWARD - REQUEST - - \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-plugin-package.properties b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-plugin-package.properties deleted file mode 100644 index fca51bc8..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/liferay-plugin-package.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=Sicilia Login Hook -module-group-id=liferay -module-incremental-version=1 -tags= -short-description= -long-description= -change-log= -page-url=http://www.liferay.com -author=Liferay, Inc. -licenses=LGPL -liferay-versions=6.2.0+ \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/constants/ApiConstants.java b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/constants/ApiConstants.java deleted file mode 100644 index e5e5b9bc..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/constants/ApiConstants.java +++ /dev/null @@ -1,46 +0,0 @@ -package it.mwg.sicilia.constants; - -import java.util.HashMap; -import java.util.Map; - -public class ApiConstants { - public static final String LABEL_ERROR_CODE = "code"; - public static final String LABEL_DESCRIPTION = "description"; - public static final String LABEL_STATUS = "status"; - - public static final int ERROR_OK = 0; - public static final int ERROR_INVALID_AUTH = 1; - public static final int ERROR_INVALID_LOGIN = 2; - public static final int ERROR_INVALID_TOKEN = 3; - public static final int ERROR_INVALID_INPUT = 4; - public static final int ERROR_MISSING_PARAMETER = 5; - public static final int ERROR_INVALID_PASSWORD = 6; - - public static final String STATUS_OK = "success"; - public static final String STATUS_ERROR = "error"; - - public static final String API_USERNAME = "sismica"; - public static final String API_PASSWORD = "4Tr-D%fO!sli5"; - - public static final String PARAMETER_AUTH = "auth"; - public static final String PARAMETER_CALLBACK_URL = "callback"; - public static final String PARAMETER_TOKEN = "token"; - public static final String PARAMETER_USERNAME = "username"; - public static final String PARAMETER_PASSWORD = "password"; - public static final String PARAMETER_FIRST_NAME = "nome"; - public static final String PARAMETER_LAST_NAME = "cognome"; - public static final String PARAMETER_CODICE_FISCALE = "codice_fiscale"; - - private static final String SESSION_BASE = "SICILIA_HOOK_"; - public static final String SESSION_AUTH = SESSION_BASE + PARAMETER_AUTH.toUpperCase(); - public static final String SESSION_TOKEN = SESSION_BASE + PARAMETER_TOKEN.toUpperCase(); - public static final String SESSION_USER_DATA = SESSION_BASE + "USER_DATA"; - - public static final String LOGIN_SERVER = "https://autenticazione.lavoripubblici.sicilia.it/"; - private static final String ENDPOINT_BASE = LOGIN_SERVER + "api/v1/"; - public static final String ENDPOINT_LOGIN = ENDPOINT_BASE + "login.cgi"; - public static final String ENDPOINT_GET_TOKEN = ENDPOINT_BASE + "get_token.cgi"; - public static final String ENDPOINT_GET_USER = ENDPOINT_BASE + "get_user.cgi"; - - public static final String HTTP_USER_AGENT = "Sicilia Login like Mozilla/5.0"; -} diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaAutoLogin.java b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaAutoLogin.java deleted file mode 100644 index 0c2074e0..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaAutoLogin.java +++ /dev/null @@ -1,113 +0,0 @@ -package it.mwg.sicilia.login; - -import it.mwg.sicilia.constants.ApiConstants; - -import java.util.Date; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.log.Log; -import com.liferay.portal.kernel.log.LogFactoryUtil; -import com.liferay.portal.kernel.security.SecureRandom; -import com.liferay.portal.kernel.util.StringPool; -import com.liferay.portal.kernel.util.Validator; -import com.liferay.portal.model.User; -import com.liferay.portal.security.auth.AutoLogin; -import com.liferay.portal.security.auth.AutoLoginException; -import com.liferay.portal.service.ServiceContext; -import com.liferay.portal.service.UserLocalServiceUtil; -import com.liferay.portal.util.PortalUtil; - -/** - * @author Manifattura Web Group per Regione Siciliana - * - */ -public class SiciliaAutoLogin implements AutoLogin { - private static final Log _log = LogFactoryUtil.getLog(SiciliaAutoLogin.class); - - @Override - public String[] login(HttpServletRequest request, HttpServletResponse response) throws AutoLoginException { - User user = null; - HttpSession session = request.getSession(); - Map userData = (Map) session - .getAttribute(ApiConstants.SESSION_USER_DATA); - if (Validator.isNotNull(userData)) { - long companyId = PortalUtil.getCompanyId(request); - user = logUser(companyId, userData.get(ApiConstants.PARAMETER_CODICE_FISCALE), - userData.get(ApiConstants.PARAMETER_FIRST_NAME), - userData.get(ApiConstants.PARAMETER_LAST_NAME)); - if (Validator.isNotNull(user)) { - return new String[] { String.valueOf(user.getUserId()), user.getPassword(), - String.valueOf(user.isPasswordEncrypted()) }; - } - } - return null; - } - - @Override - public String[] handleException(HttpServletRequest request, HttpServletResponse response, Exception e) - throws AutoLoginException { - _log.error(e); - return null; - } - - private User logUser(long companyId, String screenName, String firstName, String lastName) { - _log.info("Cerco l'utente " + screenName + " (" + firstName + " " + lastName + ")"); - User user = null; - try { - user = UserLocalServiceUtil.fetchUserByScreenName(companyId, screenName); - - if (Validator.isNull(user)) { - long creatorUserId = UserLocalServiceUtil.getDefaultUserId(companyId); - boolean autoPassword = true; - String password = randomPassword(24); - boolean autoScreenName = false; - String emailAddress = screenName + "@no-email.regione.sicilia.it"; - long facebookId = 0; - String openId = StringPool.BLANK; - Locale locale = Locale.ITALY; - String middleName = StringPool.BLANK; - int prefixId = 0; - int suffixId = 0; - boolean male = true; - int birthdayMonth = 0; - int birthdayDay = 1; - int birthdayYear = 1970; - String jobTitle = StringPool.BLANK; - long[] groupIds = null; - long[] organizationIds = null; - long[] roleIds = null; - long[] userGroupIds = null; - boolean sendEmail = false; - ServiceContext serviceContext = new ServiceContext(); - user = UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password, - password, autoScreenName, screenName, emailAddress, facebookId, openId, locale, - firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, - birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, - userGroupIds, sendEmail, serviceContext); - user.setPasswordModified(true); - user.setPasswordModifiedDate(new Date()); - user.setPasswordReset(false); - UserLocalServiceUtil.updateUser(user); - } - } catch (SystemException | PortalException e) { - _log.error("Errore durante l'autenticazione/creazione dell'utente " + screenName, e); - } - return user; - } - - private String randomPassword(int length) { - SecureRandom rnd = new SecureRandom(); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { - sb.append((char) (32 + rnd.nextInt(95))); - } - return sb.toString(); - } -} diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaLoginFilter.java b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaLoginFilter.java deleted file mode 100644 index b94c6ef9..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/login/SiciliaLoginFilter.java +++ /dev/null @@ -1,76 +0,0 @@ -package it.mwg.sicilia.login; - -import it.mwg.sicilia.constants.ApiConstants; -import it.mwg.sicilia.util.ApiUtil; - -import java.io.IOException; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import com.liferay.portal.kernel.exception.PortalException; -import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.log.Log; -import com.liferay.portal.kernel.log.LogFactoryUtil; -import com.liferay.portal.kernel.util.StringPool; -import com.liferay.portal.kernel.util.Validator; -import com.liferay.portal.kernel.util.WebKeys; -import com.liferay.portal.model.User; -import com.liferay.portal.service.ServiceContext; -import com.liferay.portal.service.UserLocalServiceUtil; -import com.liferay.portal.util.PortalUtil; - -public class SiciliaLoginFilter implements Filter { - public static final Log _log = LogFactoryUtil.getLog(SiciliaLoginFilter.class); - - @Override - public void destroy() { - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) - throws IOException, ServletException { - HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; - String url = httpServletRequest.getRequestURL().toString(); - String qs = httpServletRequest.getQueryString(); - if (Validator.isNotNull(qs)) { - url += "?" + qs; - } - _log.info("Filtro: " + url); - HttpSession session = httpServletRequest.getSession(); - String token = (String) session.getAttribute(ApiConstants.SESSION_TOKEN); - if (Validator.isNull(token)) { - token = ApiUtil.getToken(url); - _log.info("Ho creato il token " + token + ". Eseguo redirect"); - session.setAttribute(ApiConstants.SESSION_TOKEN, token); - ((HttpServletResponse) servletResponse).sendRedirect(ApiConstants.LOGIN_SERVER + "?t=" + token); - return; - } else { - Map userData = ApiUtil.getUserInfo(token); - if (Validator.isNull(userData)) { - _log.info("Il token potrebbe essere scaduto. Lo ricreo ed eseguo redirect."); - token = ApiUtil.getToken(url); - session.setAttribute(ApiConstants.SESSION_TOKEN, token); - ((HttpServletResponse) servletResponse).sendRedirect(ApiConstants.LOGIN_SERVER + "?t=" - + token); - return; - } else { - session.setAttribute(ApiConstants.SESSION_USER_DATA, userData); - } - } - chain.doFilter(servletRequest, servletResponse); - } - - @Override - public void init(FilterConfig config) throws ServletException { - } -} diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/util/ApiUtil.java b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/util/ApiUtil.java deleted file mode 100644 index 15f04d44..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/it/mwg/sicilia/util/ApiUtil.java +++ /dev/null @@ -1,126 +0,0 @@ -package it.mwg.sicilia.util; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import it.mwg.sicilia.constants.ApiConstants; - -import com.liferay.portal.kernel.json.JSONException; -import com.liferay.portal.kernel.json.JSONFactoryUtil; -import com.liferay.portal.kernel.json.JSONObject; -import com.liferay.portal.kernel.log.Log; -import com.liferay.portal.kernel.log.LogFactoryUtil; -import com.liferay.portal.kernel.util.Validator; - -public class ApiUtil { - private static final Log _log = LogFactoryUtil.getLog(ApiUtil.class); - private static String auth = null; - - public static String getToken(String callbackURL) { - if (Validator.isNull(auth)) { - login(); - } - for (int i = 0; i < 10; i++) { - if (Validator.isNotNull(auth)) { - JSONObject map = JSONFactoryUtil.createJSONObject(); - map.put(ApiConstants.PARAMETER_AUTH, auth).put(ApiConstants.PARAMETER_CALLBACK_URL, - callbackURL); - map = post(ApiConstants.ENDPOINT_GET_TOKEN, map); - if (Validator.isNotNull(map)) { - switch (map.getInt(ApiConstants.LABEL_ERROR_CODE)) { - case ApiConstants.ERROR_OK: - return map.getString(ApiConstants.PARAMETER_TOKEN); - case ApiConstants.ERROR_INVALID_AUTH: - _log.info("Auth scaduto. Eseguo nuovo login"); - login(); - break; - default: - _log.error("Errore durante la creazione del token: " + map.toString()); - return null; - } - } else { - _log.error("Errore inatteso durante la creazione del token"); - } - } - } - return null; - } - - public static Map getUserInfo(String token) { - _log.info("Recupero informazioni sull'utente con il token " + token + ", auth " + auth); - JSONObject map = JSONFactoryUtil.createJSONObject(); - map.put(ApiConstants.PARAMETER_AUTH, auth).put(ApiConstants.PARAMETER_TOKEN, token); - map = post(ApiConstants.ENDPOINT_GET_USER, map); - if (Validator.isNotNull(map)) { - switch (map.getInt(ApiConstants.LABEL_ERROR_CODE)) { - case ApiConstants.ERROR_OK: - _log.info("Ho i dati dell'utente"); - Map ret = new HashMap(); - ret.put(ApiConstants.PARAMETER_FIRST_NAME, map.getString(ApiConstants.PARAMETER_FIRST_NAME)); - ret.put(ApiConstants.PARAMETER_LAST_NAME, map.getString(ApiConstants.PARAMETER_LAST_NAME)); - ret.put(ApiConstants.PARAMETER_CODICE_FISCALE, - map.getString(ApiConstants.PARAMETER_CODICE_FISCALE)); - return ret; - default: - _log.error("Errore durante il recupero dei dati utente: " + map.toString()); - } - } - return null; - } - - private static void login() { - JSONObject map = JSONFactoryUtil.createJSONObject(); - map.put(ApiConstants.PARAMETER_USERNAME, ApiConstants.API_USERNAME).put( - ApiConstants.PARAMETER_PASSWORD, ApiConstants.API_PASSWORD); - map = post(ApiConstants.ENDPOINT_LOGIN, map); - if (Validator.isNotNull(map)) { - if (ApiConstants.ERROR_OK == map.getInt(ApiConstants.LABEL_ERROR_CODE)) { - auth = map.getString(ApiConstants.PARAMETER_AUTH); - } else { - _log.error("Errore durante il login: " + map.toString()); - } - } - } - - private static JSONObject post(String endPoint, JSONObject json) { - try { - URL url = new URL(endPoint); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("POST"); - connection.setRequestProperty("User-Agent", ApiConstants.HTTP_USER_AGENT); - connection.setDoOutput(true); - OutputStream stream = connection.getOutputStream(); - _log.info("Invio: " + json.toString() + " (" + endPoint + ")"); - stream.write(json.toString().getBytes()); - stream.flush(); - stream.close(); - int code = connection.getResponseCode(); - if (code == HttpURLConnection.HTTP_OK) { - String response = readResponse(connection); - _log.info("Ricevo: " + response); - JSONObject ret = JSONFactoryUtil.createJSONObject(response); - return ret; - } - } catch (IOException | JSONException e) { - _log.error(e); - } - return null; - } - - private static String readResponse(HttpURLConnection connection) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - StringBuilder builder = new StringBuilder(); - String inputLine; - while ((inputLine = reader.readLine()) != null) { - builder.append(inputLine); - } - reader.close(); - - return builder.toString(); - } -} diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/portal.properties b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/portal.properties deleted file mode 100644 index 37b77654..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/src/portal.properties +++ /dev/null @@ -1,2 +0,0 @@ -#auth.pipeline.enable.liferay.check=false -auto.login.hooks=it.mwg.sicilia.login.SiciliaAutoLogin \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/web.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/web.xml deleted file mode 100644 index ff1320bc..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/docroot/WEB-INF/web.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml deleted file mode 100644 index abdd7ea2..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml.MD5 b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml.MD5 deleted file mode 100644 index 29d34b16..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/ivy.xml.MD5 +++ /dev/null @@ -1 +0,0 @@ -f1563bf5bac3cf93500d1510b72dd9da diff --git a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/test/integration/arquillian.xml b/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/test/integration/arquillian.xml deleted file mode 100644 index 9413609b..00000000 --- a/liferay-plugins-sdk-6.2/hooks/sicilia-login-hook/test/integration/arquillian.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - 8099 - tomcat - tomcat - - - \ No newline at end of file From c46ccd95a4c1e3b39f93653aebc44b2751c7f514 Mon Sep 17 00:00:00 2001 From: Salvatore La Manna Date: Fri, 9 Oct 2020 10:54:48 +0200 Subject: [PATCH 2/2] Correzioni classpath --- .../hooks/portos-p7m-preview-hook/.classpath | 2 +- .../portlets/portos-accesso-atti-portlet/.classpath | 2 +- .../portlets/portos-audit-portlet/.classpath | 2 +- .../portlets/portos-autodestroy-portlet/.classpath | 2 +- liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath | 2 +- .../portlets/portos-calendar-appointments-portlet/.classpath | 2 +- .../portlets/portos-company-configuration-portlet/.classpath | 2 +- .../portlets/portos-comunicazioni-portlet/.classpath | 2 +- .../portlets/portos-cookies-portlet/.classpath | 2 +- .../portlets/portos-deploy-alert-portlet/.classpath | 2 +- liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/.classpath | 2 +- .../WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java | 1 - .../portlets/portos-firma-portlet/.classpath | 2 +- .../portlets/portos-kaleo-controller-portlet/.classpath | 2 +- .../portlets/portos-kaleo-portlet/.classpath | 2 +- liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.classpath | 2 +- .../portlets/portos-mail-manager-portlet/.classpath | 2 +- .../portlets/portos-maintenance-portlet/.classpath | 2 +- .../portlets/portos-mapit-plugin-portlet/.classpath | 2 +- .../portlets/portos-notification-portlet/.classpath | 2 +- .../portlets/portos-report-engine-portlet/.classpath | 2 +- .../portlets/portos-report-portlet/.classpath | 2 +- .../themes/portos-private-fe-theme/.classpath | 2 +- liferay-plugins-sdk-6.2/themes/portos-private-theme/.classpath | 2 +- liferay-plugins-sdk-6.2/themes/portos-public-theme/.classpath | 2 +- liferay-plugins-sdk-6.2/webs/elasticray-web/.classpath | 2 +- liferay-plugins-sdk-6.2/webs/portos-kaleo-web/.classpath | 2 +- 27 files changed, 26 insertions(+), 27 deletions(-) diff --git a/liferay-plugins-sdk-6.2/hooks/portos-p7m-preview-hook/.classpath b/liferay-plugins-sdk-6.2/hooks/portos-p7m-preview-hook/.classpath index b1d20cc4..991a105e 100644 --- a/liferay-plugins-sdk-6.2/hooks/portos-p7m-preview-hook/.classpath +++ b/liferay-plugins-sdk-6.2/hooks/portos-p7m-preview-hook/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-accesso-atti-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-accesso-atti-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-accesso-atti-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-accesso-atti-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-audit-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-audit-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-audit-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-audit-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-autodestroy-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-autodestroy-portlet/.classpath index 6987637e..1d33a4b7 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-autodestroy-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-autodestroy-portlet/.classpath @@ -13,7 +13,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath index bbcb6f86..98a15bfe 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-bo-portlet/.classpath @@ -2,7 +2,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-calendar-appointments-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-calendar-appointments-portlet/.classpath index 250e6e62..d4becd03 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-calendar-appointments-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-calendar-appointments-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/.classpath index c9bb34d9..8870e168 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-company-configuration-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-comunicazioni-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-comunicazioni-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-comunicazioni-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-comunicazioni-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-cookies-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-cookies-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-cookies-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-cookies-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-deploy-alert-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-deploy-alert-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-deploy-alert-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-deploy-alert-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/.classpath index 4ffbb84d..8d9075a1 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java index e9bc421f..e10171dd 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java +++ b/liferay-plugins-sdk-6.2/portlets/portos-fe-portlet/docroot/WEB-INF/src/it/mwg/sismica/fe/servlet/SorgentiServlet.java @@ -48,7 +48,6 @@ import com.liferay.portal.util.PortalUtil; public class SorgentiServlet extends HttpServlet { private static final long serialVersionUID = 5549374841236285035L; - private static final Log _log = LogFactoryUtil.getLog(SorgentiServlet.class); private static final int validita = 3; private static final String folder = "condivisi"; diff --git a/liferay-plugins-sdk-6.2/portlets/portos-firma-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-firma-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-firma-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-firma-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.classpath index 3143cb15..e3868bf1 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-kaleo-controller-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-kaleo-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-kaleo-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-kaleo-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-kaleo-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-log-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/.classpath index 49008c9b..130677e9 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-mail-manager-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-maintenance-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-maintenance-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-maintenance-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-maintenance-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/.classpath index 1a538b03..9975372f 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-mapit-plugin-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-notification-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-notification-portlet/.classpath index 8ddc78ee..e2e2522a 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-notification-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-notification-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.classpath index 5c4dbb8c..0e46395b 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-engine-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/.classpath b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/.classpath index 5d845633..11cfe5fc 100644 --- a/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/.classpath +++ b/liferay-plugins-sdk-6.2/portlets/portos-report-portlet/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/themes/portos-private-fe-theme/.classpath b/liferay-plugins-sdk-6.2/themes/portos-private-fe-theme/.classpath index cfbd58dd..9c188251 100644 --- a/liferay-plugins-sdk-6.2/themes/portos-private-fe-theme/.classpath +++ b/liferay-plugins-sdk-6.2/themes/portos-private-fe-theme/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/themes/portos-private-theme/.classpath b/liferay-plugins-sdk-6.2/themes/portos-private-theme/.classpath index cfbd58dd..9c188251 100644 --- a/liferay-plugins-sdk-6.2/themes/portos-private-theme/.classpath +++ b/liferay-plugins-sdk-6.2/themes/portos-private-theme/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/themes/portos-public-theme/.classpath b/liferay-plugins-sdk-6.2/themes/portos-public-theme/.classpath index cfbd58dd..9c188251 100644 --- a/liferay-plugins-sdk-6.2/themes/portos-public-theme/.classpath +++ b/liferay-plugins-sdk-6.2/themes/portos-public-theme/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/webs/elasticray-web/.classpath b/liferay-plugins-sdk-6.2/webs/elasticray-web/.classpath index 089238a7..31fed00b 100644 --- a/liferay-plugins-sdk-6.2/webs/elasticray-web/.classpath +++ b/liferay-plugins-sdk-6.2/webs/elasticray-web/.classpath @@ -1,7 +1,7 @@ - + diff --git a/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/.classpath b/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/.classpath index ca4bcf17..db21580d 100644 --- a/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/.classpath +++ b/liferay-plugins-sdk-6.2/webs/portos-kaleo-web/.classpath @@ -1,7 +1,7 @@ - +