Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J2EE Container Authentication #26

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added preAuth filter.
  • Loading branch information
Per Junel committed Nov 1, 2012
commit 80ac2c3a919507e264ee46c36ff03173adcc9b2d
14 changes: 12 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<classpathentry kind="lib" path="lib/httpclient-cache-4.1.3.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.1.4.jar"/>
<classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging.jar">
<attributes>
<attribute name="javadoc_location" value="http://jakarta.apache.org/commons/logging/apidocs/"/>
Expand Down Expand Up @@ -100,5 +99,16 @@
<classpathentry kind="lib" path="lib/jersey-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/jersey-server-1.3.jar"/>
<classpathentry kind="lib" path="lib/jersey-spring-1.3.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
<classpathentry kind="lib" path="lib/jaxen-1.1.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-6-openjdk-amd64">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>
7 changes: 3 additions & 4 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#Mon Jan 16 16:53:40 PST 2012
*=(?)Code placement information (within a file), used by Eclipse, for developing purposes.
**=
*/=
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
Expand Down
5 changes: 3 additions & 2 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="jst.web" version="2.4" />
<installed facet="jst.java" version="5.0" />
<runtime name="Apache Tomcat v6.0"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="jst.java" version="1.5"/>
</faceted-project>
25 changes: 25 additions & 0 deletions .settings/org.springframework.ide.eclipse.beans.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/aop=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/beans=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/context=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jee=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/jms=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/lang=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/p=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/security=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/tx=
//org.springframework.ide.eclipse.beans.core.default.version.http\://www.springframework.org/schema/util=
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/aop=aop
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/beans=beans
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/context=context
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/jee=jee
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/jms=jms
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/lang=lang
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/p=p
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/security=security
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/tx=tx
//org.springframework.ide.eclipse.beans.core.prefix.http\://www.springframework.org/schema/util=util
eclipse.preferences.version=1
org.springframework.ide.eclipse.beans.core.default.version.check.classpath=true
org.springframework.ide.eclipse.beans.core.enable.project.preferences=false
org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false
org.springframework.ide.eclipse.beans.core.loadNamespaceHandlerFromClasspath=true
12 changes: 11 additions & 1 deletion .settings/org.springframework.ide.eclipse.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#Sun Jan 15 01:49:57 PST 2012
eclipse.preferences.version=1
org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true
org.springframework.ide.eclipse.core.builders.enable.beanmetadatabuilder=true
org.springframework.ide.eclipse.core.builders.enable.osgibundleupdater=false
org.springframework.ide.eclipse.core.enable.project.preferences=false
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=false
org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.autowire.autowire-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true
Expand All @@ -19,6 +21,14 @@ org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.i
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.toolAnnotation-org.springframework.ide.eclipse.beans.core.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.AvoidDriverManagerDataSource-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ImportElementsAtTopRulee-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ParentBeanSpecifiesAbstractClassRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.RefElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.TooManyBeansInFileRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UnnecessaryValueElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UseBeanInheritance-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.legacyxmlusage.jndiobjectfactory-org.springframework.ide.eclipse.bestpractices.beansvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=false
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true
org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true
Expand Down
14 changes: 14 additions & 0 deletions .springBeans
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[3.1.0.201210040510-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>conf/applicationContext-security.xml</config>
</configs>
<configSets>
</configSets>
</beansProjectDescription>
48 changes: 43 additions & 5 deletions conf/applicationContext-security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,50 @@
filters="httpSessionContextIntegrationFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,ajaxExceptionTranslationFilter,filterInvocationInterceptor"
pattern="/ajax/**" />
<security:filter-chain
filters="httpSessionContextIntegrationFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor"
filters="httpSessionContextIntegrationFilter,j2eePreAuthFilter,logoutFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,exceptionTranslationFilter,filterInvocationInterceptor"
pattern="/**" />
</security:filter-chain-map>
</bean>


<bean id="preAuthenticatedUserDetailsService"
class="org.springframework.security.providers.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsService" />

<bean id="j2eePreAuthFilter"
class="org.springframework.security.ui.preauth.j2ee.J2eePreAuthenticatedProcessingFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="authenticationDetailsSource">
<bean
class="org.springframework.security.ui.preauth.j2ee.J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource">
<property name="mappableRolesRetriever">
<bean class="org.springframework.security.ui.preauth.j2ee.WebXmlMappableAttributesRetriever" >
<property name="webXmlInputStream">
<bean factory-bean="webXmlResource" factory-method="getInputStream" />
</property>
</bean>
</property>
<property name="userRoles2GrantedAuthoritiesMapper">
<bean
class="org.springframework.security.authoritymapping.SimpleAttributes2GrantedAuthoritiesMapper">
<property name="convertAttributeToUpperCase" value="true" />
</bean>
</property>
</bean>
</property>
</bean>

<bean id="webXmlResource" class="org.springframework.web.context.support.ServletContextResource" >
<constructor-arg ref="servletContext" />
<constructor-arg value="/WEB-INF/web.xml" />
</bean>
<bean id="servletContext" class="org.springframework.web.context.support.ServletContextFactoryBean" />

<!--
<bean id="preAuthenticatedProcessingFilterEntryPoint"
class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint" />
-->



<bean id="remoteServicesFilter" class="fi.hut.soberit.agilefant.security.RemoteServicesFilter" />

Expand Down Expand Up @@ -80,11 +120,9 @@
value="anonymousUser,ROLE_ANONYMOUS" />
</bean>

<bean id="exceptionTranslationFilter"
class="org.springframework.security.ui.ExceptionTranslationFilter">
<bean id="exceptionTranslationFilter" class="org.springframework.security.ui.ExceptionTranslationFilter">
<property name="authenticationEntryPoint">
<bean
class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<bean class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<property name="loginFormUrl" value="/login.jsp" />
<property name="forceHttps" value="false" />
</bean>
Expand Down
2 changes: 1 addition & 1 deletion conf/database-mysql5.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

hibernate.connection.username=agilefant
hibernate.connection.password=agilefant
hibernate.connection.url=jdbc:mysql://localhost/agilefant?relaxAutoCommit\=true&amp;autoReconnect\=true&amp;useUnicode\=true&amp;characterEncoding\=utf-8&amp;autoReconnectForPools\=true
hibernate.connection.url=jdbc:mysql://localhost:3306/agilefant?relaxAutoCommit\=true&amp;autoReconnect\=true&amp;useUnicode\=true&amp;characterEncoding\=utf-8&amp;autoReconnectForPools\=true
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.show_sql=false
Expand Down
Binary file added lib/jaxen-1.1.1.jar
Binary file not shown.
13 changes: 13 additions & 0 deletions web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@
<role-name>agilefantremote</role-name>
</auth-constraint>
</security-constraint>

<security-constraint>
<web-resource-collection>
<web-resource-name>Default</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
Expand All @@ -159,6 +169,9 @@
<security-role>
<role-name>agilefantreadonly</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>

<env-entry>
<env-entry-name>remoteEnabled</env-entry-name>
Expand Down