protocl fix

This commit is contained in:
shimingxy
2019-06-02 08:43:34 +08:00
parent 86701ba7d0
commit e62f96fa73
169 changed files with 2856 additions and 7134 deletions

View File

@@ -80,12 +80,23 @@ public abstract class AbstractAuthenticationProvider{
}
// user authenticated
_logger.debug("'{0}' authenticated successfully by {}.", authentication.getPrincipal(), getProviderName());
_logger.debug("'{}' authenticated successfully by {}.", authentication.getPrincipal(), getProviderName());
UserInfo userInfo=WebContext.getUserInfo();
Object password_set_type=WebContext.getSession().getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
//登录完成后切换SESSION
_logger.debug("Login Session {}.", WebContext.getSession().getId());
WebContext.getSession().invalidate();
WebContext.setAttribute(WebConstants.CURRENT_USER_SESSION_ID, WebContext.getSession().getId());
_logger.debug("Login Success Session {}.", WebContext.getSession().getId());
authenticationRealm.insertLoginHistory(userInfo,LOGINTYPE.LOCAL,"","xe00000004","success");
//认证设置
WebContext.setAuthentication(authentication);
WebContext.setUserInfo(userInfo);
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,password_set_type);
// create new authentication response containing the user and it's authorities
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(userInfo.getUsername(), authentication.getCredentials(), authentication.getAuthorities());
return simpleUserAuthentication;

View File

@@ -1,8 +1,10 @@
package org.maxkey.authn;
import java.util.ArrayList;
import java.util.Collection;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
public class BasicAuthentication implements Authentication{
/**
@@ -17,10 +19,13 @@ public class BasicAuthentication implements Authentication{
String j_remeberme;
String j_auth_type;
String j_jwt_token;
ArrayList<GrantedAuthority> grantedAuthority;
boolean authenticated;
public BasicAuthentication() {
grantedAuthority = new ArrayList<GrantedAuthority>();
grantedAuthority.add(new SimpleGrantedAuthority("ROLE_USER"));
grantedAuthority.add(new SimpleGrantedAuthority("ORDINARY_USER"));
}
@Override
@@ -30,7 +35,7 @@ public class BasicAuthentication implements Authentication{
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
return grantedAuthority;
}
@Override
@@ -122,6 +127,14 @@ public class BasicAuthentication implements Authentication{
public void setJ_jwt_token(String j_jwt_token) {
this.j_jwt_token = j_jwt_token;
}
public ArrayList<GrantedAuthority> getGrantedAuthority() {
return grantedAuthority;
}
public void setGrantedAuthority(ArrayList<GrantedAuthority> grantedAuthority) {
this.grantedAuthority = grantedAuthority;
}
@Override
public String toString() {

View File

@@ -52,6 +52,7 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
authenticationRealm.passwordPolicyValid(userInfo);
authenticationRealm.passwordMatches(userInfo, auth.getJ_password());
authenticationRealm.grantAuthority(userInfo);
/**
* put userInfo to current session context
*/
@@ -63,9 +64,11 @@ public class RealmAuthenticationProvider extends AbstractAuthenticationProvider
_logger.debug("do Remeber Me");
}
}
auth.setAuthenticated(true);
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =new UsernamePasswordAuthenticationToken(
userInfo,
auth.getJ_password(),
auth,
"PASSWORD",
authenticationRealm.grantAuthorityAndNavs(userInfo));
usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetails(WebContext.getRequest()));

View File

@@ -69,7 +69,7 @@ public abstract class AbstractRemeberMeService {
cookie.setMaxAge(maxAge);
//cookie.setPath("/");
cookie.setDomain("."+applicationConfig.getDomainName());
cookie.setDomain(applicationConfig.getDomainName());
response.addCookie(cookie);
request.getSession().removeAttribute(WebConstants.REMEBER_ME_SESSION);
}
@@ -126,7 +126,7 @@ public abstract class AbstractRemeberMeService {
cookie.setMaxAge(maxAge);
//cookie.setPath("/");
cookie.setDomain("."+applicationConfig.getDomainName());
cookie.setDomain(applicationConfig.getDomainName());
response.addCookie(cookie);
return true;
}
@@ -135,7 +135,7 @@ public abstract class AbstractRemeberMeService {
Cookie cookie= new Cookie(WebConstants.REMEBER_ME_COOKIE,null);
cookie.setMaxAge(0);
cookie.setDomain("."+applicationConfig.getDomainName());
cookie.setDomain(applicationConfig.getDomainName());
response.addCookie(cookie);
remove(WebContext.getUserInfo().getUsername());

View File

@@ -2,6 +2,12 @@ package org.maxkey.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
import org.hibernate.validator.constraints.Length;
@@ -15,22 +21,33 @@ import org.hibernate.validator.constraints.Length;
STATUS char(1) null
constraint PK_ROLES primary key clustered (ID)
*/
public class Accounts extends JpaBaseDomain implements Serializable{
@Table(name = "ACCOUNTS")
public class Accounts extends JpaBaseDomain implements Serializable{
/**
*
*/
private static final long serialVersionUID = 6829592256223630307L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
private String id;
@Column
private String uid;
@Column
private String username;
@Column
private String displayName;
@Column
private String appId;
@Column
private String appName;
@Length(max=60)
@Column
private String relatedUsername;
@Column
private String relatedPassword;
public Accounts(){

View File

@@ -1,21 +1,39 @@
package org.maxkey.domain;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
/**
* @author Crystal.Sea
*
*/
@Table(name = "LOGIN_APPS_HISTORY")
public class LoginAppsHistory extends JpaBaseDomain {
private static final long serialVersionUID = 5085201575292304749L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
String id;
@Column
private String sessionId;
@Column
private String appId;
@Column
private String appName;
@Column
private String uid;
@Column
private String username;
@Column
private String displayName;
@Column
private String loginTime;

View File

@@ -2,6 +2,9 @@ package org.maxkey.domain;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
@@ -9,32 +12,42 @@ import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
* @author Crystal.Sea
*
*/
@Table(name = "LOGIN_HISTORY")
public class LoginHistory extends JpaBaseDomain implements Serializable{
/**
*
*/
private static final long serialVersionUID = -1321470643357719383L;
@Column
String sessionId;
@Column
String uid;
@Column
String username;
@Column
String displayName;
@Column
String loginType;
@Column
String message;
@Column
String code;
@Column
String provider;
@Column
String sourceIp;
@Column
String browser;
@Column
String platform;
@Column
String application;
@Column
String loginUrl;
@Column
String loginTime;
@Column
String logoutTime;

View File

@@ -3,6 +3,12 @@ package org.maxkey.domain;
import java.io.IOException;
import java.util.HashMap;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.maxkey.util.StringUtils;
@@ -12,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
* @author Crystal.Sea
*
*/
@Table(name = "USERINFO")
public class UserInfo extends JpaBaseDomain {
/**
@@ -19,8 +26,11 @@ public class UserInfo extends JpaBaseDomain {
*/
private static final long serialVersionUID = 6402443942083382236L;
//
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
String id;
@Column
protected String username;
protected String password;
protected String decipherable;

View File

@@ -3,12 +3,18 @@ package org.maxkey.domain.apps;
import java.io.Serializable;
import java.util.Arrays;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
import org.maxkey.constants.BOOLEAN;
import org.maxkey.domain.Accounts;
import org.springframework.web.multipart.MultipartFile;
@Table(name = "APPLICATIONS")
public class Applications extends JpaBaseDomain implements Serializable{
/**
@@ -30,7 +36,9 @@ public class Applications extends JpaBaseDomain implements Serializable{
public static final int INTRANET=3;
}
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
protected String id;
/**
*

View File

@@ -1,14 +1,25 @@
package org.maxkey.domain.apps;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Table(name = "CAS_DETAILS")
public class CasDetails extends Applications {
/**
*
*/
private static final long serialVersionUID = -4272290765948322084L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
private String id;
@Column
private String service;
@Column
private String validation;
/**

View File

@@ -1,20 +1,33 @@
package org.maxkey.domain.apps;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Crystal.Sea
*
*/
@Table(name = "FORM_BASED_DETAILS")
public class FormBasedDetails extends Applications {
/**
*
*/
private static final long serialVersionUID = 563313247706861431L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
protected String id;
@Column
private String redirectUri;
@Column
private String usernameMapping;
@Column
private String passwordMapping;
@Column
private String authorizeView;
@@ -81,6 +94,16 @@ public class FormBasedDetails extends Applications {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "FormBasedDetails [redirectUri=" + redirectUri

View File

@@ -1,19 +1,96 @@
package org.maxkey.domain.apps;
import java.util.Arrays;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.web.multipart.MultipartFile;
/**
* @author Crystal.Sea
*
*/
public class SAML20Details extends SAMLBaseDetails {
@Table(name = "SAML_V20_DETAILS")
public class SAML20Details extends Applications {
/**
*
*/
private static final long serialVersionUID = -291159876339333345L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
protected String id;
@Column
private String certIssuer;
@Column
private String certSubject;
@Column
private String certExpiration;
@Column
private byte[] keyStore;
private String entityId;
@Column
private String spAcsUrl;
@Column
private String issuer;
@Column
private String audience;
@Column
private String nameidFormat;
@Column
private String validityInterval;
/**
* Redirect-Post
* Post-Post
* IdpInit-Post
* Redirect-PostSimpleSign
* Post-PostSimpleSign
* IdpInit-PostSimpleSign
*/
@Column
private String binding;
/**
* 0 false
* 1 true
*/
@Column
private int encrypted;
/**
* for upload
*/
@Column
private MultipartFile certMetaFile;
/**
* metadata or certificate
*/
@Column
private String fileType;
/**
* 0 original
* 1 uppercase
* 2 lowercase
*/
@Column
private int nameIdConvert;
public static class BINDINGTYPE{
public String Redirect_Post="Redirect-Post";
public String Post_Post="Post-Post";
public String IdpInit_Post="IdpInit-Post";
public String Redirect_PostSimpleSign="Redirect-PostSimpleSign";
public String Post_PostSimpleSign="Post-PostSimpleSign";
public String IdpInit_PostSimpleSign="IdpInit-PostSimpleSign";
}
@@ -25,4 +102,315 @@ public class SAML20Details extends SAMLBaseDetails {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
/**
* @return the certIssuer
*/
public String getCertIssuer() {
return certIssuer;
}
/**
* @param certIssuer the certIssuer to set
*/
public void setCertIssuer(String certIssuer) {
this.certIssuer = certIssuer;
}
/**
* @return the certSubject
*/
public String getCertSubject() {
return certSubject;
}
/**
* @param certSubject the certSubject to set
*/
public void setCertSubject(String certSubject) {
this.certSubject = certSubject;
}
/**
* @return the certExpiration
*/
public String getCertExpiration() {
return certExpiration;
}
/**
* @param certExpiration the certExpiration to set
*/
public void setCertExpiration(String certExpiration) {
this.certExpiration = certExpiration;
}
/**
* @return the keyStore
*/
public byte[] getKeyStore() {
return keyStore;
}
/**
* @param keyStore the keyStore to set
*/
public void setKeyStore(byte[] keyStore) {
this.keyStore = keyStore;
}
/**
* @return the entityId
*/
public String getEntityId() {
return entityId;
}
/**
* @param entityId the entityId to set
*/
public void setEntityId(String entityId) {
this.entityId = entityId;
}
/**
* @return the spAcsUrl
*/
public String getSpAcsUrl() {
return spAcsUrl;
}
/**
* @param spAcsUrl the spAcsUrl to set
*/
public void setSpAcsUrl(String spAcsUrl) {
this.spAcsUrl = spAcsUrl;
}
/**
* @return the issuer
*/
public String getIssuer() {
return issuer;
}
/**
* @param issuer the issuer to set
*/
public void setIssuer(String issuer) {
this.issuer = issuer;
}
/**
* @return the audience
*/
public String getAudience() {
return audience;
}
/**
* @param audience the audience to set
*/
public void setAudience(String audience) {
this.audience = audience;
}
/**
* @return the nameidFormat
*/
public String getNameidFormat() {
return nameidFormat;
}
/**
* @param nameidFormat the nameidFormat to set
*/
public void setNameidFormat(String nameidFormat) {
this.nameidFormat = nameidFormat;
}
/**
* @return the validityInterval
*/
public String getValidityInterval() {
return validityInterval;
}
/**
* @param validityInterval the validityInterval to set
*/
public void setValidityInterval(String validityInterval) {
this.validityInterval = validityInterval;
}
/**
* @return the certMetaFile
*/
public MultipartFile getCertMetaFile() {
return certMetaFile;
}
/**
* @param certMetaFile the certMetaFile to set
*/
public void setCertMetaFile(MultipartFile certMetaFile) {
this.certMetaFile = certMetaFile;
}
/**
* @return the fileType
*/
public String getFileType() {
return fileType;
}
/**
* @param fileType the fileType to set
*/
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getBinding() {
return binding;
}
public void setBinding(String binding) {
this.binding = binding;
}
public int getEncrypted() {
return encrypted;
}
public void setEncrypted(int encrypted) {
this.encrypted = encrypted;
}
public int getNameIdConvert() {
return nameIdConvert;
}
public void setNameIdConvert(int nameIdConvert) {
this.nameIdConvert = nameIdConvert;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "SAMLBaseDetails [certIssuer=" + certIssuer + ", certSubject="
+ certSubject + ", certExpiration=" + certExpiration
+ ", keyStore=" + Arrays.toString(keyStore) + ", entityId="
+ entityId + ", spAcsUrl=" + spAcsUrl + ", issuer=" + issuer
+ ", audience=" + audience + ", nameidFormat=" + nameidFormat
+ ", validityInterval=" + validityInterval + ", binding="
+ binding + ", encrypted=" + encrypted + ", certMetaFile="
+ certMetaFile + ", fileType=" + fileType + ", nameIdConvert="
+ nameIdConvert + "]";
}
}

View File

@@ -1,378 +0,0 @@
package org.maxkey.domain.apps;
import java.util.Arrays;
import org.springframework.web.multipart.MultipartFile;
/**
* @author Crystal.Sea
*
*/
public class SAMLBaseDetails extends Applications {
/**
*
*/
private static final long serialVersionUID = -1091817972127532386L;
private String certIssuer;
private String certSubject;
private String certExpiration;
private byte[] keyStore;
private String entityId;
private String spAcsUrl;
private String issuer;
private String audience;
private String nameidFormat;
private String validityInterval;
/**
* Redirect-Post
* Post-Post
* IdpInit-Post
* Redirect-PostSimpleSign
* Post-PostSimpleSign
* IdpInit-PostSimpleSign
*/
private String binding;
/**
* 0 false
* 1 true
*/
private int encrypted;
/**
* for upload
*/
private MultipartFile certMetaFile;
/**
* metadata or certificate
*/
private String fileType;
/**
* 0 original
* 1 uppercase
* 2 lowercase
*/
private int nameIdConvert;
public static class BINDINGTYPE{
public String Redirect_Post="Redirect-Post";
public String Post_Post="Post-Post";
public String IdpInit_Post="IdpInit-Post";
public String Redirect_PostSimpleSign="Redirect-PostSimpleSign";
public String Post_PostSimpleSign="Post-PostSimpleSign";
public String IdpInit_PostSimpleSign="IdpInit-PostSimpleSign";
}
/**
*
*/
public SAMLBaseDetails() {
super();
}
/**
* @return the certIssuer
*/
public String getCertIssuer() {
return certIssuer;
}
/**
* @param certIssuer the certIssuer to set
*/
public void setCertIssuer(String certIssuer) {
this.certIssuer = certIssuer;
}
/**
* @return the certSubject
*/
public String getCertSubject() {
return certSubject;
}
/**
* @param certSubject the certSubject to set
*/
public void setCertSubject(String certSubject) {
this.certSubject = certSubject;
}
/**
* @return the certExpiration
*/
public String getCertExpiration() {
return certExpiration;
}
/**
* @param certExpiration the certExpiration to set
*/
public void setCertExpiration(String certExpiration) {
this.certExpiration = certExpiration;
}
/**
* @return the keyStore
*/
public byte[] getKeyStore() {
return keyStore;
}
/**
* @param keyStore the keyStore to set
*/
public void setKeyStore(byte[] keyStore) {
this.keyStore = keyStore;
}
/**
* @return the entityId
*/
public String getEntityId() {
return entityId;
}
/**
* @param entityId the entityId to set
*/
public void setEntityId(String entityId) {
this.entityId = entityId;
}
/**
* @return the spAcsUrl
*/
public String getSpAcsUrl() {
return spAcsUrl;
}
/**
* @param spAcsUrl the spAcsUrl to set
*/
public void setSpAcsUrl(String spAcsUrl) {
this.spAcsUrl = spAcsUrl;
}
/**
* @return the issuer
*/
public String getIssuer() {
return issuer;
}
/**
* @param issuer the issuer to set
*/
public void setIssuer(String issuer) {
this.issuer = issuer;
}
/**
* @return the audience
*/
public String getAudience() {
return audience;
}
/**
* @param audience the audience to set
*/
public void setAudience(String audience) {
this.audience = audience;
}
/**
* @return the nameidFormat
*/
public String getNameidFormat() {
return nameidFormat;
}
/**
* @param nameidFormat the nameidFormat to set
*/
public void setNameidFormat(String nameidFormat) {
this.nameidFormat = nameidFormat;
}
/**
* @return the validityInterval
*/
public String getValidityInterval() {
return validityInterval;
}
/**
* @param validityInterval the validityInterval to set
*/
public void setValidityInterval(String validityInterval) {
this.validityInterval = validityInterval;
}
/**
* @return the certMetaFile
*/
public MultipartFile getCertMetaFile() {
return certMetaFile;
}
/**
* @param certMetaFile the certMetaFile to set
*/
public void setCertMetaFile(MultipartFile certMetaFile) {
this.certMetaFile = certMetaFile;
}
/**
* @return the fileType
*/
public String getFileType() {
return fileType;
}
/**
* @param fileType the fileType to set
*/
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getBinding() {
return binding;
}
public void setBinding(String binding) {
this.binding = binding;
}
public int getEncrypted() {
return encrypted;
}
public void setEncrypted(int encrypted) {
this.encrypted = encrypted;
}
public int getNameIdConvert() {
return nameIdConvert;
}
public void setNameIdConvert(int nameIdConvert) {
this.nameIdConvert = nameIdConvert;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "SAMLBaseDetails [certIssuer=" + certIssuer + ", certSubject="
+ certSubject + ", certExpiration=" + certExpiration
+ ", keyStore=" + Arrays.toString(keyStore) + ", entityId="
+ entityId + ", spAcsUrl=" + spAcsUrl + ", issuer=" + issuer
+ ", audience=" + audience + ", nameidFormat=" + nameidFormat
+ ", validityInterval=" + validityInterval + ", binding="
+ binding + ", encrypted=" + encrypted + ", certMetaFile="
+ certMetaFile + ", fileType=" + fileType + ", nameIdConvert="
+ nameIdConvert + "]";
}
}

View File

@@ -3,11 +3,17 @@
*/
package org.maxkey.domain.apps;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author Crystal.Sea
*
*/
@Table(name = "TOKEN_BASED_DETAILS")
public class TokenBasedDetails extends Applications {
/**
@@ -15,23 +21,39 @@ public class TokenBasedDetails extends Applications {
*/
private static final long serialVersionUID = -1717427271305620545L;
@Id
@Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid")
protected String id;
/**
*
*/
@Column
private String redirectUri;
//
@Column
private String cookieName;
@Column
private String algorithm;
@Column
private String algorithmKey;
@Column
private String expires;
//
@Column
private int uid;
@Column
private int username;
@Column
private int email;
@Column
private int windowsAccount;
@Column
private int employeeNumber;
@Column
private int departmentId;
@Column
private int department;

View File

@@ -53,4 +53,6 @@ public class WebConstants {
public static final String CURRENT_SINGLESIGNON_URI = "current_singlesignon_uri";
public static final String AUTHENTICATION = "current_authentication";
}

View File

@@ -147,11 +147,15 @@ public final class WebContext {
}
return true;
}
public static void setAuthentication(Authentication authentication) {
setAttribute(WebConstants.AUTHENTICATION,authentication);
}
public static Authentication getAuthentication(){
UsernamePasswordAuthenticationToken authentication =(UsernamePasswordAuthenticationToken)SecurityContextHolder.getContext().getAuthentication();
return authentication;
}
public static Authentication getAuthentication() {
Authentication authentication = (Authentication)getAttribute(WebConstants.AUTHENTICATION);
return authentication;
}
public static boolean isAuthenticated(){
if (getUserInfo() != null) {