shimingxy 5 年之前
父节点
当前提交
d254e8a27d

+ 68 - 89
maxkey-core/src/main/java/org/maxkey/config/CharacterEncodingConfig.java

@@ -1,104 +1,83 @@
-/**
- * 
- */
 package org.maxkey.config;
 
 import java.io.UnsupportedEncodingException;
-
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
 /**
- * 字符集转换及转换配置
+ * 字符集转换及转换配置.
+ * 
  * @author Crystal.Sea
  *
  */
 @Configuration
 @PropertySource("classpath:/config/applicationConfig.properties")
 public class CharacterEncodingConfig {
-	
-	/**
-	 * 源字符集
-	 */
-	@Value("${config.characterencoding.charset.from}")
-	String fromCharSet;
-	
-	/**
-	 * 目标字符集
-	 */
-	@Value("${config.characterencoding.charset.to}")
-	String toCharSet;
-	
-	/**
-	 * 转换标志
-	 */
-	@Value("${config.characterencoding.encoding}")
-	boolean encoding	=	false;
-
-	
-	public CharacterEncodingConfig() {
-		
-	}
-
-	/**
-	 * @return the fromCharSet
-	 */
-	public String getFromCharSet() {
-		return fromCharSet;
-	}
-
-	/**
-	 * @param fromCharSet the fromCharSet to set
-	 */
-	public void setFromCharSet(String fromCharSet) {
-		this.fromCharSet = fromCharSet;
-	}
-
-	/**
-	 * @return the toCharSet
-	 */
-	public String getToCharSet() {
-		return toCharSet;
-	}
-
-	/**
-	 * @param toCharSet the toCharSet to set
-	 */
-	public void setToCharSet(String toCharSet) {
-		this.toCharSet = toCharSet;
-	}
-
-	/**
-	 * @return the encoding
-	 */
-	public boolean isEncoding() {
-		return encoding;
-	}
-
-	/**
-	 * @param encoding the encoding to set
-	 */
-	public void setEncoding(boolean encoding) {
-		this.encoding = encoding;
-	}
-	
-	/**
-	 * 字符集转换
-	 * @param encodingString 源字符串
-	 * @return encoded目标字符串
-	 */
-	public String encoding(String encodingString){
-		if(!this.encoding||encodingString==null) {
-			return encodingString;
-		}
-		
-		try {
-			return new String(encodingString.getBytes(this.fromCharSet),this.toCharSet);
-		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-	
+
+    /**
+     * 源字符集.
+     */
+    @Value("${config.characterencoding.charset.from}")
+    String fromCharSet;
+
+    /**
+     * 目标字符集.
+     */
+    @Value("${config.characterencoding.charset.to}")
+    String toCharSet;
+
+    /**
+     * 转换标志.
+     */
+    @Value("${config.characterencoding.encoding}")
+    boolean encoding = false;
+
+    public CharacterEncodingConfig() {
+
+    }
+
+    public String getFromCharSet() {
+        return fromCharSet;
+    }
+
+    public void setFromCharSet(String fromCharSet) {
+        this.fromCharSet = fromCharSet;
+    }
+
+    public String getToCharSet() {
+        return toCharSet;
+    }
+
+    public void setToCharSet(String toCharSet) {
+        this.toCharSet = toCharSet;
+    }
+
+    public boolean isEncoding() {
+        return encoding;
+    }
+
+    public void setEncoding(boolean encoding) {
+        this.encoding = encoding;
+    }
+
+    /**
+     * 字符集转换.
+     * 
+     * @param encodingString 源字符串
+     * @return encoded目标字符串
+     */
+    public String encoding(String encodingString) {
+        if (!this.encoding || encodingString == null) {
+            return encodingString;
+        }
+
+        try {
+            return new String(encodingString.getBytes(this.fromCharSet), this.toCharSet);
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
 }

+ 161 - 167
maxkey-core/src/main/java/org/maxkey/config/DataSoruceConfig.java

@@ -7,177 +7,171 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
-/**
- * 数据源配置
+/*
+ * 数据源配置.
  *
- * @author Crystal.Sea
- * dataSource.driverClassName=com.mysql.jdbc.Driver
- * dataSource.url=jdbc:mysql://192.168.1.49/parasecdb?autoReconnect=true&characterEncoding=UTF-8
- * dataSource.username=root
- * dataSource.password=connsec
- * dataSource.type=mysql
- *
- */
-/**
- * @author Crystal.Sea
+ *  @author Crystal.Sea
+ *  dataSource.driverClassName=com.mysql.jdbc.Driver
+ *  dataSource.url=jdbc:mysql://192.168.1.49/parasecdb?autoReconnect=true&characterEncoding=UTF-8
+ *  dataSource.username=root
+ *  dataSource.password=connsec
+ *  dataSource.type=mysql
  *
  */
 @Configuration
 @PropertySource("classpath:/config/applicationConfig.properties")
 public class DataSoruceConfig {
-	
-	/**
-	 * 数据库类型
-	 */
-	@Value("${config.datasource.database:mysql}")
-	String database;
-	/**
-	 * jdbc驱动类
-	 */
-	@Value("${config.datasource.driverclass:com.mysql.jdbc.Driver}")
-	String driverClass;
-	/**
-	 * jdbc连接地址
-	 */
-	@Value("${config.datasource.url:jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8}")
-	String url;
-	/**
-	 * 数据库用户名
-	 */
-	@Value("${config.datasource.username:root}")
-	String username;
-	/**
-	 * 数据库密码
-	 */
-	@Value("${config.datasource.password:maxkey}")
-	String password;
-	
-	/**
-	 * 数据库密码是否加密
-	 */
-	@Value("${config.datasource.password.encrypt}")
-	boolean encrypt=false;
-	
-	/**
-	 * 数据库dialect for mybatis
-	 */
-	String dialect;
-	
-
-	
-	public DataSoruceConfig() {
-		super();
-	}
-	
-
-	public String getUrl() {
-		return url;
-	}
-	public void setUrl(String url) {
-		this.url = url;
-	}
-	public String getUsername() {
-		return username;
-	}
-	public void setUsername(String username) {
-		this.username = username;
-	}
-	
-	/**
-	 * 取得数据库密码
-	 * 如果是加密密码(encrypt==true),则进行解密
-	 * @return decodePassword
-	 */
-	public String getPassword() {
-		String decodePassword="";
-		LogFactory.getLog(DataSoruceConfig.class).debug("password is "+password);
-		if(encrypt){
-			decodePassword = PasswordReciprocal.getInstance().decoder(password);
-		}else{
-			decodePassword= password;
-		}
-		LogFactory.getLog(DataSoruceConfig.class).debug("password is "+password+" , decodePassword is "+decodePassword);
-		return decodePassword;
-	}
-	
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-
-	/**
-	 * @return the database
-	 */
-	public String getDatabase() {
-		return database;
-	}
-
-
-	/**
-	 * @param database the database to set
-	 */
-	public void setDatabase(String database) {
-		this.database = database;
-
-	}
-
-
-	/**
-	 * @return the driverClass
-	 */
-	public String getDriverClass() {
-		return driverClass;
-	}
-
-
-	/**
-	 * @param driverClass the driverClass to set
-	 */
-	public void setDriverClass(String driverClass) {
-		this.driverClass = driverClass;
-	}
-
-
-	public boolean isEncrypt() {
-		return encrypt;
-	}
-
-	public void setEncrypt(boolean encrypt) {
-		this.encrypt = encrypt;
-	}
-
-	
-
-	/**
-	 * @return the dialect
-	 */
-	public String getDialect() {
-		if(this.dialect==null) {
-			this.dialect=Dialect.getDialectMap().get(database);
-		}
-		return dialect;
-	}
-
-
-	/**
-	 * @param dialect the dialect to set
-	 */
-	public void setDialect(String dialect) {
-		this.dialect = dialect;
-	}
-
-
-	/* (non-Javadoc)
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString() {
-		return "DataSoruceConfig [database=" + database + ", driverClass="
-				+ driverClass + ", url=" + url + ", username=" + username
-				+ ", password=" + password + ", encrypt=" + encrypt + "]";
-	}
-
-
-	
-	
+
+    /*
+     * 数据库类型
+     */
+    @Value("${config.datasource.database:mysql}")
+    String database;
+    /*
+     * jdbc驱动类
+     */
+    @Value("${config.datasource.driverclass:com.mysql.jdbc.Driver}")
+    String driverClass;
+    /*
+     * jdbc连接地址
+     */
+    @Value("${config.datasource.url:" 
+            + "jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8}")
+    String url;
+    /*
+     * 数据库用户名
+     */
+    @Value("${config.datasource.username:root}")
+    String username;
+    /*
+     * 数据库密码
+     */
+    @Value("${config.datasource.password:maxkey}")
+    String password;
+
+    /*
+     * 数据库密码是否加密
+     */
+    @Value("${config.datasource.password.encrypt}")
+    boolean encrypt = false;
+
+    /*
+     * 数据库dialect for mybatis
+     */
+    String dialect;
+
+    public DataSoruceConfig() {
+        super();
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /**
+     * 取得数据库密码 如果是加密密码(encrypt==true),则进行解密.
+     * 
+     * @return decodePassword
+     */
+    public String getPassword() {
+        String decodePassword = "";
+        LogFactory.getLog(DataSoruceConfig.class).debug("password is " + password);
+        if (encrypt) {
+            decodePassword = PasswordReciprocal.getInstance().decoder(password);
+        } else {
+            decodePassword = password;
+        }
+        LogFactory.getLog(DataSoruceConfig.class)
+                .debug("password is " + password + " , decodePassword is " + decodePassword);
+        return decodePassword;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /*
+     * 
+     * @return the database
+     */
+    public String getDatabase() {
+        return database;
+    }
+
+    /*
+     * @param database the database to set
+     */
+    public void setDatabase(String database) {
+        this.database = database;
+
+    }
+
+    /*
+     * @return the driverClass
+     */
+    public String getDriverClass() {
+        return driverClass;
+    }
+
+    /*
+     * @param driverClass the driverClass to set
+     */
+    public void setDriverClass(String driverClass) {
+        this.driverClass = driverClass;
+    }
+
+    public boolean isEncrypt() {
+        return encrypt;
+    }
+
+    public void setEncrypt(boolean encrypt) {
+        this.encrypt = encrypt;
+    }
+
+    /**
+     * getDialect.
+     * @return the dialect
+     */
+    public String getDialect() {
+        if (this.dialect == null) {
+            this.dialect = Dialect.getDialectMap().get(database);
+        }
+        return dialect;
+    }
+
+    /*
+     * @param dialect the dialect to set
+     */
+    public void setDialect(String dialect) {
+        this.dialect = dialect;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return "DataSoruceConfig [database=" + database 
+                + ", driverClass=" + driverClass 
+                + ", url=" + url
+                + ", username=" + username 
+                + ", password=" + password 
+                + ", encrypt=" + encrypt 
+                + "]";
+    }
+
 }

+ 101 - 105
maxkey-core/src/main/java/org/maxkey/config/EmailConfig.java

@@ -8,109 +8,105 @@ import org.springframework.context.annotation.PropertySource;
 @PropertySource("classpath:/config/applicationConfig.properties")
 public class EmailConfig {
 
-	@Value("${config.email.username}")
-	private String username;
-	@Value("${config.email.password}")
-	private String password;
-	@Value("${config.email.smtpHost}")
-	private String smtpHost;
-	@Value("${config.email.senderMail}")
-	private String senderMail;
-	@Value("${config.email.port}")
-	private Integer port;
-	@Value("${config.email.ssl}")
-	private boolean ssl;
-	
-	
-
-	public EmailConfig() {
-		// TODO Auto-generated constructor stub
-	}
-
-	/**
-	 * @return the username
-	 */
-	public String getUsername() {
-		return username;
-	}
-
-	/**
-	 * @param username the username to set
-	 */
-	public void setUsername(String username) {
-		this.username = username;
-	}
-
-	/**
-	 * @return the password
-	 */
-	public String getPassword() {
-		return password;
-	}
-
-	/**
-	 * @param password the password to set
-	 */
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-
-	/**
-	 * @return the smtpHost
-	 */
-	public String getSmtpHost() {
-		return smtpHost;
-	}
-
-	/**
-	 * @param smtpHost the smtpHost to set
-	 */
-	public void setSmtpHost(String smtpHost) {
-		this.smtpHost = smtpHost;
-	}
-
-	/**
-	 * @return the senderMail
-	 */
-	public String getSenderMail() {
-		return senderMail;
-	}
-
-	/**
-	 * @param senderMail the senderMail to set
-	 */
-	public void setSenderMail(String senderMail) {
-		this.senderMail = senderMail;
-	}
-
-	/**
-	 * @return the port
-	 */
-	public Integer getPort() {
-		return port;
-	}
-
-	/**
-	 * @param port the port to set
-	 */
-	public void setPort(Integer port) {
-		this.port = port;
-	}
-
-	/**
-	 * @return the ssl
-	 */
-	public boolean isSsl() {
-		return ssl;
-	}
-
-	/**
-	 * @param ssl the ssl to set
-	 */
-	public void setSsl(boolean ssl) {
-		this.ssl = ssl;
-	}
-	
-	
+    @Value("${config.email.username}")
+    private String username;
+    @Value("${config.email.password}")
+    private String password;
+    @Value("${config.email.smtpHost}")
+    private String smtpHost;
+    @Value("${config.email.senderMail}")
+    private String senderMail;
+    @Value("${config.email.port}")
+    private Integer port;
+    @Value("${config.email.ssl}")
+    private boolean ssl;
+
+    public EmailConfig() {
+        // TODO Auto-generated constructor stub
+    }
+
+    /*
+     * @return the username
+     */
+    public String getUsername() {
+        return username;
+    }
+
+    /*
+     * @param username the username to set
+     */
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /*
+     * @return the password
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /*
+     * @param password the password to set
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /*
+     * @return the smtpHost
+     */
+    public String getSmtpHost() {
+        return smtpHost;
+    }
+
+    /*
+     * @param smtpHost the smtpHost to set
+     */
+    public void setSmtpHost(String smtpHost) {
+        this.smtpHost = smtpHost;
+    }
+
+    /*
+     * @return the senderMail
+     */
+    public String getSenderMail() {
+        return senderMail;
+    }
+
+    /*
+     * @param senderMail the senderMail to set
+     */
+    public void setSenderMail(String senderMail) {
+        this.senderMail = senderMail;
+    }
+
+    /*
+     * @return the port
+     */
+    public Integer getPort() {
+        return port;
+    }
+
+    /*
+     * @param port the port to set
+     */
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    /*
+     * @return the ssl
+     */
+    public boolean isSsl() {
+        return ssl;
+    }
+
+    /*
+     * @param ssl the ssl to set
+     */
+    public void setSsl(boolean ssl) {
+        this.ssl = ssl;
+    }
+
 }

+ 11 - 3
maxkey-core/src/main/java/org/maxkey/config/LoginConfig.java

@@ -87,8 +87,16 @@ public class LoginConfig {
 
     @Override
     public String toString() {
-        return "LoginConfig [captcha=" + captcha + ", oneTimePwd=" + oneTimePwd + ", socialSignOn=" + socialSignOn
-                + ", kerberos=" + kerberos + ", remeberMe=" + remeberMe + ", wsFederation=" + wsFederation
-                + ", defaultUri=" + defaultUri + "]";
+        StringBuilder builder = new StringBuilder();
+        builder
+            .append("LoginConfig [captcha=").append(captcha)
+            .append(", oneTimePwd=").append(oneTimePwd)
+            .append(", socialSignOn=").append(socialSignOn)
+            .append(", kerberos=").append(kerberos)
+            .append(", remeberMe=").append(remeberMe)
+            .append(", wsFederation=").append(wsFederation)
+            .append(", defaultUri=").append(defaultUri).append("]");
+        return builder.toString();
     }
+
 }

+ 60 - 62
maxkey-core/src/main/java/org/maxkey/config/oidc/OIDCProviderMetadataDetails.java

@@ -1,96 +1,94 @@
-/**
- * 
- */
 package org.maxkey.config.oidc;
 
 import java.net.URI;
 import java.util.Set;
 
 /**
- * @author Hiro
+ * OIDCProviderMetadataDetails.
+ * @author cm
  *
  */
 public class OIDCProviderMetadataDetails implements OIDCProviderMetadata {
-	protected String issuer;
+    protected String issuer;
 
-	protected URI authorizationEndpoint;
+    protected URI authorizationEndpoint;
 
-	protected URI tokenEndpoint;
+    protected URI tokenEndpoint;
 
-	protected URI userinfoEndpoint;
+    protected URI userinfoEndpoint;
 
-	protected URI jwksUri;
+    protected URI jwksUri;
 
-	protected URI registrationEndpoint;
+    protected URI registrationEndpoint;
 
-	protected Set<String> scopesSupported;
+    protected Set<String> scopesSupported;
 
-	protected Set<String> responseTypesSupported;
+    protected Set<String> responseTypesSupported;
 
-	public String getIssuer() {
-		return issuer;
-	}
+    public String getIssuer() {
+        return issuer;
+    }
 
-	public void setIssuer(String issuer) {
-		this.issuer = issuer;
-	}
+    public void setIssuer(String issuer) {
+        this.issuer = issuer;
+    }
 
-	public URI getAuthorizationEndpoint() {
-		return authorizationEndpoint;
-	}
+    public URI getAuthorizationEndpoint() {
+        return authorizationEndpoint;
+    }
 
-	public void setAuthorizationEndpoint(URI authorizationEndpoint) {
-		this.authorizationEndpoint = authorizationEndpoint;
-	}
+    public void setAuthorizationEndpoint(URI authorizationEndpoint) {
+        this.authorizationEndpoint = authorizationEndpoint;
+    }
 
-	public URI getTokenEndpoint() {
-		return tokenEndpoint;
-	}
+    public URI getTokenEndpoint() {
+        return tokenEndpoint;
+    }
 
-	public void setTokenEndpoint(URI tokenEndpoint) {
-		this.tokenEndpoint = tokenEndpoint;
-	}
+    public void setTokenEndpoint(URI tokenEndpoint) {
+        this.tokenEndpoint = tokenEndpoint;
+    }
 
-	public URI getUserinfoEndpoint() {
-		return userinfoEndpoint;
-	}
+    public URI getUserinfoEndpoint() {
+        return userinfoEndpoint;
+    }
 
-	public void setUserinfoEndpoint(URI userinfoEndpoint) {
-		this.userinfoEndpoint = userinfoEndpoint;
-	}
+    public void setUserinfoEndpoint(URI userinfoEndpoint) {
+        this.userinfoEndpoint = userinfoEndpoint;
+    }
 
-	public URI getJwksUri() {
-		return jwksUri;
-	}
+    public URI getJwksUri() {
+        return jwksUri;
+    }
 
-	public void setJwksUri(URI jwksUri) {
-		this.jwksUri = jwksUri;
-	}
+    public void setJwksUri(URI jwksUri) {
+        this.jwksUri = jwksUri;
+    }
 
-	public URI getRegistrationEndpoint() {
-		return registrationEndpoint;
-	}
+    public URI getRegistrationEndpoint() {
+        return registrationEndpoint;
+    }
 
-	public void setRegistrationEndpoint(URI registrationEndpoint) {
-		this.registrationEndpoint = registrationEndpoint;
-	}
+    public void setRegistrationEndpoint(URI registrationEndpoint) {
+        this.registrationEndpoint = registrationEndpoint;
+    }
 
-	public Set<String> getScopesSupported() {
-		return scopesSupported;
-	}
+    public Set<String> getScopesSupported() {
+        return scopesSupported;
+    }
 
-	public void setScopesSupported(Set<String> scopesSupported) {
-		this.scopesSupported = scopesSupported;
-	}
+    public void setScopesSupported(Set<String> scopesSupported) {
+        this.scopesSupported = scopesSupported;
+    }
 
-	public Set<String> getResponseTypesSupported() {
-		return responseTypesSupported;
-	}
+    public Set<String> getResponseTypesSupported() {
+        return responseTypesSupported;
+    }
 
-	public void setResponseTypesSupported(Set<String> responseTypesSupported) {
-		this.responseTypesSupported = responseTypesSupported;
-	}
+    public void setResponseTypesSupported(Set<String> responseTypesSupported) {
+        this.responseTypesSupported = responseTypesSupported;
+    }
 
-	// TODO: Complete remaining properties from
-	// http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
+    // TODO: Complete remaining properties from
+    // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
 }

+ 16 - 6
maxkey-core/src/main/java/org/maxkey/web/InitApplicationContext.java

@@ -1,6 +1,3 @@
-/**
- * 
- */
 package org.maxkey.web;
 
 import java.sql.Connection;
@@ -11,11 +8,9 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
-
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
-
 import org.maxkey.cache.CacheFactory;
 import org.maxkey.util.PathUtils;
 import org.slf4j.Logger;
@@ -27,6 +22,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
+ * InitApplicationContext .
  * @author Crystal.Sea
  *
  */
@@ -71,6 +67,9 @@ public class InitApplicationContext extends HttpServlet {
         this.applicationContext = applicationContext;
     }
 
+    /**
+     * loadCaches.
+     */
     public void loadCaches() {
         _logger.info(
                 "----------------------------------------------------------------------------------------------------");
@@ -89,6 +88,9 @@ public class InitApplicationContext extends HttpServlet {
 
     }
 
+    /**
+     * listDataBaseVariables.
+     */
     public void listDataBaseVariables() {
         if (applicationContext.containsBean("dataSource")) {
             try {
@@ -122,7 +124,9 @@ public class InitApplicationContext extends HttpServlet {
         }
     }
 
-    // propertySourcesPlaceholderConfigurer
+    /**
+     * propertySourcesPlaceholderConfigurer.
+     */
     public void listProperties() {
         if (applicationContext.containsBean("propertySourcesPlaceholderConfigurer")) {
             _logger.debug(
@@ -149,6 +153,9 @@ public class InitApplicationContext extends HttpServlet {
         }
     }
 
+    /**
+     * listEnvVars.
+     */
     public void listEnvVars() {
         _logger.debug(
                 "----------------------------------------------------------------------------------------------------");
@@ -169,6 +176,9 @@ public class InitApplicationContext extends HttpServlet {
                 "----------------------------------------------------------------------------------------------------");
     }
 
+    /**
+     * showLicense.
+     */
     public void showLicense() {
         _logger.info(
                 "----------------------------------------------------------------------------------------------------");