AutorizzazioneHttpServletRequest.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.pdd.core.autorizzazione.container;

  21. import java.security.Principal;

  22. import javax.servlet.http.HttpServletRequest;

  23. import org.openspcoop2.utils.UtilsException;
  24. import org.openspcoop2.utils.transport.http.WrappedHttpServletRequest;
  25. import org.openspcoop2.utils.xacml.XacmlRequest;


  26. /**
  27.  * AutorizzazioneHttpServletRequest
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class AutorizzazioneHttpServletRequest extends WrappedHttpServletRequest {


  34.     private IAutorizzazioneSecurityContainer authEngine;
  35.    
  36.     public AutorizzazioneHttpServletRequest(HttpServletRequest httpServletRequest, IAutorizzazioneSecurityContainer authEngine) throws UtilsException{
  37.         super(httpServletRequest);
  38.        
  39.         this.authEngine = authEngine;
  40.     }
  41.    
  42.     @Override
  43.     public Principal getUserPrincipal() {
  44.         String p = this.authEngine.getUserPrincipal();
  45.         if(p!=null) {
  46.             return new AutorizzazioneSecurityContainerPrincipal(p);
  47.         }
  48.         return null;
  49.     }
  50.    
  51.     @Override
  52.     public boolean isUserInRole(String role) {
  53.         return this.authEngine.isUserInRole(role);
  54.     }
  55.    
  56.     public void fillXacmlRequest(XacmlRequest request) {
  57.         this.authEngine.fillXacmlRequest(request);
  58.     }
  59. }