提交 44a72145 编写于 作者: M MaxKey

fix

上级 d4aced98
......@@ -94,7 +94,7 @@ public class ApplicationAutoConfiguration implements InitializingBean {
if(_logger.isDebugEnabled()) {
_logger.debug("Password Encoders :");
for (String key : encoders.keySet()) {
_logger.debug(key + "=" + encoders.get(key));
_logger.debug(key + "=" + encoders.get(key).getClass().getName());
}
}
_logger.debug("default encoder " + idForEncode);
......
......@@ -65,7 +65,7 @@ public class ActiveDirectoryUser {
/*
*常规
* 名 First Name givenName
* 姓 Last Name sn
* 姓 Last Name/SurName sn
* 英文缩写 Initials initials
* 描述 Description description
* 办公室 Office physicalDeliveryOfficeName
......@@ -179,13 +179,45 @@ public class ActiveDirectoryUser {
public static final String DISTINGUISHEDNAME = "distinguishedname";
//MaxKey EXTEND
/**
* EXTEND managerName
*/
public static final String MANAGERNAME = "managerName";
/**
* EXTEND username
*/
public static final String USERNAME = "username";
/**
* EXTEND userType
*/
public static final String USERTYPE = "userType";
/**
* EXTEND gender
*/
public static final String GENDER = "gender";
/**
* EXTEND status
*/
public static final String USERSTATUS = "status";
/**
* EXTEND firstName
*/
public static final String FIRSTNAME = "firstName";
/**
* EXTEND lastName
*/
public static final String LASTNAME = "lastName";
/**
* EXTEND email
*/
public static final String EMAIL = "email";
/**
* encodePassword for ActiveDirectory
* @param password
* @return
* @throws UnsupportedEncodingException
*/
public static byte[] encodePassword(String password) throws UnsupportedEncodingException {
return ("\"" + password + "\"").getBytes("UTF-16LE");
}
......
......@@ -132,9 +132,21 @@ public class InetOrgPerson {
public static final String MANAGER = "manager";
//MaxKey EXTEND
/**
* EXTEND department
*/
public static final String DEPARTMENT = "department";
/**
* EXTEND firstName
*/
public static final String FIRSTNAME = "firstName";
/**
* EXTEND lastName
*/
public static final String LASTNAME = "lastName";
/**
* EXTEND email
*/
public static final String EMAIL = "email";
}
......@@ -35,6 +35,7 @@ import org.maxkey.util.IdGenerator;
import org.maxkey.web.message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.security.core.Authentication;
......@@ -161,13 +162,21 @@ public final class WebContext {
* @param id
* @return Object
*/
public static Object getBean(String id){
public static Object getBean(String name){
if(applicationContext==null) {
return getApplicationContext().getBean(id);
return getApplicationContext().getBean(name);
}else {
return applicationContext.getBean(id);
return applicationContext.getBean(name);
}
}
public static <T> T getBean(String name, Class<T> requiredType) throws BeansException{
if(applicationContext==null) {
return getApplicationContext().getBean(name,requiredType);
}else {
return applicationContext.getBean(name,requiredType);
}
};
// below method is common HttpServlet method
/**
......@@ -202,8 +211,8 @@ public final class WebContext {
* http://www.website.com/webcontext
*/
public static String getHttpContextPath(HttpServletRequest httpServletRequest) {
ApplicationConfig applicationConfig = (
ApplicationConfig) WebContext.getBean("applicationConfig");
ApplicationConfig applicationConfig =
WebContext.getBean("applicationConfig",ApplicationConfig.class);
_logger.trace("Config ServerPrefix " + applicationConfig.getServerPrefix());
_logger.trace("Config DomainName " + applicationConfig.getDomainName());
......@@ -295,7 +304,7 @@ public final class WebContext {
* @return encoded String
*/
public static String encoding(String encodingString) {
ApplicationConfig applicationConfig = (ApplicationConfig) getBean("applicationConfig");
ApplicationConfig applicationConfig = getBean("applicationConfig",ApplicationConfig.class);
return applicationConfig.getCharacterEncodingConfig().encoding(encodingString);
}
......@@ -309,7 +318,7 @@ public final class WebContext {
Locale locale = null;
try {
CookieLocaleResolver cookieLocaleResolver =
(CookieLocaleResolver) getBean("localeResolver");
getBean("localeResolver",CookieLocaleResolver.class);
locale = cookieLocaleResolver.resolveLocale(getRequest());
} catch (Exception e) {
......
......@@ -154,7 +154,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
if(userInfo.getStatus() != ConstantsStatus.ACTIVE) {
if(accountsService==null) {
accountsService =
(AccountsService)WebContext.getBean("accountsService");
WebContext.getBean("accountsService",AccountsService.class);
}
Accounts queryAcount =new Accounts();
queryAcount.setUserId(userInfo.getId());
......
......@@ -44,7 +44,7 @@ public abstract class AbstractAuthorizeAdapter {
public String sign(String data,Apps app){
if(Boolean.isTrue(app.getIsSignature())){
KeyStoreLoader keyStoreLoader=(KeyStoreLoader)WebContext.getBean("keyStoreLoader");
KeyStoreLoader keyStoreLoader=WebContext.getBean("keyStoreLoader",KeyStoreLoader.class);
try {
byte[] signature= CertSigner.sign(data.getBytes(), keyStoreLoader.getKeyStore(), keyStoreLoader.getEntityName(), keyStoreLoader.getKeystorePassword());
_logger.debug("signed Token : "+data);
......
......@@ -49,8 +49,8 @@ public class JwtAdapter extends AbstractAuthorizeAdapter {
AppsJwtDetails details=(AppsJwtDetails)app;
JwtSigningAndValidationService jwtSignerService= (JwtSigningAndValidationService)WebContext.getBean("jwtSignerValidationService");
OIDCProviderMetadata providerMetadata= (OIDCProviderMetadata)WebContext.getBean("oidcProviderMetadata");
JwtSigningAndValidationService jwtSignerService= WebContext.getBean("jwtSignerValidationService",JwtSigningAndValidationService.class);
OIDCProviderMetadata providerMetadata= WebContext.getBean("oidcProviderMetadata",OIDCProviderMetadata.class);
DateTime currentDateTime=DateTime.now();
......
......@@ -48,8 +48,8 @@ public class JwtDefaultAdapter extends AbstractAuthorizeAdapter {
AppsJwtDetails details=(AppsJwtDetails)app;
JwtSigningAndValidationService jwtSignerService= (JwtSigningAndValidationService)WebContext.getBean("jwtSignerValidationService");
OIDCProviderMetadata providerMetadata= (OIDCProviderMetadata)WebContext.getBean("oidcProviderMetadata");
JwtSigningAndValidationService jwtSignerService= WebContext.getBean("jwtSignerValidationService",JwtSigningAndValidationService.class);
OIDCProviderMetadata providerMetadata= WebContext.getBean("oidcProviderMetadata",OIDCProviderMetadata.class);
DateTime currentDateTime=DateTime.now();
......
......@@ -52,7 +52,7 @@ public class JwtHS256Adapter extends AbstractAuthorizeAdapter {
public String generateInfo(SigninPrincipal authentication,UserInfo userInfo,Object app) {
AppsJwtDetails details=(AppsJwtDetails)app;
OIDCProviderMetadata providerMetadata= (OIDCProviderMetadata)WebContext.getBean("oidcProviderMetadata");
OIDCProviderMetadata providerMetadata= WebContext.getBean("oidcProviderMetadata",OIDCProviderMetadata.class);
DateTime currentDateTime=DateTime.now();
......
......@@ -121,13 +121,13 @@ public class TokenEndpointAuthenticationFilter implements Filter {
ServletException {
logger.debug("Authentication TokenEndpoint ");
if(authenticationManager==null) {
authenticationManager=(AuthenticationManager)WebContext.getBean("oauth20UserAuthenticationManager");
authenticationManager= WebContext.getBean("oauth20UserAuthenticationManager",AuthenticationManager.class);
}
if(oAuth2RequestFactory==null) {
oAuth2RequestFactory=(OAuth2RequestFactory)WebContext.getBean("oAuth2RequestFactory");
oAuth2RequestFactory= WebContext.getBean("oAuth2RequestFactory",OAuth2RequestFactory.class);
}
if(oauth20ClientAuthenticationManager==null) {
oauth20ClientAuthenticationManager = (AuthenticationManager)WebContext.getBean("oauth20ClientAuthenticationManager");
oauth20ClientAuthenticationManager = WebContext.getBean("oauth20ClientAuthenticationManager",AuthenticationManager.class);
}
final boolean debug = logger.isDebugEnabled();
......
......@@ -79,7 +79,7 @@ public class AttributeStatementGenerator {
}
logger.debug("ExtendAttr "+saml20Details.getExtendAttr());
if(Boolean.isTrue(saml20Details.getIsExtendAttr())) {
if(Boolean.isTrue(saml20Details.getIsExtendAttr()) && saml20Details.getExtendAttr() != null) {
ExtraAttrs extraAttrs=new ExtraAttrs(saml20Details.getExtendAttr());
for(ExtraAttr extraAttr : extraAttrs.getExtraAttrs()) {
logger.debug("Attribute : "+extraAttr.getAttr()+" , Vale : "+extraAttr.getValue()+" , Type : "+extraAttr.getType());
......@@ -140,12 +140,19 @@ public class AttributeStatementGenerator {
attributeMap.put(ActiveDirectoryUser.MANAGERNAME, userInfo.getManager());
attributeMap.put(ActiveDirectoryUser.DISPLAYNAME, userInfo.getDisplayName());
attributeMap.put(ActiveDirectoryUser.FIRSTNAME, userInfo.getGivenName());
attributeMap.put(ActiveDirectoryUser.LASTNAME, userInfo.getFamilyName());
attributeMap.put(ActiveDirectoryUser.GIVENNAME, userInfo.getGivenName());
attributeMap.put(ActiveDirectoryUser.SN, userInfo.getFamilyName());
attributeMap.put(ActiveDirectoryUser.GENDER, userInfo.getGender() + "");
attributeMap.put(ActiveDirectoryUser.MAIL, userInfo.getEmail());
attributeMap.put(ActiveDirectoryUser.MOBILE, userInfo.getMobile());
attributeMap.put(ActiveDirectoryUser.MAIL, userInfo.getEmail());
attributeMap.put(ActiveDirectoryUser.EMAIL, userInfo.getEmail());
attributeMap.put(ActiveDirectoryUser.USERSTATUS, userInfo.getStatus() + "");
return attributeMap;
......
......@@ -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);
......
......@@ -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 #
############################################################################
......
......@@ -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 #
############################################################################
......
......@@ -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();
}
......
......@@ -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 #
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册