Single Sign-On CAS (8): Using maven overlay to implement non-intrusive CAS and mavenoverlay

Source: Internet
Author: User

Single Sign-On CAS (8): Using maven overlay to implement non-intrusive CAS and mavenoverlay

In the early stages of learning CAS deployment, there were various online tutorials and various solutions kept trying.

During this period, the source code was changed by various intrusions. After a long time, it may be hard to find out which file, which configuration was modified, and which code was added.

The biggest problem is, how can I start if I want to change my personal maintenance or upgrade the CAS version one day?

 

Fortunately, the maven overlay function can help me solve this problem.

What is maven overlay?

Overlay can merge multiple project war files into one project. If the project has a file with the same name, the files in the main project overwrite the files of the same name in other projects.

So I can implement cas without modifying the original CAS-server-webapp code.

 

Step 1: Create my-cas-server

CAS-server-webapp is the main project by default. The user logon authentication portal, user logon page, and various master configuration files are included in this project.

Now, I want to import the newly created my-cas-server as my main project, and the cas-server-core project as a subordinate project to the main project.

Pom. xml of my-cas-server

        <dependency>            <groupId>org.jasig.cas</groupId>            <artifactId>cas-server-webapp</artifactId>            <version>3.4.11</version>            <type>war</type>            <scope>runtime</scope>        </dependency>

 

Step 2: Set overlays

Overlay is used to overwrite files of the same name in a subordinate project. This means that if a file with the same directory and name as the cas-server-webapp project exists in the main project, that is, the file that overwrites the subordinate project.

Add:

    <build>        <plugins>            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-war-plugin</artifactId>                <configuration>                    <overlays>                        <overlay>                            <groupId>org.jasig.cas</groupId>                            <artifactId>cas-server-webapp</artifactId>                        </overlay>                    </overlays>                </configuration>            </plugin>        </plugins>    </build>

 

Step 3: copy an object with the same name

List all the source code and configuration files of the cas-server-webapp modified previously, and copy them to the same directory of my-cas-server.

For example, I have modified some code before (some code)

UsernamePasswordCredentials.java

AuthenticationViaFormAction.java

webapp/WEB-INF/

|--classes

  |---cas-theme-default.properties

  |---default_views.properties

  |---messages_zh_CN.properties

|--spring-configuration

  |----ticketRegistry.xml

cas-servlet.xml

deployerConfigContext.xml

login-webflow.xml

web.xml

Similarly, I copied all these files to the new project, and the directory is consistent with that of the original project.

 

Step 4: Start my-cas-server to test the effect

After it is started, it is found that the effect is exactly the same as before. It can be accessed normally or authenticated normally.

 

Extension:

After the overlay method is used, you can not only modify the source code for CAS transformation, but also find that the degree of freedom of encoding is greatly increased, and you do not need to be limited by the constraints of the original project.

For example, if I want to beautify the login page, it would be too simple.

I can develop a new logon page as usual, and then replace the default logon page in the configuration file.

Modify default_views.properties.

### Login view (/login)casLoginView.(class)=org.springframework.web.servlet.view.JstlViewcasLoginView.url=/WEB-INF/view/jsp/default/ui/casLoginView.jsp

 

-->

### Login view (/login)casLoginView.(class)=org.springframework.web.servlet.view.JstlViewcasLoginView.url=/WEB-INF/jsp/login.jsp

 

Restart and run.

 

Single Sign-On CAS series:

  • Single Sign-On CAS Usage Note (1): preparations and configuration of SSL protocol for CAS-Server
  • Single Sign-On CAS Usage Note (2): deploy CAS servers and clients
  • Single Sign-On CAS Usage Note (3): Implement custom authentication for User Login
  • Single Sign-On CAS Usage Note (4): Add a verification code to the logon page
  • Single Sign-On CAS Usage Note (5): cas-client does not intercept static resources and does not require logon requests.
  • CAS usage notes for Single Sign-On (6): single sign-off and single sign-off
  • CAS usage for Single Sign-On (7): Analysis on server timeout and client timeout
  • Single Sign-On CAS Usage Note (8): Using maven overlay to implement non-intrusive CAS Transformation

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.