Environment Description:

ubuntu14.04

CAS5.2.3

Java1.8.0 _111

Cas project engineering adopted: github.com/apereo/cas-…

1. Go to cas-overlay-Template, open build.sh, and edit the following content

# override DNAME and CERT_SUBJ_ALT_NAMES before calling or use dummy values DNAME="${DNAME:-CN=cas.example.org,OU=Example,OU=Org,C=CN}" CERT_SUBJ_ALT_NAMES = "${CERT_SUBJ_ALT_NAMES:-dns:example.org, DNS: localhost, IP: 127.0.0.1}" echo "Generating keystore for CAS with DN ${DNAME}" keytool -genkeypair -alias cas -keyalg RSA -keypass changeit -storepass changeit -keystore /etc/cas/thekeystore -dname ${DNAME} -ext SAN=${CERT_SUBJ_ALT_NAMES} keytool -exportcert -alias cas -storepass changeit -keystore /etc/cas/thekeystore -file /etc/cas/cas.cerCopy the code

CN=cas.example.org,OU=Example,OU=Org,C=CN, and -dns:example.org.

Run the following commands in sequence

Build. sh package // Generate the key, build.sh gencert // copy the key to /etc/cas/ directory build.sh copyCopy the code

NOTE:

When generating the key, you can modify parameters such as password, encryption algorithm, and file path. The key command is as follows (view the gencert method body in build.sh) :

keytool -genkeypair -alias cas -keyalg RSA -keypass changeit -storepass changeit -keystore /etc/cas/thekeystore -dname ${DNAME} -ext SAN=${CERT_SUBJ_ALT_NAMES}
keytool -exportcert -alias cas -storepass changeit -keystore /etc/cas/thekeystore -file /etc/cas/cas.cer
Copy the code

2. Modify the pom. XML file to add mysql dependencies

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apereo.cas</groupId>
    <artifactId>cas-overlay</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>com.rimerosolutions.maven.plugins</groupId>
                <artifactId>wrapper-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <verifyDownload>true</verifyDownload>
                    <checksumAlgorithm>MD5</checksumAlgorithm>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${springboot.version}</version>
                <configuration>
                    <mainClass>${mainClassName}</mainClass>
                    <addResources>true</addResources>
                    <executable>${isExecutable}</executable>
                    <layout>WAR</layout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warName>cas</warName>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <recompressZippedFiles>false</recompressZippedFiles>
                    <archive>
                        <compress>false</compress>
                        <manifestFile>${manifestFileToUse}</manifestFile>
                    </archive>
                    <overlays>
                        <overlay>
                            <groupId>org.apereo.cas</groupId>
                            <artifactId>cas-server-webapp${app.server}</artifactId>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
            </plugin>
        </plugins>
        <finalName>cas</finalName>
    </build>

    <properties>
        <cas.version>5.2.3</cas.version>
        <springboot.version>1.5.8.RELEASE</springboot.version>
        <!-- app.server could be -jetty, -undertow, -tomcat, or blank if you plan to provide appserver -->
        <app.server>-tomcat</app.server>

        <mainClassName>org.springframework.boot.loader.WarLauncher</mainClassName>
        <isExecutable>false</isExecutable>
        <manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF</manifestFileToUse>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
            <id>sonatype-releases</id>
            <url>http://oss.sonatype.org/content/repositories/releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
        <repository>
            <id>sonatype-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
        <repository>
            <id>shibboleth-releases</id>
            <url>https://build.shibboleth.net/nexus/content/repositories/releases</url>
        </repository>
    </repositories>

    <profiles>
        <profile>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <id>default</id>
            <dependencies>
                <dependency>
                    <groupId>org.apereo.cas</groupId>
                    <artifactId>cas-server-webapp${app.server}</artifactId>
                    <version>${cas.version}</version>
                    <type>war</type>
                    <scope>runtime</scope>
                </dependency>
                <!--
                ...Additional dependencies may be placed here...
                -->
		<dependency>
		    <groupId>org.apereo.cas</groupId>
		    <artifactId>cas-server-support-jdbc</artifactId>
		    <version>${cas.version}</version>
		</dependency>
		<dependency>
		   <groupId>org.apereo.cas</groupId>
		   <artifactId>cas-server-support-jdbc-drivers</artifactId>
		   <version>${cas.version}</version>
		</dependency>
		<dependency>
		    <groupId>mysql</groupId>
		    <artifactId>mysql-connector-java</artifactId>
		    <version>5.1.46</version>
		</dependency>
            </dependencies>
        </profile>

        <profile>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <id>exec</id>
            <properties>
                <mainClassName>org.apereo.cas.web.CasWebApplication</mainClassName>
                <isExecutable>true</isExecutable>
                <manifestFileToUse></manifestFileToUse>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.soebes.maven.plugins</groupId>
                        <artifactId>echo-maven-plugin</artifactId>
                        <version>0.3.0</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>echo</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <echos>
                                <echo>Executable profile to make the generated CAS web application executable.</echo>
                            </echos>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <id>bootiful</id>
            <properties>
                <app.server>-tomcat</app.server>
                <isExecutable>false</isExecutable>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.apereo.cas</groupId>
                    <artifactId>cas-server-webapp${app.server}</artifactId>
                    <version>${cas.version}</version>
                    <type>war</type>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <id>pgp</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.s4u.plugins</groupId>
                        <artifactId>pgpverify-maven-plugin</artifactId>
                        <version>1.1.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <pgpKeyServer>hkp://pool.sks-keyservers.net</pgpKeyServer>
                            <pgpKeysCachePath>${settings.localRepository}/pgpkeys-cache</pgpKeysCachePath>
                            <scope>test</scope>
                            <verifyPomFiles>true</verifyPomFiles>
                            <failNoSignature>false</failNoSignature>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
Copy the code

Create a SRC /main/resources folder and copy the following files from target/cas/ web-info /classes

Application. The properties,

Application. Yml,

Log4j2. XML.

Application.properties looks like this (note the MSYQL section) :

## # CAS Server Context Configuration # server.context-path=/cas server.port=8443 server.ssl.key-store=file:/etc/cas/thekeystore server.ssl.key-store-password=changeit server.ssl.key-password=changeit #  server.ssl.ciphers= # server.ssl.client-auth= server.ssl.enabled=true # server.ssl.key-alias= # server.ssl.key-store-provider= # server.ssl.key-store-type= # server.ssl.protocol= # server.ssl.trust-store= # server.ssl.trust-store-password= # server.ssl.trust-store-provider= # server.ssl.trust-store-type= server.max-http-header-size=2097152 server.use-forward-headers=true server.connection-timeout=20000 server.error.include-stacktrace=ALWAYS server.compression.enabled=true server.compression.mime-types=application/javascript,application/json,application/xml,text/html,text/xml,text/plain server.tomcat.max-http-post-size=2097152 server.tomcat.basedir=build/tomcat server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms) server.tomcat.accesslog.suffix=.log server.tomcat.max-threads=10 server.tomcat.port-header=X-Forwarded-Port server.tomcat.protocol-header=X-Forwarded-Proto server.tomcat.protocol-header-https-value=https server.tomcat.remote-ip-header=X-FORWARDED-FOR server.tomcat.uri-encoding=UTF-8 spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true spring.http.encoding.force=true ## # CAS Cloud Bus Configuration # spring.cloud.bus.enabled=false # spring.cloud.bus.refresh.enabled=true # spring.cloud.bus.env.enabled=true # spring.cloud.bus.destination=CasCloudBus # spring.cloud.bus.ack.enabled=true endpoints.enabled=false endpoints.sensitive=true endpoints.restart.enabled=false endpoints.shutdown.enabled=false management.security.enabled=true management.security.roles=ACTUATOR,ADMIN management.security.sessions=if_required management.context-path=/status management.add-application-context-header=false  security.basic.authorize-mode=role security.basic.enabled=false security.basic.path=/cas/status/** ## # CAS Web Application Session Configuration # server.session.timeout=300 server.session.cookie.http-only=true server.session.tracking-modes=COOKIE ## # CAS Thymeleaf View Configuration # spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.cache=true spring.thymeleaf.mode=HTML ## # CAS Log4j Configuration # # logging.config=file:/etc/cas/log4j2.xml server.context-parameters.isLog4jAutoInitializationDisabled=true ## # CAS AspectJ Configuration # spring.aop.auto=true spring.aop.proxy-target-class=true ## # CAS Authentication Credentials # # cas.authn.accept.users=casuser::Mellon cas.server.name: https://cas.example.org:8443 cas.server.prefix: https://cas.example.org:8443/cas cas. AdminPagesSecurity. IP = 127.0.0.1 cas. Authn. JDBC. The query [0]. SQL = SELECT * FROM the users WHERE username=? cas.authn.jdbc.query[0].healthQuery= cas.authn.jdbc.query[0].isolateInternalQueries=false Cas. Authn. JDBC. The query [0]. Url = JDBC: mysql: / / 127.0.0.1:3306 / raidclouds? UseUnicode = true&characterEncoding = utf-8 & autoReconnect =true&useSSL=false cas.authn.jdbc.query[0].failFastTimeout=1 cas.authn.jdbc.query[0].isolationLevelName=ISOLATION_READ_COMMITTED cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQL5InnoDBDialect cas.authn.jdbc.query[0].leakThreshold=10 cas.authn.jdbc.query[0].propagationBehaviorName=PROPAGATION_REQUIRED cas.authn.jdbc.query[0].batchSize=1 cas.authn.jdbc.query[0].user=root cas.authn.jdbc.query[0].ddlAuto=create-drop cas.authn.jdbc.query[0].maxAgeDays=180 cas.authn.jdbc.query[0].password=123456 cas.authn.jdbc.query[0].autocommit=false cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver cas.authn.jdbc.query[0].idleTimeout=5000 # cas.authn.jdbc.query[0].credentialCriteria= # cas.authn.jdbc.query[0].name= # cas.authn.jdbc.query[0].order=0 # cas.authn.jdbc.query[0].dataSourceName= cas.authn.jdbc.query[0].dataSourceProxy=false # Hibernate-specific properties (i.e. `hibernate.globally_quoted_identifiers`) cas.authn.jdbc.query[0].properties.propertyName=propertyValue cas.authn.jdbc.query[0].fieldPassword=password cas.authn.jdbc.query[0].fieldExpired=expired cas.authn.jdbc.query[0].fieldDisabled=disabled cas.authn.jdbc.query[0].principalAttributeList=sn,cn:commonName,givenName  cas.authn.jdbc.query[0].passwordEncoder.type=NONE cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8 # cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm= # cas.authn.jdbc.query[0].passwordEncoder.secret= # cas.authn.jdbc.query[0].passwordEncoder.strength=16 # cas.authn.jdbc.query[0].principalTransformation.pattern=(.+)@example.org # cas.authn.jdbc.query[0].principalTransformation.groovy.location=file:///etc/cas/config/principal.groovy # cas.authn.jdbc.query[0].principalTransformation.suffix= # cas.authn.jdbc.query[0].principalTransformation.caseConversion=NONE|UPPERCASE|LOWERCASE # cas.authn.jdbc.query[0].principalTransformation.prefix=Copy the code

Mysql > select * from ‘mysql’;

The log4j2.xml file is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- Specify the refresh internal in seconds. -->
<Configuration monitorInterval="5" packages="org.apereo.cas.logging">
    <Properties>
        <!-- 
        Default log directory is the current directory but that can be overridden with -Dcas.log.dir=<logdir>
        Or you can change this property to a new default
        -->
        <Property name="cas.log.dir" >logs</Property>
        <!-- To see more CAS specific logging, adjust this property to info or debug or run server with -Dcas.log.leve=debug -->
        <Property name="cas.log.level" >debug</Property>
    </Properties>
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %p [%c] - <%m>%n"/>
        </Console>
        <RollingFile name="file" fileName="${sys:cas.log.dir}/cas.log" append="true"
                     filePattern="${sys:cas.log.dir}/cas-%d{yyyy-MM-dd-HH}-%i.log">
            <PatternLayout pattern="%d %p [%c] - <%m>%n"/>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="10 MB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
        <RollingFile name="auditlogfile" fileName="${sys:cas.log.dir}/cas_audit.log" append="true"
                     filePattern="${sys:cas.log.dir}/cas_audit-%d{yyyy-MM-dd-HH}-%i.log">
            <PatternLayout pattern="%d %p [%c] - %m%n"/>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="10 MB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>

        <RollingFile name="perfFileAppender" fileName="${sys:cas.log.dir}/perfStats.log" append="true"
                     filePattern="${sys:cas.log.dir}/perfStats-%d{yyyy-MM-dd-HH}-%i.log">
            <PatternLayout pattern="%m%n"/>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="10 MB"/>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>

        <CasAppender name="casAudit">
            <AppenderRef ref="auditlogfile" />
        </CasAppender>
        <CasAppender name="casFile">
            <AppenderRef ref="file" />
        </CasAppender>
        <CasAppender name="casConsole">
            <AppenderRef ref="console" />
        </CasAppender>
        <CasAppender name="casPerf">
            <AppenderRef ref="perfFileAppender" />
        </CasAppender>
    </Appenders>
    <Loggers>
        <!-- If adding a Logger with level set higher than warn, make category as selective as possible -->
        <!-- Loggers inherit appenders from Root Logger unless additivity is false -->
        <AsyncLogger name="org.apereo" level="${sys:cas.log.level}" includeLocation="true"/>
        <AsyncLogger name="org.apereo.services.persondir" level="${sys:cas.log.level}" includeLocation="true"/>
        <AsyncLogger name="org.apereo.cas.web.flow" level="info" includeLocation="true"/>
        <AsyncLogger name="org.apache" level="warn" />
        <AsyncLogger name="org.apache.http" level="error" />
        <AsyncLogger name="org.springframework" level="warn" />
        <AsyncLogger name="org.springframework.cloud.server" level="warn" />
        <AsyncLogger name="org.springframework.cloud.client" level="warn" />
        <AsyncLogger name="org.springframework.cloud.bus" level="warn" />
        <AsyncLogger name="org.springframework.aop" level="warn" />
        <AsyncLogger name="org.springframework.boot" level="warn" />
        <AsyncLogger name="org.springframework.boot.actuate.autoconfigure" level="warn" />
        <AsyncLogger name="org.springframework.webflow" level="warn" />
        <AsyncLogger name="org.springframework.session" level="warn" />
        <AsyncLogger name="org.springframework.amqp" level="error" />
        <AsyncLogger name="org.springframework.integration" level="warn" />
        <AsyncLogger name="org.springframework.messaging" level="warn" />
        <AsyncLogger name="org.springframework.web" level="warn" />
        <AsyncLogger name="org.springframework.orm.jpa" level="warn" />
        <AsyncLogger name="org.springframework.scheduling" level="warn" />
        <AsyncLogger name="org.springframework.context.annotation" level="error" />
        <AsyncLogger name="org.springframework.boot.devtools" level="error" />
        <AsyncLogger name="org.springframework.web.socket" level="warn" />
        <AsyncLogger name="org.thymeleaf" level="warn" />
        <AsyncLogger name="org.pac4j" level="warn" />
        <AsyncLogger name="org.opensaml" level="warn"/>
        <AsyncLogger name="net.sf.ehcache" level="warn" />
        <AsyncLogger name="com.couchbase" level="warn" includeLocation="true"/>
        <AsyncLogger name="com.ryantenney.metrics" level="warn" />
        <AsyncLogger name="net.jradius" level="warn" />
        <AsyncLogger name="org.openid4java" level="warn" />
        <AsyncLogger name="org.ldaptive" level="debug" additivity="false">
	    <AppenderRef ref="console"/>
	    <AppenderRef ref="file"/>
	</AsyncLogger>
        <AsyncLogger name="com.hazelcast" level="warn" />
        <AsyncLogger name="org.apereo.spring" level="warn" />

        <!-- Log perf stats only to perfStats.log -->
        <AsyncLogger name="perfStatsLogger" level="info" additivity="false" includeLocation="true">
            <AppenderRef ref="casPerf"/>
        </AsyncLogger>

        <!-- Log audit to all root appenders, and also to audit log (additivity is not false) -->
        <AsyncLogger name="org.apereo.inspektr.audit.support" level="info" includeLocation="true" >
            <AppenderRef ref="casAudit"/>
        </AsyncLogger>

        <!-- All Loggers inherit appenders specified here, unless additivity="false" on the Logger -->
        <AsyncRoot level="debug">
            <AppenderRef ref="casFile"/>
            <!-- 
                 For deployment to an application server running as service, 
                 delete the casConsole appender below
            -->
            <AppenderRef ref="casConsole"/>
        </AsyncRoot>
    </Loggers>
</Configuration>
Copy the code

The BASIC CAS configuration is complete.

3. Run the script

build.sh run
Copy the code

Reference:

Github.com/apereo/cas-…

Apereo. Making. IO/cas / 5.2 x/I…

Apereo. Making. IO/cas / 5.2 x/I…

Stackoverflow.com/questions/4…

gs98.cn/article/23

B2bbp.next-level-help.org/B2B_Install…

Wiki.shibboleth.net/confluence/…