Author: anil.saldhana(a)jboss.com
Date: 2012-02-07 17:37:52 -0500 (Tue, 07 Feb 2012)
New Revision: 1379
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/TomcatRoleGenerator.java
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SAML11SPRedirectFormAuthenticator.java
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaContext.java
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaResponse.java
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaSession.java
Log:
JBossWeb7 related changes
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -103,8 +103,7 @@
{
this.subjectInteractionClassName = subjectRetrieverClassName;
}
-
- @Override
+
public boolean authenticate(Request request, Response response, LoginConfig
loginConfig) throws IOException
{
log.trace("Authenticating user");
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/TomcatRoleGenerator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/TomcatRoleGenerator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/TomcatRoleGenerator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -24,11 +24,8 @@
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
-import org.apache.catalina.Role;
-import org.apache.catalina.User;
import org.apache.catalina.realm.GenericPrincipal;
import org.picketlink.identity.federation.core.ErrorCodes;
import org.picketlink.identity.federation.core.interfaces.RoleGenerator;
@@ -44,7 +41,7 @@
* @see RoleGenerator#generateRoles(Principal)
* @throws IllegalArgumentException if principal is not of type GenericPrincipal or
User
*/
- public List<String> generateRoles(Principal principal)
+ /*public List<String> generateRoles(Principal principal)
{
String className = principal.getClass().getCanonicalName();
@@ -70,5 +67,28 @@
}
}
return userRoles;
+ }*/
+
+
+ /**
+ * @see RoleGenerator#generateRoles(Principal)
+ * @throws IllegalArgumentException if principal is not of type GenericPrincipal or
User
+ */
+ public List<String> generateRoles(Principal principal)
+ {
+ String className = principal.getClass().getCanonicalName();
+
+ if (principal instanceof GenericPrincipal == false)
+ throw new IllegalArgumentException(ErrorCodes.WRONG_TYPE + "principal is
not tomcat principal:" + className);
+ List<String> userRoles = new ArrayList<String>();
+
+ if (principal instanceof GenericPrincipal)
+ {
+ GenericPrincipal gp = (GenericPrincipal) principal;
+ String[] roles = gp.getRoles();
+ if (roles.length > 0)
+ userRoles.addAll(Arrays.asList(roles));
+ }
+ return userRoles;
}
}
\ No newline at end of file
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/BaseFormAuthenticator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -249,7 +249,6 @@
* call and save it. Subsquent invocations utilize the saved {@link Method}
* @see
org.apache.catalina.authenticator.AuthenticatorBase#register(org.apache.catalina.connector.Request,
org.apache.catalina.connector.Response, java.security.Principal, java.lang.String,
java.lang.String, java.lang.String)
*/
- @Override
protected void register(Request request, Response response, Principal principal,
String arg3, String arg4,
String arg5)
{
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SAML11SPRedirectFormAuthenticator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SAML11SPRedirectFormAuthenticator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SAML11SPRedirectFormAuthenticator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -29,6 +29,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.catalina.Session;
import org.apache.catalina.authenticator.Constants;
import org.apache.catalina.connector.Request;
@@ -139,7 +141,7 @@
{
this.restoreRequest(request, session);
}
- register(request, response, principal, Constants.FORM_METHOD, username,
password);
+ register(request, response, principal, HttpServletRequest.FORM_AUTH,
username, password);
return true;
}
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPPostFormAuthenticator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -30,6 +30,7 @@
import java.util.Set;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Session;
@@ -115,7 +116,6 @@
throw new RuntimeException(ErrorCodes.SERVICE_PROVIDER_NOT_CATALINA_RESPONSE);
}
- @Override
public boolean authenticate(Request request, Response response, LoginConfig
loginConfig) throws IOException
{
Session session = request.getSessionInternal(true);
@@ -306,7 +306,7 @@
{
this.restoreRequest(request, session);
}
- register(request, response, principal, Constants.FORM_METHOD, username,
password);
+ register(request, response, principal, HttpServletRequest.FORM_AUTH,
username, password);
return true;
}
Modified:
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/main/java/org/picketlink/identity/federation/bindings/tomcat/sp/SPRedirectFormAuthenticator.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -32,6 +32,7 @@
import java.util.StringTokenizer;
import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Session;
@@ -106,8 +107,7 @@
}
throw new RuntimeException(ErrorCodes.SERVICE_PROVIDER_NOT_CATALINA_RESPONSE);
}
-
- @Override
+
public boolean authenticate(Request request, Response response, LoginConfig
loginConfig) throws IOException
{
Session session = request.getSessionInternal(true);
@@ -322,7 +322,7 @@
{
this.restoreRequest(request, session);
}
- register(request, response, principal, Constants.FORM_METHOD, username,
password);
+ register(request, response, principal, HttpServletRequest.FORM_AUTH,
username, password);
return true;
}
Modified:
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaContext.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaContext.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaContext.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -27,6 +27,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
+import java.util.EventListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -41,6 +42,7 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import org.apache.catalina.Authenticator;
import org.apache.catalina.Cluster;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerListener;
@@ -49,6 +51,7 @@
import org.apache.catalina.Manager;
import org.apache.catalina.Pipeline;
import org.apache.catalina.Realm;
+import org.apache.catalina.ThreadBindingListener;
import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
@@ -56,12 +59,15 @@
import org.apache.catalina.deploy.ErrorPage;
import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.deploy.FilterMap;
+import org.apache.catalina.deploy.JspPropertyGroup;
import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.deploy.SecurityConstraint;
+import org.apache.catalina.deploy.SessionCookie;
+import org.apache.catalina.deploy.jsp.TagLibraryInfo;
import org.apache.catalina.util.CharsetMapper;
-import org.apache.juli.logging.Log;
+import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.util.http.mapper.Mapper;
+import org.jboss.logging.Logger;
/**
* Mock Catalina Context
@@ -131,12 +137,6 @@
throw new RuntimeException("NYI");
}
- public Log getLogger()
- {
-
- throw new RuntimeException("NYI");
- }
-
public Manager getManager()
{
@@ -536,11 +536,6 @@
throw new RuntimeException("NYI");
}
- public NamingResources getNamingResources()
- {
- throw new RuntimeException("NYI");
- }
-
public boolean getOverride()
{
return false;
@@ -734,10 +729,6 @@
{
}
- public void setNamingResources(NamingResources arg0)
- {
- }
-
public void setOverride(boolean arg0)
{
}
@@ -961,4 +952,163 @@
{
this.attribs.put(arg0, arg1);
}
+
+ @Override
+ public boolean isStarted()
+ {
+ return false;
+ }
+
+ @Override
+ public Logger getLogger()
+ {
+ return null;
+ }
+
+ @Override
+ public void fireContainerEvent(String type, Object data)
+ {
+ }
+
+ @Override
+ public void addSessionTrackingMode(String trackingMode)
+ {
+ }
+
+ @Override
+ public Authenticator getAuthenticator()
+ {
+ return null;
+ }
+
+ @Override
+ public void setAuthenticator(Authenticator authenticator)
+ {
+ }
+
+ @Override
+ public Object[] getApplicationSessionLifecycleListeners()
+ {
+ return null;
+ }
+
+ @Override
+ public void setApplicationSessionLifecycleListeners(Object[] listeners)
+ {
+ }
+
+ @Override
+ public boolean isStarting()
+ {
+ return false;
+ }
+
+ @Override
+ public void setStarting(boolean starting)
+ {
+ }
+
+ @Override
+ public void setSessionCookie(SessionCookie sessionCookie)
+ {
+ }
+
+ @Override
+ public SessionCookie getSessionCookie()
+ {
+ return null;
+ }
+
+ @Override
+ public InstanceManager getInstanceManager()
+ {
+ return null;
+ }
+
+ @Override
+ public void setInstanceManager(InstanceManager instanceManager)
+ {
+ }
+
+ @Override
+ public String getLogicalName()
+ {
+ return null;
+ }
+
+ @Override
+ public void setLogicalName(String logicalName)
+ {
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return null;
+ }
+
+ @Override
+ public int getVersionMajor()
+ {
+ return 0;
+ }
+
+ @Override
+ public int getVersionMinor()
+ {
+ return 0;
+ }
+
+ @Override
+ public void setVersion(String version)
+ {
+ }
+
+ @Override
+ public <T extends EventListener> void addApplicationListenerInstance(T
listener)
+ {
+ }
+
+ @Override
+ public void addFilterMapBefore(FilterMap filterMap)
+ {
+ }
+
+ @Override
+ public void addJspPropertyGroup(JspPropertyGroup propertyGroup)
+ {
+ }
+
+ @Override
+ public void addJspTagLibrary(TagLibraryInfo tagLibraryInfo)
+ {
+ }
+
+ @Override
+ public void addJspTagLibrary(String uri, TagLibraryInfo tagLibraryInfo)
+ {
+ }
+
+ @Override
+ public JspPropertyGroup[] findJspPropertyGroups()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isInitialized()
+ {
+ return false;
+ }
+
+ @Override
+ public ThreadBindingListener getThreadBindingListener()
+ {
+ return null;
+ }
+
+ @Override
+ public void setThreadBindingListener(ThreadBindingListener threadBindingListener)
+ {
+ }
}
\ No newline at end of file
Modified:
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaResponse.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaResponse.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaResponse.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -94,6 +94,8 @@
@Override
public PrintWriter getWriter() throws IOException
{
+ if(mywriter == null)
+ mywriter = applicationWriter;
return this.mywriter;
}
Modified:
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaSession.java
===================================================================
---
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaSession.java 2012-02-07
22:37:18 UTC (rev 1378)
+++
product/branches/Branch_6_plus/picketlink-core/src/test/java/org/picketlink/test/identity/federation/bindings/mock/MockCatalinaSession.java 2012-02-07
22:37:52 UTC (rev 1379)
@@ -291,4 +291,10 @@
{
this.notes.clear();
}
+
+ @Override
+ public boolean isValidInternal()
+ {
+ return false;
+ }
}
\ No newline at end of file