1 7 8 package org.jboss.web.tomcat.security; 9 10 import java.security.Principal ; 11 12 import javax.security.auth.callback.Callback ; 13 import javax.security.auth.callback.CallbackHandler ; 14 import javax.security.auth.callback.UnsupportedCallbackException ; 15 import javax.servlet.http.HttpServletRequest ; 16 17 import org.jboss.security.auth.callback.SecurityAssociationHandler; 18 19 33 public class WebCallbackHandler extends SecurityAssociationHandler implements 34 CallbackHandler 35 { 36 public WebCallbackHandler() 37 { 38 super(); 39 } 40 41 45 public WebCallbackHandler(Principal principal, Object credential) 46 { 47 super(principal, credential); 48 } 49 50 54 public void setSecurityInfo(Principal principal, Object credential) 55 { 56 super.setSecurityInfo(principal, credential); 57 } 58 59 62 public void handle(Callback [] callbacks) throws UnsupportedCallbackException 63 { 64 try 65 { 66 super.handle(callbacks); 67 } 68 catch (UnsupportedCallbackException uce) 69 { 70 Callback c = uce.getCallback(); 71 72 if (c instanceof HttpServletRequestCallback) 73 { 74 HttpServletRequest request = getHttpServletRequestFromValve(); 76 77 HttpServletRequestCallback hsrc = (HttpServletRequestCallback) c; 79 hsrc.setHttpServletRequest(request); 80 } 81 else 82 { 83 throw new UnsupportedCallbackException (c, "Unrecognized Callback"); 84 } 85 } 86 } 87 88 93 protected HttpServletRequest getHttpServletRequestFromValve() 94 { 95 return (HttpServletRequest ) HttpServletRequestValve.httpRequest.get(); 96 } 97 } | Popular Tags |