Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:apereo/wsfed-sample-java-webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed Apr 8, 2022
2 parents 67f5cfd + fee3f24 commit dd70847
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 120 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.sh text eol=lf
gradlew text eol=lf
*.java text eol=lf
*.xml text eol=lf
*.properties text eol=lf
*.txt text eol=lf
*.json text eol=lf
*.html text eol=lf
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
runs-on: ${{ matrix.os }}
needs: cancel-previous-runs
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: ${{ env.JDK_CURRENT }}
distribution: 'temurin'
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.gradle
build/
.idea
classes
*.iml
bin/
.classpath
.project
.settings/
.vscode/

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ You will need a keystore at `/etc/cas/thekeystore`.
See:

- `WEB-INF/fediz.xml`
- `WEB-INF/applicationContext-security.xml`
- `src/main/webapp/fediz.xml`
- `src/main/webapp/applicationContext-security.xml`

Binary file not shown.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
}

dependencies {
classpath "org.gretty:gretty:3.0.6"
classpath "org.gretty:gretty:3.0.7"
}
}

Expand Down Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation "org.slf4j:slf4j-api:${project.slf4jVersion}"
implementation "org.slf4j:slf4j-log4j12:${project.slf4jVersion}"
implementation "org.slf4j:jcl-over-slf4j:${project.slf4jVersion}"
implementation "org.slf4j:jul-to-slf4j:${project.slf4jVersion}"

implementation "org.apache.cxf.fediz:fediz-core:${project.fedizVersion}"
implementation "org.apache.cxf.fediz:fediz-spring:${project.fedizVersion}"
Expand All @@ -63,13 +64,14 @@ dependencies {

implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'log4j:log4j:1.2.17'
implementation 'joda-time:joda-time:2.7'
implementation 'joda-time:joda-time:2.10.14'
implementation 'org.jasypt:jasypt:1.9.3'
implementation 'net.sf.ehcache:ehcache:2.10.9.2'
implementation 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.6"
implementation "se.jiderhamn.classloader-leak-prevention:classloader-leak-prevention-servlet:2.7.0"

}

Expand Down Expand Up @@ -101,6 +103,7 @@ gretty {
programArgs.add("-Xdebug")
programArgs.add("-Xrunjdwp:transport=dt_socket,address=5008,server=y,suspend=n")
}
programArgs.add("-Djava.util.logging.config.file=./src/main/resources/logging.properties")
logger.info("Program arguments: " + programArgs)

jvmArgs = programArgs
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 19 additions & 0 deletions src/main/java/org/apereo/cas/ClassLoaderLeakPreventorListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.apereo.cas;

import org.slf4j.bridge.SLF4JBridgeHandler;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Extend ClassLoaderLeakPreventorListener to override standard logger (route it to slf4j) so we can control logging.
* This might risk classloader leak but we just want threads stopped.
*/
public class ClassLoaderLeakPreventorListener
extends se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventorListener {
static {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Logger.getLogger("").setLevel(Level.FINEST);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootLogger=INFO, CONSOLE
log4j.logger.org.springframework=INFO, CONSOLE
log4j.additivity.org.springframework=false
log4j.logger.org.springframework.security=DEBUG, CONSOLE
log4j.additivity.org.springframework.security=false
log4j.logger.org.apache.cxf.fediz=DEBUG, CONSOLE
log4j.additivity.org.apache.cxf.fediz=false
log4j.logger.org.springframework=INFO
log4j.logger.org.springframework.security=DEBUG
log4j.logger.org.springframework.security.web.access.ExceptionTranslationFilter=INFO
log4j.logger.org.apache.cxf.fediz=DEBUG


# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
Expand All @@ -20,3 +19,6 @@ log4j.appender.LOGFILE.Append=false
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

# Logging for ClassLoader Leak Prevention
log4j.logger.se.jiderhamn.classloader.leak.prevention=ERROR
File renamed without changes.
File renamed without changes.
179 changes: 97 additions & 82 deletions WEB-INF/web.xml → src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,82 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true">

<description>WS Federation Spring Example</description>
<display-name>WS Federation Spring Example</display-name>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<!-- Optional: Cache the security token in Thread Local Storage -->
<filter>
<filter-name>FederationFilter</filter-name>
<filter-class>org.apache.cxf.fediz.core.servlet.FederationFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>FederationFilter</filter-name>
<url-pattern>/secure/*</url-pattern>
</filter-mapping>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-security.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>FederationServlet</servlet-name>
<servlet-class>org.apereo.cas.FederationServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/admin/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/user/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/manager/fedservlet</url-pattern>
</servlet-mapping>

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0" metadata-complete="true">

<description>WS Federation Spring Example</description>
<display-name>WS Federation Spring Example</display-name>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-security.xml</param-value>
</context-param>

<context-param>
<param-name>ClassLoaderLeakPreventor.threadWaitMs</param-name>
<param-value>100</param-value>
</context-param>

<context-param>
<param-name>ClassLoaderLeakPreventor.shutdownHookWaitMs</param-name>
<param-value>200</param-value>
</context-param>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<!-- Optional: Cache the security token in Thread Local Storage -->
<filter>
<filter-name>FederationFilter</filter-name>
<filter-class>org.apache.cxf.fediz.core.servlet.FederationFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>FederationFilter</filter-name>
<url-pattern>/secure/*</url-pattern>
</filter-mapping>

<!--ClassLoaderLeakPreventorListener should be first (outermost) listener-->
<listener>
<listener-class>org.apereo.cas.ClassLoaderLeakPreventorListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>FederationServlet</servlet-name>
<servlet-class>org.apereo.cas.FederationServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/admin/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/user/fedservlet</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>FederationServlet</servlet-name>
<url-pattern>/secure/manager/fedservlet</url-pattern>
</servlet-mapping>

</web-app>
File renamed without changes.
44 changes: 22 additions & 22 deletions index.html → src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>WS Federation Sample Web Application</TITLE>
<META http-equiv=Content-Type content="text/html">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" type="text/javascript"></script>
</HEAD>
<body>

<div class="container">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">WS Federation Sample Web Application</h1>
<p class="col-md-8 fs-4">This is a sample application that acts as a WS Federation client using Apache Fediz.</p>
<p><a id="logincas" class="btn btn-lg btn-success" href="/fediz/secure/fedservlet" role="button">Login with CAS</a></p>
</div>
</div>
</div>
</body>

</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML lang="en">
<HEAD>
<TITLE>WS Federation Sample Web Application</TITLE>
<META http-equiv=Content-Type content="text/html">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" type="text/javascript"></script>
</HEAD>
<body>

<div class="container">
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">WS Federation Sample Web Application</h1>
<p class="col-md-8 fs-4">This is a sample application that acts as a WS Federation client using Apache Fediz.</p>
<p><a id="logincas" class="btn btn-lg btn-success" href="/fediz/secure/fedservlet" role="button">Login with CAS</a></p>
</div>
</div>
</div>
</body>

</HTML>
2 changes: 1 addition & 1 deletion secure/test.html → src/main/webapp/secure/test.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>WS Federation Tomcat Examples</TITLE>
<HTML lang="en"><HEAD><TITLE>WS Federation Tomcat Examples</TITLE>
<META http-equiv=Content-Type content="text/html">
</HEAD>
<BODY>
Expand Down

0 comments on commit dd70847

Please sign in to comment.