details: https://code.openbravo.com/erp/devel/pi/rev/075ca846cedf
changeset: 24227:075ca846cedf
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Mon Aug 11 11:43:25 2014 +0200
summary: related to issue 27277: core changes to support new Google sign in
New Google OAuth2 sign is implemented by an external module [1], this patch
provides required infrastructure in order it to be implemented:
- Sign In button in Login page can be modified by external modules
- Some methods in LoginHandler are now accessible to be used by classes
extending it
[1]
http://centralrepository.openbravo.com/heartbeat-server/org.openbravo.forge.ui/sso/ForgeModuleDetail/Google-Sign-In
diffstat:
src/org/openbravo/base/secureApp/LoginHandler.java | 10 ++--
src/org/openbravo/erpCommon/security/Login.java | 35 +++++++++----
src/org/openbravo/erpCommon/security/SignInProvider.java | 39 ++++++++++++++++
3 files changed, 68 insertions(+), 16 deletions(-)
diffs (142 lines):
diff -r 3c7438e9bf3f -r 075ca846cedf
src/org/openbravo/base/secureApp/LoginHandler.java
--- a/src/org/openbravo/base/secureApp/LoginHandler.java Fri Aug 08
16:49:37 2014 +0000
+++ b/src/org/openbravo/base/secureApp/LoginHandler.java Mon Aug 11
11:43:25 2014 +0200
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2001-2013 Openbravo S.L.U.
+ * Copyright (C) 2001-2014 Openbravo S.L.U.
* Licensed under the Apache Software License version 2.0
* 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
@@ -120,7 +120,7 @@
}
}
- private void checkLicenseAndGo(HttpServletResponse res, VariablesSecureApp
vars,
+ protected final void checkLicenseAndGo(HttpServletResponse res,
VariablesSecureApp vars,
String strUserAuth, String username, String sessionId, boolean redirect)
throws IOException,
ServletException {
OBContext.setAdminMode();
@@ -365,9 +365,9 @@
}
}
- private void goToRetry(HttpServletResponse response, VariablesSecureApp
vars, String message,
- String title, String msgType, String action, boolean doRedirect) throws
IOException,
- ServletException {
+ protected final void goToRetry(HttpServletResponse response,
VariablesSecureApp vars,
+ String message, String title, String msgType, String action, boolean
doRedirect)
+ throws IOException, ServletException {
String msg = (message != null && !message.equals("")) ? message
: "Please enter your username and password.";
diff -r 3c7438e9bf3f -r 075ca846cedf
src/org/openbravo/erpCommon/security/Login.java
--- a/src/org/openbravo/erpCommon/security/Login.java Fri Aug 08 16:49:37
2014 +0000
+++ b/src/org/openbravo/erpCommon/security/Login.java Mon Aug 11 11:43:25
2014 +0200
@@ -11,7 +11,7 @@
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2014 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -21,6 +21,9 @@
import java.io.IOException;
import java.io.PrintWriter;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -49,6 +52,10 @@
private static final String GOOGLE_INTEGRATION_MODULE_ID =
"FF8080813129ADA401312CA1222A0005";
private static final String GOOGLE_PREFERENCE_PROPERTY = "OBSEIG_ShowGIcon";
+ @Inject
+ @Any
+ private Instance<SignInProvider> signInProvider;
+
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException,
ServletException {
@@ -333,16 +340,22 @@
xmlDocument.setParameter("recBrowserMsgText",
recBrowserMsgTextFinal.replaceAll("\\n", "\n"));
if (showGoogleIcon) {
-
- String authServlet =
"../org.openbravo.service.integration.google/auth.html";
- String link = "<p class=\"LabelText Login_LabelText\"
style=\"line-height:24px;\">"
- + Utility.messageBD(this, "OBSEIG_SignIn", vars.getLanguage()) +
" <a href=\""
- + authServlet + "\" title=\""
- + Utility.messageBD(this, "OBSEIG_SignInAltMsg", vars.getLanguage())
- + "\" target=\"_top\" "
- + "><img style=\"vertical-align:middle;\"
src=\"../web/images/google.png\" alt=\""
- + Utility.messageBD(this, "OBSEIG_SignInAltMsg", vars.getLanguage())
- + "\" width=\"24\" height=\"24\" border=\"0\"/></a></p>";
+ String link;
+ if (signInProvider.isUnsatisfied()) {
+ // there is no external sign in provider, using default OpenID link
+ String authServlet =
"../org.openbravo.service.integration.google/auth.html";
+ link = "<p class=\"LabelText Login_LabelText\"
style=\"line-height:24px;\">"
+ + Utility.messageBD(this, "OBSEIG_SignIn", vars.getLanguage()) +
" <a href=\""
+ + authServlet + "\" title=\""
+ + Utility.messageBD(this, "OBSEIG_SignInAltMsg",
vars.getLanguage())
+ + "\" target=\"_top\" "
+ + "><img style=\"vertical-align:middle;\"
src=\"../web/images/google.png\" alt=\""
+ + Utility.messageBD(this, "OBSEIG_SignInAltMsg",
vars.getLanguage())
+ + "\" width=\"24\" height=\"24\" border=\"0\"/></a></p>";
+ } else {
+ // a module is providing a different sign in: including its HTML code
in Log In page
+ link = signInProvider.get().getLoginPageSignInHTMLCode();
+ }
xmlDocument.setParameter("sign-in", link);
}
diff -r 3c7438e9bf3f -r 075ca846cedf
src/org/openbravo/erpCommon/security/SignInProvider.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/security/SignInProvider.java Mon Aug 11
11:43:25 2014 +0200
@@ -0,0 +1,39 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.security;
+
+import javax.enterprise.context.ApplicationScoped;
+
+/**
+ * If this interface is implemented, an alternative HTML code for Google Sign
In is displayed in Log
+ * In page.
+ *
+ * Note at most one class per instance should implement this interface.
+ *
+ * @author alostale
+ *
+ */
+@ApplicationScoped
+public interface SignInProvider {
+ /**
+ * HTML code to be placed in Log In page for Google Sing in button
+ */
+ public String getLoginPageSignInHTMLCode();
+}
------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits