model change
This commit is contained in:
parent
2a30b37875
commit
7df5c1458a
|
@ -5,7 +5,6 @@ import com.loafle.overflow.central.commons.utils.EmailSender;
|
||||||
import com.loafle.overflow.central.commons.utils.SessionMetadata;
|
import com.loafle.overflow.central.commons.utils.SessionMetadata;
|
||||||
import com.loafle.overflow.central.module.email.service.EmailAuthService;
|
import com.loafle.overflow.central.module.email.service.EmailAuthService;
|
||||||
import com.loafle.overflow.central.module.member.dao.MemberDAO;
|
import com.loafle.overflow.central.module.member.dao.MemberDAO;
|
||||||
import com.loafle.overflow.central.module.member.exception.*;
|
|
||||||
|
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.model.apikey.ApiKey;
|
import com.loafle.overflow.model.apikey.ApiKey;
|
||||||
|
@ -129,7 +128,7 @@ public class CentralMemberService implements MemberService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.emailAuthService.sendEmailResetPassword(member);
|
this.emailAuthService.sendEmailResetPassword(member);
|
||||||
} catch (MailException e) {
|
} catch (Exception e) {
|
||||||
// Todo ReSend Mail
|
// Todo ReSend Mail
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +149,7 @@ public class CentralMemberService implements MemberService {
|
||||||
Member member = this.memberDAO.findByEmail(deEmail);
|
Member member = this.memberDAO.findByEmail(deEmail);
|
||||||
|
|
||||||
if (null == member) {
|
if (null == member) {
|
||||||
throw new SignInIdNotExistException();
|
throw new OverflowException("", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPass = this.isPasswordStrong(pw);
|
boolean checkPass = this.isPasswordStrong(pw);
|
||||||
|
|
|
@ -22,14 +22,14 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MemberTotpDAO totpDAO;
|
private MemberTotpDAO totpDAO;
|
||||||
|
|
||||||
public void regist(Member member, String secretCode, String code) throws OverflowException {
|
public void regist(Member member, String secretCode, String code) throws OverflowException {
|
||||||
|
|
||||||
if (null == member || 0 >= member.getId()) {
|
if (null == member || 0 >= member.getId()) {
|
||||||
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.checkCode(secretCode, code) ) {
|
if (!this.checkCode(secretCode, code)) {
|
||||||
throw new OverflowException("TotpCodeNotMatchException",new Throwable());
|
throw new OverflowException("TotpCodeNotMatchException", new Throwable());
|
||||||
}
|
}
|
||||||
|
|
||||||
MemberTotp totp = new MemberTotp();
|
MemberTotp totp = new MemberTotp();
|
||||||
|
@ -40,8 +40,8 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemberTotp modify(MemberTotp totp) throws OverflowException {
|
public MemberTotp modify(MemberTotp totp) throws OverflowException {
|
||||||
if ( null == totp.getSecretCode() || totp.getSecretCode().equals("")) {
|
if (null == totp.getSecretCode() || totp.getSecretCode().equals("")) {
|
||||||
throw new OverflowException("SecretCodeNotExistException",new Throwable());
|
throw new OverflowException("SecretCodeNotExistException", new Throwable());
|
||||||
}
|
}
|
||||||
if (null == totp.getMember() || 0 < totp.getMember().getId()) {
|
if (null == totp.getMember() || 0 < totp.getMember().getId()) {
|
||||||
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
||||||
|
@ -50,7 +50,7 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
return this.totpDAO.save(totp);
|
return this.totpDAO.save(totp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(long id) throws OverflowException {
|
public void remove(long id) throws OverflowException {
|
||||||
this.totpDAO.delete(id);
|
this.totpDAO.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
|
|
||||||
public boolean checkCodeForMember(Member member, String code) throws OverflowException {
|
public boolean checkCodeForMember(Member member, String code) throws OverflowException {
|
||||||
MemberTotp totp = this.totpDAO.findByMember(member);
|
MemberTotp totp = this.totpDAO.findByMember(member);
|
||||||
if (null == totp && (totp.getSecretCode() == null || totp.getSecretCode().equals("")) ) {
|
if (null == totp && (totp.getSecretCode() == null || totp.getSecretCode().equals(""))) {
|
||||||
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
throw new OverflowException("SignInIdNotExistException", new Throwable());
|
||||||
}
|
}
|
||||||
return this.checkCode(totp.getSecretCode(), code);
|
return this.checkCode(totp.getSecretCode(), code);
|
||||||
|
@ -78,19 +78,17 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
return isCheck;
|
return isCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> createTotp(Member member) throws OverflowException {
|
public Map<String, String> createTotp(Member member) throws OverflowException {
|
||||||
Map<String, String> returnMap = new HashMap<>();
|
Map<String, String> returnMap = new HashMap<>();
|
||||||
|
|
||||||
GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator();
|
GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator();
|
||||||
final GoogleAuthenticatorKey key = googleAuthenticator.createCredentials();
|
final GoogleAuthenticatorKey key = googleAuthenticator.createCredentials();
|
||||||
|
|
||||||
String secret = key.getKey();
|
String secret = key.getKey();
|
||||||
// List<Integer> scratchCodes = key.getScratchCodes();
|
// List<Integer> scratchCodes = key.getScratchCodes();
|
||||||
// String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("overFlow", member.getEmail(), key);
|
// String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("overFlow", member.getEmail(), key);
|
||||||
URIBuilder uri = (new URIBuilder()).setScheme("otpauth")
|
URIBuilder uri = (new URIBuilder()).setScheme("otpauth").setHost("totp")
|
||||||
.setHost("totp")
|
.setPath("/" + formatLabel("overFlow", member.getEmail())).setParameter("secret", key.getKey());
|
||||||
.setPath("/" + formatLabel("overFlow", member.getEmail()))
|
|
||||||
.setParameter("secret", key.getKey());
|
|
||||||
|
|
||||||
returnMap.put("key", secret);
|
returnMap.put("key", secret);
|
||||||
returnMap.put("uri", uri.toString());
|
returnMap.put("uri", uri.toString());
|
||||||
|
@ -98,11 +96,11 @@ public class CentralMemberTotpService implements MemberTotpService {
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatLabel(String issuer, String accountName) throws OverflowException {
|
private String formatLabel(String issuer, String accountName) throws OverflowException {
|
||||||
if(accountName != null && accountName.trim().length() != 0) {
|
if (accountName != null && accountName.trim().length() != 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if(issuer != null) {
|
if (issuer != null) {
|
||||||
if(issuer.contains(":")) {
|
if (issuer.contains(":")) {
|
||||||
throw new IllegalArgumentException("Issuer cannot contain the ':' character.");
|
throw new IllegalArgumentException("Issuer cannot contain the ':' character.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@ import com.loafle.overflow.service.central.domain.DomainMemberService;
|
||||||
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
|
import com.loafle.overflow.service.central.noauthprobe.NoAuthProbeService;
|
||||||
import com.loafle.overflow.service.central.probe.ProbeService;
|
import com.loafle.overflow.service.central.probe.ProbeService;
|
||||||
|
|
||||||
import org.codehaus.jackson.JsonParseException;
|
|
||||||
import org.codehaus.jackson.map.JsonMappingException;
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.codehaus.jackson.type.TypeReference;
|
import org.codehaus.jackson.type.TypeReference;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
package com.loafle.overflow.central.module.target.service;
|
package com.loafle.overflow.central.module.target.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.infra.service.*;
|
import com.loafle.overflow.central.module.infra.service.*;
|
||||||
|
import com.loafle.overflow.model.infra.InfraService;
|
||||||
|
import com.loafle.overflow.service.central.infra.InfraHostService;
|
||||||
|
import com.loafle.overflow.service.central.infra.InfraMachineService;
|
||||||
|
import com.loafle.overflow.service.central.infra.InfraOSPortService;
|
||||||
|
import com.loafle.overflow.service.central.infra.InfraOSService;
|
||||||
|
import com.loafle.overflow.service.central.infra.InfraServiceService;
|
||||||
import com.loafle.overflow.service.central.target.TargetService;
|
import com.loafle.overflow.service.central.target.TargetService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -25,7 +31,7 @@ public class TargetDiscoveryService {
|
||||||
private InfraHostService infraHostService;
|
private InfraHostService infraHostService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private com.loafle.overflow.central.module.infra.service.InfraService infraService;
|
private InfraService infraService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InfraOSPortService infraOSPortService;
|
private InfraOSPortService infraOSPortService;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.loafle.overflow.central.module.member.service;
|
package com.loafle.overflow.central.module.member.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
import com.loafle.overflow.central.module.member.model.MemberTotp;
|
|
||||||
import com.loafle.overflow.central.module.meta.model.MetaMemberStatus;
|
|
||||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||||
|
import com.loafle.overflow.model.member.Member;
|
||||||
|
import com.loafle.overflow.service.central.member.MemberService;
|
||||||
|
import com.loafle.overflow.service.central.member.MemberTotpService;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.loafle.overflow.central.module.member.service;
|
package com.loafle.overflow.central.module.member.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.module.member.model.Member;
|
|
||||||
import com.loafle.overflow.central.module.member.model.MemberTotp;
|
|
||||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||||
|
import com.loafle.overflow.model.member.Member;
|
||||||
|
import com.loafle.overflow.model.member.MemberTotp;
|
||||||
|
import com.loafle.overflow.service.central.member.MemberTotpService;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user