mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 17:38:32 +08:00
spring boot init
spring boot init
This commit is contained in:
parent
6181f5d657
commit
fb15e2b070
100
build.gradle
100
build.gradle
@ -22,7 +22,11 @@ configurations.all {
|
||||
//all*.exclude group: 'commons-logging'
|
||||
//exclude group: 'org.slf4j', module: 'slf4j-api'
|
||||
//compile.exclude module: 'commons'
|
||||
//all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
|
||||
//all*.exclude group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j'
|
||||
}
|
||||
|
||||
|
||||
// Apply the java plugin to add support for Java
|
||||
//apply plugin: 'java'
|
||||
allprojects {
|
||||
@ -32,6 +36,14 @@ allprojects {
|
||||
//apply plugin: "findbugs"
|
||||
//apply plugin: "jdepend"
|
||||
|
||||
configurations.all {
|
||||
transitive = false// 为本依赖关闭依赖传递特性
|
||||
//all*.exclude group: 'commons-logging'
|
||||
//exclude group: 'org.slf4j', module: 'slf4j-api'
|
||||
//compile.exclude module: 'commons'
|
||||
//all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
|
||||
exclude(group: "org.apache.logging.log4j", module: "log4j-to-slf4j")
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
@ -80,6 +92,23 @@ subprojects {
|
||||
//apply plugin: 'org.springframework.boot'
|
||||
//apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
//项目名
|
||||
println project.name
|
||||
//项目相对路径
|
||||
println project.path
|
||||
//项目描述
|
||||
println project.description
|
||||
//项目的绝对路径
|
||||
println project.projectDir
|
||||
//项目的build文件绝对路径
|
||||
println project.buildDir
|
||||
//项目所在的group
|
||||
println project.group
|
||||
//项目的版本号
|
||||
println project.version
|
||||
//项目的ant对象
|
||||
println project.ant
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
@ -135,7 +164,8 @@ subprojects {
|
||||
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.10'
|
||||
compile group: 'org.apache.velocity', name: 'velocity', version: '1.7'
|
||||
compile group: 'velocity', name: 'velocity-dep', version: '1.4'
|
||||
testCompile group: 'org.apache.commons', name: 'not-yet-commons-ssl', version: '0.3.9'
|
||||
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.28'
|
||||
//compile group: 'org.apache.commons', name: 'not-yet-commons-ssl', version: '0.3.9'
|
||||
|
||||
compile group: 'org.apache.logging.log4j', name: 'log4j-1.2-api', version: "${log4jVersion}"
|
||||
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4jVersion}"
|
||||
@ -146,13 +176,13 @@ subprojects {
|
||||
compile group: 'org.apache.logging.log4j', name: 'log4j-web', version: "${log4jVersion}"
|
||||
compile group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}"
|
||||
|
||||
compile group: 'org.springframework', name: 'spring-webmvc', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-core', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-aop', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-aspects', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-context', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-context-index', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-beans', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-core', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-context', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-context-indexer', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-context-support', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-expression', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-instrument', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-jcl', version: "${springVersion}"
|
||||
@ -165,31 +195,46 @@ subprojects {
|
||||
compile group: 'org.springframework', name: 'spring-tx', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-web', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-webflux', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-webmvc', version: "${springVersion}"
|
||||
compile group: 'org.springframework', name: 'spring-websocket', version: "${springVersion}"
|
||||
|
||||
compile group: 'org.springframework.security', name: 'spring-security-core', version: "${springSecurityVersion}"
|
||||
compile group: 'org.springframework.security', name: 'spring-security-web', version: "${springSecurityVersion}"
|
||||
compile group: 'org.springframework.security', name: 'spring-security-crypto', version: "${springSecurityVersion}"
|
||||
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-actuator', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: "${springBootVersion}"
|
||||
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: "${springBootVersion}"
|
||||
|
||||
compile group: 'org.opensaml', name: 'opensaml', version: '2.6.4'
|
||||
compile group: 'org.opensaml', name: 'openws', version: '1.5.4'
|
||||
compile group: 'org.opensaml', name: 'xmltooling', version: '1.4.4'
|
||||
|
||||
compile group: 'org.javassist', name: 'javassist', version: '3.23.0-GA'
|
||||
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
|
||||
compile group: 'org.owasp.esapi', name: 'esapi', version: '2.2.0.0'
|
||||
compile group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
|
||||
compile group: 'javax.transaction', name: 'jta', version: '1.1'
|
||||
compile group: 'taglibs', name: 'standard', version: '1.1.2'
|
||||
compile group: 'javax.servlet.jsp.jstl', name: 'jstl', version: '1.2'
|
||||
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
|
||||
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
|
||||
compile group: 'javax.transaction', name: 'jta', version: '1.1'
|
||||
compile group: 'javax.transaction', name: 'javax.transaction-api', version: '1.3'
|
||||
compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
|
||||
compile group: 'org.owasp.esapi', name: 'esapi', version: '2.2.0.0'
|
||||
compile group: 'javax.xml', name: 'jsr173', version: '1.0'
|
||||
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
|
||||
|
||||
compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.60'
|
||||
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
|
||||
compile group: 'org.bouncycastle', name: 'bcprov-ext-jdk15on', version: '1.60'
|
||||
compile group: 'com.google.crypto.tink', name: 'tink', version: '1.2.2'
|
||||
|
||||
compile group: 'com.jhlabs', name: 'filters', version: '2.0.235-1'
|
||||
compile group: 'com.github.penggle', name: 'kaptcha', version: '2.3.2'
|
||||
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
@ -211,7 +256,7 @@ subprojects {
|
||||
compile group: 'org.mybatis', name: 'mybatis-spring', version: '2.0.1'
|
||||
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.47'
|
||||
compile group: 'com.mchange', name: 'c3p0', version: '0.9.5.4'
|
||||
compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.16'
|
||||
//compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.15'
|
||||
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.17.Final'
|
||||
compile group: 'org.hibernate', name: 'hibernate-validator-cdi', version: '6.0.17.Final'
|
||||
compile group: 'org.hibernate.validator', name: 'hibernate-validator-annotation-processor', version: '6.0.17.Final'
|
||||
@ -232,32 +277,33 @@ subprojects {
|
||||
compile group: 'aopalliance', name: 'aopalliance', version: '1.0'
|
||||
compile group: 'org.aspectj', name: 'aspectjtools', version: '1.9.4'
|
||||
compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
|
||||
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
|
||||
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.1'
|
||||
compile group: 'javax.xml', name: 'jsr173', version: '1.0'
|
||||
compile group: 'xalan', name: 'serializer', version: '2.7.2'
|
||||
compile group: 'xalan', name: 'xalan', version: '2.7.2'
|
||||
compile group: 'xerces', name: 'xercesImpl', version: '2.12.0'
|
||||
compile group: 'xml-apis', name: 'xml-apis', version: '1.0.b2'
|
||||
//compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.2'
|
||||
//compile group: 'xalan', name: 'serializer', version: '2.7.2'
|
||||
//compile group: 'xalan', name: 'xalan', version: '2.7.2'
|
||||
//compile group: 'xml-apis', name: 'xml-apis', version: '1.4.01'
|
||||
compile group: 'xml-resolver', name: 'xml-resolver', version: '1.2'
|
||||
compile group: 'org.apache.santuario', name: 'xmlsec', version: '1.5.8'
|
||||
compile group: 'org.ogce', name: 'xpp3', version: '1.1.6'
|
||||
compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
|
||||
testCompile group: 'xmlunit', name: 'xmlunit', version: '1.6'
|
||||
|
||||
|
||||
|
||||
compile group: 'com.belerweb', name: 'pinyin4j', version: '2.5.1'
|
||||
|
||||
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "${springBootVersion}"
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
|
||||
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: "${springBootVersion}"
|
||||
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
|
||||
|
||||
//compile("org.springframework.boot:spring-boot-starter-web")
|
||||
//testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
//local jars
|
||||
compile fileTree(dir: "${rootDir}/maxkey-lib/", include: '*/*.jar')
|
||||
|
||||
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '8.5.43'
|
||||
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '8.5.43'
|
||||
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '8.5.2'
|
||||
|
||||
//compile group: 'org.eclipse.jdt.core.compiler', name: 'ecj', version: '4.6.1'
|
||||
//compile group: 'javax.el', name: 'javax.el-api', version: '3.0.0'
|
||||
//compile group: 'el-impl', name: 'el-impl', version: '1.0'
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -272,8 +318,8 @@ subprojects {
|
||||
"Implementation-Version": project.version)
|
||||
}
|
||||
}
|
||||
/*
|
||||
task checkenv<<{
|
||||
|
||||
/* task checkenv<<{
|
||||
//项目名
|
||||
println project.name
|
||||
//项目相对路径
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
package org.maxkey.authn.support.cas;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jasig.cas.client.util.AbstractCasFilter;
|
||||
import org.jasig.cas.client.validation.Assertion;
|
||||
import org.maxkey.config.ApplicationConfig;
|
||||
import org.maxkey.constants.LOGINTYPE;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class CasEndpoint {
|
||||
private static Logger _logger = LoggerFactory.getLogger(CasEndpoint.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("applicationConfig")
|
||||
protected ApplicationConfig applicationConfig;
|
||||
|
||||
|
||||
/**
|
||||
* init login
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/logon/cas"})
|
||||
public ModelAndView casLogin(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
_logger.debug("CasEndpoint /cas.");
|
||||
|
||||
Assertion assertion = (Assertion) request.getSession().getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
|
||||
|
||||
|
||||
String username= assertion.getPrincipal().getName();
|
||||
|
||||
_logger.debug("CAS username : "+username);
|
||||
|
||||
if(WebContext.setAuthentication(username,LOGINTYPE.CAS,"","","success")){
|
||||
|
||||
}
|
||||
|
||||
|
||||
return WebContext.redirect("/login");
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
package org.maxkey.authn.support.cas;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
|
||||
public class CasEntryPoint implements AuthenticationEntryPoint {
|
||||
|
||||
private static final Logger _logger = LoggerFactory.getLogger(CasEntryPoint.class);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.security.web.AuthenticationEntryPoint#commence(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.security.core.AuthenticationException)
|
||||
*/
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException ex) throws IOException, ServletException {
|
||||
|
||||
_logger.debug("CasEntryPoint..");
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,7 +41,10 @@ import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.bouncycastle.asn1.DERObjectIdentifier;
|
||||
import org.bouncycastle.asn1.x500.X500Name;
|
||||
import org.bouncycastle.asn1.x509.X509Name;
|
||||
import org.bouncycastle.cert.X509v3CertificateBuilder;
|
||||
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
|
||||
import org.bouncycastle.jce.PKCS10CertificationRequest;
|
||||
import org.bouncycastle.jce.PrincipalUtil;
|
||||
import org.bouncycastle.jce.X509Principal;
|
||||
@ -590,10 +593,14 @@ public final class X509CertUtils {
|
||||
int iValidity, PublicKey publicKey, PrivateKey privateKey,
|
||||
SignatureType signatureType) throws CryptoException {
|
||||
// Holds certificate attributes
|
||||
|
||||
|
||||
|
||||
Hashtable<DERObjectIdentifier, String> attrs = new Hashtable<DERObjectIdentifier, String>();
|
||||
Vector<DERObjectIdentifier> vOrder = new Vector<DERObjectIdentifier>();
|
||||
|
||||
// Load certificate attributes
|
||||
/*
|
||||
if (sCommonName != null) {
|
||||
attrs.put(X509Name.CN, sCommonName);
|
||||
vOrder.add(0, X509Name.CN);
|
||||
@ -627,7 +634,7 @@ public final class X509CertUtils {
|
||||
if (sEmailAddress != null) {
|
||||
attrs.put(X509Name.E, sEmailAddress);
|
||||
vOrder.add(0, X509Name.E);
|
||||
}
|
||||
}*/
|
||||
|
||||
// Get an X509 Version 1 Certificate generator
|
||||
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
|
||||
@ -654,6 +661,14 @@ public final class X509CertUtils {
|
||||
// Set the serial number
|
||||
certGen.setSerialNumber(generateX509SerialNumber());
|
||||
|
||||
X509v3CertificateBuilder builder = new JcaX509v3CertificateBuilder(
|
||||
new X500Name("issueDn"),
|
||||
generateX509SerialNumber(),
|
||||
new Date(System.currentTimeMillis()),
|
||||
new Date(System.currentTimeMillis()+ ((long) iValidity * 24 * 60 * 60 * 1000)),
|
||||
new X500Name("subjectDn"),
|
||||
publicKey);
|
||||
|
||||
try {
|
||||
// Generate an X.509 certificate, based on the current issuer and
|
||||
// subject
|
||||
|
||||
@ -19,10 +19,6 @@
|
||||
*/
|
||||
package org.maxkey.crypto.jose;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.nimbusds.jose.JWEAlgorithm;
|
||||
|
||||
@ -33,7 +29,7 @@ import com.nimbusds.jose.JWEAlgorithm;
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Embeddable
|
||||
|
||||
public class JWEAlgorithmEmbed {
|
||||
|
||||
public static final JWEAlgorithmEmbed NONE = getForAlgorithmName("none");
|
||||
@ -62,7 +58,7 @@ public class JWEAlgorithmEmbed {
|
||||
* Get the name of this algorithm, return null if no algorithm set.
|
||||
* @return
|
||||
*/
|
||||
@Basic
|
||||
|
||||
public String getAlgorithmName() {
|
||||
if (algorithm != null) {
|
||||
return algorithm.getName();
|
||||
@ -95,7 +91,6 @@ public class JWEAlgorithmEmbed {
|
||||
/**
|
||||
* @return the algorithm
|
||||
*/
|
||||
@Transient
|
||||
public JWEAlgorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
@ -19,9 +19,6 @@
|
||||
*/
|
||||
package org.maxkey.crypto.jose;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.nimbusds.jose.EncryptionMethod;
|
||||
@ -30,7 +27,7 @@ import com.nimbusds.jose.EncryptionMethod;
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Embeddable
|
||||
|
||||
public class JWEEncryptionMethodEmbed {
|
||||
|
||||
public static final JWEEncryptionMethodEmbed NONE = getForAlgorithmName("none");
|
||||
@ -59,7 +56,7 @@ public class JWEEncryptionMethodEmbed {
|
||||
* Get the name of this algorithm, return null if no algorithm set.
|
||||
* @return
|
||||
*/
|
||||
@Basic
|
||||
|
||||
public String getAlgorithmName() {
|
||||
if (algorithm != null) {
|
||||
return algorithm.getName();
|
||||
@ -92,7 +89,7 @@ public class JWEEncryptionMethodEmbed {
|
||||
/**
|
||||
* @return the algorithm
|
||||
*/
|
||||
@Transient
|
||||
|
||||
public EncryptionMethod getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
@ -19,10 +19,6 @@
|
||||
*/
|
||||
package org.maxkey.crypto.jose;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.nimbusds.jose.JWSAlgorithm;
|
||||
|
||||
@ -33,7 +29,7 @@ import com.nimbusds.jose.JWSAlgorithm;
|
||||
* @author jricher
|
||||
*
|
||||
*/
|
||||
@Embeddable
|
||||
|
||||
public class JWSAlgorithmEmbed {
|
||||
|
||||
public static final JWSAlgorithmEmbed NONE = getForAlgorithmName("none");
|
||||
@ -67,7 +63,7 @@ public class JWSAlgorithmEmbed {
|
||||
* Get the name of this algorithm, return null if no algorithm set.
|
||||
* @return
|
||||
*/
|
||||
@Basic
|
||||
|
||||
public String getAlgorithmName() {
|
||||
if (algorithm != null) {
|
||||
return algorithm.getName();
|
||||
@ -92,7 +88,7 @@ public class JWSAlgorithmEmbed {
|
||||
/**
|
||||
* @return the algorithm
|
||||
*/
|
||||
@Transient
|
||||
|
||||
public JWSAlgorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.maxkey.authz.oauth2.common.util;
|
||||
package org.maxkey.util;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package org.maxkey.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.maxkey.web.tag.BaseTagDirective;
|
||||
import org.maxkey.web.tag.FreemarkerTag;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.TemplateException;
|
||||
|
||||
@Component
|
||||
public class MaxKeyFreeMarkerConfigurer implements ApplicationContextAware {
|
||||
|
||||
ApplicationContext applicationContext ;
|
||||
|
||||
@Autowired
|
||||
Configuration configuration;
|
||||
|
||||
@Autowired
|
||||
BaseTagDirective baseTagDirective;
|
||||
|
||||
@PostConstruct // 在项目启动时执行方法
|
||||
public void setSharedVariable() throws IOException, TemplateException {
|
||||
// configuration.setSharedVariable("base", baseTagDirective);
|
||||
// 根据注解FreemarkerTag获取bean ,key is bean name ,value is bean object
|
||||
Map<String, Object> map = this.applicationContext.getBeansWithAnnotation(FreemarkerTag.class);
|
||||
for (String key : map.keySet()) {
|
||||
configuration.setSharedVariable(key, map.get(key));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
|
||||
|
||||
/**
|
||||
* 获取请求地址及应用上下文标签
|
||||
* get Http Context full Path,if port equals 80 is omitted
|
||||
* @return String
|
||||
* eg:http://192.168.1.20:9080/webcontext or http://www.website.com/webcontext
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class BasePathTag extends BodyTagSupport{
|
||||
private static final long serialVersionUID = 4494502315876572711L;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
String basePath="";
|
||||
HttpServletRequest request = (HttpServletRequest)this.pageContext.getRequest();
|
||||
basePath = request.getScheme()+"://"+request.getServerName();
|
||||
int port=request.getServerPort();
|
||||
if(port==443 && request.getScheme().equalsIgnoreCase("https")){
|
||||
|
||||
}else if(port==80 && request.getScheme().equalsIgnoreCase("http")){
|
||||
|
||||
}else{
|
||||
basePath += ":"+port;
|
||||
}
|
||||
basePath += request.getContextPath()+"";
|
||||
|
||||
try{
|
||||
pageContext.getOut().print(basePath);
|
||||
pageContext.getOut().flush();
|
||||
}catch(Exception e){
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
}
|
||||
|
||||
public void realse(){
|
||||
pageContext=null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
|
||||
/**
|
||||
* <@basePath/>
|
||||
* 获取请求地址及应用上下文标签
|
||||
* get Http Context full Path,if port equals 80 443 is omitted
|
||||
* @return String
|
||||
* eg:http://192.168.1.20:9080/webcontext or http://www.website.com/webcontext
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("basePath")
|
||||
public class BasePathTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private String basePath = null;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
if(basePath==null) {
|
||||
basePath = request.getScheme()+"://"+request.getServerName();
|
||||
int port=request.getServerPort();
|
||||
if(port==443 && request.getScheme().equalsIgnoreCase("https")){
|
||||
|
||||
}else if(port==80 && request.getScheme().equalsIgnoreCase("http")){
|
||||
|
||||
}else{
|
||||
basePath += ":"+port;
|
||||
}
|
||||
basePath += request.getContextPath()+"";
|
||||
}
|
||||
env.getOut().append(basePath);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
|
||||
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class BaseTag extends BodyTagSupport
|
||||
{
|
||||
private static final long serialVersionUID = 4494502315876572711L;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
String base="";
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest)this.pageContext.getRequest();
|
||||
base=request.getContextPath();
|
||||
|
||||
try{
|
||||
pageContext.getOut().print(base);
|
||||
pageContext.getOut().flush();
|
||||
}catch(Exception e){
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
|
||||
}
|
||||
|
||||
public void realse(){
|
||||
pageContext=null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@base/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("base")
|
||||
public class BaseTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private static String base = null;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
//String url = params.get(URL).toString();
|
||||
if(base==null) {
|
||||
base=request.getContextPath();
|
||||
}
|
||||
env.getOut().append(base);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
|
||||
/**
|
||||
* 浏览器版本标签
|
||||
* 根据浏览器版本包含html
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class BrowserTag extends BodyTagSupport{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2336696641611234784L;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
String version;
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
public int doEndTag() throws JspException {
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
public int doStartTag() throws JspException {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest)this.pageContext.getRequest();
|
||||
String userAgent = request.getHeader("User-Agent");
|
||||
try {
|
||||
pageContext.getOut().print("<!--<div style='display:none'>"+userAgent+"</div>-->");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(userAgent.indexOf(version)>0){
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
return SKIP_BODY;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@browser name=""></@browser>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("browser")
|
||||
public class BrowserTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
String browser = params.get("name").toString();
|
||||
String userAgent = request.getHeader("User-Agent");
|
||||
env.getOut().append("<!--<div style='display:none'>"+userAgent+"</div>-->");
|
||||
|
||||
if(userAgent.indexOf(browser)>0){
|
||||
body.render(env.getOut());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,135 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.Tag;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.maxkey.web.WebContext;
|
||||
|
||||
public class ColumnTag extends TagSupport {
|
||||
|
||||
private String field;
|
||||
|
||||
private String title;
|
||||
|
||||
private int width;
|
||||
|
||||
private boolean hidden;
|
||||
|
||||
private boolean sortable;
|
||||
|
||||
private String formatter;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5581918481537828383L;
|
||||
|
||||
|
||||
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public int doStartTag() throws JspException {
|
||||
Tag pTag =this.getParent();
|
||||
if(pTag.getClass().getSimpleName().equalsIgnoreCase("GridTag")){
|
||||
List<GridColumn> listGridColumn=(List<GridColumn>)pageContext.getAttribute(GridTag.GridTagAttribute);
|
||||
String i18nTitle=WebContext.getI18nValue(title);
|
||||
if(i18nTitle != null){
|
||||
title = i18nTitle;
|
||||
}
|
||||
GridColumn gridColumn=new GridColumn(field,title,width,hidden,sortable,formatter);
|
||||
|
||||
if(listGridColumn == null){
|
||||
listGridColumn=new ArrayList<GridColumn>();
|
||||
}
|
||||
|
||||
listGridColumn.add(gridColumn);
|
||||
pageContext.setAttribute(GridTag.GridTagAttribute, listGridColumn);
|
||||
|
||||
}else{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
return super.doStartTag();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSortable() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
|
||||
public void setSortable(boolean sortable) {
|
||||
this.sortable = sortable;
|
||||
}
|
||||
|
||||
|
||||
public String getFormatter() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
|
||||
public void setFormatter(String formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
|
||||
import org.maxkey.util.DateUtils;
|
||||
|
||||
public class DateTag extends BodyTagSupport {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2223298103020379292L;
|
||||
private PageContext pageContext;
|
||||
private String format;
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
try {
|
||||
// HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
|
||||
if (format != null && !format.equals("")) {
|
||||
pageContext.getOut().print(DateUtils.getCurrentDateAsString(format));
|
||||
}else{
|
||||
pageContext.getOut().print(DateUtils.getCurrentDateAsString(DateUtils.FORMAT_DATE_YYYY_MM_DD));
|
||||
}
|
||||
pageContext.getOut().flush();
|
||||
} catch (Exception e) {
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
// TODO: handle exception
|
||||
}
|
||||
return tagReturn;
|
||||
}
|
||||
public void realse(){
|
||||
pageContext=null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@date format="" value=""></@date>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("date")
|
||||
public class DateTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
String dateValue = params.get("value").toString();
|
||||
String format = params.get("format").toString();
|
||||
String dateString="";
|
||||
if(dateValue==null) {
|
||||
if(format==null) {
|
||||
dateString=DateUtils.getCurrentDateAsString(DateUtils.FORMAT_DATE_YYYY_MM_DD);
|
||||
}else {
|
||||
dateString=DateUtils.getCurrentDateAsString(format);
|
||||
}
|
||||
}else {
|
||||
if(format==null) {
|
||||
dateString=DateUtils.format(DateUtils.tryParse(dateValue),DateUtils.FORMAT_DATE_YYYY_MM_DD);
|
||||
}else {
|
||||
dateString=DateUtils.format(DateUtils.tryParse(dateValue),format);
|
||||
}
|
||||
}
|
||||
|
||||
env.getOut().append(dateString);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,103 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.maxkey.web.WebContext;
|
||||
|
||||
public class DialogTag extends TagSupport {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3872210456717811884L;
|
||||
|
||||
|
||||
private String url;
|
||||
|
||||
private String title;
|
||||
|
||||
private int width=300;
|
||||
|
||||
private int height=400;
|
||||
|
||||
private String text;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
|
||||
@Override
|
||||
public int doStartTag() throws JspException {
|
||||
|
||||
String i18nTitle=WebContext.getI18nValue(title);
|
||||
if(i18nTitle != null){
|
||||
title = i18nTitle;
|
||||
}
|
||||
|
||||
String i18nText=WebContext.getI18nValue(text);
|
||||
if(i18nText != null){
|
||||
text = i18nText;
|
||||
}
|
||||
|
||||
try {
|
||||
pageContext.getOut().println("<input class=\"window button\" type=\"button\" value=\""+text+"\" title=\""+title+"\" ");
|
||||
pageContext.getOut().println("wurl=\""+pageContext.getServletContext().getContextPath()+url+"\" wwidth=\""+width+"\" wheight=\""+height+"\" />" );
|
||||
return SKIP_BODY;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return super.doStartTag();
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@dialog url="" title="" text="" width=500 height=100 />
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("dialog")
|
||||
public class DialogTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private String url;
|
||||
|
||||
private String title;
|
||||
|
||||
private int width=300;
|
||||
|
||||
private int height=400;
|
||||
|
||||
private String text;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
|
||||
url=params.get("url").toString();
|
||||
title=params.get("title").toString();
|
||||
text=params.get("text").toString();
|
||||
if(params.get("width")!=null) {
|
||||
width=Integer.parseInt(params.get("width").toString());
|
||||
}
|
||||
if(params.get("height")!=null) {
|
||||
height=Integer.parseInt(params.get("height").toString());
|
||||
}
|
||||
|
||||
env.getOut().append("<input class=\"window button\" type=\"button\" value=\""+text+"\" title=\""+title+"\" ");
|
||||
env.getOut().append("wurl=\""+request.getContextPath()+url+"\" wwidth=\""+width+"\" wheight=\""+height+"\" />" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Target(value = ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Component
|
||||
public @interface FreemarkerTag {
|
||||
String value() default "";
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.BodyTagSupport;
|
||||
|
||||
|
||||
/**
|
||||
* 主键或者唯一编号生成标签
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class GenIdTag extends BodyTagSupport
|
||||
{
|
||||
private static final long serialVersionUID = 4494502315876572711L;
|
||||
private PageContext pageContext;
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
try{
|
||||
pageContext.getOut().print(UUID.randomUUID().toString().toLowerCase());
|
||||
pageContext.getOut().flush();
|
||||
}catch(Exception e){
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
|
||||
}
|
||||
|
||||
public void realse(){
|
||||
pageContext=null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@genId/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("genId")
|
||||
public class GenIdTagDirective implements TemplateDirectiveModel {
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
env.getOut().append(UUID.randomUUID().toString().toLowerCase());
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,118 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
public class GridColumn {
|
||||
|
||||
private String field;
|
||||
|
||||
private String title;
|
||||
|
||||
private int width;
|
||||
|
||||
private boolean hidden;
|
||||
|
||||
private boolean sortable;
|
||||
|
||||
private String formatter;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public GridColumn() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param field
|
||||
* @param title
|
||||
* @param width
|
||||
* @param hidden
|
||||
* @param sortable
|
||||
* @param formatter
|
||||
*/
|
||||
public GridColumn(String field, String title, int width, boolean hidden,
|
||||
boolean sortable, String formatter) {
|
||||
this.field = field;
|
||||
this.title = title;
|
||||
this.width = width;
|
||||
this.hidden = hidden;
|
||||
this.sortable = sortable;
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(String field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public boolean isSortable() {
|
||||
return sortable;
|
||||
}
|
||||
|
||||
public void setSortable(boolean sortable) {
|
||||
this.sortable = sortable;
|
||||
}
|
||||
|
||||
public String getFormatter() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
public void setFormatter(String formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
public String getJson(){
|
||||
StringBuffer sb=new StringBuffer("{");
|
||||
sb.append("name :\"").append(this.field).append("\", ");
|
||||
sb.append("index :\"").append(this.field).append("\", ");
|
||||
sb.append("width :").append(this.width).append(", ");
|
||||
sb.append("hidden :").append(this.hidden).append(", ");
|
||||
if(this.formatter==null){
|
||||
sb.append("sortable :").append(this.sortable).append(" ");
|
||||
}else{
|
||||
sb.append("sortable :").append(this.sortable).append(", ");
|
||||
sb.append("formatter :").append(this.formatter).append("");
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GridColumn [field=" + field + ", title=" + title + ", width="
|
||||
+ width + ", hidden=" + hidden + ", sortable=" + sortable
|
||||
+ ", formatter=" + formatter + "]";
|
||||
}
|
||||
}
|
||||
@ -1,265 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class GridTag extends TagSupport {
|
||||
final static Logger _logger = LoggerFactory.getLogger(GridTag.class);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1243669057069893859L;
|
||||
|
||||
|
||||
public static final String GridTagAttribute=GridTag.class.getName()+"_GridTagAttribute";
|
||||
|
||||
public static final int MultiSelectColumnWidth=903;
|
||||
|
||||
public static final int DefaultColumnWidth=928;
|
||||
|
||||
private String id;
|
||||
|
||||
private String url;
|
||||
|
||||
private boolean multiselect;
|
||||
|
||||
private String onSelect;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
private boolean resize=true;
|
||||
|
||||
private int rowLimit=10;
|
||||
|
||||
private String rowList="[10,50,100]";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public int doEndTag() throws JspException {
|
||||
List<GridColumn> listGridColumn=(List<GridColumn>)pageContext.getAttribute(GridTag.GridTagAttribute);
|
||||
|
||||
try {
|
||||
if(url == null){
|
||||
pageContext.getOut().println("<div>Grid URL can not be null . </div>");
|
||||
return super.doEndTag();
|
||||
}
|
||||
_logger.debug(""+listGridColumn);
|
||||
|
||||
StringBuffer colNames=new StringBuffer("");
|
||||
colNames.append("\t colNames : [\n");
|
||||
|
||||
StringBuffer colModel=new StringBuffer("");
|
||||
colModel.append("\t colModel : [\n");
|
||||
int visibleColumnWidth=0;
|
||||
int visibleColumnCount=0;
|
||||
for(int i=0;i<listGridColumn.size();i++){
|
||||
GridColumn gridColumn=listGridColumn.get(i);
|
||||
String titleText=WebContext.getI18nValue(gridColumn.getTitle());
|
||||
if(titleText==null||titleText.equals("")){
|
||||
String []localPath=gridColumn.getTitle().split("\\.");
|
||||
titleText=localPath[(localPath.length>1?localPath.length-1:0)];
|
||||
titleText=titleText.toUpperCase().charAt(0)+titleText.substring(1);
|
||||
}
|
||||
if(i<listGridColumn.size()-1){
|
||||
colNames.append("\t\t\"").append(titleText).append("\",\n");
|
||||
colModel.append("\t\t").append(gridColumn.getJson()).append(",\n");
|
||||
}else{
|
||||
colNames.append("\t\t\"").append(titleText).append("\"");
|
||||
colModel.append("\t\t").append(gridColumn.getJson());
|
||||
}
|
||||
if(!gridColumn.isHidden()){
|
||||
visibleColumnWidth+=gridColumn.getWidth();
|
||||
visibleColumnCount++;
|
||||
}
|
||||
}
|
||||
colNames.append("\n\t ], ");
|
||||
colModel.append("\n\t ] ");
|
||||
|
||||
StringBuffer gridsb=new StringBuffer("");
|
||||
if(visibleColumnWidth>MultiSelectColumnWidth&&this.isMultiselect()){
|
||||
gridsb.append("<div>Grid Column Width "+visibleColumnWidth+" greate than "+MultiSelectColumnWidth+" . </div>");
|
||||
pageContext.getOut().println(gridsb);
|
||||
return super.doEndTag();
|
||||
}else if(visibleColumnWidth>DefaultColumnWidth){
|
||||
gridsb.append("<div>Grid Column Width "+visibleColumnWidth+" greate than "+DefaultColumnWidth+" . </div>");
|
||||
pageContext.getOut().println(gridsb);
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
int currentRowLimit = rowLimit;
|
||||
if(WebContext.getAttribute(GridTag.class.getName()+"_PageResults")!=null){
|
||||
currentRowLimit=Integer.parseInt(WebContext.getAttribute(GridTag.class.getName()+"_PageResults").toString());
|
||||
_logger.debug("current RowLimit "+currentRowLimit);
|
||||
}
|
||||
|
||||
gridsb.append("\n<script type=\"text/javascript\">\n<!--");
|
||||
gridsb.append("\nvar "+id+"_gridSettings={");
|
||||
gridsb.append("\n\t element : \""+id+"\",");
|
||||
gridsb.append("\n\t url : '"+pageContext.getServletContext().getContextPath()+url+"',");
|
||||
gridsb.append("\n\t visibleColumnWidth : "+visibleColumnWidth+",");
|
||||
gridsb.append("\n\t visibleColumnCount : "+visibleColumnCount+",");
|
||||
gridsb.append("\n\t columnWidth : "+bulidColumnWidth(visibleColumnCount)+",");
|
||||
gridsb.append("\n\t multiselect : "+multiselect+",");
|
||||
gridsb.append("\n\t resize : "+resize+",");
|
||||
gridsb.append("\n\t rowNum : "+currentRowLimit+",");
|
||||
gridsb.append("\n\t rowList : "+rowList+",");
|
||||
|
||||
if(onSelect != null){
|
||||
gridsb.append("\n\t onSelectRow : "+onSelect+",");
|
||||
}
|
||||
|
||||
gridsb.append("\n"+colNames.toString()+"");
|
||||
gridsb.append("\n"+colModel.toString()+"");
|
||||
|
||||
gridsb.append("\n};");
|
||||
gridsb.append("\n$(function () {");
|
||||
gridsb.append("\n\t $.grid("+id+"_gridSettings);");
|
||||
gridsb.append("\n});");
|
||||
|
||||
gridsb.append("\n-->\n</script>");
|
||||
|
||||
gridsb.append("\n<table id=\""+id+"\" class=\"scroll\"></table>");
|
||||
gridsb.append("\n<div id=\""+id+"_pager"+"\" class=\"scroll\" style=\"text-align: center;\"></div>");
|
||||
pageContext.getOut().println(gridsb);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
pageContext.removeAttribute(GridTag.GridTagAttribute);
|
||||
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
|
||||
public int bulidColumnWidth(int visibleColumnCount){
|
||||
int columnWidth=0;
|
||||
if(this.isMultiselect()){
|
||||
if(visibleColumnCount>5){
|
||||
columnWidth=MultiSelectColumnWidth-5*(visibleColumnCount-6);
|
||||
}else if(visibleColumnCount<5){
|
||||
columnWidth=MultiSelectColumnWidth+5*(5-visibleColumnCount);
|
||||
}else{
|
||||
columnWidth=MultiSelectColumnWidth;
|
||||
}
|
||||
}else{
|
||||
if(visibleColumnCount>5){
|
||||
columnWidth=DefaultColumnWidth-5*(visibleColumnCount-6);
|
||||
}else if(visibleColumnCount<5){
|
||||
columnWidth=DefaultColumnWidth+5*(5-visibleColumnCount);
|
||||
}else{
|
||||
columnWidth=DefaultColumnWidth;
|
||||
}
|
||||
}
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public int doStartTag() throws JspException {
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setValue(String k, Object o) {
|
||||
// TODO Auto-generated method stub
|
||||
super.setValue(k, o);
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public boolean isMultiselect() {
|
||||
return multiselect;
|
||||
}
|
||||
|
||||
public void setMultiselect(boolean multiselect) {
|
||||
this.multiselect = multiselect;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getOnSelect() {
|
||||
return onSelect;
|
||||
}
|
||||
|
||||
|
||||
public void setOnSelect(String onSelect) {
|
||||
this.onSelect = onSelect;
|
||||
}
|
||||
|
||||
|
||||
public boolean isResize() {
|
||||
return resize;
|
||||
}
|
||||
|
||||
|
||||
public void setResize(boolean resize) {
|
||||
this.resize = resize;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the rowLimit
|
||||
*/
|
||||
public int getRowLimit() {
|
||||
return rowLimit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param rowLimit the rowLimit to set
|
||||
*/
|
||||
public void setRowLimit(int rowLimit) {
|
||||
this.rowLimit = rowLimit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the rowList
|
||||
*/
|
||||
public String getRowList() {
|
||||
return rowList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param rowList the rowList to set
|
||||
*/
|
||||
public void setRowList(String rowList) {
|
||||
this.rowList = rowList;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,422 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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.
|
||||
*/
|
||||
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.JspTagException;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.NoSuchMessageException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.tags.ArgumentAware;
|
||||
import org.springframework.web.servlet.tags.HtmlEscapingAwareTag;
|
||||
import org.springframework.web.util.JavaScriptUtils;
|
||||
import org.springframework.web.util.TagUtils;
|
||||
|
||||
/**
|
||||
* The {@code <message>} tag looks up a message in the scope of this page.
|
||||
* Messages are resolved using the ApplicationContext and thus support
|
||||
* internationalization.
|
||||
*
|
||||
* <p>Detects an HTML escaping setting, either on this tag instance, the page level,
|
||||
* or the {@code web.xml} level. Can also apply JavaScript escaping.
|
||||
*
|
||||
* <p>If "code" isn't set or cannot be resolved, "text" will be used as default
|
||||
* message. Thus, this tag can also be used for HTML escaping of any texts.
|
||||
*
|
||||
* <p>Message arguments can be specified via the {@link #setArguments(Object) arguments}
|
||||
* attribute or by using nested {@code <spring:argument>} tags.
|
||||
*
|
||||
* <table>
|
||||
* <caption>Attribute Summary</caption>
|
||||
* <thead>
|
||||
* <tr>
|
||||
* <th>Attribute</th>
|
||||
* <th>Required?</th>
|
||||
* <th>Runtime Expression?</th>
|
||||
* <th>Description</th>
|
||||
* </tr>
|
||||
* </thead>
|
||||
* <tbody>
|
||||
* <tr>
|
||||
* <td>arguments</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>Set optional message arguments for this tag, as a (comma-)delimited
|
||||
* String (each String argument can contain JSP EL), an Object array (used as
|
||||
* argument array), or a single Object (used as single argument).</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>argumentSeparator</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>The separator character to be used for splitting the arguments string
|
||||
* value; defaults to a 'comma' (',').</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>code</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>The code (key) to use when looking up the message.
|
||||
* If code is not provided, the text attribute will be used.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>htmlEscape</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>Set HTML escaping for this tag, as boolean value.
|
||||
* Overrides the default HTML escaping setting for the current page.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>javaScriptEscape</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>Set JavaScript escaping for this tag, as boolean value.
|
||||
* Default is false.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>message</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>A MessageSourceResolvable argument (direct or through JSP EL).
|
||||
* Fits nicely when used in conjunction with Spring’s own validation error
|
||||
* classes which all implement the MessageSourceResolvable interface.
|
||||
* For example, this allows you to iterate over all of the errors in a form,
|
||||
* passing each error (using a runtime expression) as the value of this
|
||||
* 'message' attribute, thus effecting the easy display of such error
|
||||
* messages.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>scope</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>The scope to use when exporting the result to a variable. This attribute
|
||||
* is only used when var is also set. Possible values are page, request, session
|
||||
* and application.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>text</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>Default text to output when a message for the given code could not be
|
||||
* found. If both text and code are not set, the tag will output null.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>var</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* <td>The string to use when binding the result to the page, request, session
|
||||
* or application scope. If not specified, the result gets outputted to the writer
|
||||
* (i.e. typically directly to the JSP).</td>
|
||||
* </tr>
|
||||
* </tbody>
|
||||
* </table>
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Nicholas Williams
|
||||
* @see #setCode
|
||||
* @see #setText
|
||||
* @see #setHtmlEscape
|
||||
* @see #setJavaScriptEscape
|
||||
* @see HtmlEscapeTag#setDefaultHtmlEscape
|
||||
* @see org.springframework.web.util.WebUtils#HTML_ESCAPE_CONTEXT_PARAM
|
||||
* @see ArgumentTag
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class LocaleTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
|
||||
/**
|
||||
* Default separator for splitting an arguments String: a comma (",").
|
||||
*/
|
||||
public static final String DEFAULT_ARGUMENT_SEPARATOR = ",";
|
||||
|
||||
|
||||
@Nullable
|
||||
private MessageSourceResolvable message;
|
||||
|
||||
@Nullable
|
||||
private String code;
|
||||
|
||||
@Nullable
|
||||
private Object arguments;
|
||||
|
||||
private String argumentSeparator = DEFAULT_ARGUMENT_SEPARATOR;
|
||||
|
||||
private List<Object> nestedArguments = Collections.emptyList();
|
||||
|
||||
@Nullable
|
||||
private String text;
|
||||
|
||||
@Nullable
|
||||
private String var;
|
||||
|
||||
private String scope = TagUtils.SCOPE_PAGE;
|
||||
|
||||
private boolean javaScriptEscape = false;
|
||||
|
||||
|
||||
/**
|
||||
* Set the MessageSourceResolvable for this tag.
|
||||
* <p>If a MessageSourceResolvable is specified, it effectively overrides
|
||||
* any code, arguments or text specified on this tag.
|
||||
*/
|
||||
public void setMessage(MessageSourceResolvable message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message code for this tag.
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set optional message arguments for this tag, as a comma-delimited
|
||||
* String (each String argument can contain JSP EL), an Object array
|
||||
* (used as argument array), or a single Object (used as single argument).
|
||||
*/
|
||||
public void setArguments(Object arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the separator to use for splitting an arguments String.
|
||||
* Default is a comma (",").
|
||||
* @see #setArguments
|
||||
*/
|
||||
public void setArgumentSeparator(String argumentSeparator) {
|
||||
this.argumentSeparator = argumentSeparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgument(@Nullable Object argument) throws JspTagException {
|
||||
this.nestedArguments.add(argument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message text for this tag.
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PageContext attribute name under which to expose
|
||||
* a variable that contains the resolved message.
|
||||
* @see #setScope
|
||||
* @see javax.servlet.jsp.PageContext#setAttribute
|
||||
*/
|
||||
public void setVar(String var) {
|
||||
this.var = var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the scope to export the variable to.
|
||||
* Default is SCOPE_PAGE ("page").
|
||||
* @see #setVar
|
||||
* @see org.springframework.web.util.TagUtils#SCOPE_PAGE
|
||||
* @see javax.servlet.jsp.PageContext#setAttribute
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set JavaScript escaping for this tag, as boolean value.
|
||||
* Default is "false".
|
||||
*/
|
||||
public void setJavaScriptEscape(boolean javaScriptEscape) throws JspException {
|
||||
this.javaScriptEscape = javaScriptEscape;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected final int doStartTagInternal() throws JspException, IOException {
|
||||
this.nestedArguments = new LinkedList<>();
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the message, escapes it if demanded,
|
||||
* and writes it to the page (or exposes it as variable).
|
||||
* @see #resolveMessage()
|
||||
* @see org.springframework.web.util.HtmlUtils#htmlEscape(String)
|
||||
* @see org.springframework.web.util.JavaScriptUtils#javaScriptEscape(String)
|
||||
* @see #writeMessage(String)
|
||||
*/
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
try {
|
||||
if(code==null) {
|
||||
pageContext.getOut().print(getRequestContext().getLocale());
|
||||
}else {
|
||||
// Resolve the unescaped message.
|
||||
String msg = resolveMessage();
|
||||
|
||||
// HTML and/or JavaScript escape, if demanded.
|
||||
msg = htmlEscape(msg);
|
||||
msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;
|
||||
|
||||
// Expose as variable, if demanded, else write to the page.
|
||||
if (this.var != null) {
|
||||
this.pageContext.setAttribute(this.var, msg, TagUtils.getScope(this.scope));
|
||||
}
|
||||
else {
|
||||
writeMessage(msg);
|
||||
}
|
||||
}
|
||||
return EVAL_PAGE;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
System.out.println("IOException code "+code);
|
||||
throw new JspTagException(ex.getMessage(), ex);
|
||||
}
|
||||
catch (NoSuchMessageException ex) {
|
||||
System.out.println("IOException code "+code);
|
||||
throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
super.release();
|
||||
this.arguments = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolve the specified message into a concrete message String.
|
||||
* The returned message String should be unescaped.
|
||||
*/
|
||||
protected String resolveMessage() throws JspException, NoSuchMessageException {
|
||||
MessageSource messageSource = getMessageSource();
|
||||
|
||||
// Evaluate the specified MessageSourceResolvable, if any.
|
||||
if (this.message != null) {
|
||||
// We have a given MessageSourceResolvable.
|
||||
return messageSource.getMessage(this.message, getRequestContext().getLocale());
|
||||
}
|
||||
|
||||
if (this.code != null || this.text != null) {
|
||||
// We have a code or default text that we need to resolve.
|
||||
Object[] argumentsArray = resolveArguments(this.arguments);
|
||||
if (!this.nestedArguments.isEmpty()) {
|
||||
argumentsArray = appendArguments(argumentsArray, this.nestedArguments.toArray());
|
||||
}
|
||||
|
||||
if (this.text != null) {
|
||||
// We have a fallback text to consider.
|
||||
String msg = messageSource.getMessage(
|
||||
this.code, argumentsArray, this.text, getRequestContext().getLocale());
|
||||
return (msg != null ? msg : "");
|
||||
}
|
||||
else {
|
||||
// We have no fallback text to consider.
|
||||
return messageSource.getMessage(
|
||||
this.code, argumentsArray, getRequestContext().getLocale());
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("No resolvable message for code "+code);
|
||||
return argumentSeparator;
|
||||
}
|
||||
|
||||
private Object[] appendArguments(@Nullable Object[] sourceArguments, Object[] additionalArguments) {
|
||||
if (ObjectUtils.isEmpty(sourceArguments)) {
|
||||
return additionalArguments;
|
||||
}
|
||||
Object[] arguments = new Object[sourceArguments.length + additionalArguments.length];
|
||||
System.arraycopy(sourceArguments, 0, arguments, 0, sourceArguments.length);
|
||||
System.arraycopy(additionalArguments, 0, arguments, sourceArguments.length, additionalArguments.length);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given arguments Object into an arguments array.
|
||||
* @param arguments the specified arguments Object
|
||||
* @return the resolved arguments as array
|
||||
* @throws JspException if argument conversion failed
|
||||
* @see #setArguments
|
||||
*/
|
||||
@Nullable
|
||||
protected Object[] resolveArguments(@Nullable Object arguments) throws JspException {
|
||||
if (arguments instanceof String) {
|
||||
String[] stringArray =
|
||||
StringUtils.delimitedListToStringArray((String) arguments, this.argumentSeparator);
|
||||
if (stringArray.length == 1) {
|
||||
Object argument = stringArray[0];
|
||||
if (argument != null && argument.getClass().isArray()) {
|
||||
return ObjectUtils.toObjectArray(argument);
|
||||
}
|
||||
else {
|
||||
return new Object[] {argument};
|
||||
}
|
||||
}
|
||||
else {
|
||||
return stringArray;
|
||||
}
|
||||
}
|
||||
else if (arguments instanceof Object[]) {
|
||||
return (Object[]) arguments;
|
||||
}
|
||||
else if (arguments instanceof Collection) {
|
||||
return ((Collection<?>) arguments).toArray();
|
||||
}
|
||||
else if (arguments != null) {
|
||||
// Assume a single argument object.
|
||||
return new Object[] {arguments};
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the message to the page.
|
||||
* <p>Can be overridden in subclasses, e.g. for testing purposes.
|
||||
* @param msg the message to write
|
||||
* @throws IOException if writing failed
|
||||
*/
|
||||
protected void writeMessage(String msg) throws IOException {
|
||||
this.pageContext.getOut().write(String.valueOf(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the current RequestContext's application context as MessageSource.
|
||||
*/
|
||||
protected MessageSource getMessageSource() {
|
||||
return getRequestContext().getMessageSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default exception message.
|
||||
*/
|
||||
protected String getNoSuchMessageExceptionDescription(NoSuchMessageException ex) {
|
||||
return ex.getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.support.RequestContext;
|
||||
import org.springframework.web.servlet.tags.RequestContextAwareTag;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@locale/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("locale")
|
||||
public class LocaleTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
WebApplicationContext webApplicationContext =RequestContextUtils.findWebApplicationContext(request);
|
||||
if(params.get("code")==null) {
|
||||
env.getOut().append(RequestContextUtils.getLocale(request).getLanguage());
|
||||
}else {
|
||||
env.getOut().append(webApplicationContext.getMessage(params.get("code").toString(), null, RequestContextUtils.getLocale(request)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
/**
|
||||
* 获取请求参数标签
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class ParameterTag extends TagSupport{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9094347470856820500L;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
try{
|
||||
if(this.getName()!=null&&!this.getName().equals("")){
|
||||
pageContext.getOut().print(this.pageContext.getRequest().getParameter(this.getName()));
|
||||
pageContext.getOut().flush();
|
||||
}
|
||||
} catch (IOException e){
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@parameter/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("parameter")
|
||||
public class ParameterTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
name=params.get("name").toString();
|
||||
env.getOut().append(request.getParameter(name));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@pathVar/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("pathVar")
|
||||
public class PathVarTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private int index;
|
||||
String pathVariable;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
|
||||
index=Integer.parseInt(params.get("index").toString());
|
||||
String[] pathVariables=request.getAttribute(org.springframework.web.util.WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE).toString().split("/");
|
||||
|
||||
if(pathVariables==null){
|
||||
pathVariables=request.getRequestURI().split("/");
|
||||
}
|
||||
|
||||
if(index==0){
|
||||
pathVariable=pathVariables[pathVariables.length-1];
|
||||
}else{
|
||||
pathVariable=pathVariables[index+1];
|
||||
}
|
||||
env.getOut().append(request.getParameter(pathVariable));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
|
||||
/**
|
||||
* 获取访问地址url参数标签
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class PathVariableTag extends TagSupport{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3906613920420893358L;
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
private int index;
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
String pathVariable="";
|
||||
try
|
||||
{
|
||||
HttpServletRequest request = (HttpServletRequest)this.pageContext.getRequest();
|
||||
String[] pathVariables=request.getAttribute(org.springframework.web.util.WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE).toString().split("/");
|
||||
|
||||
if(pathVariables==null){
|
||||
pathVariables=request.getRequestURI().split("/");
|
||||
}
|
||||
|
||||
if(this.getIndex()==0){
|
||||
pathVariable=pathVariables[pathVariables.length-1];
|
||||
}else{
|
||||
pathVariable=pathVariables[this.getIndex()+1];
|
||||
}
|
||||
|
||||
pageContext.getOut().print(pathVariable);
|
||||
pageContext.getOut().flush();
|
||||
} catch (IOException e)
|
||||
{
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.support.RequestContextUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.support.RequestContext;
|
||||
import org.springframework.web.servlet.tags.RequestContextAwareTag;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@locale/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("redirect")
|
||||
public class RedirectTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
|
||||
private String basePath = null;
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
String location=params.get("url").toString();
|
||||
|
||||
basePath = request.getScheme()+"://"+request.getServerName();
|
||||
int port=request.getServerPort();
|
||||
//Ignore 443 or 80 port
|
||||
if((port==443 && request.getScheme().equalsIgnoreCase("https"))
|
||||
||(port==80 && request.getScheme().equalsIgnoreCase("http"))){
|
||||
}else{
|
||||
basePath += ":"+port;
|
||||
}
|
||||
basePath += request.getContextPath()+"";
|
||||
|
||||
response.sendRedirect(basePath+"/"+location);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,171 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class TreeTag extends TagSupport {
|
||||
final static Logger _logger = LoggerFactory.getLogger(TreeTag.class);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1243669057069893859L;
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
private String url;
|
||||
|
||||
private String rootId;
|
||||
|
||||
private boolean checkbox;
|
||||
|
||||
private int width=300;
|
||||
|
||||
private int height;
|
||||
|
||||
private String onClick="null";
|
||||
|
||||
private String onDblClick="null";
|
||||
|
||||
private PageContext pageContext;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int doEndTag() throws JspException {
|
||||
|
||||
return super.doEndTag();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public int doStartTag() throws JspException {
|
||||
try{
|
||||
StringBuffer sb=new StringBuffer("");
|
||||
sb.append("\n<script type=\"text/javascript\">\n<!--");
|
||||
sb.append("\nvar "+id+"_treeSettings={");
|
||||
sb.append("\n\t element : \""+id+"\",");
|
||||
sb.append("\n\t rootId : \""+rootId+"\",");
|
||||
sb.append("\n\t checkbox : "+checkbox+",");
|
||||
sb.append("\n\t onClick : "+onClick+",");
|
||||
sb.append("\n\t onDblClick : "+onDblClick+",");
|
||||
sb.append("\n\t url : '").append(pageContext.getServletContext().getContextPath()).append(url).append("',");
|
||||
|
||||
sb.append("\n};");
|
||||
sb.append("\n$(function () {");
|
||||
sb.append("\n\t $.tree(").append(id).append("_treeSettings);");
|
||||
sb.append("\n});");
|
||||
|
||||
sb.append("\n-->\n</script>");
|
||||
|
||||
sb.append("\n<div id=\"").append(id).append("\" class=\"ztree\"") ;
|
||||
sb.append(" style=\"height:"+(height == 0? "100%" : (height+"px"))+";width:"+width+"px\"").append("></div>");
|
||||
|
||||
pageContext.getOut().println(sb);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return EVAL_BODY_INCLUDE;
|
||||
}
|
||||
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getRootId() {
|
||||
return rootId;
|
||||
}
|
||||
|
||||
|
||||
public void setRootId(String rootId) {
|
||||
this.rootId = rootId;
|
||||
}
|
||||
|
||||
|
||||
public boolean isCheckbox() {
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
|
||||
public void setCheckbox(boolean checkbox) {
|
||||
this.checkbox = checkbox;
|
||||
}
|
||||
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
public String getOnClick() {
|
||||
return onClick;
|
||||
}
|
||||
|
||||
|
||||
public void setOnClick(String onClick) {
|
||||
this.onClick = onClick;
|
||||
}
|
||||
|
||||
|
||||
public String getOnDblClick() {
|
||||
return onDblClick;
|
||||
}
|
||||
|
||||
|
||||
public void setOnDblClick(String onDblClick) {
|
||||
this.onDblClick = onDblClick;
|
||||
}
|
||||
|
||||
|
||||
public PageContext getPageContext() {
|
||||
return pageContext;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.TemplateDirectiveBody;
|
||||
import freemarker.template.TemplateDirectiveModel;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateModel;
|
||||
/**
|
||||
* 获取应用上下文标签
|
||||
* <@base/>
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
|
||||
@FreemarkerTag("tree")
|
||||
public class TreeTagDirective implements TemplateDirectiveModel {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
private String id;
|
||||
|
||||
private String url;
|
||||
|
||||
private String rootId;
|
||||
|
||||
private String checkbox;
|
||||
|
||||
private int width=300;
|
||||
|
||||
private int height;
|
||||
|
||||
private String onClick="null";
|
||||
|
||||
private String onDblClick="null";
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
|
||||
throws TemplateException, IOException {
|
||||
id = params.get("id").toString();
|
||||
url = params.get("url").toString();
|
||||
rootId = params.get("rootId").toString();
|
||||
checkbox = params.get("checkbox").toString();
|
||||
if(params.get("width")!=null) {
|
||||
width=Integer.parseInt(params.get("width").toString());
|
||||
}
|
||||
if(params.get("height")!=null) {
|
||||
height=Integer.parseInt(params.get("height").toString());
|
||||
}
|
||||
if(params.get("onClick")!=null) {
|
||||
onClick = params.get("onClick").toString();
|
||||
}
|
||||
if(params.get("onDblClick")!=null) {
|
||||
onDblClick = params.get("onDblClick").toString();
|
||||
}
|
||||
|
||||
try{
|
||||
StringBuffer sb=new StringBuffer("");
|
||||
sb.append("\n<script type=\"text/javascript\">\n<!--");
|
||||
sb.append("\nvar "+id+"_treeSettings={");
|
||||
sb.append("\n\t element : \""+id+"\",");
|
||||
sb.append("\n\t rootId : \""+rootId+"\",");
|
||||
sb.append("\n\t checkbox : "+checkbox+",");
|
||||
sb.append("\n\t onClick : "+onClick+",");
|
||||
sb.append("\n\t onDblClick : "+onDblClick+",");
|
||||
sb.append("\n\t url : '").append(request.getContextPath()).append(url).append("',");
|
||||
|
||||
sb.append("\n};");
|
||||
sb.append("\n$(function () {");
|
||||
sb.append("\n\t $.tree(").append(id).append("_treeSettings);");
|
||||
sb.append("\n});");
|
||||
|
||||
sb.append("\n-->\n</script>");
|
||||
|
||||
sb.append("\n<div id=\"").append(id).append("\" class=\"ztree\"") ;
|
||||
sb.append(" style=\"height:"+(height == 0? "100%" : (height+"px"))+";width:"+width+"px\"").append("></div>");
|
||||
|
||||
env.getOut().append(sb);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package org.maxkey.web.tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.web.WebContext;
|
||||
|
||||
/**
|
||||
* 获取当前登录用户标签
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class UsernameTag extends TagSupport
|
||||
{
|
||||
private PageContext pageContext;
|
||||
private static final long serialVersionUID = 4494502315876572711L;
|
||||
public void setPageContext(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
public final int doStartTag() throws JspException{
|
||||
return SKIP_BODY;
|
||||
}
|
||||
|
||||
public final int doEndTag() throws JspException{
|
||||
int tagReturn=EVAL_PAGE;
|
||||
try
|
||||
{
|
||||
UserInfo userInfo=WebContext.getUserInfo();
|
||||
if(userInfo!=null&&!userInfo.getUsername().equals("")){
|
||||
pageContext.getOut().print(userInfo.getUsername());
|
||||
pageContext.getOut().flush();
|
||||
}
|
||||
} catch (IOException e)
|
||||
{
|
||||
throw new JspException("exception="+e.getMessage());
|
||||
}
|
||||
return tagReturn;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
BIN
maxkey-lib/other/jaxb-impl-2.2_1.jar
Normal file
BIN
maxkey-lib/other/jaxb-impl-2.2_1.jar
Normal file
Binary file not shown.
BIN
maxkey-lib/other/mchange-commons-java-0.2.16.jar
Normal file
BIN
maxkey-lib/other/mchange-commons-java-0.2.16.jar
Normal file
Binary file not shown.
BIN
maxkey-lib/other/not-yet-commons-ssl-0.3.9.jar
Normal file
BIN
maxkey-lib/other/not-yet-commons-ssl-0.3.9.jar
Normal file
Binary file not shown.
BIN
maxkey-lib/other/serializer-2.10.0.jar
Normal file
BIN
maxkey-lib/other/serializer-2.10.0.jar
Normal file
Binary file not shown.
BIN
maxkey-lib/other/xalan-2.7.1.jar
Normal file
BIN
maxkey-lib/other/xalan-2.7.1.jar
Normal file
Binary file not shown.
BIN
maxkey-lib/other/xml-apis-2.10.0.jar
Normal file
BIN
maxkey-lib/other/xml-apis-2.10.0.jar
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
/org/
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -1 +0,0 @@
|
||||
/org/
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -80,7 +80,13 @@ renew [OPTIONAL] - if this parameter is set, ticket validation will only succeed
|
||||
@RequestParam(value = CasConstants.PARAMETER.SERVICE) String service,
|
||||
@RequestParam(value = CasConstants.PARAMETER.RENEW,required=false) String renew
|
||||
){
|
||||
Ticket storedTicket=ticketServices.consumeTicket(ticket);
|
||||
Ticket storedTicket=null;
|
||||
try {
|
||||
storedTicket = ticketServices.consumeTicket(ticket);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(storedTicket!=null){
|
||||
return new Service10ResponseBuilder().success()
|
||||
|
||||
@ -179,7 +179,13 @@ For all error codes, it is RECOMMENDED that CAS provide a more detailed message
|
||||
@RequestParam(value = CasConstants.PARAMETER.FORMAT,required=false,defaultValue=CasConstants.FORMAT_TYPE.XML) String format){
|
||||
|
||||
|
||||
Ticket storedTicket=ticketServices.consumeTicket(ticket);
|
||||
Ticket storedTicket=null;
|
||||
try {
|
||||
storedTicket = ticketServices.consumeTicket(ticket);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
|
||||
|
||||
if(storedTicket!=null){
|
||||
@ -276,7 +282,12 @@ Response on ticket validation failure:
|
||||
@RequestParam(value = CasConstants.PARAMETER.FORMAT,required=false,defaultValue=CasConstants.FORMAT_TYPE.XML) String format){
|
||||
|
||||
|
||||
Ticket storedTicket=ticketServices.consumeTicket(ticket);
|
||||
Ticket storedTicket=null;
|
||||
try {
|
||||
storedTicket = ticketServices.consumeTicket(ticket);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
|
||||
|
||||
if(storedTicket!=null){
|
||||
|
||||
@ -61,7 +61,12 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||
@RequestParam(value = CasConstants.PARAMETER.FORMAT,required=false,defaultValue=CasConstants.FORMAT_TYPE.XML) String format){
|
||||
|
||||
|
||||
Ticket storedTicket=ticketServices.consumeTicket(ticket);
|
||||
Ticket storedTicket=null;
|
||||
try {
|
||||
storedTicket = ticketServices.consumeTicket(ticket);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
|
||||
|
||||
if(storedTicket!=null){
|
||||
@ -98,7 +103,12 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||
@RequestParam(value = CasConstants.PARAMETER.FORMAT,required=false,defaultValue=CasConstants.FORMAT_TYPE.XML) String format){
|
||||
|
||||
|
||||
Ticket storedTicket=ticketServices.consumeTicket(ticket);
|
||||
Ticket storedTicket=null;
|
||||
try {
|
||||
storedTicket = ticketServices.consumeTicket(ticket);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ServiceResponseBuilder serviceResponseBuilder=new ServiceResponseBuilder();
|
||||
|
||||
if(storedTicket!=null){
|
||||
|
||||
@ -7,7 +7,7 @@ import java.sql.Types;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.maxkey.authz.cas.endpoint.ticket.Ticket;
|
||||
import org.maxkey.authz.oauth2.common.util.SerializationUtils;
|
||||
import org.maxkey.util.SerializationUtils;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
@ -3,7 +3,6 @@ package org.maxkey.authz.cas.endpoint.ticket.service;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.CasConstants;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.Ticket;
|
||||
import org.maxkey.authz.cas.endpoint.ticket.generator.DefaultUniqueTicketIdGenerator;
|
||||
import org.maxkey.authz.oauth2.common.exceptions.InvalidGrantException;
|
||||
|
||||
|
||||
public abstract class RandomServiceTicketServices implements TicketServices {
|
||||
@ -39,11 +38,10 @@ public abstract class RandomServiceTicketServices implements TicketServices {
|
||||
return ticketId;
|
||||
}
|
||||
|
||||
public Ticket consumeTicket(String ticketId)
|
||||
throws InvalidGrantException {
|
||||
public Ticket consumeTicket(String ticketId) throws Exception{
|
||||
Ticket ticket = this.remove(ticketId);
|
||||
if (ticket == null) {
|
||||
throw new InvalidGrantException("Invalid authorization code: " + ticketId);
|
||||
throw new Exception("Invalid authorization code: " + ticketId);
|
||||
}
|
||||
return ticket;
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.maxkey.authz.cas.endpoint.ticket.service;
|
||||
|
||||
import org.maxkey.authz.cas.endpoint.ticket.Ticket;
|
||||
import org.maxkey.authz.oauth2.common.exceptions.InvalidGrantException;
|
||||
|
||||
public interface TicketServices {
|
||||
|
||||
@ -21,6 +20,6 @@ public interface TicketServices {
|
||||
* @throws InvalidGrantException If the authorization code is invalid or expired.
|
||||
*/
|
||||
Ticket consumeTicket(String ticketId)
|
||||
throws InvalidGrantException;
|
||||
throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
http\://www.springframework.org/schema/security/oauth2=org.springframework.security.oauth2.config.xml.OAuth2SecurityNamespaceHandler
|
||||
http\://www.springframework.org/schema/security/oauth=org.springframework.security.oauth.config.OAuthSecurityNamespaceHandler
|
||||
@ -0,0 +1,5 @@
|
||||
http\://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd=org/springframework/security/oauth2/spring-security-oauth2-1.0.xsd
|
||||
http\://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd=org/springframework/security/oauth2/spring-security-oauth2-2.0.xsd
|
||||
http\://www.springframework.org/schema/security/spring-security-oauth2.xsd=org/springframework/security/oauth2/spring-security-oauth2-2.0.xsd
|
||||
http\://www.springframework.org/schema/security/spring-security-oauth-1.0.xsd=org/springframework/security/oauth/spring-security-oauth-1.0.xsd
|
||||
http\://www.springframework.org/schema/security/spring-security-oauth.xsd=org/springframework/security/oauth/spring-security-oauth-1.0.xsd
|
||||
@ -5,6 +5,7 @@ dependencies {
|
||||
compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar')
|
||||
|
||||
compile project(":maxkey-core")
|
||||
compile project(":maxkey-dao")
|
||||
compile project(":maxkey-jose-jwt")
|
||||
compile project(":maxkey-protocols:maxkey-protocol-authorize")
|
||||
|
||||
|
||||
@ -6,8 +6,8 @@ import java.sql.Types;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.maxkey.authz.oauth2.common.util.SerializationUtils;
|
||||
import org.maxkey.authz.oauth2.provider.OAuth2Authentication;
|
||||
import org.maxkey.util.SerializationUtils;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
@ -17,11 +17,11 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.maxkey.authz.oauth2.common.OAuth2AccessToken;
|
||||
import org.maxkey.authz.oauth2.common.OAuth2RefreshToken;
|
||||
import org.maxkey.authz.oauth2.common.util.SerializationUtils;
|
||||
import org.maxkey.authz.oauth2.provider.OAuth2Authentication;
|
||||
import org.maxkey.authz.oauth2.provider.token.AuthenticationKeyGenerator;
|
||||
import org.maxkey.authz.oauth2.provider.token.DefaultAuthenticationKeyGenerator;
|
||||
import org.maxkey.authz.oauth2.provider.token.TokenStore;
|
||||
import org.maxkey.util.SerializationUtils;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -76,7 +76,7 @@ public class ConsumerEndpoint {
|
||||
private String assertionConsumerServiceURL;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("bindingAdpater")
|
||||
@Qualifier("extractRedirectBindingAdapter")
|
||||
private ExtractBindingAdapter extractBindingAdapter;
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
||||
@ -5,26 +5,23 @@
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-oauth-2.0/maxkey-protocol-oauth-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-authorize/maxkey-protocol-authorize">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-saml-2.0/maxkey-protocol-saml-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-dao/maxkey-dao">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-core/maxkey-core">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-jose-jwt/maxkey-jose-jwt">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-dao/maxkey-dao">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-client-sdk/maxkey-client-sdk">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-oauth-2.0/maxkey-protocol-oauth-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-saml-2.0/maxkey-protocol-saml-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
||||
@ -1,2 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/resources/templates/views/authorize/formbased_netease_163email_sso_submint.ftl=UTF-8
|
||||
encoding//src/main/resources/templates/views/authorize/formbased_redirect_post_submint.ftl=UTF-8
|
||||
encoding//src/main/resources/templates/views/profile/myProfile.ftl=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
@ -5,9 +5,24 @@
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-core/maxkey-core">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-dao/maxkey-dao">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-jose-jwt/maxkey-jose-jwt">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-client-sdk/maxkey-client-sdk">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-authentications/maxkey-authentications">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-authorize/maxkey-protocol-authorize">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-cas/maxkey-protocol-cas">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
@ -29,23 +44,8 @@
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-oauth-2.0/maxkey-protocol-oauth-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-authorize/maxkey-protocol-authorize">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-protocol-saml-2.0/maxkey-protocol-saml-2.0">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-dao/maxkey-dao">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-core/maxkey-core">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-jose-jwt/maxkey-jose-jwt">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/maxkey-client-sdk/maxkey-client-sdk">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
|
||||
@ -22,9 +22,6 @@ dependencies {
|
||||
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
|
||||
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"
|
||||
|
||||
//local jars
|
||||
compile fileTree(dir: '../maxkey-lib/', include: '*/*.jar')
|
||||
|
||||
compile project(":maxkey-core")
|
||||
compile project(":maxkey-dao")
|
||||
compile project(":maxkey-jose-jwt")
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package org.maxkey;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
@SpringBootApplication
|
||||
public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MaxKeyApplication.class, args);
|
||||
}
|
||||
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(MaxKeyApplication.class);
|
||||
}
|
||||
|
||||
}
|
||||
10
maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
Normal file
10
maxkey-web-maxkey/src/main/java/org/maxkey/MaxKeyConfig.java
Normal file
@ -0,0 +1,10 @@
|
||||
package org.maxkey;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@Configuration
|
||||
@ImportResource(locations={"classpath:spring/maxkey.xml"})
|
||||
public class MaxKeyConfig {
|
||||
|
||||
}
|
||||
@ -79,11 +79,6 @@ public class AppListController{
|
||||
WebContext.setAttribute(app.getId(), app.getIcon());
|
||||
}
|
||||
|
||||
if(appList.size()%5>0){
|
||||
for(int i=0;i<=appList.size()%5;i++){
|
||||
appList.add(new UserApplications());
|
||||
}
|
||||
}
|
||||
return appList;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class OneTimePasswordController {
|
||||
|
||||
@RequestMapping(value={"/timebased"})
|
||||
public ModelAndView timebased(){
|
||||
ModelAndView modelAndView=new ModelAndView("otp/timeBased");
|
||||
ModelAndView modelAndView=new ModelAndView("safe/timeBased");
|
||||
UserInfo userInfo=WebContext.getUserInfo();
|
||||
String sharedSecret=passwordReciprocal.decoder(userInfo.getSharedSecret());
|
||||
timeBasedKeyUriFormat.setSecret(sharedSecret);
|
||||
@ -84,7 +84,7 @@ public class OneTimePasswordController {
|
||||
|
||||
@RequestMapping(value={"/counterbased"})
|
||||
public ModelAndView counterbased(){
|
||||
ModelAndView modelAndView=new ModelAndView("otp/counterBased");
|
||||
ModelAndView modelAndView=new ModelAndView("safe/counterBased");
|
||||
UserInfo userInfo=WebContext.getUserInfo();
|
||||
String sharedSecret=passwordReciprocal.decoder(userInfo.getSharedSecret());
|
||||
counterBasedKeyUriFormat.setSecret(sharedSecret);
|
||||
@ -117,7 +117,7 @@ public class OneTimePasswordController {
|
||||
|
||||
@RequestMapping(value={"/hotp"})
|
||||
public ModelAndView hotp(){
|
||||
ModelAndView modelAndView=new ModelAndView("otp/hotp");
|
||||
ModelAndView modelAndView=new ModelAndView("safe/hotp");
|
||||
UserInfo userInfo=WebContext.getUserInfo();
|
||||
String sharedSecret=passwordReciprocal.decoder(userInfo.getSharedSecret());
|
||||
hotpKeyUriFormat.setSecret(sharedSecret);
|
||||
|
||||
@ -67,9 +67,9 @@ public class LoginEndpoint {
|
||||
@Qualifier("userInfoService")
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
/*@Autowired
|
||||
@Qualifier("wsFederationService")
|
||||
WsFederationService wsFederationService;
|
||||
WsFederationService wsFederationService;*/
|
||||
|
||||
@Autowired
|
||||
@Qualifier("authenticationProvider")
|
||||
@ -117,7 +117,7 @@ public class LoginEndpoint {
|
||||
if(applicationConfig.getLoginConfig().isWsFederation()&&
|
||||
StringUtils.isNotEmpty(wsFederationWA) &&
|
||||
wsFederationWA.equalsIgnoreCase(WsFederationConstants.WSIGNIN)){
|
||||
isAuthenticated=wsFederationService.login(wsFederationWA,wsFederationWResult,request);
|
||||
//isAuthenticated=wsFederationService.login(wsFederationWA,wsFederationWResult,request);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
22
maxkey-web-maxkey/src/main/resources/application.properties
Normal file
22
maxkey-web-maxkey/src/main/resources/application.properties
Normal file
@ -0,0 +1,22 @@
|
||||
#server config
|
||||
#spring.profiles.active=dev
|
||||
#server port
|
||||
server.port=80
|
||||
#web app context path
|
||||
server.servlet.context-path=/maxkey
|
||||
|
||||
#for freemarker
|
||||
spring.freemarker.template-loader-path=classpath:/templates/views
|
||||
spring.freemarker.cache=false
|
||||
spring.freemarker.charset=UTF-8
|
||||
spring.freemarker.check-template-location=true
|
||||
spring.freemarker.content-type=text/html
|
||||
spring.freemarker.expose-request-attributes=false
|
||||
spring.freemarker.expose-session-attributes=false
|
||||
spring.freemarker.request-context-attribute=request
|
||||
spring.freemarker.suffix=.ftl
|
||||
|
||||
#static resources
|
||||
spring.mvc.static-path-pattern=/static/**
|
||||
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
@ -5,22 +5,16 @@
|
||||
<Console name="consolePrint" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
<!--
|
||||
<File name="File" fileName="logs/PipeLineRunner.log">
|
||||
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</File>
|
||||
-->
|
||||
|
||||
<!-- 输出到文件,按天或者超过80MB分割 -->
|
||||
<RollingFile name="RollingFile" fileName="${catalina.home}/logs/maxkey.log" filePattern="${catalina.home}/logs/$${date:yyyy-MM}/maxkey-%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<!-- 输出到文件,按天或者超过250MB分割 每天进行归档yyyy-MM-dd -->
|
||||
<RollingFile name="RollingFile" fileName="${catalina.home}/logs/maxkey.log" filePattern="${catalina.home}/logs/$${date:yyyy-MM-dd}/maxkey-%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<!-- 需要记录的级别 -->
|
||||
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
|
||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%F:%L) - %m%n" />
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="512 MB" />
|
||||
<!-- <SizeBasedTriggeringPolicy size="80 MB" /> -->
|
||||
<SizeBasedTriggeringPolicy size="250 MB" />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
</appenders>
|
||||
|
||||
@ -26,11 +26,10 @@
|
||||
<import resource="maxkey-support-kerberos.xml"/>
|
||||
|
||||
<import resource="maxkey-support-social.xml"/>
|
||||
|
||||
<!--
|
||||
<import resource="maxkey-support-wsfederation.xml"/>
|
||||
|
||||
<import resource="maxkey-support-cas.xml"/>
|
||||
<!--
|
||||
|
||||
<import resource="maxkey-support-jwt.xml"/>
|
||||
-->
|
||||
|
||||
@ -108,9 +108,9 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- View Resolver -->
|
||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/views/" p:suffix=".jsp" p:order="2" />
|
||||
|
||||
<!-- View Resolver
|
||||
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/templates/" p:suffix=".jsp" p:order="2" />
|
||||
-->
|
||||
<!-- upload file support -->
|
||||
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
|
||||
<property name="maxUploadSize" value="4194304" />
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user