From 43e5ae565a1f097e4861937b44c13644505d088d Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 28 Jun 2017 15:29:18 +0900 Subject: [PATCH 1/3] servicesssssssss --- .../module/infra/service/InfraService.java | 67 +++++++++++++++++++ .../module/sensor/service/SensorService.java | 15 +++++ .../service/TargetDiscoveryService.java | 8 +++ .../module/target/service/TargetService.java | 2 + 4 files changed, 92 insertions(+) create mode 100644 src/main/java/com/loafle/overflow/module/infra/service/InfraService.java create mode 100644 src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java diff --git a/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java new file mode 100644 index 0000000..0302f6d --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java @@ -0,0 +1,67 @@ +package com.loafle.overflow.module.infra.service; + +import com.loafle.overflow.module.infra.dao.*; +import com.loafle.overflow.module.infra.model.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by insanity on 17. 6. 28. + */ + +@Service +public class InfraService { + + @Autowired + InfraDAO infraDAO; + @Autowired + InfraMachineDAO infraMachineDAO; + @Autowired + InfraHostDAO infraHostDAO; + @Autowired + InfraOSDAO infraOSDAO; + @Autowired + InfraOSApplicationDAO infraOSApplicationDAO; + @Autowired + InfraOSDaemonDAO infraOSDaemonDAO; + @Autowired + InfraOSPortDAO infraOSPortDAO; + @Autowired + InfraServiceDAO infraServiceDAO; + + + public Infra regist(Infra infra) { + return this.infraDAO.save(infra); + } + + public InfraMachine registMachine(InfraMachine infraMachine) { + return this.infraMachineDAO.save(infraMachine); + } + + public InfraHost registHost(InfraHost infraHost) { + return this.infraHostDAO.save(infraHost); + } + + public InfraOS registOS(InfraOS infraOS) { + return this.infraOSDAO.save(infraOS); + } + public InfraOSApplication registOSApplication(InfraOSApplication infraOSApplication) { + return this.infraOSApplicationDAO.save(infraOSApplication); + } + public InfraOSDaemon registOSDaemon(InfraOSDaemon infraOSDaemon) { + return this.infraOSDaemonDAO.save(infraOSDaemon); + } + + public InfraOSPort registOSPort(InfraOSPort infraOSPort) { + return this.infraOSPortDAO.save(infraOSPort); + } + + public com.loafle.overflow.module.infra.model.InfraService registService(com.loafle.overflow.module.infra.model.InfraService infraService) { + return this.infraServiceDAO.save(infraService); + } + + public Infra read(String id) { + return this.infraDAO.findOne(Long.valueOf(id)); + } + +} diff --git a/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java index 291daf2..4b0711b 100644 --- a/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java +++ b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java @@ -1,15 +1,18 @@ package com.loafle.overflow.module.sensor.service; +import com.loafle.overflow.module.meta.model.MetaSensorStatus; import com.loafle.overflow.module.sensor.dao.SensorDAO; import com.loafle.overflow.module.sensor.model.Sensor; import com.loafle.overflow.module.target.model.Target; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import java.util.List; /** * Created by insanity on 17. 6. 28. */ +@Service public class SensorService { @Autowired @@ -30,4 +33,16 @@ public class SensorService { public void remove(Sensor sensor) { this.sensorDAO.delete(sensor); } + + public Sensor start(Sensor sensor) { + MetaSensorStatus status = new MetaSensorStatus((short)1); + sensor.setStatus(status); + return this.sensorDAO.save(sensor); + } + + public Sensor stop(Sensor sensor) { + MetaSensorStatus status = new MetaSensorStatus((short)2); + sensor.setStatus(status); + return this.sensorDAO.save(sensor); + } } diff --git a/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java b/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java new file mode 100644 index 0000000..8b9a100 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/target/service/TargetDiscoveryService.java @@ -0,0 +1,8 @@ +package com.loafle.overflow.module.target.service; + +/** + * Created by insanity on 17. 6. 28. + */ +public class TargetDiscoveryService { + +} diff --git a/src/main/java/com/loafle/overflow/module/target/service/TargetService.java b/src/main/java/com/loafle/overflow/module/target/service/TargetService.java index bca0f3e..8280516 100644 --- a/src/main/java/com/loafle/overflow/module/target/service/TargetService.java +++ b/src/main/java/com/loafle/overflow/module/target/service/TargetService.java @@ -4,12 +4,14 @@ import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.target.dao.TargetDAO; import com.loafle.overflow.module.target.model.Target; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import java.util.List; /** * Created by insanity on 17. 6. 28. */ +@Service public class TargetService { @Autowired From 4e9484758e3c169375afebe8133a2a588a2c0f2b Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 28 Jun 2017 15:36:19 +0900 Subject: [PATCH 2/3] member --- .../module/member/service/MemberService.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/com/loafle/overflow/module/member/service/MemberService.java diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java new file mode 100644 index 0000000..7e5551b --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -0,0 +1,59 @@ +package com.loafle.overflow.module.member.service; + +import com.loafle.overflow.module.member.dao.MemberDAO; +import com.loafle.overflow.module.member.model.Member; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by geek on 17. 6. 28. + */ +@Service +public class MemberService { + + @Autowired + private MemberDAO memberDAO; + + public Member signin(Member member) throws Exception { + Member m = this.memberDAO.findByEmail(member); + + if ( null == m ) { + return m; + } + + if ( m.getStatus().getId() == 1 ) { + throw new Exception("Email Auth Confirm Check"); + } + + // Todo member.pw m.pw compare + + return m; + } + + public Member signup(Member member) { + + + return this.memberDAO.save(member); + } + + public void signout(Member member) { + // Todo websocket session remove + } + + public Member modify(Member member) { + + return this.memberDAO.save(member); + } + + public Member read(long memberId) { + return this.memberDAO.findOne(memberId); + } + + public void withdrawal(Member member) { + // Todo DB delete? + } + + public void emailConfirm(Member member) { + + } +} From 081326b1ab3fcf8502a151a66e2ae783aad8ca21 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 28 Jun 2017 15:41:23 +0900 Subject: [PATCH 3/3] member password security --- .../loafle/overflow/module/member/model/Member.java | 11 ----------- .../overflow/module/member/service/MemberService.java | 8 ++++++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/member/model/Member.java b/src/main/java/com/loafle/overflow/module/member/model/Member.java index 18bb290..2d75fd3 100644 --- a/src/main/java/com/loafle/overflow/module/member/model/Member.java +++ b/src/main/java/com/loafle/overflow/module/member/model/Member.java @@ -15,7 +15,6 @@ public class Member { private long id; private String email; private String pw; - private String pwSalt; private String name; private String phone; private String companyName; @@ -59,16 +58,6 @@ public class Member { this.pw = pw; } - @Basic - @Column(name = "PW_SALT", nullable = true, length = 32) - public String getPwSalt() { - return pwSalt; - } - - public void setPwSalt(String pwSalt) { - this.pwSalt = pwSalt; - } - @Basic @Column(name = "NAME", nullable = true, length = 50) public String getName() { diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java index 7e5551b..4a22f14 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -3,6 +3,7 @@ package com.loafle.overflow.module.member.service; import com.loafle.overflow.module.member.dao.MemberDAO; import com.loafle.overflow.module.member.model.Member; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; /** @@ -13,6 +14,8 @@ public class MemberService { @Autowired private MemberDAO memberDAO; + @Autowired + private BCryptPasswordEncoder passwordEncoder; public Member signin(Member member) throws Exception { Member m = this.memberDAO.findByEmail(member); @@ -25,14 +28,15 @@ public class MemberService { throw new Exception("Email Auth Confirm Check"); } - // Todo member.pw m.pw compare + Boolean match = this.passwordEncoder.matches(member.getPw(), m.getPw()); + if(!match) return null; return m; } public Member signup(Member member) { - + member.setPw(this.passwordEncoder.encode(member.getPw())); return this.memberDAO.save(member); }