This commit is contained in:
MaxKey
2021-11-06 20:09:39 +08:00
parent d4aced9886
commit 44a721452d
16 changed files with 127 additions and 58 deletions

View File

@@ -23,6 +23,8 @@ import javax.servlet.ServletException;
import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.constants.ConstantsStatus;
import org.maxkey.crypto.ReciprocalUtils;
@@ -35,6 +37,7 @@ import org.maxkey.util.DateUtils;
import org.maxkey.util.StringUtils;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.mybatis.spring.SqlSessionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,8 +55,6 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/registration"})
public class RegistrationController {
private static Logger _logger = LoggerFactory.getLogger(RegistrationController.class);
@Autowired
@@ -98,7 +99,10 @@ public class RegistrationController {
try {
email.setHostName(applicationConfig.getEmailConfig().getSmtpHost());
email.setSmtpPort(applicationConfig.getEmailConfig().getPort());
email.setAuthenticator(new DefaultAuthenticator(applicationConfig.getEmailConfig().getUsername(), applicationConfig.getEmailConfig().getPassword()));
email.setAuthenticator(new DefaultAuthenticator(
applicationConfig.getEmailConfig().getUsername(),
applicationConfig.getEmailConfig().getPassword()
));
email.addTo(registration.getWorkEmail(), registration.getLastName()+registration.getFirstName());
email.setFrom(applicationConfig.getEmailConfig().getSender(), "MaxKey");
@@ -141,14 +145,17 @@ public class RegistrationController {
@RequestMapping(value={"/activate/{id}"})
public ModelAndView setPassWord(@PathVariable("id") String id,@RequestParam String password,@RequestParam String confirmpassword) {
public ModelAndView setPassWord(@PathVariable("id") String id,
@RequestParam String password,
@RequestParam String confirmpassword) {
_logger.debug("Registration /registration/setpassword.");
ModelAndView modelAndView=new ModelAndView("registration/activated");
if(password.equals(confirmpassword)){
Registration registration=registrationService.get(id);
if(registration!=null){
org.mybatis.spring.SqlSessionUtils.getSqlSession((org.apache.ibatis.session.SqlSessionFactory)WebContext.getBean("sqlSessionFactory")).commit(false);
SqlSession sqlSession = SqlSessionUtils.getSqlSession(
WebContext.getBean("sqlSessionFactory",SqlSessionFactory.class));
sqlSession.commit(false);
UserInfo userInfo=new UserInfo();
userInfo.setUsername(registration.getWorkEmail());
@@ -167,7 +174,7 @@ public class RegistrationController {
userInfoService.insert(userInfo);
registrationService.remove(id);
org.mybatis.spring.SqlSessionUtils.getSqlSession((org.apache.ibatis.session.SqlSessionFactory)WebContext.getBean("sqlSessionFactory")).commit(true);
sqlSession.commit(true);
modelAndView.addObject("activate", 1);
}else{
modelAndView.addObject("activate", 2);

View File

@@ -286,20 +286,15 @@ maxkey.saml.v20.assertion.validity.time.ins.seconds =90
maxkey.saml.v20.replay.cache.life.in.millis =14400000
maxkey.saml.v20.issue.instant.check.clock.skew.in.seconds =90
maxkey.saml.v20.issue.instant.check.validity.time.in.seconds =300
#saml idp keystore
#saml Identity Provider keystore
maxkey.saml.v20.idp.keystore.password =maxkey
maxkey.saml.v20.idp.keystore.private.key.password =maxkey
maxkey.saml.v20.idp.keystore =classpath\:config/samlServerKeystore.jks
#keystore id for sec
#keystore Identity Provider for security
maxkey.saml.v20.idp.issuing.entity.id =maxkey.top
maxkey.saml.v20.idp.issuer =${maxkey.server.authz.uri}/saml
maxkey.saml.v20.idp.receiver.endpoint =https\://sso.maxkey.top/
#saml sp keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
#Saml v20 METADATA
#Saml v20 Identity Provider METADATA
maxkey.saml.v20.metadata.orgName =MaxKeyTop
maxkey.saml.v20.metadata.orgDisplayName =MaxKeyTop
maxkey.saml.v20.metadata.orgURL =https://www.maxkey.top
@@ -310,6 +305,12 @@ maxkey.saml.v20.metadata.surName =maxkey
maxkey.saml.v20.metadata.emailAddress =maxkeysupport@163.com
maxkey.saml.v20.metadata.telephoneNumber =4008981111
#saml RelayParty keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
############################################################################
#Management endpoints configuration #
############################################################################

View File

@@ -288,20 +288,15 @@ maxkey.saml.v20.assertion.validity.time.ins.seconds =90
maxkey.saml.v20.replay.cache.life.in.millis =14400000
maxkey.saml.v20.issue.instant.check.clock.skew.in.seconds =90
maxkey.saml.v20.issue.instant.check.validity.time.in.seconds =300
#saml idp keystore
#saml Identity Provider keystore
maxkey.saml.v20.idp.keystore.password =maxkey
maxkey.saml.v20.idp.keystore.private.key.password =maxkey
maxkey.saml.v20.idp.keystore =classpath\:config/samlServerKeystore.jks
#keystore id for sec
#keystore Identity Provider for security
maxkey.saml.v20.idp.issuing.entity.id =maxkey.top
maxkey.saml.v20.idp.issuer =${maxkey.server.authz.uri}/saml
maxkey.saml.v20.idp.receiver.endpoint =https\://sso.maxkey.top/
#saml sp keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
#Saml v20 METADATA
#Saml v20 Identity Provider METADATA
maxkey.saml.v20.metadata.orgName =MaxKeyTop
maxkey.saml.v20.metadata.orgDisplayName =MaxKeyTop
maxkey.saml.v20.metadata.orgURL =https://www.maxkey.top
@@ -312,6 +307,12 @@ maxkey.saml.v20.metadata.surName =maxkey
maxkey.saml.v20.metadata.emailAddress =maxkeysupport@163.com
maxkey.saml.v20.metadata.telephoneNumber =4008981111
#saml RelayParty keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
############################################################################
#Management endpoints configuration #
############################################################################

View File

@@ -111,7 +111,7 @@ public class SynchronizersController {
for(String sysId : ids) {
Synchronizers synchronizer = synchronizersService.get(sysId);
_logger.debug("synchronizer " + synchronizer);
ISynchronizerService synchronizerService = (ISynchronizerService)WebContext.getBean(synchronizer.getService());
ISynchronizerService synchronizerService = WebContext.getBean(synchronizer.getService(),ISynchronizerService.class);
synchronizerService.setSynchronizer(synchronizer);
synchronizerService.sync();
}

View File

@@ -30,7 +30,7 @@ maxkey.server.scheme =http
maxkey.server.basedomain =${SERVER_DOMAIN:maxkey.top}
maxkey.server.domain =sso.${maxkey.server.basedomain}
maxkey.server.name =${maxkey.server.scheme}://${maxkey.server.domain}
maxkey.server.uri =${maxkey.server.name}:9527/${server.servlet.context-path}
maxkey.server.uri =${maxkey.server.name}:9527${server.servlet.context-path}
#default.uri
maxkey.server.default.uri =${maxkey.server.uri}/main
maxkey.server.mgt.uri =${maxkey.server.uri}
@@ -178,20 +178,15 @@ maxkey.saml.v20.assertion.validity.time.ins.seconds =90
maxkey.saml.v20.replay.cache.life.in.millis =14400000
maxkey.saml.v20.issue.instant.check.clock.skew.in.seconds =90
maxkey.saml.v20.issue.instant.check.validity.time.in.seconds =300
#saml idp keystore
#saml Identity Provider keystore
maxkey.saml.v20.idp.keystore.password =maxkey
maxkey.saml.v20.idp.keystore.private.key.password =maxkey
maxkey.saml.v20.idp.keystore =classpath\:config/samlServerKeystore.jks
#keystore id for sec
#keystore Identity Provider for security
maxkey.saml.v20.idp.issuing.entity.id =maxkey.top
maxkey.saml.v20.idp.issuer =${maxkey.server.authz.uri}/saml
maxkey.saml.v20.idp.receiver.endpoint =https\://sso.maxkey.top/
#saml sp keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
#Saml v20 METADATA
#Saml v20 Identity Provider METADATA
maxkey.saml.v20.metadata.orgName =MaxKeyTop
maxkey.saml.v20.metadata.orgDisplayName =MaxKeyTop
maxkey.saml.v20.metadata.orgURL =https://www.maxkey.top
@@ -202,6 +197,11 @@ maxkey.saml.v20.metadata.surName =maxkey
maxkey.saml.v20.metadata.emailAddress =maxkeysupport@163.com
maxkey.saml.v20.metadata.telephoneNumber =4008981111
#saml RelayParty keystore
maxkey.saml.v20.sp.keystore.password =maxkey
maxkey.saml.v20.sp.keystore.private.key.password =maxkey
maxkey.saml.v20.sp.keystore =classpath\:config/samlClientKeystore.jks
maxkey.saml.v20.sp.issuing.entity.id =client.maxkey.org
#############################################################################
#OIDC V1.0 METADATA configuration #