cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1329602 [2/2] - in /cxf/sandbox/fediz: fediz-core/src/main/java/org/apache/cxf/fediz/core/ fediz-core/src/main/java/org/apache/cxf/fediz/core/saml/ fediz-core/src/test/java/org/apache/cxf/fediz/core/ fediz-examples/webapp/src/main/java/org...
Date Tue, 24 Apr 2012 09:20:02 GMT
Modified: cxf/sandbox/fediz/fediz-examples/webservice/service/src/main/java/org/apache/cxf/fediz/examples/service/GreeterImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-examples/webservice/service/src/main/java/org/apache/cxf/fediz/examples/service/GreeterImpl.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-examples/webservice/service/src/main/java/org/apache/cxf/fediz/examples/service/GreeterImpl.java
(original)
+++ cxf/sandbox/fediz/fediz-examples/webservice/service/src/main/java/org/apache/cxf/fediz/examples/service/GreeterImpl.java
Tue Apr 24 09:20:01 2012
@@ -28,21 +28,20 @@ public class GreeterImpl implements Gree
 
     private static final Logger LOG = Logger.getLogger(GreeterImpl.class.getPackage().getName());
 
-	@Resource
-	WebServiceContext context = null;
+    @Resource
+    WebServiceContext context = null;
 
     public String greetMe() {
         LOG.info("Executing operation greetMe");
         System.out.println("Executing operation greetMe");
         if (context == null) {
-           return "Unknown user";
-        }
-        else {
-           Principal p = context.getUserPrincipal();
-           if (p == null) {
-             return "Principal null";
-           }
-           return p.getName();
+            return "Unknown user";
+        } else {
+            Principal p = context.getUserPrincipal();
+            if (p == null) {
+                return "Principal null";
+            }
+            return p.getName();
         }
     }
 

Modified: cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/PasswordCallbackHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/PasswordCallbackHandler.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/PasswordCallbackHandler.java
(original)
+++ cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/PasswordCallbackHandler.java
Tue Apr 24 09:20:01 2012
@@ -26,17 +26,16 @@ import org.apache.ws.security.WSPassword
 
 public class PasswordCallbackHandler implements CallbackHandler {
 
-	public void handle(Callback[] callbacks) throws IOException,
-			UnsupportedCallbackException {
-		for (int i = 0; i < callbacks.length; i++) {
-			if (callbacks[i] instanceof WSPasswordCallback) { // CXF
-				WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-				if ("mystskey".equals(pc.getIdentifier())) {
-					pc.setPassword("stskpass");
-					break;
-				}
-			}
-		}
-	}
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+        for (int i = 0; i < callbacks.length; i++) {
+            if (callbacks[i] instanceof WSPasswordCallback) { // CXF
+                WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+                if ("mystskey".equals(pc.getIdentifier())) {
+                    pc.setPassword("stskpass");
+                    break;
+                }
+            }
+        }
+    }
 
 }

Modified: cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/UsernamePasswordCallbackHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/UsernamePasswordCallbackHandler.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/UsernamePasswordCallbackHandler.java
(original)
+++ cxf/sandbox/fediz/fediz-idp-sts/src/main/java/org/apache/cxf/fediz/service/sts/UsernamePasswordCallbackHandler.java
Tue Apr 24 09:20:01 2012
@@ -27,31 +27,31 @@ import org.apache.ws.security.WSPassword
 
 public class UsernamePasswordCallbackHandler implements CallbackHandler {
 
-	private Map<String,String> passwords;
-	
-	public void setPasswords(Map<String,String> passwords) {
-		this.passwords = passwords;
-	}
-
-	public Map<String,String> getPasswords() {
-		return passwords;
-	}
-	
+    private Map<String,String> passwords;
+
+    public void setPasswords(Map<String,String> passwords) {
+        this.passwords = passwords;
+    }
+
+    public Map<String,String> getPasswords() {
+        return passwords;
+    }
+
     public void handle(Callback[] callbacks) throws IOException,
-            UnsupportedCallbackException {
-    	
-    	if (getPasswords() == null || getPasswords().size() == 0)
-    		return;
-    	
+    UnsupportedCallbackException {
+
+        if (getPasswords() == null || getPasswords().size() == 0)
+            return;
+
         for (int i = 0; i < callbacks.length; i++) {
             if (callbacks[i] instanceof WSPasswordCallback) { // CXF
                 WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
-                
+
                 String pw = getPasswords().get(pc.getIdentifier());
                 pc.setPassword(pw);
             }
         }
     }
-	
-    
+
+
 }

Modified: cxf/sandbox/fediz/fediz-idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
(original)
+++ cxf/sandbox/fediz/fediz-idp/src/main/java/org/apache/cxf/fediz/service/idp/IdpServlet.java
Tue Apr 24 09:20:01 2012
@@ -65,8 +65,8 @@ public class IdpServlet extends HttpServ
     public static final String SERVLET_PARAM_TOKENTYPE = "ws-trust-tokentype";
 
     /**
-	 * 
-	 */
+     * 
+     */
     private static final long serialVersionUID = -9019993850246851112L;
 
     private String tokenType;
@@ -75,26 +75,26 @@ public class IdpServlet extends HttpServ
     public void init() throws ServletException {
         if (getInitParameter("sts.wsdl.url") == null) {
             throw new ServletException(
-                    "Parameter 'sts.wsdl.url' not configured");
+                "Parameter 'sts.wsdl.url' not configured");
         }
         if (getInitParameter("sts.wsdl.service") == null) {
             throw new ServletException(
-                    "Parameter 'sts.wsdl.service' not configured");
+                "Parameter 'sts.wsdl.service' not configured");
         }
         if (getInitParameter("sts.wsdl.endpoint") == null) {
             throw new ServletException(
-                    "Parameter 'sts.wsdl.endpoint' not configured");
+                "Parameter 'sts.wsdl.endpoint' not configured");
         }
 
         tokenType = getInitParameter(SERVLET_PARAM_TOKENTYPE);
         if (tokenType != null && tokenType.length() > 0) {
-           LOG.info("Configured Tokentype: " + tokenType);
+            LOG.info("Configured Tokentype: " + tokenType);
         }
 
     }
 
     public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
+        throws ServletException, IOException {
 
         /*
          * if (request.getPathInfo().contains("jsp")) { return; }
@@ -107,20 +107,20 @@ public class IdpServlet extends HttpServ
 
         if (action == null) {
             LOG.error("Bad request. HTTP parameter '" + PARAM_ACTION
-                    + "' missing");
+                      + "' missing");
             response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter "
-                    + PARAM_ACTION + " missing");
+                + PARAM_ACTION + " missing");
             return;
         }
         if (action.equals(ACTION_SIGNIN)) {
             LOG.debug("Sign-In request [" + PARAM_ACTION + "=" + ACTION_SIGNIN
-                    + "] ...");
+                      + "] ...");
 
             if (wtrealm == null || wtrealm.length() == 0) {
                 LOG.error("Bad request. HTTP parameter '" + ACTION_SIGNIN
-                        + "' missing");
+                          + "' missing");
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST,
-                        "Parameter " + ACTION_SIGNIN + " missing");
+                                   "Parameter " + ACTION_SIGNIN + " missing");
                 return;
             }
 
@@ -139,7 +139,7 @@ public class IdpServlet extends HttpServ
                     if (authType.equalsIgnoreCase("basic")) {
 
                         String decoded = new String(
-                                Base64Utility.decode(encoded));
+                                                    Base64Utility.decode(encoded));
 
                         int colon = decoded.indexOf(':');
                         if (colon < 0) {
@@ -147,19 +147,19 @@ public class IdpServlet extends HttpServ
                         } else {
                             username = decoded.substring(0, colon);
                             password = decoded.substring(colon + 1,
-                                    decoded.length());
+                                                         decoded.length());
                         }
                         LOG.debug("Validating user [" + username
-                                + "] and password [" + password + "]");
+                                  + "] and password [" + password + "]");
 
                         try {
                             wresult = requestSecurityToken(username, password,
-                                    wtrealm);
+                                                           wtrealm);
                             request.setAttribute("fed." + PARAM_WRESULT,
-                                    StringEscapeUtils.escapeXml(wresult));
+                                                 StringEscapeUtils.escapeXml(wresult));
                             if (wctx != null) {
                                 request.setAttribute("fed." + PARAM_WCONTEXT,
-                                        StringEscapeUtils.escapeXml(wctx));
+                                                     StringEscapeUtils.escapeXml(wctx));
                             }
                             if (wreply == null) {
                                 request.setAttribute("fed.action", wtrealm);
@@ -169,8 +169,8 @@ public class IdpServlet extends HttpServ
                         } catch (Exception ex) {
                             LOG.info("Requesting security token failed", ex);
                             response.sendError(
-                                    HttpServletResponse.SC_FORBIDDEN,
-                                    "Requesting security token failed");
+                                               HttpServletResponse.SC_FORBIDDEN,
+                                "Requesting security token failed");
                             return;
                         }
 
@@ -180,19 +180,19 @@ public class IdpServlet extends HttpServ
                         // this.getServletContext().getRequestDispatcher("/WEB-INF/signinresponse.jsp").forward(request,
                         // response);
                         this.getServletContext()
-                                .getRequestDispatcher(
-                                        "/WEB-INF/signinresponse.jsp")
-                                .forward(request, response);
+                        .getRequestDispatcher(
+                            "/WEB-INF/signinresponse.jsp")
+                            .forward(request, response);
 
                     } else {
                         response.sendError(HttpServletResponse.SC_BAD_REQUEST,
-                                "Invalid Authorization header");
+                            "Invalid Authorization header");
                         return;
                     }
                 } catch (Exception ex) {
                     LOG.error("Invalid Authorization header", ex);
                     response.sendError(HttpServletResponse.SC_BAD_REQUEST,
-                            "Invalid Authorization header");
+                        "Invalid Authorization header");
                     return;
                 }
 
@@ -205,22 +205,22 @@ public class IdpServlet extends HttpServ
             }
         } else {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter "
-                    + PARAM_ACTION + " with value " + action
-                    + " is not supported");
+                + PARAM_ACTION + " with value " + action
+                + " is not supported");
             return;
         }
     }
 
     private String requestSecurityToken(String username, String password,
-            String wtrealm) throws Exception {
+                                        String wtrealm) throws Exception {
         try {
             Bus bus = BusFactory.getDefaultBus();
             List<String> realmClaims = null;
             ApplicationContext ctx = (ApplicationContext) bus
-                    .getExtension(ApplicationContext.class);
+                .getExtension(ApplicationContext.class);
             try {
                 Map<String, List<String>> realmClaimsMap = (Map<String, List<String>>)
ctx
-                        .getBean("realm2ClaimsMap");
+                    .getBean("realm2ClaimsMap");
                 realmClaims = realmClaimsMap.get(wtrealm);
                 if (realmClaims != null && realmClaims.size() > 0) {
                     LOG.debug("claims for realm " + wtrealm);
@@ -243,11 +243,11 @@ public class IdpServlet extends HttpServ
 
             sts.setWsdlLocation(getInitParameter("sts.wsdl.url"));
             sts.setServiceQName(new QName(
-                    "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
-                    getInitParameter("sts.wsdl.service")));
+                                          "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
+                                          getInitParameter("sts.wsdl.service")));
             sts.setEndpointQName(new QName(
-                    "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
-                    getInitParameter("sts.wsdl.endpoint")));
+                                           "http://docs.oasis-open.org/ws-sx/ws-trust/200512/",
+                                           getInitParameter("sts.wsdl.endpoint")));
             sts.getProperties().put(SecurityConstants.USERNAME, username);
             sts.getProperties().put(SecurityConstants.PASSWORD, password);
 
@@ -270,7 +270,7 @@ public class IdpServlet extends HttpServ
     }
 
     private Element createClaimsElement(List<String> realmClaims)
-            throws Exception {
+        throws Exception {
         if (realmClaims == null || realmClaims.size() == 0)
             return null;
 
@@ -278,15 +278,15 @@ public class IdpServlet extends HttpServ
         writer.writeStartElement("wst", "Claims", STSUtils.WST_NS_05_12);
         writer.writeNamespace("wst", STSUtils.WST_NS_05_12);
         writer.writeNamespace("ic",
-                "http://schemas.xmlsoap.org/ws/2005/05/identity");
+            "http://schemas.xmlsoap.org/ws/2005/05/identity");
         writer.writeAttribute("Dialect",
-                "http://schemas.xmlsoap.org/ws/2005/05/identity");
+            "http://schemas.xmlsoap.org/ws/2005/05/identity");
 
         if (realmClaims != null && realmClaims.size() > 0) {
             for (String item : realmClaims) {
                 LOG.debug("claim: " + item);
                 writer.writeStartElement("ic", "ClaimType",
-                        "http://schemas.xmlsoap.org/ws/2005/05/identity");
+                    "http://schemas.xmlsoap.org/ws/2005/05/identity");
                 writer.writeAttribute("Uri", item);
                 writer.writeEndElement();
             }

Modified: cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/beans.xml?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/beans.xml (original)
+++ cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/beans.xml Tue Apr 24 09:20:01 2012
@@ -27,7 +27,7 @@
 	</cxf:bus>
 
     
-    <http:conduit name="https://localhost:9443/.*">
+    <http:conduit name="https://localhost:8443/.*">
       <http:tlsClientParameters disableCNCheck="true">
         <sec:trustManagers>
           <sec:keyStore type="jks" password="cspass" resource="clientstore.jks"/>

Modified: cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/sandbox/fediz/fediz-idp/src/main/webapp/WEB-INF/web.xml Tue Apr 24 09:20:01 2012
@@ -13,7 +13,7 @@
 		<servlet-class>org.apache.cxf.fediz.service.idp.IdpServlet</servlet-class>
 		<init-param>
 			<param-name>sts.wsdl.url</param-name>
-			<param-value>https://localhost:9443/fedizidpsts/STSService?wsdl</param-value>
+			<param-value>https://localhost:8443/fedizidpsts/STSService?wsdl</param-value>
 		</init-param>
 		<init-param>
 			<param-name>sts.wsdl.service</param-name>

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java
(original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationFilter.java
Tue Apr 24 09:20:01 2012
@@ -13,55 +13,55 @@ import javax.servlet.http.HttpServletReq
 import org.w3c.dom.Element;
 
 /**
-* Add security token to thread local
-*
-* @deprecated  Use filter shipped with SAFT
-*/
+ * Add security token to thread local
+ *
+ * @deprecated  Use filter shipped with SAFT
+ */
 @Deprecated
 public class FederationFilter implements Filter {
 
-	private static final String DEFAULT_SECURITY_TOKEN_ATTR = "org.apache.fediz.SECURITY_TOKEN";
-	private static final String SECURITY_TOKEN_ATTR_CONFIG = "security.token.attribute";
-	
-	private String securityTokenAttr = DEFAULT_SECURITY_TOKEN_ATTR;
-	
-	@Override
-	public void init(FilterConfig filterConfig) throws ServletException {
-		String attrName = filterConfig.getInitParameter(SECURITY_TOKEN_ATTR_CONFIG);
-		if (attrName != null) {
-			securityTokenAttr = attrName;
-		}
-		
-	}
-
-	@Override
-	public void doFilter(ServletRequest request, ServletResponse response,
-			FilterChain chain) throws IOException, ServletException {
-	
-		if (request instanceof HttpServletRequest) {
-			HttpServletRequest hrequest = (HttpServletRequest)request;
-			Element el = (Element)hrequest.getSession().getAttribute(securityTokenAttr);
-			if (el != null) {
-				try
-				{
-					SecurityTokenThreadLocal.setToken(el);
-					chain.doFilter(request, response);
-				} finally {
-					SecurityTokenThreadLocal.setToken(null);
-				}		
-			} else {
-				chain.doFilter(request, response);
-			}
-			
-		} else {
-			chain.doFilter(request, response);
-		}
-	}
-
-	@Override
-	public void destroy() {
-		// TODO Auto-generated method stub
+    private static final String DEFAULT_SECURITY_TOKEN_ATTR = "org.apache.fediz.SECURITY_TOKEN";
+    private static final String SECURITY_TOKEN_ATTR_CONFIG = "security.token.attribute";
 
-	}
+    private String securityTokenAttr = DEFAULT_SECURITY_TOKEN_ATTR;
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+        String attrName = filterConfig.getInitParameter(SECURITY_TOKEN_ATTR_CONFIG);
+        if (attrName != null) {
+            securityTokenAttr = attrName;
+        }
+
+    }
+
+    @Override
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain) throws IOException, ServletException {
+
+        if (request instanceof HttpServletRequest) {
+            HttpServletRequest hrequest = (HttpServletRequest)request;
+            Element el = (Element)hrequest.getSession().getAttribute(securityTokenAttr);
+            if (el != null) {
+                try
+                {
+                    SecurityTokenThreadLocal.setToken(el);
+                    chain.doFilter(request, response);
+                } finally {
+                    SecurityTokenThreadLocal.setToken(null);
+                }		
+            } else {
+                chain.doFilter(request, response);
+            }
+
+        } else {
+            chain.doFilter(request, response);
+        }
+    }
+
+    @Override
+    public void destroy() {
+        // TODO Auto-generated method stub
+
+    }
 
 }

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
(original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
Tue Apr 24 09:20:01 2012
@@ -25,76 +25,76 @@ import org.w3c.dom.Element;
 
 public class FederationServlet extends HttpServlet {
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = -9019993850246851112L;
-
-	public void doGet(HttpServletRequest request, HttpServletResponse response)
-			throws ServletException, IOException {
-
-		response.setContentType("text/html");
-		PrintWriter out = response.getWriter();
-
-		out.println("<html>");
-		out.println("<head><title>WS Federation Tomcat Examples</title></head>");
-		out.println("<body>");
-		out.println("<h1>Hello World</h1>");
-		out.println("Hello world<br>");
-		out.println("Request url: " + request.getRequestURL().toString() + "<p>");
-		
-
-		
-		out.println("<br><b>User</b><p>");
-		Principal p = request.getUserPrincipal();
-		if (p != null) {
-			out.println("Principal: " + p.getName() + "<p>");
-		}
-		
-		out.println("<br><b>Roles</b><p>");
-		List<String> roleListToCheck = Arrays.asList("Admin", "Manager", "User", "Authenticated");
-		for (String item: roleListToCheck) {
-			out.println("Has role '" + item + "': " + ((request.isUserInRole(item)) ? "<b>yes</b>"
: "no") + "<p>" );
-		}
-		
-		if (p instanceof FederationPrincipal) {
-			FederationPrincipal fp = (FederationPrincipal)p;
-			
-			out.println("<br><b>Claims</b><p>");
-			ClaimCollection claims = fp.getClaims();
-			for (Claim c: claims) {
-				out.println(c.getClaimType().toString() + ": " + c.getValue() + "<p>");
-			}
-		}
-		else {
-			out.println("Principal is not instance of FederationPrincipal");
-		}
-		
-		
-		//FederationResponse fd = (FederationResponse)request.getSession().getAttribute(FederationAuthenticator.FEDERATION_NOTE);
-		
-		Element el = SecurityTokenThreadLocal.getToken();
-		if (el != null) {
-			out.println("<p>Bootstrap token...");
-			String token = null;
-			try {
-				TransformerFactory transFactory = TransformerFactory.newInstance();
-				Transformer transformer = transFactory.newTransformer();
-				StringWriter buffer = new StringWriter();
-				transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-				transformer.transform(new DOMSource(el),
-				      new StreamResult(buffer));
-				token = buffer.toString();
-				out.println("<p>" + StringEscapeUtils.escapeXml(token));
-			} catch (Exception ex) {
-				out.println("<p>Failed to transform cached element to string: " + ex.toString());
-			}
-		}
-		else {
-			out.println("<p>Bootstrap token not cached in thread local storage");
-		}
-		
-		out.println("</body>");
-	}
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -9019993850246851112L;
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+        throws ServletException, IOException {
+
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+
+        out.println("<html>");
+        out.println("<head><title>WS Federation Tomcat Examples</title></head>");
+        out.println("<body>");
+        out.println("<h1>Hello World</h1>");
+        out.println("Hello world<br>");
+        out.println("Request url: " + request.getRequestURL().toString() + "<p>");
+
+
+
+        out.println("<br><b>User</b><p>");
+        Principal p = request.getUserPrincipal();
+        if (p != null) {
+            out.println("Principal: " + p.getName() + "<p>");
+        }
+
+        out.println("<br><b>Roles</b><p>");
+        List<String> roleListToCheck = Arrays.asList("Admin", "Manager", "User", "Authenticated");
+        for (String item: roleListToCheck) {
+            out.println("Has role '" + item + "': " + ((request.isUserInRole(item)) ? "<b>yes</b>"
: "no") + "<p>" );
+        }
+
+        if (p instanceof FederationPrincipal) {
+            FederationPrincipal fp = (FederationPrincipal)p;
+
+            out.println("<br><b>Claims</b><p>");
+            ClaimCollection claims = fp.getClaims();
+            for (Claim c: claims) {
+                out.println(c.getClaimType().toString() + ": " + c.getValue() + "<p>");
+            }
+        }
+        else {
+            out.println("Principal is not instance of FederationPrincipal");
+        }
+
+
+        //FederationResponse fd = (FederationResponse)request.getSession().getAttribute(FederationAuthenticator.FEDERATION_NOTE);
+
+        Element el = SecurityTokenThreadLocal.getToken();
+        if (el != null) {
+            out.println("<p>Bootstrap token...");
+            String token = null;
+            try {
+                TransformerFactory transFactory = TransformerFactory.newInstance();
+                Transformer transformer = transFactory.newTransformer();
+                StringWriter buffer = new StringWriter();
+                transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+                transformer.transform(new DOMSource(el),
+                                      new StreamResult(buffer));
+                token = buffer.toString();
+                out.println("<p>" + StringEscapeUtils.escapeXml(token));
+            } catch (Exception ex) {
+                out.println("<p>Failed to transform cached element to string: " + ex.toString());
+            }
+        }
+        else {
+            out.println("<p>Bootstrap token not cached in thread local storage");
+        }
+
+        out.println("</body>");
+    }
 
 }
\ No newline at end of file

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java
(original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/java/org/apache/cxf/fediz/example/SecurityTokenThreadLocal.java
Tue Apr 24 09:20:01 2012
@@ -4,22 +4,22 @@ import org.w3c.dom.Element;
 
 
 /**
-* Thread local storage for security token
-*
-* @deprecated  Use TLS shipped with SAFT
-*/
+ * Thread local storage for security token
+ *
+ * @deprecated  Use TLS shipped with SAFT
+ */
 @Deprecated
 public class SecurityTokenThreadLocal {
 
-	private static final ThreadLocal<Element> threadToken = 
-	       new ThreadLocal<Element>() {
-	};
-	
-	public static void setToken(Element token) {
-		threadToken.set(token);
-	}
-	
-	public static Element getToken() {
-		return threadToken.get();
-	}
+    private static final ThreadLocal<Element> threadToken = 
+        new ThreadLocal<Element>() {
+    };
+
+    public static void setToken(Element token) {
+        threadToken.set(token);
+    }
+
+    public static Element getToken() {
+        return threadToken.get();
+    }
 }
\ No newline at end of file

Modified: cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml (original)
+++ cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml Tue Apr 24
09:20:01 2012
@@ -1,3 +1,3 @@
 <Context>
-        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" issuerURL="https://localhost:9443/fedizidp/"
truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" trustedIssuer=".*CN=www.sts.com.*"
/>        
+        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" issuerURL="https://localhost:8443/fedizidp/"
truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" trustedIssuer=".*CN=www.sts.com.*"
/>        
 </Context>

Modified: cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipal.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipal.java?rev=1329602&r1=1329601&r2=1329602&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipal.java
(original)
+++ cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipal.java
Tue Apr 24 09:20:01 2012
@@ -7,18 +7,18 @@ import org.apache.cxf.fediz.core.Claim;
 import org.apache.cxf.fediz.core.ClaimCollection;
 
 public class FederationPrincipal extends GenericPrincipal {
-	// [TODO] make sure claims and roles are imutable 
-	protected ClaimCollection claims;
-	
-	public FederationPrincipal(String username, List<String> roles, List<Claim>
claims) {
-		super(username, null, roles);
-		this.claims = new ClaimCollection(claims);
-	}
-	
-	public ClaimCollection getClaims() {
-		return this.claims;
-	}
-	
-	
+    // [TODO] make sure claims and roles are imutable 
+    protected ClaimCollection claims;
+
+    public FederationPrincipal(String username, List<String> roles, List<Claim>
claims) {
+        super(username, null, roles);
+        this.claims = new ClaimCollection(claims);
+    }
+
+    public ClaimCollection getClaims() {
+        return this.claims;
+    }
+
+
 
 }



Mime
View raw message