|
@@ -14,8 +14,11 @@ import cn.com.qmth.stmms.common.enums.Role;
|
|
import cn.com.qmth.stmms.common.enums.SystemAuthType;
|
|
import cn.com.qmth.stmms.common.enums.SystemAuthType;
|
|
import cn.com.qmth.stmms.common.utils.AesUtils;
|
|
import cn.com.qmth.stmms.common.utils.AesUtils;
|
|
import cn.com.qmth.stmms.common.utils.Encodes;
|
|
import cn.com.qmth.stmms.common.utils.Encodes;
|
|
|
|
+
|
|
import com.qmth.boot.tools.models.ByteArray;
|
|
import com.qmth.boot.tools.models.ByteArray;
|
|
|
|
+
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
|
|
+
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -30,6 +33,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -85,7 +89,8 @@ public class SystemAuthController extends BaseController {
|
|
@Logging(menu = "修改授权配置", type = LogType.UPDATE)
|
|
@Logging(menu = "修改授权配置", type = LogType.UPDATE)
|
|
@RoleRequire(Role.SYS_ADMIN)
|
|
@RoleRequire(Role.SYS_ADMIN)
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
|
- public String update(HttpServletRequest request, SystemAuth systemAuth, MultipartFile file) {
|
|
|
|
|
|
+ public String update(HttpServletRequest request, RedirectAttributes redirectAttributes, SystemAuth systemAuth,
|
|
|
|
+ MultipartFile file) {
|
|
if (SystemAuthType.ONLINE.equals(systemAuth.getType())) {
|
|
if (SystemAuthType.ONLINE.equals(systemAuth.getType())) {
|
|
SolarHttpUtil httpUtil = new SolarHttpUtil(systemAuth.getAccessKey(), systemAuth.getAccessSecret(), host,
|
|
SolarHttpUtil httpUtil = new SolarHttpUtil(systemAuth.getAccessKey(), systemAuth.getAccessSecret(), host,
|
|
uri);
|
|
uri);
|
|
@@ -101,6 +106,7 @@ public class SystemAuthController extends BaseController {
|
|
authCache.setAuth(false);
|
|
authCache.setAuth(false);
|
|
authCache.setDoubleTrack(false);
|
|
authCache.setDoubleTrack(false);
|
|
authCache.setExpireTime(null);
|
|
authCache.setExpireTime(null);
|
|
|
|
+ addMessage(redirectAttributes, "授权验证失败");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
@@ -108,7 +114,12 @@ public class SystemAuthController extends BaseController {
|
|
JSONObject json = AppLicenseUtil.parseLicense(ByteArray.fromInputStream(file.getInputStream()).value());
|
|
JSONObject json = AppLicenseUtil.parseLicense(ByteArray.fromInputStream(file.getInputStream()).value());
|
|
authCache.parseJson(json);
|
|
authCache.parseJson(json);
|
|
authService.save(systemAuth);
|
|
authService.save(systemAuth);
|
|
|
|
+ if (json == null) {
|
|
|
|
+ addMessage(redirectAttributes, "授权文件解析失败");
|
|
|
|
+ }
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
|
+ addMessage(redirectAttributes, "授权文件解析失败");
|
|
|
|
+ e.printStackTrace();
|
|
log.error("parseLicense error", e);
|
|
log.error("parseLicense error", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -134,4 +145,11 @@ public class SystemAuthController extends BaseController {
|
|
IOUtils.copy(new ByteArrayInputStream(data), response.getOutputStream());
|
|
IOUtils.copy(new ByteArrayInputStream(data), response.getOutputStream());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (String message : messages) {
|
|
|
|
+ sb.append(message).append(messages.length > 1 ? "<br/>" : "");
|
|
|
|
+ }
|
|
|
|
+ redirectAttributes.addFlashAttribute("message", sb.toString());
|
|
|
|
+ }
|
|
}
|
|
}
|