Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cleanup #17801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ngocnhan-tran1996 wants to merge 11 commits into spring-projects:main
base: main
Choose a base branch
Loading
from ngocnhan-tran1996:cleanup
Open

Cleanup #17801

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolve conflict
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
  • Loading branch information
commit 8f09d930c9b123c2007ab2dc5e69272265efe8db
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
import org.springframework.security.authorization.DefaultAuthorizationManagerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.function.SingletonSupplier;

/**
* Base root object for use in Spring Security expression evaluations.
*
* @author Luke Taylor
* @author Evgeniy Cheban
* @author Ngoc Nhan
* @author Steve Riesenberg
* @since 3.0
*/
public abstract class SecurityExpressionRoot<T extends @Nullable Object> implements SecurityExpressionOperations {
Expand Down Expand Up @@ -209,8 +208,7 @@ private boolean isGranted(AuthorizationManager<T> authorizationManager) {
/**
* Convenience method to access {@link Authentication#getPrincipal()} from
* {@link #getAuthentication()}
* @return the <code>Principal</code> being authenticated or the authenticated
* principal after authentication.
* @return
*/
public @Nullable Object getPrincipal() {
return getAuthentication().getPrincipal();
Expand Down Expand Up @@ -306,24 +304,4 @@ public void setPermissionEvaluator(PermissionEvaluator permissionEvaluator) {
this.permissionEvaluator = permissionEvaluator;
}

/**
* Prefixes role with defaultRolePrefix if defaultRolePrefix is non-null and if role
* does not already start with defaultRolePrefix.
* @param defaultRolePrefix the default prefix to add to roles.
* @param role the role that should be required.
* @return a {@code String} role
*/
private static String getRoleWithDefaultPrefix(@Nullable String defaultRolePrefix, String role) {
if (role == null) {
return role;
}
if (!StringUtils.hasLength(defaultRolePrefix)) {
return role;
}
if (role.startsWith(defaultRolePrefix)) {
return role;
}
return defaultRolePrefix + role;
}

}
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.springframework.security.web.util.UrlUtils;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.util.UriComponentsBuilder;

/**
Expand All @@ -59,7 +58,6 @@
* @author Andrey Grebnev
* @author Ben Alex
* @author Luke Taylor
* @author Ngoc Nhan
*/
public class DefaultSavedRequest implements SavedRequest {

Expand Down Expand Up @@ -195,65 +193,24 @@ private void addLocale(Locale locale) {
* @since 4.2
*/
private void addParameters(Map<String, String[]> parameters) {
if (ObjectUtils.isEmpty(parameters)) {
return;
}

for (Map.Entry<String, String[]> entry : parameters.entrySet()) {
String name = entry.getKey();
String[] values = entry.getValue();
if (values != null) {
this.parameters.put(name, values);
if (!ObjectUtils.isEmpty(parameters)) {
for (String paramName : parameters.keySet()) {
Object paramValues = parameters.get(paramName);
if (paramValues instanceof String[]) {
this.addParameter(paramName, (String[]) paramValues);
}
else {
logger.warn("ServletRequest.getParameterMap() returned non-String array");
}
}
}
}

/**
* Determines if the current request matches the <code>DefaultSavedRequest</code>.
* <p>
* All URL arguments are considered but not cookies, locales, headers or parameters.
* @param request the actual request to be matched against this one
* @param portResolver used to obtain the server port of the request
* @return true if the request is deemed to match this one.
* @deprecated This is deprecated for removal. Users can compare
* {@link #getRedirectUrl()} to the {@link HttpServletRequest} URL instead.
*/
@Deprecated(forRemoval = true)
public boolean doesRequestMatch(HttpServletRequest request, PortResolver portResolver) {
if (!propertyEquals(this.pathInfo, request.getPathInfo())) {
return false;
}
if (!propertyEquals(createQueryString(this.queryString, this.matchingRequestParameterName),
request.getQueryString())) {
return false;
}
if (!propertyEquals(this.requestURI, request.getRequestURI())) {
return false;
}
if (!"GET".equals(request.getMethod()) && "GET".equals(this.method)) {
// A save GET should not match an incoming non-GET method
return false;
}
if (!propertyEquals(this.serverPort, portResolver.getServerPort(request))) {
return false;
}
if (!propertyEquals(this.requestURL, request.getRequestURL().toString())) {
return false;
}
if (!propertyEquals(this.scheme, request.getScheme())) {
return false;
}
if (!propertyEquals(this.serverName, request.getServerName())) {
return false;
}
if (!propertyEquals(this.contextPath, request.getContextPath())) {
return false;
}
return propertyEquals(this.servletPath, request.getServletPath());

private void addParameter(String name, String[] values) {
this.parameters.put(name, values);
}

public String getContextPath() {
public @Nullable String getContextPath() {
return this.contextPath;
}

Expand Down Expand Up @@ -364,7 +321,7 @@ public String toString() {
if (matchingRequestParameterName == null) {
return queryString;
}
if (!StringUtils.hasLength(queryString)) {
if (queryString == null || queryString.length() == 0) {
return matchingRequestParameterName;
}
return UriComponentsBuilder.newInstance()
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.

AltStyle によって変換されたページ (->オリジナル) /