src/index.jsp
author RM packaging bot <staff.rm@openbravo.com>
Mon, 06 Nov 2017 09:49:46 +0000
changeset 32847 8c7325c13227
parent 32234 624c1fa5299c
child 33656 6d6a3a710fd2
permissions -rw-r--r--
Merge temporary head for 3.0PR17Q2.4
antonio@19365
     1
ivan@10243
     2
<%@ page import="java.util.Properties" %>
ivan@10243
     3
<%@ page import="org.openbravo.base.HttpBaseServlet" %>
martin@13190
     4
<%@ page import="org.openbravo.dal.core.OBContext"%>
ivan@10243
     5
<%@ page import="org.openbravo.base.util.OBClassLoader" %>
carlos@31981
     6
<%@ page import="org.openbravo.base.weld.WeldUtils"%>
ivan@10243
     7
<%@ page import="org.openbravo.authentication.AuthenticationManager" %>
david@16048
     8
<%@ page import="org.openbravo.client.kernel.KernelUtils" %>
ivan@16865
     9
<%@ page import="org.openbravo.client.kernel.KernelConstants" %>
carlos@32076
    10
<%@ page import="org.openbravo.client.kernel.StaticResourceProvider" %>
david@16048
    11
<%@ page import="org.openbravo.dal.core.OBContext" %>
david@16048
    12
<%@ page import="org.openbravo.model.ad.module.Module" %>
stefan@12524
    13
<%@ page import="org.apache.log4j.Logger" %>
antonio@19365
    14
<%@ page import="org.openbravo.model.ad.access.Role" %>
antonio@19368
    15
<%@ page import="org.openbravo.model.ad.access.User" %>
antonio@19365
    16
<%@ page import="org.openbravo.dal.service.OBDal" %>
antonio@19365
    17
<%@ page import="org.openbravo.base.secureApp.VariablesSecureApp" %>
asier@29443
    18
<%@ page import="org.openbravo.erpCommon.obps.ActivationKey" %>
asier@29444
    19
<%@ page import="org.openbravo.base.secureApp.LoginHandler" %>
asier@29445
    20
<%@ page import="org.openbravo.base.HttpBaseUtils" %>
asier@29445
    21
<%@ page import="org.openbravo.erpCommon.utility.OBMessageUtils" %>
asier@29445
    22
<%@ page import="org.openbravo.erpCommon.utility.OBError" %>
asier@29445
    23
<%@ page import="java.util.Date" %>
asier@29445
    24
<%@ page import="org.openbravo.erpCommon.obps.ActivationKey.LicenseRestriction" %>
carlos@31981
    25
<%@ page import="org.openbravo.client.application.window.ApplicationDictionaryCachedStructures"%>
ivan@10243
    26
<%@ page contentType="text/html; charset=UTF-8" %>
asier@32234
    27
<%@ page session="false" %>
ivan@10243
    28
<%
ivan@13719
    29
  /*
ivan@10243
    30
 *************************************************************************
ivan@10243
    31
 * The contents of this file are subject to the Openbravo  Public  License
ivan@10243
    32
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
ivan@10243
    33
 * Version 1.1  with a permitted attribution clause; you may not  use this
ivan@10243
    34
 * file except in compliance with the License. You  may  obtain  a copy of
ivan@10243
    35
 * the License at http://www.openbravo.com/legal/license.html 
ivan@10243
    36
 * Software distributed under the License  is  distributed  on  an "AS IS"
ivan@10243
    37
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
ivan@10243
    38
 * License for the specific  language  governing  rights  and  limitations
ivan@10243
    39
 * under the License. 
ivan@10243
    40
 * The Original Code is Openbravo ERP. 
ivan@10243
    41
 * The Initial Developer of the Original Code is Openbravo SLU 
carlos@31981
    42
 * All portions are Copyright (C) 2011-2017 Openbravo SLU
ivan@10243
    43
 * All Rights Reserved. 
martin@15614
    44
 * Contributor(s):  ______________________________________.
ivan@10243
    45
 ************************************************************************
ivan@10243
    46
 */
stefan@12524
    47
stefan@12524
    48
Logger log = Logger.getLogger(org.openbravo.authentication.AuthenticationManager.class); 
ivan@10243
    49
asier@32234
    50
HttpSession currentSession = request.getSession(false);
asier@32234
    51
ivan@16797
    52
AuthenticationManager authManager = AuthenticationManager.getAuthenticationManager(this);
asier@32234
    53
if (currentSession == null) {
asier@32234
    54
  response.sendRedirect(authManager.getLoginURL(request));
asier@32234
    55
  return;
asier@32234
    56
}
ivan@10243
    57
ivan@10243
    58
String userId = authManager.authenticate(request, response);
ivan@16797
    59
asier@32234
    60
if (userId == null) {
ivan@10243
    61
  return;
ivan@10243
    62
}
david@11337
    63
asier@29443
    64
OBContext.setAdminMode(false);
asier@29443
    65
String sessionId = null;
asier@29443
    66
try {
asier@32234
    67
  sessionId = (String) currentSession.getAttribute("#AD_SESSION_ID");
asier@32234
    68
  if (sessionId != null && !"".equals(sessionId) && !"Y".equals(currentSession.getAttribute("forceLogin"))) {
asier@29443
    69
    org.openbravo.model.ad.access.Session dbSession = OBDal.getInstance().get(org.openbravo.model.ad.access.Session.class, sessionId);
asier@29443
    70
    String currentSessionType = dbSession.getLoginStatus();
asier@29443
    71
asier@29443
    72
    if (!ActivationKey.consumesConcurrentUser(currentSessionType)) {
asier@29445
    73
      // session was created not counting concurrent users, now switching to backend so they
asier@29445
    74
      // should be counted
asier@29444
    75
      dbSession.setLoginStatus(LoginHandler.SUCCESS_SESSION_STANDARD);
asier@29443
    76
      OBDal.getInstance().flush();
asier@29445
    77
asier@29445
    78
      if (ActivationKey.getInstance().checkOPSLimitations(sessionId) == LicenseRestriction.NUMBER_OF_CONCURRENT_USERS_REACHED) {
asier@29445
    79
        dbSession.setSessionActive(false);
asier@29445
    80
        OBDal.getInstance().flush();
asier@29445
    81
asier@29445
    82
        OBError errMsg = new OBError();
asier@29445
    83
        errMsg.setTitle(OBMessageUtils.messageBD("NUMBER_OF_CONCURRENT_USERS_REACHED_TITLE", false, true));
asier@29445
    84
        errMsg.setMessage(OBMessageUtils.messageBD("NUMBER_OF_CONCURRENT_USERS_REACHED", false, true));
asier@32234
    85
        currentSession.setAttribute("LOGINERRORMSG", errMsg);
asier@29445
    86
asier@29455
    87
        response.sendRedirect(authManager.getLoginURL(request));
asier@29445
    88
        return;
asier@29445
    89
      }
asier@29443
    90
    }
asier@29443
    91
  }
asier@29443
    92
} catch (Exception e) {
asier@29443
    93
  log.error("Error resetting login status for session "  + sessionId,e);
asier@29443
    94
} finally {
asier@29443
    95
  OBContext.restorePreviousMode();
asier@29443
    96
}
asier@29443
    97
asier@29443
    98
david@16048
    99
boolean uncompSC = false;
david@16052
   100
String scDevModulePackage = "org.openbravo.userinterface.smartclient.dev";
david@16048
   101
OBContext.setAdminMode();
david@16048
   102
try {
david@16048
   103
  if (KernelUtils.getInstance().isModulePresent(scDevModulePackage)) {
david@16048
   104
    uncompSC = KernelUtils.getInstance().getModule(scDevModulePackage).isInDevelopment();
david@16048
   105
  }
david@16048
   106
} catch (Exception e) {
david@16052
   107
  log.error("Error trying to acquire module \"" + scDevModulePackage + "\": " + e.getMessage(), e);
david@16048
   108
} finally {
david@16048
   109
  OBContext.restorePreviousMode();
david@16048
   110
}
david@16048
   111
david@11337
   112
String ua = request.getHeader( "User-Agent" );
david@11337
   113
boolean isMSIE = ( ua != null && ua.indexOf( "MSIE" ) != -1 );
david@11337
   114
int verMSIE = 0;
david@11337
   115
String verMSIEtmp = "";
david@11337
   116
if (isMSIE) {
david@11337
   117
  verMSIEtmp = ua.substring(ua.indexOf("MSIE") + 5);
david@11337
   118
  verMSIEtmp = verMSIEtmp.substring(0, verMSIEtmp.indexOf("."));
david@11337
   119
  if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/4") != -1) {
david@11337
   120
    //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
   121
    verMSIEtmp = "8";
david@11337
   122
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/5") != -1) {
david@11337
   123
    // 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
   124
    verMSIEtmp = "9";
david@11337
   125
  } else if (ua.indexOf("MSIE 7.0") != -1 && ua.indexOf("Trident/") != -1) {
david@11337
   126
    // 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
   127
    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
   128
  }
david@11337
   129
  verMSIE = Integer.parseInt(verMSIEtmp);
david@11337
   130
}
martin@15540
   131
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
martin@15540
   132
response.addHeader("Pragma", "no-cache");
martin@15540
   133
response.addHeader("Expires", "0");
ivan@10243
   134
%>
david@16334
   135
<!DOCTYPE html>
ivan@10243
   136
david@16384
   137
<html dir="<%=(OBContext.isRightToLeft() ? "RTL" : "LTR")%>">
david@10938
   138
<head>
ivan@10243
   139
<meta http-equiv="Expires" content="Tue, 24 Apr 1979 00:00:01 GMT"/>
ivan@10243
   140
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
martin@15539
   141
<meta http-equiv="Cache-Control" content="no-cache no-store must-revalidate" >
ivan@10243
   142
<meta http-equiv="Pragma" content="no-cache" >
david@26257
   143
<meta http-equiv="X-UA-Compatible" content="IE=edge">
ivan@10243
   144
<meta name="author" content="Openbravo S.L.U.">
ivan@10243
   145
<meta name="keywords" content="openbravo">
ivan@10243
   146
<meta name="description" content="Openbravo S.L.U.">
ivan@10257
   147
<link rel="shortcut icon" href="./web/images/favicon.ico" />
ivan@16865
   148
<link rel="stylesheet" type="text/css" href="./org.openbravo.client.kernel/OBCLKER_Kernel/StyleSheetResources?_appName=OB3&_skinVersion=Default&_cssDataUri=<%=(!isMSIE || (isMSIE && verMSIE >=8))%>"/>
david@11337
   149
ivan@10243
   150
<title>Openbravo</title>
carlos@31981
   151
<%
carlos@31981
   152
  ApplicationDictionaryCachedStructures adcs = WeldUtils.getInstanceFromStaticBeanManager(ApplicationDictionaryCachedStructures.class);
carlos@31981
   153
  if (!adcs.useCache()) {
carlos@31981
   154
%>
ivan@16479
   155
<script src="./web/org.openbravo.client.kernel/js/scopeleaks.min.js"></script>
carlos@31981
   156
<%
carlos@31981
   157
  }
carlos@31981
   158
%>
ivan@16479
   159
<script src="./web/org.openbravo.client.kernel/js/LAB.min.js"></script>
ivan@16479
   160
<script src="./web/org.openbravo.client.kernel/js/BigDecimal-all-1.0.1.min.js"></script>
david@11337
   161
david@23075
   162
<script>
david@23075
   163
  (function () {
david@23075
   164
    var b = document.documentElement;
david@23075
   165
    b.setAttribute('data-useragent',  navigator.userAgent);
david@23075
   166
    b.setAttribute('data-platform', navigator.platform );
david@23075
   167
    b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
david@23075
   168
  }());
david@23075
   169
</script>
david@23075
   170
ivan@10243
   171
<!-- styles used during loading -->
ivan@16479
   172
<style>
ivan@10243
   173
  html, body {
ivan@10243
   174
      height: 100%;
ivan@10243
   175
      width: 100%;
ivan@10243
   176
  }
ivan@10243
   177
ivan@10243
   178
  .OBCenteredBox {
ivan@10243
   179
      position: fixed;
ivan@10243
   180
      z-index: 1000000;
ivan@10243
   181
      top: 50%;
ivan@10243
   182
      left: 50%;
ivan@10243
   183
      margin: -25px 0 0 -150px;
ivan@10243
   184
      width: 300px;
ivan@10243
   185
      height: 50px;
ivan@10243
   186
  }
ivan@10243
   187
ivan@10243
   188
  .OBLoadingPromptLabel {
ivan@10243
   189
      font-family: 'Arial';
ivan@10243
   190
      font-size: 12px;
ivan@10243
   191
      color: #ccd0d4;
ivan@10243
   192
  }
ivan@10243
   193
ivan@10243
   194
  .OBLoadingPromptModalMask {
ivan@10243
   195
      left: 0;
ivan@10243
   196
      top: 0;
ivan@10243
   197
      width: 100%;
ivan@10243
   198
      height: 100%;
ivan@10243
   199
      background-color: #7f7f7f;
ivan@10243
   200
  }
ivan@10243
   201
</style>
ivan@10243
   202
ivan@10243
   203
</head>
david@16384
   204
<body>
ivan@10243
   205
ivan@10243
   206
<!-- shows the loading div -->
ivan@10243
   207
<div class="OBLoadingPromptModalMask" id="OBLoadingDiv">
ivan@10243
   208
    <div class="OBCenteredBox">
ivan@10243
   209
        <table>
ivan@10243
   210
            <tr>
ivan@10243
   211
                <td>
ivan@10243
   212
                    <span class="OBLoadingPromptLabel">LOADING...</span>
ivan@10243
   213
                </td>
ivan@10243
   214
                <td>
martin@12927
   215
                    <img width="220" height="16" src="./web/org.openbravo.userinterface.smartclient/openbravo/skins/Default/org.openbravo.client.application/images/system/windowLoading.gif"/>
ivan@10243
   216
                </td>
ivan@10243
   217
            </tr>
ivan@10243
   218
        </table>
ivan@10243
   219
    </div>
ivan@10243
   220
</div>
ivan@10243
   221
<!-- load the rest -->
ivan@16479
   222
<script>
ivan@16865
   223
// Bootstrap error handling: Shows an alert to the user when an error occurs loading static resources
ivan@16865
   224
// This error handler gets removed at the end of static resources
ivan@16865
   225
window.onerror = function <%=KernelConstants.BOOTSTRAP_ERROR_HANDLER_NAME%> (errorMsg, url, lineNumber) {
ivan@16865
   226
  var msg = errorMsg + ' - ' + url + ':' + lineNumber;
ivan@16865
   227
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@16865
   228
  alert(msg);
ivan@16865
   229
};
ivan@16865
   230
martin@15593
   231
$LAB.setGlobalDefaults({AppendTo: 'body'});
martin@15593
   232
ivan@10243
   233
var isomorphicDir='./web/org.openbravo.userinterface.smartclient/isomorphic/';
david@21907
   234
var isc = window.isc ? window.isc : {};
ivan@10243
   235
ivan@10243
   236
// starts the application is called as the last statement in the StaticResources part
ivan@15690
   237
function OBStartApplication() {
antonio@19365
   238
<%
antonio@19365
   239
//If the role has its access to the backend restricted, an error message will be shown
antonio@19365
   240
final VariablesSecureApp vars1 = new VariablesSecureApp(request, false);
antonio@19368
   241
OBContext.setAdminMode();
antonio@19368
   242
try{
antonio@19368
   243
  String roleId=vars1.getRole();
antonio@19368
   244
  Role role;
antonio@19368
   245
  if(roleId==null || roleId.equals("")){
antonio@19368
   246
    role=OBDal.getInstance().get(User.class, userId).getDefaultRole();
antonio@19368
   247
  }else{
antonio@19368
   248
    role = OBDal.getInstance().get(Role.class, vars1.getRole());
antonio@19368
   249
  }
antonio@20499
   250
if(role !=null && role.isRestrictbackend()){
antonio@19365
   251
%>
antonio@19365
   252
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
antonio@19365
   253
  isc.Dialog.create({message: OB.I18N.getLabel('OBUIAPP_RestrictedUser'), title: OB.I18N.getLabel('OBUIAPP_RestrictedUserTitle'), showCloseButton: false}).show();
antonio@19365
   254
  return;
antonio@19365
   255
<%
antonio@19365
   256
}
augusto@29326
   257
boolean onlySystemAdminAccess = "Y".equals(vars1.getSessionValue("onlySystemAdminRoleShouldBeAvailableInErp"));
augusto@29326
   258
if (onlySystemAdminAccess && role != null && !"0".equals(role.getId())) {
augusto@29326
   259
  %>
augusto@29326
   260
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
augusto@29326
   261
  isc.Dialog.create({message: OB.I18N.getLabel('BACKEND_LOGIN_RESTRICTED'), title: OB.I18N.getLabel('BACKEND_LOGIN_RESTRICTED_TITLE'), showCloseButton: false}).show();
augusto@29326
   262
  return;
augusto@29326
   263
<%  
augusto@29326
   264
}
antonio@19368
   265
 }finally{
antonio@19368
   266
  OBContext.restorePreviousMode();
antonio@19368
   267
}
antonio@19365
   268
%>
martin@12948
   269
  OB.Layout.initialize();
ivan@10243
   270
  OB.Layout.draw();
ivan@10243
   271
  OB.Layout.ViewManager.createAddStartTab();
ivan@10243
   272
  // get rid of the loading stuff
ivan@10243
   273
  document.body.removeChild(document.getElementById('OBLoadingDiv'));
ivan@10243
   274
  OB.GlobalHiddenForm = document.forms.OBGlobalHiddenForm;
ivan@13342
   275
<%
asier@32234
   276
  if (currentSession.getAttribute("STARTUP-MESSAGE") != null) {
asier@32234
   277
    String text = (String) currentSession.getAttribute("STARTUP-MESSAGE");
asier@32234
   278
    String title = (String) currentSession.getAttribute("STARTUP-MESSAGE-TITLE");
asier@32234
   279
    currentSession.removeAttribute("STARTUP-MESSAGE");
asier@32234
   280
    currentSession.removeAttribute("STARTUP-MESSAGE-TITLE");
ivan@13342
   281
%>
ivan@13342
   282
  isc.say('<%=text%>', null, {title: '<%=title%>'});
ivan@13342
   283
<%
ivan@13342
   284
  }
ivan@13342
   285
%>
ivan@10243
   286
}
ivan@10243
   287
</script>
ivan@16479
   288
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
ivan@16479
   289
<script src="./web/org.openbravo.userinterface.smartclient/isomorphic/ISC_History<%=(uncompSC ? ".uncompressed" : "")%>.js"></script>
carlos@32071
   290
<%
carlos@32076
   291
  StaticResourceProvider resourceProvider = WeldUtils.getInstanceFromStaticBeanManager(StaticResourceProvider.class);
carlos@32086
   292
  final String staticResourceFileName = resourceProvider.getStaticResourceCachedFileName("OB3");
carlos@32079
   293
  if (staticResourceFileName != null) {
carlos@32071
   294
%>
carlos@32081
   295
<script src="./web/js/gen/<%=staticResourceFileName%>.js"></script>
carlos@32071
   296
<%
carlos@32071
   297
  } else {
carlos@32071
   298
%>
ivan@16865
   299
<script src="./org.openbravo.client.kernel/OBCLKER_Kernel/StaticResources?_appName=OB3&_skinVersion=Default"></script>
carlos@32071
   300
<%
carlos@32071
   301
  }
carlos@32071
   302
%>
naroa@27877
   303
<iframe name="background_target" id="background_target" height="0" width="0"></iframe>
antonio@11954
   304
<form name="OBGlobalHiddenForm" method="post" action="blank.html" target="background_target">
antonio@11344
   305
</form>
ivan@10243
   306
</body>
ivan@14579
   307
</html>