OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/java/kr/wisestone/owl/service/impl/ApiTokenServiceImpl.java
@@ -95,7 +95,12 @@
        ObjectMapper objectMapper = new ObjectMapper();
        //반환 타입은 LinkedHashMap 이다. 이를 User 타입으로 변환하기 위해 ObjectMapper 사용
        return objectMapper.convertValue(claims.getBody().get(DATA_KEY), UserVo.class);
        try {
            return objectMapper.convertValue(claims.getBody().get(DATA_KEY), UserVo.class);
        } catch (Exception ex) {
            log.debug(ex.getMessage());
        }
        return null;
    }
    private Jws<Claims> decryption(String jwt) {
@@ -119,9 +124,15 @@
    @Override
    public ApiTokenVo find() {
        User user = this.webAppUtil.getLoginUserObject();
        List<ApiToken> apiTokens = this.apiTokenRepository.findByUserId(user.getId());
        if (apiTokens != null && apiTokens.size() >0 ) {
            return ConvertUtil.copyProperties(apiTokens.get(0), ApiTokenVo.class);
        return this.find(user.getId());
    }
    private ApiTokenVo find(Long userId) {
        if (userId != null) {
            List<ApiToken> apiTokens = this.apiTokenRepository.findByUserId(userId);
            if (apiTokens != null && apiTokens.size() > 0) {
                return ConvertUtil.copyProperties(apiTokens.get(0), ApiTokenVo.class);
            }
        }
        return null;
    }
@@ -130,7 +141,7 @@
    @Override
    public UserVo certification(String token) {
         UserVo userVo = this.getUserVo(token);
         if (userVo != null){
         if (userVo != null && containsToken(userVo, token)){
             return userVo;
         } else  {
             throw new OwlRuntimeException(
@@ -138,6 +149,15 @@
         }
    }
    // 토큰 값이 db에 존재하는지 확인
    private boolean containsToken(UserVo userVo, String token) {
        List<ApiToken> apiTokens = this.apiTokenRepository.findByUserId(userVo.getId());
        if (apiTokens != null && apiTokens.size() > 0) {
            return apiTokens.get(0).getToken().equals(token);
        }
        return false;
    }
    // 토큰 삭제
    @Override
    public void remove(ApiTokenForm apiTokenForm) {