fix format

This commit is contained in:
shimingxy 2020-04-12 11:53:57 +08:00
parent 2fb491b477
commit f3b799e741
88 changed files with 1172 additions and 1256 deletions

View File

@ -3,7 +3,7 @@ package org.maxkey.authn.support.basic;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.util.AuthorizationHeaderUtils; import org.maxkey.util.AuthorizationHeaderUtils;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -99,7 +99,7 @@ public class BasicEntryPoint extends HandlerInterceptorAdapter {
} }
if(!isAuthenticated){ if(!isAuthenticated){
if(WebContext.setAuthentication(username,LOGINTYPE.BASIC,"","","success")){ if(WebContext.setAuthentication(username,ConstantsLoginType.BASIC,"","","success")){
_logger.info("Authentication "+username+" successful ."); _logger.info("Authentication "+username+" successful .");
} }
} }

View File

@ -3,7 +3,7 @@ package org.maxkey.authn.support.httpheader;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -86,7 +86,7 @@ public class HttpHeaderEntryPoint extends HandlerInterceptorAdapter {
} }
if(!isAuthenticated){ if(!isAuthenticated){
if(WebContext.setAuthentication(httpHeaderUsername,LOGINTYPE.HTTPHEADER,"","","success")){ if(WebContext.setAuthentication(httpHeaderUsername,ConstantsLoginType.HTTPHEADER,"","","success")){
_logger.info("Authentication "+httpHeaderUsername+" successful ."); _logger.info("Authentication "+httpHeaderUsername+" successful .");
} }
} }

View File

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.util.DateUtils; import org.maxkey.util.DateUtils;
import org.maxkey.util.JsonUtils; import org.maxkey.util.JsonUtils;
@ -37,7 +37,7 @@ public class RemoteKerberosService implements KerberosService{
DateTime notOnOrAfter=DateUtils.toUtcDate(kerberosToken.getNotOnOrAfter()); DateTime notOnOrAfter=DateUtils.toUtcDate(kerberosToken.getNotOnOrAfter());
_logger.debug("Kerberos Token is After Now "+notOnOrAfter.isAfterNow()); _logger.debug("Kerberos Token is After Now "+notOnOrAfter.isAfterNow());
if(notOnOrAfter.isAfterNow()){ if(notOnOrAfter.isAfterNow()){
return WebContext.setAuthentication(kerberosToken.getPrincipal(),LOGINTYPE.KERBEROS,kerberosUserDomain,"","success"); return WebContext.setAuthentication(kerberosToken.getPrincipal(),ConstantsLoginType.KERBEROS,kerberosUserDomain,"","success");
}else{ }else{
return false; return false;

View File

@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.support.socialsignon.service.SocialSignOnUserToken; import org.maxkey.authn.support.socialsignon.service.SocialSignOnUserToken;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -138,7 +138,7 @@ public class SocialSignOnEndpoint extends AbstractSocialSignOnEndpoint{
_logger.debug("Social Sign On from "+socialSignOnUserToken.getProvider()+" mapping to user "+socialSignOnUserToken.getUsername()); _logger.debug("Social Sign On from "+socialSignOnUserToken.getProvider()+" mapping to user "+socialSignOnUserToken.getUsername());
if(WebContext.setAuthentication(socialSignOnUserToken.getUsername(), LOGINTYPE.SOCIALSIGNON,this.socialSignOnProvider.getProviderName(),"xe00000004","success")){ if(WebContext.setAuthentication(socialSignOnUserToken.getUsername(), ConstantsLoginType.SOCIALSIGNON,this.socialSignOnProvider.getProviderName(),"xe00000004","success")){
//socialSignOnUserToken.setAccessToken(JsonUtils.object2Json(this.accessToken)); //socialSignOnUserToken.setAccessToken(JsonUtils.object2Json(this.accessToken));
socialSignOnUserToken.setSocialUserInfo(accountJsonString); socialSignOnUserToken.setSocialUserInfo(accountJsonString);
//socialSignOnUserToken.setExAttribute(JsonUtils.object2Json(accessToken.getResponseObject())); //socialSignOnUserToken.setExAttribute(JsonUtils.object2Json(accessToken.getResponseObject()));

View File

@ -2,7 +2,7 @@ package org.maxkey.authn.support.wsfederation;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.util.StringUtils; import org.maxkey.util.StringUtils;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
import org.opensaml.saml1.core.impl.AssertionImpl; import org.opensaml.saml1.core.impl.AssertionImpl;
@ -42,7 +42,7 @@ public class WsFederationServiceImpl implements WsFederationService{
return WebContext.setAuthentication( return WebContext.setAuthentication(
wsFederationCredential.getAttributes().get("").toString(), wsFederationCredential.getAttributes().get("").toString(),
LOGINTYPE.WSFEDERATION, ConstantsLoginType.WSFEDERATION,
"","","success"); "","","success");
} else { } else {

View File

@ -3,7 +3,7 @@ package org.maxkey.authn;
import org.maxkey.authn.realm.AbstractAuthenticationRealm; import org.maxkey.authn.realm.AbstractAuthenticationRealm;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService; import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.crypto.password.opt.AbstractOptAuthn; import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -93,7 +93,7 @@ public abstract class AbstractAuthenticationProvider {
_logger.debug("Login Success Session {}.", WebContext.getSession().getId()); _logger.debug("Login Success Session {}.", WebContext.getSession().getId());
authenticationRealm.insertLoginHistory( authenticationRealm.insertLoginHistory(
userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "success"); userInfo, ConstantsLoginType.LOCAL, "", "xe00000004", "success");
// 认证设置 // 认证设置
WebContext.setAuthentication(authentication); WebContext.setAuthentication(authentication);
@ -268,7 +268,7 @@ public abstract class AbstractAuthenticationProvider {
loginUser.setId(loginUser.generateId()); loginUser.setId(loginUser.generateId());
loginUser.setDisplayName("not exist"); loginUser.setDisplayName("not exist");
loginUser.setLoginCount(0); loginUser.setLoginCount(0);
authenticationRealm.insertLoginHistory(loginUser, LOGINTYPE.LOCAL, "", authenticationRealm.insertLoginHistory(loginUser, ConstantsLoginType.LOCAL, "",
WebContext.getI18nValue("login.error.username"), "user not exist"); WebContext.getI18nValue("login.error.username"), "user not exist");
throw new BadCredentialsException(WebContext.getI18nValue("login.error.username")); throw new BadCredentialsException(WebContext.getI18nValue("login.error.username"));
} }

View File

@ -11,9 +11,9 @@ import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService; import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.constants.PASSWORDSETTYPE; import org.maxkey.constants.ConstantsPasswordSetType;
import org.maxkey.constants.STATUS; import org.maxkey.constants.ConstantsStatus;
import org.maxkey.domain.Groups; import org.maxkey.domain.Groups;
import org.maxkey.domain.PasswordPolicy; import org.maxkey.domain.PasswordPolicy;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -108,13 +108,13 @@ public abstract class AbstractAuthenticationRealm {
WebContext.getI18nValue("login.error.attempts") + " " + userInfo.getBadPasswordCount()); WebContext.getI18nValue("login.error.attempts") + " " + userInfo.getBadPasswordCount());
} }
if (userInfo.getPasswordSetType() != PASSWORDSETTYPE.PASSWORD_NORMAL) { if (userInfo.getPasswordSetType() != ConstantsPasswordSetType.PASSWORD_NORMAL) {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
userInfo.getPasswordSetType()); userInfo.getPasswordSetType());
return true; return true;
} else { } else {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
PASSWORDSETTYPE.PASSWORD_NORMAL); ConstantsPasswordSetType.PASSWORD_NORMAL);
} }
/* /*
@ -134,7 +134,7 @@ public abstract class AbstractAuthenticationRealm {
_logger.debug("validate result " + (intDuration <= getPasswordPolicy().getExpiration())); _logger.debug("validate result " + (intDuration <= getPasswordPolicy().getExpiration()));
if (intDuration > getPasswordPolicy().getExpiration()) { if (intDuration > getPasswordPolicy().getExpiration()) {
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,
PASSWORDSETTYPE.PASSWORD_EXPIRED); ConstantsPasswordSetType.PASSWORD_EXPIRED);
} }
} }
@ -171,7 +171,7 @@ public abstract class AbstractAuthenticationRealm {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT, jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT,
new Object[] { STATUS.LOCK, new Date(), userInfo.getId() }, new Object[] { ConstantsStatus.LOCK, new Date(), userInfo.getId() },
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -188,7 +188,7 @@ public abstract class AbstractAuthenticationRealm {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(UNLOCK_USER_UPDATE_STATEMENT, jdbcTemplate.update(UNLOCK_USER_UPDATE_STATEMENT,
new Object[] { STATUS.ACTIVE, new Date(), userInfo.getId() }, new Object[] { ConstantsStatus.ACTIVE, new Date(), userInfo.getId() },
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -205,7 +205,7 @@ public abstract class AbstractAuthenticationRealm {
try { try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(BADPASSWORDCOUNT_RESET_UPDATE_STATEMENT, jdbcTemplate.update(BADPASSWORDCOUNT_RESET_UPDATE_STATEMENT,
new Object[] { 0, STATUS.ACTIVE, new Date(), userInfo.getId() }, new Object[] { 0, ConstantsStatus.ACTIVE, new Date(), userInfo.getId() },
new int[] { Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR });
} }
} catch (Exception e) { } catch (Exception e) {
@ -227,7 +227,7 @@ public abstract class AbstractAuthenticationRealm {
jdbcTemplate.update(BADPASSWORDCOUNT_UPDATE_STATEMENT, jdbcTemplate.update(BADPASSWORDCOUNT_UPDATE_STATEMENT,
new Object[] { badPasswordCount, new Date(), userInfo.getId() }, new Object[] { badPasswordCount, new Date(), userInfo.getId() },
new int[] { Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR }); new int[] { Types.INTEGER, Types.TIMESTAMP, Types.VARCHAR });
insertLoginHistory(userInfo, LOGINTYPE.LOCAL, "", "xe00000004", "password error"); insertLoginHistory(userInfo, ConstantsLoginType.LOCAL, "", "xe00000004", "password error");
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -1,19 +1,5 @@
package org.maxkey.authn.support.jwt; package org.maxkey.authn.support.jwt;
import java.util.Date;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import org.joda.time.DateTime;
import org.maxkey.config.ApplicationConfig;
import org.maxkey.config.oidc.OIDCProviderMetadataDetails;
import org.maxkey.constants.LOGINTYPE;
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
import org.maxkey.web.WebContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSHeader; import com.nimbusds.jose.JWSHeader;
@ -23,10 +9,21 @@ import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.PlainJWT; import com.nimbusds.jwt.PlainJWT;
import com.nimbusds.jwt.SignedJWT; import com.nimbusds.jwt.SignedJWT;
import java.util.Date;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import org.joda.time.DateTime;
import org.maxkey.config.ApplicationConfig;
import org.maxkey.config.oidc.OIDCProviderMetadataDetails;
import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
import org.maxkey.web.WebContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JwtLoginService { public class JwtLoginService {
private static final Logger _logger = LoggerFactory private static final Logger _logger = LoggerFactory.getLogger(JwtLoginService.class);
.getLogger(JwtLoginService.class);
protected ApplicationConfig applicationConfig; protected ApplicationConfig applicationConfig;
@ -44,10 +41,8 @@ public class JwtLoginService {
JWTClaimsSet jwtClaimsSet = null; JWTClaimsSet jwtClaimsSet = null;
try { try {
RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier( RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier(((RSAKey) jwtSignerValidationService.getAllPublicKeys()
((RSAKey) jwtSignerValidationService.getAllPublicKeys() .get(jwtSignerValidationService.getDefaultSignerKeyId())).toRSAPublicKey());
.get(jwtSignerValidationService
.getDefaultSignerKeyId())).toRSAPublicKey());
signedJWT = SignedJWT.parse(jwt); signedJWT = SignedJWT.parse(jwt);
if (signedJWT.verify(rsaSSAVerifier)) { if (signedJWT.verify(rsaSSAVerifier)) {
@ -62,9 +57,7 @@ public class JwtLoginService {
_logger.debug("jwtClaimsSet Issuer " + jwtClaimsSet.getIssuer()); _logger.debug("jwtClaimsSet Issuer " + jwtClaimsSet.getIssuer());
_logger.debug("Metadata Issuer " + jwtProviderMetadata.getIssuer()); _logger.debug("Metadata Issuer " + jwtProviderMetadata.getIssuer());
if (loginResult if (loginResult && jwtClaimsSet.getIssuer().equals(jwtProviderMetadata.getIssuer())) {
&& jwtClaimsSet.getIssuer().equals(
jwtProviderMetadata.getIssuer())) {
loginResult = true; loginResult = true;
_logger.debug("Issuer equals "); _logger.debug("Issuer equals ");
} else { } else {
@ -82,10 +75,8 @@ public class JwtLoginService {
DateTime now = new DateTime(); DateTime now = new DateTime();
if (loginResult if (loginResult && now.isBefore(jwtClaimsSet.getExpirationTime().getTime())) {
&& now.isBefore(jwtClaimsSet.getExpirationTime().getTime())) { if (WebContext.setAuthentication(username, ConstantsLoginType.JWT, "", "", "success")) {
if (WebContext.setAuthentication(username, LOGINTYPE.JWT, "",
"", "success")) {
return true; return true;
} }
} }
@ -107,20 +98,15 @@ public class JwtLoginService {
DateTime currentDateTime = DateTime.now(); DateTime currentDateTime = DateTime.now();
Date expirationTime = currentDateTime.plusMinutes(5).toDate(); Date expirationTime = currentDateTime.plusMinutes(5).toDate();
_logger.debug("expiration Time : " + expirationTime); _logger.debug("expiration Time : " + expirationTime);
JWTClaimsSet jwtClaims = new JWTClaimsSet.Builder() JWTClaimsSet jwtClaims = new JWTClaimsSet.Builder().subject(WebContext.getSession().getId())
.subject(WebContext.getSession().getId()) .expirationTime(expirationTime).issuer(jwtProviderMetadata.getIssuer())
.expirationTime(expirationTime) .issueTime(currentDateTime.toDate()).jwtID(UUID.randomUUID().toString()).build();
.issuer(jwtProviderMetadata.getIssuer())
.issueTime(currentDateTime.toDate())
.jwtID(UUID.randomUUID().toString())
.build();
JWT jwtToken = new PlainJWT(jwtClaims); JWT jwtToken = new PlainJWT(jwtClaims);
_logger.info("jwt Claims : " + jwtClaims.toString()); _logger.info("jwt Claims : " + jwtClaims.toString());
JWSAlgorithm signingAlg = jwtSignerValidationService JWSAlgorithm signingAlg = jwtSignerValidationService.getDefaultSigningAlgorithm();
.getDefaultSigningAlgorithm();
jwtToken = new SignedJWT(new JWSHeader(signingAlg), jwtClaims); jwtToken = new SignedJWT(new JWSHeader(signingAlg), jwtClaims);
// sign it with the server's key // sign it with the server's key
@ -138,10 +124,8 @@ public class JwtLoginService {
JWTClaimsSet jwtClaimsSet = null; JWTClaimsSet jwtClaimsSet = null;
try { try {
RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier( RSASSAVerifier rsaSSAVerifier = new RSASSAVerifier(((RSAKey) jwtSignerValidationService.getAllPublicKeys()
((RSAKey) jwtSignerValidationService.getAllPublicKeys() .get(jwtSignerValidationService.getDefaultSignerKeyId())).toRSAPublicKey());
.get(jwtSignerValidationService
.getDefaultSignerKeyId())).toRSAPublicKey());
signedJWT = SignedJWT.parse(jwt); signedJWT = SignedJWT.parse(jwt);
if (signedJWT.verify(rsaSSAVerifier)) { if (signedJWT.verify(rsaSSAVerifier)) {
@ -158,9 +142,7 @@ public class JwtLoginService {
_logger.debug("jwtClaimsSet Issuer " + jwtClaimsSet.getIssuer()); _logger.debug("jwtClaimsSet Issuer " + jwtClaimsSet.getIssuer());
_logger.debug("Metadata Issuer " + jwtProviderMetadata.getIssuer()); _logger.debug("Metadata Issuer " + jwtProviderMetadata.getIssuer());
if (loginResult if (loginResult && jwtClaimsSet.getIssuer().equals(jwtProviderMetadata.getIssuer())) {
&& jwtClaimsSet.getIssuer().equals(
jwtProviderMetadata.getIssuer())) {
loginResult = true; loginResult = true;
_logger.debug("Issuer equals "); _logger.debug("Issuer equals ");
} else { } else {
@ -170,11 +152,10 @@ public class JwtLoginService {
DateTime now = new DateTime(); DateTime now = new DateTime();
if (loginResult if (loginResult && now.isBefore(jwtClaimsSet.getExpirationTime().getTime())) {
&& now.isBefore(jwtClaimsSet.getExpirationTime().getTime())) {
_logger.debug("ExpirationTime Validation " + now.isBefore(jwtClaimsSet.getExpirationTime().getTime())); _logger.debug("ExpirationTime Validation " + now.isBefore(jwtClaimsSet.getExpirationTime().getTime()));
loginResult = true; loginResult = true;
}else{ } else {
return false; return false;
} }
} catch (java.text.ParseException e) { } catch (java.text.ParseException e) {
@ -192,13 +173,11 @@ public class JwtLoginService {
this.applicationConfig = applicationConfig; this.applicationConfig = applicationConfig;
} }
public void setJwtProviderMetadata( public void setJwtProviderMetadata(OIDCProviderMetadataDetails jwtProviderMetadata) {
OIDCProviderMetadataDetails jwtProviderMetadata) {
this.jwtProviderMetadata = jwtProviderMetadata; this.jwtProviderMetadata = jwtProviderMetadata;
} }
public void setJwtSignerValidationService( public void setJwtSignerValidationService(DefaultJwtSigningAndValidationService jwtSignerValidationService) {
DefaultJwtSigningAndValidationService jwtSignerValidationService) {
this.jwtSignerValidationService = jwtSignerValidationService; this.jwtSignerValidationService = jwtSignerValidationService;
} }

View File

@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.crypto.Base64Utils; import org.maxkey.crypto.Base64Utils;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.util.JsonUtils; import org.maxkey.util.JsonUtils;
@ -96,7 +96,7 @@ public abstract class AbstractRemeberMeService {
if (now.isBefore(expiryDate)) { if (now.isBefore(expiryDate)) {
if (WebContext.setAuthentication( if (WebContext.setAuthentication(
storeRemeberMe.getUsername(), storeRemeberMe.getUsername(),
LOGINTYPE.REMEBER_ME, ConstantsLoginType.REMEBER_ME,
"", "",
"", "",
"success") "success")

View File

@ -7,10 +7,7 @@ public class RemeberMe implements Serializable {
private static final long serialVersionUID = 8010496585233991785L; private static final long serialVersionUID = 8010496585233991785L;
/**
* The number of seconds in one year (= 60 * 60 * 24 * 365).
*/
public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day
@ -18,7 +15,14 @@ public class RemeberMe implements Serializable {
public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week
public static final Integer TWO_MONTH = ONE_DAY * 30; // 1 month public static final Integer ONE_MONTH = ONE_DAY * 30; // 1 month
public static final Integer TWO_MONTH = ONE_DAY * 60; // 2 month
/**
* The number of seconds in one year (= 60 * 60 * 24 * 365).
*/
public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
String id; String id;

View File

@ -1,44 +0,0 @@
package org.maxkey.constants;
/**
* Define int for boolean
* 0 false
* 1 true
*
* @author Crystal.Sea
*
*/
public class BOOLEAN {
public final static int FALSE = 0;
public final static int TRUE = 1;
private int value = FALSE;
public BOOLEAN() {
}
public int getValue() {
return value;
}
public boolean isValue() {
return TRUE==value;
}
public void setValue(int value) {
this.value = value;
}
public static boolean isTrue(int value){
return TRUE==value;
}
public static boolean isFalse(int value){
return FALSE==value;
}
}

View File

@ -0,0 +1,41 @@
package org.maxkey.constants;
/**
* Define int for boolean 0 false 1 true.
*
* @author Crystal.Sea
*
*/
public class Boolean {
public static final int FALSE = 0;
public static final int TRUE = 1;
private int value = FALSE;
public Boolean() {
}
public int getValue() {
return value;
}
public boolean isValue() {
return TRUE == value;
}
public void setValue(int value) {
this.value = value;
}
public static boolean isTrue(int value) {
return TRUE == value;
}
public static boolean isFalse(int value) {
return FALSE == value;
}
}

View File

@ -0,0 +1,12 @@
package org.maxkey.constants;
public class ConstantsEntryType {
public static int USERINFO_TYPE = 1;
public static int ORG_TYPE = 2;
public static int GROUP_TYPE = 3;
public static int PASSWORD_TYPE = 4;
public static int RESOURCES_TYPE = 5;
public static int PERMISSIONS_TYPE = 6;
}

View File

@ -0,0 +1,20 @@
package org.maxkey.constants;
public class ConstantsLoginType {
public static final String LOCAL = "Local Login";
public static final String BASIC = "Basic";
public static final String SOCIALSIGNON = "Social Sign On";
public static final String REMEBER_ME = "RemeberMe";
public static final String DESKTOP = "Desktop";
public static final String KERBEROS = "Kerberos";
public static final String SAMLTRUST = "SAML v2.0 Trust";
public static final String MSADTRUST = "MS AD Trust";
public static final String CAS = "CAS";
public static final String WSFEDERATION = "WsFederation";
public static final String JWT = "Jwt";
public static final String HTTPHEADER = "HttpHeader";
}

View File

@ -0,0 +1,19 @@
package org.maxkey.constants;
public final class ConstantsOperateAction {
public static final int CREATE_ACTION = 1;
public static final int DELETE_ACTION = 2;
public static final int UPDATE_ACTION = 3;
public static final int CHANGE_PASSWORD_ACTION = 4;
public static final int ADD_MEMBER_ACTION = 5;
public static final int DELETE_MEMBER_ACTION = 6;
public static final int VIEW_ACTION = 7;
}

View File

@ -0,0 +1,14 @@
package org.maxkey.constants;
public final class ConstantsOperateMessage {
public static final String INSERT_SUCCESS = "message.action.insert.success";
public static final String INSERT_ERROR = "message.action.insert.error";
public static final String UPDATE_SUCCESS = "message.action.update.success";
public static final String UPDATE_ERROR = "message.action.update.error";
public static final String DELETE_SUCCESS = "message.action.delete.success";
public static final String DELETE_ERROR = "message.action.delete.error";
}

View File

@ -0,0 +1,18 @@
package org.maxkey.constants;
/**
* PASSWORDSETTYPE.
* @author Crystal.Sea
*
*/
public final class ConstantsPasswordSetType {
public static final int PASSWORD_NORMAL = 0;
public static final int INITIAL_PASSWORD = 1;
public static final int MANAGER_CHANGED_PASSWORD = 2;
public static final int PASSWORD_EXPIRED = 3;
}

View File

@ -0,0 +1,10 @@
package org.maxkey.constants;
public final class ConstantsPlatformRole {
public static final String PLATFORM_ADMIN = "PLATFORM_ADMIN";
public static final String TANANT_ADMIN = "TANANT_ADMIN";
public static final String ORDINARY_USER = "ORDINARY_USER";
}

View File

@ -0,0 +1,29 @@
package org.maxkey.constants;
/**
* PROTOCOLS.
* @author Crystal.Sea
*
*/
public final class ConstantsProtocols {
public static final String DESKTOP = "Desktop";
public static final String BASIC = "Basic";
public static final String EXTEND_API = "Extend_API";
public static final String FORMBASED = "Form_Based";
public static final String TOKENBASED = "Token_Based";
// OAuth
public static final String OAUTH20 = "OAuth_v2.0";
// SAML
public static final String SAML20 = "SAML_v2.0";
public static final String OPEN_ID_CONNECT = "OpenID_Connect";
public static final String CAS = "CAS";
}

View File

@ -0,0 +1,120 @@
package org.maxkey.constants;
public final class ConstantsServiceMessage {
public static final class EMPLOYEES {
public static final String SERVICE_NAME = "employees";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XE00000007 = "XE00000007";
public static final String XE00000008 = "XE00000008";
public static final String XW00000001 = "XW00000001";
public static final String XW00000002 = "XW00000002";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
}
public static final class ENTERPRISES {
public static final String SERVICE_NAME = "enterprises";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XE00000007 = "XE00000007";
public static final String XE00000008 = "XE00000008";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XS00000004 = "XS00000004";
}
public static final class RETRIEVEPASSWORD {
public static final String SERVICE_NAME = "retrievepassword";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
}
public static final class USERCENTER {
public static final String SERVICE_NAME = "usercenter";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
}
public static final class APPLICATIONS {
public static final String SERVICE_NAME = "applications";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XS00000004 = "XS00000004";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
}
public static final class APPROLES {
public static final String SERVICE_NAME = "approles";
public static final String XE00000002 = "XE00000002";
public static final String XS00000002 = "XS00000002";
public static final String XE00000001 = "XE00000001";
public static final String XS00000001 = "XS00000001";
public static final String XE00000003 = "XE00000003";
public static final String XS00000003 = "XS00000003";
public static final String XE00000004 = "XE00000004";
public static final String XS00000004 = "XS00000004";
public static final String XS00000005 = "XS00000005";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XS00000006 = "XS00000006";
public static final String XE00000007 = "XE00000007";
public static final String XS00000007 = "XS00000007";
public static final String XS00000008 = "XS00000008";
public static final String XE00000008 = "XE00000008";
public static final String XE00000009 = "XE00000009";
public static final String XS00000009 = "XS00000009";
}
public static final class APIUSERS {
public static final String SERVICE_NAME = "apiusers";
public static final String XS00000003 = "XS00000003";
public static final String XE00000003 = "XE00000003";
public static final String XW00000001 = "XW00000001";
public static final String XW00000002 = "XW00000002";
public static final String XS00000001 = "XS00000001";
public static final String XE00000001 = "XE00000001";
}
public static final class PASSWORDPOLICY {
public static final String SERVICE_NAME = "passwordpolicy";
public static final String XW00000002 = "XW00000002";
public static final String XW00000001 = "XW00000001";
public static final String XW00000003 = "XW00000003";
public static final String XW00000004 = "XW00000004";
public static final String XW00000005 = "XW00000005";
public static final String XW00000006 = "XW00000006";
public static final String XW00000007 = "XW00000007";
public static final String XW00000008 = "XW00000008";
}
}

View File

@ -0,0 +1,30 @@
package org.maxkey.constants;
public final class ConstantsStatus {
public static final int ACTIVE = 1;
public static final int INACTIVE = 2;
public static final int ENABLED = 3;
public static final int DISABLED = 4;
public static final int LOCK = 5;
public static final int UNLOCK = 6;
public static final int INVALID = 7;
public static final int EXPIRED = 8;
public static final int DELETE = 9;
public static final int VALIDATED = 10;
public static final int START = 11;
public static final int STOP = 12;
public static final int APPROVED = 13;
}

View File

@ -0,0 +1,23 @@
package org.maxkey.constants;
public final class ConstantsTimeInterval {
public static final Integer ONE_MINUTE = 60; // 1 minutes
public static final Integer ONE_HOUR = 60 * 60; // 1 hour
public static final Integer ONE_DAY = 60 * 60 * 24; // 1 day
public static final Integer ONE_WEEK = ONE_DAY * 7; // 1 week
public static final Integer TWO_WEEK = ONE_DAY * 14; // 2 week
public static final Integer ONE_MONTH = ONE_DAY * 30; // 1 month
public static final Integer TWO_MONTH = ONE_DAY * 60; // 2 month
/**
* The number of seconds in one year (= 60 * 60 * 24 * 365).
*/
public static final Integer ONE_YEAR = 60 * 60 * 24 * 365;
}

View File

@ -1,12 +0,0 @@
package org.maxkey.constants;
public class ENTRY_TYPE{
public static int USERINFO_TYPE = 1;
public static int ORG_TYPE = 2;
public static int GROUP_TYPE = 3;
public static int PASSWORD_TYPE = 4;
public static int RESOURCES_TYPE = 5;
public static int PERMISSIONS_TYPE = 6;
}

View File

@ -1,21 +0,0 @@
package org.maxkey.constants;
public class LOGINTYPE {
public static final String LOCAL = "Local Login";
public static final String BASIC = "Basic";
public static final String SOCIALSIGNON = "Social Sign On";
public static final String REMEBER_ME = "RemeberMe";
public static final String DESKTOP = "Desktop";
public static final String KERBEROS = "Kerberos";
public static final String SAMLTRUST = "SAML v2.0 Trust";
public static final String MSADTRUST = "MS AD Trust";
public static final String CAS = "CAS";
public static final String WSFEDERATION = "WsFederation";
public static final String JWT = "Jwt";
public static final String HTTPHEADER = "HttpHeader";
}

View File

@ -1,19 +0,0 @@
package org.maxkey.constants;
public final class OPERATEACTION {
public static final int CREATE_ACTION = 1;
public static final int DELETE_ACTION = 2;
public static final int UPDATE_ACTION = 3;
public static final int CHANGE_PASSWORD_ACTION = 4;
public static final int ADD_MEMBER_ACTION = 5;
public static final int DELETE_MEMBER_ACTION = 6;
public static final int VIEW_ACTION = 7;
}

View File

@ -1,16 +0,0 @@
package org.maxkey.constants;
public final class OPERATEMESSAGE {
public static final String INSERT_SUCCESS="message.action.insert.success";
public static final String INSERT_ERROR="message.action.insert.error";
public static final String UPDATE_SUCCESS="message.action.update.success";
public static final String UPDATE_ERROR="message.action.update.error";
public static final String DELETE_SUCCESS="message.action.delete.success";
public static final String DELETE_ERROR="message.action.delete.error";
}

View File

@ -1,20 +0,0 @@
/**
*
*/
package org.maxkey.constants;
/**
* @author Crystal.Sea
*
*/
public final class PASSWORDSETTYPE {
public static final int PASSWORD_NORMAL = 0;
public static final int INITIAL_PASSWORD = 1;
public static final int MANAGER_CHANGED_PASSWORD = 2;
public static final int PASSWORD_EXPIRED = 3;
}

View File

@ -1,10 +0,0 @@
package org.maxkey.constants;
public final class PLATFORMROLE {
public static final String PLATFORM_ADMIN = "PLATFORM_ADMIN";
public static final String TANANT_ADMIN = "TANANT_ADMIN";
public static final String ORDINARY_USER = "ORDINARY_USER";
}

View File

@ -1,38 +0,0 @@
/**
*
*/
package org.maxkey.constants;
/**
* @author Crystal.Sea
*
*/
public final class PROTOCOLS {
public static final String DESKTOP = "Desktop";
public static final String BASIC = "Basic";
public static final String EXTEND_API = "Extend_API";
public static final String FORMBASED = "Form_Based";
public static final String TOKENBASED = "Token_Based";
//OAuth
public static final String OAUTH20 = "OAuth_v2.0";
//SAML
public static final String SAML20 = "SAML_v2.0";
public static final String OPEN_ID_CONNECT = "OpenID_Connect";
public static final String CAS = "CAS";
/**
*
*/
public PROTOCOLS() {
}
}

View File

@ -1,121 +0,0 @@
package org.maxkey.constants;
public final class SERVICEMESSAGE {
public static final class EMPLOYEES {
public static final String SERVICE_NAME = "employees";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XE00000007 = "XE00000007";
public static final String XE00000008 = "XE00000008";
public static final String XW00000001 = "XW00000001";
public static final String XW00000002 = "XW00000002";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
}
public static final class ENTERPRISES{
public static final String SERVICE_NAME = "enterprises";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XE00000007 = "XE00000007";
public static final String XE00000008 = "XE00000008";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XS00000004 = "XS00000004";
}
public static final class RETRIEVEPASSWORD{
public static final String SERVICE_NAME = "retrievepassword";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
}
public static final class USERCENTER {
public static final String SERVICE_NAME = "usercenter";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
}
public static final class APPLICATIONS {
public static final String SERVICE_NAME="applications";
public static final String XS00000001 = "XS00000001";
public static final String XS00000002 = "XS00000002";
public static final String XS00000003 = "XS00000003";
public static final String XS00000004 = "XS00000004";
public static final String XE00000001 = "XE00000001";
public static final String XE00000002 = "XE00000002";
public static final String XE00000003 = "XE00000003";
public static final String XE00000004 = "XE00000004";
}
public static final class APPROLES{
public static final String SERVICE_NAME="approles";
public static final String XE00000002 = "XE00000002";
public static final String XS00000002 = "XS00000002";
public static final String XE00000001 = "XE00000001";
public static final String XS00000001 = "XS00000001";
public static final String XE00000003 = "XE00000003";
public static final String XS00000003 = "XS00000003";
public static final String XE00000004 = "XE00000004";
public static final String XS00000004 = "XS00000004";
public static final String XS00000005 = "XS00000005";
public static final String XE00000005 = "XE00000005";
public static final String XE00000006 = "XE00000006";
public static final String XS00000006 = "XS00000006";
public static final String XE00000007 = "XE00000007";
public static final String XS00000007 = "XS00000007";
public static final String XS00000008 = "XS00000008";
public static final String XE00000008 = "XE00000008";
public static final String XE00000009 = "XE00000009";
public static final String XS00000009 = "XS00000009";
}
public static final class APIUSERS{
public static final String SERVICE_NAME="apiusers";
public static final String XS00000003 = "XS00000003";
public static final String XE00000003 = "XE00000003";
public static final String XW00000001 = "XW00000001";
public static final String XW00000002 = "XW00000002";
public static final String XS00000001 = "XS00000001";
public static final String XE00000001 = "XE00000001";
}
public static final class PASSWORDPOLICY{
public static final String SERVICE_NAME="passwordpolicy";
public static final String XW00000002 = "XW00000002";
public static final String XW00000001 = "XW00000001";
public static final String XW00000003 = "XW00000003";
public static final String XW00000004 = "XW00000004";
public static final String XW00000005 = "XW00000005";
public static final String XW00000006 = "XW00000006";
public static final String XW00000007 = "XW00000007";
public static final String XW00000008 = "XW00000008";
}
}

View File

@ -1,30 +0,0 @@
package org.maxkey.constants;
public final class STATUS {
public static final int ACTIVE = 1;
public static final int INACTIVE = 2;
public static final int ENABLED = 3;
public static final int DISABLED = 4;
public static final int LOCK = 5;
public static final int UNLOCK = 6;
public static final int INVALID = 7;
public static final int EXPIRED = 8;
public static final int DELETE = 9;
public static final int VALIDATED = 10;
public static final int START = 11;
public static final int STOP = 12;
public static final int APPROVED = 13;
}

View File

@ -1,19 +1,9 @@
package org.maxkey.crypto.password.opt; package org.maxkey.crypto.password.opt;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Date;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.format.DateTimeFormat;
import org.maxkey.constants.STATUS;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.util.StringGenerator; import org.maxkey.util.StringGenerator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
/** /**
* AbstractOTPAuthn. * AbstractOTPAuthn.
@ -31,8 +21,6 @@ public abstract class AbstractOptAuthn {
StringGenerator stringGenerator; StringGenerator stringGenerator;
private final JdbcTemplate jdbcTemplate;
public static final class OptTypes { public static final class OptTypes {
// 手机 // 手机
public static int MOBILE = 2; public static int MOBILE = 2;
@ -51,19 +39,6 @@ public abstract class AbstractOptAuthn {
} }
private static final String DEFAULT_DEFAULT_INSERT_STATEMENT =
"INSERT INTO ONE_TIME_PASSWORD(ID ,OPTTYPE,USERNAME,TOKEN,RECEIVER,CREATETIME,STATUS)"
+ " VALUES(?,?,?,?,?,?," + STATUS.ACTIVE + ")";
private static final String DEFAULT_DEFAULT_SELECT_STATEMENT =
"SELECT ID ,OPTTYPE,USERNAME,TOKEN,RECEIVER,CREATETIME FROM ONE_TIME_PASSWORD"
+ " WHERE STATUS =" + STATUS.ACTIVE
+ " AND USERNAME = ? AND TOKEN = ? AND OPTTYPE = ?";
private static final String DEFAULT_DEFAULT_DELETE_STATEMENT =
"UPDATE ONE_TIME_PASSWORD SET STATUS ="
+ STATUS.DELETE + " WHERE USERNAME = ? AND TOKEN = ? AND OPTTYPE = ?";
public abstract boolean produce(UserInfo userInfo); public abstract boolean produce(UserInfo userInfo);
public abstract boolean validate(UserInfo userInfo, String token); public abstract boolean validate(UserInfo userInfo, String token);
@ -81,62 +56,9 @@ public abstract class AbstractOptAuthn {
if (stringGenerator == null) { if (stringGenerator == null) {
stringGenerator = new StringGenerator(StringGenerator.DEFAULT_CODE_NUMBER, digits); stringGenerator = new StringGenerator(StringGenerator.DEFAULT_CODE_NUMBER, digits);
} }
return stringGenerator.randomGenerate(); String token = stringGenerator.randomGenerate();
} logger.debug("Generator token " + token);
return token;
public AbstractOptAuthn(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
protected void insertDataBase(UserInfo userInfo, String token, String receiver, int type) {
jdbcTemplate.update(DEFAULT_DEFAULT_INSERT_STATEMENT,
new Object[] {
java.util.UUID.randomUUID(),
type,
userInfo.getUsername(),
token,
receiver,
new Date()
},
new int[] { Types.VARCHAR, Types.INTEGER,
Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR,Types.TIMESTAMP
}
);
}
/**
* validateDataBase.
* @param userInfo UserInfo
* @param token String
* @param type int
* @return
*/
public boolean validateDataBase(UserInfo userInfo, String token, int type) {
OneTimePassword oneTimePassword = jdbcTemplate.queryForObject(
DEFAULT_DEFAULT_SELECT_STATEMENT,
new OneTimePasswordRowMapper(), userInfo.getUsername(), token, type);
if (oneTimePassword != null) {
jdbcTemplate.update(
DEFAULT_DEFAULT_DELETE_STATEMENT,
new Object[] { userInfo.getUsername(), token, type },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.INTEGER }
);
DateTime currentdateTime = new DateTime();
DateTime oneTimePwdData = DateTime.parse(oneTimePassword.getCreateTime(),
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
Duration duration = new Duration(oneTimePwdData, currentdateTime);
int intDuration = Integer.parseInt(duration.getStandardSeconds() + "");
logger.debug("validate duration " + intDuration);
logger.debug("validate result " + (intDuration <= interval));
if (intDuration <= interval) {
return true;
}
}
return false;
} }
/** /**
@ -187,22 +109,5 @@ public abstract class AbstractOptAuthn {
this.crypto = crypto; this.crypto = crypto;
} }
public class OneTimePasswordRowMapper implements RowMapper<OneTimePassword> {
/**
*ResultSet.
*/
public OneTimePassword mapRow(ResultSet rs, int rowNum) throws SQLException {
OneTimePassword oneTimePassword = new OneTimePassword();
oneTimePassword.setId(rs.getString("ID"));
oneTimePassword.setType(rs.getInt("OPTTYPE"));
oneTimePassword.setUsername(rs.getString("USERNAME"));
oneTimePassword.setToken(rs.getString("TOKEN"));
oneTimePassword.setUsername(rs.getString("USERNAME"));
oneTimePassword.setReceiver(rs.getString("RECEIVER"));
oneTimePassword.setCreateTime(rs.getString("CREATETIME"));
return oneTimePassword;
}
}
} }

View File

@ -2,7 +2,6 @@ package org.maxkey.crypto.password.opt.impl;
import org.maxkey.crypto.password.opt.AbstractOptAuthn; import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.springframework.jdbc.core.JdbcTemplate;
/** /**
* Chip Authentication Program EMV stands for Europay, MasterCard and Visa, a * Chip Authentication Program EMV stands for Europay, MasterCard and Visa, a
@ -16,10 +15,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
*/ */
public class CapOtpAuthn extends AbstractOptAuthn { public class CapOtpAuthn extends AbstractOptAuthn {
public CapOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -7,14 +7,10 @@ import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
public class CounterBasedOtpAuthn extends AbstractOptAuthn { public class CounterBasedOtpAuthn extends AbstractOptAuthn {
private static final Logger _logger = LoggerFactory.getLogger(CounterBasedOtpAuthn.class); private static final Logger _logger = LoggerFactory.getLogger(CounterBasedOtpAuthn.class);
public CounterBasedOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {

View File

@ -8,7 +8,6 @@ import org.maxkey.crypto.password.opt.algorithm.HOTP;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
public class HotpOtpAuthn extends AbstractOptAuthn { public class HotpOtpAuthn extends AbstractOptAuthn {
private static final Logger _logger = LoggerFactory.getLogger(HotpOtpAuthn.class); private static final Logger _logger = LoggerFactory.getLogger(HotpOtpAuthn.class);
@ -16,10 +15,6 @@ public class HotpOtpAuthn extends AbstractOptAuthn {
boolean addChecksum; boolean addChecksum;
int truncation = -1; int truncation = -1;
public HotpOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
return true; return true;

View File

@ -8,16 +8,11 @@ import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
public class MailOtpAuthn extends AbstractOptAuthn { public class MailOtpAuthn extends AbstractOptAuthn {
private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class); private static final Logger _logger = LoggerFactory.getLogger(MailOtpAuthn.class);
EmailConfig emailConfig; EmailConfig emailConfig;
public MailOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
try { try {
@ -37,7 +32,7 @@ public class MailOtpAuthn extends AbstractOptAuthn {
_logger.debug( _logger.debug(
"token " + token + " send to user +" + userInfo.getUsername() "token " + token + " send to user +" + userInfo.getUsername()
+ ", email " + userInfo.getEmail()); + ", email " + userInfo.getEmail());
this.insertDataBase(userInfo, token, userInfo.getUsername(), OptTypes.EMAIL); //this.insertDataBase(userInfo, token, userInfo.getUsername(), OptTypes.EMAIL);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -47,7 +42,7 @@ public class MailOtpAuthn extends AbstractOptAuthn {
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.validateDataBase(userInfo, token, OptTypes.EMAIL); return true;
} }
public void setEmailConfig(EmailConfig emailConfig) { public void setEmailConfig(EmailConfig emailConfig) {

View File

@ -2,14 +2,9 @@ package org.maxkey.crypto.password.opt.impl;
import org.maxkey.crypto.password.opt.AbstractOptAuthn; import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.springframework.jdbc.core.JdbcTemplate;
public class MobileOtpAuthn extends AbstractOptAuthn { public class MobileOtpAuthn extends AbstractOptAuthn {
public MobileOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -2,7 +2,6 @@ package org.maxkey.crypto.password.opt.impl;
import org.maxkey.crypto.password.opt.AbstractOptAuthn; import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.springframework.jdbc.core.JdbcTemplate;
/** /**
* Chip Authentication Program EMV stands for Europay, MasterCard and Visa, a * Chip Authentication Program EMV stands for Europay, MasterCard and Visa, a
@ -16,10 +15,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
*/ */
public class RsaOtpAuthn extends AbstractOptAuthn { public class RsaOtpAuthn extends AbstractOptAuthn {
public RsaOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -2,26 +2,20 @@ package org.maxkey.crypto.password.opt.impl;
import org.maxkey.crypto.password.opt.AbstractOptAuthn; import org.maxkey.crypto.password.opt.AbstractOptAuthn;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.springframework.jdbc.core.JdbcTemplate;
public class SmsOtpAuthn extends AbstractOptAuthn { public class SmsOtpAuthn extends AbstractOptAuthn {
public SmsOtpAuthn(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override @Override
public boolean produce(UserInfo userInfo) { public boolean produce(UserInfo userInfo) {
String token = this.genToken(userInfo); String token = this.genToken(userInfo);
// TODO:You must add send sms code here // TODO:You must add send sms code here
this.insertDataBase(userInfo, token, userInfo.getUsername(), OptTypes.SMS);
return true; return true;
} }
@Override @Override
public boolean validate(UserInfo userInfo, String token) { public boolean validate(UserInfo userInfo, String token) {
return this.validateDataBase(userInfo, token, OptTypes.SMS); return true;
} }
} }

View File

@ -11,14 +11,12 @@ import org.maxkey.crypto.password.opt.algorithm.TimeBasedOTP;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
public class TimeBasedOtpAuthn extends AbstractOptAuthn { public class TimeBasedOtpAuthn extends AbstractOptAuthn {
private static final Logger _logger = LoggerFactory.getLogger(TimeBasedOtpAuthn.class); private static final Logger _logger = LoggerFactory.getLogger(TimeBasedOtpAuthn.class);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public TimeBasedOtpAuthn(JdbcTemplate jdbcTemplate) { public TimeBasedOtpAuthn() {
super(jdbcTemplate);
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
} }

View File

@ -12,7 +12,6 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn; import org.maxkey.crypto.password.opt.impl.SmsOtpAuthn;
import org.springframework.jdbc.core.JdbcTemplate;
/** /**
* 网易云信的短信验证. * 网易云信的短信验证.
@ -21,9 +20,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
*/ */
public class SmsOtpAuthnYunxin extends SmsOtpAuthn { public class SmsOtpAuthnYunxin extends SmsOtpAuthn {
public SmsOtpAuthnYunxin(JdbcTemplate jdbcTemplate) { public SmsOtpAuthnYunxin() {
super(jdbcTemplate);
// TODO Auto-generated constructor stub
} }
//发送验证码的请求路径URL //发送验证码的请求路径URL

View File

@ -0,0 +1,5 @@
package org.maxkey.crypto.password.opt.token;
public class AbstractOptTokenStore {
}

View File

@ -0,0 +1,19 @@
package org.maxkey.crypto.password.opt.token;
import java.time.Duration;
import org.ehcache.UserManagedCache;
import org.ehcache.config.builders.ExpiryPolicyBuilder;
import org.ehcache.config.builders.UserManagedCacheBuilder;
import org.maxkey.authn.support.rememberme.RemeberMe;
import org.maxkey.crypto.password.opt.OneTimePassword;
public class InMemoryOptTokenStore {
protected static final UserManagedCache<String, OneTimePassword> remeberMeStore =
UserManagedCacheBuilder.newUserManagedCacheBuilder(String.class, OneTimePassword.class)
.withExpiry(
ExpiryPolicyBuilder.timeToLiveExpiration(
Duration.ofMinutes(RemeberMe.TWO_WEEK)
)
)
.build(true);
}

View File

@ -0,0 +1,110 @@
package org.maxkey.crypto.password.opt.token;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Date;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.joda.time.format.DateTimeFormat;
import org.maxkey.constants.ConstantsStatus;
import org.maxkey.crypto.password.opt.OneTimePassword;
import org.maxkey.domain.UserInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
public class JdbcOptTokenStore {
private static final Logger logger = LoggerFactory.getLogger(JdbcOptTokenStore.class);
private static final String DEFAULT_DEFAULT_INSERT_STATEMENT =
"INSERT INTO ONE_TIME_PASSWORD(ID ,OPTTYPE,USERNAME,TOKEN,RECEIVER,CREATETIME,STATUS)"
+ " VALUES(?,?,?,?,?,?," + ConstantsStatus.ACTIVE + ")";
private static final String DEFAULT_DEFAULT_SELECT_STATEMENT =
"SELECT ID ,OPTTYPE,USERNAME,TOKEN,RECEIVER,CREATETIME FROM ONE_TIME_PASSWORD"
+ " WHERE STATUS =" + ConstantsStatus.ACTIVE
+ " AND USERNAME = ? AND TOKEN = ? AND OPTTYPE = ?";
private static final String DEFAULT_DEFAULT_DELETE_STATEMENT =
"UPDATE ONE_TIME_PASSWORD SET STATUS ="
+ ConstantsStatus.DELETE + " WHERE USERNAME = ? AND TOKEN = ? AND OPTTYPE = ?";
private final JdbcTemplate jdbcTemplate;
public JdbcOptTokenStore(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
protected void store(UserInfo userInfo, String token, String receiver, int type) {
jdbcTemplate.update(DEFAULT_DEFAULT_INSERT_STATEMENT,
new Object[] {
java.util.UUID.randomUUID(),
type,
userInfo.getUsername(),
token,
receiver,
new Date()
},
new int[] { Types.VARCHAR, Types.INTEGER,
Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR,Types.TIMESTAMP
}
);
}
/**
* validate.
* @param userInfo UserInfo
* @param token String
* @param type int
* @return
*/
public boolean validate(UserInfo userInfo, String token, int type,int interval) {
OneTimePassword oneTimePassword = jdbcTemplate.queryForObject(
DEFAULT_DEFAULT_SELECT_STATEMENT,
new OneTimePasswordRowMapper(), userInfo.getUsername(), token, type);
if (oneTimePassword != null) {
jdbcTemplate.update(
DEFAULT_DEFAULT_DELETE_STATEMENT,
new Object[] { userInfo.getUsername(), token, type },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.INTEGER }
);
DateTime currentdateTime = new DateTime();
DateTime oneTimePwdData = DateTime.parse(oneTimePassword.getCreateTime(),
DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
Duration duration = new Duration(oneTimePwdData, currentdateTime);
int intDuration = Integer.parseInt(duration.getStandardSeconds() + "");
logger.debug("validate duration " + intDuration);
logger.debug("validate result " + (intDuration <= interval));
if (intDuration <= interval) {
return true;
}
}
return false;
}
public class OneTimePasswordRowMapper implements RowMapper<OneTimePassword> {
/**
*ResultSet.
*/
public OneTimePassword mapRow(ResultSet rs, int rowNum) throws SQLException {
OneTimePassword oneTimePassword = new OneTimePassword();
oneTimePassword.setId(rs.getString("ID"));
oneTimePassword.setType(rs.getInt("OPTTYPE"));
oneTimePassword.setUsername(rs.getString("USERNAME"));
oneTimePassword.setToken(rs.getString("TOKEN"));
oneTimePassword.setUsername(rs.getString("USERNAME"));
oneTimePassword.setReceiver(rs.getString("RECEIVER"));
oneTimePassword.setCreateTime(rs.getString("CREATETIME"));
return oneTimePassword;
}
}
}

View File

@ -0,0 +1,5 @@
package org.maxkey.crypto.password.opt.token;
public class RedisOptTokenStore {
}

View File

@ -6,9 +6,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain; import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
import org.maxkey.constants.SERVICEMESSAGE; import org.maxkey.constants.ConstantsServiceMessage;
import org.maxkey.exception.PasswordPolicyException; import org.maxkey.exception.PasswordPolicyException;
/** /**
@ -22,7 +21,7 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
private static final long serialVersionUID = -4797776994287829182L; private static final long serialVersionUID = -4797776994287829182L;
@Id @Id
@Column @Column
@GeneratedValue(strategy=GenerationType.AUTO,generator="uuid") @GeneratedValue(strategy = GenerationType.AUTO, generator = "uuid")
String id; String id;
/** /**
* minimum password lengths * minimum password lengths
@ -79,8 +78,7 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
private int expiration; private int expiration;
/** /**
* 0 no * 0 no 1 yes
* 1 yes
*/ */
@Column @Column
private int username; private int username;
@ -91,8 +89,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
@Column @Column
private String simplePasswords; private String simplePasswords;
/** /**
* @return the minLength * @return the minLength
*/ */
@ -100,8 +96,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return minLength; return minLength;
} }
/** /**
* @param minLength the minLength to set * @param minLength the minLength to set
*/ */
@ -109,8 +103,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.minLength = minLength; this.minLength = minLength;
} }
/** /**
* @return the maxLength * @return the maxLength
*/ */
@ -118,8 +110,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return maxLength; return maxLength;
} }
/** /**
* @param maxLength the maxLength to set * @param maxLength the maxLength to set
*/ */
@ -127,7 +117,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.maxLength = maxLength; this.maxLength = maxLength;
} }
/** /**
* @return the lowerCase * @return the lowerCase
*/ */
@ -135,8 +124,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return lowerCase; return lowerCase;
} }
/** /**
* @param lowerCase the lowerCase to set * @param lowerCase the lowerCase to set
*/ */
@ -144,8 +131,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.lowerCase = lowerCase; this.lowerCase = lowerCase;
} }
/** /**
* @return the upperCase * @return the upperCase
*/ */
@ -153,8 +138,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return upperCase; return upperCase;
} }
/** /**
* @param upperCase the upperCase to set * @param upperCase the upperCase to set
*/ */
@ -162,8 +145,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.upperCase = upperCase; this.upperCase = upperCase;
} }
/** /**
* @return the digits * @return the digits
*/ */
@ -171,8 +152,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return digits; return digits;
} }
/** /**
* @param digits the digits to set * @param digits the digits to set
*/ */
@ -180,8 +159,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.digits = digits; this.digits = digits;
} }
/** /**
* @return the specialChar * @return the specialChar
*/ */
@ -189,8 +166,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return specialChar; return specialChar;
} }
/** /**
* @return the id * @return the id
*/ */
@ -198,8 +173,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return id; return id;
} }
/** /**
* @param id the id to set * @param id the id to set
*/ */
@ -207,8 +180,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.id = id; this.id = id;
} }
/** /**
* @param specialChar the specialChar to set * @param specialChar the specialChar to set
*/ */
@ -216,8 +187,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.specialChar = specialChar; this.specialChar = specialChar;
} }
/** /**
* @return the attempts * @return the attempts
*/ */
@ -225,8 +194,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return attempts; return attempts;
} }
/** /**
* @param attempts the attempts to set * @param attempts the attempts to set
*/ */
@ -234,11 +201,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.attempts = attempts; this.attempts = attempts;
} }
/** /**
* @return the duration * @return the duration
*/ */
@ -246,8 +208,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return duration; return duration;
} }
/** /**
* @param duration the duration to set * @param duration the duration to set
*/ */
@ -255,8 +215,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.duration = duration; this.duration = duration;
} }
/** /**
* @return the expiration * @return the expiration
*/ */
@ -264,8 +222,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return expiration; return expiration;
} }
/** /**
* @param expiration the expiration to set * @param expiration the expiration to set
*/ */
@ -273,8 +229,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.expiration = expiration; this.expiration = expiration;
} }
/** /**
* @return the username * @return the username
*/ */
@ -282,8 +236,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return username; return username;
} }
/** /**
* @param username the username to set * @param username the username to set
*/ */
@ -291,8 +243,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.username = username; this.username = username;
} }
/** /**
* @return the simplePasswords * @return the simplePasswords
*/ */
@ -300,8 +250,6 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
return simplePasswords; return simplePasswords;
} }
/** /**
* @param simplePasswords the simplePasswords to set * @param simplePasswords the simplePasswords to set
*/ */
@ -309,28 +257,18 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
this.simplePasswords = simplePasswords; this.simplePasswords = simplePasswords;
} }
public void check(String username, String newPassword, String oldPassword) throws PasswordPolicyException {
if ((1 == this.getUsername()) && newPassword.toLowerCase().contains(username.toLowerCase())) {
public void check(String username, String newPassword,String oldPassword) throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000001);
throws PasswordPolicyException {
if((1==this.getUsername())
&&newPassword.toLowerCase().contains(username.toLowerCase())){
throw new PasswordPolicyException(
SERVICEMESSAGE.PASSWORDPOLICY.XW00000001);
} }
if(oldPassword!=null&&newPassword.equalsIgnoreCase(oldPassword)){ if (oldPassword != null && newPassword.equalsIgnoreCase(oldPassword)) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000002);
SERVICEMESSAGE.PASSWORDPOLICY.XW00000002);
} }
if (newPassword.length() < this.getMinLength()) { if (newPassword.length() < this.getMinLength()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000003, this.getMinLength());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000003,
this.getMinLength());
} }
if (newPassword.length() > this.getMaxLength()) { if (newPassword.length() > this.getMaxLength()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000004, this.getMaxLength());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000004,
this.getMaxLength());
} }
int numCount = 0, upperCount = 0, lowerCount = 0, spacil = 0; int numCount = 0, upperCount = 0, lowerCount = 0, spacil = 0;
char[] chPwd = newPassword.toCharArray(); char[] chPwd = newPassword.toCharArray();
@ -340,52 +278,41 @@ public class PasswordPolicy extends JpaBaseDomain implements java.io.Serializabl
numCount++; numCount++;
continue; continue;
} }
if(Character.isLowerCase(ch)){ if (Character.isLowerCase(ch)) {
lowerCount++; lowerCount++;
continue; continue;
} }
if(Character.isUpperCase(ch)){ if (Character.isUpperCase(ch)) {
upperCount++; upperCount++;
continue; continue;
} }
spacil++; spacil++;
} }
if(numCount<this.getDigits()){ if (numCount < this.getDigits()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000005, this.getDigits());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000005,
this.getDigits());
} }
if(lowerCount<this.getLowerCase()){ if (lowerCount < this.getLowerCase()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000006, this.getLowerCase());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000006,
this.getLowerCase());
} }
if(upperCount<this.getUpperCase()){ if (upperCount < this.getUpperCase()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000007, this.getUpperCase());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000007,
this.getUpperCase());
} }
if(spacil<this.getSpecialChar()){ if (spacil < this.getSpecialChar()) {
throw new PasswordPolicyException( throw new PasswordPolicyException(ConstantsServiceMessage.PASSWORDPOLICY.XW00000008, this.getSpecialChar());
SERVICEMESSAGE.PASSWORDPOLICY.XW00000008,
this.getSpecialChar());
} }
} }
/*
* (non-Javadoc)
/* (non-Javadoc) *
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
return "PasswordPolicy [minLength=" + minLength + ", maxLength=" return "PasswordPolicy [minLength=" + minLength + ", maxLength=" + maxLength + ", lowerCase=" + lowerCase
+ maxLength + ", lowerCase=" + lowerCase + ", upperCase=" + ", upperCase=" + upperCase + ", digits=" + digits + ", specialChar=" + specialChar + ", attempts="
+ upperCase + ", digits=" + digits + ", specialChar=" + attempts + ", duration=" + duration + ", expiration=" + expiration + ", username=" + username
+ specialChar + ", attempts=" + attempts + ", duration=" + ", simplePasswords=" + simplePasswords + "]";
+ duration + ", expiration=" + expiration + ", username="
+ username + ", simplePasswords=" + simplePasswords + "]";
} }
} }

View File

@ -10,7 +10,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.mybatis.jpa.persistence.JpaBaseDomain; import org.apache.mybatis.jpa.persistence.JpaBaseDomain;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.Accounts; import org.maxkey.domain.Accounts;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -133,7 +133,7 @@ public class Apps extends JpaBaseDomain implements Serializable{
public Apps() { public Apps() {
super(); super();
isSignature=BOOLEAN.FALSE; isSignature=Boolean.FALSE;
credential=CREDENTIALS.NONE; credential=CREDENTIALS.NONE;
} }

View File

@ -1,10 +1,8 @@
package org.maxkey.dao.service; package org.maxkey.dao.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService; import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.constants.OPERATEACTION;
import org.maxkey.dao.persistence.MyProfileMapper; import org.maxkey.dao.persistence.MyProfileMapper;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -2,7 +2,7 @@ package org.maxkey.dao.service;
import org.apache.mybatis.jpa.persistence.JpaBaseService; import org.apache.mybatis.jpa.persistence.JpaBaseService;
import org.maxkey.constants.STATUS; import org.maxkey.constants.ConstantsStatus;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.dao.persistence.UserInfoMapper; import org.maxkey.dao.persistence.UserInfoMapper;
@ -154,7 +154,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
public void locked(UserInfo userInfo) { public void locked(UserInfo userInfo) {
try { try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(STATUS.STOP); userInfo.setIsLocked(ConstantsStatus.STOP);
getMapper().locked(userInfo); getMapper().locked(userInfo);
} }
} catch(Exception e) { } catch(Exception e) {
@ -169,7 +169,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
public void unlock(UserInfo userInfo) { public void unlock(UserInfo userInfo) {
try { try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) { if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(STATUS.START); userInfo.setIsLocked(ConstantsStatus.START);
userInfo.setBadPasswordCount(0); userInfo.setBadPasswordCount(0);
getMapper().unlock(userInfo); getMapper().unlock(userInfo);
} }

View File

@ -6,7 +6,7 @@ package org.maxkey.authz.endpoint;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.dao.service.AppsCasDetailsService; import org.maxkey.dao.service.AppsCasDetailsService;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.web.WebConstants; import org.maxkey.web.WebConstants;
@ -37,23 +37,23 @@ public class AuthorizeEndpoint extends AuthorizeBaseEndpoint{
Apps application=getApp(id); Apps application=getApp(id);
WebContext.setAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID, id); WebContext.setAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID, id);
if(application.getProtocol().equalsIgnoreCase(PROTOCOLS.EXTEND_API)){ if(application.getProtocol().equalsIgnoreCase(ConstantsProtocols.EXTEND_API)){
modelAndView=WebContext.forward("/authz/api/"+id); modelAndView=WebContext.forward("/authz/api/"+id);
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.FORMBASED)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.FORMBASED)){
modelAndView=WebContext.forward("/authz/formbased/"+id); modelAndView=WebContext.forward("/authz/formbased/"+id);
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.OAUTH20)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.OAUTH20)){
modelAndView=WebContext.forward("/authz/oauthv20/"+application.getId()); modelAndView=WebContext.forward("/authz/oauthv20/"+application.getId());
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.OPEN_ID_CONNECT)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.OPEN_ID_CONNECT)){
// modelAndView=new ModelAndView("openid connect"); // modelAndView=new ModelAndView("openid connect");
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.SAML20)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.SAML20)){
modelAndView=WebContext.forward("/authz/saml20/idpinit/"+application.getId()); modelAndView=WebContext.forward("/authz/saml20/idpinit/"+application.getId());
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.TOKENBASED)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.TOKENBASED)){
modelAndView=WebContext.forward("/authz/tokenbased/"+id); modelAndView=WebContext.forward("/authz/tokenbased/"+id);
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.CAS)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.CAS)){
modelAndView=WebContext.forward("/authz/cas/"+id); modelAndView=WebContext.forward("/authz/cas/"+id);
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.DESKTOP)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.DESKTOP)){
modelAndView=WebContext.forward("/authz/desktop/"+id); modelAndView=WebContext.forward("/authz/desktop/"+id);
}else if (application.getProtocol().equalsIgnoreCase(PROTOCOLS.BASIC)){ }else if (application.getProtocol().equalsIgnoreCase(ConstantsProtocols.BASIC)){
modelAndView=WebContext.redirect(application.getLoginUrl()); modelAndView=WebContext.redirect(application.getLoginUrl());
} }

View File

@ -2,7 +2,7 @@ package org.maxkey.authz.endpoint.adapter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.crypto.Base64Utils; import org.maxkey.crypto.Base64Utils;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.cert.CertSigner; import org.maxkey.crypto.cert.CertSigner;
@ -25,7 +25,7 @@ public abstract class AbstractAuthorizeAdapter {
public abstract String generateInfo(UserInfo userInfo,Object app); public abstract String generateInfo(UserInfo userInfo,Object app);
public String sign(String data,Apps app){ public String sign(String data,Apps app){
if(BOOLEAN.isTrue(app.getIsSignature())){ if(Boolean.isTrue(app.getIsSignature())){
KeyStoreLoader keyStoreLoader=(KeyStoreLoader)WebContext.getBean("keyStoreLoader"); KeyStoreLoader keyStoreLoader=(KeyStoreLoader)WebContext.getBean("keyStoreLoader");
try { try {
byte[] signature= CertSigner.sign(data.getBytes(), keyStoreLoader.getKeyStore(), keyStoreLoader.getEntityName(), keyStoreLoader.getKeystorePassword()); byte[] signature= CertSigner.sign(data.getBytes(), keyStoreLoader.getKeyStore(), keyStoreLoader.getEntityName(), keyStoreLoader.getKeystorePassword());

View File

@ -15,7 +15,7 @@ import org.maxkey.authz.cas.endpoint.ticket.service.TicketServices;
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.dao.service.AppsCasDetailsService; import org.maxkey.dao.service.AppsCasDetailsService;
import org.maxkey.dao.service.UserInfoService; import org.maxkey.dao.service.UserInfoService;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -194,7 +194,7 @@ For all error codes, it is RECOMMENDED that CAS provide a more detailed message
_logger.debug("principal "+principal); _logger.debug("principal "+principal);
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){ if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter()); AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal); UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
adapter.generateInfo(userInfo, serviceResponseBuilder); adapter.generateInfo(userInfo, serviceResponseBuilder);

View File

@ -14,7 +14,7 @@ import org.maxkey.authz.cas.endpoint.ticket.service.TicketServices;
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.dao.service.AppsCasDetailsService; import org.maxkey.dao.service.AppsCasDetailsService;
import org.maxkey.dao.service.UserInfoService; import org.maxkey.dao.service.UserInfoService;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -74,7 +74,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){ if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter()); AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal); UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
adapter.generateInfo(userInfo, serviceResponseBuilder); adapter.generateInfo(userInfo, serviceResponseBuilder);
@ -114,7 +114,7 @@ public class Cas30AuthorizeEndpoint extends AuthorizeBaseEndpoint{
String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername(); String principal=((BasicAuthentication)storedTicket.getAuthentication().getPrincipal()).getUsername();
serviceResponseBuilder.success().setUser(principal); serviceResponseBuilder.success().setUser(principal);
if(BOOLEAN.isTrue(storedTicket.getCasDetails().getIsAdapter())){ if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter()); AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal); UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
adapter.generateInfo(userInfo, serviceResponseBuilder); adapter.generateInfo(userInfo, serviceResponseBuilder);

View File

@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest;
import org.maxkey.authz.desktop.endpoint.adapter.DesktopDefaultAdapter; import org.maxkey.authz.desktop.endpoint.adapter.DesktopDefaultAdapter;
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.dao.service.AppsDesktopDetailsService; import org.maxkey.dao.service.AppsDesktopDetailsService;
import org.maxkey.domain.Accounts; import org.maxkey.domain.Accounts;
import org.maxkey.domain.apps.AppsDesktopDetails; import org.maxkey.domain.apps.AppsDesktopDetails;
@ -51,7 +51,7 @@ public class DesktopAuthorizeEndpoint extends AuthorizeBaseEndpoint{
ModelAndView modelAndView=new ModelAndView(); ModelAndView modelAndView=new ModelAndView();
AbstractAuthorizeAdapter adapter; AbstractAuthorizeAdapter adapter;
if(BOOLEAN.isTrue(desktopDetails.getIsAdapter())){ if(Boolean.isTrue(desktopDetails.getIsAdapter())){
adapter =(AbstractAuthorizeAdapter)Instance.newInstance(desktopDetails.getAdapter()); adapter =(AbstractAuthorizeAdapter)Instance.newInstance(desktopDetails.getAdapter());
}else{ }else{
adapter =(AbstractAuthorizeAdapter)defaultDesktopAdapter; adapter =(AbstractAuthorizeAdapter)defaultDesktopAdapter;

View File

@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.Accounts; import org.maxkey.domain.Accounts;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.util.Instance; import org.maxkey.util.Instance;
@ -33,7 +33,7 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
Apps apps=getApp(id); Apps apps=getApp(id);
_logger.debug(""+apps); _logger.debug(""+apps);
if(BOOLEAN.isTrue(apps.getIsAdapter())){ if(Boolean.isTrue(apps.getIsAdapter())){
Accounts appUser=getAccounts(apps); Accounts appUser=getAccounts(apps);
if(appUser == null){ if(appUser == null){

View File

@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest;
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.authz.formbased.endpoint.adapter.FormBasedDefaultAdapter; import org.maxkey.authz.formbased.endpoint.adapter.FormBasedDefaultAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.dao.service.AppsFormBasedDetailsService; import org.maxkey.dao.service.AppsFormBasedDetailsService;
import org.maxkey.domain.Accounts; import org.maxkey.domain.Accounts;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
@ -60,7 +60,7 @@ public class FormBasedAuthorizeEndpoint extends AuthorizeBaseEndpoint{
AbstractAuthorizeAdapter adapter; AbstractAuthorizeAdapter adapter;
if(BOOLEAN.isTrue(formBasedDetails.getIsAdapter())){ if(Boolean.isTrue(formBasedDetails.getIsAdapter())){
adapter =(AbstractAuthorizeAdapter)Instance.newInstance(formBasedDetails.getAdapter()); adapter =(AbstractAuthorizeAdapter)Instance.newInstance(formBasedDetails.getAdapter());
}else{ }else{
adapter =(AbstractAuthorizeAdapter)defaultFormBasedAdapter; adapter =(AbstractAuthorizeAdapter)defaultFormBasedAdapter;

View File

@ -1,7 +1,7 @@
package org.maxkey.authz.formbased.endpoint.adapter; package org.maxkey.authz.formbased.endpoint.adapter;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.crypto.DigestUtils; import org.maxkey.crypto.DigestUtils;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.domain.apps.AppsFormBasedDetails; import org.maxkey.domain.apps.AppsFormBasedDetails;
@ -28,7 +28,7 @@ public class FormBasedDefaultAdapter extends AbstractAuthorizeAdapter {
modelAndView.addObject("username", details.getAppUser().getRelatedUsername()); modelAndView.addObject("username", details.getAppUser().getRelatedUsername());
modelAndView.addObject("password", details.getAppUser().getRelatedPassword()); modelAndView.addObject("password", details.getAppUser().getRelatedPassword());
if(BOOLEAN.isTrue(details.getIsExtendAttr())){ if(Boolean.isTrue(details.getIsExtendAttr())){
modelAndView.addObject("extendAttr", details.getExtendAttr()); modelAndView.addObject("extendAttr", details.getExtendAttr());
modelAndView.addObject("isExtendAttr", true); modelAndView.addObject("isExtendAttr", true);
}else{ }else{

View File

@ -1,7 +1,7 @@
package org.maxkey.authz.formbased.endpoint.adapter; package org.maxkey.authz.formbased.endpoint.adapter;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.domain.apps.AppsFormBasedDetails; import org.maxkey.domain.apps.AppsFormBasedDetails;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -27,7 +27,7 @@ public class FormBasedNetease163EmailAdapter extends AbstractAuthorizeAdapter {
modelAndView.addObject("email", details.getAppUser().getRelatedUsername()); modelAndView.addObject("email", details.getAppUser().getRelatedUsername());
modelAndView.addObject("password", details.getAppUser().getRelatedPassword()); modelAndView.addObject("password", details.getAppUser().getRelatedPassword());
if(BOOLEAN.isTrue(details.getIsExtendAttr())){ if(Boolean.isTrue(details.getIsExtendAttr())){
modelAndView.addObject("extendAttr", details.getExtendAttr()); modelAndView.addObject("extendAttr", details.getExtendAttr());
modelAndView.addObject("isExtendAttr", true); modelAndView.addObject("isExtendAttr", true);
}else{ }else{

View File

@ -1,7 +1,7 @@
package org.maxkey.authz.formbased.endpoint.adapter; package org.maxkey.authz.formbased.endpoint.adapter;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.crypto.DigestUtils; import org.maxkey.crypto.DigestUtils;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.domain.apps.AppsFormBasedDetails; import org.maxkey.domain.apps.AppsFormBasedDetails;
@ -61,7 +61,7 @@ public class FormBasedRedirectAdapter extends AbstractAuthorizeAdapter {
} }
if(BOOLEAN.isTrue(details.getIsExtendAttr())){ if(Boolean.isTrue(details.getIsExtendAttr())){
modelAndView.addObject("extendAttr", details.getExtendAttr()); modelAndView.addObject("extendAttr", details.getExtendAttr());
modelAndView.addObject("isExtendAttr", true); modelAndView.addObject("isExtendAttr", true);
}else{ }else{

View File

@ -11,7 +11,7 @@ import org.maxkey.authz.oauth2.common.exceptions.OAuth2Exception;
import org.maxkey.authz.oauth2.provider.ClientDetailsService; import org.maxkey.authz.oauth2.provider.ClientDetailsService;
import org.maxkey.authz.oauth2.provider.OAuth2Authentication; import org.maxkey.authz.oauth2.provider.OAuth2Authentication;
import org.maxkey.authz.oauth2.provider.token.DefaultTokenServices; import org.maxkey.authz.oauth2.provider.token.DefaultTokenServices;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.jwt.encryption.service.JwtEncryptionAndDecryptionService; import org.maxkey.crypto.jwt.encryption.service.JwtEncryptionAndDecryptionService;
import org.maxkey.crypto.jwt.encryption.service.impl.RecipientJwtEncryptionAndDecryptionServiceBuilder; import org.maxkey.crypto.jwt.encryption.service.impl.RecipientJwtEncryptionAndDecryptionServiceBuilder;
@ -106,7 +106,7 @@ public class UserInfoEndpoint {
String userJson=""; String userJson="";
AbstractAuthorizeAdapter adapter; AbstractAuthorizeAdapter adapter;
if(BOOLEAN.isTrue(app.getIsAdapter())){ if(Boolean.isTrue(app.getIsAdapter())){
adapter =(AbstractAuthorizeAdapter)Instance.newInstance(app.getAdapter()); adapter =(AbstractAuthorizeAdapter)Instance.newInstance(app.getAdapter());
}else{ }else{
adapter =(AbstractAuthorizeAdapter)defaultOAuthUserInfoAdapter; adapter =(AbstractAuthorizeAdapter)defaultOAuthUserInfoAdapter;

View File

@ -23,7 +23,7 @@ import org.maxkey.authz.saml20.consumer.spring.IdentityProviderAuthenticationExc
import org.maxkey.authz.saml20.consumer.spring.ServiceProviderAuthenticationException; import org.maxkey.authz.saml20.consumer.spring.ServiceProviderAuthenticationException;
import org.maxkey.authz.saml20.provider.xml.AuthnResponseGenerator; import org.maxkey.authz.saml20.provider.xml.AuthnResponseGenerator;
import org.maxkey.authz.saml20.xml.SAML2ValidatorSuite; import org.maxkey.authz.saml20.xml.SAML2ValidatorSuite;
import org.maxkey.constants.LOGINTYPE; import org.maxkey.constants.ConstantsLoginType;
import org.maxkey.crypto.keystore.KeyStoreLoader; import org.maxkey.crypto.keystore.KeyStoreLoader;
import org.maxkey.dao.service.AppsSaml20DetailsService; import org.maxkey.dao.service.AppsSaml20DetailsService;
import org.maxkey.domain.apps.AppsSAML20Details; import org.maxkey.domain.apps.AppsSAML20Details;
@ -161,7 +161,7 @@ public class ConsumerEndpoint {
logger.debug("assertion.getID() ", assertion.getAuthnStatements()); logger.debug("assertion.getID() ", assertion.getAuthnStatements());
WebContext.setAuthentication(username, LOGINTYPE.SAMLTRUST,"","","success"); WebContext.setAuthentication(username, ConstantsLoginType.SAMLTRUST,"","","success");
ModelAndView mav = new ModelAndView(); ModelAndView mav = new ModelAndView();
mav.addObject("username", username); mav.addObject("username", username);

View File

@ -7,7 +7,7 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.ExtraAttr; import org.maxkey.domain.ExtraAttr;
import org.maxkey.domain.ExtraAttrs; import org.maxkey.domain.ExtraAttrs;
import org.maxkey.domain.apps.AppsSAML20Details; import org.maxkey.domain.apps.AppsSAML20Details;
@ -57,7 +57,7 @@ public class AttributeStatementGenerator {
} }
logger.debug("ExtendAttr "+saml20Details.getExtendAttr()); logger.debug("ExtendAttr "+saml20Details.getExtendAttr());
if(BOOLEAN.isTrue(saml20Details.getIsExtendAttr())) { if(Boolean.isTrue(saml20Details.getIsExtendAttr())) {
ExtraAttrs extraAttrs=new ExtraAttrs(saml20Details.getExtendAttr()); ExtraAttrs extraAttrs=new ExtraAttrs(saml20Details.getExtendAttr());
for(ExtraAttr extraAttr : extraAttrs.getExtraAttrs()) { for(ExtraAttr extraAttr : extraAttrs.getExtraAttrs()) {
logger.debug("Attribute : "+extraAttr.getAttr()+" , Vale : "+extraAttr.getValue()+" , Type : "+extraAttr.getType()); logger.debug("Attribute : "+extraAttr.getAttr()+" , Vale : "+extraAttr.getValue()+" , Type : "+extraAttr.getType());

View File

@ -8,7 +8,7 @@ import org.maxkey.authz.saml.service.IDService;
import org.maxkey.authz.saml.service.TimeService; import org.maxkey.authz.saml.service.TimeService;
import org.maxkey.authz.saml20.binding.BindingAdapter; import org.maxkey.authz.saml20.binding.BindingAdapter;
import org.maxkey.authz.saml20.xml.IssuerGenerator; import org.maxkey.authz.saml20.xml.IssuerGenerator;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.apps.AppsSAML20Details; import org.maxkey.domain.apps.AppsSAML20Details;
import org.opensaml.Configuration; import org.opensaml.Configuration;
import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Assertion;
@ -61,7 +61,7 @@ public class AuthnResponseGenerator {
attributeMap); attributeMap);
//Encrypt //Encrypt
if(BOOLEAN.isTrue(saml20Details.getEncrypted())) { if(Boolean.isTrue(saml20Details.getEncrypted())) {
logger.info("begin to encrypt assertion"); logger.info("begin to encrypt assertion");
try { try {
// Assume this contains a recipient's RSA public // Assume this contains a recipient's RSA public

View File

@ -11,7 +11,7 @@ import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.authz.token.endpoint.adapter.TokenBasedDefaultAdapter; import org.maxkey.authz.token.endpoint.adapter.TokenBasedDefaultAdapter;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.dao.service.AppsTokenBasedDetailsService; import org.maxkey.dao.service.AppsTokenBasedDetailsService;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.domain.apps.AppsTokenBasedDetails; import org.maxkey.domain.apps.AppsTokenBasedDetails;
@ -58,7 +58,7 @@ public class TokenBasedAuthorizeEndpoint extends AuthorizeBaseEndpoint{
tokenBasedDetails.setIsAdapter(application.getIsAdapter()); tokenBasedDetails.setIsAdapter(application.getIsAdapter());
AbstractAuthorizeAdapter adapter; AbstractAuthorizeAdapter adapter;
if(BOOLEAN.isTrue(tokenBasedDetails.getIsAdapter())){ if(Boolean.isTrue(tokenBasedDetails.getIsAdapter())){
adapter =(AbstractAuthorizeAdapter)Instance.newInstance(tokenBasedDetails.getAdapter()); adapter =(AbstractAuthorizeAdapter)Instance.newInstance(tokenBasedDetails.getAdapter());
}else{ }else{
adapter =(AbstractAuthorizeAdapter)defaultTokenBasedAdapter; adapter =(AbstractAuthorizeAdapter)defaultTokenBasedAdapter;

View File

@ -4,7 +4,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.domain.apps.AppsTokenBasedDetails; import org.maxkey.domain.apps.AppsTokenBasedDetails;
import org.maxkey.util.DateUtils; import org.maxkey.util.DateUtils;
@ -23,25 +23,25 @@ public class TokenBasedDefaultAdapter extends AbstractAuthorizeAdapter {
beanMap.put("randomId",(new StringGenerator()).uuidGenerate()); beanMap.put("randomId",(new StringGenerator()).uuidGenerate());
if(BOOLEAN.isTrue(details.getUid())){ if(Boolean.isTrue(details.getUid())){
beanMap.put("uid",userInfo.getId()); beanMap.put("uid",userInfo.getId());
} }
if(BOOLEAN.isTrue(details.getUsername())){ if(Boolean.isTrue(details.getUsername())){
beanMap.put("username", userInfo.getUsername()); beanMap.put("username", userInfo.getUsername());
} }
if(BOOLEAN.isTrue(details.getEmail())){ if(Boolean.isTrue(details.getEmail())){
beanMap.put("email", userInfo.getEmail()); beanMap.put("email", userInfo.getEmail());
} }
if(BOOLEAN.isTrue(details.getWindowsAccount())){ if(Boolean.isTrue(details.getWindowsAccount())){
beanMap.put("windowsAccount", userInfo.getWindowsAccount()); beanMap.put("windowsAccount", userInfo.getWindowsAccount());
} }
if(BOOLEAN.isTrue(details.getEmployeeNumber())){ if(Boolean.isTrue(details.getEmployeeNumber())){
beanMap.put("employeeNumber", userInfo.getEmployeeNumber()); beanMap.put("employeeNumber", userInfo.getEmployeeNumber());
} }
if(BOOLEAN.isTrue(details.getDepartmentId())){ if(Boolean.isTrue(details.getDepartmentId())){
beanMap.put("departmentId", userInfo.getDepartmentId()); beanMap.put("departmentId", userInfo.getDepartmentId());
} }
if(BOOLEAN.isTrue(details.getDepartment())){ if(Boolean.isTrue(details.getDepartment())){
beanMap.put("department", userInfo.getDepartment()); beanMap.put("department", userInfo.getDepartment());
} }

View File

@ -3,7 +3,7 @@ package org.maxkey.authz.token.endpoint.adapter;
import java.util.Date; import java.util.Date;
import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter;
import org.maxkey.constants.BOOLEAN; import org.maxkey.constants.Boolean;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.domain.apps.AppsTokenBasedDetails; import org.maxkey.domain.apps.AppsTokenBasedDetails;
import org.maxkey.util.DateUtils; import org.maxkey.util.DateUtils;
@ -19,17 +19,17 @@ public class TokenBasedSimpleAdapter extends AbstractAuthorizeAdapter {
String tokenUsername=""; String tokenUsername="";
if(BOOLEAN.isTrue(details.getUid())){ if(Boolean.isTrue(details.getUid())){
tokenUsername=userInfo.getId(); tokenUsername=userInfo.getId();
}else if(BOOLEAN.isTrue(details.getUsername())){ }else if(Boolean.isTrue(details.getUsername())){
tokenUsername= userInfo.getUsername(); tokenUsername= userInfo.getUsername();
}else if(BOOLEAN.isTrue(details.getEmail())){ }else if(Boolean.isTrue(details.getEmail())){
tokenUsername=userInfo.getEmail(); tokenUsername=userInfo.getEmail();
}else if(BOOLEAN.isTrue(details.getWindowsAccount())){ }else if(Boolean.isTrue(details.getWindowsAccount())){
tokenUsername= userInfo.getWindowsAccount(); tokenUsername= userInfo.getWindowsAccount();
}else if(BOOLEAN.isTrue(details.getEmployeeNumber())){ }else if(Boolean.isTrue(details.getEmployeeNumber())){
tokenUsername=userInfo.getEmployeeNumber(); tokenUsername=userInfo.getEmployeeNumber();
}else if(BOOLEAN.isTrue(details.getDepartmentId())){ }else if(Boolean.isTrue(details.getDepartmentId())){
tokenUsername= userInfo.getDepartmentId(); tokenUsername= userInfo.getDepartmentId();
} }

View File

@ -2,7 +2,7 @@ package org.maxkey.web.apps.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.domain.ExtraAttr; import org.maxkey.domain.ExtraAttr;
import org.maxkey.domain.ExtraAttrs; import org.maxkey.domain.ExtraAttrs;
@ -62,10 +62,10 @@ public class ApplicationsController extends BaseAppContorller {
transform(application); transform(application);
if (appsService.insert(application)) { if (appsService.insert(application)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
} }
@ -92,10 +92,10 @@ public class ApplicationsController extends BaseAppContorller {
} }
if (appsService.updateExtendAttr(application)) { if (appsService.updateExtendAttr(application)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
@ -109,10 +109,10 @@ public class ApplicationsController extends BaseAppContorller {
public Message query(@ModelAttribute("application") Apps application) { public Message query(@ModelAttribute("application") Apps application) {
_logger.debug("-query :" + application); _logger.debug("-query :" + application);
if (appsService.load(application)!=null) { if (appsService.load(application)!=null) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
@ -127,10 +127,10 @@ public class ApplicationsController extends BaseAppContorller {
public Message update(@ModelAttribute("application") Apps application) { public Message update(@ModelAttribute("application") Apps application) {
_logger.debug("-update application :" + application); _logger.debug("-update application :" + application);
if (appsService.update(application)) { if (appsService.update(application)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }
@ -141,10 +141,10 @@ public class ApplicationsController extends BaseAppContorller {
public Message delete(@ModelAttribute("application") Apps application) { public Message delete(@ModelAttribute("application") Apps application) {
_logger.debug("-delete application :" + application); _logger.debug("-delete application :" + application);
if (appsService.delete(application)) { if (appsService.delete(application)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -5,7 +5,7 @@ package org.maxkey.web.apps.contorller;
import java.io.IOException; import java.io.IOException;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.dao.service.AppsService; import org.maxkey.dao.service.AppsService;
@ -65,7 +65,7 @@ public class BaseAppContorller {
protected void encodeSharedPassword(Apps application){ protected void encodeSharedPassword(Apps application){
if(application.getCredential()!=Apps.CREDENTIALS.SHARED){ if(application.getCredential()!=Apps.CREDENTIALS.SHARED){
if(application.getProtocol().equals(PROTOCOLS.DESKTOP)||application.getProtocol().equals(PROTOCOLS.FORMBASED)){ if(application.getProtocol().equals(ConstantsProtocols.DESKTOP)||application.getProtocol().equals(ConstantsProtocols.FORMBASED)){
if(StringUtils.isNotEmpty(application.getSharedPassword())){ if(StringUtils.isNotEmpty(application.getSharedPassword())){
application.setSharedPassword(ReciprocalUtils.encode(application.getSharedPassword())); application.setSharedPassword(ReciprocalUtils.encode(application.getSharedPassword()));
} }
@ -75,7 +75,7 @@ public class BaseAppContorller {
protected void decoderSharedPassword(Apps application){ protected void decoderSharedPassword(Apps application){
if(application.getCredential()!=Apps.CREDENTIALS.SHARED){ if(application.getCredential()!=Apps.CREDENTIALS.SHARED){
if(application.getProtocol().equals(PROTOCOLS.DESKTOP)||application.getProtocol().equals(PROTOCOLS.FORMBASED)){ if(application.getProtocol().equals(ConstantsProtocols.DESKTOP)||application.getProtocol().equals(ConstantsProtocols.FORMBASED)){
if(StringUtils.isNotEmpty(application.getSharedPassword())){ if(StringUtils.isNotEmpty(application.getSharedPassword())){
application.setSharedPassword(ReciprocalUtils.decoder(application.getSharedPassword())); application.setSharedPassword(ReciprocalUtils.decoder(application.getSharedPassword()));
} }

View File

@ -2,8 +2,8 @@ package org.maxkey.web.apps.contorller;
import java.util.List; import java.util.List;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
@ -30,7 +30,7 @@ public class BasicDetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/basic/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/basic/appAdd");
Apps appDetails =new Apps(); Apps appDetails =new Apps();
appDetails.setId(appDetails.generateId()); appDetails.setId(appDetails.generateId());
appDetails.setProtocol(PROTOCOLS.BASIC); appDetails.setProtocol(ConstantsProtocols.BASIC);
appDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.DES)); appDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.DES));
modelAndView.addObject("model",appDetails); modelAndView.addObject("model",appDetails);
return modelAndView; return modelAndView;
@ -44,10 +44,10 @@ public class BasicDetailsController extends BaseAppContorller {
transform(appDetails); transform(appDetails);
if (appsService.insert(appDetails)) { if (appsService.insert(appDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+appDetails.getId()); return WebContext.forward("forwardUpdate/"+appDetails.getId());
} }
@ -74,10 +74,10 @@ public class BasicDetailsController extends BaseAppContorller {
transform(appDetails); transform(appDetails);
if (appsService.update(appDetails)) { if (appsService.update(appDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+appDetails.getId()); return WebContext.forward("forwardUpdate/"+appDetails.getId());
} }
@ -88,10 +88,10 @@ public class BasicDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (appsService.remove(id)) { if (appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.apps.contorller; package org.maxkey.web.apps.contorller;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AppsCasDetailsService; import org.maxkey.dao.service.AppsCasDetailsService;
import org.maxkey.domain.apps.AppsCasDetails; import org.maxkey.domain.apps.AppsCasDetails;
@ -32,7 +32,7 @@ public class CasDetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/cas/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/cas/appAdd");
AppsCasDetails casDetails =new AppsCasDetails(); AppsCasDetails casDetails =new AppsCasDetails();
casDetails.setId(casDetails.generateId()); casDetails.setId(casDetails.generateId());
casDetails.setProtocol(PROTOCOLS.CAS); casDetails.setProtocol(ConstantsProtocols.CAS);
casDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.DES)); casDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.DES));
modelAndView.addObject("model",casDetails); modelAndView.addObject("model",casDetails);
return modelAndView; return modelAndView;
@ -46,10 +46,10 @@ public class CasDetailsController extends BaseAppContorller {
transform(casDetails); transform(casDetails);
if (casDetailsService.insert(casDetails)&&appsService.insertApp(casDetails)) { if (casDetailsService.insert(casDetails)&&appsService.insertApp(casDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+casDetails.getId()); return WebContext.forward("forwardUpdate/"+casDetails.getId());
} }
@ -77,10 +77,10 @@ public class CasDetailsController extends BaseAppContorller {
transform(casDetails); transform(casDetails);
if (casDetailsService.update(casDetails)&&appsService.updateApp(casDetails)) { if (casDetailsService.update(casDetails)&&appsService.updateApp(casDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+casDetails.getId()); return WebContext.forward("forwardUpdate/"+casDetails.getId());
} }
@ -91,10 +91,10 @@ public class CasDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (casDetailsService.remove(id)&&appsService.remove(id)) { if (casDetailsService.remove(id)&&appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -2,8 +2,8 @@ package org.maxkey.web.apps.contorller;
import java.util.List; import java.util.List;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AppsDesktopDetailsService; import org.maxkey.dao.service.AppsDesktopDetailsService;
import org.maxkey.domain.apps.AppsDesktopDetails; import org.maxkey.domain.apps.AppsDesktopDetails;
@ -34,7 +34,7 @@ public class DesktopDetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/desktop/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/desktop/appAdd");
AppsDesktopDetails desktopDetails=new AppsDesktopDetails(); AppsDesktopDetails desktopDetails=new AppsDesktopDetails();
desktopDetails.setId(desktopDetails.generateId()); desktopDetails.setId(desktopDetails.generateId());
desktopDetails.setProtocol(PROTOCOLS.DESKTOP); desktopDetails.setProtocol(ConstantsProtocols.DESKTOP);
desktopDetails.setSecret(ReciprocalUtils.generateKey("")); desktopDetails.setSecret(ReciprocalUtils.generateKey(""));
modelAndView.addObject("model",desktopDetails); modelAndView.addObject("model",desktopDetails);
@ -50,10 +50,10 @@ public class DesktopDetailsController extends BaseAppContorller {
transform(desktopDetails); transform(desktopDetails);
desktopDetailsService.insert(desktopDetails); desktopDetailsService.insert(desktopDetails);
if (appsService.insertApp(desktopDetails)) { if (appsService.insertApp(desktopDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+desktopDetails.getId()); return WebContext.forward("forwardUpdate/"+desktopDetails.getId());
} }
@ -82,10 +82,10 @@ public class DesktopDetailsController extends BaseAppContorller {
transform(desktopDetails); transform(desktopDetails);
if (desktopDetailsService.update(desktopDetails)&&appsService.updateApp(desktopDetails)) { if (desktopDetailsService.update(desktopDetails)&&appsService.updateApp(desktopDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+desktopDetails.getId()); return WebContext.forward("forwardUpdate/"+desktopDetails.getId());
} }
@ -95,10 +95,10 @@ public class DesktopDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (desktopDetailsService.remove(id)&&appsService.remove(id)) { if (desktopDetailsService.remove(id)&&appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -2,8 +2,8 @@ package org.maxkey.web.apps.contorller;
import java.util.List; import java.util.List;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.domain.apps.AppsExtendApiDetails; import org.maxkey.domain.apps.AppsExtendApiDetails;
@ -32,7 +32,7 @@ public class ExtendApiDetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/extendapi/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/extendapi/appAdd");
AppsExtendApiDetails extendApiDetails=new AppsExtendApiDetails(); AppsExtendApiDetails extendApiDetails=new AppsExtendApiDetails();
extendApiDetails.setId(extendApiDetails.generateId()); extendApiDetails.setId(extendApiDetails.generateId());
extendApiDetails.setProtocol(PROTOCOLS.EXTEND_API); extendApiDetails.setProtocol(ConstantsProtocols.EXTEND_API);
extendApiDetails.setSecret(ReciprocalUtils.generateKey("")); extendApiDetails.setSecret(ReciprocalUtils.generateKey(""));
modelAndView.addObject("model",extendApiDetails); modelAndView.addObject("model",extendApiDetails);
@ -46,10 +46,10 @@ public class ExtendApiDetailsController extends BaseAppContorller {
transform(extendApiDetails); transform(extendApiDetails);
if (appsService.insert(extendApiDetails)) { if (appsService.insert(extendApiDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+extendApiDetails.getId()); return WebContext.forward("forwardUpdate/"+extendApiDetails.getId());
} }
@ -79,10 +79,10 @@ public class ExtendApiDetailsController extends BaseAppContorller {
transform(extendApiDetails); transform(extendApiDetails);
if (appsService.update(extendApiDetails)) { if (appsService.update(extendApiDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+extendApiDetails.getId()); return WebContext.forward("forwardUpdate/"+extendApiDetails.getId());
} }
@ -93,10 +93,10 @@ public class ExtendApiDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (appsService.remove(id)) { if (appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -2,8 +2,8 @@ package org.maxkey.web.apps.contorller;
import java.util.List; import java.util.List;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AppsFormBasedDetailsService; import org.maxkey.dao.service.AppsFormBasedDetailsService;
import org.maxkey.domain.apps.AppsFormBasedDetails; import org.maxkey.domain.apps.AppsFormBasedDetails;
@ -35,7 +35,7 @@ public class FormBasedDetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/formbased/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/formbased/appAdd");
AppsFormBasedDetails formBasedDetails=new AppsFormBasedDetails(); AppsFormBasedDetails formBasedDetails=new AppsFormBasedDetails();
formBasedDetails.setId(formBasedDetails.generateId()); formBasedDetails.setId(formBasedDetails.generateId());
formBasedDetails.setProtocol(PROTOCOLS.FORMBASED); formBasedDetails.setProtocol(ConstantsProtocols.FORMBASED);
formBasedDetails.setSecret(ReciprocalUtils.generateKey("")); formBasedDetails.setSecret(ReciprocalUtils.generateKey(""));
modelAndView.addObject("model",formBasedDetails); modelAndView.addObject("model",formBasedDetails);
@ -51,10 +51,10 @@ public class FormBasedDetailsController extends BaseAppContorller {
transform(formBasedDetails); transform(formBasedDetails);
if (formBasedDetailsService.insert(formBasedDetails)&&appsService.insertApp(formBasedDetails)) { if (formBasedDetailsService.insert(formBasedDetails)&&appsService.insertApp(formBasedDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+formBasedDetails.getId()); return WebContext.forward("forwardUpdate/"+formBasedDetails.getId());
} }
@ -81,10 +81,10 @@ public class FormBasedDetailsController extends BaseAppContorller {
_logger.debug("-update application :" + formBasedDetails); _logger.debug("-update application :" + formBasedDetails);
transform(formBasedDetails); transform(formBasedDetails);
if (formBasedDetailsService.update(formBasedDetails)&&appsService.updateApp(formBasedDetails)) { if (formBasedDetailsService.update(formBasedDetails)&&appsService.updateApp(formBasedDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+formBasedDetails.getId()); return WebContext.forward("forwardUpdate/"+formBasedDetails.getId());
} }
@ -95,10 +95,10 @@ public class FormBasedDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (formBasedDetailsService.remove(id)&&appsService.remove(id)) { if (formBasedDetailsService.remove(id)&&appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
} }
} }
} }

View File

@ -3,8 +3,8 @@ package org.maxkey.web.apps.contorller;
import java.util.List; import java.util.List;
import org.maxkey.authz.oauth2.provider.client.JdbcClientDetailsService; import org.maxkey.authz.oauth2.provider.client.JdbcClientDetailsService;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
import org.maxkey.domain.apps.AppsOAuth20Details; import org.maxkey.domain.apps.AppsOAuth20Details;
@ -40,7 +40,7 @@ public class OAuth20DetailsController extends BaseAppContorller {
oauth20Details.setSecret(ReciprocalUtils.generateKey("")); oauth20Details.setSecret(ReciprocalUtils.generateKey(""));
oauth20Details.setClientId(oauth20Details.getId()); oauth20Details.setClientId(oauth20Details.getId());
oauth20Details.setClientSecret(oauth20Details.getSecret()); oauth20Details.setClientSecret(oauth20Details.getSecret());
oauth20Details.setProtocol(PROTOCOLS.OAUTH20); oauth20Details.setProtocol(ConstantsProtocols.OAUTH20);
modelAndView.addObject("model",oauth20Details); modelAndView.addObject("model",oauth20Details);
return modelAndView; return modelAndView;
} }
@ -56,10 +56,10 @@ public class OAuth20DetailsController extends BaseAppContorller {
oauth20JdbcClientDetailsService.addClientDetails(oauth20Details.clientDetailsRowMapper()); oauth20JdbcClientDetailsService.addClientDetails(oauth20Details.clientDetailsRowMapper());
if (appsService.insertApp(oauth20Details)) { if (appsService.insertApp(oauth20Details)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+oauth20Details.getId()); return WebContext.forward("forwardUpdate/"+oauth20Details.getId());
} }
@ -94,9 +94,9 @@ public class OAuth20DetailsController extends BaseAppContorller {
oauth20JdbcClientDetailsService.updateClientDetails(oauth20Details.clientDetailsRowMapper()); oauth20JdbcClientDetailsService.updateClientDetails(oauth20Details.clientDetailsRowMapper());
oauth20JdbcClientDetailsService.updateClientSecret(oauth20Details.getClientId(), oauth20Details.getClientSecret()); oauth20JdbcClientDetailsService.updateClientSecret(oauth20Details.getClientId(), oauth20Details.getClientSecret());
if (appsService.updateApp(oauth20Details)) { if (appsService.updateApp(oauth20Details)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+oauth20Details.getId()); return WebContext.forward("forwardUpdate/"+oauth20Details.getId());
} }
@ -108,10 +108,10 @@ public class OAuth20DetailsController extends BaseAppContorller {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
oauth20JdbcClientDetailsService.removeClientDetails(id); oauth20JdbcClientDetailsService.removeClientDetails(id);
if (appsService.remove(id)) { if (appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -7,8 +7,8 @@ import java.security.cert.X509Certificate;
import java.util.List; import java.util.List;
import org.maxkey.authz.saml20.metadata.MetadataDescriptorUtil; import org.maxkey.authz.saml20.metadata.MetadataDescriptorUtil;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.cert.NameUtil; import org.maxkey.crypto.cert.NameUtil;
import org.maxkey.crypto.cert.X509CertUtils; import org.maxkey.crypto.cert.X509CertUtils;
@ -54,7 +54,7 @@ public class SAML20DetailsController extends BaseAppContorller {
ModelAndView modelAndView=new ModelAndView("apps/saml20/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/saml20/appAdd");
AppsSAML20Details saml20Details=new AppsSAML20Details(); AppsSAML20Details saml20Details=new AppsSAML20Details();
saml20Details.setSecret(ReciprocalUtils.generateKey("")); saml20Details.setSecret(ReciprocalUtils.generateKey(""));
saml20Details.setProtocol(PROTOCOLS.SAML20); saml20Details.setProtocol(ConstantsProtocols.SAML20);
modelAndView.addObject("model",saml20Details); modelAndView.addObject("model",saml20Details);
return modelAndView; return modelAndView;
@ -72,10 +72,10 @@ public class SAML20DetailsController extends BaseAppContorller {
} }
saml20DetailsService.insert(saml20Details); saml20DetailsService.insert(saml20Details);
if (appsService.insertApp(saml20Details)) { if (appsService.insertApp(saml20Details)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+saml20Details.getId()); return WebContext.forward("forwardUpdate/"+saml20Details.getId());
} }
@ -107,10 +107,10 @@ public class SAML20DetailsController extends BaseAppContorller {
} }
saml20DetailsService.update(saml20Details); saml20DetailsService.update(saml20Details);
if (appsService.updateApp(saml20Details)) { if (appsService.updateApp(saml20Details)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+saml20Details.getId()); return WebContext.forward("forwardUpdate/"+saml20Details.getId());
} }
@ -121,10 +121,10 @@ public class SAML20DetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (saml20DetailsService.remove(id)&&appsService.remove(id)) { if (saml20DetailsService.remove(id)&&appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -1,9 +1,7 @@
package org.maxkey.web.apps.contorller; package org.maxkey.web.apps.contorller;
import java.util.List; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.constants.OPERATEMESSAGE;
import org.maxkey.constants.PROTOCOLS;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AppsTokenBasedDetailsService; import org.maxkey.dao.service.AppsTokenBasedDetailsService;
import org.maxkey.domain.apps.AppsTokenBasedDetails; import org.maxkey.domain.apps.AppsTokenBasedDetails;
@ -34,7 +32,7 @@ public class TokenBasedDetailsController extends BaseAppContorller {
public ModelAndView forwardAdd() { public ModelAndView forwardAdd() {
ModelAndView modelAndView=new ModelAndView("apps/tokenbased/appAdd"); ModelAndView modelAndView=new ModelAndView("apps/tokenbased/appAdd");
AppsTokenBasedDetails tokenBasedDetails =new AppsTokenBasedDetails(); AppsTokenBasedDetails tokenBasedDetails =new AppsTokenBasedDetails();
tokenBasedDetails.setProtocol(PROTOCOLS.TOKENBASED); tokenBasedDetails.setProtocol(ConstantsProtocols.TOKENBASED);
tokenBasedDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.AES)); tokenBasedDetails.setSecret(ReciprocalUtils.generateKey(ReciprocalUtils.Algorithm.AES));
tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret()); tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret());
modelAndView.addObject("model",tokenBasedDetails); modelAndView.addObject("model",tokenBasedDetails);
@ -51,10 +49,10 @@ public class TokenBasedDetailsController extends BaseAppContorller {
tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret()); tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret());
if (tokenBasedDetailsService.insert(tokenBasedDetails)&&appsService.insertApp(tokenBasedDetails)) { if (tokenBasedDetailsService.insert(tokenBasedDetails)&&appsService.insertApp(tokenBasedDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+tokenBasedDetails.getId()); return WebContext.forward("forwardUpdate/"+tokenBasedDetails.getId());
} }
@ -83,10 +81,10 @@ public class TokenBasedDetailsController extends BaseAppContorller {
transform(tokenBasedDetails); transform(tokenBasedDetails);
tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret()); tokenBasedDetails.setAlgorithmKey(tokenBasedDetails.getSecret());
if (tokenBasedDetailsService.update(tokenBasedDetails)&&appsService.updateApp(tokenBasedDetails)) { if (tokenBasedDetailsService.update(tokenBasedDetails)&&appsService.updateApp(tokenBasedDetails)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
return WebContext.forward("forwardUpdate/"+tokenBasedDetails.getId()); return WebContext.forward("forwardUpdate/"+tokenBasedDetails.getId());
} }
@ -97,10 +95,10 @@ public class TokenBasedDetailsController extends BaseAppContorller {
public Message delete(@PathVariable("id") String id) { public Message delete(@PathVariable("id") String id) {
_logger.debug("-delete application :" + id); _logger.debug("-delete application :" + id);
if (tokenBasedDetailsService.remove(id)&&appsService.remove(id)) { if (tokenBasedDetailsService.remove(id)&&appsService.remove(id)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AccountsService; import org.maxkey.dao.service.AccountsService;
import org.maxkey.dao.service.AppsService; import org.maxkey.dao.service.AppsService;
@ -79,7 +79,7 @@ public class AccountsController {
_logger.debug("-update :" + appAccounts); _logger.debug("-update :" + appAccounts);
appAccounts.setRelatedPassword(ReciprocalUtils.encode(appAccounts.getRelatedPassword())); appAccounts.setRelatedPassword(ReciprocalUtils.encode(appAccounts.getRelatedPassword()));
accountsService.insert(appAccounts); accountsService.insert(appAccounts);
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} }
@ -107,7 +107,7 @@ public class AccountsController {
appAccounts.setRelatedPassword(ReciprocalUtils.encode(appAccounts.getRelatedPassword())); appAccounts.setRelatedPassword(ReciprocalUtils.encode(appAccounts.getRelatedPassword()));
accountsService.update(appAccounts); accountsService.update(appAccounts);
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} }
@ -123,7 +123,7 @@ public class AccountsController {
accountsService.remove(appAccountsds[i]); accountsService.remove(appAccountsds[i]);
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.GroupMemberService; import org.maxkey.dao.service.GroupMemberService;
import org.maxkey.dao.service.GroupsService; import org.maxkey.dao.service.GroupsService;
import org.maxkey.domain.GroupMember; import org.maxkey.domain.GroupMember;
@ -115,11 +115,11 @@ public class GroupMemberController {
result = groupMemberService.insert(newGroupMember); result = groupMemberService.insert(newGroupMember);
} }
if(!result) { if(!result) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.info); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.info);
} }
@RequestMapping(value = {"/delete"}) @RequestMapping(value = {"/delete"})
@ -138,10 +138,10 @@ public class GroupMemberController {
groupMemberService.remove(arrMemberIds[i]); groupMemberService.remove(arrMemberIds[i]);
} }
if(!result) { if(!result) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.info); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.info);
} }
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.GroupPrivilegesService; import org.maxkey.dao.service.GroupPrivilegesService;
import org.maxkey.domain.GroupPrivileges; import org.maxkey.domain.GroupPrivileges;
import org.maxkey.domain.apps.Apps; import org.maxkey.domain.apps.Apps;
@ -97,11 +97,11 @@ public class GroupPrivilegesController {
result = groupPrivilegesService.insert(newGroupApp); result = groupPrivilegesService.insert(newGroupApp);
} }
if(!result) { if(!result) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.info); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.info);
} }
@RequestMapping(value = {"/delete"}) @RequestMapping(value = {"/delete"})
@ -121,11 +121,11 @@ public class GroupPrivilegesController {
result = groupPrivilegesService.remove(arrPrivilegesIds[i]); result = groupPrivilegesService.remove(arrPrivilegesIds[i]);
} }
if(!result) { if(!result) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.info); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.info);
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.GroupsService; import org.maxkey.dao.service.GroupsService;
import org.maxkey.domain.Groups; import org.maxkey.domain.Groups;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
@ -68,10 +68,10 @@ public class GroupsController {
_logger.debug("-Add :" + group); _logger.debug("-Add :" + group);
if (groupsService.insert(group)) { if (groupsService.insert(group)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
} }
@ -86,10 +86,10 @@ public class GroupsController {
public Message query(@ModelAttribute("group") Groups group) { public Message query(@ModelAttribute("group") Groups group) {
_logger.debug("-query :" + group); _logger.debug("-query :" + group);
if (groupsService.load(group)!=null) { if (groupsService.load(group)!=null) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
@ -105,10 +105,10 @@ public class GroupsController {
_logger.debug("-update group :" + group); _logger.debug("-update group :" + group);
if (groupsService.update(group)) { if (groupsService.update(group)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }
@ -120,10 +120,10 @@ public class GroupsController {
_logger.debug("-delete group :" + group); _logger.debug("-delete group :" + group);
if (groupsService.remove(group.getId())) { if (groupsService.remove(group.getId())) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.IpAddrFilterService; import org.maxkey.dao.service.IpAddrFilterService;
import org.maxkey.domain.IpAddrFilter; import org.maxkey.domain.IpAddrFilter;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
@ -63,10 +63,10 @@ public class IpAddrFilterController {
_logger.debug("-Add :" + ipAddrFilter); _logger.debug("-Add :" + ipAddrFilter);
if (ipAddrFilterService.insert(ipAddrFilter)) { if (ipAddrFilterService.insert(ipAddrFilter)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.error);
} }
} }
@ -81,10 +81,10 @@ public class IpAddrFilterController {
public Message query(@ModelAttribute("ipAddrFilter") IpAddrFilter ipAddrFilter) { public Message query(@ModelAttribute("ipAddrFilter") IpAddrFilter ipAddrFilter) {
_logger.debug("-query :" + ipAddrFilter); _logger.debug("-query :" + ipAddrFilter);
if (ipAddrFilterService.load(ipAddrFilter)!=null) { if (ipAddrFilterService.load(ipAddrFilter)!=null) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
} }
} }
@ -100,10 +100,10 @@ public class IpAddrFilterController {
_logger.debug("-update ipAddrFilter :" + ipAddrFilter); _logger.debug("-update ipAddrFilter :" + ipAddrFilter);
if (ipAddrFilterService.update(ipAddrFilter)) { if (ipAddrFilterService.update(ipAddrFilter)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }
@ -115,10 +115,10 @@ public class IpAddrFilterController {
_logger.debug("-delete ipAddrFilter :" + ipAddrFilter); _logger.debug("-delete ipAddrFilter :" + ipAddrFilter);
if (ipAddrFilterService.delete(ipAddrFilter)) { if (ipAddrFilterService.delete(ipAddrFilter)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.error);
} }
} }

View File

@ -2,7 +2,7 @@ package org.maxkey.web.contorller;
import javax.validation.Valid; import javax.validation.Valid;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.PasswordPolicyService; import org.maxkey.dao.service.PasswordPolicyService;
import org.maxkey.domain.PasswordPolicy; import org.maxkey.domain.PasswordPolicy;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
@ -53,9 +53,9 @@ public class PasswordPolicyController {
return message; return message;
} }
if(passwordPolicyService.update(passwordPolicy)) { if(passwordPolicyService.update(passwordPolicy)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }

View File

@ -9,7 +9,7 @@ import java.util.Map;
import javax.validation.Valid; import javax.validation.Valid;
import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.UserInfoService; import org.maxkey.dao.service.UserInfoService;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -108,10 +108,10 @@ public class UserInfoController {
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true)); //userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false)); //userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
if( userInfoService.insert(userInfo)) { if( userInfoService.insert(userInfo)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
} }
new Message(WebContext.getI18nValue(OPERATEMESSAGE.INSERT_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId()); return WebContext.forward("forwardUpdate/"+userInfo.getId());
} }
@ -167,10 +167,10 @@ public class UserInfoController {
convertExtraAttribute(userInfo) ; convertExtraAttribute(userInfo) ;
_logger.info(userInfo.getExtraAttribute()); _logger.info(userInfo.getExtraAttribute());
if(userInfoService.update(userInfo)) { if(userInfoService.update(userInfo)) {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
} }
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId()); return WebContext.forward("forwardUpdate/"+userInfo.getId());
} }
@ -185,10 +185,10 @@ public class UserInfoController {
public Message batchDeleteUsers(@RequestParam("id")String id) { public Message batchDeleteUsers(@RequestParam("id")String id) {
_logger.debug(id); _logger.debug(id);
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) { if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
} }
} }
@ -204,9 +204,9 @@ public class UserInfoController {
_logger.debug(id); _logger.debug(id);
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) { if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION); //provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.DELETE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
} }
} }
@ -237,10 +237,10 @@ public class UserInfoController {
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) { public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
_logger.debug(userInfo.getId()); _logger.debug(userInfo.getId());
if(userInfoService.changePassword(userInfo)) { if(userInfoService.changePassword(userInfo)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }

View File

@ -1,8 +1,8 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import java.util.List; import java.util.List;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.constants.PROTOCOLS; import org.maxkey.constants.ConstantsProtocols;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.dao.service.AccountsService; import org.maxkey.dao.service.AccountsService;
import org.maxkey.dao.service.AppsService; import org.maxkey.dao.service.AppsService;
@ -171,10 +171,10 @@ public class AppListController {
userInfoService.updateProtectedApps(userInfo); userInfoService.updateProtectedApps(userInfo);
} else { } else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR), MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS), MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), MessageType.success);
} }
@RequestMapping(value = { "/forward/appUserConfig/{protocol}/{credential}/{appId}" }) @RequestMapping(value = { "/forward/appUserConfig/{protocol}/{credential}/{appId}" })
@ -187,12 +187,12 @@ public class AppListController {
UserInfo userInfo = WebContext.getUserInfo(); UserInfo userInfo = WebContext.getUserInfo();
if (credential == Apps.CREDENTIALS.USER_DEFINED) { if (credential == Apps.CREDENTIALS.USER_DEFINED) {
appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId)); appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId));
if (protocol.equalsIgnoreCase(PROTOCOLS.DESKTOP) || protocol.equalsIgnoreCase(PROTOCOLS.FORMBASED) if (protocol.equalsIgnoreCase(ConstantsProtocols.DESKTOP) || protocol.equalsIgnoreCase(ConstantsProtocols.FORMBASED)
|| protocol.equalsIgnoreCase(PROTOCOLS.BASIC) || protocol.equalsIgnoreCase(PROTOCOLS.EXTEND_API)) { || protocol.equalsIgnoreCase(ConstantsProtocols.BASIC) || protocol.equalsIgnoreCase(ConstantsProtocols.EXTEND_API)) {
modelAndView.addObject("username", true); modelAndView.addObject("username", true);
modelAndView.addObject("password", true); modelAndView.addObject("password", true);
} else if (protocol.equalsIgnoreCase(PROTOCOLS.SAML20)) { } else if (protocol.equalsIgnoreCase(ConstantsProtocols.SAML20)) {
modelAndView.addObject("username", true); modelAndView.addObject("username", true);
modelAndView.addObject("password", false); modelAndView.addObject("password", false);
} else { } else {
@ -253,6 +253,6 @@ public class AppListController {
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS), MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), MessageType.success);
} }
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import javax.validation.Valid; import javax.validation.Valid;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.dao.service.MyProfileService; import org.maxkey.dao.service.MyProfileService;
import org.maxkey.dao.service.UserInfoService; import org.maxkey.dao.service.UserInfoService;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
@ -71,12 +71,12 @@ public class ProfileController {
if (myProfileService.updateProfile(userInfo) > 0) { if (myProfileService.updateProfile(userInfo) > 0) {
new Message( new Message(
WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS), WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),
userInfo, MessageType.success, userInfo, MessageType.success,
OperateType.add, MessageScope.DB); OperateType.add, MessageScope.DB);
} else { } else {
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR), MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
} }
return WebContext.forward("forwardMyProfile"); return WebContext.forward("forwardMyProfile");

View File

@ -6,7 +6,7 @@ import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.EmailException; import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail; import org.apache.commons.mail.HtmlEmail;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.STATUS; import org.maxkey.constants.ConstantsStatus;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.dao.service.RegistrationService; import org.maxkey.dao.service.RegistrationService;
@ -136,7 +136,7 @@ public class RegistrationController {
userInfo.setWorkPhoneNumber(registration.getWorkPhone()); userInfo.setWorkPhoneNumber(registration.getWorkPhone());
userInfo.setEmail(registration.getWorkEmail()); userInfo.setEmail(registration.getWorkEmail());
userInfo.setStatus(STATUS.ACTIVE); userInfo.setStatus(ConstantsStatus.ACTIVE);
String rawPassword=PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password); String rawPassword=PasswordReciprocal.getInstance().rawPassword(userInfo.getUsername(), password);
userInfo.setDecipherable(ReciprocalUtils.encode(rawPassword)); userInfo.setDecipherable(ReciprocalUtils.encode(rawPassword));

View File

@ -1,6 +1,6 @@
package org.maxkey.web.contorller; package org.maxkey.web.contorller;
import org.maxkey.constants.OPERATEMESSAGE; import org.maxkey.constants.ConstantsOperateMessage;
import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.crypto.password.PasswordReciprocal; import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.dao.service.UserInfoService; import org.maxkey.dao.service.UserInfoService;
@ -47,9 +47,9 @@ public class SafeController {
@RequestParam("confirmPassword") String confirmPassword) { @RequestParam("confirmPassword") String confirmPassword) {
if(changeUserPassword(oldPassword,newPassword,confirmPassword)) { if(changeUserPassword(oldPassword,newPassword,confirmPassword)) {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
}else { }else {
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
} }
@ -66,7 +66,7 @@ public class SafeController {
} }
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
return modelAndView; return modelAndView;
} }
@ -84,7 +84,7 @@ public class SafeController {
//modelAndView.setViewName("index"); //modelAndView.setViewName("index");
} }
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
return modelAndView; return modelAndView;
} }
@ -130,11 +130,11 @@ public class SafeController {
userInfo.setAppLoginPassword(ReciprocalUtils.encode(newPassword)); userInfo.setAppLoginPassword(ReciprocalUtils.encode(newPassword));
boolean change= userInfoService.changeAppLoginPassword(userInfo); boolean change= userInfoService.changeAppLoginPassword(userInfo);
_logger.debug(""+change); _logger.debug(""+change);
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.prompt); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.prompt);
} }
} }
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR),MessageType.error); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
} }
@ -164,7 +164,7 @@ public class SafeController {
userInfo.setEmail(email); userInfo.setEmail(email);
userInfoService.changeEmail(userInfo); userInfoService.changeEmail(userInfo);
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),MessageType.success); return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} }

View File

@ -1,7 +1,7 @@
package org.maxkey.web.endpoint; package org.maxkey.web.endpoint;
import org.maxkey.config.ApplicationConfig; import org.maxkey.config.ApplicationConfig;
import org.maxkey.constants.PASSWORDSETTYPE; import org.maxkey.constants.ConstantsPasswordSetType;
import org.maxkey.domain.UserInfo; import org.maxkey.domain.UserInfo;
import org.maxkey.web.WebConstants; import org.maxkey.web.WebConstants;
import org.maxkey.web.WebContext; import org.maxkey.web.WebContext;
@ -31,7 +31,7 @@ public class IndexEndpoint {
_logger.debug("IndexEndpoint /forwardindex."); _logger.debug("IndexEndpoint /forwardindex.");
ModelAndView modelAndView=new ModelAndView(); ModelAndView modelAndView=new ModelAndView();
Integer passwordSetType=(Integer)WebContext.getSession().getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE); Integer passwordSetType=(Integer)WebContext.getSession().getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
if(passwordSetType==null || passwordSetType==PASSWORDSETTYPE.PASSWORD_NORMAL){ if(passwordSetType==null || passwordSetType==ConstantsPasswordSetType.PASSWORD_NORMAL){
if(applicationConfig.getLoginConfig().getDefaultUri()!=null&& if(applicationConfig.getLoginConfig().getDefaultUri()!=null&&
!applicationConfig.getLoginConfig().getDefaultUri().equals("")){ !applicationConfig.getLoginConfig().getDefaultUri().equals("")){
if(applicationConfig.getLoginConfig().getDefaultUri().startsWith("http")){ if(applicationConfig.getLoginConfig().getDefaultUri().startsWith("http")){
@ -45,11 +45,11 @@ public class IndexEndpoint {
UserInfo userInfo=WebContext.getUserInfo(); UserInfo userInfo=WebContext.getUserInfo();
modelAndView.addObject("model", userInfo); modelAndView.addObject("model", userInfo);
if(passwordSetType==PASSWORDSETTYPE.PASSWORD_EXPIRED){ if(passwordSetType==ConstantsPasswordSetType.PASSWORD_EXPIRED){
modelAndView.setViewName("passwordExpired"); modelAndView.setViewName("passwordExpired");
return modelAndView; return modelAndView;
}else if(passwordSetType==PASSWORDSETTYPE.INITIAL_PASSWORD|| }else if(passwordSetType==ConstantsPasswordSetType.INITIAL_PASSWORD||
passwordSetType==PASSWORDSETTYPE.MANAGER_CHANGED_PASSWORD){ passwordSetType==ConstantsPasswordSetType.MANAGER_CHANGED_PASSWORD){
modelAndView.setViewName("passwordInitial"); modelAndView.setViewName("passwordInitial");
return modelAndView; return modelAndView;
} }