diff --git a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java index d8b47df..3e0c8a4 100644 --- a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java +++ b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberService.java @@ -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); diff --git a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberTotpService.java b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberTotpService.java index fc7e2dd..23fbc02 100644 --- a/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberTotpService.java +++ b/src/main/java/com/loafle/overflow/central/module/member/service/CentralMemberTotpService.java @@ -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 createTotp(Member member) throws OverflowException { + public Map createTotp(Member member) throws OverflowException { Map returnMap = new HashMap<>(); GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(); final GoogleAuthenticatorKey key = googleAuthenticator.createCredentials(); String secret = key.getKey(); -// List 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 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."); } diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java index fcc5188..a41e911 100644 --- a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/CentralNoAuthProbeService.java @@ -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; diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java index 14dd65c..efb7195 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java +++ b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java @@ -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; diff --git a/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java index 3d12b64..5b4c02b 100644 --- a/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java @@ -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; diff --git a/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java b/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java index 840d6a9..39dcb5e 100644 --- a/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java @@ -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;