cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1329984 - in /cxf/sandbox/fediz: fediz-core/src/main/java/org/apache/cxf/fediz/core/ fediz-core/src/main/java/org/apache/fediz/ fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/ fediz-examples/webapp/src/main/webapp/META-IN...
Date Tue, 24 Apr 2012 20:06:03 GMT
Author: owulff
Date: Tue Apr 24 20:06:03 2012
New Revision: 1329984

URL: http://svn.apache.org/viewvc?rev=1329984&view=rev
Log:
Support to configure configFile relative to catalina.home

Added:
    cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipalImpl.java
Removed:
    cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/IDPCallback.java
    cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/cxf/fediz/core/WsFedPrincipal.java
    cxf/sandbox/fediz/fediz-core/src/main/java/org/apache/fediz/
Modified:
    cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
    cxf/sandbox/fediz/fediz-examples/webapp/src/main/webapp/META-INF/context.xml
    cxf/sandbox/fediz/fediz-tomcat-example/src/main/webapp/META-INF/context.xml
    cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java

Modified: cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java?rev=1329984&r1=1329983&r2=1329984&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
(original)
+++ cxf/sandbox/fediz/fediz-examples/webapp/src/main/java/org/apache/cxf/fediz/example/FederationServlet.java
Tue Apr 24 20:06:03 2012
@@ -38,7 +38,6 @@ import org.apache.commons.lang3.StringEs
 import org.apache.cxf.fediz.core.Claim;
 import org.apache.cxf.fediz.core.ClaimCollection;
 import org.apache.cxf.fediz.core.FederationPrincipal;
-import org.apache.cxf.fediz.tomcat.FederationPrincipalImpl;
 import org.apache.hello_world_soap_http.Greeter;
 import org.w3c.dom.Element;
 
@@ -141,8 +140,8 @@ public class FederationServlet extends H
             out.println("Has role '" + item + "': " + ((request.isUserInRole(item)) ? "<b>yes</b>"
: "no") + "<p>" );
         }
 
-        if (p instanceof FederationPrincipalImpl) {
-            FederationPrincipalImpl fp = (FederationPrincipalImpl)p;
+        if (p instanceof FederationPrincipal) {
+            FederationPrincipal fp = (FederationPrincipal)p;
 
             out.println("<br><b>Claims</b><p>");
             ClaimCollection claims = fp.getClaims();

Modified: cxf/sandbox/fediz/fediz-examples/webapp/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-examples/webapp/src/main/webapp/META-INF/context.xml?rev=1329984&r1=1329983&r2=1329984&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-examples/webapp/src/main/webapp/META-INF/context.xml (original)
+++ cxf/sandbox/fediz/fediz-examples/webapp/src/main/webapp/META-INF/context.xml Tue Apr 24
20:06:03 2012
@@ -1,4 +1,5 @@
 <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" configFile="conf/fediz_config.xml"
/>
+        <!--<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" issuerCallbackHandler="org.apache.cxf.fediz.tomcat.DummyIDPCallbackHandler"
truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" />-->        
 </Context>

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=1329984&r1=1329983&r2=1329984&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
20:06:03 2012
@@ -1,5 +1,5 @@
 <Context>
-        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" configFile="/projects/fediz/tomcat-rp2/conf/fediz_config.xml"
/>
+        <Valve className="org.apache.cxf.fediz.tomcat.FederationAuthenticator" configFile="conf/fediz_config.xml"
/>
         <!--<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" issuerCallbackHandler="org.apache.cxf.fediz.tomcat.DummyIDPCallbackHandler"
truststoreFile="conf/stsstore.jks" truststorePassword="stsspass" />-->        
 </Context>

Modified: cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java?rev=1329984&r1=1329983&r2=1329984&view=diff
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
(original)
+++ cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationAuthenticator.java
Tue Apr 24 20:06:03 2012
@@ -47,52 +47,12 @@ public class FederationAuthenticator ext
 
     protected static final String TRUSTED_ISSUER = "org.apache.cxf.fediz.tomcat.TRUSTED_ISSUER";
 
-    //    /**
-    //     * IssuerURL
-    //     */
-    //    protected String issuerURL = null;
-    //
-    //    /**
-    //     * Requested Authentication type. See
-    //     * org.apache.cxf.fediz.tomcat.WsFedConstants.AUTH_TYPE_*
-    //     */
-    //    protected URI authenticationType = null;
-    //
-    //    /**
-    //     * Trusted Issuer Name
-    //     */
-    //    protected String trustedIssuer = null;
-    //
-    //    /**
-    //     * Truststore file
-    //     */
-    //    protected String truststoreFile = null;
-    //
-    //    /**
-    //     * Truststore password
-    //     */
-    //    protected String truststorePassword = null;
-    //
-    //    /**
-    //     * Role URI in Claim
-    //     */
-    //    protected String roleClaimURI = null;
-    //
-    //    /**
-    //     * Role delimiter in claim value
-    //     */
-    //    protected String roleDelimiter = ",";
 
     /**
      * Fediz Configuration file
      */
     protected String configFile = null;
 
-    //    /**
-    //     * Role delimiter in claim value
-    //     */
-    //    protected CallbackHandler issuerCallbackHandler = null;
-
     private FederationConfigurator configurator = null;
 
     public FederationAuthenticator() {
@@ -107,115 +67,6 @@ public class FederationAuthenticator ext
         return (info);
     }
 
-    //    /**
-    //     * Return the callback handler to figure out the IDP url
-    //     */
-    //    public CallbackHandler getIssuerCallbackHandler() {
-    //        return issuerCallbackHandler;
-    //    }
-    //
-    //    /**
-    //     * Set the callback handler class to figure out the IDP url
-    //     */
-    //    public void setIssuerCallbackHandler(String issuerCallbackHandler) {
-    //
-    //        try {
-    //            this.issuerCallbackHandler = (CallbackHandler) Thread
-    //                    .currentThread().getContextClassLoader()
-    //                    .loadClass(issuerCallbackHandler).newInstance();
-    //        } catch (Throwable ex) {
-    //            log.fatal("Callback handler not intialized: " + ex.getMessage());
-    //        }
-    //    }
-    //
-    //    /**
-    //     * Return the character encoding to use to read the username and password.
-    //     */
-    //    public String getIssuerURL() {
-    //        return issuerURL;
-    //    }
-    //
-    //    /**
-    //     * Set the character encoding to be used to read the username and password.
-    //     */
-    //    public void setIssuerURL(String issuerURL) {
-    //        this.issuerURL = issuerURL;
-    //    }
-    //
-    //    /**
-    //     * Return the requested authentication type.
-    //     */
-    //    public URI getAuthenticationType() {
-    //        return authenticationType;
-    //    }
-    //
-    //    /**
-    //     * Set the requested authentication type.
-    //     */
-    //    public void setAuthenticationType(String authenticationType) {
-    //        FederationConstants.AUTH_TYPE_MAP.containsKey(authenticationType);
-    //        this.authenticationType = FederationConstants.AUTH_TYPE_MAP
-    //                .get(authenticationType);
-    //    }
-    //
-    //    public String getTruststorePassword() {
-    //        return truststorePassword;
-    //    }
-    //
-    //    public void setTruststorePassword(String truststorePassword) {
-    //        this.truststorePassword = truststorePassword;
-    //    }
-    //
-    //    public String getTruststoreFile() {
-    //        return truststoreFile;
-    //    }
-    //
-    //    public void setTruststoreFile(String truststoreFile) {
-    //        this.truststoreFile = truststoreFile;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public String getRoleClaimURI() {
-    //        return this.roleClaimURI;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public void setRoleClaimURI(String roleClaimURI) {
-    //        this.roleClaimURI = roleClaimURI;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public String getRoleDelimiter() {
-    //        return this.roleDelimiter;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public void setRoleDelimiter(String roleDelimiter) {
-    //        this.roleDelimiter = roleDelimiter;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public String getTrustedIssuer() {
-    //        return this.trustedIssuer;
-    //    }
-    //
-    //    /**
-    //     * 
-    //     */
-    //    public void setTrustedIssuer(String trustedIssuer) {
-    //        this.trustedIssuer = trustedIssuer;
-    //    }
-
     public String getConfigFile() {
         return configFile;
     }
@@ -228,8 +79,14 @@ public class FederationAuthenticator ext
     protected synchronized void startInternal() throws LifecycleException {
 
         try {
-            configurator = new FederationConfigurator();
             File f = new File(getConfigFile());
+            if (!f.exists()) {
+                String catalinaHome = System.getProperty("catalina.home");
+                if (catalinaHome != null && catalinaHome.length() > 0) {
+                    f = new File(catalinaHome.concat(File.separator + getConfigFile()));
+                }
+            }
+            configurator = new FederationConfigurator();
             configurator.loadConfig(f);
         } catch (JAXBException e) {
             throw new LifecycleException("Failed to load Fediz configuration",
@@ -430,55 +287,6 @@ public class FederationAuthenticator ext
                 // fedConfig.setTrustedIssuer(trustedIssuer);
                 // log.info("Trusted issuer: " + trustedIssuer);
                 //
-                // fedConfig.setRoleDelimiter(this.getRoleDelimiter());
-                // if (this.getRoleClaimURI() == null
-                // || this.getRoleClaimURI().length() == 0) {
-                // fedConfig.setRoleURI(FederationConstants.DEFAULT_ROLE_URI);
-                // } else {
-                // fedConfig.setRoleURI(URI.create(this.getRoleClaimURI()));
-                // }
-                //
-                // if (this.getTruststoreFile() == null
-                // || this.getTruststoreFile().length() == 0) {
-                // log.error("Truststore file configuration must be checked before redirect
to IDP");
-                // // TODO would an exception not be the better solution here ?
-                // return false;
-                // }
-                // if (this.getTruststorePassword() == null
-                // || this.getTruststorePassword().length() == 0) {
-                // log.error("Truststore password configuration must be checked before redirect
to IDP");
-                // // TODO would an exception not be the better solution here ?
-                // return false;
-                // } else {
-                // if ((new File(getTruststoreFile())).exists()) {
-                // fedConfig.setTrustStoreFile(this.getTruststoreFile());
-                // } else {
-                // String catalinaHome = System
-                // .getProperty("catalina.home");
-                // if (catalinaHome != null && catalinaHome.length() > 0) {
-                //
-                // String fqTruststoreFile = catalinaHome
-                // .concat(File.separator
-                // + getTruststoreFile());
-                // this.setTruststoreFile(fqTruststoreFile);
-                // fedConfig.setTrustStoreFile(this
-                // .getTruststoreFile());
-                // } else {
-                // log.error("Truststore file configuration not valid");
-                // return false;
-                // }
-                // }
-                //
-                // fedConfig.setTrustStoreFile(this.getTruststoreFile());
-                // fedConfig.setTrustStorePassword(this
-                // .getTruststorePassword());
-                // if (log.isDebugEnabled()) {
-                // log.debug("Truststore file: "
-                // + fedConfig.getTrustStoreFile());
-                // log.debug("Truststore password: "
-                // + fedConfig.getTrustStorePassword());
-                // }
-                // }
 
                 FederationProcessor wfProc = new FederationProcessorImpl();
                 wfRes = wfProc.processRequest(wfReq, fedConfig);
@@ -629,104 +437,6 @@ public class FederationAuthenticator ext
         } else {
             response.sendRedirect(redirectURL);
         }
-
-
-        //        if (this.getIssuerCallbackHandler() != null) {
-        //            org.apache.cxf.fediz.core.spi.IDPCallback callback = new org.apache.cxf.fediz.core.spi.IDPCallback(
-        //                    request);
-        //            try {
-        //                this.getIssuerCallbackHandler().handle(
-        //                        new Callback[] { callback });
-        //                redirectURL = callback.getIssuerUrl().toString();
-        //                String trustedIssuer = callback.getTrustedIssuer();
-        //                if (trustedIssuer != null && trustedIssuer.length() >
0) {
-        //                    request.getSessionInternal().setNote(TRUSTED_ISSUER,
-        //                            trustedIssuer);
-        //                }
-        //            } catch (Exception ex) {
-        //                log.error("Failed to handle callback: " + ex.getMessage());
-        //            }
-        //        } else {
-        //            String issuerURL = ((FederationProtocolType) fedCtx.getProtocol())
-        //                    .getIssuer();
-        //            if (issuerURL != null && issuerURL.length() > 0) {
-        //                redirectURL = issuerURL;
-        //            }
-        //        }
-        //        log.info("Issuer url: " + redirectURL);
-        //
-        //        String loginPage = config.getLoginPage();
-        //        if (redirectURL == null) {
-        //            if (loginPage != null && loginPage.length() > 0) {
-        //                redirectURL = loginPage;
-        //            } else {
-        //                String msg = sm.getString("formAuthenticator.noLoginPage",
-        //                        context.getName());
-        //                log.warn(msg);
-        //                response.sendError(
-        //                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
-        //                return;
-        //            }
-        //        }
-        //        StringBuilder sb = new StringBuilder();
-        //
-        //        // StringBuilder sb = new StringBuilder(redirectURL);
-        //        // sb.append('?');
-        //
-        //        sb.append(FederationConstants.PARAM_ACTION).append('=')
-        //                .append(FederationConstants.ACTION_SIGNIN);
-        //
-        //        sb.append('&').append(FederationConstants.PARAM_REPLY).append('=');
-        //        sb.append(URLEncoder
-        //                .encode(request.getRequestURL().toString(), "UTF-8"));
-        //
-        //        String realm = null;
-        //        String contextPath = request.getContextPath();
-        //        String requestUrl = request.getRequestURL().toString();
-        //        String requestPath = new URL(requestUrl).getPath();
-        //
-        //        // Cut request path of request url and add context path if not ROOT
-        //        if (requestPath != null && requestPath.length() > 0) {
-        //            int lastIndex = requestUrl.lastIndexOf(requestPath);
-        //            realm = requestUrl.substring(0, lastIndex);
-        //        } else {
-        //            realm = requestUrl;
-        //        }
-        //        if (contextPath != null && contextPath.length() > 0) {
-        //            // contextPath contains starting slash
-        //            realm = realm + contextPath + "/";
-        //        } else {
-        //            realm = realm + "/";
-        //        }
-        //        log.debug("wtrealm=" + realm);
-        //
-        //        StringBuffer realmSb = new StringBuffer(request.getScheme());
-        //        realmSb.append("://").append(request.getServerName()).append(":")
-        //                .append(request.getServerPort())
-        //                .append(request.getContextPath());
-        //        sb.append('&').append(FederationConstants.PARAM_TREALM).append('=')
-        //                .append(URLEncoder.encode(realm, "UTF-8"));
-        //
-        //        // [TODO] Current time, wct
-        //
-        //        // if (false) {
-        //        // sb.append("&");
-        //        // sb.append("wfresh=jjjj");
-        //        // }
-        //        // if (false) {
-        //        // sb.append("&");
-        //        // sb.append("wauth=jjjj");
-        //        // }
-        //        // if (false) {
-        //        // sb.append("&");wct
-        //        // sb.append("wreq=jjjj");
-        //        // }
-        //        // if (false) {
-        //        // sb.append("&");
-        //        // sb.append("wct=").append("jjjj");
-        //        // }
-
-
     }
 
 }

Added: cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipalImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipalImpl.java?rev=1329984&view=auto
==============================================================================
--- cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipalImpl.java
(added)
+++ cxf/sandbox/fediz/fediz-tomcat/src/main/java/org/apache/cxf/fediz/tomcat/FederationPrincipalImpl.java
Tue Apr 24 20:06:03 2012
@@ -0,0 +1,24 @@
+package org.apache.cxf.fediz.tomcat;
+
+import java.util.List;
+
+import org.apache.catalina.realm.GenericPrincipal;
+import org.apache.cxf.fediz.core.Claim;
+import org.apache.cxf.fediz.core.ClaimCollection;
+import org.apache.cxf.fediz.core.FederationPrincipal;
+
+public class FederationPrincipalImpl extends GenericPrincipal implements FederationPrincipal
{
+
+    protected ClaimCollection claims;
+
+    public FederationPrincipalImpl(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