Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
2ade309f
Unverified
Commit
2ade309f
authored
Nov 04, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#12932 Cookie
parent
3042f0e6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
25 deletions
+4
-25
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+0
-1
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
...in/java/org/b3log/solo/processor/console/SkinConsole.java
+0
-2
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+1
-5
src/main/java/org/b3log/solo/util/Solos.java
src/main/java/org/b3log/solo/util/Solos.java
+3
-17
No files found.
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
2ade309f
...
...
@@ -127,7 +127,6 @@ public class IndexProcessor {
cookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
specifiedSkin
);
}
cookie
.
setMaxAge
(
60
*
60
);
// 1 hour
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
...
...
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
View file @
2ade309f
...
...
@@ -166,11 +166,9 @@ public class SkinConsole {
final
Response
response
=
context
.
getResponse
();
final
Cookie
skinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_SKIN
,
skin
.
getString
(
Option
.
ID_C_SKIN_DIR_NAME
));
skinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
skinDirNameCookie
.
setPath
(
"/"
);
response
.
addCookie
(
skinDirNameCookie
);
final
Cookie
mobileSkinDirNameCookie
=
new
Cookie
(
Common
.
COOKIE_NAME_MOBILE_SKIN
,
skin
.
getString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
));
mobileSkinDirNameCookie
.
setMaxAge
(
60
*
60
);
// 1 hour
mobileSkinDirNameCookie
.
setPath
(
"/"
);
response
.
addCookie
(
mobileSkinDirNameCookie
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
...
...
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
2ade309f
...
...
@@ -178,23 +178,19 @@ public class StatisticMgmtService {
final
StringBuilder
builder
=
new
StringBuilder
(
"["
).
append
(
"\""
).
append
(
request
.
getRequestURI
()).
append
(
"\"]"
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
builder
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
else
if
(
needToAppend
)
{
cookieJSONArray
.
put
(
request
.
getRequestURI
());
final
Cookie
c
=
new
Cookie
(
"visited"
,
URLs
.
encode
(
cookieJSONArray
.
toString
()));
c
.
setMaxAge
(
COOKIE_EXPIRY
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Parses cookie failed, clears the cookie[name=visited]"
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
null
);
final
Cookie
c
=
new
Cookie
(
"visited"
,
""
);
c
.
setMaxAge
(
0
);
c
.
setPath
(
"/"
);
response
.
addCookie
(
c
);
}
...
...
src/main/java/org/b3log/solo/util/Solos.java
View file @
2ade309f
...
...
@@ -46,7 +46,7 @@ import java.util.*;
* Solo utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.9.0.
2, Sep 22
, 2019
* @version 1.9.0.
3, Nov 4
, 2019
* @since 2.8.0
*/
public
final
class
Solos
{
...
...
@@ -81,11 +81,6 @@ public final class Solos {
*/
public
static
final
String
COOKIE_SECRET
;
/**
* Cookie HTTP only.
*/
public
static
final
boolean
COOKIE_HTTP_ONLY
;
static
{
ResourceBundle
solo
;
try
{
...
...
@@ -115,8 +110,6 @@ public final class Solos {
cookieSecret
=
RandomStringUtils
.
randomAlphanumeric
(
8
);
}
COOKIE_SECRET
=
cookieSecret
;
COOKIE_HTTP_ONLY
=
Boolean
.
valueOf
(
Latkes
.
getLocalProperty
(
"cookieHttpOnly"
));
}
/**
...
...
@@ -273,17 +266,13 @@ public final class Solos {
final
String
tokenVal
=
cookieJSONObject
.
optString
(
Keys
.
TOKEN
);
final
String
token
=
StringUtils
.
substringBeforeLast
(
tokenVal
,
":"
);
if
(
StringUtils
.
equals
(
b3Key
,
token
))
{
login
(
user
,
response
);
return
user
;
}
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
TRACE
,
"Parses cookie failed, clears the cookie [name="
+
COOKIE_NAME
+
"]"
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
null
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
...
...
@@ -306,9 +295,7 @@ public final class Solos {
cookieJSONObject
.
put
(
Keys
.
TOKEN
,
b3Key
+
":"
+
random
);
final
String
cookieValue
=
Crypts
.
encryptByAES
(
cookieJSONObject
.
toString
(),
COOKIE_SECRET
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
cookieValue
);
cookie
.
setPath
(
"/"
);
cookie
.
setMaxAge
(
COOKIE_EXPIRY
);
cookie
.
setHttpOnly
(
COOKIE_HTTP_ONLY
);
response
.
addCookie
(
cookie
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Can not write cookie"
,
e
);
...
...
@@ -324,9 +311,8 @@ public final class Solos {
*/
public
static
void
logout
(
final
Request
request
,
final
Response
response
)
{
if
(
null
!=
response
)
{
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
null
);
final
Cookie
cookie
=
new
Cookie
(
COOKIE_NAME
,
""
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment