diff --git a/src/main/java/com/dispose/common/PrivacyHelper.java b/src/main/java/com/dispose/common/PrivacyHelper.java index b8966c61..eac15e40 100644 --- a/src/main/java/com/dispose/common/PrivacyHelper.java +++ b/src/main/java/com/dispose/common/PrivacyHelper.java @@ -56,10 +56,9 @@ public class PrivacyHelper { return username; } - if(username.length() < 8) { - return username.substring(0, username.length() / 2) + "****"; - } else { - return username.substring(0, 7) + "****"; - } + int showChars = Math.min(8, username.length() / 2 + 1); + showChars = Math.min(username.length(), showChars); + + return username.substring(0, showChars) + "****"; } } diff --git a/src/main/java/com/dispose/manager/DisposeDeviceManager.java b/src/main/java/com/dispose/manager/DisposeDeviceManager.java index a52053df..7c40709a 100644 --- a/src/main/java/com/dispose/manager/DisposeDeviceManager.java +++ b/src/main/java/com/dispose/manager/DisposeDeviceManager.java @@ -6,7 +6,6 @@ import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.MulReturnType; import com.github.pagehelper.PageInfo; -import java.lang.reflect.InvocationTargetException; import java.util.List; /** @@ -20,24 +19,16 @@ public interface DisposeDeviceManager { * * @param dev the dev * @return the mul return type - * @throws IllegalAccessException the illegal access exception - * @throws NoSuchMethodException the no such method exception - * @throws InvocationTargetException the invocation target exception */ - MulReturnType addDisposeDevice(DisposeDevice dev) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException; + MulReturnType addDisposeDevice(DisposeDevice dev); /** * Upgrade dispose device mul return type. * * @param dev the dev * @return the mul return type - * @throws IllegalAccessException the illegal access exception - * @throws NoSuchMethodException the no such method exception - * @throws InvocationTargetException the invocation target exception */ - MulReturnType upgradeDisposeDevice(DisposeDevice dev) throws IllegalAccessException, NoSuchMethodException, - InvocationTargetException; + MulReturnType upgradeDisposeDevice(DisposeDevice dev); /** * Change dispose device status mul return type. diff --git a/src/main/java/com/dispose/manager/impl/UserAccountManagerImpl.java b/src/main/java/com/dispose/manager/impl/UserAccountManagerImpl.java index 0b9613ba..0a24e1f0 100644 --- a/src/main/java/com/dispose/manager/impl/UserAccountManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/UserAccountManagerImpl.java @@ -415,33 +415,31 @@ public class UserAccountManagerImpl implements UserAccountManager { // 本机曾经登录过 if (userAccountCache.containsKey(token)) { user = userAccountCache.get(token); - - // 超时 - if(tokenTimeout(user.getLastAccess())) { - return ErrorCode.ERR_TOKENTIMEOUT; - } - - return ErrorCode.ERR_OK; - } else { user = userAccountMapper.getUserByToken(token); // 用户未登录或者已经注销 - if(user == null) { + if (user == null) { return ErrorCode.ERR_LOGOUT; } // 用户未登录或者已经注销 - if(user.getToken().length() == 0) { + if (user.getToken().length() == 0) { return ErrorCode.ERR_LOGOUT; } - - if(tokenTimeout(user.getLastAccess())) { - return ErrorCode.ERR_TOKENTIMEOUT; - } - - return ErrorCode.ERR_OK; } + + // 检测用户名是否匹配 + if(!user.getUsername().equals(username)) { + return ErrorCode.ERR_USERNOTFOUND; + } + + // 超时 + if (tokenTimeout(user.getLastAccess())) { + return ErrorCode.ERR_TOKENTIMEOUT; + } + + return ErrorCode.ERR_OK; } /** diff --git a/src/main/java/com/dispose/pojo/dto/protocol/base/ProtocolRespDTO.java b/src/main/java/com/dispose/pojo/dto/protocol/base/ProtocolRespDTO.java index 4e94ff15..3d64ced8 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/base/ProtocolRespDTO.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/base/ProtocolRespDTO.java @@ -60,7 +60,7 @@ public class ProtocolRespDTO extends BaseProtocolDTO { resp.setVer(ConstValue.Protocol.VERSION); resp.setCode(err.getHttpCode()); - resp.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode()); + resp.setCryptoType(crypto); resp.setTimeStamp(System.currentTimeMillis()); resp.setMsgContent(respMsg); diff --git a/src/main/java/com/dispose/pojo/dto/protocol/base/ValidGroups.java b/src/main/java/com/dispose/pojo/dto/protocol/base/ValidGroups.java index b2a44d92..4e790ba9 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/base/ValidGroups.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/base/ValidGroups.java @@ -1,17 +1,17 @@ package com.dispose.pojo.dto.protocol.base; /** - * The type Valid groups. + * The interface Valid groups. * * @author */ -public class ValidGroups { +public interface ValidGroups { /** * The interface Protocol common valid. * * @author */ - public interface ProtocolCommonValid { + interface ProtocolCommonValid { } /** @@ -19,7 +19,7 @@ public class ValidGroups { * * @author */ - public interface LoginReqValid extends LogoutReqValid { + interface LoginReqValid extends LogoutReqValid { } /** @@ -27,10 +27,15 @@ public class ValidGroups { * * @author */ - public interface LogoutReqValid extends ProtocolCommonValid { + interface LogoutReqValid extends ProtocolCommonValid { } - public interface UpgradeDeviceValid extends ProtocolCommonValid { + /** + * The interface Upgrade device valid. + * + * @author + */ + interface UpgradeDeviceValid extends ProtocolCommonValid { } /** @@ -38,7 +43,7 @@ public class ValidGroups { * * @author */ - public interface AddDeviceValid extends UpgradeDeviceValid { + interface AddDeviceValid extends UpgradeDeviceValid { } /** @@ -46,7 +51,7 @@ public class ValidGroups { * * @author */ - public interface IdArrayValid extends ProtocolCommonValid { + interface IdArrayValid extends ProtocolCommonValid { } /** @@ -54,6 +59,6 @@ public class ValidGroups { * * @author */ - public interface ExplicitIdArrayValid extends IdArrayValid{ + interface ExplicitIdArrayValid extends IdArrayValid { } } diff --git a/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java index 76a9ddd0..47009f96 100644 --- a/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeDeviceManagerServiceImpl.java @@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; @@ -45,7 +44,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ MulReturnType ret = disposeDeviceManager.addDisposeDevice(v); v.setId(ret.getSecondParam()); rspList.add(new MulReturnType<>(ret.getFirstParam(), v)); - } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + } catch (Exception e) { rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v)); } }); @@ -68,7 +67,7 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ MulReturnType ret = disposeDeviceManager.upgradeDisposeDevice(v); v.setId(ret.getSecondParam()); rspList.add(new MulReturnType<>(ret.getFirstParam(), v)); - } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + } catch (Exception e) { rspList.add(new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, v)); } }); @@ -89,7 +88,6 @@ public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerServ for (Long v : ids) { DisposeDevice dev = new DisposeDevice(); - MulReturnType ret = disposeDeviceManager.changeDisposeDeviceStatus(v, ObjectStatus.DELETED);