Ejemplo n.º 1
0
  /**
   * This method verify the ticket.
   *
   * @param ticket String, ticket to validate
   * @param userId String, user id
   * @return String
   * @throws SecurityException the security exception
   */
  public void validateTicket(String ticket, String userId) throws SecurityException {
    logger.debug("IN");
    ConfigSingleton config = ConfigSingleton.getInstance();
    String validateUrl = null;
    String validateService = null;
    if (config != null) {
      // only server side...
      validateUrl = SingletonConfig.getInstance().getConfigValue("CAS_SSO.VALIDATE-USER.URL");
      logger.debug("Read validateUrl=" + validateUrl);
      validateService =
          SingletonConfig.getInstance().getConfigValue("CAS_SSO.VALIDATE-USER.SERVICE");
      logger.debug("Read validateService=" + validateService);
    }
    logger.debug("userId:" + userId);
    try {
      AttributePrincipal principal = null;
      Cas20ProxyTicketValidator sv = new Cas20ProxyTicketValidator(validateUrl);
      sv.setAcceptAnyProxy(true);

      Assertion a = sv.validate(ticket, validateService);
      principal = a.getPrincipal();
      logger.debug("Ticket is VALID, username="******"An exception occured while validating the cas token");
      throw new SecurityException("An exception occured while validating the cas token", e);
    } catch (Throwable e) {
      logger.error("An exception occured while validating the cas token");
      throw new SecurityException("An exception occured while validating the cas token", e);
    } finally {
      logger.debug("OUT");
    }
  }
Ejemplo n.º 2
0
  /**
   * Gets the map url.
   *
   * @param mapName the map name
   * @return the map url
   */
  public static String getMapUrl(String mapName) {
    if (mapName.equalsIgnoreCase("circoscrizioniBis")) mapName = "circoscrizioni";

    File file = new File(ConfigSingleton.getRootPath() + "/maps/genova/" + mapName + ".svg");
    try {
      return file.toURL().toString();
    } catch (MalformedURLException e) {
      e.printStackTrace();
      return null;
    }
  }
  /* (non-Javadoc)
   * @see junit.framework.TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();
    System.setProperty("AF_CONFIG_FILE", TestConstants.AF_CONFIG_FILE);
    ConfigSingleton.setConfigurationCreation(
        new FileCreatorConfiguration(TestConstants.WEBCONTENT_PATH));

    TenantManager.setTenant(new Tenant("SPAGOBI"));

    // Creating DataSources and DataSets
    this.createDataSources();
    this.createDatasets();
  }
Ejemplo n.º 4
0
  /**
   * Do start tag.
   *
   * @return the int
   * @throws JspException the jsp exception
   * @see it.eng.spagobi.commons.presentation.tags.CheckListTag#doStartTag()
   */
  public int doStartTag() throws JspException {
    SpagoBITracer.info("Admintools", "ListTag", "doStartTag", " method invoked");
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    renderResponse = (RenderResponse) httpRequest.getAttribute("javax.portlet.response");
    renderRequest = (RenderRequest) httpRequest.getAttribute("javax.portlet.request");

    _requestContainer = RequestContainerPortletAccess.getRequestContainer(httpRequest);
    portReq = PortletUtilities.getPortletRequest();
    _serviceRequest = _requestContainer.getServiceRequest();
    _responseContainer = ResponseContainerPortletAccess.getResponseContainer(httpRequest);

    msgBuilder = MessageBuilderFactory.getMessageBuilder();
    if (_bundle == null) _bundle = "messages";

    _session = _requestContainer.getSessionContainer();

    _serviceResponse = _responseContainer.getServiceResponse();
    ConfigSingleton configure = ConfigSingleton.getInstance();
    if (_actionName != null) {
      _serviceName = _actionName;
      _content = _serviceResponse;
      SourceBean actionBean =
          (SourceBean)
              configure.getFilteredSourceBeanAttribute("ACTIONS.ACTION", "NAME", _actionName);
      _layout = (SourceBean) actionBean.getAttribute("CONFIG");
      if (_layout == null) {
        // if the layout is dinamically created it is an attribute of the response
        _layout = (SourceBean) _serviceResponse.getAttribute("CONFIG");
      }
      _providerURL = "ACTION_NAME=" + _actionName + "&";
      _providerUrlMap.put("ACTION_NAME", _actionName);
      HashMap params = (HashMap) _serviceResponse.getAttribute("PARAMETERS_MAP");
      if (params != null) {
        _paramsMap = params;
        _providerUrlMap.putAll(_paramsMap);
      }
    } // if (_actionName != null)
    else if (_moduleName != null) {
      _serviceName = _moduleName;
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " Module Name: " + _moduleName);
      _content = (SourceBean) _serviceResponse.getAttribute(_moduleName);
      SourceBean moduleBean =
          (SourceBean)
              configure.getFilteredSourceBeanAttribute("MODULES.MODULE", "NAME", _moduleName);

      if (moduleBean != null)
        SpagoBITracer.debug(
            "Admintools", "ListTag", "doStartTag", _moduleName + " configuration loaded");
      _layout = (SourceBean) moduleBean.getAttribute("CONFIG");
      if (_layout == null) {
        // if the layout is dinamically created it is an attribute of the response
        _layout = (SourceBean) _serviceResponse.getAttribute(_moduleName + ".CONFIG");
      }
      String pageName = (String) _serviceRequest.getAttribute("PAGE");
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " PAGE: " + pageName);
      _providerURL = "PAGE=" + pageName + "&MODULE=" + _moduleName + "&";
      _providerUrlMap.put("PAGE", pageName);
      _providerUrlMap.put("MODULE", _moduleName);
      HashMap params = (HashMap) _serviceResponse.getAttribute(_moduleName + ".PARAMETERS_MAP");
      if (params != null) {
        _paramsMap = params;
        _providerUrlMap.putAll(_paramsMap);
      }
    } // if (_moduleName != null)
    else {
      SpagoBITracer.critical("Admintools", "ListTag", "doStartTag", "service name not specified");
      throw new JspException("Business name not specified !");
    } // if (_content == null)
    if (_content == null) {
      SpagoBITracer.warning("Admintools", "ListTag", "doStartTag", "list content null");
      return SKIP_BODY;
    } // if (_content == null)
    if (_layout == null) {
      SpagoBITracer.warning(
          "Admintools", "ListTag", "doStartTag", "list module configuration null");
      return SKIP_BODY;
    } // if (_layout == null)
    // if the LightNavigator is disabled entering the list, it is kept disabled untill exiting the
    // list
    Object lightNavigatorDisabledObj =
        _serviceRequest.getAttribute(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED);
    if (lightNavigatorDisabledObj != null) {
      String lightNavigatorDisabled = (String) lightNavigatorDisabledObj;
      _providerUrlMap.put(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED, lightNavigatorDisabled);
    }
    _htmlStream = new StringBuffer();

    PortletURL url = renderResponse.createActionURL();
    url.setParameter("PAGE", "DetailBIObjectPage");
    url.setParameter("MESSAGEDET", "RETURN_FROM_SUBREPORTS_LOOKUP");
    url.setParameter("LIGHT_NAVIGATOR_DISABLED", "true");

    _htmlStream.append(" <form method='POST' action='" + url.toString() + "'>\n");
    makeForm();
    _htmlStream.append(" </form>\n");
    try {
      pageContext.getOut().print(_htmlStream);
    } // try
    catch (Exception ex) {
      SpagoBITracer.critical(
          "Admintools", "ListTag", "doStartTag", "Impossible to send the stream");
      throw new JspException("Impossible to send the stream");
    } // catch (Exception ex)
    return SKIP_BODY;
  } // public int doStartTag() throws JspException