Gabriele Incoronato
3 settimane fa
10 ha cambiato i file con 220 aggiunte e 0 eliminazioni
@ -0,0 +1,27 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<classpath> |
||||||
|
<classpathentry kind="src" path="docroot/WEB-INF/src"/> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.7.0_231"> |
||||||
|
<attributes> |
||||||
|
<attribute name="owner.project.facets" value="java"/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.liferay.ide.eclipse.server.tomcat.runtimeClasspathProvider/Liferay v6.2 CE (Tomcat 7)"> |
||||||
|
<attributes> |
||||||
|
<attribute name="owner.project.facets" value="jst.web"/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> |
||||||
|
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> |
||||||
|
<classpathentry kind="con" path="com.liferay.ide.eclipse.server.plugin.container/hook"> |
||||||
|
<attributes> |
||||||
|
<attribute name="org.eclipse.jst.component.nondependency" value=""/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="con" path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=portos-filter-hook&ivyXmlPath=ivy.xml&confs=*&ivySettingsPath=%24%7Bliferay_sdk_dir%3Aportos-filter-hook%7D%2Fivy-settings.xml&loadSettingsOnDemand=false&ivyUserDir=%24%7Bliferay_sdk_dir%3Aportos-filter-hook%7D%2F.ivy&propertyFiles="> |
||||||
|
<attributes> |
||||||
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> |
||||||
|
</attributes> |
||||||
|
</classpathentry> |
||||||
|
<classpathentry kind="output" path="docroot/WEB-INF/classes"/> |
||||||
|
</classpath> |
@ -0,0 +1,37 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<projectDescription> |
||||||
|
<name>portos-filter-hook</name> |
||||||
|
<comment></comment> |
||||||
|
<projects> |
||||||
|
</projects> |
||||||
|
<buildSpec> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
<buildCommand> |
||||||
|
<name>org.eclipse.wst.validation.validationbuilder</name> |
||||||
|
<arguments> |
||||||
|
</arguments> |
||||||
|
</buildCommand> |
||||||
|
</buildSpec> |
||||||
|
<natures> |
||||||
|
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> |
||||||
|
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> |
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> |
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature> |
||||||
|
<nature>org.apache.ivyde.eclipse.ivynature</nature> |
||||||
|
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> |
||||||
|
</natures> |
||||||
|
</projectDescription> |
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0"?> |
||||||
|
<!DOCTYPE project> |
||||||
|
|
||||||
|
<project name="portos-filter-hook" basedir="." default="deploy"> |
||||||
|
<import file="../build-common-hook.xml" /> |
||||||
|
</project> |
@ -0,0 +1,3 @@ |
|||||||
|
Manifest-Version: 1.0 |
||||||
|
Class-Path: |
||||||
|
|
@ -0,0 +1 @@ |
|||||||
|
/classes/ |
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0"?> |
||||||
|
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd"> |
||||||
|
|
||||||
|
|
||||||
|
<hook> |
||||||
|
<servlet-filter> |
||||||
|
<servlet-filter-name>Sample Filter</servlet-filter-name> |
||||||
|
<servlet-filter-impl>it.tref.liferay.portos.filter.PortosAccesFilter</servlet-filter-impl> |
||||||
|
</servlet-filter> |
||||||
|
<servlet-filter-mapping> |
||||||
|
<servlet-filter-name>Sample Filter</servlet-filter-name> |
||||||
|
<url-pattern>/group/control_panel/*</url-pattern> |
||||||
|
<dispatcher>REQUEST</dispatcher> |
||||||
|
<dispatcher>FORWARD</dispatcher> |
||||||
|
</servlet-filter-mapping> |
||||||
|
</hook> |
@ -0,0 +1,13 @@ |
|||||||
|
name=Portos Filter |
||||||
|
module-group-id=liferay |
||||||
|
module-incremental-version=1 |
||||||
|
module-version=6.2.0.5 |
||||||
|
tags= |
||||||
|
short-description= |
||||||
|
long-description= |
||||||
|
change-log= |
||||||
|
page-url=http://www.liferay.com |
||||||
|
author=Liferay, Inc. |
||||||
|
licenses=LGPL |
||||||
|
liferay-versions=6.2.0+ |
||||||
|
liferay-version=6.2.0+ |
@ -0,0 +1,99 @@ |
|||||||
|
package it.tref.liferay.portos.filter; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.log.Log; |
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.util.StringUtil; |
||||||
|
import com.liferay.portal.kernel.util.WebKeys; |
||||||
|
import com.liferay.portal.model.Company; |
||||||
|
import com.liferay.portal.model.Role; |
||||||
|
import com.liferay.portal.model.User; |
||||||
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
||||||
|
import com.liferay.portal.util.PortalUtil; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import javax.servlet.Filter; |
||||||
|
import javax.servlet.FilterChain; |
||||||
|
import javax.servlet.FilterConfig; |
||||||
|
import javax.servlet.ServletException; |
||||||
|
import javax.servlet.ServletRequest; |
||||||
|
import javax.servlet.ServletResponse; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
public class PortosAccesFilter implements Filter { |
||||||
|
final static Log _log = LogFactoryUtil.getLog(PortosAccesFilter.class.getName()); |
||||||
|
|
||||||
|
@Override |
||||||
|
public void destroy() { |
||||||
|
_log.debug("Called destroy()"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, |
||||||
|
FilterChain filterChain) throws IOException, ServletException { |
||||||
|
HttpServletRequest httpReq = (HttpServletRequest) servletRequest; |
||||||
|
_log.debug("httpReq.getRequestURI()=" + httpReq.getRequestURI()); |
||||||
|
_log.debug("httpReq.getRequestURL()=" + httpReq.getRequestURL()); |
||||||
|
|
||||||
|
String uri = (String) servletRequest.getAttribute(WebKeys.INVOKER_FILTER_URI); |
||||||
|
|
||||||
|
_log.debug("Called SampleFilter.doFilter(" + servletRequest + ", " + servletResponse + ", " + filterChain |
||||||
|
+ ") for URI " + uri); |
||||||
|
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; |
||||||
|
boolean permesso = false; |
||||||
|
boolean permessoRuoli = false; |
||||||
|
try { |
||||||
|
User user = PortalUtil.getUser(httpServletRequest); |
||||||
|
|
||||||
|
if (user != null) { |
||||||
|
List<Role> userRoles = RoleLocalServiceUtil.getUserRoles(user.getUserId()); |
||||||
|
for (int i = 0; i < userRoles.size(); i++) { |
||||||
|
if("Admin publication".equals((userRoles.get(i)).getName())){ |
||||||
|
permessoRuoli=true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if ((user == null || (user.isDefaultUser() && !permessoRuoli))) { |
||||||
|
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; |
||||||
|
httpServletResponse.setStatus(403); |
||||||
|
_log.debug("Guest non permesso"); |
||||||
|
return; |
||||||
|
} |
||||||
|
if(httpServletRequest.getParameterMap().containsKey("p_p_id")&& |
||||||
|
!httpServletRequest.getParameterMap().get("p_p_id")[0].isEmpty()&& |
||||||
|
("158".equals( httpServletRequest.getParameterMap().get("p_p_id")[0]))){ |
||||||
|
|
||||||
|
if (user != null && PortalUtil.isCompanyAdmin(user) || permessoRuoli) { |
||||||
|
permesso = true; |
||||||
|
_log.debug("Admin passa il controllo :" + user.getFullName()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
if (!permesso) { |
||||||
|
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; |
||||||
|
//RequestLogUtil.createOrUpdateLog(httpReq);
|
||||||
|
httpServletResponse.setStatus(403); |
||||||
|
} else { |
||||||
|
filterChain.doFilter(servletRequest, servletResponse); |
||||||
|
} |
||||||
|
}else { |
||||||
|
filterChain.doFilter(servletRequest, servletResponse); |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
_log.error(e, e); |
||||||
|
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse; |
||||||
|
if (httpServletResponse.getStatus() != 403) { |
||||||
|
filterChain.doFilter(servletRequest, servletResponse); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void init(FilterConfig filterConfig) { |
||||||
|
_log.debug("Called FIXPermissionFilter.init()"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> |
||||||
|
</web-app> |
@ -0,0 +1,15 @@ |
|||||||
|
<?xml version="1.0"?> |
||||||
|
|
||||||
|
<arquillian |
||||||
|
xmlns="http://jboss.org/schema/arquillian" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd" |
||||||
|
> |
||||||
|
<container default="true" qualifier="tomcat"> |
||||||
|
<configuration> |
||||||
|
<property name="jmxPort">8099</property> |
||||||
|
<property name="pass">tomcat</property> |
||||||
|
<property name="user">tomcat</property> |
||||||
|
</configuration> |
||||||
|
</container> |
||||||
|
</arquillian> |
Caricamento…
Reference in new issue