Skip to content

Commit

Permalink
be
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Nov 16, 2023
1 parent aece228 commit 6525cd8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e5d044 to 6baa8f
12 changes: 6 additions & 6 deletions src/main/java/com/rebuild/api/user/AuthTokenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public class AuthTokenManager {
* 生成 Token
*
* @param user
* @param expires
* @param seconds
* @param type
* @return
*/
protected static String generateToken(ID user, int expires, String type) {
protected static String generateToken(ID user, int seconds, String type) {
// Type,User,Time,Version
String desc = String.format("%s,%s,%d,v2",
ObjectUtils.defaultIfNull(type, TYPE_ACCESS_TOKEN),
ObjectUtils.defaultIfNull(user, UserService.SYSTEM_USER),
System.nanoTime());
String token = EncryptUtils.toSHA1Hex(desc);

Application.getCommonsCache().put(TOKEN_PREFIX + token, desc, expires);
Application.getCommonsCache().put(TOKEN_PREFIX + token, desc, seconds);
return token;
}

Expand All @@ -84,12 +84,12 @@ public static String generateCsrfToken() {
}

/**
* @param expires
* @param seconds
* @return
* @see #TYPE_CSRF_TOKEN
*/
public static String generateCsrfToken(int expires) {
return generateToken(null, expires, TYPE_CSRF_TOKEN);
public static String generateCsrfToken(int seconds) {
return generateToken(null, seconds, TYPE_CSRF_TOKEN);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/rebuild/web/commons/FileDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public static void setDownloadHeaders(HttpServletRequest request, HttpServletRes

// 火狐 Safari 中文名乱码问题
String UA = StringUtils.defaultIfBlank(request.getHeader("user-agent"), "").toUpperCase();
if (UA.contains("FIREFOX") || UA.contains("SAFARI")) {
if (UA.contains("FIREFOX") || UA.contains("SAFARI") || UA.contains("APPLEWEBKIT")) {
attname = CodecUtils.urlDecode(attname);
attname = new String(attname.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/rebuild/web/general/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,20 @@ public void reportGenerate(@PathVariable String entity,

if (AppUtils.isMobile(request)) {
String fileUrl = String.format(
"/filex/download/%s?temp=yes&_onceToken=%s&attname=%s",
CodecUtils.urlEncode(output.getName()), AuthTokenManager.generateOnceToken(null), fileName);
"/filex/download/%s?temp=yes&_csrfToken=%s&attname=%s",
CodecUtils.urlEncode(output.getName()), AuthTokenManager.generateCsrfToken(90), CodecUtils.urlEncode(fileName));
data.put("fileUrl", fileUrl);
}
writeSuccess(response, data);

} else if ("preview".equalsIgnoreCase(typeOutput)) {
String fileUrl = String.format(
"/filex/download/%s?temp=yes&_onceToken=%s&attname=%s",
CodecUtils.urlEncode(output.getName()), AuthTokenManager.generateOnceToken(null), fileName);
CodecUtils.urlEncode(output.getName()), AuthTokenManager.generateOnceToken(null), CodecUtils.urlEncode(fileName));
fileUrl = RebuildConfiguration.getHomeUrl(fileUrl);

String previewUrl = StringUtils.defaultIfBlank(
RebuildConfiguration.get(ConfigurationItem.PortalOfficePreviewUrl),
"https://view.officeapps.live.com/op/embed.aspx?src=");
RebuildConfiguration.get(ConfigurationItem.PortalOfficePreviewUrl), "https://view.officeapps.live.com/op/embed.aspx?src=");

previewUrl += CodecUtils.urlEncode(fileUrl);
response.sendRedirect(previewUrl);
Expand Down

0 comments on commit 6525cd8

Please sign in to comment.