Sfoglia il codice sorgente

Filtro su pannello di controllo

control-panel-filter
Gabriele Incoronato 3 settimane fa
parent
commit
333f2a1c19
  1. 27
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/.classpath
  2. 37
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/.project
  3. 6
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/build.xml
  4. 3
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/META-INF/MANIFEST.MF
  5. 1
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/.gitignore
  6. 16
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/liferay-hook.xml
  7. 13
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/liferay-plugin-package.properties
  8. 99
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/src/it/tref/liferay/portos/filter/PortosAccesFilter.java
  9. 3
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/web.xml
  10. 15
      liferay-plugins-sdk-6.2/hooks/portos-filter-hook/test/integration/arquillian.xml

27
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/.classpath

@ -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&amp;ivyXmlPath=ivy.xml&amp;confs=*&amp;ivySettingsPath=%24%7Bliferay_sdk_dir%3Aportos-filter-hook%7D%2Fivy-settings.xml&amp;loadSettingsOnDemand=false&amp;ivyUserDir=%24%7Bliferay_sdk_dir%3Aportos-filter-hook%7D%2F.ivy&amp;propertyFiles=">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="docroot/WEB-INF/classes"/>
</classpath>

37
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/.project

@ -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>

6
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/build.xml

@ -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>

3
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/META-INF/MANIFEST.MF

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

1
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/.gitignore vendored

@ -0,0 +1 @@
/classes/

16
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/liferay-hook.xml

@ -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>

13
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/liferay-plugin-package.properties

@ -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+

99
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/src/it/tref/liferay/portos/filter/PortosAccesFilter.java

@ -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()");
}
}

3
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/docroot/WEB-INF/web.xml

@ -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>

15
liferay-plugins-sdk-6.2/hooks/portos-filter-hook/test/integration/arquillian.xml

@ -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…
Annulla
Salva