提交 7b29fd21 编写于 作者: N Nicky.Ma

Merge commit '1.0.0' into dev

......@@ -14,8 +14,12 @@
<properties>
<shiro.version>1.2.3</shiro.version>
<shiro.spring.version>1.2.4</shiro.spring.version>
<shiro.encache.version>1.2.4</shiro.encache.version>
<lucene.version>4.7.2</lucene.version>
<poi.version>3.7</poi.version>
<cas.version>3.2.0</cas.version>
<shiro.cas.version>1.2.4</shiro.cas.version>
</properties>
<dependencies>
......@@ -56,8 +60,18 @@
<!-- Shiro -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-all</artifactId>
<version>${shiro.version}</version>
<artifactId>shiro-spring</artifactId>
<version>${shiro.spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-ehcache</artifactId>
<version>${shiro.encache.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-cas</artifactId>
<version>${shiro.cas.version}</version>
</dependency>
<!-- Apache POI -->
......@@ -81,6 +95,13 @@
<version>2.5</version>
</dependency>
<!-- cas -->
<dependency>
<groupId>org.jasig.cas.client</groupId>
<artifactId>cas-client-core</artifactId>
<version>${cas.version}</version>
</dependency>
</dependencies>
......
......@@ -7,7 +7,7 @@ import java.util.Locale;
* @author Nicky
* @date 2017年3月6日
*/
public class Constants {
public class CommonConsts {
//定义统一Locale.CHINA,程序中所有和Locale相关操作均默认使用此Locale
public static final Locale LOCALE_CHINA = Locale.CHINA;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.util;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -40,7 +40,7 @@ public class DateUtils {
* @return
*/
public static Date parse(String pattern, String date){
return parse(pattern, date, Constants.LOCALE_CHINA);
return parse(pattern, date, CommonConsts.LOCALE_CHINA);
}
/**
......
......@@ -3,7 +3,7 @@ package org.muses.jeeplatform.web.controller;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -30,7 +30,7 @@ public class CodeController {
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
session.setAttribute(Constants.SESSION_SECURITY_CODE, code);
session.setAttribute(CommonConsts.SESSION_SECURITY_CODE, code);
try {
ServletOutputStream out = response.getOutputStream();
......
......@@ -8,7 +8,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.ResultVO;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
......@@ -95,7 +95,7 @@ public class LoginController extends BaseController {
//获取Shiro管理的Session
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
String codeSession = (String)session.getAttribute(Constants.SESSION_SECURITY_CODE);
String codeSession = (String)session.getAttribute(CommonConsts.SESSION_SECURITY_CODE);
String code = logindata[2];
/**检测页面验证码是否为空,调用工具类检测**/
if(Tools.isEmpty(code)){
......@@ -116,9 +116,9 @@ public class LoginController extends BaseController {
}else{
//Shiro添加会话
session.setAttribute("username", username);
session.setAttribute(Constants.SESSION_USER, user);
session.setAttribute(CommonConsts.SESSION_USER, user);
//删除验证码Session
session.removeAttribute(Constants.SESSION_SECURITY_CODE);
session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
//保存登录IP
this.getRemortIP(username);
/**Shiro加入身份验证**/
......@@ -153,7 +153,7 @@ public class LoginController extends BaseController {
/**获取Shiro管理的Session**/
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
User user = (User)session.getAttribute(Constants.SESSION_USER);
User user = (User)session.getAttribute(CommonConsts.SESSION_USER);
if(user != null){
Set<Role> roles = user.getRoles();
......@@ -218,8 +218,8 @@ public class LoginController extends BaseController {
/**Shiro管理Session**/
Subject sub = SecurityUtils.getSubject();
Session session = sub.getSession();
session.removeAttribute(Constants.SESSION_USER);
session.removeAttribute(Constants.SESSION_SECURITY_CODE);
session.removeAttribute(CommonConsts.SESSION_USER);
session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
/**Shiro销毁登录**/
Subject subject = SecurityUtils.getSubject();
subject.logout();
......@@ -228,5 +228,11 @@ public class LoginController extends BaseController {
return mv;
}
@RequestMapping("/403")
public ModelAndView to403PAge(){
ModelAndView mv = this.getModelAndView();
mv.setViewName("admin/frame/403");
return mv;
}
}
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.muses.jeeplatform.annotation.LogController;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.service.MenuService;
......@@ -39,7 +39,7 @@ public class MenuController extends BaseController {
public ModelAndView toMenuList(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Menu> menuPage;
......@@ -72,7 +72,7 @@ public class MenuController extends BaseController {
pageIndex = 1;
}
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
Page<Menu> menuPage = menuService.findAll(pageIndex, pageSize, Sort.Direction.ASC,"menuId");
String json = JSON.toJSONString(menuPage.getContent());
return json;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.muses.jeeplatform.annotation.LogController;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.service.PermissionPageService;
import org.muses.jeeplatform.service.PermissionService;
......@@ -43,7 +43,7 @@ public class PermissionController extends BaseController {
public ModelAndView queryAll(HttpServletRequest request, HttpServletResponse response, Model model){
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Permission> permissionPage;
......
......@@ -2,7 +2,7 @@ package org.muses.jeeplatform.web.controller;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.core.entity.admin.Role;
......@@ -51,7 +51,7 @@ public class RoleController extends BaseController {
public ModelAndView queryAll(HttpServletRequest request, HttpServletResponse response, Model model){
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<Role> rolePage;
......
......@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.email.JavaEmailSender;
import org.muses.jeeplatform.core.entity.admin.Role;
import org.muses.jeeplatform.core.entity.admin.User;
......@@ -58,7 +58,7 @@ public class UserController extends BaseController {
public ModelAndView findAll(HttpServletRequest request, HttpServletResponse response, Model model) {
String pageIndexStr = request.getParameter("pageIndex");
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<User> userPage;
......@@ -97,7 +97,7 @@ public class UserController extends BaseController {
@RequestMapping(value = "/searchU", produces = "application/json;charset=UTf-8")
public ModelAndView doSearch(@RequestParam(value = "pageIndex",required = true) String pageIndexStr, @RequestParam(value = "keyword",required = false) String keyword,
@RequestParam(value = "startDate",required = false) String startDateStr, @RequestParam(value = "endDate",required = false) String endDateStr) {
int pageSize = Constants.PAGE_SIZE;
int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page<User> userPage;
......
......@@ -3,7 +3,7 @@ package org.muses.jeeplatform.web.interceptor;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.muses.jeeplatform.core.Constants;
import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.User;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
......@@ -22,19 +22,19 @@ public class LoginInterceptor extends HandlerInterceptorAdapter{
HttpServletResponse response, Object handler) throws Exception {
String urlpath = request.getServletPath();
/**正则表达式过滤,不匹配该值的就拦截处理**/
if(urlpath.matches(Constants.REGEXP_PATH)){
if(urlpath.matches(CommonConsts.REGEXP_PATH)){
return true;
}else {
//shiro框架的会话管理,获取Session,校验用户是否通过登录验证
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
User user = (User)session.getAttribute(Constants.SESSION_USER);
User user = (User)session.getAttribute(CommonConsts.SESSION_USER);
if(user != null){
/**加入权限校验,待开发...**/
return true;
}else{
//重定向到登录页面
response.sendRedirect(request.getContextPath() + Constants.URL_LOGIN);
response.sendRedirect(request.getContextPath() + CommonConsts.URL_LOGIN);
return false;
}
}
......
server:
port: 8080
port: 8081
spring:
......@@ -72,3 +72,6 @@ spring:
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<base href="<%=basePath %>">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>403无权访问</title>
<style type="text/css">
body,h1,p{margin:0;padding:0;}
body{background:#fcfbfb;}
.nofound{width:470px;margin:0 auto;padding:180px 0 100px;text-align:center;color:#5c6048;font-size:16px;line-height:30px;font-family:"Microsoft Yahei";background:url(images/nofound-bg.png) right 62px no-repeat;}
.nofound p{padding-top:20px;}
.nofound-tit{padding-bottom:32px;font-weight:normal;font-size:150px;line-height:120px;}
.nofound-why{font-size:30px;line-height:30px;}
.sorry{font-size:30px;}
.back-homepage{color:#ff6000;font-size:14px;}
</style>
</head>
<body>
<div class="nofound">
<h1 class="nofound-tit">403 <span class="nofound-why">why</span></h1>
<p class="sorry">非常抱歉...</p>
<p>您访问的页面无权访问</p>
<p>您可以 <a class="back-homepage" href="/jeeplatform">返回登录页</a></p>
</div>
</body>
</html>
\ No newline at end of file
<!--<?xml version="1.0" encoding="UTF-8"?>-->
<!--<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">-->
<!--<display-name>Archetype Created Web Application</display-name>-->
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Archetype Created Web Application</display-name>
<!--<welcome-file-list>-->
<!--<welcome-file>index.jsp</welcome-file>-->
<!--</welcome-file-list>-->
<!--<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>-->
<!--<context-param>-->
<!--<param-name>contextConfigLocation</param-name>-->
<!--<param-value>classpath:spring/spring-base.xml</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>log4jConfigLocation</param-name>-->
<!--<param-value>classpath:log4j.properties</param-value>-->
<!--</context-param>-->
<!--<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-base.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.properties</param-value>
</context-param>
<!--<filter>-->
<!--<filter-name>encodingFilter</filter-name>-->
<!--<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>-->
<!--<init-param>-->
<!--<param-name>encoding</param-name>-->
<!--<param-value>utf-8</param-value>-->
<!--</init-param>-->
<!--<init-param>-->
<!--<param-name>forceEncoding</param-name>-->
<!--<param-value>true</param-value> &lt;!&ndash; 配置forceEncoding为true,请求和响应的数据的字符集均使用当前配置的字符集&ndash;&gt;-->
<!--</init-param>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>encodingFilter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value> &lt;!&ndash; 配置forceEncoding为true,请求和响应的数据的字符集均使用当前配置的字符集&ndash;&gt;
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--&lt;!&ndash; 添加SSI(服务端页面包含技术)配置 start-->
<!--<servlet>-->
<!--<servlet-name>ssi</servlet-name>-->
<!--<servlet-class>org.apache.catalina.ssi.SSIServlet</servlet-class>-->
<!--</servlet>-->
<!--<servlet-mapping>-->
<!--<servlet-name>ssi</servlet-name>-->
<!--<url-pattern>*.shtml</url-pattern>-->
<!--</servlet-mapping>-->
<!--&ndash;&gt;-->
<!--&lt;!&ndash; 添加SSI(服务端页面包含技术)配置 end &ndash;&gt;-->
&lt;!&ndash; 添加SSI(服务端页面包含技术)配置 start &ndash;&gt;
<servlet>
<servlet-name>ssi</servlet-name>
<servlet-class>org.apache.catalina.ssi.SSIServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ssi</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
&lt;!&ndash; 添加SSI(服务端页面包含技术)配置 end &ndash;&gt;
<!--&lt;!&ndash; 连接池 启用Web监控统计功能 start&ndash;&gt;-->
<!--<filter>-->
<!--<filter-name>DruidWebStatFilter</filter-name>-->
<!--<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>-->
<!--<init-param>-->
<!--<param-name>exclusions</param-name>-->
<!--<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>-->
<!--</init-param>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>DruidWebStatFilter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
<!--<servlet>-->
<!--<servlet-name>DruidStatView</servlet-name>-->
<!--<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>-->
<!--</servlet>-->
<!--<servlet-mapping>-->
<!--<servlet-name>DruidStatView</servlet-name>-->
<!--<url-pattern>/druid/*</url-pattern>-->
<!--</servlet-mapping>-->
<!--&lt;!&ndash; 连接池 启用Web监控统计功能 end&ndash;&gt;-->
&lt;!&ndash; 连接池 启用Web监控统计功能 start&ndash;&gt;
<filter>
<filter-name>DruidWebStatFilter</filter-name>
<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DruidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>
<url-pattern>/druid/*</url-pattern>
</servlet-mapping>
&lt;!&ndash; 连接池 启用Web监控统计功能 end&ndash;&gt;
<!--<listener>-->
<!--<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>-->
<!--</listener>-->
<!--<listener>-->
<!--<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>-->
<!--</listener>-->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--<servlet>-->
<!--<servlet-name>springMvc</servlet-name>-->
<!--<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>-->
<!--<init-param>-->
<!--<param-name>contextConfigLocation</param-name>-->
<!--<param-value>classpath:spring/spring-mvc.xml</param-value>-->
<!--</init-param>-->
<!--<load-on-startup>1</load-on-startup>-->
<!--</servlet>-->
<!--<servlet-mapping>-->
<!--<servlet-name>springMvc</servlet-name>-->
<!--<url-pattern>/</url-pattern>-->
<!--</servlet-mapping>-->
<servlet>
<servlet-name>springMvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springMvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--&lt;!&ndash; Shiro过滤器配置 start &ndash;&gt;-->
<!--<filter>-->
<!--<filter-name>shiroFilter</filter-name>-->
<!--<filter-class>-->
<!--org.springframework.web.filter.DelegatingFilterProxy-->
<!--</filter-class>-->
<!--<init-param>-->
<!--<param-name>targetFilterLifecycle</param-name>-->
<!--<param-value>true</param-value>-->
<!--</init-param>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>shiroFilter</filter-name>-->
<!--<url-pattern>/*</url-pattern>-->
<!--</filter-mapping>-->
<!--&lt;!&ndash; Shiro过滤器配置 end &ndash;&gt;-->
&lt;!&ndash; Shiro过滤器配置 start &ndash;&gt;
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
&lt;!&ndash; Shiro过滤器配置 end &ndash;&gt;
<!--<session-config>-->
<!--<session-timeout>600</session-timeout>-->
<!--</session-config>-->
<session-config>
<session-timeout>600</session-timeout>
</session-config>-->
<!--</web-app>-->
<!--!&#45;&#45; 单点退出Listener &ndash;&gt;
<listener>
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
</listener>
&lt;!&ndash; 单点退出Filter &ndash;&gt;
<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>
&lt;!&ndash; CAS认证Filter &ndash;&gt;
<filter>
<filter-name>CASFilter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
&lt;!&ndash; CAS登录页面,当SessionId无法匹配Session时,跳转到CAS登录页面 &ndash;&gt;
<param-name>casServerLoginUrl</param-name>
<param-value>http://localhost:8080/cas/login</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CASFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
&lt;!&ndash; CAS Ticket校验Filter &ndash;&gt;
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>http://localhost:8080/cas</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>http://localhost:8080</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
&lt;!&ndash; 使客户端支持通过AssertionHolder来获取用户的登录名 &ndash;&gt;
<filter>
<filter-name>CAS Assertion Thread Local Filter</filter-name>
<filter-class>org.jasig.cas.client.util.AssertionThreadLocalFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CAS Assertion Thread Local Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>-->
</web-app>
......@@ -61,7 +61,7 @@
<version>${cas.version}</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
......@@ -75,7 +75,7 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>${log4j2.version}</version>
</dependency>
</dependency>-->
<dependency>
<groupId>com.lmax</groupId>
......@@ -89,11 +89,12 @@
<version>${fastjson.version}</version>
</dependency>
<!--<dependency>
<groupId>ren.boot</groupId>
<!-- 保存Ticket到redis-->
<dependency>
<groupId>com.github.izerui</groupId>
<artifactId>cas-server-integration-redis</artifactId>
<version>${cas.integration.redis.version}</version>
</dependency>-->
</dependency>
<dependency>
<groupId>com.github.penggle</groupId>
......
......@@ -15,6 +15,12 @@
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!-- 对密码进行加密 -->
<!-- <bean id="passwordEncoder" class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
<constructor-arg value="MD5"></constructor-arg>
<property name="characterEncoding" value="UTF-8"></property>
</bean>-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="${platform.jdbc.jdbcUrl}"/>
<property name="username" value="${platform.jdbc.username}"/>
......@@ -86,7 +92,25 @@
<alias name="jsonServiceRegistryDao" alias="serviceRegistryDao" />
<alias name="defaultTicketRegistry" alias="ticketRegistry" />
<!-- 先注释默认的ticket Registry-->
<!--<alias name="defaultTicketRegistry" alias="ticketRegistry" />-->
<!-- Redis相关配置 -->
<alias name="redisTicketRegistry" alias="ticketRegistry"/>
<bean id="redisTicketRegistry" class="ren.boot.cas.ticket.registry.RedisTicketRegistry"
p:client-ref="ticketRedisTemplate"
p:tgtTimeout="${tgt.maxTimeToLiveInSeconds}"
p:stTimeout="${st.timeToKillInSeconds}"/>
<!-- redis连接池 -->
<bean id="jedisConnFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:hostName="${redis.hostName}"
p:database="${redis.database}"
p:password="${redis.password}"
p:port="${redis.port}"
p:usePool="true"/>
<bean id="ticketRedisTemplate" class="ren.boot.cas.ticket.registry.TicketRedisTemplate"
p:connectionFactory-ref="jedisConnFactory"/>
<alias name="ticketGrantingTicketExpirationPolicy" alias="grantingTicketExpirationPolicy" />
<alias name="multiTimeUseOrTimeoutExpirationPolicy" alias="serviceTicketExpirationPolicy" />
......
<jsp:directive.include file="includes/top.jsp" />
<div id="login" style="width: 100%;">
<form:form method="post" id="fm1" htmlEscape="true">
<h2>Acceptable Usage Policy</h2>
<div>
The purpose of this policy is to establish acceptable and unacceptable use of electronic devices and network resources in conjunction with the established culture of ethical and lawful behavior, openness, trust, and integrity.
<p>
By using these resources, you agree to abide by the Acceptable Usage Policy.
</p>
<p>Click '<spring:message code="screen.aup.button.accept" />' to continue. Otherwise, click '<spring:message code="screen.aup.button.cancel" />'.</p>
</div>
<section class="row btn-row">
<input type="hidden" name="execution" value="${flowExecutionKey}" />
<input type="hidden" name="_eventId" value="submit" />
<input class="btn-submit" name="submit" accesskey="s" value="<spring:message code="screen.aup.button.accept" />" type="submit" />
<input class="btn-reset" name="cancel" accesskey="c"
value="<spring:message code="screen.aup.button.cancel" />" type="button"
onclick="location.href = location.href;" />
</section>
</form:form>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.accountdisabled.heading" /></h2>
<p><spring:message code="screen.accountdisabled.message" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.accountlocked.heading" /></h2>
<p><spring:message code="screen.accountlocked.message" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.badhours.heading" /></h2>
<p><spring:message code="screen.badhours.message" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.badworkstation.heading" /></h2>
<p><spring:message code="screen.badworkstation.message" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="info">
<p><spring:message code="screen.confirmation.message" arguments="${fn:escapeXml(param.service)}${fn:indexOf(param.service, '?') eq -1 ? '?' : '&'}ticket=${serviceTicketId}" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
\ No newline at end of file
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.expiredpass.heading" /></h2>
<p><spring:message code="screen.expiredpass.message" arguments="${passwordPolicyUrl}" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="success">
<h2><spring:message code="screen.success.header" /></h2>
<p><spring:message code="screen.success.success" arguments="${principal.id}"/></p>
<p><spring:message code="screen.success.security" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<!-- 支持Http方式登录-->
<%--<c:if test="${not pageContext.request.secure}">
<div id="msg" class="errors">
<h2><spring:message code="screen.nonsecure.title" /></h2>
<p><spring:message code="screen.nonsecure.message" /></p>
</div>
</c:if>--%>
<div class="login" id="login">
<div class="box png">
<div class="input">
<div class="log">
<div class="name">
<label>用户名</label><input type="text" class="text" id="username" placeholder="用户名" value="admin" />
</div>
<div class="pwd">
<label>密 码</label><input type="password" class="text" id="password" placeholder="密码" value="123" />
</div>
<div class="rcode">
<label><img style="height:22px;" id="codeImg" alt="点击更换"
title="点击更换" src="" /></label>
<input type="text" class="text" name="code" id="code" placeholder="验证码" value="code" />
</div>
<input type="button" class="submit" onclick="loginCheck();" value="登录">
</div>
</div>
</div>
<div class="air-balloon ab-1 png"></div>
<div class="air-balloon ab-2 png"></div>
<div class="footer"></div>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.mustchangepass.heading" /></h2>
<p><spring:message code="screen.mustchangepass.message" arguments="${passwordPolicyUrl}" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<c:url var="url" value="/login">
<c:param name="service" value="${param.service}" />
<c:param name="renew" value="true" />
</c:url>
<div id="msg" class="errors">
<h2><spring:message code="screen.service.sso.error.header" /></h2>
<p><spring:message code="screen.service.sso.error.message" arguments="${fn:escapeXml(url)}" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
<jsp:directive.include file="includes/top.jsp" />
<div id="msg" class="errors">
<h2><spring:message code="screen.service.error.header" /></h2>
<p><spring:message code="${rootCauseException.code}" /></p>
</div>
<jsp:directive.include file="includes/bottom.jsp" />
server.name=http://localhost:8080
server.prefix=${server.name}/cas
server.name=http://localhost:8080
server.prefix=${server.name}/cas
##
# Datasource config
platform.jdbc.jdbcUrl=jdbc:mysql://127.0.0.1:3306/jeeplatform?autoReconnect=true&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
platform.jdbc.username=root
platform.jdbc.password=root
platform.jdbc.jdbcUrl=jdbc:mysql://127.0.0.1:3306/jeeplatform?autoReconnect=true&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
platform.jdbc.username=root
platform.jdbc.password=root
#platform.jdbc.publickey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKZijIzzXp1dyksL1ZSejBmuVz1Y0vgiQVbcQ/13p4pwHRo8gU3pd6YaWutOlBTEWvHBbnGxIdnrhxnQZGwU1O0CAwEAAQ==
platform.jdbc.initialSize=10
platform.jdbc.minIdle=10
platform.jdbc.maxActive=50
platform.jdbc.initialSize=10
platform.jdbc.minIdle=10
platform.jdbc.maxActive=50
# security configuration based on IP address to access the /status and /statistics pages
# cas.securityContext.adminpages.ip=127\.0\.0\.1
cas.securityContext.adminpages.ip=127\.0\.0\.1
##
# Unique CAS node name
......@@ -20,6 +20,13 @@ platform.jdbc.maxActive=50
# hostname of the machine running the CAS node, but it could be any label so long as it is unique in the cluster.
# host.name=
##
# Redis registry config
redis.hostName=127.0.0.1
redis.database=0
redis.password=
redis.port=6379
##
# JPA Ticket Registry Database Configuration
#
......@@ -69,22 +76,22 @@ platform.jdbc.maxActive=50
# Do note that the following settings MUST be generated per deployment.
#
# The encryption secret key. By default, must be a octet string of size 256.
# tgc.encryption.key=
#tgc.encryption.key=DSi19FXiMznOlZvZRHsThtl-3FZzNKjQzbHt8QASI7Q
# The signing secret key. By default, must be a octet string of size 512.
# tgc.signing.key=
#tgc.signing.key=fOs-_ZjGNfcLsg8LWqkuHM6KccWlTsozxZZrwptqFMQAIvzqCD5lL9s4hvqDp5f-w1bpQM8IUAKEotw7jzhlvw
# Decides whether SSO cookie should be created only under secure connections.
tgc.secure=false
# The expiration value of the SSO cookie
# tgc.maxAge=-1
tgc.maxAge=-1
# The name of the SSO cookie
# tgc.name=TGC
tgc.name=TGC
# The path to which the SSO cookie will be scoped
# tgc.path=/cas
tgc.path=/cas
# The expiration value of the SSO cookie for long-term authentications
# tgc.remember.me.maxAge=1209600
......@@ -93,16 +100,16 @@ platform.jdbc.maxActive=50
warn.cookie.secure=false
# The expiration value of the SSO Warning cookie
# warn.cookie.maxAge=-1
warn.cookie.maxAge=-1
# The name of the SSO Warning cookie
# warn.cookie.name=CASPRIVACY
warn.cookie.name=CASPRIVACY
# The path to which the SSO Warning cookie will be scoped
# warn.cookie.path=/cas
warn.cookie.path=/cas
# Whether we should track the most recent session by keeping the latest service ticket
# tgt.onlyTrackMostRecentSession = true
tgt.onlyTrackMostRecentSession = true
##
# CAS UI Theme Resolution
......@@ -131,7 +138,7 @@ platform.jdbc.maxActive=50
# Single Sign-On Session
#
# Indicates whether an SSO session should be created for renewed authentication requests.
# create.sso.renewed.authn=true
create.sso.renewed.authn=true
#
# Indicates whether an SSO session can be created if no service is present.
# create.sso.missing.service=true
......@@ -194,10 +201,11 @@ message.bundle.basenames=WEB-INF/locale/messages
# See the cas-servlet.xml file to understand how these properties are used.
#
# The encryption secret key. By default, must be a octet string of size 256.
# webflow.encryption.key=
# webflow.encryption.key=DsCqdpcudQPzsdHz
# The signing secret key. By default, must be a octet string of size 512.
# webflow.signing.key=
# webflow.signing.key=U2ImXkZHYsZkORpSbjAqcvW3_gzz9oOUg6q2SWMz3Sr4Sf6NIVoNfQ97rqdhmtSZH6elMl8YgaoZrdiRWiybGw
##
# Remote User Authentication
......@@ -296,7 +304,7 @@ accept.authn.users=casuser::Mellon
# Single Sign-On Session TGT Timeouts
#
# Inactivity Timeout Policy
# tgt.timeout.maxTimeToLiveInSeconds=28800
tgt.timeout.maxTimeToLiveInSeconds=28800
# Hard Timeout Policy
# tgt.timeout.hard.maxTimeToLiveInSeconds
......@@ -306,13 +314,14 @@ accept.authn.users=casuser::Mellon
# tgt.throttled.timeInBetweenUsesInSeconds=5
# Default Expiration Policy
# tgt.maxTimeToLiveInSeconds=28800
# tgt.timeToKillInSeconds=7200
tgt.maxTimeToLiveInSeconds=28800
tgt.timeToKillInSeconds=7200
##
# Service Ticket Timeout
#
# st.timeToKillInSeconds=10
#默认是10秒,改成1800s
st.timeToKillInSeconds=1800
# st.numberOfUses=1
##
......@@ -355,7 +364,7 @@ accept.authn.users=casuser::Mellon
# JSON Service Registry
#
# Directory location where JSON service files may be found.
# service.registry.config.location=classpath:services
service.registry.config.location=WEB-INF/services
##
# Service Registry Periodic Reloading Scheduler
......@@ -458,8 +467,11 @@ accept.authn.users=casuser::Mellon
# Ticket Registry Cleaner
#
# Indicates how frequently the Ticket Registry cleaner should run. Configured in seconds.
# ticket.registry.cleaner.startdelay=20
# ticket.registry.cleaner.repeatinterval=5000
#ticket.registry.cleaner.startdelay=20
#ticket.registry.cleaner.repeatinterval=5000
# startdelay设置为0就不会启动cleaner,因为需要使用redis默认的超时管理,不需要cas的calendar
ticket.registry.cleaner.startdelay=0
ticket.registry.cleaner.repeatinterval=0
##
# Ticket ID Generation
......@@ -718,3 +730,4 @@ accept.authn.users=casuser::Mellon
# cas.aup.ldap.startTLS=false
# cas.aup.ldap.basedn=dc=example,dc=org
# cas.aup.attribute=
@charset "utf-8";
html,body{margin:0;padding:0;width:100%;}
body{font-size:12px;font-family: "微软雅黑";color:#333;line-height:160%;background: url(../images/login-bg.jpg) center top repeat-x #FFF;height:100%;}
p,ul,.name,.pwd,dd,h1,h2,h3,form,input,select,textarea{margin:0;padding:0;border:0;font-family:"微软雅黑";line-height:150%;}
ul,li{list-style:none;}
div,p{word-wrap: break-word;}
img{border: none;}
input,button,select,textarea{outline:none}
/*login*/
.login{padding:1px 0 0 0;background:url(../images/login-bg.jpg) center top no-repeat #FFF;padding:150px 0 0 0;}
.login input.submit{border:none;font-weight:bold;color:#FFF;margin:25px 0 0 150px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow: #CCC 0px 0px 5px;-moz-box-shadow: #CCC 0px 0px 5px;box-shadow: #CCC 0px 0px 5px;background: #31b6e7;cursor: pointer;}
.login input.submit:hover{background:#ff9229;}
.login input.submit{padding:6px 20px;}
.login .box{position:relative;z-index:100;margin:0 auto;width:700px;height:320px;background:url(../images/login.png) center top no-repeat;}
.login .log{position:relative;width:370px;height:260px;margin:0 auto;padding:60px 0 0 20px;}
.login label{display:inline-block;width:70px;text-align:right;padding-right:20px;vertical-align:middle;}
.login .name{padding:10px 5px;font-size:14px;}
.login .pwd{padding:10px 5px;font-size:14px;}
.login .rcode{padding:10px;font-size:14px;}
.login .alt{position:absolute;top:43px;left:260px;font-size:20px;}
.login .text{filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;}
.login .copyright{position:absolute;left:0;width:100%;bottom:-40px;text-align:center;color:#AAA;}
.login .air-balloon{position:absolute;top:-100px;left:-100px;z-index:50;}
.login .air-balloon.ab-1{width:43px;height:78px;background:url(../images/air-balloon-1.png) no-repeat;}
.login .air-balloon.ab-2{width:24px;height:31px;background:url(../images/air-balloon-2.png) no-repeat;}
.login .footer{position: fixed;left:0;bottom:0;z-index:-1;width:100%;height:198px;background:url(../images/login-foot.jpg) center bottom repeat-x;}
.text{border:1px solid #CCC;padding:5px;background-color:#FCFCFC;line-height:14px;width:220px;font-size:12px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow: #CCC 0px 0px 5px;-moz-box-shadow: #CCC 0px 0px 5px;box-shadow: #CCC 0px 0px 5px;border:1px solid #CCC;font-size:12px;}
.text:focus{border:1px solid #31b6e7;background-color:#FFF;-webkit-box-shadow: #CCC 0px 0px 5px;-moz-box-shadow: #CCC 0px 0px 5px;box-shadow: #0178a4 0px 0px 5px;}
.text:hover{background-color:#FFF;}
\ No newline at end of file
;function rand(mi,ma){
var range = ma - mi;
var out = mi + Math.round( Math.random() * range) ;
return parseInt(out);
};
function getViewSize(){
var de=document.documentElement;
var db=document.body;
var viewW=de.clientWidth==0 ? db.clientWidth : de.clientWidth;
var viewH=de.clientHeight==0 ? db.clientHeight : de.clientHeight;
return Array(viewW,viewH);
}
\ No newline at end of file
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// CommonJS
factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function (key, value, options) {
// Write
if (arguments.length > 1 && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5);
}
return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// Read
var result = key ? undefined : {};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false;
}
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};
}));
/**
* jquery tips 提示插件 jquery.tips.js v0.1beta
*
* 使用方法
* $(selector).tips({ //selector 为jquery选择器
* msg:'your messages!', //你的提示消息 必填
* side:1, //提示窗显示位置 1,2,3,4 分别代表 上右下左 默认为1(上) 可选
* color:'#FFF', //提示文字色 默认为白色 可选
* bg:'#F00',//提示窗背景色 默认为红色 可选
* time:2,//自动关闭时间 默认2秒 设置0则不自动关闭 可选
* x:0,//横向偏移 正数向右偏移 负数向左偏移 默认为0 可选
* y:0,//纵向偏移 正数向下偏移 负数向上偏移 默认为0 可选
* })
*
*
*/
(function ($) {
$.fn.tips = function(options){
var defaults = {
side:1,
msg:'',
color:'#FFF',
bg:'#F00',
time:2,
x:0,
y:0
}
var options = $.extend(defaults, options);
if (!options.msg||isNaN(options.side)) {
throw new Error('params error');
}
if(!$('#jquery_tips_style').length){
var style='<style id="jquery_tips_style" type="text/css">';
style+='.jq_tips_box{padding:10px;position:absolute;overflow:hidden;display:inline;display:none;z-index:10176523;}';
style+='.jq_tips_arrow{display:block;width:0px;height:0px;position:absolute;}';
style+='.jq_tips_top{border-left:10px solid transparent;left:20px;bottom:0px;}';
style+='.jq_tips_left{border-top:10px solid transparent;right:0px;top:18px;}';
style+='.jq_tips_bottom{border-left:10px solid transparent;left:20px;top:0px;}';
style+='.jq_tips_right{border-top:10px solid transparent;left:0px;top:18px;}';
style+='.jq_tips_info{word-wrap: break-word;word-break:normal;border-radius:4px;padding:5px 8px;max-width:130px;overflow:hidden;box-shadow:1px 1px 1px #999;font-size:12px;cursor:pointer;}';
style+='</style>';
$(document.body).append(style);
}
this.each(function(){
var element=$(this);
var element_top=element.offset().top,element_left=element.offset().left,element_height=element.outerHeight(),element_width=element.outerWidth();
options.side=options.side<1?1:options.side>4?4:Math.round(options.side);
var sideName=options.side==1?'top':options.side==2?'right':options.side==3?'bottom':options.side==4?'left':'top';
var tips=$('<div class="jq_tips_box"><i class="jq_tips_arrow jq_tips_'+sideName+'"></i><div class="jq_tips_info">'+options.msg+'</div></div>').appendTo(document.body);
tips.find('.jq_tips_arrow').css('border-'+sideName,'10px solid '+options.bg);
tips.find('.jq_tips_info').css({
color:options.color,
backgroundColor:options.bg
});
switch(options.side){
case 1:
tips.css({
top:element_top-tips.outerHeight()+options.x,
left:element_left-10+options.y
});
break;
case 2:
tips.css({
top:element_top-20+options.x,
left:element_left+element_width+options.y
});
break;
case 3:
tips.css({
top:element_top+element_height+options.x,
left:element_left-10+options.y
});
break;
case 4:
tips.css({
top:element_top-20+options.x,
left:element_left-tips.outerWidth()+options.y
});
break;
default:
}
var closeTime;
tips.fadeIn('fast').click(function(){
clearTimeout(closeTime);
tips.fadeOut('fast',function(){
tips.remove();
})
})
if(options.time){
closeTime=setTimeout(function(){
tips.click();
},options.time*1000);
tips.hover(function(){
clearTimeout(closeTime);
},function(){
closeTime=setTimeout(function(){
tips.click();
},options.time*1000);
})
}
});
return this;
};
})(jQuery);
\ No newline at end of file
$(function(){
airBalloon('div.air-balloon');
});
/*
@function 热气球移动
@update by julying , 2012/7/25
*/
function airBalloon(balloon){
var viewSize = [] , viewWidth = 0 , viewHeight = 0 ;
resize();
$(balloon).each(function(){
$(this).css({top: rand(40, viewHeight * 0.5 ) , left : rand( 10 , viewWidth - $(this).width() ) });
fly(this);
});
$(window).resize(function(){
resize()
$(balloon).each(function(){
$(this).stop().animate({top: rand(40, viewHeight * 0.5 ) , left : rand( 10 , viewWidth - $(this).width() ) } ,1000 , function(){
fly(this);
});
});
});
function resize(){
viewSize = getViewSize();
viewWidth = $(document).width() ;
viewHeight = viewSize[1] ;
}
function fly(obj){
var $obj = $(obj);
var currentTop = parseInt($obj.css('top'));
var currentLeft = parseInt($obj.css('left') );
var targetLeft = rand( 10 , viewWidth - $obj.width() );
var targetTop = rand(40, viewHeight /2 );
/*求两点之间的距离*/
var removing = Math.sqrt( Math.pow( targetLeft - currentLeft , 2 ) + Math.pow( targetTop - currentTop , 2 ) );
/*每秒移动24px ,计算所需要的时间,从而保持 气球的速度恒定*/
var moveTime = removing / 24;
$obj.animate({ top : targetTop , left : targetLeft} , moveTime * 1000 , function(){
setTimeout(function(){
fly(obj);
}, rand(1000, 3000) );
});
}
};
\ No newline at end of file
......@@ -226,13 +226,19 @@
</dependencies>
<!-- 设定Maven主仓库为阿里私服 -->
<!-- 设定Maven私服仓库 -->
<repositories>
<repository>
<id>repos</id>
<name>Repository</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<!-- 设定插件仓库 -->
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册