2012-07-07 4 views
1

구성된 https 제약 조건이 web.xml에 기밀로 설정된 단순한 jsf 보안 전송 메커니즘에서 작업했습니다. 이제 보안 전송을 위해 특정 페이지를 선택했습니다. 나는 다른 페이지로 나를 데려 갈 로그인 페이지가 있습니다. 로그인 페이지는 사용자 이름과 암호를 사용하고 요청 된 page.Now 같은 url 패턴을 사용할 때 전에 인증을 확인 ejb 보안 레이어를 통해 전송해야합니다. faces/pageToView.xhtml 요청 된 페이지에 대한 web.xml, 내가 정말 이해가 안 재미있는 행동을. 첫 번째, 내가 로그인 할 때 내 pageToView.xhtml은 https없이 표시하고 다른 pageToView2.xhtml로 이동하려면 클릭하십시오. 첫 번째 pageToView.xhtml이 https로 다시 표시됩니다. 내가 탐색하는 다른 모든 페이지는 https를 표시 할뿐만 아니라 보안 전송을 위해 구성하지 않았습니다. 특정 페이지에 대한 보안 전송 동작을 구성하는 올바른 방법을 알아야합니다. 미리 감사드립니다.jsf 보안 전송 메커니즘

답변

0

https에 갈 때 일반적으로 로그인 페이지에서이 작업을 수행하는 것처럼 보이는 방식으로 https에 머물러 있습니다. 제한된 보안 요구 사항을 가진 응용 프로그램의 경우 큰 부담이되는 것처럼 보였습니다. 그러나이 문제를 조사한 결과 큰 위험은 세션 도용이라고합니다. 따라서 보안 페이지가 2 개 있고 & 쇼핑을하고 다른 모든 페이지가 SSL을 사용하지 않는 경우 세션 쿠키를 무선/유선으로 보내고 쿠키를 스니핑 할 수 있습니다.

당신이 아파치 웹 서버를 당신의 애플리케이션 서버에 접하는다면 당신은 클라이언트 브라우저와 아파치 사이에 https를 사용하는 것보다 더 많은 옵션이 있지만 아파치와 앱 서버 사이에는 http를 사용한다고 생각합니다. 나는 당신이 이것을 할 수 있다고 확신하지만 나는 전문가가 아니며 그것을 시도하지 않았습니다.

나는 약간의 시간 전에이 글을 보았을 때 글래스 피시 (Glassfish) 팀이 https - http에서 다운 시프트 (downshift)하기로되어있는이 필터를 보았습니다. 내 기억은 컨테이너 보안과 함께 사용될 때 작업이 중단 된 모든 것을 다운 시프트하는 것입니다.

사용자 환경에 맞게 조정할 수 있습니다.이 예에서 main.xhtml 파일은 web.xml의 환영 파일입니다.이 파일은 성공적인 로그인시로드되는 페이지 일 것입니다. https - http에서 다운 시프트 할 지점. @ WebServlet의 주석 처리를 제거하고 Log.log() 대신 사용자 자신의 로깅을 사용하고 URL/경로 이름을 확인해야합니다.

언제든지이 작업을 수행 할 수는 없으므로 항상 권장 사항을 따르고 https를 사용하는 것이 좋습니다.

package uk.co.sportquest.jsfbeans.helper; 

/* 
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 
* 
* Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved. 
* 
* The contents of this file are subject to the terms of either the GNU General 
* Public License Version 2 only ("GPL") or the Common Development and 
* Distribution License("CDDL") (collectively, the "License"). You may not use 
* this file except in compliance with the License. You can obtain a copy of the 
* License at https://glassfish.dev.java.net/public/CDDL+GPL.html or 
* glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific 
* language governing permissions and limitations under the License. 
* 
* When distributing the software, include this License Header Notice in each 
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. 
* Sun designates this particular file as subject to the "Classpath" exception 
* as provided by Sun in the GPL Version 2 section of the License file that 
* accompanied this code. If applicable, add the following below the License 
* Header, with the fields enclosed by brackets [] replaced by your own 
* identifying information: "Portions Copyrighted [year] [name of copyright 
* owner]" 
* 
* Contributor(s): 
* 
* If you wish your version of this file to be governed by only the CDDL or only 
* the GPL Version 2, indicate your decision by adding "[Contributor] elects to 
* include this software in this distribution under the [CDDL or GPL Version 2] 
* license." If you don't indicate a single choice of license, a recipient has 
* the option to distribute your version of this file under either the CDDL, the 
* GPL Version 2 or to extend the choice of license to its licensees as provided 
* above. However, if you add GPL Version 2 code and therefore, elected the GPL 
* Version 2 license, then the option applies only if the new code is made 
* subject to such option by the copyright holder. 
*/ 
import java.io.*; 
import java.util.*; 
import java.security.*; 
import java.util.logging.Logger; 
import javax.faces.context.FacesContext; 
import javax.security.jacc.*; 
import javax.servlet.*; 
import javax.servlet.annotation.WebFilter; 
import javax.servlet.http.*; 
import uk.co.sportquest.general.Log; 

/** 
* Filter that downshifts from https to http if the given request came in over 
* https, but the target resource does not require any confidentiality 
* protection. 
* 
* @author jluehe 
* @author monzillo 
*/ 

//@WebFilter(filterName = "CacheFilterStatic", urlPatterns = {"/faces/secure/main.xhtml"}, 
// dispatcherTypes = {DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.REQUEST, DispatcherType.INCLUDE}) 
public class MyFilter implements Filter { 

    private static final CodeSource cs = 
      new CodeSource(null, (java.security.cert.Certificate[]) null); 
    private static final ProtectionDomain pd = 
      new ProtectionDomain(cs, null, null, null); 
// private static final Policy policy = Policy.getPolicy(); 
    private static final Policy policy = Policy.getPolicy(); 
    private static final String httpPort = "8080"; 

    @Override 
    public void init(javax.servlet.FilterConfig filterConfig) 
      throws ServletException { 

     //httpPort = filterConfig.getInitParameter("httpPort"); 
    } 

    @Override 
    @SuppressWarnings("static-access") 
    public void doFilter(ServletRequest req, ServletResponse res, 
      FilterChain filterChain) 
      throws IOException, ServletException { 

     if (req.isSecure()) { 
      HttpServletRequest httpReq = (HttpServletRequest) req; 
      Permission p = new WebUserDataPermission(httpReq); 
      p = new WebUserDataPermission(p.getName(), httpReq.getMethod()); 
      //SQLog.log("Filter: " + httpReq.getRequestURI()); 
      boolean isTransportProtected = policy.implies(pd, p) ? false : true; 
      Log.log(); 
      if (!isTransportProtected) { 
       // Downshift from https to http, by redirecting to the 
       // target resource using http 
       String redirectUrl = "http://" + req.getServerName() + ":" 
         + httpPort + httpReq.getRequestURI(); 
       String queryString = httpReq.getQueryString(); 
       if (queryString != null) { 
        redirectUrl += "?" + queryString; 
       } 
       //redirectUrl = "http://localhost:8080/SportQuest/faces/secure/main.xhtml"; 
       Log.log("url: " + redirectUrl); 
       ((HttpServletResponse) res).sendRedirect(redirectUrl); 
      } else { 
       // Perform normal request processing 
       Log.log("normal"); 
       filterChain.doFilter(req, res); 
      } 
     } else { 
      // Perform normal request processing 
      Log.log("even more normal"); 
      filterChain.doFilter(req, res); 
     } 
    } 

    @Override 
    public void destroy() { 
     // Do nothing 
    } 
} 
+0

난 아직 내 응용 프로그램에 더 많은 보안 기능을 추가하려고 해요,하지만 난 아직도 내가이 필터를 적응하려고합니다 내가 earlier.However 언급 재미있는 동작을받지 않고 SSL을 통해 사용자 이름과 암호를 전송하는 방법을 알아야 – khare