This commit is contained in:
crusader 2018-06-13 20:12:35 +09:00
parent 588cca4212
commit d99a5a716b
4 changed files with 37 additions and 50 deletions

View File

@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId> <artifactId>commons-java</artifactId>
<version>1.0.57-SNAPSHOT</version> <version>1.0.58-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -90,11 +90,8 @@ public class CentralInfraService implements InfraService {
throw new OverflowException("Iface is not valid"); throw new OverflowException("Iface is not valid");
} }
MetaIPType metaIPType = new MetaIPType();
metaIPType.setKey(zone.getMetaIPTypeKey());
InfraHostIP infraHostIP = new InfraHostIP(); InfraHostIP infraHostIP = new InfraHostIP();
infraHostIP.setMetaIPType(metaIPType); infraHostIP.setMetaIPType(zone.getMetaIPType());
infraHostIP.setAddress(zone.getAddress()); infraHostIP.setAddress(zone.getAddress());
infraHostIP.setMac(zone.getMac()); infraHostIP.setMac(zone.getMac());
@ -137,22 +134,18 @@ public class CentralInfraService implements InfraService {
InfraZone infraZone = this.registByZone(probeID, zone); InfraZone infraZone = this.registByZone(probeID, zone);
MetaIPType metaIPType = new MetaIPType();
metaIPType.setKey(host.getMetaIPTypeKey());
InfraHostIP infraHostIP = new InfraHostIP(); InfraHostIP infraHostIP = new InfraHostIP();
infraHostIP.setMetaIPType(metaIPType); infraHostIP.setMetaIPType(host.getMetaIPType());
infraHostIP.setAddress(host.getAddress()); infraHostIP.setAddress(host.getAddress());
infraHostIP.setMac(host.getMac()); infraHostIP.setMac(host.getMac());
infraHostIP = infraHostIPService.validate(infraHostIP); infraHostIP = infraHostIPService.validate(infraHostIP);
metaIPType = infraHostIP.getMetaIPType();
InfraHostIP eInfraHostIP = this.infraHostIPService.readByInfraHostInfraZoneIDAndMetaIPTypeKeyAndAddress( InfraHostIP eInfraHostIP = this.infraHostIPService.readByInfraHostInfraZoneIDAndMetaIPTypeKeyAndAddress(
infraZone.getId(), metaIPType.getKey(), host.getAddress()); infraZone.getId(), infraHostIP.getMetaIPType().getKey(), host.getAddress());
if (null != eInfraHostIP) { if (null != eInfraHostIP) {
throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is exist already", host.getAddress(), throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is exist already", host.getAddress(),
metaIPType.getName(), infraZone.getNetwork())); infraHostIP.getMetaIPType().getName(), infraZone.getNetwork()));
} }
InfraHost infraHost = new InfraHost(); InfraHost infraHost = new InfraHost();
@ -174,13 +167,14 @@ public class CentralInfraService implements InfraService {
throw new OverflowException("Service is not valid"); throw new OverflowException("Service is not valid");
} }
if (null == service.getMetaCryptoTypeKey()) { if (null == service.getMetaCryptoType()) {
throw new OverflowException("MetaCryptoTypeKey is not valid"); throw new OverflowException("MetaCryptoType is not valid");
} }
MetaCryptoType metaCryptoType = this.metaCryptoTypeService.readByKey(service.getMetaCryptoTypeKey()); MetaCryptoType metaCryptoType = this.metaCryptoTypeService.readByKey(service.getMetaCryptoType().getKey());
if (null == metaCryptoType) { if (null == metaCryptoType) {
throw new OverflowException(String.format("MetaCryptoTypeKey[%s] is not valid", service.getMetaCryptoTypeKey())); throw new OverflowException(
String.format("MetaCryptoTypeKey[%s] is not valid", service.getMetaCryptoType().getKey()));
} }
Probe probe = this.probeService.read(probeID); Probe probe = this.probeService.read(probeID);
@ -203,43 +197,36 @@ public class CentralInfraService implements InfraService {
throw new OverflowException("Zone is not valid"); throw new OverflowException("Zone is not valid");
} }
MetaIPType metaIPType = new MetaIPType();
metaIPType.setKey(host.getMetaIPTypeKey());
InfraHostIP infraHostIP = new InfraHostIP(); InfraHostIP infraHostIP = new InfraHostIP();
infraHostIP.setMetaIPType(metaIPType); infraHostIP.setMetaIPType(host.getMetaIPType());
infraHostIP.setAddress(host.getAddress()); infraHostIP.setAddress(host.getAddress());
infraHostIP.setMac(host.getMac()); infraHostIP.setMac(host.getMac());
infraHostIP = this.infraHostIPService.validate(infraHostIP); infraHostIP = this.infraHostIPService.validate(infraHostIP);
metaIPType = infraHostIP.getMetaIPType();
MetaPortType metaPortType = new MetaPortType();
metaPortType.setKey(port.getMetaPortTypeKey());
InfraHostPort infraHostPort = new InfraHostPort(); InfraHostPort infraHostPort = new InfraHostPort();
infraHostPort.setMetaPortType(metaPortType); infraHostPort.setMetaPortType(port.getMetaPortType());
infraHostPort.setPort(port.getPortNumber()); infraHostPort.setPort(port.getPortNumber());
infraHostPort = this.infraHostPortService.validate(infraHostPort); infraHostPort = this.infraHostPortService.validate(infraHostPort);
metaPortType = infraHostPort.getMetaPortType();
InfraZone infraZone = this.registByZone(probeID, zone); InfraZone infraZone = this.registByZone(probeID, zone);
InfraHost infraHost = this.registByHost(probeID, host); InfraHost infraHost = this.registByHost(probeID, host);
infraHostIP = this.infraHostIPService.readByInfraHostIDAndMetaIPTypeKeyAndAddress(infraHost.getId(), InfraHostIP eInfraHostIP = this.infraHostIPService.readByInfraHostIDAndMetaIPTypeKeyAndAddress(infraHost.getId(),
metaIPType.getKey(), infraHostIP.getAddress()); infraHostIP.getMetaIPType().getKey(), infraHostIP.getAddress());
if (null == infraHostIP) { if (null == eInfraHostIP) {
throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is not exist", host.getAddress(), throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is not exist", host.getAddress(),
metaIPType.getName(), infraZone.getNetwork())); infraHostIP.getMetaIPType().getName(), infraZone.getNetwork()));
} }
infraHostIP = eInfraHostIP;
InfraHostPort eInfraHostPort = this.infraHostPortService InfraHostPort eInfraHostPort = this.infraHostPortService.readByInfraHostIDAndMetaPortTypeKeyAndPort(
.readByInfraHostIDAndMetaPortTypeKeyAndPort(infraHost.getId(), metaPortType.getKey(), infraHostPort.getPort()); infraHost.getId(), infraHostPort.getMetaPortType().getKey(), infraHostPort.getPort());
if (null != eInfraHostPort) { if (null != eInfraHostPort) {
throw new OverflowException( throw new OverflowException(String.format("Port[%d(%s)] of Zone[%s].Host[%s(%s)] is not exist", host.getAddress(),
String.format("Port[%d(%s)] of Zone[%s].Host[%s(%s)] is not exist", host.getAddress(), metaPortType.getName(), infraHostPort.getMetaPortType().getName(), infraZone.getNetwork(), infraHostIP.getAddress(),
infraZone.getNetwork(), infraHostIP.getAddress(), infraHostIP.getMetaIPType().getName())); infraHostIP.getMetaIPType().getName()));
} }
infraHostPort = this.infraHostPortService.regist(infraHostPort); infraHostPort = this.infraHostPortService.regist(infraHostPort);
@ -294,7 +281,8 @@ public class CentralInfraService implements InfraService {
return this.infraZoneDAO.save(infraZone); return this.infraZoneDAO.save(infraZone);
} }
public InfraHost registInfraHostByInfraHost(Long probeID, Long infraZoneID, InfraHost oriInfraHost) throws OverflowException { public InfraHost registInfraHostByInfraHost(Long probeID, Long infraZoneID, InfraHost oriInfraHost)
throws OverflowException {
InfraHost infraHost = new InfraHost(); InfraHost infraHost = new InfraHost();
infraHost.setProbe(new Probe(probeID)); infraHost.setProbe(new Probe(probeID));
infraHost.setInfraZone(new InfraZone(infraZoneID)); infraHost.setInfraZone(new InfraZone(infraZoneID));
@ -302,7 +290,8 @@ public class CentralInfraService implements InfraService {
InfraHostOS infraHostOS = oriInfraHost.getInfraHostOS(); InfraHostOS infraHostOS = oriInfraHost.getInfraHostOS();
if (null != infraHostOS) { if (null != infraHostOS) {
// MetaTargetHostType metaTargetHostType = this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS); // MetaTargetHostType metaTargetHostType =
// this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS);
infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
infraHost.setInfraHostOS(infraHostOS); infraHost.setInfraHostOS(infraHostOS);
} else { } else {

View File

@ -59,7 +59,7 @@ public class CentralMemberService implements MemberService {
throw new OverflowException("EmailNotConfirmedException()", new Throwable()); throw new OverflowException("EmailNotConfirmedException()", new Throwable());
} }
Boolean match = passwordEncoder.matches(signinPw, m.getPw()); Boolean match = passwordEncoder.matches(signinPw, m.getPassword());
if (!match) { if (!match) {
if (m.getSigninFailCount() > 10) { if (m.getSigninFailCount() > 10) {
throw new OverflowException("SigninOverFailedException()", new Throwable()); throw new OverflowException("SigninOverFailedException()", new Throwable());
@ -95,7 +95,7 @@ public class CentralMemberService implements MemberService {
// "special character, lowercase letter, and number, " + // "special character, lowercase letter, and number, " +
// "and must be at least 6 characters long."); // "and must be at least 6 characters long.");
} }
member.setPw(passwordEncoder.encode(pw)); member.setPassword(passwordEncoder.encode(pw));
if (member.getMetaMemberStatus() == null) { if (member.getMetaMemberStatus() == null) {
member.setMetaMemberStatus(new MetaMemberStatus((short) 1)); member.setMetaMemberStatus(new MetaMemberStatus((short) 1));
@ -162,7 +162,7 @@ public class CentralMemberService implements MemberService {
// "special character, lowercase letter, and number, " + // "special character, lowercase letter, and number, " +
// "and must be at least 6 characters long."); // "and must be at least 6 characters long.");
} }
member.setPw(passwordEncoder.encode(pw)); member.setPassword(passwordEncoder.encode(pw));
return this.modify(member); return this.modify(member);
} }
@ -178,7 +178,6 @@ public class CentralMemberService implements MemberService {
return this.domainMemberService.readAllMemberByDomainID(probe.getDomain().getId()); return this.domainMemberService.readAllMemberByDomainID(probe.getDomain().getId());
} }
public void signout(Member member) { public void signout(Member member) {
// Todo websocket session remove // Todo websocket session remove
} }
@ -201,12 +200,12 @@ public class CentralMemberService implements MemberService {
// "and must be at least 6 characters long."); // "and must be at least 6 characters long.");
} }
Boolean match = passwordEncoder.matches(member.getPw(), preMember.getPw()); Boolean match = passwordEncoder.matches(member.getPassword(), preMember.getPassword());
if (!match) { if (!match) {
member.setPw(passwordEncoder.encode(pw)); member.setPassword(passwordEncoder.encode(pw));
} }
} else { } else {
member.setPw(preMember.getPw()); member.setPassword(preMember.getPassword());
} }
if (member.getMetaMemberStatus() == null || member.getMetaMemberStatus().getId() <= 0) { if (member.getMetaMemberStatus() == null || member.getMetaMemberStatus().getId() <= 0) {
@ -224,7 +223,7 @@ public class CentralMemberService implements MemberService {
Member preMember = this.memberDAO.findByEmail(signinId); Member preMember = this.memberDAO.findByEmail(signinId);
String encodePw = passwordEncoder.encode(signinPw); String encodePw = passwordEncoder.encode(signinPw);
Boolean match = passwordEncoder.matches(encodePw, preMember.getPw()); Boolean match = passwordEncoder.matches(encodePw, preMember.getPassword());
if (!match) { if (!match) {
throw new OverflowException("SignInPwNotMatchException", new Throwable()); throw new OverflowException("SignInPwNotMatchException", new Throwable());
@ -260,7 +259,6 @@ public class CentralMemberService implements MemberService {
// Todo DB delete? // Todo DB delete?
} }
public List<Member> readAllByApiKey(String apikey) throws OverflowException { public List<Member> readAllByApiKey(String apikey) throws OverflowException {
ApiKey apiKey = this.apiKeyService.readByApiKey(apikey); ApiKey apiKey = this.apiKeyService.readByApiKey(apikey);

View File

@ -869,16 +869,16 @@ INSERT INTO meta_sensor_display_mapping (id,meta_sensor_display_item_id,meta_sen
INSERT INTO public."member" (company_name,email,"name",phone,pw,meta_member_status_id) VALUES ( INSERT INTO public."member" (company_name,email,"name",phone,password,meta_member_status_id) VALUES (
'loafle','overflow@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); 'loafle','overflow@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
INSERT INTO public."member" (company_name,email,"name",phone,pw,meta_member_status_id) VALUES ( INSERT INTO public."member" (company_name,email,"name",phone,password,meta_member_status_id) VALUES (
'loafle','insanity@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); 'loafle','insanity@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
INSERT INTO public."member" (company_name,email,"name",phone,pw,meta_member_status_id) VALUES ( INSERT INTO public."member" (company_name,email,"name",phone,password,meta_member_status_id) VALUES (
'loafle','snoop@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); 'loafle','snoop@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
INSERT INTO public."member" (company_name,email,"name",phone,pw,meta_member_status_id) VALUES ( INSERT INTO public."member" (company_name,email,"name",phone,password,meta_member_status_id) VALUES (
'loafle','geekdev@naver.com','geek','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); 'loafle','geekdev@naver.com','geek','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
INSERT INTO public.email_auth (auth_confirm_date,email_auth_key,member_id, meta_email_type_id) VALUES ( INSERT INTO public.email_auth (auth_confirm_date,email_auth_key,member_id, meta_email_type_id) VALUES (