JSPWiki数据迁移以及同CAS整合

前端之家收集整理的这篇文章主要介绍了JSPWiki数据迁移以及同CAS整合前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1 JSPWiki数据迁移

1.1 内容数据迁移

1. 配置内容数据源

Tomcat.xml添加如下内容

<Resource name="PostgresqlDataSource"

auth="Container"

type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"

url="jdbc:postgresql://192.168.0.180:5432/jspwiki_trial"

username="pgsql"

password="javac"

maxActive="5"

maxIdle="3"

maxWait="-1"/>

2. 复制JDBC插件lib

从下载的包中复制JDBCProvider.jarWEB-INF下的lib目录中

3. /WEB-INF下创建文件jdbcprovider.properties

connectionProvider = com.forthgo.jspwiki.jdbcprovider.JNDIConnectionProvider

jndi.datasource = PostgresqlDataSource

database.flavour = pgsql ## POSTGREsql; other,MysqL,oracle etc.

## Copy the jdbcprovider.<flavour>.properties file to .../WEB-INF

driver.useUnicode = true

driver.characterEncoding = utf8

driver.connectionCollation = utf8_bin

database.create = false

continuationEditMinutes = 15

4. 复制文件

从下载的包中复制文件jdbcprovider.pgsql.properties/WEB-INF目录下

5. 修改jspwiki.properties

注释如下内容

jspwiki.pageProvider = FileSystemProvider

jspwiki.fileSystemProvider.pageDir = /p/web/www-data/jspwiki/

jspwiki.attachmentProvider = BasicAttachmentProvider

jspwiki.basicAttachmentProvider.storageDir = /p/web/www-data/jspwiki/

文件添加如下内容

jspwiki.pageProvider = com.forthgo.jspwiki.jdbcprovider.JDBCPageProvider

jspwiki.attachmentProvider = com.forthgo.jspwiki.jdbcprovider.JDBCAttachmentProvider

jspwiki.jdbcprovider.configuration=jdbcprovider.properties

6. 新建数据库

在新建180上新建数据库jspwiki_trial,字符集编码UTF-8

脚本如下:

CREATE TABLE "WIKI_PAGE"

(

"NAME" character varying(100) NOT NULL,

"VERSION" integer NOT NULL,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "CHANGE_TIME" timestamp without time zone,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "CHANGE_BY" character varying(50),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "CHANGE_NOTE" character varying(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "CONTENT" text

);

ALTER TABLE ONLY "WIKI_PAGE"

ADD CONSTRAINT "WIKI_PAGE_UNIQUE_KEY" UNIQUE ("NAME","VERSION");

ADD CONSTRAINT "WIKI_PAGE_PKEY" PRIMARY KEY ("NAME",160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">

CREATE INDEX "WIKI_PAGE_CHANGE_TIME_IX" ON "WIKI_PAGE" USING btree ("CHANGE_TIME");

CREATE TABLE "WIKI_ATT"

"PAGENAME" character varying(100) NOT NULL,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "FILENAME" character varying(100) NOT NULL,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "CHANGE_BY" character varying(50),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "LENGTH" integer,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> "DATA" bytea

ALTER TABLE ONLY "WIKI_ATT"

ADD CONSTRAINT "WIKI_ATT_UNIQUE_KEY" UNIQUE ("PAGENAME","FILENAME",160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> ADD CONSTRAINT "WIKI_ATT_PKEY" PRIMARY KEY ("PAGENAME",160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">CREATE INDEX "WIKI_ATT_CHANGE_TIME_IX" ON "WIKI_ATT" USING btree ("CHANGE_TIME");

12 用户数据迁移

1. 新建数据表

create table wiki_users (

email varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> full_name varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> login_name varchar(100) not null primary key,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> password varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> wiki_name varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> created timestamp,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> modified timestamp

);

create table wiki_role (

login_name varchar(100) not null,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> wiki_role varchar(100) not null

create table wiki_groups (

name varchar(100) not null primary key,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> creator varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> modifier varchar(100),160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">create table wiki_member (

name varchar(100) not null,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> wiki_member varchar(100) not null,160) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> constraint wiki_member_pk

primary key (name,wiki_member)

grant select,insert,update,delete on wiki_users to pgsql;

sql;

sql;

sql;

2. 配置用户数据源

用户数据源可以与内容数据源相同。如果用不同的数据源,同第一节所示,在Tomcatserver.xml添加数据源即可。本例使用相同的数据源。

3. 修改jspwiki.properties文件

注释如下内容

jspwiki.groupdatabase = com.ecyrd.jspwiki.auth.authorize.XMLGroupDatabase

jspwiki.userdatabase = com.ecyrd.jspwiki.auth.user.XMLUserDatabase

jspwiki.userdatabase.isSharedWithContainer = false

添加如下内容

jspwiki.groupdatabase =com.ecyrd.jspwiki.auth.authorize.JDBCGroupDatabase

jspwiki.userdatabase = com.ecyrd.jspwiki.auth.user.JDBCUserDatabase

jspwiki.userdatabase.datasource=PostgresqlDataSource

jspwiki.groupdatabase.datasource=PostgresqlDataSource

jspwiki.userdatabase.table=wiki_users

jspwiki.userdatabase.email=email

jspwiki.userdatabase.fullName=full_name

jspwiki.userdatabase.loginName=login_name

jspwiki.userdatabase.password=password

jspwiki.userdatabase.wikiName=wiki_name

jspwiki.userdatabase.created=created

jspwiki.userdatabase.modified=modified

jspwiki.userdatabase.roleTable=wiki_role

jspwiki.userdatabase.role=wiki_role

jspwiki.groupdatabase.table=wiki_groups

jspwiki.groupdatabase.membertable=wiki_member

jspwiki.groupdatabase.created=created

jspwiki.groupdatabase.creator=creator

jspwiki.groupdatabase.name=name

jspwiki.groupdatabase.member=wiki_member

jspwiki.groupdatabase.modified=modified

jspwiki.groupdatabase.modifier=modifier

jspwiki.userdatabase.isSharedWithContainer = true

4. 注册管理员用户

访问:http://localhost:8080/wiki/后,单击右上角登录按钮,后选择注册新用户

登录名: admin

密码: 123456

密码验证: 123456

名字: Administrator

创建组Admin,后将Administrator加入到Admin组中

注意:

在将数据存储路径改为数据库后,禁止访问Install.jsp页面,否则会丢失修改


2 CAS整合

2.1 建立CAS Server

CAS学习笔记中建立

2.2 配置CAS Client

1. CAS SSL证书导入到jspWiki所在的JDK

1)复制CAS服务器上tomcatsso.crt 文件%JAVA_HOME%/jre/lib/security

2)然后用下面命令将证书tomcatsso.crt 文件导入到cacerts文件中。

Cd %JAVA_HOME%/jre/lib/security

keytool -import -alias tomcatsso -file tomcatsso.crt -keystore cacerts -storepass changeit

2. 插入CAS CLIENT文件

复制cas-client-core- 3.1.3 .jarspring.jar2文件WEB-INF/lib目录文件夹下

3. 修改web.xml文件

web.xml添加CAS Filter

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring-appContext.xml</param-value>

</context-param>

<filter>

<filter-name>CAS Single Sign Out Filter</filter-name>

<filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>CAS Single Sign Out Filter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

<listener>

<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>

</listener>

<filter-name>CAS Authentication Filter</filter-name>

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

<init-param>

<param-name>targetBeanName</param-name>

<param-value>casAuthenticationFilter</param-value>

</init-param>

<filter-name>CAS Validation Filter</filter-name>

<param-value>casValidationFilter</param-value>

</init-param>

<filter-name>CAS HttpServletRequestWrapperFilter</filter-name>

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

<init-param>

<param-name>targetBeanName</param-name>

<param-value>casHttpServletRequestWrapperFilter</param-value>

<url-pattern>/Login.jsp</url-pattern>

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

</listener>

4. 插入spring-appContext.xml

WEB-INF目录下添加spring-appContext.xml文件

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="casAuthenticationFilter"

class="org.jasig.cas.client.authentication.AuthenticationFilter">

<property name ="casServerLoginUrl" value="https://www.test.com:443/cas-server/login"/>

<property name ="serverName" value="http://192.168.0.116:8080"/>

</bean>

<bean id="casValidationFilter"

class="org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter">

<property name="ticketValidator">

<ref bean="Cas20ProxyTicketValidator"/>

</property>

<property name="useSession" value="true"/>

<property name="serverName" value="http://192.168.0.116:8080"/>

<property name="redirectAfterValidation" value="false"/>

</bean>

<bean id="Cas20ProxyTicketValidator"

class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator">

<constructor-arg index="0" value="https://www.test.com:443/cas-server" />

<bean id="casHttpServletRequestWrapperFilter"

class="org.jasig.cas.client.util.HttpServletRequestWrapperFilter"/>

</beans>

5. 修改jspWikiLogin.jsp文件

注释掉

/*

if( wikiSession.isAuthenticated() )

{

response.sendError( HttpServletResponse.SC_FORBIDDEN,

rb.getString("login.error.noaccess") );

return;

}

*/

6. 修改jspWikilogout.jsp文件

response.sendRedirect("https://www.test.com:443/cas-server/logout?url=http://192.168.0.116:8080/wiki");

原文链接:https://www.f2er.com/postgresql/197359.html

猜你在找的Postgre SQL相关文章