Package com.googlecode.s2hibernate.struts2.plugin.util

Examples of com.googlecode.s2hibernate.struts2.plugin.util.HibernateConfiguration


  @Override
  public String intercept(ActionInvocation invocation) throws Exception {
    createTempJSPFile(invocation);
   
    String errormessage = null;
    HibernateManagementAction action = ((HibernateManagementAction)invocation.getAction());
    if (publicAccessEnabled) {
      action.setPublicAccessEnabled(true);
      return invocation.invoke();
    }
    else if ((httpAuthRoles!=null) || (validIpsHosts!=null)) {
      if (httpAuthRoles!=null) {
        HttpServletRequest request = ServletActionContext.getRequest();
        String roles[] = httpAuthRoles.split(",");
        Boolean isValidUser = false;
        for (String role : roles) {
          if (request.isUserInRole(role)) {
            isValidUser = true;
            break;
          }
        }
        if (!isValidUser)
          errormessage = action.getText("hibernateplugin.httpauth_error");
      }
      if (validIpsHosts!=null) {
        String userIp = ServletActionContext.getRequest().getRemoteAddr();
        if (ServletActionContext.getRequest().getHeader("X-Forwarded-For")!=null)
          userIp = ServletActionContext.getRequest().getHeader("X-Forwarded-For");
        String userHost = ServletActionContext.getRequest().getRemoteHost();
        if (userHost.equals(userIp))
          userHost = InetAddress.getByAddress(new byte[]{127,0,0,1}).getHostName();
        String ipshosts[] = validIpsHosts.split(",");
        Boolean isValidIp = ArrayUtils.contains(ipshosts, userIp);
        Boolean isValidHost = ArrayUtils.contains(ipshosts, userHost);
        if ( (!isValidIp) && (!isValidHost) )
          errormessage = action.getText("hibernateplugin.iphost_error");
      }
    }
    else {
      errormessage = action.getText("hibernateplugin.public_access_disabled");
    }
   
    if (errormessage!=null) {
      throw new SecurityException(errormessage);
    } else {
View Full Code Here


    if (validator!=null)
      return validator;
   
    try {
      Class.forName("org.hibernate.validator.InvalidValue");
      validator = new Struts2HibernateValidatorV310();
      log.info("Full Hibernate Plugin Validation using Hibernate Validator 3.x");
      return validator;
    } catch (ClassNotFoundException e) {
      log.info("Full Hibernate Plugin Validation could not detect Hibernate Validator 3.x");
    }
View Full Code Here

    } catch (ClassNotFoundException e) {
      log.info("Full Hibernate Plugin Validation could not detect Hibernate Validator 3.x");
    }
    try {
      Class.forName("org.hibernate.validator.HibernateValidator");
      validator = new Struts2HibernateValidatorV402();
      log.info("Full Hibernate Plugin Validation using Hibernate Validator 4.x");
      return validator;
    } catch (ClassNotFoundException e) {
      log.info("Full Hibernate Plugin Validation could not detect Hibernate Validator 4.x");
    }
View Full Code Here

        Properties properties = new Properties();
        for (Object key:propertiesAll.keySet()) {
          if (key.toString().startsWith("hibernate"))
            properties.put(key, propertiesAll.get(key));
        }
        HibernateConfiguration hConfiguration = new HibernateConfiguration(file,properties);
        configurations.add(hConfiguration);
      }
    } catch (Exception e) {
      addActionError(e.getMessage());
    }
View Full Code Here

    } else {
      //TODO: verificar se o Hibernate Manager est� Habilitado antes de por as sess�es no contexto de aplica��o para economizar mem�ria!
      Set<SessionInfo> hibernateSessions = (Set<SessionInfo>) ActionContext.getContext().getApplication().get("struts2HibernatePlugin_Sessions");
      if (hibernateSessions==null)
        hibernateSessions = new LinkedHashSet<SessionInfo>();
      SessionInfo info = new SessionInfo(hibernateSession,new Date(),request.getSession());
      hibernateSessions.add(info);
      ActionContext.getContext().getApplication().put("struts2HibernatePlugin_Sessions", hibernateSessions);
    }   
  }
View Full Code Here

TOP

Related Classes of com.googlecode.s2hibernate.struts2.plugin.util.HibernateConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.