-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
base: main
Are you sure you want to change the base?
Cleanup #17801
Changes from 5 commits
23fa294
a96dbd8
82ac99f
8bf49d2
7c436a2
e08de06
f77e0b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
* and using the current URL minus the artifact and the corresponding value. | ||
* | ||
* @author Rob Winch | ||
* @author Ngoc Nhan | ||
*/ | ||
final class DefaultServiceAuthenticationDetails extends WebAuthenticationDetails | ||
implements ServiceAuthenticationDetails { | ||
|
@@ -70,14 +71,13 @@ public String getServiceUrl() { | |
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
if (super.equals(obj)) { | ||
return true; | ||
} | ||
if (!super.equals(obj) || !(obj instanceof DefaultServiceAuthenticationDetails)) { | ||
return false; | ||
if (obj instanceof DefaultServiceAuthenticationDetails that) { | ||
return this.serviceUrl.equals(that.getServiceUrl()); | ||
} | ||
ServiceAuthenticationDetails that = (ServiceAuthenticationDetails) obj; | ||
return this.serviceUrl.equals(that.getServiceUrl()); | ||
return false; | ||
} | ||
|
||
@Override | ||
|
@@ -100,7 +100,11 @@ public String toString() { | |
/** | ||
* If present, removes the artifactParameterName and the corresponding value from the | ||
* query String. | ||
* @param request | ||
* @param request the current {@link HttpServletRequest} to obtain the | ||
* {@link #getServiceUrl()} from. | ||
* @param artifactPattern the {@link Pattern} that will be used to clean up the query | ||
* string from containing the artifact name and value. This can be created using | ||
* {@link #createArtifactPattern(String)}. | ||
* @return the query String minus the artifactParameterName and the corresponding | ||
* value. | ||
*/ | ||
|
@@ -110,7 +114,7 @@ private String getQueryString(final HttpServletRequest request, final Pattern ar | |
return null; | ||
} | ||
String result = artifactPattern.matcher(query).replaceFirst(""); | ||
if (result.length() == 0) { | ||
if (result.isEmpty()) { | ||
return null; | ||
} | ||
// strip off the trailing & only if the artifact was the first query param | ||
|
@@ -121,8 +125,10 @@ private String getQueryString(final HttpServletRequest request, final Pattern ar | |
* Creates a {@link Pattern} that can be passed into the constructor. This allows the | ||
* {@link Pattern} to be reused for every instance of | ||
* {@link DefaultServiceAuthenticationDetails}. | ||
* @param artifactParameterName | ||
* @return | ||
* @param artifactParameterName the artifactParameterName that is removed from the | ||
* current URL. The result becomes the service url. Cannot be null and cannot be an | ||
* empty String. | ||
|
||
* @return a {@link Pattern} | ||
*/ | ||
static Pattern createArtifactPattern(String artifactParameterName) { | ||
Assert.hasLength(artifactParameterName, "artifactParameterName is expected to have a length"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
* | ||
* @author Luke Taylor | ||
* @author Evgeniy Cheban | ||
* @author Ngoc Nhan | ||
* @since 3.0 | ||
*/ | ||
public abstract class SecurityExpressionRoot implements SecurityExpressionOperations { | ||
|
@@ -167,7 +168,8 @@ public final boolean isFullyAuthenticated() { | |
/** | ||
* Convenience method to access {@link Authentication#getPrincipal()} from | ||
* {@link #getAuthentication()} | ||
* @return | ||
* @return the <code>Principal</code> being authenticated or the authenticated | ||
* principal after authentication. | ||
*/ | ||
public @Nullable Object getPrincipal() { | ||
return getAuthentication().getPrincipal(); | ||
|
@@ -228,15 +230,15 @@ public void setPermissionEvaluator(PermissionEvaluator permissionEvaluator) { | |
/** | ||
* Prefixes role with defaultRolePrefix if defaultRolePrefix is non-null and if role | ||
* does not already start with defaultRolePrefix. | ||
* @param defaultRolePrefix | ||
* @param role | ||
* @return | ||
* @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 (defaultRolePrefix == null || defaultRolePrefix.length() == 0) { | ||
if (defaultRolePrefix == null || defaultRolePrefix.isEmpty()) { | ||
|
||
return role; | ||
} | ||
if (role.startsWith(defaultRolePrefix)) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.