src/index.jsp
author Stefan Hühner <stefan.huehner@openbravo.com>
Fri, 27 May 2011 17:45:12 +0200
changeset 12524 3bf5295a7f03
parent 12425 0f8274676fcf
child 12927 0fa43a9749aa
permissions -rw-r--r--
Fixed 16775: Improve error handling if defined authentication.manager is missing
In case the defined authentication.manager can't be loaded log an error message
and use the default one instead of crashing with ClassNotFoundException.
Also improve error message in that case pointing to config option in config file
ivan@10243
     1
<%@ page import="java.util.Properties" %>
ivan@10243
     2
<%@ page import="org.openbravo.base.HttpBaseServlet" %>
ivan@10243
     3
<%@ page import="org.openbravo.base.util.OBClassLoader" %>
ivan@10243
     4
<%@ page import="org.openbravo.base.session.OBPropertiesProvider" %>
ivan@10243
     5
<%@ page import="org.openbravo.authentication.AuthenticationManager" %>
stefan@12524
     6
<%@ page import="org.apache.log4j.Logger" %>
ivan@10243
     7
<%@ page contentType="text/html; charset=UTF-8" %>
ivan@10243
     8
<%
ivan@10243
     9
/*
ivan@10243
    10
 *************************************************************************
ivan@10243
    11
 * The contents of this file are subject to the Openbravo  Public  License
ivan@10243
    12
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
ivan@10243
    13
 * Version 1.1  with a permitted attribution clause; you may not  use this
ivan@10243
    14
 * file except in compliance with the License. You  may  obtain  a copy of
ivan@10243
    15
 * the License at http://www.openbravo.com/legal/license.html 
ivan@10243
    16
 * Software distributed under the License  is  distributed  on  an "AS IS"
ivan@10243
    17
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
ivan@10243
    18
 * License for the specific  language  governing  rights  and  limitations
ivan@10243
    19
 * under the License. 
ivan@10243
    20
 * The Original Code is Openbravo ERP. 
ivan@10243
    21
 * The Initial Developer of the Original Code is Openbravo SLU 
ivan@10243
    22
 * All portions are Copyright (C) 2011 Openbravo SLU
ivan@10243
    23
 * All Rights Reserved. 
ivan@10243
    24
 * Contributor(s):  ______________________________________.
ivan@10243
    25
 ************************************************************************
ivan@10243
    26
 */
stefan@12524
    27
stefan@12524
    28
Logger log = Logger.getLogger(org.openbravo.authentication.AuthenticationManager.class); 
ivan@10243
    29
Properties obProperties = OBPropertiesProvider.getInstance().getOpenbravoProperties();
ivan@10243
    30
String authClass = obProperties.getProperty("authentication.class");
ivan@10243
    31
ivan@10243
    32
if(authClass == null || authClass.equals("")) {
ivan@10243
    33
  authClass = "org.openbravo.authentication.basic.DefaultAuthenticationManager";
ivan@10243
    34
}
ivan@10243
    35
stefan@12524
    36
AuthenticationManager authManager = null;
stefan@12524
    37
try {
stefan@12524
    38
  authManager = (AuthenticationManager) OBClassLoader.getInstance().loadClass(authClass).newInstance();
stefan@12524
    39
} catch (ClassNotFoundException cnfe) {
stefan@12524
    40
  log.error("Defined authentication manager cannot be loaded. Verify the 'authentication.class' entry in Openbravo.properties");
stefan@12524
    41
  authManager = new org.openbravo.authentication.basic.DefaultAuthenticationManager();
stefan@12524
    42
}
ivan@10243
    43
ivan@10243
    44
HttpBaseServlet s = new HttpBaseServlet(); // required for ConnectionProvider
ivan@10243
    45
s.init(getServletConfig());
ivan@10243
    46
s.initialize(request, response);
ivan@10243
    47
ivan@10243
    48
authManager.init(s);
ivan@10243
    49
ivan@10243
    50
String userId = authManager.authenticate(request, response);
ivan@10243
    51
if(userId == null){
ivan@10243
    52
  return;
ivan@10243
    53
}
david@11337
    54
david@11337
    55
String ua = request.getHeader( "User-Agent" );
david@11337
    56
boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
david@11337
    57
int verMSIE = 0;
david@11337
    58
String verMSIEtmp = "";
david@11337
    59
if (isMSIE) {
david@11337
    60
  verMSIEtmp = ua.substring(ua.indexOf("MSIE") + 5);
david@11337
    61
  verMSIEtmp = verMSIEtmp.substring(0, verMSIEtmp.indexOf("."));
david@11337
    62
  if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/4") != -1) {
david@11337
    63
    //In case IE8 runs in "IE8 Compatibility mode, look for Trident/4.0 to know that is IE8 although MSIE string is MSIE 7.0
david@11337
    64
    verMSIEtmp = "8";
david@11337
    65
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/5") != -1) {
david@11337
    66
    // In case IE9 runs in "IE8 Compatibility mode, look for Trident/5.0 to know that is IE9 although MSIE string is MSIE 7.0
david@11337
    67
    verMSIEtmp = "9";
david@11337
    68
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/") != -1) {
david@11337
    69
    // For hypothetic future IE versions in case IEX runs in "IEX Compatibility mode, look for Trident/ to know that is IEX although MSIE string is MSIE 7.0
david@11337
    70
    verMSIEtmp = "10"; //If this 'if' statement is not updated, could be 10 or 11 or anything... but set 10 just to ensure it is not in IE7
david@11337
    71
  }
david@11337
    72
  verMSIE = Integer.parseInt(verMSIEtmp);
david@11337
    73
}
ivan@10243
    74
%>
ivan@10243
    75
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
ivan@10243
    76
        "http://www.w3.org/TR/html4/loose.dtd">
ivan@10243
    77
ivan@10243
    78
<html>
david@10937
    79
<head>
martin@12425
    80
<meta http-equiv="X-UA-Compatible" content="IE=8">
ivan@10243
    81
<meta http-equiv="Expires" content="Tue, 24 Apr 1979 00:00:01 GMT"/>
ivan@10243
    82
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
ivan@10243
    83
<meta http-equiv="Pragma" content="no-cache" >
ivan@10243
    84
<meta name="author" content="Openbravo S.L.U.">
ivan@10243
    85
<meta name="keywords" content="openbravo">
ivan@10243
    86
<meta name="description" content="Openbravo S.L.U.">
ivan@10256
    87
<link rel="shortcut icon" href="./web/images/favicon.ico" />
david@11337
    88
<link rel="stylesheet" type="text/css" href="./org.openbravo.client.kernel/OBCLKER_Kernel/StyleSheetResources?_mode=3.00&_skinVersion=3.00&_cssDataUri=<%=(!isMSIE || (isMSIE && verMSIE >=8))%>"/>
david@11337
    89
ivan@10243
    90
<title>Openbravo</title>
ivan@10243
    91
<script type="text/javascript" src="./web/org.openbravo.client.kernel/js/LAB.min.js"></script>
david@11337
    92
ivan@10243
    93
<!-- styles used during loading -->
ivan@10243
    94
<style type="text/css">
ivan@10243
    95
  html, body {
ivan@10243
    96
      height: 100%;
ivan@10243
    97
      width: 100%;
ivan@10243
    98
  }
ivan@10243
    99
ivan@10243
   100
  .OBCenteredBox {
ivan@10243
   101
      position: fixed;
ivan@10243
   102
      z-index: 1000000;
ivan@10243
   103
      top: 50%;
ivan@10243
   104
      left: 50%;
ivan@10243
   105
      margin: -25px 0 0 -150px;
ivan@10243
   106
      width: 300px;
ivan@10243
   107
      height: 50px;
ivan@10243
   108
  }
ivan@10243
   109
ivan@10243
   110
  .OBLoadingPromptLabel {
ivan@10243
   111
      font-family: 'Arial';
ivan@10243
   112
      font-size: 12px;
ivan@10243
   113
      color: #ccd0d4;
ivan@10243
   114
  }
ivan@10243
   115
ivan@10243
   116
  .OBLoadingPromptModalMask {
ivan@10243
   117
      left: 0;
ivan@10243
   118
      top: 0;
ivan@10243
   119
      width: 100%;
ivan@10243
   120
      height: 100%;
ivan@10243
   121
      background-color: #7f7f7f;
ivan@10243
   122
  }
ivan@10243
   123
</style>
ivan@10243
   124
ivan@10243
   125
</head>
ivan@10243
   126
<body>
ivan@10243
   127
ivan@10243
   128
<!-- shows the loading div -->
ivan@10243
   129
<div class="OBLoadingPromptModalMask" id="OBLoadingDiv">
ivan@10243
   130
    <div class="OBCenteredBox">
ivan@10243
   131
        <table>
ivan@10243
   132
            <tr>
ivan@10243
   133
                <td>
ivan@10243
   134
                    <span class="OBLoadingPromptLabel">LOADING...</span>
ivan@10243
   135
                </td>
ivan@10243
   136
                <td>
ivan@10243
   137
                    <img width="220" height="16" src="./web/org.openbravo.userinterface.smartclient/openbravo/skins/3.00/org.openbravo.client.application/images/system/windowLoading.gif"/>
ivan@10243
   138
                </td>
ivan@10243
   139
            </tr>
ivan@10243
   140
        </table>
ivan@10243
   141
    </div>
ivan@10243
   142
</div>
ivan@10243
   143
<!-- load the rest -->
ivan@10243
   144
<script type="text/javascript">
ivan@10392
   145
$LAB.setGlobalDefaults({AppendTo: 'body'});
ivan@10243
   146
ivan@10243
   147
var isomorphicDir='./web/org.openbravo.userinterface.smartclient/isomorphic/';
ivan@10243
   148
ivan@10243
   149
// starts the application is called as the last statement in the StaticResources part
ivan@10243
   150
function OBStartApplication() {
ivan@10243
   151
  OB.Layout.draw();
ivan@10243
   152
  OB.Layout.ViewManager.createAddStartTab();
ivan@10243
   153
  // get rid of the loading stuff
ivan@10243
   154
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@10243
   155
  OB.GlobalHiddenForm = document.forms.OBGlobalHiddenForm;
ivan@10243
   156
}
ivan@10243
   157
</script>
ivan@10243
   158
<script type="text/javascript" src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined.js"></script>
ivan@10243
   159
<script type="text/javascript" src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_History.js"></script>
ivan@10243
   160
<script type="text/javascript" src="./org.openbravo.client.kernel/OBCLKER_Kernel/StaticResources?_mode=3.00&_skinVersion=3.00"></script>
ivan@11956
   161
<iframe name="background_target" id="background_target" height="0" width="0" style="display:none;"></iframe>
antonio@11954
   162
<form name="OBGlobalHiddenForm" method="post" action="blank.html" target="background_target">
antonio@11343
   163
</form>
ivan@10243
   164
</body>
ivan@10243
   165
</html>