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