diff --git a/pom.xml b/pom.xml
index a6537d8..166263d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,7 @@
1.7
docker.loafle.net/overflow
1.1.2
+ 3.1.5
@@ -181,6 +182,12 @@
googleauth
${googleauth.version}
+
+
+ com.fasterxml.uuid
+ java-uuid-generator
+ ${ fasterxml.uuid.verion }
+
diff --git a/src/main/java/com/loafle/overflow/commons/utils/GenerateKey.java b/src/main/java/com/loafle/overflow/commons/utils/GenerateKey.java
new file mode 100644
index 0000000..fe7826b
--- /dev/null
+++ b/src/main/java/com/loafle/overflow/commons/utils/GenerateKey.java
@@ -0,0 +1,25 @@
+package com.loafle.overflow.commons.utils;
+
+import com.fasterxml.uuid.EthernetAddress;
+import com.fasterxml.uuid.Generators;
+import com.fasterxml.uuid.impl.TimeBasedGenerator;
+
+/**
+ * Created by geek on 18. 3. 27.
+ */
+public class GenerateKey {
+ private static TimeBasedGenerator generator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
+
+ public static synchronized String getKey() {
+
+ String[] uuids = generator.generate().toString().split("-");
+ StringBuffer sb = new StringBuffer();
+
+ for ( int idx = 0; idx < uuids.length; idx++ ) {
+ sb.append(uuids[idx]);
+ }
+
+ return sb.toString();
+ }
+
+}
diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
index 896c7d6..a2bff2b 100644
--- a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
+++ b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java
@@ -1,12 +1,17 @@
package com.loafle.overflow.module.noauthprobe.service;
+import com.loafle.overflow.commons.model.SessionMetadata;
import com.loafle.overflow.commons.service.MessagePublisher;
import com.loafle.overflow.commons.stereotype.ProbeAPI;
import com.loafle.overflow.commons.stereotype.WebappAPI;
+import com.loafle.overflow.commons.utils.GenerateKey;
import com.loafle.overflow.module.apikey.model.ApiKey;
import com.loafle.overflow.module.apikey.service.ApiKeyService;
import com.loafle.overflow.module.domain.model.Domain;
+import com.loafle.overflow.module.domain.model.DomainMember;
+import com.loafle.overflow.module.domain.service.DomainMemberService;
import com.loafle.overflow.module.member.model.Member;
+import com.loafle.overflow.module.member.service.MemberService;
import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus;
import com.loafle.overflow.module.meta.model.MetaProbeStatus;
import com.loafle.overflow.module.noauthprobe.dao.NoAuthProbeDAO;
@@ -46,15 +51,18 @@ public class NoAuthProbeService {
@Autowired
private MessagePublisher messagePublisher;
+ @Autowired
+ private DomainMemberService domainMemberService;
+
@ProbeAPI
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
- noAuthProbe.setTempProbeKey(UUID.randomUUID().toString());
- noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short)3));
-
ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey());
noAuthProbe.setDomain(apiKey.getDomain());
+ noAuthProbe.setTempProbeKey(GenerateKey.getKey());
+ noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short)3));
+
messagePublisher.publishToDomainMembers(apiKey.getDomain().getId(), "NoAuthProbeService.regist", noAuthProbe);
return this.noAuthProbeDAO.save(noAuthProbe);
@@ -72,18 +80,22 @@ public class NoAuthProbeService {
@WebappAPI
public List acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException {
+ String memberEmail = SessionMetadata.getTargetID();
// Todo domain injection & member injection
-
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString());
+ ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey());
+ DomainMember domainMember = domainMemberService.readByMemberEmail(memberEmail);
+
Probe probe = new Probe();
probe.setEncryptionKey(encryptKey);
- probe.setProbeKey(noAuthProbe.getApiKey());
- probe.setDomain(new Domain(1));
- probe.setAuthorizeMember(new Member(1));
+ probe.setProbeKey(GenerateKey.getKey());
+
+ probe.setDomain(new Domain(apiKey.getDomain().getId()));
+ probe.setAuthorizeMember(new Member(domainMember.getMember().getId()));
probe.setStatus(new MetaProbeStatus((short)1));
Map objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference>() {});
@@ -114,6 +126,7 @@ public class NoAuthProbeService {
@WebappAPI
public List denyNoauthProbe(NoAuthProbe noAuthProbe) {
+ noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2));
this.noAuthProbeDAO.save(noAuthProbe);
messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Deny");
diff --git a/src/main/resources/local/init.sql b/src/main/resources/local/init.sql
index 232c25b..7c74227 100644
--- a/src/main/resources/local/init.sql
+++ b/src/main/resources/local/init.sql
@@ -858,6 +858,12 @@ INSERT INTO public.meta_history_type (id,create_date,"name") VALUES (
INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES (
'loafle','2017-06-26 11:07:27.625','overflow@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
+INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES (
+'loafle','2017-06-26 11:07:27.625','insanity@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
+
+INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES (
+'loafle','2017-06-26 11:07:27.625','snoop@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
+
INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES (
'loafle','2017-06-26 11:07:27.625','geekdev@naver.com','geek','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2);
@@ -870,10 +876,23 @@ INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,memb
INSERT INTO public."domain" (create_date,"name") VALUES (
'2017-06-26 11:25:44.866','overFlow''s domain');
+INSERT INTO public."domain" (create_date,"name") VALUES (
+'2017-06-26 11:25:44.866','insanity''s domain');
+
+INSERT INTO public."domain" (create_date,"name") VALUES (
+'2017-06-26 11:25:44.866','snoop''s domain');
+
+INSERT INTO public."domain" (create_date,"name") VALUES (
+'2017-06-26 11:25:44.866','geek''s domain');
+
INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
'2017-06-26 11:27:43.023',1,1);
INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
-'2017-06-26 11:27:43.023',1,2);
+'2017-06-26 11:27:43.023',2,2);
+INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
+'2017-06-26 11:27:43.023',3,3);
+INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
+'2017-06-26 11:27:43.023',4,4);
-- Member TOTP Insert SQL
-- INSERT INTO public.member_totp (create_date, secret_code, update_date, member_id) VALUES(
@@ -884,6 +903,15 @@ INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1);
+INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
+'bf78f1f4319611e897713222d3c76cf6','2017-06-26 13:02:28.347',2);
+
+INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
+'05cf2947319911e898993222d3c76cf6','2017-06-26 13:02:28.347',3);
+
+INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
+'09c8c54f319911e8a41f3222d3c76cf6','2017-06-26 13:02:28.347',4);
+
INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,authorize_member_id,domain_id,status) VALUES (
'2017-08-21 14:48:31.563','192.168.1.0/24','2017-08-21 14:48:31.563','snoop probe','test probe 111111','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',1,1,1);