Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,11 +127,7 @@ final class FilterOrderRegistration {
* @param position the position to associate with the {@link Filter}
*/
void put(Class<? extends Filter> filter, int position) {
String className = filter.getName();
if (this.filterToOrder.containsKey(className)) {
return;
}
this.filterToOrder.put(className, position);
this.filterToOrder.putIfAbsent(filter.getName(), position);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public Collection<GrantedAuthority> getAuthorities() {

@Override
public String getName() {
if (this.getPrincipal() instanceof UserDetails) {
return ((UserDetails) this.getPrincipal()).getUsername();
if (this.getPrincipal() instanceof UserDetails userDetails) {
return userDetails.getUsername();
}
if (this.getPrincipal() instanceof AuthenticatedPrincipal) {
return ((AuthenticatedPrincipal) this.getPrincipal()).getName();
if (this.getPrincipal() instanceof AuthenticatedPrincipal authenticatedPrincipal) {
return authenticatedPrincipal.getName();
}
if (this.getPrincipal() instanceof Principal) {
return ((Principal) this.getPrincipal()).getName();
if (this.getPrincipal() instanceof Principal principal) {
return principal.getName();
}
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
}
Expand Down Expand Up @@ -119,10 +119,9 @@ private void eraseSecret(Object secret) {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof AbstractAuthenticationToken)) {
if (!(obj instanceof AbstractAuthenticationToken test)) {
return false;
}
AbstractAuthenticationToken test = (AbstractAuthenticationToken) obj;
if (!this.authorities.equals(test.authorities)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public boolean equals(Object obj) {
if (!super.equals(obj)) {
return false;
}
if (obj instanceof AnonymousAuthenticationToken) {
AnonymousAuthenticationToken test = (AnonymousAuthenticationToken) obj;
if (obj instanceof AnonymousAuthenticationToken test) {
return (this.getKeyHash() == test.getKeyHash());
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public boolean isObserveOncePerRequest() {

/**
* Sets whether this filter apply only once per request. By default, this is
* <code>false</code>, meaning the filter will execute on every request. Sometimes
* <code>true</code>, meaning the filter will only execute once per request. Sometimes
* users may wish it to execute more than once per request, such as when JSP forwards
* are being used and filter security is desired on each included fragment of the HTTP
* request.
Expand All @@ -218,8 +218,7 @@ public void setObserveOncePerRequest(boolean observeOncePerRequest) {
}

/**
* If set to true, the filter will be applied to error dispatcher. Defaults to
* {@code true}.
* If set to true, the filter will be applied to error dispatcher. Defaults to false.
* @param filterErrorDispatch whether the filter should be applied to error dispatcher
*/
public void setFilterErrorDispatch(boolean filterErrorDispatch) {
Expand All @@ -228,7 +227,7 @@ public void setFilterErrorDispatch(boolean filterErrorDispatch) {

/**
* If set to true, the filter will be applied to the async dispatcher. Defaults to
* {@code true}.
* false.
* @param filterAsyncDispatch whether the filter should be applied to async dispatch
*/
public void setFilterAsyncDispatch(boolean filterAsyncDispatch) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 the original author or authors.
* Copyright 2010-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,10 +127,9 @@ protected Subject obtainSubject(ServletRequest request) {
if (!authentication.isAuthenticated()) {
return null;
}
if (!(authentication instanceof JaasAuthenticationToken)) {
if (!(authentication instanceof JaasAuthenticationToken token)) {
return null;
}
JaasAuthenticationToken token = (JaasAuthenticationToken) authentication;
LoginContext loginContext = token.getLoginContext();
if (loginContext == null) {
return null;
Expand Down