v1.3 RC
This commit is contained in:
@@ -5,94 +5,90 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:/config/applicationLogin.properties")
|
||||
@PropertySource("classpath:/config/applicationConfig.properties")
|
||||
public class LoginConfig {
|
||||
@Value("${config.login.captcha}")
|
||||
boolean captcha;
|
||||
@Value("${config.login.onetimepwd}")
|
||||
boolean oneTimePwd;
|
||||
@Value("${config.login.socialsignon}")
|
||||
boolean socialSignOn;
|
||||
@Value("${config.login.kerberos}")
|
||||
boolean kerberos;
|
||||
@Value("${config.login.remeberme}")
|
||||
boolean remeberMe;
|
||||
@Value("${config.login.wsfederation}")
|
||||
boolean wsFederation;
|
||||
@Value("${config.login.default.uri}")
|
||||
String defaultUri;
|
||||
@Value("${config.login.captcha}")
|
||||
boolean captcha;
|
||||
@Value("${config.login.onetimepwd}")
|
||||
boolean oneTimePwd;
|
||||
@Value("${config.login.socialsignon}")
|
||||
boolean socialSignOn;
|
||||
@Value("${config.login.kerberos}")
|
||||
boolean kerberos;
|
||||
@Value("${config.login.remeberme}")
|
||||
boolean remeberMe;
|
||||
@Value("${config.login.wsfederation}")
|
||||
boolean wsFederation;
|
||||
@Value("${config.login.default.uri}")
|
||||
String defaultUri;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public LoginConfig() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
/**
|
||||
* .
|
||||
*/
|
||||
public LoginConfig() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public boolean isCaptcha() {
|
||||
return captcha;
|
||||
}
|
||||
public boolean isCaptcha() {
|
||||
return captcha;
|
||||
}
|
||||
|
||||
public void setCaptcha(boolean captcha) {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
public void setCaptcha(boolean captcha) {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
|
||||
public boolean isOneTimePwd() {
|
||||
return oneTimePwd;
|
||||
}
|
||||
|
||||
public void setOneTimePwd(boolean oneTimePwd) {
|
||||
this.oneTimePwd = oneTimePwd;
|
||||
}
|
||||
|
||||
public boolean isOneTimePwd() {
|
||||
return oneTimePwd;
|
||||
}
|
||||
public boolean isSocialSignOn() {
|
||||
return socialSignOn;
|
||||
}
|
||||
|
||||
public void setOneTimePwd(boolean oneTimePwd) {
|
||||
this.oneTimePwd = oneTimePwd;
|
||||
}
|
||||
public void setSocialSignOn(boolean socialSignOn) {
|
||||
this.socialSignOn = socialSignOn;
|
||||
}
|
||||
|
||||
public boolean isSocialSignOn() {
|
||||
return socialSignOn;
|
||||
}
|
||||
public boolean isKerberos() {
|
||||
return kerberos;
|
||||
}
|
||||
|
||||
public void setSocialSignOn(boolean socialSignOn) {
|
||||
this.socialSignOn = socialSignOn;
|
||||
}
|
||||
public void setKerberos(boolean kerberos) {
|
||||
this.kerberos = kerberos;
|
||||
}
|
||||
|
||||
public boolean isKerberos() {
|
||||
return kerberos;
|
||||
}
|
||||
public String getDefaultUri() {
|
||||
return defaultUri;
|
||||
}
|
||||
|
||||
public void setKerberos(boolean kerberos) {
|
||||
this.kerberos = kerberos;
|
||||
}
|
||||
public void setDefaultUri(String defaultUri) {
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
|
||||
public String getDefaultUri() {
|
||||
return defaultUri;
|
||||
}
|
||||
public boolean isRemeberMe() {
|
||||
return remeberMe;
|
||||
}
|
||||
|
||||
public void setDefaultUri(String defaultUri) {
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
public void setRemeberMe(boolean remeberMe) {
|
||||
this.remeberMe = remeberMe;
|
||||
}
|
||||
|
||||
public boolean isRemeberMe() {
|
||||
return remeberMe;
|
||||
}
|
||||
public boolean isWsFederation() {
|
||||
return wsFederation;
|
||||
}
|
||||
|
||||
public void setRemeberMe(boolean remeberMe) {
|
||||
this.remeberMe = remeberMe;
|
||||
}
|
||||
|
||||
public boolean isWsFederation() {
|
||||
return wsFederation;
|
||||
}
|
||||
public void setWsFederation(boolean wsFederation) {
|
||||
this.wsFederation = wsFederation;
|
||||
}
|
||||
|
||||
public void setWsFederation(boolean wsFederation) {
|
||||
this.wsFederation = wsFederation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoginConfig [captcha=" + captcha + ", oneTimePwd=" + oneTimePwd
|
||||
+ ", socialSignOn=" + socialSignOn + ", kerberos=" + kerberos
|
||||
+ ", remeberMe=" + remeberMe + ", wsFederation=" + wsFederation
|
||||
+ ", defaultUri=" + defaultUri + "]";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoginConfig [captcha=" + captcha + ", oneTimePwd=" + oneTimePwd + ", socialSignOn=" + socialSignOn
|
||||
+ ", kerberos=" + kerberos + ", remeberMe=" + remeberMe + ", wsFederation=" + wsFederation
|
||||
+ ", defaultUri=" + defaultUri + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,144 +32,154 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
*/
|
||||
public class InitApplicationContext extends HttpServlet {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(InitApplicationContext.class);
|
||||
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
*
|
||||
private static final long serialVersionUID = -797399138268601444L;
|
||||
ApplicationContext applicationContext;
|
||||
Properties properties;
|
||||
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return super.getServletInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
|
||||
// List Environment Variables
|
||||
listEnvVars();
|
||||
|
||||
listProperties();
|
||||
|
||||
// List DatabaseMetaData Variables
|
||||
listDataBaseVariables();
|
||||
|
||||
// load caches
|
||||
loadCaches();
|
||||
|
||||
// Show License
|
||||
showLicense();
|
||||
}
|
||||
|
||||
/**
|
||||
* InitApplicationContext.
|
||||
*/
|
||||
private static final long serialVersionUID = -797399138268601444L;
|
||||
public InitApplicationContext() {
|
||||
this.applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return super.getServletInfo();
|
||||
}
|
||||
public InitApplicationContext(ConfigurableApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
|
||||
//List Environment Variables
|
||||
listEnvVars();
|
||||
|
||||
listProperties();
|
||||
|
||||
//List DatabaseMetaData Variables
|
||||
listDataBaseVariables();
|
||||
|
||||
//load caches
|
||||
loadCaches();
|
||||
|
||||
//Show License
|
||||
showLicense();
|
||||
}
|
||||
public void loadCaches() {
|
||||
_logger.info(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
_logger.info("Load Caches ");
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public InitApplicationContext() {
|
||||
this.applicationContext=WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
|
||||
}
|
||||
|
||||
public InitApplicationContext(ConfigurableApplicationContext applicationContext) {
|
||||
this.applicationContext=applicationContext;
|
||||
}
|
||||
|
||||
public void loadCaches(){
|
||||
_logger.info("----------------------------------------------------------------------------------------------------");
|
||||
_logger.info("Load Caches ");
|
||||
|
||||
try {
|
||||
if(applicationContext.containsBean("cacheFactory")){
|
||||
CacheFactory cacheFactory=applicationContext.getBean("cacheFactory", CacheFactory.class);
|
||||
cacheFactory.start();
|
||||
}
|
||||
} catch (BeansException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
_logger.info("----------------------------------------------------------------------------------------------------");
|
||||
|
||||
}
|
||||
public void listDataBaseVariables(){
|
||||
if(applicationContext.containsBean("dataSource")){
|
||||
try {
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List DatabaseMetaData Variables ");
|
||||
Connection connection = ((javax.sql.DataSource)applicationContext.getBean("dataSource")).getConnection();
|
||||
|
||||
java.sql.DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||
_logger.debug("DatabaseProductName : " + databaseMetaData.getDatabaseProductName());
|
||||
_logger.debug("DatabaseProductVersion: " + databaseMetaData.getDatabaseProductVersion());
|
||||
_logger.debug("DatabaseMajorVersion : " + databaseMetaData.getDatabaseMajorVersion());
|
||||
_logger.debug("DatabaseMinorVersion : " + databaseMetaData.getDatabaseMinorVersion());
|
||||
_logger.debug("supportsTransactions : " + databaseMetaData.supportsTransactions());
|
||||
_logger.debug("DefaultTransaction : " + databaseMetaData.getDefaultTransactionIsolation());
|
||||
_logger.debug("MaxConnections : " + databaseMetaData.getMaxConnections());
|
||||
_logger.debug("");
|
||||
_logger.debug("JDBCMajorVersion : " + databaseMetaData.getJDBCMajorVersion());
|
||||
_logger.debug("JDBCMinorVersion : " + databaseMetaData.getJDBCMinorVersion());
|
||||
_logger.debug("DriverName : " + databaseMetaData.getDriverName());
|
||||
_logger.debug("DriverVersion : " + databaseMetaData.getDriverVersion());
|
||||
_logger.debug("");
|
||||
_logger.debug("DBMS URL : " + databaseMetaData.getURL());
|
||||
_logger.debug("UserName : " + databaseMetaData.getUserName());
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//propertySourcesPlaceholderConfigurer
|
||||
public void listProperties(){
|
||||
if(applicationContext.containsBean("propertySourcesPlaceholderConfigurer")){
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List Properties Variables ");
|
||||
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = ((PropertySourcesPlaceholderConfigurer)applicationContext.getBean("propertySourcesPlaceholderConfigurer"));
|
||||
Properties properties=(Properties)propertySourcesPlaceholderConfigurer.getAppliedPropertySources().get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME).getSource();
|
||||
Set<Object> keyValue = properties.keySet();
|
||||
SortedSet<String> keyValueSet=new TreeSet<String>();
|
||||
//sort key
|
||||
for (Iterator<Object> it = keyValue.iterator(); it.hasNext();){
|
||||
String key = (String) it.next();
|
||||
keyValueSet.add(key);
|
||||
}
|
||||
//out
|
||||
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();){
|
||||
String key = (String) it.next();
|
||||
_logger.debug(key + " = " + properties.get(key));
|
||||
}
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public void listEnvVars() {
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List Environment Variables ");
|
||||
Map<String, String> map = System.getenv();
|
||||
SortedSet<String> keyValueSet = new TreeSet<String>();
|
||||
for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
|
||||
String key = itr.next();
|
||||
keyValueSet.add(key);
|
||||
}
|
||||
// out
|
||||
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
_logger.debug(key + " = " + map.get(key));
|
||||
}
|
||||
_logger.debug("APP_HOME" + " = " + PathUtils.getInstance().getAppPath());
|
||||
_logger.debug("----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
public void showLicense(){
|
||||
_logger.info("----------------------------------------------------------------------------------------------------");
|
||||
_logger.info("+ Single Sign On ( SSO ) ");
|
||||
_logger.info("+ MaxKey Version v1.3 GA");
|
||||
_logger.info("");
|
||||
_logger.info("+ Apache License 2.0");
|
||||
_logger.info("+ https://github.com/shimingxy/MaxKey");
|
||||
_logger.info("+ email:shimingxy@163.com");
|
||||
_logger.info("----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
try {
|
||||
if (applicationContext.containsBean("cacheFactory")) {
|
||||
CacheFactory cacheFactory = applicationContext.getBean("cacheFactory", CacheFactory.class);
|
||||
cacheFactory.start();
|
||||
}
|
||||
} catch (BeansException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
_logger.info(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
public void listDataBaseVariables() {
|
||||
if (applicationContext.containsBean("dataSource")) {
|
||||
try {
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List DatabaseMetaData Variables ");
|
||||
Connection connection = ((javax.sql.DataSource) applicationContext.getBean("dataSource"))
|
||||
.getConnection();
|
||||
|
||||
java.sql.DatabaseMetaData databaseMetaData = connection.getMetaData();
|
||||
_logger.debug("DatabaseProductName : " + databaseMetaData.getDatabaseProductName());
|
||||
_logger.debug("DatabaseProductVersion: " + databaseMetaData.getDatabaseProductVersion());
|
||||
_logger.debug("DatabaseMajorVersion : " + databaseMetaData.getDatabaseMajorVersion());
|
||||
_logger.debug("DatabaseMinorVersion : " + databaseMetaData.getDatabaseMinorVersion());
|
||||
_logger.debug("supportsTransactions : " + databaseMetaData.supportsTransactions());
|
||||
_logger.debug("DefaultTransaction : " + databaseMetaData.getDefaultTransactionIsolation());
|
||||
_logger.debug("MaxConnections : " + databaseMetaData.getMaxConnections());
|
||||
_logger.debug("");
|
||||
_logger.debug("JDBCMajorVersion : " + databaseMetaData.getJDBCMajorVersion());
|
||||
_logger.debug("JDBCMinorVersion : " + databaseMetaData.getJDBCMinorVersion());
|
||||
_logger.debug("DriverName : " + databaseMetaData.getDriverName());
|
||||
_logger.debug("DriverVersion : " + databaseMetaData.getDriverVersion());
|
||||
_logger.debug("");
|
||||
_logger.debug("DBMS URL : " + databaseMetaData.getURL());
|
||||
_logger.debug("UserName : " + databaseMetaData.getUserName());
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// propertySourcesPlaceholderConfigurer
|
||||
public void listProperties() {
|
||||
if (applicationContext.containsBean("propertySourcesPlaceholderConfigurer")) {
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List Properties Variables ");
|
||||
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = ((PropertySourcesPlaceholderConfigurer) applicationContext
|
||||
.getBean("propertySourcesPlaceholderConfigurer"));
|
||||
properties = (Properties) propertySourcesPlaceholderConfigurer.getAppliedPropertySources()
|
||||
.get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME).getSource();
|
||||
Set<Object> keyValue = properties.keySet();
|
||||
SortedSet<String> keyValueSet = new TreeSet<String>();
|
||||
// sort key
|
||||
for (Iterator<Object> it = keyValue.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
keyValueSet.add(key);
|
||||
}
|
||||
// out
|
||||
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
_logger.debug(key + " = " + properties.get(key));
|
||||
}
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public void listEnvVars() {
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
_logger.debug("List Environment Variables ");
|
||||
Map<String, String> map = System.getenv();
|
||||
SortedSet<String> keyValueSet = new TreeSet<String>();
|
||||
for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
|
||||
String key = itr.next();
|
||||
keyValueSet.add(key);
|
||||
}
|
||||
// out
|
||||
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
|
||||
String key = (String) it.next();
|
||||
_logger.debug(key + " = " + map.get(key));
|
||||
}
|
||||
_logger.debug("APP_HOME" + " = " + PathUtils.getInstance().getAppPath());
|
||||
_logger.debug(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
public void showLicense() {
|
||||
_logger.info(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
_logger.info("+ Single Sign On ( SSO ) ");
|
||||
_logger.info("+ MaxKey Version "+properties.getProperty("application.formatted-version"));
|
||||
_logger.info("");
|
||||
_logger.info("+ Apache License 2.0");
|
||||
_logger.info("+ https://shimingxy.github.io/MaxKey/");
|
||||
_logger.info("+ email:shimingxy@163.com");
|
||||
_logger.info(
|
||||
"----------------------------------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user