<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core'%> <%@ page language="java" import="org.springframework.security.ui.AbstractProcessingFilter,org.springframework.security.ui.webapp.AuthenticationProcessingFilter,org.springframework.security.ui.savedrequest.SavedRequest,org.springframework.security.AuthenticationException,org.pentaho.platform.uifoundation.component.HtmlComponent,org.pentaho.platform.engine.core.system.PentahoSystem,org.pentaho.platform.util.messages.LocaleHelper,org.pentaho.platform.api.engine.IPentahoSession,org.pentaho.platform.web.http.WebTemplateHelper,org.pentaho.platform.api.engine.IUITemplater,org.pentaho.platform.web.jsp.messages.Messages,java.util.List,java.util.ArrayList,java.util.StringTokenizer,org.apache.commons.lang.StringEscapeUtils,org.pentaho.platform.web.http.PentahoHttpSessionHelper"%> <%!// List of request URL strings to look for to send 401 private List send401RequestList; public void jspInit() { // super.jspInit(); send401RequestList = new ArrayList(); String unauthList = getServletConfig().getInitParameter("send401List"); //$NON-NLS-1$ if (unauthList == null) { send401RequestList.add("AdhocWebService"); //$NON-NLS-1$ } else { StringTokenizer st = new StringTokenizer(unauthList, ","); //$NON-NLS-1$ String requestStr; while (st.hasMoreElements()) { requestStr = st.nextToken(); send401RequestList.add(requestStr.trim()); } } }%> <% response.setCharacterEncoding(LocaleHelper.getSystemEncoding()); String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl(); String path = request.getContextPath(); IPentahoSession userSession = PentahoHttpSessionHelper .getPentahoSession(request); // SPRING_SECURITY_SAVED_REQUEST_KEY contains the URL the user originally wanted before being redirected to the login page // if the requested url is in the list of URLs specified in the web.xml's init-param send401List, // then return a 401 status now and don't show a login page (401 means not authenticated) Object reqObj = request.getSession().getAttribute(AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY); String requestedURL = ""; if (reqObj != null) { requestedURL = ((SavedRequest) reqObj).getFullRequestUrl(); String lookFor; for (int i = 0; i < send401RequestList.size(); i++) { lookFor = send401RequestList.get(i); if (requestedURL.indexOf(lookFor) >= 0) { response.sendError(401); return; } } } boolean loggedIn; String remoteUser = request.getRemoteUser(); if (remoteUser != null && remoteUser != "") { loggedIn = true; } %> Proyecto EnoBI - Login <%!// reads the exception stored by AbstractProcessingFilter private String getUserMessage(final AuthenticationException e) { String userMessage = Messages .getString("UI.USER_LOGIN_FAILED_DEFAULT_REASON"); if (null != e) { String errorClassName = e.getClass().getName(); errorClassName = errorClassName.replace('.', '_'); errorClassName = errorClassName.toUpperCase(); String key = "UI.USER_LOGIN_FAILED_REASON_" + errorClassName; String tmp = Messages.getString(key); if (null != tmp && 0 != tmp.length() && !tmp.startsWith("!")) { userMessage = tmp; } } return userMessage; }%>