ing
This commit is contained in:
parent
389d62184f
commit
5dfb51e339
|
@ -0,0 +1,51 @@
|
|||
package com.loafle.overflow.central.commons.utils;
|
||||
|
||||
import io.grpc.Context;
|
||||
import io.grpc.Metadata;
|
||||
|
||||
import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
|
||||
|
||||
public class SessionMetadata {
|
||||
/*
|
||||
digits: 0-9
|
||||
uppercase letters: A-Z (normalized to lower)
|
||||
lowercase letters: a-z
|
||||
special characters: -_.
|
||||
*/
|
||||
|
||||
public static final String CLIENT_TYPE_KEY = "OVERFLOW_GRPC_CLIENT_TYPE";
|
||||
public static final String SESSION_ID_KEY = "OVERFLOW_GRPC_SESSION_ID";
|
||||
public static final String TARGET_ID_KEY = "OVERFLOW_GRPC_TARGET_ID";
|
||||
|
||||
public static final Context.Key<String> CTX_CLIENT_TYPE_KEY = Context.key(CLIENT_TYPE_KEY);
|
||||
public static final Context.Key<String> CTX_SESSION_ID_KEY = Context.key(SESSION_ID_KEY);
|
||||
public static final Context.Key<String> CTX_TARGET_ID_KEY = Context.key(TARGET_ID_KEY);
|
||||
|
||||
public static final Metadata.Key<String> METADATA_CLIENT_TYPE_KEY = Metadata.Key.of(CLIENT_TYPE_KEY, ASCII_STRING_MARSHALLER);
|
||||
public static final Metadata.Key<String> METADATA_SESSION_ID_KEY = Metadata.Key.of(SESSION_ID_KEY, ASCII_STRING_MARSHALLER);
|
||||
public static final Metadata.Key<String> METADATA_TARGET_ID_KEY = Metadata.Key.of(TARGET_ID_KEY, ASCII_STRING_MARSHALLER);
|
||||
|
||||
public static ClientType getClientType() {
|
||||
return ClientType.valueOf(CTX_CLIENT_TYPE_KEY.get());
|
||||
}
|
||||
public static String getSessionID() {
|
||||
return CTX_SESSION_ID_KEY.get();
|
||||
}
|
||||
public static String getTargetID() {
|
||||
return CTX_TARGET_ID_KEY.get();
|
||||
}
|
||||
|
||||
public static enum ClientType {
|
||||
MEMBER("MEMBER"),
|
||||
PROBE("PROBE");
|
||||
|
||||
final private String name;
|
||||
|
||||
private ClientType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class SensorConfigGenerator {
|
|||
private InfraServiceGenerator infraServiceGenerator;
|
||||
|
||||
|
||||
public String generate(Sensor sensor) throws OverflowException {
|
||||
public String generate(Sensor sensor) throws Exception {
|
||||
PageParams pageParams = new PageParams();
|
||||
pageParams.setPageNo(0);
|
||||
pageParams.setCountPerPage(Integer.MAX_VALUE);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraDAO;
|
||||
import com.loafle.overflow.core.model.PageParams;
|
||||
import com.loafle.overflow.model.domain.Domain;
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class EmailNotConfirmedException extends OverflowRuntimeException {
|
||||
public EmailNotConfirmedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EmailNotConfirmedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 23.
|
||||
*/
|
||||
public class EqualsOldPasswordException extends OverflowRuntimeException {
|
||||
public EqualsOldPasswordException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EqualsOldPasswordException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 18.
|
||||
*/
|
||||
public class JoinedEmailException extends OverflowRuntimeException {
|
||||
public JoinedEmailException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JoinedEmailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 11. 22.
|
||||
*/
|
||||
public class PasswordNotStrongException extends OverflowRuntimeException {
|
||||
public PasswordNotStrongException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PasswordNotStrongException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 15.
|
||||
*/
|
||||
public class SecretCodeNotExistException extends OverflowRuntimeException {
|
||||
public SecretCodeNotExistException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SecretCodeNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class SignInIdNotExistException extends OverflowRuntimeException {
|
||||
public SignInIdNotExistException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SignInIdNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class SignInPwNotMatchException extends OverflowRuntimeException {
|
||||
public SignInPwNotMatchException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SignInPwNotMatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 11. 23.
|
||||
*/
|
||||
public class SigninOverFailedException extends OverflowRuntimeException {
|
||||
public SigninOverFailedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SigninOverFailedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 15.
|
||||
*/
|
||||
public class TotpCodeNotMatchException extends OverflowRuntimeException {
|
||||
public TotpCodeNotMatchException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TotpCodeNotMatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.loafle.overflow.central.module.member.service;
|
|||
|
||||
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
|
||||
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.*;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.loafle.overflow.central.module.member.service;
|
||||
|
||||
import com.loafle.overflow.central.module.member.dao.MemberTotpDAO;
|
||||
import com.loafle.overflow.central.module.member.exception.SecretCodeNotExistException;
|
||||
import com.loafle.overflow.central.module.member.exception.SignInIdNotExistException;
|
||||
import com.loafle.overflow.central.module.member.exception.TotpCodeNotMatchException;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.member.Member;
|
||||
import com.loafle.overflow.model.member.MemberTotp;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.loafle.overflow.central.commons.service.MessagePublisher;
|
|||
import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
|
||||
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
|
||||
import com.loafle.overflow.central.commons.utils.GenerateKey;
|
||||
import com.loafle.overflow.central.commons.utils.SessionMetadata;
|
||||
import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.apikey.ApiKey;
|
||||
|
@ -19,6 +20,8 @@ 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;
|
||||
|
@ -99,12 +102,15 @@ public class CentralNoAuthProbeService implements NoAuthProbeService{
|
|||
probe.setAuthorizeMember(new Member(domainMember.getMember().getId()));
|
||||
probe.setStatus(new MetaProbeStatus((short)1));
|
||||
|
||||
Map<String, Object> objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference<HashMap<String,Object>>() {});
|
||||
Map<String, String> hostMap = (Map<String, String>)objMap.get("host");
|
||||
Map<String, String> netMap = (Map<String, String>)objMap.get("network");
|
||||
Map<String, Object> objMap = null;
|
||||
try {
|
||||
objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference<HashMap<String,Object>>() {});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, String> hostMap = (Map<String, String>) objMap.get("host");
|
||||
Map<String, String> netMap = (Map<String, String>) objMap.get("network");
|
||||
|
||||
// String dispName = noAuth.getHostName().isEmpty() ?
|
||||
// StringConvertor.intToIp(noAuth.getIpAddress()) : noAuth.getHostName();
|
||||
String dispName = hostMap.get("name");
|
||||
dispName += " probe";
|
||||
probe.setDisplayName(dispName);
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package com.loafle.overflow.central.module.probe.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 14.
|
||||
*/
|
||||
public class ProbeNotFoundException extends OverflowRuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ProbeNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProbeNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -70,7 +69,7 @@ public class CentralSensorService implements SensorService {
|
|||
Infra dbInfra = this.infraService.read(infraId);
|
||||
|
||||
if (dbInfra == null || dbInfra.getTarget() == null) {
|
||||
throw new InfraNotFoundException();
|
||||
throw new OverflowException("", new Throwable());
|
||||
}
|
||||
|
||||
return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams));
|
||||
|
@ -115,9 +114,11 @@ public class CentralSensorService implements SensorService {
|
|||
}
|
||||
|
||||
public String generateSensorConfig(Sensor sensor) throws OverflowException {
|
||||
|
||||
return this.sensorConfigGenerator.generate(sensor);
|
||||
|
||||
try {
|
||||
return this.sensorConfigGenerator.generate(sensor);
|
||||
} catch (Exception e) {
|
||||
throw new OverflowException("", new Throwable());
|
||||
}
|
||||
}
|
||||
|
||||
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user