diff --git a/cache/src/main/java/org/apache/shiro/cache/AbstractCacheManager.java b/cache/src/main/java/org/apache/shiro/cache/AbstractCacheManager.java index 9f27fd6bb9..f3d7abd257 100644 --- a/cache/src/main/java/org/apache/shiro/cache/AbstractCacheManager.java +++ b/cache/src/main/java/org/apache/shiro/cache/AbstractCacheManager.java @@ -56,6 +56,7 @@ public AbstractCacheManager() { * @throws IllegalArgumentException if the {@code name} argument is {@code null} or does not contain text. * @throws CacheException if there is a problem lazily creating a {@code Cache} instance. */ + @Override @SuppressWarnings("unchecked") public Cache getCache(String name) throws IllegalArgumentException, CacheException { if (!StringUtils.hasText(name)) { @@ -92,6 +93,7 @@ public Cache getCache(String name) throws IllegalArgumentException, * * @throws Exception if any of the managed caches can't destroy properly. */ + @Override public void destroy() throws Exception { while (!caches.isEmpty()) { for (Cache cache : caches.values()) { @@ -101,6 +103,7 @@ public void destroy() throws Exception { } } + @Override public String toString() { Collection> values = caches.values(); StringBuilder sb = new StringBuilder(getClass().getSimpleName()) diff --git a/cache/src/main/java/org/apache/shiro/cache/MapCache.java b/cache/src/main/java/org/apache/shiro/cache/MapCache.java index 23a4e1641a..a55a95fc25 100644 --- a/cache/src/main/java/org/apache/shiro/cache/MapCache.java +++ b/cache/src/main/java/org/apache/shiro/cache/MapCache.java @@ -54,26 +54,32 @@ public MapCache(String name, Map backingMap) { this.map = backingMap; } + @Override public V get(K key) throws CacheException { return map.get(key); } + @Override public V put(K key, V value) throws CacheException { return map.put(key, value); } + @Override public V remove(K key) throws CacheException { return map.remove(key); } + @Override public void clear() throws CacheException { map.clear(); } + @Override public int size() { return map.size(); } + @Override public Set keys() { Set keys = map.keySet(); if (!keys.isEmpty()) { @@ -82,6 +88,7 @@ public Set keys() { return Collections.emptySet(); } + @Override public Collection values() { Collection values = map.values(); if (!values.isEmpty()) { @@ -90,6 +97,7 @@ public Collection values() { return Collections.emptyList(); } + @Override public String toString() { return new StringBuilder("MapCache '") .append(name).append("' (") diff --git a/config/core/src/main/java/org/apache/shiro/config/Ini.java b/config/core/src/main/java/org/apache/shiro/config/Ini.java index bc1a897ced..59b38c1115 100644 --- a/config/core/src/main/java/org/apache/shiro/config/Ini.java +++ b/config/core/src/main/java/org/apache/shiro/config/Ini.java @@ -112,6 +112,7 @@ public Ini(Ini defaults) { * @return {@code true} if no sections have been configured, or if there are sections, but the sections themselves * are all empty, {@code false} otherwise. */ + @Override public boolean isEmpty() { Collection
sections = this.sections.values(); if (!sections.isEmpty()) { @@ -445,6 +446,7 @@ protected static String getSectionName(String line) { return null; } + @Override public boolean equals(Object obj) { if (obj instanceof Ini ini) { return this.sections.equals(ini.sections); @@ -457,6 +459,7 @@ public int hashCode() { return this.sections.hashCode(); } + @Override public String toString() { if (this.sections == null || this.sections.isEmpty()) { return ""; @@ -474,26 +477,32 @@ public String toString() { } } + @Override public int size() { return this.sections.size(); } + @Override public boolean containsKey(Object key) { return this.sections.containsKey(key); } + @Override public boolean containsValue(Object value) { return this.sections.containsValue(value); } + @Override public Section get(Object key) { return this.sections.get(key); } + @Override public Section put(String key, Section value) { return this.sections.put(key, value); } + @Override public Section remove(Object key) { return this.sections.remove(key); } @@ -502,18 +511,22 @@ public void putAll(Map m) { this.sections.putAll(m); } + @Override public void clear() { this.sections.clear(); } + @Override public Set keySet() { return Collections.unmodifiableSet(this.sections.keySet()); } + @Override public Collection
values() { return Collections.unmodifiableCollection(this.sections.values()); } + @Override public Set> entrySet() { return Collections.unmodifiableSet(this.sections.entrySet()); } @@ -651,34 +664,42 @@ public String getName() { return this.name; } + @Override public void clear() { this.props.clear(); } + @Override public boolean containsKey(Object key) { return this.props.containsKey(key); } + @Override public boolean containsValue(Object value) { return this.props.containsValue(value); } + @Override public Set> entrySet() { return this.props.entrySet(); } + @Override public String get(Object key) { return this.props.get(key); } + @Override public boolean isEmpty() { return this.props.isEmpty(); } + @Override public Set keySet() { return this.props.keySet(); } + @Override public String put(String key, String value) { return this.props.put(key, value); } @@ -687,18 +708,22 @@ public void putAll(Map m) { this.props.putAll(m); } + @Override public String remove(Object key) { return this.props.remove(key); } + @Override public int size() { return this.props.size(); } + @Override public Collection values() { return this.props.values(); } + @Override public String toString() { String name = getName(); if (DEFAULT_SECTION_NAME.equals(name)) { diff --git a/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/InitializableBean.groovy b/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/InitializableBean.groovy index cc5d8f3d3d..ed25abdab3 100644 --- a/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/InitializableBean.groovy +++ b/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/InitializableBean.groovy @@ -30,6 +30,7 @@ class InitializableBean implements Initializable { public InitializableBean() {} + @Override public void init() throws ShiroException { initialized = true; } diff --git a/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/SimpleBeanFactory.groovy b/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/SimpleBeanFactory.groovy index 6026374737..2f79ac235e 100644 --- a/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/SimpleBeanFactory.groovy +++ b/config/ogdl/src/test/groovy/org/apache/shiro/config/ogdl/SimpleBeanFactory.groovy @@ -23,6 +23,7 @@ class SimpleBeanFactory implements org.apache.shiro.lang.util.Factory clazz) { if (mi == null) { throw new IllegalArgumentException("method argument cannot be null"); diff --git a/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java b/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java index db648904dc..906a7547f3 100644 --- a/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java +++ b/core/src/main/java/org/apache/shiro/authc/AbstractAuthenticator.java @@ -163,6 +163,7 @@ protected void notifyLogout(PrincipalCollection principals) { * * @param principals the identifying principals of the {@code Subject}/account logging out. */ + @Override public void onLogout(PrincipalCollection principals) { notifyLogout(principals); } @@ -187,6 +188,7 @@ public void onLogout(PrincipalCollection principals) { * @throws AuthenticationException if there is any problem during the authentication process - see the * interface's JavaDoc for a more detailed explanation. */ + @Override public final AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException { if (token == null) { diff --git a/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java b/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java index d8e01d76b0..9c53742acf 100644 --- a/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java +++ b/core/src/main/java/org/apache/shiro/authc/SimpleAccount.java @@ -220,6 +220,7 @@ public SimpleAccount(PrincipalCollection principals, Object credentials, Set getRoles() { return authzInfo.getRoles(); } @@ -326,6 +330,7 @@ public void addRole(Collection roles) { * * @return all String-based permissions assigned to this Account. */ + @Override public Collection getStringPermissions() { return authzInfo.getStringPermissions(); } @@ -364,6 +369,7 @@ public void addStringPermissions(Collection permissions) { * * @return all object-based permissions assigned directly to this Account (not any of its realms). */ + @Override public Collection getObjectPermissions() { return authzInfo.getObjectPermissions(); } @@ -445,6 +451,7 @@ public void setCredentialsExpired(boolean credentialsExpired) { * @param info the AuthenticationInfo to merge into this account. * @return this instance with the merged information from the specified argument. */ + @Override public AuthenticationInfo merge(AuthenticationInfo info) { authcInfo.merge(info); @@ -467,6 +474,7 @@ public AuthenticationInfo merge(AuthenticationInfo info) { * * @return principals.hashCode() if they are not null, 0 (zero) otherwise. */ + @Override public int hashCode() { return (getPrincipals() != null ? getPrincipals().hashCode() : 0); } @@ -479,6 +487,7 @@ public int hashCode() { * @return true if the specified object is also a {@link SimpleAccount SimpleAccount} and its * {@link #getPrincipals() principals} are equal to this object's principals, false otherwise. */ + @Override public boolean equals(Object o) { if (o == this) { return true; @@ -496,6 +505,7 @@ public boolean equals(Object o) { * * @return the String representation of this Account object. */ + @Override public String toString() { return getPrincipals() != null ? getPrincipals().toString() : "empty"; } diff --git a/core/src/main/java/org/apache/shiro/authc/UsernamePasswordToken.java b/core/src/main/java/org/apache/shiro/authc/UsernamePasswordToken.java index 21d76c56ec..79ab63cd54 100644 --- a/core/src/main/java/org/apache/shiro/authc/UsernamePasswordToken.java +++ b/core/src/main/java/org/apache/shiro/authc/UsernamePasswordToken.java @@ -257,6 +257,7 @@ public void setPassword(char[] password) { * @return the {@link #getUsername() username}. * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() */ + @Override public Object getPrincipal() { return getUsername(); } @@ -267,6 +268,7 @@ public Object getPrincipal() { * @return the {@link #getPassword() password} char array. * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() */ + @Override public Object getCredentials() { return getPassword(); } @@ -282,6 +284,7 @@ public Object getCredentials() { * explicitly omitted. * @since 1.0 */ + @Override public String getHost() { return host; } @@ -308,6 +311,7 @@ public void setHost(String host) { * across sessions, false otherwise (false by default). * @since 0.9 */ + @Override public boolean isRememberMe() { return rememberMe; } @@ -354,6 +358,7 @@ public void clear() { * @return the String representation of the UsernamePasswordToken, omitting * the password. */ + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); diff --git a/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java b/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java index ad1e5019d1..ea71a8ba85 100644 --- a/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java +++ b/core/src/main/java/org/apache/shiro/authc/credential/AllowAllCredentialsMatcher.java @@ -43,6 +43,7 @@ public class AllowAllCredentialsMatcher implements CredentialsMatcher { * @param info the account being verified for access * @return true always. (except for simulated credentials) */ + @Override public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { return info != SIMULATED_CREDENTIALS; } diff --git a/core/src/main/java/org/apache/shiro/authc/credential/SimpleCredentialsMatcher.java b/core/src/main/java/org/apache/shiro/authc/credential/SimpleCredentialsMatcher.java index a0f4713262..9350f0ea0b 100644 --- a/core/src/main/java/org/apache/shiro/authc/credential/SimpleCredentialsMatcher.java +++ b/core/src/main/java/org/apache/shiro/authc/credential/SimpleCredentialsMatcher.java @@ -130,6 +130,7 @@ protected boolean equals(Object tokenCredentials, Object accountCredentials) { * @return {@code true} if the provided token credentials are equal to the stored account credentials, * {@code false} otherwise */ + @Override public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { Object tokenCredentials = getCredentials(token); Object accountCredentials = getCredentials(info); diff --git a/core/src/main/java/org/apache/shiro/authc/pam/AbstractAuthenticationStrategy.java b/core/src/main/java/org/apache/shiro/authc/pam/AbstractAuthenticationStrategy.java index f93bc3cec7..47010fc616 100644 --- a/core/src/main/java/org/apache/shiro/authc/pam/AbstractAuthenticationStrategy.java +++ b/core/src/main/java/org/apache/shiro/authc/pam/AbstractAuthenticationStrategy.java @@ -47,6 +47,7 @@ public abstract class AbstractAuthenticationStrategy implements AuthenticationSt * which supports * aggregating account data across realms. */ + @Override public AuthenticationInfo beforeAllAttempts(Collection realms, AuthenticationToken token) throws AuthenticationException { return new SimpleAuthenticationInfo(); @@ -55,6 +56,7 @@ public AuthenticationInfo beforeAllAttempts(Collection realms, /** * Simply returns the aggregate method argument, without modification. */ + @Override public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException { return aggregate; @@ -64,6 +66,7 @@ public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, * Base implementation that will aggregate the specified singleRealmInfo into the * aggregateInfo and then returns the aggregate. Can be overridden by subclasses for custom behavior. */ + @Override public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException { @@ -113,6 +116,7 @@ protected AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo a /** * Simply returns the aggregate argument without modification. Can be overridden for custom behavior. */ + @Override public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException { return aggregate; diff --git a/core/src/main/java/org/apache/shiro/authc/pam/AllSuccessfulStrategy.java b/core/src/main/java/org/apache/shiro/authc/pam/AllSuccessfulStrategy.java index 31cb56ab1f..1666826203 100644 --- a/core/src/main/java/org/apache/shiro/authc/pam/AllSuccessfulStrategy.java +++ b/core/src/main/java/org/apache/shiro/authc/pam/AllSuccessfulStrategy.java @@ -53,6 +53,7 @@ public class AllSuccessfulStrategy extends AbstractAuthenticationStrategy { * {@link UnsupportedTokenException UnsupportedTokenException} to end the authentication * process immediately. If the realm does support the token, the info argument is returned immediately. */ + @Override public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo info) throws AuthenticationException { if (!realm.supports(token)) { @@ -76,6 +77,7 @@ public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, * realm did in fact authenticate successfully * */ + @Override public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo info, AuthenticationInfo aggregate, Throwable t) throws AuthenticationException { diff --git a/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java b/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java index c1928d583c..675391804b 100644 --- a/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java +++ b/core/src/main/java/org/apache/shiro/authc/pam/AtLeastOneSuccessfulStrategy.java @@ -51,6 +51,7 @@ private static boolean isEmpty(PrincipalCollection pc) { * is not null, and if either is null, throws an AuthenticationException to indicate * that none of the realms authenticated successfully. */ + @Override public AuthenticationInfo afterAllAttempts(AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException { //we know if one or more were able to successfully authenticate if the aggregated account object does not diff --git a/core/src/main/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategy.java b/core/src/main/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategy.java index 2845edf30d..b6380cf83a 100644 --- a/core/src/main/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategy.java +++ b/core/src/main/java/org/apache/shiro/authc/pam/FirstSuccessfulStrategy.java @@ -51,6 +51,7 @@ public boolean getStopAfterFirstSuccess() { * Returns {@code null} immediately, relying on this class's {@link #merge merge} implementation to return * only the first {@code info} object it encounters, ignoring all subsequent ones. */ + @Override public AuthenticationInfo beforeAllAttempts(Collection realms, AuthenticationToken token) throws AuthenticationException { return null; @@ -62,6 +63,7 @@ public AuthenticationInfo beforeAllAttempts(Collection realms, * Returns the aggregate method argument, without modification * otherwise. */ + @Override public AuthenticationInfo beforeAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo aggregate) throws AuthenticationException { if (getStopAfterFirstSuccess() && aggregate != null && !isEmpty(aggregate.getPrincipals())) { @@ -81,6 +83,7 @@ private static boolean isEmpty(PrincipalCollection pc) { * This logic ensures that the first valid info encountered is the one retained and all subsequent ones are ignored, * since this strategy mandates that only the info from the first successfully authenticated realm be used. */ + @Override protected AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate) { if (aggregate != null && !isEmpty(aggregate.getPrincipals())) { return aggregate; diff --git a/core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java b/core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java index b635ba1951..20e62cf89d 100644 --- a/core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java +++ b/core/src/main/java/org/apache/shiro/authc/pam/ModularRealmAuthenticator.java @@ -290,6 +290,7 @@ protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationTo * * @param principals the application-specific Subject/user identifier. */ + @Override public void onLogout(PrincipalCollection principals) { super.onLogout(principals); Collection realms = getRealms(); diff --git a/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java b/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java index 1c1b178b8a..5c48c5cf34 100644 --- a/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java +++ b/core/src/main/java/org/apache/shiro/authz/ModularRealmAuthorizer.java @@ -114,6 +114,7 @@ public PermissionResolver getPermissionResolver() { * {@link org.apache.shiro.authz.permission.PermissionResolverAware PermissionResolverAware} * interface. */ + @Override public void setPermissionResolver(PermissionResolver permissionResolver) { this.permissionResolver = permissionResolver; applyPermissionResolverToRealms(); @@ -168,6 +169,7 @@ public RolePermissionResolver getRolePermissionResolver() { * {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} * interface. */ + @Override public void setRolePermissionResolver(RolePermissionResolver rolePermissionResolver) { this.rolePermissionResolver = rolePermissionResolver; applyRolePermissionResolverToRealms(); @@ -221,6 +223,7 @@ protected void assertRealmsConfigured() throws IllegalStateException { * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} returns true, * false otherwise. */ + @Override public boolean isPermitted(PrincipalCollection principals, String permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { @@ -239,6 +242,7 @@ public boolean isPermitted(PrincipalCollection principals, String permission) { * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns true, * false otherwise. */ + @Override public boolean isPermitted(PrincipalCollection principals, Permission permission) { assertRealmsConfigured(); for (Realm realm : getRealms()) { @@ -257,6 +261,7 @@ public boolean isPermitted(PrincipalCollection principals, Permission permission * {@link #isPermittedAll(org.apache.shiro.subject.PrincipalCollection, String...)} call returns * true, false otherwise. */ + @Override public boolean[] isPermitted(PrincipalCollection principals, String... permissions) { assertRealmsConfigured(); if (permissions != null && permissions.length > 0) { @@ -274,6 +279,7 @@ public boolean[] isPermitted(PrincipalCollection principals, String... permissio * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, List)} call returns true, * false otherwise. */ + @Override public boolean[] isPermitted(PrincipalCollection principals, List permissions) { assertRealmsConfigured(); if (permissions != null && !permissions.isEmpty()) { @@ -293,6 +299,7 @@ public boolean[] isPermitted(PrincipalCollection principals, List pe * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String)} call returns true * for all of the specified string permissions, false otherwise. */ + @Override public boolean isPermittedAll(PrincipalCollection principals, String... permissions) { assertRealmsConfigured(); if (permissions != null && permissions.length > 0) { @@ -310,6 +317,7 @@ public boolean isPermittedAll(PrincipalCollection principals, String... permissi * {@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission)} call returns true * for all of the specified Permissions, false otherwise. */ + @Override public boolean isPermittedAll(PrincipalCollection principals, Collection permissions) { assertRealmsConfigured(); if (permissions != null && !permissions.isEmpty()) { @@ -326,6 +334,7 @@ public boolean isPermittedAll(PrincipalCollection principals, CollectionUnauthorizedException otherwise returns quietly. */ + @Override public void checkPermission(PrincipalCollection principals, String permission) throws AuthorizationException { assertRealmsConfigured(); if (!isPermitted(principals, permission)) { @@ -337,6 +346,7 @@ public void checkPermission(PrincipalCollection principals, String permission) t * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, Permission) isPermitted(permission)}, throws * an UnauthorizedException otherwise returns quietly. */ + @Override public void checkPermission(PrincipalCollection principals, Permission permission) throws AuthorizationException { assertRealmsConfigured(); if (!isPermitted(principals, permission)) { @@ -348,6 +358,7 @@ public void checkPermission(PrincipalCollection principals, Permission permissio * If !{@link #isPermitted(org.apache.shiro.subject.PrincipalCollection, String...) isPermitted(permission)}, * throws an UnauthorizedException otherwise returns quietly. */ + @Override public void checkPermissions(PrincipalCollection principals, String... permissions) throws AuthorizationException { assertRealmsConfigured(); if (permissions != null && permissions.length > 0) { @@ -362,6 +373,7 @@ public void checkPermissions(PrincipalCollection principals, String... permissio * all the given Permissions, throws * an UnauthorizedException otherwise returns quietly. */ + @Override public void checkPermissions(PrincipalCollection principals, Collection permissions) throws AuthorizationException { assertRealmsConfigured(); @@ -377,6 +389,7 @@ public void checkPermissions(PrincipalCollection principals, Collectiontrue, * false otherwise. */ + @Override public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { assertRealmsConfigured(); for (Realm realm : getRealms()) { @@ -394,6 +407,7 @@ public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { * Calls {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} for each role name in the specified * collection and places the return value from each call at the respective location in the returned array. */ + @Override public boolean[] hasRoles(PrincipalCollection principals, List roleIdentifiers) { assertRealmsConfigured(); if (roleIdentifiers != null && !roleIdentifiers.isEmpty()) { @@ -413,6 +427,7 @@ public boolean[] hasRoles(PrincipalCollection principals, List roleIdent * {@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String)} call returns true for * all roles specified, false otherwise. */ + @Override public boolean hasAllRoles(PrincipalCollection principals, Collection roleIdentifiers) { assertRealmsConfigured(); for (String roleIdentifier : roleIdentifiers) { @@ -427,6 +442,7 @@ public boolean hasAllRoles(PrincipalCollection principals, Collection ro * If !{@link #hasRole(org.apache.shiro.subject.PrincipalCollection, String) hasRole(role)}, throws * an UnauthorizedException otherwise returns quietly. */ + @Override public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException { assertRealmsConfigured(); if (!hasRole(principals, role)) { @@ -438,6 +454,7 @@ public void checkRole(PrincipalCollection principals, String role) throws Author * Calls {@link #checkRoles(PrincipalCollection principals, String... roles) * checkRoles(PrincipalCollection principals, String... roles) }. */ + @Override public void checkRoles(PrincipalCollection principals, Collection roles) throws AuthorizationException { //SHIRO-234 - roles.toArray() -> roles.toArray(new String[roles.size()]) if (roles != null && !roles.isEmpty()) { @@ -448,6 +465,7 @@ public void checkRoles(PrincipalCollection principals, Collection roles) /** * Calls {@link #checkRole(org.apache.shiro.subject.PrincipalCollection, String) checkRole} for each role specified. */ + @Override public void checkRoles(PrincipalCollection principals, String... roles) throws AuthorizationException { assertRealmsConfigured(); if (roles != null) { diff --git a/core/src/main/java/org/apache/shiro/authz/SimpleAuthorizationInfo.java b/core/src/main/java/org/apache/shiro/authz/SimpleAuthorizationInfo.java index 6fe99ff554..58365c7fe8 100644 --- a/core/src/main/java/org/apache/shiro/authz/SimpleAuthorizationInfo.java +++ b/core/src/main/java/org/apache/shiro/authz/SimpleAuthorizationInfo.java @@ -61,6 +61,7 @@ public SimpleAuthorizationInfo(Set roles) { this.roles = roles; } + @Override public Set getRoles() { return roles; } @@ -100,6 +101,7 @@ public void addRoles(Collection roles) { this.roles.addAll(roles); } + @Override public Set getStringPermissions() { return stringPermissions; } @@ -141,6 +143,7 @@ public void addStringPermissions(Collection permissions) { this.stringPermissions.addAll(permissions); } + @Override public Set getObjectPermissions() { return objectPermissions; } diff --git a/core/src/main/java/org/apache/shiro/authz/SimpleRole.java b/core/src/main/java/org/apache/shiro/authz/SimpleRole.java index addeccb739..a5152e46c5 100644 --- a/core/src/main/java/org/apache/shiro/authz/SimpleRole.java +++ b/core/src/main/java/org/apache/shiro/authz/SimpleRole.java @@ -94,10 +94,12 @@ public boolean isPermitted(Permission p) { return false; } + @Override public int hashCode() { return (getName() != null ? getName().hashCode() : 0); } + @Override public boolean equals(Object o) { if (o == this) { return true; @@ -109,6 +111,7 @@ public boolean equals(Object o) { return false; } + @Override public String toString() { return getName(); } diff --git a/core/src/main/java/org/apache/shiro/authz/aop/AnnotationsAuthorizingMethodInterceptor.java b/core/src/main/java/org/apache/shiro/authz/aop/AnnotationsAuthorizingMethodInterceptor.java index 69b63b9bec..f251baab2d 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/AnnotationsAuthorizingMethodInterceptor.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/AnnotationsAuthorizingMethodInterceptor.java @@ -93,6 +93,7 @@ public void setMethodInterceptors(Collection aamis = getMethodInterceptors(); diff --git a/core/src/main/java/org/apache/shiro/authz/aop/AuthenticatedAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/AuthenticatedAnnotationHandler.java index 3abf06e0c9..43131f252b 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/AuthenticatedAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/AuthenticatedAnnotationHandler.java @@ -49,6 +49,7 @@ public AuthenticatedAnnotationHandler() { * @throws org.apache.shiro.authz.UnauthenticatedException if the calling Subject has not yet * authenticated. */ + @Override public void assertAuthorized(Annotation a) throws UnauthenticatedException { if (a instanceof RequiresAuthentication && !getSubject().isAuthenticated()) { throw new UnauthenticatedException("The current Subject is not authenticated. Access denied."); diff --git a/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingAnnotationMethodInterceptor.java b/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingAnnotationMethodInterceptor.java index e49f4d02ba..6058a8a55a 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingAnnotationMethodInterceptor.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingAnnotationMethodInterceptor.java @@ -63,6 +63,7 @@ public AuthorizingAnnotationMethodInterceptor(AuthorizingAnnotationHandler handl * @throws org.apache.shiro.authz.AuthorizationException if the MethodInvocation is not allowed to proceed. * @throws Throwable if any other error occurs. */ + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { assertAuthorized(methodInvocation); return methodInvocation.proceed(); diff --git a/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingMethodInterceptor.java b/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingMethodInterceptor.java index c4fc450cb6..4739262fee 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingMethodInterceptor.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/AuthorizingMethodInterceptor.java @@ -34,6 +34,7 @@ public abstract class AuthorizingMethodInterceptor extends MethodInterceptorSupp * if authorization is allowed by first * calling {@link #assertAuthorized(org.apache.shiro.aop.MethodInvocation) assertAuthorized}. */ + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { assertAuthorized(methodInvocation); return methodInvocation.proceed(); diff --git a/core/src/main/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandler.java index 3366951843..64733b17d2 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/DenyAllAnnotationHandler.java @@ -49,6 +49,7 @@ public DenyAllAnnotationHandler() { * @param a the annotation to check for one or more roles * @throws UnauthorizedException when the DenyAll annotation is present */ + @Override public void assertAuthorized(Annotation a) throws UnauthorizedException { throw new UnauthenticatedException("Attempting to perform a denied operation."); } diff --git a/core/src/main/java/org/apache/shiro/authz/aop/GuestAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/GuestAnnotationHandler.java index 10e567741f..046518aa67 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/GuestAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/GuestAnnotationHandler.java @@ -55,6 +55,7 @@ public GuestAnnotationHandler() { * @param a the annotation to check for one or more roles * @throws org.apache.shiro.authz.AuthorizationException if the calling Subject is not a "guest". */ + @Override public void assertAuthorized(Annotation a) throws AuthorizationException { if (a instanceof RequiresGuest && getSubject().getPrincipal() != null) { throw new UnauthenticatedException("Attempting to perform a guest-only operation. The current Subject is " diff --git a/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java index d8cfb9031e..e96a113645 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java @@ -61,6 +61,7 @@ protected String[] getAnnotationValue(Annotation a) { * @throws org.apache.shiro.authz.AuthorizationException if the calling Subject does not have * the permission(s) necessary to continue access or execution. */ + @Override public void assertAuthorized(Annotation a) throws AuthorizationException { if (!(a instanceof RequiresPermissions)) { return; diff --git a/core/src/main/java/org/apache/shiro/authz/aop/RoleAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/RoleAnnotationHandler.java index 0cc8de0614..14fb68b3d5 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/RoleAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/RoleAnnotationHandler.java @@ -49,6 +49,7 @@ public RoleAnnotationHandler() { * @throws org.apache.shiro.authz.AuthorizationException if the calling Subject does not have the role(s) * necessary to proceed. */ + @Override public void assertAuthorized(Annotation a) throws AuthorizationException { if (!(a instanceof RequiresRoles)) { return; diff --git a/core/src/main/java/org/apache/shiro/authz/aop/UserAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/UserAnnotationHandler.java index 8061700d98..2eb929858e 100644 --- a/core/src/main/java/org/apache/shiro/authz/aop/UserAnnotationHandler.java +++ b/core/src/main/java/org/apache/shiro/authz/aop/UserAnnotationHandler.java @@ -56,6 +56,7 @@ public UserAnnotationHandler() { * @throws org.apache.shiro.authz.AuthorizationException if the calling Subject is not authenticated * or remembered via rememberMe services. */ + @Override public void assertAuthorized(Annotation a) throws AuthorizationException { if (a instanceof RequiresUser && getSubject().getPrincipal() == null) { throw new UnauthenticatedException("Attempting to perform a user-only operation. The current Subject is " diff --git a/core/src/main/java/org/apache/shiro/authz/permission/AllPermission.java b/core/src/main/java/org/apache/shiro/authz/permission/AllPermission.java index 5916067918..c53f4d69ee 100644 --- a/core/src/main/java/org/apache/shiro/authz/permission/AllPermission.java +++ b/core/src/main/java/org/apache/shiro/authz/permission/AllPermission.java @@ -41,6 +41,7 @@ public class AllPermission implements Permission, Serializable { * @param p the Permission to check for implies logic. * @return true always, indicating any Subject grated this permission can do anything. */ + @Override public boolean implies(Permission p) { return true; } diff --git a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java index 4a4ad19185..c9e0b88ded 100644 --- a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java +++ b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java @@ -198,6 +198,7 @@ protected void setParts(List> parts) { | M E T H O D S | ============================================*/ + @Override public boolean implies(Permission p) { // By default only supports comparisons with other WildcardPermissions if (!(p instanceof WildcardPermission)) { @@ -234,6 +235,7 @@ public boolean implies(Permission p) { return true; } + @Override public String toString() { StringBuilder buffer = new StringBuilder(); for (Set part : parts) { @@ -251,6 +253,7 @@ public String toString() { return buffer.toString(); } + @Override public boolean equals(Object o) { if (o instanceof WildcardPermission wp) { return parts.equals(wp.parts); @@ -258,6 +261,7 @@ public boolean equals(Object o) { return false; } + @Override public int hashCode() { return parts.hashCode(); } diff --git a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermissionResolver.java b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermissionResolver.java index 6bfb2d3a5f..3883fd1a90 100644 --- a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermissionResolver.java +++ b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermissionResolver.java @@ -75,6 +75,7 @@ public boolean isCaseSensitive() { * @return a new {@link WildcardPermission WildcardPermission} instance constructed based on the specified * permissionString */ + @Override public Permission resolvePermission(String permissionString) { return new WildcardPermission(permissionString, caseSensitive); } diff --git a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutor.java b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutor.java index d7e0769fd8..5d93b1404e 100644 --- a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutor.java +++ b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutor.java @@ -124,6 +124,7 @@ protected Runnable associateWithSubject(Runnable r) { * @param command the runnable to associate with the currently executing subject and then to execute via the target * {@code Executor} instance. */ + @Override public void execute(Runnable command) { Runnable associated = associateWithSubject(command); getTargetExecutor().execute(associated); diff --git a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java index 52fa28104c..0dc3987239 100644 --- a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java +++ b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java @@ -92,22 +92,27 @@ public void setTargetExecutor(Executor targetExecutor) { super.setTargetExecutor(targetExecutor); } + @Override public void shutdown() { this.targetExecutorService.shutdown(); } + @Override public List shutdownNow() { return this.targetExecutorService.shutdownNow(); } + @Override public boolean isShutdown() { return this.targetExecutorService.isShutdown(); } + @Override public boolean isTerminated() { return this.targetExecutorService.isTerminated(); } + @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { return this.targetExecutorService.awaitTermination(timeout, unit); } @@ -117,16 +122,19 @@ protected Callable associateWithSubject(Callable task) { return subject.associateWith(task); } + @Override public Future submit(Callable task) { Callable work = associateWithSubject(task); return this.targetExecutorService.submit(work); } + @Override public Future submit(Runnable task, T result) { Runnable work = associateWithSubject(task); return this.targetExecutorService.submit(work, result); } + @Override public Future submit(Runnable task) { Runnable work = associateWithSubject(task); return this.targetExecutorService.submit(work); @@ -141,22 +149,26 @@ protected Collection> associateWithSubject(Collection List> invokeAll(Collection> tasks) throws InterruptedException { Collection> workItems = associateWithSubject(tasks); return this.targetExecutorService.invokeAll(workItems); } + @Override public List> invokeAll(Collection> tasks, long timeout, TimeUnit unit) throws InterruptedException { Collection> workItems = associateWithSubject(tasks); return this.targetExecutorService.invokeAll(workItems, timeout, unit); } + @Override public T invokeAny(Collection> tasks) throws InterruptedException, ExecutionException { Collection> workItems = associateWithSubject(tasks); return this.targetExecutorService.invokeAny(workItems); } + @Override public T invokeAny(Collection> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Collection> workItems = associateWithSubject(tasks); diff --git a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java index 227604b086..60147bcf12 100644 --- a/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java +++ b/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java @@ -69,21 +69,25 @@ public void setTargetExecutorService(ExecutorService targetExecutorService) { super.setTargetExecutorService(targetExecutorService); } + @Override public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { Runnable work = associateWithSubject(command); return this.targetScheduledExecutorService.schedule(work, delay, unit); } + @Override public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { Callable work = associateWithSubject(callable); return this.targetScheduledExecutorService.schedule(work, delay, unit); } + @Override public ScheduledFuture scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) { Runnable work = associateWithSubject(command); return this.targetScheduledExecutorService.scheduleAtFixedRate(work, initialDelay, period, unit); } + @Override public ScheduledFuture scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) { Runnable work = associateWithSubject(command); return this.targetScheduledExecutorService.scheduleWithFixedDelay(work, initialDelay, delay, unit); diff --git a/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java b/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java index c243db88b3..807cd341dc 100644 --- a/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java +++ b/core/src/main/java/org/apache/shiro/env/DefaultEnvironment.java @@ -75,6 +75,7 @@ public DefaultEnvironment(Map seed) { * @return the application's {@code SecurityManager} instance accessible in the backing map using the * {@link #getSecurityManagerName() securityManagerName} property as the lookup key. */ + @Override public SecurityManager getSecurityManager() throws IllegalStateException { SecurityManager securityManager = lookupSecurityManager(); if (securityManager == null) { @@ -166,6 +167,7 @@ public void setObject(String name, Object instance) { } + @Override public void destroy() throws Exception { LifecycleUtils.destroy(this.objects.values()); } diff --git a/core/src/main/java/org/apache/shiro/ini/IniSecurityManagerFactory.java b/core/src/main/java/org/apache/shiro/ini/IniSecurityManagerFactory.java index 98d90d0beb..a6d70cc46f 100644 --- a/core/src/main/java/org/apache/shiro/ini/IniSecurityManagerFactory.java +++ b/core/src/main/java/org/apache/shiro/ini/IniSecurityManagerFactory.java @@ -100,10 +100,12 @@ private SecurityManager getSecurityManagerBean() { return getReflectionBuilder().getBean(SECURITY_MANAGER_NAME, SecurityManager.class); } + @Override protected SecurityManager createDefaultInstance() { return new DefaultSecurityManager(); } + @Override protected SecurityManager createInstance(Ini ini) { if (CollectionUtils.isEmpty(ini)) { throw new NullPointerException("Ini argument cannot be null or empty."); diff --git a/core/src/main/java/org/apache/shiro/jndi/JndiObjectFactory.java b/core/src/main/java/org/apache/shiro/jndi/JndiObjectFactory.java index ade30b88ae..4061af2c8d 100644 --- a/core/src/main/java/org/apache/shiro/jndi/JndiObjectFactory.java +++ b/core/src/main/java/org/apache/shiro/jndi/JndiObjectFactory.java @@ -33,6 +33,7 @@ public class JndiObjectFactory extends JndiLocator implements Factory { private String resourceName; private Class requiredType; + @Override @SuppressWarnings("unchecked") public T getInstance() { try { diff --git a/core/src/main/java/org/apache/shiro/jndi/JndiTemplate.java b/core/src/main/java/org/apache/shiro/jndi/JndiTemplate.java index c4062bd6ca..f899e6ba83 100644 --- a/core/src/main/java/org/apache/shiro/jndi/JndiTemplate.java +++ b/core/src/main/java/org/apache/shiro/jndi/JndiTemplate.java @@ -136,6 +136,7 @@ protected Context createInitialContext() throws NamingException { public Object lookup(final String name) throws NamingException { LOGGER.debug("Looking up JNDI object with name '{}'", name); return execute(new JndiCallback() { + @Override public Object doInContext(Context ctx) throws NamingException { Object located = ctx.lookup(name); if (located == null) { @@ -181,6 +182,7 @@ public Object lookup(String name, Class requiredType) throws NamingException public void bind(final String name, final Object object) throws NamingException { LOGGER.debug("Binding JNDI object with name '{}'", name); execute(new JndiCallback() { + @Override public Object doInContext(Context ctx) throws NamingException { ctx.bind(name, object); return null; @@ -199,6 +201,7 @@ public Object doInContext(Context ctx) throws NamingException { public void rebind(final String name, final Object object) throws NamingException { LOGGER.debug("Rebinding JNDI object with name '{}'", name); execute(new JndiCallback() { + @Override public Object doInContext(Context ctx) throws NamingException { ctx.rebind(name, object); return null; @@ -215,6 +218,7 @@ public Object doInContext(Context ctx) throws NamingException { public void unbind(final String name) throws NamingException { LOGGER.debug("Unbinding JNDI object with name '{}'", name); execute(new JndiCallback() { + @Override public Object doInContext(Context ctx) throws NamingException { ctx.unbind(name); return null; diff --git a/core/src/main/java/org/apache/shiro/mgt/AbstractRememberMeManager.java b/core/src/main/java/org/apache/shiro/mgt/AbstractRememberMeManager.java index 575d6480f4..471a0ebfe4 100644 --- a/core/src/main/java/org/apache/shiro/mgt/AbstractRememberMeManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/AbstractRememberMeManager.java @@ -361,6 +361,7 @@ protected boolean isRememberMe(AuthenticationToken token) { * @param token the token that resulted in a successful authentication attempt. * @param info the authentication info resulting from the successful authentication attempt. */ + @Override public void onSuccessfulLogin(Subject subject, AuthenticationToken token, AuthenticationInfo info) { //always clear any previous identity: forgetIdentity(subject); @@ -460,6 +461,7 @@ protected byte[] convertPrincipalsToBytes(PrincipalCollection principals) { * is being used to construct a {@link Subject} instance. * @return the remembered principals or {@code null} if none could be acquired. */ + @Override public PrincipalCollection getRememberedPrincipals(SubjectContext subjectContext) { PrincipalCollection principals = null; byte[] bytes = null; @@ -624,6 +626,7 @@ protected RememberedIdentity deserialize(byte[] serializedIdentity) { * @param token the authentication token resulting in a failed login attempt - ignored by this implementation * @param ae the exception thrown as a result of the failed login attempt - ignored by this implementation */ + @Override public void onFailedLogin(Subject subject, AuthenticationToken token, AuthenticationException ae) { forgetIdentity(subject); } @@ -634,6 +637,7 @@ public void onFailedLogin(Subject subject, AuthenticationToken token, Authentica * * @param subject the subject logging out. */ + @Override public void onLogout(Subject subject) { forgetIdentity(subject); } diff --git a/core/src/main/java/org/apache/shiro/mgt/AuthenticatingSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/AuthenticatingSecurityManager.java index 8696a21588..5bb32ec8e0 100644 --- a/core/src/main/java/org/apache/shiro/mgt/AuthenticatingSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/AuthenticatingSecurityManager.java @@ -92,6 +92,7 @@ public void setAuthenticator(Authenticator authenticator) throws IllegalArgument * Passes on the {@link #getRealms() realms} to the internal delegate Authenticator instance so * that it may use them during authentication attempts. */ + @Override protected void afterRealmsSet() { super.afterRealmsSet(); if (this.authenticator instanceof ModularRealmAuthenticator realmAuthenticator) { @@ -102,10 +103,12 @@ protected void afterRealmsSet() { /** * Delegates to the wrapped {@link org.apache.shiro.authc.Authenticator Authenticator} for authentication. */ + @Override public AuthenticationInfo authenticate(AuthenticationToken token) throws AuthenticationException { return this.authenticator.authenticate(token); } + @Override public void destroy() { LifecycleUtils.destroy(getAuthenticator()); this.authenticator = null; diff --git a/core/src/main/java/org/apache/shiro/mgt/AuthorizingSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/AuthorizingSecurityManager.java index 9152d0182b..6e40f013f7 100644 --- a/core/src/main/java/org/apache/shiro/mgt/AuthorizingSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/AuthorizingSecurityManager.java @@ -96,6 +96,7 @@ public void setAuthorizer(Authorizer authorizer) { * ((ModularRealmAuthorizer)this.authorizer).setRealms(realms); * } */ + @Override protected void afterRealmsSet() { super.afterRealmsSet(); if (this.authorizer instanceof ModularRealmAuthorizer realmAuthorizer) { @@ -103,73 +104,90 @@ protected void afterRealmsSet() { } } + @Override public void destroy() { LifecycleUtils.destroy(getAuthorizer()); this.authorizer = null; super.destroy(); } + @Override public boolean isPermitted(PrincipalCollection principals, String permissionString) { return this.authorizer.isPermitted(principals, permissionString); } + @Override public boolean isPermitted(PrincipalCollection principals, Permission permission) { return this.authorizer.isPermitted(principals, permission); } + @Override public boolean[] isPermitted(PrincipalCollection principals, String... permissions) { return this.authorizer.isPermitted(principals, permissions); } + @Override public boolean[] isPermitted(PrincipalCollection principals, List permissions) { return this.authorizer.isPermitted(principals, permissions); } + @Override public boolean isPermittedAll(PrincipalCollection principals, String... permissions) { return this.authorizer.isPermittedAll(principals, permissions); } + @Override public boolean isPermittedAll(PrincipalCollection principals, Collection permissions) { return this.authorizer.isPermittedAll(principals, permissions); } + @Override public void checkPermission(PrincipalCollection principals, String permission) throws AuthorizationException { this.authorizer.checkPermission(principals, permission); } + @Override public void checkPermission(PrincipalCollection principals, Permission permission) throws AuthorizationException { this.authorizer.checkPermission(principals, permission); } + @Override public void checkPermissions(PrincipalCollection principals, String... permissions) throws AuthorizationException { this.authorizer.checkPermissions(principals, permissions); } + @Override public void checkPermissions(PrincipalCollection principals, Collection permissions) throws AuthorizationException { this.authorizer.checkPermissions(principals, permissions); } + @Override public boolean hasRole(PrincipalCollection principals, String roleIdentifier) { return this.authorizer.hasRole(principals, roleIdentifier); } + @Override public boolean[] hasRoles(PrincipalCollection principals, List roleIdentifiers) { return this.authorizer.hasRoles(principals, roleIdentifiers); } + @Override public boolean hasAllRoles(PrincipalCollection principals, Collection roleIdentifiers) { return this.authorizer.hasAllRoles(principals, roleIdentifiers); } + @Override public void checkRole(PrincipalCollection principals, String role) throws AuthorizationException { this.authorizer.checkRole(principals, role); } + @Override public void checkRoles(PrincipalCollection principals, Collection roles) throws AuthorizationException { this.authorizer.checkRoles(principals, roles); } + @Override public void checkRoles(PrincipalCollection principals, String... roles) throws AuthorizationException { this.authorizer.checkRoles(principals, roles); } diff --git a/core/src/main/java/org/apache/shiro/mgt/CachingSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/CachingSecurityManager.java index 52eb434d50..ff829fc86f 100644 --- a/core/src/main/java/org/apache/shiro/mgt/CachingSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/CachingSecurityManager.java @@ -79,6 +79,7 @@ public CacheManager getCacheManager() { * @param cacheManager the CacheManager used by this {@code SecurityManager} and potentially any of its * children components. */ + @Override public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; afterCacheManagerSet(); @@ -115,6 +116,7 @@ public EventBus getEventBus() { * children components. * @since 1.3 */ + @Override public void setEventBus(EventBus eventBus) { this.eventBus = eventBus; afterEventBusSet(); @@ -142,6 +144,7 @@ protected void afterEventBusSet() { /** * Destroys the {@link #getCacheManager() cacheManager} via {@link LifecycleUtils#destroy LifecycleUtils.destroy}. */ + @Override public void destroy() { LifecycleUtils.destroy(getCacheManager()); this.cacheManager = null; diff --git a/core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java index 86155b5703..0d709e84a4 100644 --- a/core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/DefaultSecurityManager.java @@ -274,6 +274,7 @@ protected void rememberMeLogout(Subject subject) { * @return a Subject representing the authenticated user. * @throws AuthenticationException if there is a problem authenticating the specified {@code token}. */ + @Override public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { @@ -356,6 +357,7 @@ protected SubjectContext copy(SubjectContext subjectContext) { * @see #save(org.apache.shiro.subject.Subject) * @since 1.0 */ + @Override public Subject createSubject(SubjectContext subjectContext) { //create a copy so we don't modify the argument's backing map: SubjectContext context = copy(subjectContext); @@ -574,6 +576,7 @@ protected SessionContext createSessionContext(SubjectContext subjectContext) { return sessionContext; } + @Override public void logout(Subject subject) { if (subject == null) { diff --git a/core/src/main/java/org/apache/shiro/mgt/DefaultSessionStorageEvaluator.java b/core/src/main/java/org/apache/shiro/mgt/DefaultSessionStorageEvaluator.java index b36080e96b..b6d9720eb7 100644 --- a/core/src/main/java/org/apache/shiro/mgt/DefaultSessionStorageEvaluator.java +++ b/core/src/main/java/org/apache/shiro/mgt/DefaultSessionStorageEvaluator.java @@ -59,6 +59,7 @@ public class DefaultSessionStorageEvaluator implements SessionStorageEvaluator { * @param subject the {@code Subject} for which session state persistence may be enabled * @return the value of {@link #isSessionStorageEnabled()} and ignores the {@code Subject} argument. */ + @Override public boolean isSessionStorageEnabled(Subject subject) { return (subject != null && subject.getSession(false) != null) || isSessionStorageEnabled(); } diff --git a/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java b/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java index 354517369b..24ce975e83 100644 --- a/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java +++ b/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectDAO.java @@ -141,6 +141,7 @@ public void setSessionStorageEvaluator(SessionStorageEvaluator sessionStorageEva * @param subject the Subject instance for which its state will be created or updated. * @return the same {@code Subject} passed in (a new Subject instance is not created). */ + @Override public Subject save(Subject subject) { if (isSessionStorageEnabled(subject)) { saveToSession(subject); @@ -280,6 +281,7 @@ protected void removeFromSession(Subject subject) { * * @param subject the Subject instance for which any persistent state should be deleted. */ + @Override public void delete(Subject subject) { removeFromSession(subject); } diff --git a/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectFactory.java b/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectFactory.java index 618a44146b..09ce683dd7 100644 --- a/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectFactory.java +++ b/core/src/main/java/org/apache/shiro/mgt/DefaultSubjectFactory.java @@ -37,6 +37,7 @@ public class DefaultSubjectFactory implements SubjectFactory { public DefaultSubjectFactory() { } + @Override public Subject createSubject(SubjectContext context) { SecurityManager securityManager = context.resolveSecurityManager(); Session session = context.resolveSession(); diff --git a/core/src/main/java/org/apache/shiro/mgt/RealmSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/RealmSecurityManager.java index b7323d2477..743700cb87 100644 --- a/core/src/main/java/org/apache/shiro/mgt/RealmSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/RealmSecurityManager.java @@ -152,6 +152,7 @@ protected void applyEventBusToRealms() { * newly set {@link org.apache.shiro.cache.CacheManager CacheManager} to be propagated to the * internal collection of Realm that would need to use it. */ + @Override protected void afterCacheManagerSet() { super.afterCacheManagerSet(); applyCacheManagerToRealms(); @@ -163,6 +164,7 @@ protected void afterEventBusSet() { applyEventBusToRealms(); } + @Override public void destroy() { LifecycleUtils.destroy(getRealms()); this.realms = null; diff --git a/core/src/main/java/org/apache/shiro/mgt/SessionsSecurityManager.java b/core/src/main/java/org/apache/shiro/mgt/SessionsSecurityManager.java index a681ac39f8..52021feb72 100644 --- a/core/src/main/java/org/apache/shiro/mgt/SessionsSecurityManager.java +++ b/core/src/main/java/org/apache/shiro/mgt/SessionsSecurityManager.java @@ -165,6 +165,7 @@ protected void applyEventBusToAuthenticator() { } } + @Override public Session start(SessionContext context) throws AuthorizationException { if (sessionManager == null) { throw new IllegalStateException("Session manager is not available or has been destroyed"); @@ -172,10 +173,12 @@ public Session start(SessionContext context) throws AuthorizationException { return this.sessionManager.start(context); } + @Override public Session getSession(SessionKey key) throws SessionException { return this.sessionManager.getSession(key); } + @Override public void destroy() { LifecycleUtils.destroy(getSessionManager()); this.sessionManager = null; diff --git a/core/src/main/java/org/apache/shiro/realm/AuthenticatingRealm.java b/core/src/main/java/org/apache/shiro/realm/AuthenticatingRealm.java index 11cccbf5ad..cc361ca315 100644 --- a/core/src/main/java/org/apache/shiro/realm/AuthenticatingRealm.java +++ b/core/src/main/java/org/apache/shiro/realm/AuthenticatingRealm.java @@ -345,6 +345,7 @@ public void setAuthenticationCachingEnabled(boolean authenticationCachingEnabled } } + @Override public void setName(String name) { super.setName(name); String authcCacheName = this.authenticationCacheName; @@ -370,6 +371,7 @@ public void setName(String name) { * @param token the token being submitted for authentication. * @return true if this authentication realm can process the submitted token instance of the class, false otherwise. */ + @Override public boolean supports(AuthenticationToken token) { return token != null && getAuthenticationTokenClass().isAssignableFrom(token.getClass()); } @@ -397,6 +399,7 @@ public boolean supports(AuthenticationToken token) { * * @since 1.2 */ + @Override public final void init() { //trigger obtaining the authentication cache if possible getAvailableAuthenticationCache(); @@ -417,6 +420,7 @@ protected void onInit() { * * @since 1.2 */ + @Override protected void afterCacheManagerSet() { //trigger obtaining the authentication cache if possible getAvailableAuthenticationCache(); @@ -568,6 +572,7 @@ protected boolean isAuthenticationCachingEnabled(AuthenticationToken token, Auth * AuthenticationInfo could be found. * @throws AuthenticationException if authentication failed. */ + @Override public final AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info = getCachedAuthenticationInfo(token); diff --git a/core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java b/core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java index aa702c2eb3..cd12db7b83 100644 --- a/core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java +++ b/core/src/main/java/org/apache/shiro/realm/AuthorizingRealm.java @@ -137,6 +137,7 @@ public AuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) { | A C C E S S O R S / M O D I F I E R S | ============================================*/ + @Override public void setName(String name) { super.setName(name); String authzCacheName = this.authorizationCacheName; @@ -196,6 +197,7 @@ public PermissionResolver getPermissionResolver() { return permissionResolver; } + @Override public void setPermissionResolver(PermissionResolver permissionResolver) { if (permissionResolver == null) { throw new IllegalArgumentException("Null PermissionResolver is not allowed"); @@ -207,6 +209,7 @@ public RolePermissionResolver getRolePermissionResolver() { return permissionRoleResolver; } + @Override public void setRolePermissionResolver(RolePermissionResolver permissionRoleResolver) { this.permissionRoleResolver = permissionRoleResolver; } @@ -235,12 +238,14 @@ public void setRolePermissionResolver(RolePermissionResolver permissionRoleResol * subclass implementations for each authorization check. * */ + @Override protected void onInit() { super.onInit(); //trigger obtaining the authorization cache if possible getAvailableAuthorizationCache(); } + @Override protected void afterCacheManagerSet() { super.afterCacheManagerSet(); //trigger obtaining the authorization cache if possible @@ -476,11 +481,13 @@ private Collection resolveRolePermissions(Collection roleNam return perms; } + @Override public boolean isPermitted(PrincipalCollection principals, String permission) { Permission p = getPermissionResolver().resolvePermission(permission); return isPermitted(principals, p); } + @Override public boolean isPermitted(PrincipalCollection principals, Permission permission) { AuthorizationInfo info = getAuthorizationInfo(principals); return isPermitted(permission, info); @@ -499,6 +506,7 @@ protected boolean isPermitted(Permission permission, AuthorizationInfo info) { return false; } + @Override public boolean[] isPermitted(PrincipalCollection subjectIdentifier, String... permissions) { List perms = new ArrayList(permissions.length); for (String permString : permissions) { @@ -507,6 +515,7 @@ public boolean[] isPermitted(PrincipalCollection subjectIdentifier, String... pe return isPermitted(subjectIdentifier, perms); } + @Override public boolean[] isPermitted(PrincipalCollection principals, List permissions) { AuthorizationInfo info = getAuthorizationInfo(principals); return isPermitted(permissions, info); @@ -527,6 +536,7 @@ protected boolean[] isPermitted(List permissions, AuthorizationInfo return result; } + @Override public boolean isPermittedAll(PrincipalCollection subjectIdentifier, String... permissions) { if (permissions != null && permissions.length > 0) { Collection perms = new ArrayList(permissions.length); @@ -538,6 +548,7 @@ public boolean isPermittedAll(PrincipalCollection subjectIdentifier, String... p return false; } + @Override public boolean isPermittedAll(PrincipalCollection principal, Collection permissions) { AuthorizationInfo info = getAuthorizationInfo(principal); return info != null && isPermittedAll(permissions, info); @@ -554,11 +565,13 @@ protected boolean isPermittedAll(Collection permissions, Authorizati return true; } + @Override public void checkPermission(PrincipalCollection subjectIdentifier, String permission) throws AuthorizationException { Permission p = getPermissionResolver().resolvePermission(permission); checkPermission(subjectIdentifier, p); } + @Override public void checkPermission(PrincipalCollection principal, Permission permission) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkPermission(permission, info); @@ -571,6 +584,7 @@ protected void checkPermission(Permission permission, AuthorizationInfo info) { } } + @Override public void checkPermissions(PrincipalCollection subjectIdentifier, String... permissions) throws AuthorizationException { if (permissions != null) { for (String permString : permissions) { @@ -579,6 +593,7 @@ public void checkPermissions(PrincipalCollection subjectIdentifier, String... pe } } + @Override public void checkPermissions(PrincipalCollection principal, Collection permissions) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); @@ -593,6 +608,7 @@ protected void checkPermissions(Collection permissions, Authorizatio } } + @Override public boolean hasRole(PrincipalCollection principal, String roleIdentifier) { AuthorizationInfo info = getAuthorizationInfo(principal); return hasRole(roleIdentifier, info); @@ -602,6 +618,7 @@ protected boolean hasRole(String roleIdentifier, AuthorizationInfo info) { return info != null && info.getRoles() != null && info.getRoles().contains(roleIdentifier); } + @Override public boolean[] hasRoles(PrincipalCollection principal, List roleIdentifiers) { AuthorizationInfo info = getAuthorizationInfo(principal); boolean[] result = new boolean[roleIdentifiers != null ? roleIdentifiers.size() : 0]; @@ -626,6 +643,7 @@ protected boolean[] hasRoles(List roleIdentifiers, AuthorizationInfo inf return result; } + @Override public boolean hasAllRoles(PrincipalCollection principal, Collection roleIdentifiers) { AuthorizationInfo info = getAuthorizationInfo(principal); return info != null && hasAllRoles(roleIdentifiers, info); @@ -642,6 +660,7 @@ private boolean hasAllRoles(Collection roleIdentifiers, AuthorizationInf return true; } + @Override public void checkRole(PrincipalCollection principal, String role) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkRole(role, info); @@ -654,11 +673,13 @@ protected void checkRole(String role, AuthorizationInfo info) { } } + @Override public void checkRoles(PrincipalCollection principal, Collection roles) throws AuthorizationException { AuthorizationInfo info = getAuthorizationInfo(principal); checkRoles(roles, info); } + @Override public void checkRoles(PrincipalCollection principal, String... roles) throws AuthorizationException { checkRoles(principal, Arrays.asList(roles)); } diff --git a/core/src/main/java/org/apache/shiro/realm/CachingRealm.java b/core/src/main/java/org/apache/shiro/realm/CachingRealm.java index bcb98bf74c..3ea598d12d 100644 --- a/core/src/main/java/org/apache/shiro/realm/CachingRealm.java +++ b/core/src/main/java/org/apache/shiro/realm/CachingRealm.java @@ -89,6 +89,7 @@ public CacheManager getCacheManager() { * * @param cacheManager the CacheManager to use for data caching, or null to disable caching. */ + @Override public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; afterCacheManagerSet(); @@ -119,10 +120,12 @@ public void setCachingEnabled(boolean cachingEnabled) { this.cachingEnabled = cachingEnabled; } + @Override public String getName() { return name; } + @Override public void setName(String name) { this.name = name; } @@ -146,6 +149,7 @@ protected void afterCacheManagerSet() { * @see #getAvailablePrincipal(org.apache.shiro.subject.PrincipalCollection) * @since 1.2 */ + @Override public void onLogout(PrincipalCollection principals) { clearCache(principals); } diff --git a/core/src/main/java/org/apache/shiro/realm/SimpleAccountRealm.java b/core/src/main/java/org/apache/shiro/realm/SimpleAccountRealm.java index e9347da53f..3da896bb77 100644 --- a/core/src/main/java/org/apache/shiro/realm/SimpleAccountRealm.java +++ b/core/src/main/java/org/apache/shiro/realm/SimpleAccountRealm.java @@ -162,6 +162,7 @@ protected static Set toSet(String delimited, String delimiter) { return values; } + @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { UsernamePasswordToken upToken = (UsernamePasswordToken) token; SimpleAccount account = getUser(upToken.getUsername()); @@ -181,6 +182,7 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) return account; } + @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { String username = getUsername(principals); usersLock.readLock().lock(); diff --git a/core/src/main/java/org/apache/shiro/realm/jndi/JndiRealmFactory.java b/core/src/main/java/org/apache/shiro/realm/jndi/JndiRealmFactory.java index 6ca774fb35..e6f6663284 100644 --- a/core/src/main/java/org/apache/shiro/realm/jndi/JndiRealmFactory.java +++ b/core/src/main/java/org/apache/shiro/realm/jndi/JndiRealmFactory.java @@ -98,6 +98,7 @@ public void setJndiNames(String commaDelimited) throws IllegalStateException { * @return an ordered collection of the {@link #setJndiNames(java.util.Collection) specified Realms} found in JNDI. * @throws IllegalStateException if any of the JNDI names fails to successfully look up a Realm instance. */ + @Override public Collection getRealms() throws IllegalStateException { Collection jndiNames = getJndiNames(); if (jndiNames == null || jndiNames.isEmpty()) { diff --git a/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java b/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java index a7806a7245..f0e1678ef7 100644 --- a/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java +++ b/core/src/main/java/org/apache/shiro/realm/ldap/JndiLdapContextFactory.java @@ -397,6 +397,7 @@ public String getSystemUsername() { * @return the system LdapContext * @throws NamingException if there is a problem connecting to the LDAP directory */ + @Override public LdapContext getSystemLdapContext() throws NamingException { return getLdapContext(getSystemUsername(), getSystemPassword()); } @@ -434,6 +435,7 @@ protected boolean isPoolingConnections(Object principal) { * @throws NamingException * @throws IllegalStateException */ + @Override public LdapContext getLdapContext(Object principal, Object credentials) throws NamingException, IllegalStateException { diff --git a/core/src/main/java/org/apache/shiro/realm/text/PropertiesRealm.java b/core/src/main/java/org/apache/shiro/realm/text/PropertiesRealm.java index cdd051048f..067dcb7854 100644 --- a/core/src/main/java/org/apache/shiro/realm/text/PropertiesRealm.java +++ b/core/src/main/java/org/apache/shiro/realm/text/PropertiesRealm.java @@ -170,6 +170,7 @@ protected void afterRoleCacheSet() { /** * Destroy reload scheduler if one exists. */ + @Override public void destroy() { try { if (scheduler != null) { @@ -192,6 +193,7 @@ protected void startReloadThread() { } } + @Override public void run() { try { reloadPropertiesIfNecessary(); diff --git a/core/src/main/java/org/apache/shiro/session/ProxiedSession.java b/core/src/main/java/org/apache/shiro/session/ProxiedSession.java index b07a884f01..bfe2f23a8b 100644 --- a/core/src/main/java/org/apache/shiro/session/ProxiedSession.java +++ b/core/src/main/java/org/apache/shiro/session/ProxiedSession.java @@ -54,6 +54,7 @@ public ProxiedSession(Session target) { /** * Immediately delegates to the underlying proxied session. */ + @Override public Serializable getId() { return delegate.getId(); } @@ -61,6 +62,7 @@ public Serializable getId() { /** * Immediately delegates to the underlying proxied session. */ + @Override public Date getStartTimestamp() { return delegate.getStartTimestamp(); } @@ -68,6 +70,7 @@ public Date getStartTimestamp() { /** * Immediately delegates to the underlying proxied session. */ + @Override public Date getLastAccessTime() { return delegate.getLastAccessTime(); } @@ -75,6 +78,7 @@ public Date getLastAccessTime() { /** * Immediately delegates to the underlying proxied session. */ + @Override public long getTimeout() throws InvalidSessionException { return delegate.getTimeout(); } @@ -82,6 +86,7 @@ public long getTimeout() throws InvalidSessionException { /** * Immediately delegates to the underlying proxied session. */ + @Override public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { delegate.setTimeout(maxIdleTimeInMillis); } @@ -89,6 +94,7 @@ public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException /** * Immediately delegates to the underlying proxied session. */ + @Override public String getHost() { return delegate.getHost(); } @@ -96,6 +102,7 @@ public String getHost() { /** * Immediately delegates to the underlying proxied session. */ + @Override public void touch() throws InvalidSessionException { delegate.touch(); } @@ -103,6 +110,7 @@ public void touch() throws InvalidSessionException { /** * Immediately delegates to the underlying proxied session. */ + @Override public void stop() throws InvalidSessionException { delegate.stop(); } @@ -110,6 +118,7 @@ public void stop() throws InvalidSessionException { /** * Immediately delegates to the underlying proxied session. */ + @Override public Collection getAttributeKeys() throws InvalidSessionException { return delegate.getAttributeKeys(); } @@ -117,6 +126,7 @@ public Collection getAttributeKeys() throws InvalidSessionException { /** * Immediately delegates to the underlying proxied session. */ + @Override public Object getAttribute(Object key) throws InvalidSessionException { return delegate.getAttribute(key); } @@ -124,6 +134,7 @@ public Object getAttribute(Object key) throws InvalidSessionException { /** * Immediately delegates to the underlying proxied session. */ + @Override public void setAttribute(Object key, Object value) throws InvalidSessionException { delegate.setAttribute(key, value); } @@ -131,6 +142,7 @@ public void setAttribute(Object key, Object value) throws InvalidSessionExceptio /** * Immediately delegates to the underlying proxied session. */ + @Override public Object removeAttribute(Object key) throws InvalidSessionException { return delegate.removeAttribute(key); } diff --git a/core/src/main/java/org/apache/shiro/session/SessionListenerAdapter.java b/core/src/main/java/org/apache/shiro/session/SessionListenerAdapter.java index 5e46af75a9..fea77267d8 100644 --- a/core/src/main/java/org/apache/shiro/session/SessionListenerAdapter.java +++ b/core/src/main/java/org/apache/shiro/session/SessionListenerAdapter.java @@ -31,6 +31,7 @@ public class SessionListenerAdapter implements SessionListener { * * @param session the session that has started. */ + @Override public void onStart(Session session) { //no-op } @@ -40,6 +41,7 @@ public void onStart(Session session) { * * @param session the session that has stopped. */ + @Override public void onStop(Session session) { //no-op } @@ -49,6 +51,7 @@ public void onStop(Session session) { * * @param session the session that has expired. */ + @Override public void onExpiration(Session session) { //no-op } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/AbstractNativeSessionManager.java b/core/src/main/java/org/apache/shiro/session/mgt/AbstractNativeSessionManager.java index a172a01d03..239aed4d6a 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/AbstractNativeSessionManager.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/AbstractNativeSessionManager.java @@ -80,6 +80,7 @@ protected EventBus getEventBus() { * @param eventBus the EventBus to use to publish SessionEvents. * @since 1.3 */ + @Override public void setEventBus(EventBus eventBus) { this.eventBus = eventBus; } @@ -96,6 +97,7 @@ protected void publishEvent(Object event) { } } + @Override public Session start(SessionContext context) { Session session = createSession(context); applyGlobalSessionTimeout(session); @@ -137,6 +139,7 @@ protected void applyGlobalSessionTimeout(Session session) { protected void onStart(Session session, SessionContext context) { } + @Override public Session getSession(SessionKey key) throws SessionException { Session session = lookupSession(key); return session != null ? createExposedSession(session, key) : null; @@ -210,34 +213,41 @@ protected void notifyExpiration(Session session) { } } + @Override public Date getStartTimestamp(SessionKey key) { return lookupRequiredSession(key).getStartTimestamp(); } + @Override public Date getLastAccessTime(SessionKey key) { return lookupRequiredSession(key).getLastAccessTime(); } + @Override public long getTimeout(SessionKey key) throws InvalidSessionException { return lookupRequiredSession(key).getTimeout(); } + @Override public void setTimeout(SessionKey key, long maxIdleTimeInMillis) throws InvalidSessionException { Session s = lookupRequiredSession(key); s.setTimeout(maxIdleTimeInMillis); onChange(s); } + @Override public void touch(SessionKey key) throws InvalidSessionException { Session s = lookupRequiredSession(key); s.touch(); onChange(s); } + @Override public String getHost(SessionKey key) { return lookupRequiredSession(key).getHost(); } + @Override public Collection getAttributeKeys(SessionKey key) { Collection c = lookupRequiredSession(key).getAttributeKeys(); if (!CollectionUtils.isEmpty(c)) { @@ -246,10 +256,12 @@ public Collection getAttributeKeys(SessionKey key) { return Collections.emptySet(); } + @Override public Object getAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException { return lookupRequiredSession(sessionKey).getAttribute(attributeKey); } + @Override public void setAttribute(SessionKey sessionKey, Object attributeKey, Object value) throws InvalidSessionException { if (value == null) { removeAttribute(sessionKey, attributeKey); @@ -260,6 +272,7 @@ public void setAttribute(SessionKey sessionKey, Object attributeKey, Object valu } } + @Override public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException { Session s = lookupRequiredSession(sessionKey); Object removed = s.removeAttribute(attributeKey); @@ -269,6 +282,7 @@ public Object removeAttribute(SessionKey sessionKey, Object attributeKey) throws return removed; } + @Override public boolean isValid(SessionKey key) { try { checkValid(key); @@ -278,6 +292,7 @@ public boolean isValid(SessionKey key) { } } + @Override public void stop(SessionKey key) throws InvalidSessionException { Session session = lookupRequiredSession(key); try { @@ -303,6 +318,7 @@ protected void onStop(Session session) { protected void afterStopped(Session session) { } + @Override public void checkValid(SessionKey key) throws InvalidSessionException { //just try to acquire it. If there is a problem, an exception will be thrown: lookupRequiredSession(key); diff --git a/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java b/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java index eb87cc2217..11400e78ad 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManager.java @@ -129,6 +129,7 @@ protected final Session doGetSession(final SessionKey key) throws InvalidSession */ protected abstract Session retrieveSession(SessionKey key) throws UnknownSessionException; + @Override protected Session createSession(SessionContext context) throws AuthorizationException { enableSessionValidationIfNecessary(); return doCreateSession(context); @@ -269,6 +270,7 @@ protected synchronized void disableSessionValidation() { protected void beforeSessionValidationDisabled() { } + @Override public void destroy() { disableSessionValidation(); } @@ -276,6 +278,7 @@ public void destroy() { /** * @see ValidatingSessionManager#validateSessions() */ + @Override public void validateSessions() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Validating all active sessions..."); diff --git a/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionKey.java b/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionKey.java index 134a85757c..31606482bd 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionKey.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionKey.java @@ -39,6 +39,7 @@ public void setSessionId(Serializable sessionId) { this.sessionId = sessionId; } + @Override public Serializable getSessionId() { return this.sessionId; } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionManager.java b/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionManager.java index 1f007209a9..ef120281f2 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionManager.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/DefaultSessionManager.java @@ -129,6 +129,7 @@ public void setDeleteInvalidSessions(boolean deleteInvalidSessions) { this.deleteInvalidSessions = deleteInvalidSessions; } + @Override public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; applyCacheManagerToSessionDAO(); @@ -151,6 +152,7 @@ private void applyCacheManagerToSessionDAO() { } } + @Override protected Session doCreateSession(SessionContext context) { Session s = newSessionInstance(context); if (LOGGER.isTraceEnabled()) { @@ -194,6 +196,7 @@ protected void afterStopped(Session session) { } } + @Override protected void onExpiration(Session session) { if (session instanceof SimpleSession simpleSession) { simpleSession.setExpired(true); @@ -208,10 +211,12 @@ protected void afterExpired(Session session) { } } + @Override protected void onChange(Session session) { sessionDAO.update(session); } + @Override protected Session retrieveSession(SessionKey sessionKey) throws UnknownSessionException { Serializable sessionId = getSessionId(sessionKey); if (sessionId == null) { @@ -240,6 +245,7 @@ protected void delete(Session session) { sessionDAO.delete(session); } + @Override protected Collection getActiveSessions() { Collection active = sessionDAO.getActiveSessions(); return active != null ? active : Collections.emptySet(); diff --git a/core/src/main/java/org/apache/shiro/session/mgt/DelegatingSession.java b/core/src/main/java/org/apache/shiro/session/mgt/DelegatingSession.java index 1e38fdc511..d16ab4a464 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/DelegatingSession.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/DelegatingSession.java @@ -76,6 +76,7 @@ public DelegatingSession(NativeSessionManager sessionManager, SessionKey key) { /** * @see org.apache.shiro.session.Session#getId() */ + @Override public Serializable getId() { return key.getSessionId(); } @@ -83,6 +84,7 @@ public Serializable getId() { /** * @see org.apache.shiro.session.Session#getStartTimestamp() */ + @Override public Date getStartTimestamp() { if (startTimestamp == null) { startTimestamp = sessionManager.getStartTimestamp(key); @@ -93,19 +95,23 @@ public Date getStartTimestamp() { /** * @see org.apache.shiro.session.Session#getLastAccessTime() */ + @Override public Date getLastAccessTime() { //can't cache - only business pojo knows the accurate time: return sessionManager.getLastAccessTime(key); } + @Override public long getTimeout() throws InvalidSessionException { return sessionManager.getTimeout(key); } + @Override public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { sessionManager.setTimeout(key, maxIdleTimeInMillis); } + @Override public String getHost() { if (host == null) { host = sessionManager.getHost(key); @@ -116,6 +122,7 @@ public String getHost() { /** * @see org.apache.shiro.session.Session#touch() */ + @Override public void touch() throws InvalidSessionException { sessionManager.touch(key); } @@ -123,6 +130,7 @@ public void touch() throws InvalidSessionException { /** * @see org.apache.shiro.session.Session#stop() */ + @Override public void stop() throws InvalidSessionException { sessionManager.stop(key); } @@ -130,6 +138,7 @@ public void stop() throws InvalidSessionException { /** * @see org.apache.shiro.session.Session#getAttributeKeys */ + @Override public Collection getAttributeKeys() throws InvalidSessionException { return sessionManager.getAttributeKeys(key); } @@ -137,6 +146,7 @@ public Collection getAttributeKeys() throws InvalidSessionException { /** * @see org.apache.shiro.session.Session#getAttribute(Object key) */ + @Override public Object getAttribute(Object attributeKey) throws InvalidSessionException { return sessionManager.getAttribute(this.key, attributeKey); } @@ -144,6 +154,7 @@ public Object getAttribute(Object attributeKey) throws InvalidSessionException { /** * @see Session#setAttribute(Object key, Object value) */ + @Override public void setAttribute(Object attributeKey, Object value) throws InvalidSessionException { if (value == null) { removeAttribute(attributeKey); @@ -155,6 +166,7 @@ public void setAttribute(Object attributeKey, Object value) throws InvalidSessio /** * @see Session#removeAttribute(Object key) */ + @Override public Object removeAttribute(Object attributeKey) throws InvalidSessionException { return sessionManager.removeAttribute(this.key, attributeKey); } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java b/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java index 72b16174a0..8625377c03 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java @@ -74,6 +74,7 @@ public void setSessionValidationInterval(long sessionValidationInterval) { this.sessionValidationInterval = sessionValidationInterval; } + @Override public boolean isEnabled() { return this.enabled; } @@ -92,11 +93,13 @@ public String getThreadNamePrefix() { */ //TODO Implement an integration test to test for jvm exit as part of the standalone example // (so we don't have to change the unit test execution model for the core module) + @Override public void enableSessionValidation() { if (this.sessionValidationInterval > 0L) { this.service = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { private final AtomicInteger count = new AtomicInteger(1); + @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setDaemon(true); @@ -110,6 +113,7 @@ public Thread newThread(Runnable r) { this.enabled = true; } + @Override public void run() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing session validation..."); @@ -131,6 +135,7 @@ public void run() { } } + @Override public void disableSessionValidation() { if (this.service != null) { this.service.shutdownNow(); diff --git a/core/src/main/java/org/apache/shiro/session/mgt/ImmutableProxiedSession.java b/core/src/main/java/org/apache/shiro/session/mgt/ImmutableProxiedSession.java index 5f99f76a85..fe4c875dd0 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/ImmutableProxiedSession.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/ImmutableProxiedSession.java @@ -67,6 +67,7 @@ protected void throwImmutableException() throws InvalidSessionException { * Immediately {@link #throwImmutableException() throws} an InvalidSessionException in all * cases because this proxy is immutable. */ + @Override public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { throwImmutableException(); } @@ -75,6 +76,7 @@ public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException * Immediately {@link #throwImmutableException() throws} an InvalidSessionException in all * cases because this proxy is immutable. */ + @Override public void touch() throws InvalidSessionException { throwImmutableException(); } @@ -83,6 +85,7 @@ public void touch() throws InvalidSessionException { * Immediately {@link #throwImmutableException() throws} an InvalidSessionException in all * cases because this proxy is immutable. */ + @Override public void stop() throws InvalidSessionException { throwImmutableException(); } @@ -91,6 +94,7 @@ public void stop() throws InvalidSessionException { * Immediately {@link #throwImmutableException() throws} an InvalidSessionException in all * cases because this proxy is immutable. */ + @Override public void setAttribute(Object key, Object value) throws InvalidSessionException { throwImmutableException(); } @@ -99,6 +103,7 @@ public void setAttribute(Object key, Object value) throws InvalidSessionExceptio * Immediately {@link #throwImmutableException() throws} an InvalidSessionException in all * cases because this proxy is immutable. */ + @Override public Object removeAttribute(Object key) throws InvalidSessionException { throwImmutableException(); //we should never ever reach this point due to the exception being thrown. diff --git a/core/src/main/java/org/apache/shiro/session/mgt/SimpleSessionFactory.java b/core/src/main/java/org/apache/shiro/session/mgt/SimpleSessionFactory.java index a09ecb63bc..fb77404ff1 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/SimpleSessionFactory.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/SimpleSessionFactory.java @@ -34,6 +34,7 @@ public class SimpleSessionFactory implements SessionFactory { * @param initData the initialization data to be used during {@link Session} creation. * @return a new {@link SimpleSession SimpleSession} instance */ + @Override public Session createSession(SessionContext initData) { return initData != null ? new SimpleSession(initData.getHost()) : new SimpleSession(); } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/AbstractSessionDAO.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/AbstractSessionDAO.java index 4a472ed5f1..77f390ff8a 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/eis/AbstractSessionDAO.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/eis/AbstractSessionDAO.java @@ -112,6 +112,7 @@ protected Serializable generateSessionId(Session session) { * * @param session Session object to create in the EIS and associate with an ID. */ + @Override public Serializable create(Session session) { Serializable sessionId = doCreate(session); verifySessionId(sessionId); @@ -164,6 +165,7 @@ protected void assignSessionId(Session session, Serializable sessionId) { * @return the session identified by sessionId in the EIS. * @throws UnknownSessionException if the id specified does not correspond to any session in the EIS. */ + @Override public Session readSession(Serializable sessionId) throws UnknownSessionException { Session s = doReadSession(sessionId); if (s == null) { diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/CachingSessionDAO.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/CachingSessionDAO.java index 1af752d94e..cdc36bece4 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/eis/CachingSessionDAO.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/eis/CachingSessionDAO.java @@ -79,6 +79,7 @@ public CachingSessionDAO() { * * @param cacheManager the manager to use for constructing the session cache. */ + @Override public void setCacheManager(CacheManager cacheManager) { this.cacheManager = cacheManager; } @@ -178,6 +179,7 @@ protected Cache createActiveSessionsCache() { * * @param session Session object to create in the EIS and then cache. */ + @Override public Serializable create(Session session) { Serializable sessionId = super.create(session); cache(session, sessionId); @@ -253,6 +255,7 @@ protected void cache(Session session, Serializable sessionId, Cache getActiveSessions() { Cache cache = getActiveSessionsCacheLazy(); if (cache != null) { diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/EnterpriseCacheSessionDAO.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/EnterpriseCacheSessionDAO.java index ee4b37cf1c..6995796dcd 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/eis/EnterpriseCacheSessionDAO.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/eis/EnterpriseCacheSessionDAO.java @@ -60,12 +60,14 @@ protected Cache createCache(Strin }); } + @Override protected Serializable doCreate(Session session) { Serializable sessionId = generateSessionId(session); assignSessionId(session, sessionId); return sessionId; } + @Override protected Session doReadSession(Serializable sessionId) { //should never execute because this implementation relies on parent class to access cache, which //is where all sessions reside - it is the cache implementation that determines if the @@ -73,10 +75,12 @@ protected Session doReadSession(Serializable sessionId) { return null; } + @Override protected void doUpdate(Session session) { //does nothing - parent class persists to cache. } + @Override protected void doDelete(Session session) { //does nothing - parent class removes from cache. } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/JavaUuidSessionIdGenerator.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/JavaUuidSessionIdGenerator.java index 96cdf4b8ca..afe917cada 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/eis/JavaUuidSessionIdGenerator.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/eis/JavaUuidSessionIdGenerator.java @@ -37,6 +37,7 @@ public class JavaUuidSessionIdGenerator implements SessionIdGenerator { * @param session the {@link Session} instance to which the ID will be applied. * @return the String value of the JDK's next {@link UUID#randomUUID() randomUUID()}. */ + @Override public Serializable generateId(Session session) { return UUID.randomUUID().toString(); } diff --git a/core/src/main/java/org/apache/shiro/session/mgt/eis/MemorySessionDAO.java b/core/src/main/java/org/apache/shiro/session/mgt/eis/MemorySessionDAO.java index aa07f99767..e91d76405d 100644 --- a/core/src/main/java/org/apache/shiro/session/mgt/eis/MemorySessionDAO.java +++ b/core/src/main/java/org/apache/shiro/session/mgt/eis/MemorySessionDAO.java @@ -63,6 +63,7 @@ public MemorySessionDAO() { this.sessions = new ConcurrentHashMap(); } + @Override protected Serializable doCreate(Session session) { Serializable sessionId = generateSessionId(session); assignSessionId(session, sessionId); @@ -77,14 +78,17 @@ protected Session storeSession(Serializable id, Session session) { return sessions.putIfAbsent(id, session); } + @Override protected Session doReadSession(Serializable sessionId) { return sessions.get(sessionId); } + @Override public void update(Session session) throws UnknownSessionException { storeSession(session.getId(), session); } + @Override public void delete(Session session) { if (session == null) { throw new NullPointerException("session argument cannot be null."); @@ -95,6 +99,7 @@ public void delete(Session session) { } } + @Override public Collection getActiveSessions() { Collection values = sessions.values(); if (CollectionUtils.isEmpty(values)) { diff --git a/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java b/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java index 4f847de0b7..4735f96a37 100644 --- a/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java +++ b/core/src/main/java/org/apache/shiro/subject/SimplePrincipalCollection.java @@ -102,6 +102,7 @@ protected Collection getPrincipalsLazy(String realmName) { * * @inheritDoc */ + @Override public Object getPrimaryPrincipal() { if (isEmpty()) { return null; @@ -109,6 +110,7 @@ public Object getPrimaryPrincipal() { return iterator().next(); } + @Override public void add(Object principal, String realmName) { if (realmName == null) { throw new NullPointerException("realmName argument cannot be null."); @@ -120,6 +122,7 @@ public void add(Object principal, String realmName) { getPrincipalsLazy(realmName).add(principal); } + @Override public void addAll(Collection principals, String realmName) { if (realmName == null) { throw new NullPointerException("realmName argument cannot be null."); @@ -134,6 +137,7 @@ public void addAll(Collection principals, String realmName) { getPrincipalsLazy(realmName).addAll(principals); } + @Override public void addAll(PrincipalCollection principals) { if (principals.getRealmNames() != null) { for (String realmName : principals.getRealmNames()) { @@ -144,6 +148,7 @@ public void addAll(PrincipalCollection principals) { } } + @Override public T oneByType(Class type) { if (realmPrincipals == null || realmPrincipals.isEmpty()) { return null; @@ -159,6 +164,7 @@ public T oneByType(Class type) { return null; } + @Override public Collection byType(Class type) { if (realmPrincipals == null || realmPrincipals.isEmpty()) { return Collections.emptySet(); @@ -178,6 +184,7 @@ public Collection byType(Class type) { return Collections.unmodifiableSet(typed); } + @Override public List asList() { Set all = asSet(); if (all.isEmpty()) { @@ -186,6 +193,7 @@ public List asList() { return Collections.unmodifiableList(new ArrayList<>(all)); } + @Override public Set asSet() { if (realmPrincipals == null || realmPrincipals.isEmpty()) { return Collections.emptySet(); @@ -201,6 +209,7 @@ public Set asSet() { return Collections.unmodifiableSet(aggregated); } + @Override public Collection fromRealm(String realmName) { if (realmPrincipals == null || realmPrincipals.isEmpty()) { return Collections.emptySet(); @@ -212,6 +221,7 @@ public Collection fromRealm(String realmName) { return Collections.unmodifiableSet(principals); } + @Override public Set getRealmNames() { if (realmPrincipals == null) { return null; @@ -220,10 +230,12 @@ public Set getRealmNames() { } } + @Override public boolean isEmpty() { return realmPrincipals == null || realmPrincipals.isEmpty(); } + @Override public void clear() { this.cachedToString = null; if (realmPrincipals != null) { @@ -232,10 +244,12 @@ public void clear() { } } + @Override public Iterator iterator() { return asSet().iterator(); } + @Override public boolean equals(Object o) { if (o == this) { return true; @@ -246,6 +260,7 @@ public boolean equals(Object o) { return false; } + @Override public int hashCode() { if (this.realmPrincipals != null && !realmPrincipals.isEmpty()) { return realmPrincipals.hashCode(); @@ -259,6 +274,7 @@ public int hashCode() { * @return a simple string representation suitable for printing. * @since 1.0 */ + @Override public String toString() { if (this.cachedToString == null) { Set principals = asSet(); diff --git a/core/src/main/java/org/apache/shiro/subject/support/DefaultSubjectContext.java b/core/src/main/java/org/apache/shiro/subject/support/DefaultSubjectContext.java index f14612beea..5996833ba2 100644 --- a/core/src/main/java/org/apache/shiro/subject/support/DefaultSubjectContext.java +++ b/core/src/main/java/org/apache/shiro/subject/support/DefaultSubjectContext.java @@ -91,14 +91,17 @@ public DefaultSubjectContext(SubjectContext ctx) { super(ctx); } + @Override public SecurityManager getSecurityManager() { return getTypedValue(SECURITY_MANAGER, SecurityManager.class); } + @Override public void setSecurityManager(SecurityManager securityManager) { nullSafePut(SECURITY_MANAGER, securityManager); } + @Override public SecurityManager resolveSecurityManager() { SecurityManager securityManager = getSecurityManager(); if (securityManager == null) { @@ -117,22 +120,27 @@ public SecurityManager resolveSecurityManager() { return securityManager; } + @Override public Serializable getSessionId() { return getTypedValue(SESSION_ID, Serializable.class); } + @Override public void setSessionId(Serializable sessionId) { nullSafePut(SESSION_ID, sessionId); } + @Override public Subject getSubject() { return getTypedValue(SUBJECT, Subject.class); } + @Override public void setSubject(Subject subject) { nullSafePut(SUBJECT, subject); } + @Override public PrincipalCollection getPrincipals() { return getTypedValue(PRINCIPALS, PrincipalCollection.class); } @@ -141,12 +149,14 @@ private static boolean isEmpty(PrincipalCollection pc) { return pc == null || pc.isEmpty(); } + @Override public void setPrincipals(PrincipalCollection principals) { if (!isEmpty(principals)) { put(PRINCIPALS, principals); } } + @Override public PrincipalCollection resolvePrincipals() { PrincipalCollection principals = getPrincipals(); @@ -177,14 +187,17 @@ public PrincipalCollection resolvePrincipals() { } + @Override public Session getSession() { return getTypedValue(SESSION, Session.class); } + @Override public void setSession(Session session) { nullSafePut(SESSION, session); } + @Override public Session resolveSession() { Session session = getSession(); if (session == null) { @@ -197,24 +210,29 @@ public Session resolveSession() { return session; } + @Override public boolean isSessionCreationEnabled() { Boolean val = getTypedValue(SESSION_CREATION_ENABLED, Boolean.class); return val == null || val; } + @Override public void setSessionCreationEnabled(boolean enabled) { nullSafePut(SESSION_CREATION_ENABLED, enabled); } + @Override public boolean isAuthenticated() { Boolean authc = getTypedValue(AUTHENTICATED, Boolean.class); return authc != null && authc; } + @Override public void setAuthenticated(boolean authc) { put(AUTHENTICATED, authc); } + @Override public boolean resolveAuthenticated() { Boolean authc = getTypedValue(AUTHENTICATED, Boolean.class); if (authc == null) { @@ -235,32 +253,39 @@ public boolean resolveAuthenticated() { return authc; } + @Override public AuthenticationInfo getAuthenticationInfo() { return getTypedValue(AUTHENTICATION_INFO, AuthenticationInfo.class); } + @Override public void setAuthenticationInfo(AuthenticationInfo info) { nullSafePut(AUTHENTICATION_INFO, info); } + @Override public AuthenticationToken getAuthenticationToken() { return getTypedValue(AUTHENTICATION_TOKEN, AuthenticationToken.class); } + @Override public void setAuthenticationToken(AuthenticationToken token) { nullSafePut(AUTHENTICATION_TOKEN, token); } + @Override public String getHost() { return getTypedValue(HOST, String.class); } + @Override public void setHost(String host) { if (StringUtils.hasText(host)) { put(HOST, host); } } + @Override public String resolveHost() { String host = getHost(); @@ -282,10 +307,12 @@ public String resolveHost() { return host; } + @Override public void setRememberedPrincipals(boolean remembered) { put(REMEMBERED_PRINCIPALS, remembered); } + @Override public boolean isRememberedPrincipals() { Boolean remembered = getTypedValue(REMEMBERED_PRINCIPALS, Boolean.class); return remembered != null && remembered; diff --git a/core/src/main/java/org/apache/shiro/subject/support/DelegatingSubject.java b/core/src/main/java/org/apache/shiro/subject/support/DelegatingSubject.java index 1cc764eee9..8430b07d42 100644 --- a/core/src/main/java/org/apache/shiro/subject/support/DelegatingSubject.java +++ b/core/src/main/java/org/apache/shiro/subject/support/DelegatingSubject.java @@ -151,23 +151,28 @@ private Object getPrimaryPrincipal(PrincipalCollection principals) { /** * @see Subject#getPrincipal() */ + @Override public Object getPrincipal() { return getPrimaryPrincipal(getPrincipals()); } + @Override public PrincipalCollection getPrincipals() { List runAsPrincipals = getRunAsPrincipalsStack(); return CollectionUtils.isEmpty(runAsPrincipals) ? this.principals : runAsPrincipals.get(0); } + @Override public boolean isPermitted(String permission) { return hasPrincipals() && securityManager.isPermitted(getPrincipals(), permission); } + @Override public boolean isPermitted(Permission permission) { return hasPrincipals() && securityManager.isPermitted(getPrincipals(), permission); } + @Override public boolean[] isPermitted(String... permissions) { if (hasPrincipals()) { return securityManager.isPermitted(getPrincipals(), permissions); @@ -176,6 +181,7 @@ public boolean[] isPermitted(String... permissions) { } } + @Override public boolean[] isPermitted(List permissions) { if (hasPrincipals()) { return securityManager.isPermitted(getPrincipals(), permissions); @@ -184,10 +190,12 @@ public boolean[] isPermitted(List permissions) { } } + @Override public boolean isPermittedAll(String... permissions) { return hasPrincipals() && securityManager.isPermittedAll(getPrincipals(), permissions); } + @Override public boolean isPermittedAll(Collection permissions) { return hasPrincipals() && securityManager.isPermittedAll(getPrincipals(), permissions); } @@ -206,30 +214,36 @@ protected void assertAuthzCheckPossible() throws AuthorizationException { } } + @Override public void checkPermission(String permission) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkPermission(getPrincipals(), permission); } + @Override public void checkPermission(Permission permission) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkPermission(getPrincipals(), permission); } + @Override public void checkPermissions(String... permissions) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkPermissions(getPrincipals(), permissions); } + @Override public void checkPermissions(Collection permissions) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkPermissions(getPrincipals(), permissions); } + @Override public boolean hasRole(String roleIdentifier) { return hasPrincipals() && securityManager.hasRole(getPrincipals(), roleIdentifier); } + @Override public boolean[] hasRoles(List roleIdentifiers) { if (hasPrincipals()) { return securityManager.hasRoles(getPrincipals(), roleIdentifiers); @@ -238,25 +252,30 @@ public boolean[] hasRoles(List roleIdentifiers) { } } + @Override public boolean hasAllRoles(Collection roleIdentifiers) { return hasPrincipals() && securityManager.hasAllRoles(getPrincipals(), roleIdentifiers); } + @Override public void checkRole(String role) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkRole(getPrincipals(), role); } + @Override public void checkRoles(String... roleIdentifiers) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkRoles(getPrincipals(), roleIdentifiers); } + @Override public void checkRoles(Collection roles) throws AuthorizationException { assertAuthzCheckPossible(); securityManager.checkRoles(getPrincipals(), roles); } + @Override public void login(AuthenticationToken token) throws AuthenticationException { clearRunAsIdentitiesInternal(); Subject subject = securityManager.login(this, token); @@ -294,10 +313,12 @@ public void login(AuthenticationToken token) throws AuthenticationException { } } + @Override public boolean isAuthenticated() { return authenticated && hasPrincipals(); } + @Override public boolean isRemembered() { PrincipalCollection principals = getPrincipals(); return principals != null && !principals.isEmpty() && !isAuthenticated(); @@ -313,10 +334,12 @@ protected boolean isSessionCreationEnabled() { return this.sessionCreationEnabled; } + @Override public Session getSession() { return getSession(true); } + @Override public Session getSession(boolean create) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("attempting to get session; create = " + create @@ -362,6 +385,7 @@ private void clearRunAsIdentitiesInternal() { } } + @Override public void logout() { try { clearRunAsIdentitiesInternal(); @@ -382,6 +406,7 @@ public void sessionStopped() { this.session = null; } + @Override public V execute(Callable callable) throws ExecutionException { Callable associated = associateWith(callable); try { @@ -391,15 +416,18 @@ public V execute(Callable callable) throws ExecutionException { } } + @Override public void execute(Runnable runnable) { Runnable associated = associateWith(runnable); associated.run(); } + @Override public Callable associateWith(Callable callable) { return new SubjectCallable(this, callable); } + @Override public Runnable associateWith(Runnable runnable) { if (runnable instanceof Thread) { String msg = "This implementation does not support Thread arguments because of JDK ThreadLocal " @@ -420,6 +448,7 @@ private StoppingAwareProxiedSession(Session target, DelegatingSubject owningSubj owner = owningSubject; } + @Override public void stop() throws InvalidSessionException { super.stop(); owner.sessionStopped(); @@ -431,6 +460,7 @@ public void stop() throws InvalidSessionException { // 'Run As' support implementations // ====================================== + @Override public void runAs(PrincipalCollection principals) { if (!hasPrincipals()) { String msg = "This subject does not yet have an identity. Assuming the identity of another " @@ -442,11 +472,13 @@ public void runAs(PrincipalCollection principals) { pushIdentity(principals); } + @Override public boolean isRunAs() { List stack = getRunAsPrincipalsStack(); return !CollectionUtils.isEmpty(stack); } + @Override public PrincipalCollection getPreviousPrincipals() { PrincipalCollection previousPrincipals = null; List stack = getRunAsPrincipalsStack(); @@ -463,6 +495,7 @@ public PrincipalCollection getPreviousPrincipals() { return previousPrincipals; } + @Override public PrincipalCollection releaseRunAs() { return popIdentity(); } diff --git a/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java b/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java index de22779875..2b0fee6f7a 100644 --- a/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java +++ b/core/src/main/java/org/apache/shiro/subject/support/SubjectCallable.java @@ -84,6 +84,7 @@ protected SubjectCallable(Subject subject, ThreadState threadState, Callable this.securityManager = SubjectThreadState.getSecurityManager(subject); } + @Override public V call() throws Exception { if (ScopedValues.INSTANCE.isSupported()) { return ScopedValues.INSTANCE.call(this, callable, subject, securityManager); diff --git a/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java b/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java index 7fd93e90d0..34d336ba21 100644 --- a/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java +++ b/core/src/main/java/org/apache/shiro/subject/support/SubjectRunnable.java @@ -108,6 +108,7 @@ protected SubjectRunnable(Subject subject, ThreadState threadState, Runnable del * } * */ + @Override public void run() { if (ScopedValues.INSTANCE.isSupported()) { ScopedValues.INSTANCE.run(this, runnable, subject, securityManager); diff --git a/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java b/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java index 1bad717f87..6e7a891e15 100644 --- a/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java +++ b/core/src/main/java/org/apache/shiro/subject/support/SubjectThreadState.java @@ -78,6 +78,7 @@ protected Subject getSubject() { * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are * retained so they can be restored later via the {@link #restore restore} call. */ + @Override public void bind() { SecurityManager securityManager = this.securityManager; if (securityManager == null) { @@ -98,6 +99,7 @@ public void bind() { * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the * {@code ThreadContext} to ensure the thread state is exactly as it was before binding. */ + @Override public void restore() { ThreadContext.remove(); if (!CollectionUtils.isEmpty(this.originalResources)) { @@ -110,6 +112,7 @@ public void restore() { * only be called in special cases - it is more 'correct' to {@link #restore restore} a thread to its previous * state than to clear it entirely. */ + @Override public void clear() { ThreadContext.remove(); } diff --git a/core/src/main/java/org/apache/shiro/util/AbstractFactory.java b/core/src/main/java/org/apache/shiro/util/AbstractFactory.java index 97fce29f0e..2ab8885f53 100644 --- a/core/src/main/java/org/apache/shiro/util/AbstractFactory.java +++ b/core/src/main/java/org/apache/shiro/util/AbstractFactory.java @@ -43,6 +43,7 @@ public void setSingleton(boolean singleton) { this.singleton = singleton; } + @Override public T getInstance() { T instance; if (isSingleton()) { diff --git a/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java b/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java index 20fe93f333..4692f12a23 100644 --- a/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java +++ b/core/src/main/java/org/apache/shiro/util/AntPathMatcher.java @@ -104,6 +104,7 @@ public boolean isPattern(String path) { return (path.indexOf('*') != -1 || path.indexOf('?') != -1); } + @Override public boolean matches(String pattern, String source) { return match(pattern, source); } diff --git a/core/src/main/java/org/apache/shiro/util/MapContext.java b/core/src/main/java/org/apache/shiro/util/MapContext.java index c379d8a25e..2cb97a8baf 100644 --- a/core/src/main/java/org/apache/shiro/util/MapContext.java +++ b/core/src/main/java/org/apache/shiro/util/MapContext.java @@ -89,30 +89,37 @@ protected void nullSafePut(String key, Object value) { } } + @Override public int size() { return backingMap.size(); } + @Override public boolean isEmpty() { return backingMap.isEmpty(); } + @Override public boolean containsKey(Object o) { return backingMap.containsKey(o); } + @Override public boolean containsValue(Object o) { return backingMap.containsValue(o); } + @Override public Object get(Object o) { return backingMap.get(o); } + @Override public Object put(String s, Object o) { return backingMap.put(s, o); } + @Override public Object remove(Object o) { return backingMap.remove(o); } @@ -121,18 +128,22 @@ public void putAll(Map map) { backingMap.putAll(map); } + @Override public void clear() { backingMap.clear(); } + @Override public Set keySet() { return Collections.unmodifiableSet(backingMap.keySet()); } + @Override public Collection values() { return Collections.unmodifiableCollection(backingMap.values()); } + @Override public Set> entrySet() { return Collections.unmodifiableSet(backingMap.entrySet()); } diff --git a/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java b/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java index 6055d3e320..0aad0f3cc9 100644 --- a/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java +++ b/core/src/main/java/org/apache/shiro/util/RegExPatternMatcher.java @@ -48,6 +48,7 @@ public class RegExPatternMatcher implements PatternMatcher { * @param source the source to match * @return {@code true} if the source matches the required pattern, {@code false} otherwise. */ + @Override public boolean matches(String pattern, String source) { if (pattern == null) { throw new IllegalArgumentException("pattern argument cannot be null."); diff --git a/core/src/test/groovy/org/apache/shiro/config/IniSecurityManagerFactoryTest.groovy b/core/src/test/groovy/org/apache/shiro/config/IniSecurityManagerFactoryTest.groovy index a613797d75..611b235f92 100644 --- a/core/src/test/groovy/org/apache/shiro/config/IniSecurityManagerFactoryTest.groovy +++ b/core/src/test/groovy/org/apache/shiro/config/IniSecurityManagerFactoryTest.groovy @@ -149,6 +149,7 @@ class IniSecurityManagerFactoryTest { Subject subject = new Subject.Builder(sm).buildSubject(); //ensure thread clean-up after the login method returns. Test cases only: subject.execute(new Runnable() { + @Override public void run() { //the plain-text 'secret' should be converted to an Sha256 hash first //by the CredentialsMatcher. This should return quietly if diff --git a/core/src/test/groovy/org/apache/shiro/config/MockPermissionResolver.groovy b/core/src/test/groovy/org/apache/shiro/config/MockPermissionResolver.groovy index a75dba500c..c2b011e18a 100644 --- a/core/src/test/groovy/org/apache/shiro/config/MockPermissionResolver.groovy +++ b/core/src/test/groovy/org/apache/shiro/config/MockPermissionResolver.groovy @@ -29,6 +29,7 @@ class MockPermissionResolver implements PermissionResolver { boolean invoked = false + @Override Permission resolvePermission(String permissionString) { invoked = true return new WildcardPermission(permissionString) diff --git a/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy b/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy index 42611551e9..1d922fb214 100644 --- a/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy +++ b/core/src/test/groovy/org/apache/shiro/realm/CachingRealmTest.groovy @@ -145,10 +145,12 @@ class CachingRealmTest { boolean templateMethodCalled = false boolean doClearCacheCalled = false + @Override boolean supports(AuthenticationToken token) { return true } + @Override AuthenticationInfo getAuthenticationInfo(AuthenticationToken token) { return info; } diff --git a/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java b/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java index 969f05122d..c60c682c99 100644 --- a/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java +++ b/core/src/test/java/org/apache/shiro/authc/AbstractAuthenticatorTest.java @@ -59,6 +59,7 @@ static void setUpLogger() { private AbstractAuthenticator createAuthcReturnNull() { return new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { return null; } @@ -67,6 +68,7 @@ protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws Au private AbstractAuthenticator createAuthcReturnValidAuthcInfo() { return new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { return info; } @@ -85,6 +87,7 @@ public void setUp() { @Test void newAbstractAuthenticatorSecurityManagerConstructor() { abstractAuthenticator = new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { return info; } @@ -146,6 +149,7 @@ void notifyFailureAfterDoAuthenticateThrowsAuthenticationException() { final AuthenticationException ae = new AuthenticationException("dummy exception to test notification"); abstractAuthenticator = new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { throw ae; } @@ -173,6 +177,7 @@ protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws Au void notifyFailureAfterDoAuthenticateThrowsNonAuthenticationException() { assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> { abstractAuthenticator = new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { throw new IllegalArgumentException("not an AuthenticationException subclass"); } @@ -189,6 +194,7 @@ void logExceptionAfterDoAuthenticateThrowsNonAuthenticationException() { + " for test logExceptionAfterDoAuthenticateThrowsNonAuthenticationException"; abstractAuthenticator = new AbstractAuthenticator() { + @Override protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException { throw new IllegalArgumentException(expectedExceptionMessage); } diff --git a/core/src/test/java/org/apache/shiro/authc/credential/Sha256CredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/Sha256CredentialsMatcherTest.java index d4e3715e70..ea9b233703 100644 --- a/core/src/test/java/org/apache/shiro/authc/credential/Sha256CredentialsMatcherTest.java +++ b/core/src/test/java/org/apache/shiro/authc/credential/Sha256CredentialsMatcherTest.java @@ -28,10 +28,12 @@ @Deprecated public class Sha256CredentialsMatcherTest extends AbstractHashedCredentialsMatcherTest { + @Override public Class getMatcherClass() { return Sha256CredentialsMatcher.class; } + @Override public SimpleHash hash(Object credentials) { return new Sha256Hash(credentials); } diff --git a/core/src/test/java/org/apache/shiro/authc/credential/Sha384CredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/Sha384CredentialsMatcherTest.java index 0c9b7437fd..d7855b2041 100644 --- a/core/src/test/java/org/apache/shiro/authc/credential/Sha384CredentialsMatcherTest.java +++ b/core/src/test/java/org/apache/shiro/authc/credential/Sha384CredentialsMatcherTest.java @@ -28,10 +28,12 @@ @Deprecated public class Sha384CredentialsMatcherTest extends AbstractHashedCredentialsMatcherTest { + @Override public Class getMatcherClass() { return Sha384CredentialsMatcher.class; } + @Override public SimpleHash hash(Object credentials) { return new Sha384Hash(credentials); } diff --git a/core/src/test/java/org/apache/shiro/authc/credential/Sha512CredentialsMatcherTest.java b/core/src/test/java/org/apache/shiro/authc/credential/Sha512CredentialsMatcherTest.java index dd96ea27d8..f348dbae8a 100644 --- a/core/src/test/java/org/apache/shiro/authc/credential/Sha512CredentialsMatcherTest.java +++ b/core/src/test/java/org/apache/shiro/authc/credential/Sha512CredentialsMatcherTest.java @@ -28,10 +28,12 @@ @Deprecated public class Sha512CredentialsMatcherTest extends AbstractHashedCredentialsMatcherTest { + @Override public Class getMatcherClass() { return Sha512CredentialsMatcher.class; } + @Override public SimpleHash hash(Object credentials) { return new Sha512Hash(credentials); } diff --git a/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java b/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java index c73b031181..95c1929874 100644 --- a/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java +++ b/core/src/test/java/org/apache/shiro/authc/pam/AllSuccessfulStrategyTest.java @@ -59,6 +59,7 @@ void beforeAttemptRealmDoesntSupportToken() { assertThatExceptionOfType(UnsupportedTokenException.class).isThrownBy(() -> { Realm notSupportingRealm = new AuthorizingRealm() { + @Override public boolean supports(AuthenticationToken token) { return false; } diff --git a/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java b/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java index 62b44c8bdd..4c00b987ae 100644 --- a/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java +++ b/core/src/test/java/org/apache/shiro/authz/ModularRealmAuthorizerTest.java @@ -56,6 +56,7 @@ void testSettingOfRolePermissionResolver() { // now set the RolePermissionResolver RolePermissionResolver rolePermissionResolver = new RolePermissionResolver() { + @Override public Collection resolvePermissionsInRole(String roleString) { return null; } diff --git a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerObjectInputFilterTest.java b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerObjectInputFilterTest.java index 5b819fa150..d6120f2c62 100644 --- a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerObjectInputFilterTest.java +++ b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerObjectInputFilterTest.java @@ -184,6 +184,7 @@ protected void forgetIdentity(Subject subject) { forgetCount++; } + @Override public void forgetIdentity(SubjectContext subjectContext) { stored = null; forgetCount++; diff --git a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java index 7405156427..89bf989f23 100644 --- a/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java +++ b/core/src/test/java/org/apache/shiro/mgt/AbstractRememberMeManagerTest.java @@ -58,6 +58,7 @@ protected byte[] getRememberedSerializedIdentity(SubjectContext subjectContext) @SuppressWarnings("checkstyle:FinalClass") private static class DummyRememberMeManager extends AbstractRememberMeManager { + @Override public void forgetIdentity(SubjectContext subjectContext) { //do nothing } diff --git a/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java b/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java index 13b3252418..ba47492d23 100644 --- a/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java +++ b/core/src/test/java/org/apache/shiro/mgt/DefaultSecurityManagerTest.java @@ -64,6 +64,7 @@ public void setup() { } @AfterEach + @Override public void tearDown() { SecurityUtils.setSecurityManager(null); sm.destroy(); diff --git a/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java b/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java index 55b82f634b..017cfc016d 100644 --- a/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java +++ b/core/src/test/java/org/apache/shiro/realm/AuthorizingRealmTest.java @@ -123,10 +123,12 @@ protected AuthenticationInfo buildAuthenticationInfo(Object principal, Object cr @Test void testNullAuthzInfo() { AuthorizingRealm realm = new AuthorizingRealm() { + @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { return null; } + @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { return null; } @@ -208,6 +210,7 @@ void testRealmWithRolePermissionResolver() { AuthorizingRealm realm = new AllowAllRealm(); realm.setRolePermissionResolver(new RolePermissionResolver() { + @Override public Collection resolvePermissionsInRole(String roleString) { Collection permissions = new HashSet(); if (roleString.equals(ROLE)) { @@ -234,6 +237,7 @@ void testRealmWithEmptyOrNullPermissions() { AuthorizingRealm realm = new AllowAllRealm(); realm.setRolePermissionResolver(new RolePermissionResolver() { + @Override public Collection resolvePermissionsInRole(String roleString) { Collection permissions = new HashSet(); if (roleString.equals(ROLE)) { @@ -276,10 +280,12 @@ public AllowAllRealm() { setCredentialsMatcher(new AllowAllCredentialsMatcher()); } + @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { return buildAuthenticationInfo(token.getPrincipal(), token.getCredentials()); } + @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { Set roles = new HashSet(); roles.add(ROLE); diff --git a/core/src/test/java/org/apache/shiro/realm/UserIdPrincipal.java b/core/src/test/java/org/apache/shiro/realm/UserIdPrincipal.java index 1ddc709317..cf82212e1f 100644 --- a/core/src/test/java/org/apache/shiro/realm/UserIdPrincipal.java +++ b/core/src/test/java/org/apache/shiro/realm/UserIdPrincipal.java @@ -33,6 +33,7 @@ public int getUserId() { return userId; } + @Override public String getName() { return String.valueOf(userId); } diff --git a/core/src/test/java/org/apache/shiro/realm/UsernamePrincipal.java b/core/src/test/java/org/apache/shiro/realm/UsernamePrincipal.java index f9535f6d6d..1149c803a5 100644 --- a/core/src/test/java/org/apache/shiro/realm/UsernamePrincipal.java +++ b/core/src/test/java/org/apache/shiro/realm/UsernamePrincipal.java @@ -33,6 +33,7 @@ public String getUsername() { return username; } + @Override public String getName() { return String.valueOf(username); } diff --git a/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java b/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java index 6b25db52e5..3c03c864a7 100644 --- a/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java +++ b/core/src/test/java/org/apache/shiro/realm/activedirectory/ActiveDirectoryRealmTest.java @@ -269,6 +269,7 @@ public TestActiveDirectoryRealm() { credentialsMatcher = new CredentialsMatcher() { + @Override public boolean doCredentialsMatch(AuthenticationToken object, AuthenticationInfo object1) { return true; } @@ -303,6 +304,7 @@ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principal } // override ldap query because i don't care about testing that piece in this case + @Override protected AuthenticationInfo queryForAuthenticationInfo(AuthenticationToken token, LdapContextFactory ldapContextFactory) { return new SimpleAccount(token.getPrincipal(), token.getCredentials(), getName()); diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java index ea1be3403f..0a2ab99e94 100644 --- a/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java +++ b/core/src/test/java/org/apache/shiro/realm/ldap/DefaultLdapRealmTest.java @@ -160,10 +160,12 @@ void testGetAuthenticationInfoNonSimpleToken() throws NamingException { replay(factory); realm.getAuthenticationInfo(new AuthenticationToken() { + @Override public Object getPrincipal() { return userId; } + @Override public Object getCredentials() { return "secret"; } diff --git a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java index e2b36cef2c..2030f8fe62 100644 --- a/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java +++ b/core/src/test/java/org/apache/shiro/realm/ldap/JndiLdapRealmTest.java @@ -32,10 +32,12 @@ @Deprecated public class JndiLdapRealmTest extends DefaultLdapRealmTest { + @Override protected DefaultLdapRealm getNewRealmUnderTest() { return new JndiLdapRealm(); } + @Override @Test public void testGetUserDnWithOutPrefixAndSuffix() { JndiLdapRealm realm = new JndiLdapRealm() { diff --git a/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java b/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java index 4384a6fa44..396710e9bd 100644 --- a/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java +++ b/core/src/test/java/org/apache/shiro/realm/text/TextConfigurationRealmTest.java @@ -57,6 +57,7 @@ private void setUpForReadConfigurationTest() { * Demonstrates that a lock can't be obtained on the realm by a read thread until after * the lock is released. */ + @Override public void test(Thread runnable) throws InterruptedException { // Obtain the realm's locks usersLock.writeLock().lock(); @@ -100,6 +101,7 @@ private void executeTest(Runnable runnable) throws InterruptedException { void testRoleAndUserAccount() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { + @Override public void run() { assertTrue(realm.roleExists("role1"), "role not found when it was expected"); assertTrue(realm.accountExists("user1"), "user not found when it was expected"); @@ -114,6 +116,7 @@ public void run() { void testHasRole() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { + @Override public void run() { PrincipalCollection principalCollection = ImmutablePrincipalCollection.ofSinglePrincipal("user1", "realm1"); assertTrue(realm.hasRole(principalCollection, "role2"), @@ -131,6 +134,7 @@ public void run() { void testCheckRole() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { + @Override public void run() { PrincipalCollection principalCollection = ImmutablePrincipalCollection.ofSinglePrincipal("user1", "realm1"); try { @@ -149,6 +153,7 @@ public void run() { void testCheckPermission() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { + @Override public void run() { PrincipalCollection principalCollection = ImmutablePrincipalCollection.ofSinglePrincipal("user1", "realm1"); try { @@ -169,6 +174,7 @@ void testIsPermitted() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { + @Override public void run() { PrincipalCollection principalCollection = ImmutablePrincipalCollection.ofSinglePrincipal("user1", "realm1"); assertTrue(realm.isPermitted(principalCollection, @@ -187,6 +193,7 @@ public void run() { @Test void testProcessRoleDefinitions() throws InterruptedException { realm = new TestRealm() { + @Override public void test(Thread runnable) throws InterruptedException { // While the realm's lock is held by this thread role definitions cannot be processed // Obtain the realm's locks @@ -203,6 +210,7 @@ public void test(Thread runnable) throws InterruptedException { }; // A thread to process new role definitions TestThread testThread = new TestThread(new Runnable() { + @Override public void run() { try { realm.processRoleDefinitions(); @@ -225,6 +233,7 @@ public void run() { @Test void testProcessUserDefinitions() throws InterruptedException { realm = new TestRealm() { + @Override public void test(Thread runnable) throws InterruptedException { // While the realm's lock is held by this thread user definitions cannot be processed // Obtain the realm's locks @@ -240,6 +249,7 @@ public void test(Thread runnable) throws InterruptedException { } }; TestThread testThread = new TestThread(new Runnable() { + @Override public void run() { try { realm.processUserDefinitions(); @@ -267,6 +277,7 @@ private class TestThread implements Runnable { this.test = test; } + @Override public void run() { try { test.run(); diff --git a/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java index d49567c06e..76d2b4a757 100644 --- a/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java +++ b/core/src/test/java/org/apache/shiro/session/mgt/AbstractValidatingSessionManagerTest.java @@ -101,14 +101,17 @@ protected Collection getActiveSessions() { @Test void testNoMemoryLeakOnInvalidSessions() throws Exception { SessionListener sessionListener = new SessionListener() { + @Override public void onStart(Session session) { session.setAttribute("I love", "Romania"); } + @Override public void onStop(Session session) { tryToCleanSession(session); } + @Override public void onExpiration(Session session) { tryToCleanSession(session); } diff --git a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java index b0b88d7308..ca305913da 100644 --- a/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java +++ b/core/src/test/java/org/apache/shiro/session/mgt/DefaultSessionManagerTest.java @@ -87,6 +87,7 @@ void testGlobalTimeout() { void testSessionListenerStartNotification() { final boolean[] started = new boolean[1]; SessionListener listener = new SessionListenerAdapter() { + @Override public void onStart(Session session) { started[0] = true; } @@ -100,6 +101,7 @@ public void onStart(Session session) { void testSessionListenerStopNotification() { final boolean[] stopped = new boolean[1]; SessionListener listener = new SessionListenerAdapter() { + @Override public void onStop(Session session) { stopped[0] = true; } @@ -118,6 +120,7 @@ void testSessionListenerStopNotificationWithReadAttribute() { final boolean[] stopped = new boolean[1]; final String[] value = new String[1]; SessionListener listener = new SessionListenerAdapter() { + @Override public void onStop(Session session) { stopped[0] = true; value[0] = (String) session.getAttribute("foo"); @@ -138,6 +141,7 @@ public void onStop(Session session) { void testSessionListenerExpiredNotification() { final boolean[] expired = new boolean[1]; SessionListener listener = new SessionListenerAdapter() { + @Override public void onExpiration(Session session) { expired[0] = true; } @@ -169,6 +173,7 @@ void testSessionDeleteOnExpiration() { final Session[] activeSession = new SimpleSession[] {session1}; sm.setSessionFactory(new SessionFactory() { + @Override public Session createSession(SessionContext initData) { return activeSession[0]; } @@ -247,10 +252,12 @@ private static class SessionTimeoutMatcher implements IArgumentMatcher { this.timeout = timeout; } + @Override public void appendTo(StringBuffer buffer) { buffer.append("eqSession(timeout=").append(this.timeout).append(")"); } + @Override public boolean matches(Object o) { return o instanceof Session session && session.getTimeout() == this.timeout; } diff --git a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java index 3b0d65a0ca..67cf39ba1a 100644 --- a/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java +++ b/core/src/test/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationSchedulerTest.java @@ -104,6 +104,7 @@ public void tearDown() throws Exception { } private static final class FakeDefaultSessionManager extends DefaultSessionManager { + @Override public void validateSessions() throws RuntimeException { throw new RuntimeException("Session test exception"); } diff --git a/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java b/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java index 9b2a2175aa..df4b2b0999 100644 --- a/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java +++ b/core/src/test/java/org/apache/shiro/subject/DelegatingSubjectTest.java @@ -95,6 +95,7 @@ void testExecuteCallable() { assertThat(ThreadContext.getSecurityManager()).isNull(); Callable callable = new Callable() { + @Override public String call() throws Exception { Subject callingSubject = SecurityUtils.getSubject(); assertThat(callingSubject).isNotNull(); @@ -125,6 +126,7 @@ void testExecuteRunnable() { assertThat(ThreadContext.getSecurityManager()).isNull(); Runnable runnable = new Runnable() { + @Override public void run() { Subject callingSubject = SecurityUtils.getSubject(); assertThat(callingSubject).isNotNull(); diff --git a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/DefaultBlockCipherService.java b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/DefaultBlockCipherService.java index 6d70f9b234..51d19fbcdc 100644 --- a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/DefaultBlockCipherService.java +++ b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/DefaultBlockCipherService.java @@ -455,6 +455,7 @@ public void setStreamingBlockSize(int streamingBlockSize) { * @param streaming if the transformation string is going to be used for a Cipher performing stream-based encryption or not. * @return the transformation string */ + @Override protected String getTransformationString(boolean streaming) { if (streaming) { if (this.streamingTransformationString == null) { diff --git a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/JcaCipherService.java b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/JcaCipherService.java index fb832d201b..7dae7df9b6 100644 --- a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/JcaCipherService.java +++ b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/JcaCipherService.java @@ -303,6 +303,7 @@ protected byte[] generateInitializationVector(boolean streaming) { return ivBytes; } + @Override public ByteSource encrypt(byte[] plaintext, byte[] key) { byte[] ivBytes = null; boolean generate = isGenerateInitializationVectors(false); @@ -347,6 +348,7 @@ private ByteSource encrypt(byte[] plaintext, byte[] key, byte[] iv, boolean prep return ByteSource.Util.bytes(output); } + @Override public ByteSourceBroker decrypt(byte[] ciphertext, byte[] key) throws CryptoException { return new SimpleByteSourceBroker(this, ciphertext, key); } @@ -504,6 +506,7 @@ private void init(javax.crypto.Cipher cipher, int mode, java.security.Key key, } + @Override public void encrypt(InputStream in, OutputStream out, byte[] key) throws CryptoException { byte[] iv = null; boolean generate = isGenerateInitializationVectors(true); @@ -530,6 +533,7 @@ private void encrypt(InputStream in, OutputStream out, byte[] key, byte[] iv, bo crypt(in, out, key, iv, javax.crypto.Cipher.ENCRYPT_MODE); } + @Override public void decrypt(InputStream in, OutputStream out, byte[] key) throws CryptoException { decrypt(in, out, key, isGenerateInitializationVectors(true)); } diff --git a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/SimpleByteSourceBroker.java b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/SimpleByteSourceBroker.java index 8e872f558c..b0a0d9a224 100644 --- a/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/SimpleByteSourceBroker.java +++ b/crypto/cipher/src/main/java/org/apache/shiro/crypto/cipher/SimpleByteSourceBroker.java @@ -43,6 +43,7 @@ public SimpleByteSourceBroker(JcaCipherService cipherService, byte[] ciphertext, this.key = key.clone(); } + @Override public synchronized void useBytes(ByteSourceUser user) { if (destroyed || user == null) { return; @@ -57,12 +58,14 @@ public synchronized void useBytes(ByteSourceUser user) { } + @Override public byte[] getClonedBytes() { ByteSource byteSource = cipherService.decryptInternal(ciphertext, key); // this's a newly created byte array return byteSource.getBytes(); } + @Override public void destroy() throws Exception { if (!destroyed) { synchronized (this) { diff --git a/crypto/core/src/main/java/org/apache/shiro/crypto/SecureRandomNumberGenerator.java b/crypto/core/src/main/java/org/apache/shiro/crypto/SecureRandomNumberGenerator.java index 25a091eb93..2128af28ae 100644 --- a/crypto/core/src/main/java/org/apache/shiro/crypto/SecureRandomNumberGenerator.java +++ b/crypto/core/src/main/java/org/apache/shiro/crypto/SecureRandomNumberGenerator.java @@ -106,10 +106,12 @@ public void setDefaultNextBytesSize(int defaultNextBytesSize) throws IllegalArgu this.defaultNextBytesSize = defaultNextBytesSize; } + @Override public ByteSource nextBytes() { return nextBytes(getDefaultNextBytesSize()); } + @Override public ByteSource nextBytes(int numBytes) { if (numBytes <= 0) { throw new IllegalArgumentException("numBytes argument must be a positive integer (1 or larger)"); diff --git a/crypto/hash/src/test/groovy/org/apache/shiro/crypto/hash/format/ToStringHashFormat.groovy b/crypto/hash/src/test/groovy/org/apache/shiro/crypto/hash/format/ToStringHashFormat.groovy index 6ff0fdbe7f..eaae50ad43 100644 --- a/crypto/hash/src/test/groovy/org/apache/shiro/crypto/hash/format/ToStringHashFormat.groovy +++ b/crypto/hash/src/test/groovy/org/apache/shiro/crypto/hash/format/ToStringHashFormat.groovy @@ -27,6 +27,7 @@ import org.apache.shiro.crypto.hash.Hash */ class ToStringHashFormat implements HashFormat { + @Override String format(Hash hash) { return hash.toString() } diff --git a/event/src/main/java/org/apache/shiro/event/support/AnnotationEventListenerResolver.java b/event/src/main/java/org/apache/shiro/event/support/AnnotationEventListenerResolver.java index 3ab39f9cd2..59c32e5e6a 100644 --- a/event/src/main/java/org/apache/shiro/event/support/AnnotationEventListenerResolver.java +++ b/event/src/main/java/org/apache/shiro/event/support/AnnotationEventListenerResolver.java @@ -53,6 +53,7 @@ public AnnotationEventListenerResolver() { * @return a new collection of {@link EventListener} instances, each instance corresponding to an annotated * method discovered on the specified {@code instance} argument. */ + @Override public List getEventListeners(Object instance) { if (instance == null) { return Collections.emptyList(); diff --git a/event/src/main/java/org/apache/shiro/event/support/DefaultEventBus.java b/event/src/main/java/org/apache/shiro/event/support/DefaultEventBus.java index 418e110975..2e6227525e 100644 --- a/event/src/main/java/org/apache/shiro/event/support/DefaultEventBus.java +++ b/event/src/main/java/org/apache/shiro/event/support/DefaultEventBus.java @@ -126,6 +126,7 @@ public Map getRegistry() { } } + @Override public void publish(Object event) { if (event == null) { LOGGER.info("Received null event for publishing. Ignoring and returning."); @@ -155,6 +156,7 @@ public void publish(Object event) { } } + @Override public void register(Object instance) { if (instance == null) { LOGGER.info("Received null instance for event listener registration. Ignoring registration request."); @@ -181,6 +183,7 @@ public void register(Object instance) { } } + @Override public void unregister(Object instance) { if (instance == null) { return; diff --git a/event/src/main/java/org/apache/shiro/event/support/EventClassComparator.java b/event/src/main/java/org/apache/shiro/event/support/EventClassComparator.java index c85445375a..075ea150c6 100644 --- a/event/src/main/java/org/apache/shiro/event/support/EventClassComparator.java +++ b/event/src/main/java/org/apache/shiro/event/support/EventClassComparator.java @@ -48,6 +48,7 @@ * @since 1.3 */ public class EventClassComparator implements Comparator> { + @Override public int compare(Class a, Class b) { if (a == null) { if (b == null) { diff --git a/event/src/main/java/org/apache/shiro/event/support/EventListenerComparator.java b/event/src/main/java/org/apache/shiro/event/support/EventListenerComparator.java index a9a5c616a2..e51f89c58f 100644 --- a/event/src/main/java/org/apache/shiro/event/support/EventListenerComparator.java +++ b/event/src/main/java/org/apache/shiro/event/support/EventListenerComparator.java @@ -39,6 +39,7 @@ public class EventListenerComparator implements Comparator { //event class comparator is stateless, so we can retain an instance: private static final EventClassComparator EVENT_CLASS_COMPARATOR = new EventClassComparator(); + @Override public int compare(EventListener a, EventListener b) { if (a == null) { if (b == null) { diff --git a/event/src/main/java/org/apache/shiro/event/support/SingleArgumentMethodEventListener.java b/event/src/main/java/org/apache/shiro/event/support/SingleArgumentMethodEventListener.java index 48d59c4bba..47e51ecd14 100644 --- a/event/src/main/java/org/apache/shiro/event/support/SingleArgumentMethodEventListener.java +++ b/event/src/main/java/org/apache/shiro/event/support/SingleArgumentMethodEventListener.java @@ -55,14 +55,17 @@ private void assertPublicMethod(Method method) { } } + @Override public boolean accepts(Object event) { return event != null && getEventType().isInstance(event); } + @Override public Class getEventType() { return getMethodArgumentType(getMethod()); } + @Override public void onEvent(Object event) { Method method = getMethod(); try { diff --git a/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy b/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy index 51327b7a9a..9ce45d39bd 100644 --- a/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy +++ b/event/src/test/groovy/org/apache/shiro/event/support/DefaultEventBusTest.groovy @@ -39,6 +39,7 @@ class DefaultEventBusTest { @Test void testSetEventListenerResolver() { def resolver = new EventListenerResolver() { + @Override List getEventListeners(Object instance) { return null //dummy implementation } @@ -87,6 +88,7 @@ class DefaultEventBusTest { @Test void testSubscribeWithNullResolvedListeners() { def resolver = new EventListenerResolver() { + @Override List getEventListeners(Object instance) { return null //dummy implementation } diff --git a/lang/src/main/java/org/apache/shiro/lang/io/DefaultSerializer.java b/lang/src/main/java/org/apache/shiro/lang/io/DefaultSerializer.java index 9f2683e3de..a932f12a59 100644 --- a/lang/src/main/java/org/apache/shiro/lang/io/DefaultSerializer.java +++ b/lang/src/main/java/org/apache/shiro/lang/io/DefaultSerializer.java @@ -55,6 +55,7 @@ public class DefaultSerializer implements Serializer { * @return the bytes representing the serialized object using standard JVM serialization. * @throws SerializationException wrapping a {@link IOException} if something goes wrong with the streams. */ + @Override public byte[] serialize(T o) throws SerializationException { if (o == null) { String msg = "argument cannot be null."; @@ -85,6 +86,7 @@ public byte[] serialize(T o) throws SerializationException { * @return the deserialized/reconstituted object based on the given byte array * @throws SerializationException if anything goes wrong using the streams. */ + @Override public T deserialize(byte[] serialized) throws SerializationException { if (serialized == null) { String msg = "argument cannot be null."; diff --git a/lang/src/main/java/org/apache/shiro/lang/util/ByteSourceWrapper.java b/lang/src/main/java/org/apache/shiro/lang/util/ByteSourceWrapper.java index 2e41d413a9..365244f1f8 100644 --- a/lang/src/main/java/org/apache/shiro/lang/util/ByteSourceWrapper.java +++ b/lang/src/main/java/org/apache/shiro/lang/util/ByteSourceWrapper.java @@ -49,6 +49,7 @@ public byte[] getBytes() { return bytes; } + @Override public void close() throws IOException { ByteUtils.wipe(bytes); } diff --git a/lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java b/lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java index ef00fadd1f..f9a4a243c1 100644 --- a/lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java +++ b/lang/src/main/java/org/apache/shiro/lang/util/ClassUtils.java @@ -367,6 +367,7 @@ public interface ClassLoaderAccessor { * @since 1.0 */ public abstract static class ExceptionIgnoringAccessor implements ClassLoaderAccessor { + @Override public Class loadClass(String fqcn) { Class clazz = null; ClassLoader cl = getClassLoader(); @@ -383,6 +384,7 @@ public Class loadClass(String fqcn) { return clazz; } + @Override public InputStream getResourceStream(String name) { InputStream is = null; ClassLoader cl = getClassLoader(); @@ -392,6 +394,7 @@ public InputStream getResourceStream(String name) { return is; } + @Override public URL getResource(String name) { URL url = null; ClassLoader cl = getClassLoader(); diff --git a/lang/src/main/java/org/apache/shiro/lang/util/SoftHashMap.java b/lang/src/main/java/org/apache/shiro/lang/util/SoftHashMap.java index d488c127c5..373ae2aaa7 100644 --- a/lang/src/main/java/org/apache/shiro/lang/util/SoftHashMap.java +++ b/lang/src/main/java/org/apache/shiro/lang/util/SoftHashMap.java @@ -150,6 +150,7 @@ public SoftHashMap(Map source, int retentionSize) { putAll(source); } + @Override public V get(Object key) { processQueue(); @@ -204,22 +205,26 @@ private void processQueue() { } } + @Override public boolean isEmpty() { processQueue(); return map.isEmpty(); } + @Override public boolean containsKey(Object key) { processQueue(); return map.containsKey(key); } + @Override public boolean containsValue(Object value) { processQueue(); Collection values = values(); return values.contains(value); } + @Override public void putAll(Map m) { if (m == null || m.isEmpty()) { processQueue(); @@ -230,11 +235,13 @@ public void putAll(Map m) { } } + @Override public Set keySet() { processQueue(); return map.keySet(); } + @Override public Collection values() { processQueue(); Collection keys = map.keySet(); @@ -254,6 +261,7 @@ public Collection values() { /** * Creates a new entry, but wraps the value in a SoftValue instance to enable auto garbage collection. */ + @Override public V put(K key, V value) { // throw out garbage collected values first processQueue(); @@ -263,6 +271,7 @@ public V put(K key, V value) { return previous != null ? previous.get() : null; } + @Override public V remove(Object key) { // throw out garbage collected values first processQueue(); @@ -270,6 +279,7 @@ public V remove(Object key) { return raw != null ? raw.get() : null; } + @Override public void clear() { strongReferencesLock.lock(); try { @@ -282,12 +292,14 @@ public void clear() { map.clear(); } + @Override public int size() { // throw out garbage collected values first processQueue(); return map.size(); } + @Override public Set> entrySet() { // throw out garbage collected values first processQueue(); diff --git a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/Account.java b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/Account.java index c58dce8cc4..aedfbadcf4 100644 --- a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/Account.java +++ b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/Account.java @@ -174,6 +174,7 @@ public Date getCreationDate() { * @see java.lang.Object#toString() */ + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE). append("id", id). diff --git a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/AccountTransaction.java b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/AccountTransaction.java index a3eab3d819..dbcd9bd5b8 100644 --- a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/AccountTransaction.java +++ b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/AccountTransaction.java @@ -135,6 +135,7 @@ public Date getCreationDate() { * @see java.lang.Object#toString() */ + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE). append("id", id). diff --git a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java index 2706734d61..4ffa43ea2e 100644 --- a/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java +++ b/samples/aspectj/src/main/java/org/apache/shiro/samples/aspectj/bank/SecureBankService.java @@ -85,6 +85,7 @@ public int getAccountCount() { * @see com.connectif.trilogy.root.security.BankService#createNewAccount(java.lang.String) */ + @Override @RequiresPermissions("bankAccount:create") public long createNewAccount(String anOwnerName) { assertServiceState(); @@ -105,6 +106,7 @@ public long createNewAccount(String anOwnerName) { * @see com.connectif.trilogy.root.security.BankService#searchAccountIdsByOwner(java.lang.String) */ + @Override public long[] searchAccountIdsByOwner(String anOwnerName) { assertServiceState(); LOGGER.info("Searching existing accounts for " + anOwnerName); @@ -132,6 +134,7 @@ public long[] searchAccountIdsByOwner(String anOwnerName) { * @see com.connectif.trilogy.root.security.BankService#getOwnerOf(long) */ + @Override @RequiresPermissions("bankAccount:read") public String getOwnerOf(long anAccountId) throws AccountNotFoundException { assertServiceState(); @@ -145,6 +148,7 @@ public String getOwnerOf(long anAccountId) throws AccountNotFoundException { * @see com.connectif.trilogy.root.security.BankService#getBalanceOf(long) */ + @Override @RequiresPermissions("bankAccount:read") public double getBalanceOf(long anAccountId) throws AccountNotFoundException { assertServiceState(); @@ -158,6 +162,7 @@ public double getBalanceOf(long anAccountId) throws AccountNotFoundException { * @see com.connectif.trilogy.root.security.BankService#depositInto(long, double) */ + @Override @RequiresPermissions("bankAccount:operate") public double depositInto(long anAccountId, double anAmount) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); @@ -182,6 +187,7 @@ public double depositInto(long anAccountId, double anAmount) throws AccountNotFo /* (non-Javadoc) * @see com.connectif.trilogy.root.security.BankService#withdrawFrom(long, double) */ + @Override @RequiresPermissions("bankAccount:operate") public double withdrawFrom(long anAccountId, double anAmount) throws AccountNotFoundException, NotEnoughFundsException, InactiveAccountException { @@ -203,6 +209,7 @@ public double withdrawFrom(long anAccountId, double anAmount) * @see com.connectif.trilogy.root.security.BankService#getTxHistoryFor(long) */ + @Override @RequiresPermissions("bankAccount:read") public TxLog[] getTxHistoryFor(long anAccountId) throws AccountNotFoundException { assertServiceState(); @@ -229,6 +236,7 @@ public TxLog[] getTxHistoryFor(long anAccountId) throws AccountNotFoundException * @see com.connectif.trilogy.root.security.BankService#closeAccount(long) */ + @Override @RequiresPermissions("bankAccount:close") public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException { assertServiceState(); @@ -258,6 +266,7 @@ public double closeAccount(long anAccountId) throws AccountNotFoundException, In * @see com.connectif.trilogy.root.security.BankService#isAccountActive(long) */ + @Override @RequiresPermissions("bankAccount:read") public boolean isAccountActive(long anAccountId) throws AccountNotFoundException { assertServiceState(); diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/BootstrapDataPopulator.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/BootstrapDataPopulator.java index 79f8e0d6c9..a0a19ece94 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/BootstrapDataPopulator.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/BootstrapDataPopulator.java @@ -39,6 +39,7 @@ public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } + @Override public void afterPropertiesSet() throws Exception { //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the //app starts, so insert the sample admin user at startup: diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateUserDAO.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateUserDAO.java index ccc11363e7..69059207ee 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateUserDAO.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/dao/HibernateUserDAO.java @@ -27,24 +27,29 @@ @Repository("userDAO") public class HibernateUserDAO extends HibernateDao implements UserDAO { + @Override public User getUser(Long userId) { return (User) getSession().find(User.class, userId); } + @Override public User findUser(String username) { Assert.hasText(username); String query = "from User u where u.username = :username"; return getSession().createQuery(query, User.class).setParameter("username", username).getSingleResultOrNull(); } + @Override public void createUser(User user) { getSession().persist(user); } + @Override public List getAllUsers() { return getSession().createQuery("from User order by username", User.class).getResultList(); } + @Override public void deleteUser(Long userId) { User user = getUser(userId); if (user != null) { @@ -52,6 +57,7 @@ public void deleteUser(Long userId) { } } + @Override public void updateUser(User user) { getSession().merge(user); } diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/DefaultUserService.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/DefaultUserService.java index a03804dc75..da4fd9cfef 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/DefaultUserService.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/service/DefaultUserService.java @@ -43,6 +43,7 @@ public void setUserDAO(UserDAO userDAO) { this.userDAO = userDAO; } + @Override public User getCurrentUser() { final Long currentUserId = (Long) SecurityUtils.getSubject().getPrincipal(); if (currentUserId != null) { @@ -52,6 +53,7 @@ public User getCurrentUser() { } } + @Override public void createUser(String username, String email, String password) { User user = new User(); user.setUsername(username); @@ -60,18 +62,22 @@ public void createUser(String username, String email, String password) { userDAO.createUser(user); } + @Override public List getAllUsers() { return userDAO.getAllUsers(); } + @Override public User getUser(Long userId) { return userDAO.getUser(userId); } + @Override public void deleteUser(Long userId) { userDAO.deleteUser(userId); } + @Override public void updateUser(User user) { userDAO.updateUser(user); } diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserValidator.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserValidator.java index f5d5944e5f..6bc46f8dff 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserValidator.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/EditUserValidator.java @@ -32,10 +32,12 @@ public class EditUserValidator implements Validator { private static final String SIMPLE_EMAIL_REGEX = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}"; + @Override public boolean supports(Class aClass) { return EditUserCommand.class.isAssignableFrom(aClass); } + @Override public void validate(Object o, Errors errors) { EditUserCommand command = (EditUserCommand) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.empty", "Please specify a username."); diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginValidator.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginValidator.java index 9b799c26da..2e594c0972 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginValidator.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/LoginValidator.java @@ -26,10 +26,12 @@ * Validator for login. */ public class LoginValidator implements Validator { + @Override public boolean supports(Class aClass) { return LoginCommand.class.isAssignableFrom(aClass); } + @Override public void validate(Object o, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.empty", "Please specify a username."); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "error.password.empty", "Please specify a password."); diff --git a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupValidator.java b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupValidator.java index 14e3bd7df7..f0b12bba13 100644 --- a/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupValidator.java +++ b/samples/spring-hibernate/src/main/java/org/apache/shiro/samples/sprhib/web/SignupValidator.java @@ -32,10 +32,12 @@ public class SignupValidator implements Validator { private static final String SIMPLE_EMAIL_REGEX = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}"; + @Override public boolean supports(Class aClass) { return SignupCommand.class.isAssignableFrom(aClass); } + @Override public void validate(Object o, Errors errors) { SignupCommand command = (SignupCommand) o; ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username.empty", "Please specify a username."); diff --git a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/BootstrapDataPopulator.java b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/BootstrapDataPopulator.java index 4f358a0b94..4500805fe6 100644 --- a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/BootstrapDataPopulator.java +++ b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/BootstrapDataPopulator.java @@ -65,6 +65,7 @@ public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; } + @Override public void afterPropertiesSet() throws Exception { //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the //app starts, so create the tables and insert the 2 sample users on bootstrap: diff --git a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java index 1585dac398..b4070e5c21 100644 --- a/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java +++ b/samples/spring-mvc/src/main/java/org/apache/shiro/samples/spring/DefaultSampleManager.java @@ -58,6 +58,7 @@ public class DefaultSampleManager implements SampleManager { /*-------------------------------------------- | M E T H O D S | ============================================*/ + @Override public String getValue() { String value = null; @@ -74,6 +75,7 @@ public String getValue() { return value; } + @Override public void setValue(String newValue) { Subject subject = SecurityUtils.getSubject(); Session session = subject.getSession(); @@ -86,18 +88,21 @@ public void setValue(String newValue) { session.setAttribute(VALUE_KEY, newValue); } + @Override public void secureMethod1() { if (LOGGER.isInfoEnabled()) { LOGGER.info("Secure method 1 called..."); } } + @Override public void secureMethod2() { if (LOGGER.isInfoEnabled()) { LOGGER.info("Secure method 2 called..."); } } + @Override public void secureMethod3() { if (LOGGER.isInfoEnabled()) { LOGGER.info("Secure method 3 called..."); diff --git a/support/aspectj/src/main/java/org/apache/shiro/aspectj/BeforeAdviceMethodInvocationAdapter.java b/support/aspectj/src/main/java/org/apache/shiro/aspectj/BeforeAdviceMethodInvocationAdapter.java index a90ef1607d..25fc283c71 100644 --- a/support/aspectj/src/main/java/org/apache/shiro/aspectj/BeforeAdviceMethodInvocationAdapter.java +++ b/support/aspectj/src/main/java/org/apache/shiro/aspectj/BeforeAdviceMethodInvocationAdapter.java @@ -78,6 +78,7 @@ public static BeforeAdviceMethodInvocationAdapter createFrom(JoinPoint aJoinPoin * @see org.apache.shiro.aop.MethodInvocation#getArguments() */ + @Override public Object[] getArguments() { return someArguments; } @@ -86,6 +87,7 @@ public Object[] getArguments() { * @see org.apache.shiro.aop.MethodInvocation#getMethod() */ + @Override public Method getMethod() { return method; } @@ -94,6 +96,7 @@ public Method getMethod() { * @see org.apache.shiro.aop.MethodInvocation#proceed() */ + @Override public Object proceed() throws Throwable { // Do nothing since this adapts a before advice return null; @@ -102,6 +105,7 @@ public Object proceed() throws Throwable { /** * @since 1.0 */ + @Override public Object getThis() { return anObject; } diff --git a/support/aspectj/src/test/java/org/apache/shiro/aspectj/RestrictedDummyService.java b/support/aspectj/src/test/java/org/apache/shiro/aspectj/RestrictedDummyService.java index e8314d0321..c37318a530 100644 --- a/support/aspectj/src/test/java/org/apache/shiro/aspectj/RestrictedDummyService.java +++ b/support/aspectj/src/test/java/org/apache/shiro/aspectj/RestrictedDummyService.java @@ -26,6 +26,7 @@ @RequiresPermissions("dummy:admin") public class RestrictedDummyService extends SecuredDummyService { + @Override public void retrieve() { log("retrieve *RESTRICTED*"); super.retrieve(); diff --git a/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java b/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java index 5c8942ed3a..091a91eec1 100644 --- a/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java +++ b/support/aspectj/src/test/java/org/apache/shiro/aspectj/SecuredDummyService.java @@ -30,6 +30,7 @@ */ public class SecuredDummyService implements DummyService { + @Override @RequiresAuthentication @RequiresPermissions("dummy:admin") public void change() { @@ -38,25 +39,30 @@ public void change() { peek(); } + @Override public void anonymous() { log("anonymous"); } + @Override @RequiresGuest public void guest() { log("guest"); } + @Override @RequiresUser public void peek() { log("peek"); } + @Override @RequiresPermissions("dummy:user") public void retrieve() { log("retrieve"); } + @Override public void log(String aMessage) { if (aMessage != null) { System.out.println(new Timestamp(System.currentTimeMillis()) diff --git a/support/guice/src/main/java/org/apache/shiro/guice/BeanTypeListener.java b/support/guice/src/main/java/org/apache/shiro/guice/BeanTypeListener.java index 26ecd2def1..c3137fbfab 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/BeanTypeListener.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/BeanTypeListener.java @@ -92,6 +92,7 @@ class BeanTypeListener implements TypeListener { SuppressPropertiesBeanIntrospector.SUPPRESS_CLASS); } + @Override public void hear(TypeLiteral type, final TypeEncounter encounter) { PropertyDescriptor[] propertyDescriptors = beanUtilsBean.getPropertyUtils().getPropertyDescriptors(type.getRawType()); final Map> propertyDependencies @@ -105,6 +106,7 @@ public void hear(TypeLiteral type, final TypeEncounter encounter) { } } encounter.register(new MembersInjector() { + @Override public void injectMembers(I instance) { for (Map.Entry> dependency : propertyDependencies.entrySet()) { try { diff --git a/support/guice/src/main/java/org/apache/shiro/guice/GuiceEnvironment.java b/support/guice/src/main/java/org/apache/shiro/guice/GuiceEnvironment.java index 2d3046ef2a..efd7e6e9bf 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/GuiceEnvironment.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/GuiceEnvironment.java @@ -30,6 +30,7 @@ class GuiceEnvironment implements Environment { this.securityManager = securityManager; } + @Override public SecurityManager getSecurityManager() { return securityManager; } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/LifecycleTypeListener.java b/support/guice/src/main/java/org/apache/shiro/guice/LifecycleTypeListener.java index 7a7d97719d..0afe74f9b2 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/LifecycleTypeListener.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/LifecycleTypeListener.java @@ -37,6 +37,7 @@ class LifecycleTypeListener implements TypeListener { this.registry = registry; } + @Override public void hear(TypeLiteral type, TypeEncounter encounter) { if (InitializableInjectionListener.MATCHER.matches(type)) { encounter.register(this.castListener(new InitializableInjectionListener())); diff --git a/support/guice/src/main/java/org/apache/shiro/guice/ShiroModule.java b/support/guice/src/main/java/org/apache/shiro/guice/ShiroModule.java index cf15836c7f..9095f64d54 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/ShiroModule.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/ShiroModule.java @@ -76,6 +76,7 @@ public void configure() { bindListener(Matchers.any(), new SubscribedEventTypeListener()); bindListener(Matchers.any(), new EventBusAwareTypeListener()); final DestroyableInjectionListener.DestroyableRegistry registry = new DestroyableInjectionListener.DestroyableRegistry() { + @Override public void add(Destroyable destroyable) { ShiroModule.this.add(destroyable); } @@ -191,6 +192,7 @@ protected void bindEventBus(AnnotatedBindingBuilder bind) { * * @throws Exception */ + @Override public final void destroy() { for (Destroyable destroyable : destroyables) { try { diff --git a/support/guice/src/main/java/org/apache/shiro/guice/ShiroSessionScope.java b/support/guice/src/main/java/org/apache/shiro/guice/ShiroSessionScope.java index 7f2a46d7df..8872a2ed01 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/ShiroSessionScope.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/ShiroSessionScope.java @@ -31,8 +31,10 @@ * Guice scope for Shiro sessions. Not bound by default. */ public class ShiroSessionScope implements Scope { + @Override public Provider scope(final Key key, final Provider unscoped) { return new Provider() { + @Override public T get() { Subject subject; if (ScopedValues.INSTANCE.isSupported() && ScopedValues.INSTANCE.isBound()) { diff --git a/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapter.java b/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapter.java index 4d7fbda6da..619d355dbd 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapter.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapter.java @@ -32,6 +32,7 @@ class AopAllianceMethodInterceptorAdapter implements MethodInterceptor { this.shiroInterceptor = shiroInterceptor; } + @Override public Object invoke(MethodInvocation invocation) throws Throwable { return shiroInterceptor.invoke(new AopAllianceMethodInvocationAdapter(invocation)); } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapter.java b/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapter.java index 62f57e17f9..c03090321e 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapter.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/aop/AopAllianceMethodInvocationAdapter.java @@ -33,22 +33,27 @@ class AopAllianceMethodInvocationAdapter implements org.apache.shiro.aop.MethodI this.mi = mi; } + @Override public Method getMethod() { return mi.getMethod(); } + @Override public Object[] getArguments() { return mi.getArguments(); } + @Override public String toString() { return "Method invocation [" + mi.getMethod() + "]"; } + @Override public Object proceed() throws Throwable { return mi.proceed(); } + @Override public Object getThis() { return mi.getThis(); } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/AbstractInjectionProvider.java b/support/guice/src/main/java/org/apache/shiro/guice/web/AbstractInjectionProvider.java index 684da73add..13124bd91e 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/web/AbstractInjectionProvider.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/web/AbstractInjectionProvider.java @@ -52,6 +52,7 @@ class AbstractInjectionProvider implements ProviderWithDependencies { this.dependencies = Collections.unmodifiableSet(dependencyBuilder); } + @Override public T get() { Constructor constructor = getConstructor(); Object[] params = new Object[constructor.getParameterTypes().length]; @@ -78,6 +79,7 @@ protected T postProcess(T t) { return t; } + @Override public Set> getDependencies() { return dependencies; } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/FilterChainResolverProvider.java b/support/guice/src/main/java/org/apache/shiro/guice/web/FilterChainResolverProvider.java index 348375fc3a..55480f65fc 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/web/FilterChainResolverProvider.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/web/FilterChainResolverProvider.java @@ -63,10 +63,12 @@ public void setPatternMatcher(PatternMatcher patternMatcher) { this.patternMatcher = patternMatcher; } + @Override public Set> getDependencies() { return dependencies; } + @Override public FilterChainResolver get() { return new SimpleFilterChainResolver(chains, injector, patternMatcher); } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChain.java b/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChain.java index 1e4b4bc38d..e619d40b14 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChain.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChain.java @@ -39,6 +39,7 @@ class SimpleFilterChain implements FilterChain { this.chain = chain; } + @Override public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { if (chain.hasNext()) { Filter filter = chain.next(); diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChainResolver.java b/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChainResolver.java index 3981f4db64..f63d0e0a0c 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChainResolver.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/web/SimpleFilterChainResolver.java @@ -46,6 +46,7 @@ class SimpleFilterChainResolver implements FilterChainResolver { this.patternMatcher = patternMatcher; } + @Override public FilterChain getChain(ServletRequest request, ServletResponse response, final FilterChain originalChain) { String requestURI = WebUtils.getPathWithinApplication(WebUtils.toHttp(request)); final String requestURINoTrailingSlash = removeTrailingSlash(requestURI); @@ -66,12 +67,17 @@ public FilterChain getChain(ServletRequest request, ServletResponse response, fi private FilterChain proxy(FilterChain originalChain, String pathPattern) { final Iterator> chain = Arrays.asList(chains.get(pathPattern)).iterator(); return new SimpleFilterChain(originalChain, new Iterator<>() { + @Override public boolean hasNext() { return chain.hasNext(); } + + @Override public Filter next() { return injector.getInstance(chain.next()); } + + @Override public void remove() { throw new UnsupportedOperationException(); } diff --git a/support/guice/src/main/java/org/apache/shiro/guice/web/WebGuiceEnvironment.java b/support/guice/src/main/java/org/apache/shiro/guice/web/WebGuiceEnvironment.java index 09e758639c..c6efcee37b 100644 --- a/support/guice/src/main/java/org/apache/shiro/guice/web/WebGuiceEnvironment.java +++ b/support/guice/src/main/java/org/apache/shiro/guice/web/WebGuiceEnvironment.java @@ -50,22 +50,27 @@ class WebGuiceEnvironment implements WebEnvironment { servletContext.setAttribute(EnvironmentLoaderListener.ENVIRONMENT_ATTRIBUTE_KEY, this); } + @Override public FilterChainResolver getFilterChainResolver() { return filterChainResolver; } + @Override public ServletContext getServletContext() { return servletContext; } + @Override public WebSecurityManager getWebSecurityManager() { return securityManager; } + @Override public SecurityManager getSecurityManager() { return securityManager; } + @Override public ShiroFilterConfiguration getShiroFilterConfiguration() { return filterConfiguration; } diff --git a/support/guice/src/test/java/org/apache/shiro/guice/LifecycleTypeListenerTest.java b/support/guice/src/test/java/org/apache/shiro/guice/LifecycleTypeListenerTest.java index e145f03c6c..76e787204f 100644 --- a/support/guice/src/test/java/org/apache/shiro/guice/LifecycleTypeListenerTest.java +++ b/support/guice/src/test/java/org/apache/shiro/guice/LifecycleTypeListenerTest.java @@ -67,12 +67,14 @@ void testHearDestroyable() throws Exception { static class MyInitializable implements Initializable { + @Override public void init() throws ShiroException { // do nothing } } static class MyDestroyable implements Destroyable { + @Override public void destroy() throws Exception { // do nothing } diff --git a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java index 704797fbac..ba65bb1b4f 100644 --- a/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java +++ b/support/guice/src/test/java/org/apache/shiro/guice/aop/AopAllianceMethodInterceptorAdapterTest.java @@ -38,6 +38,7 @@ void testInvoke() throws Throwable { MethodInvocation allianceInvocation = createMock(MethodInvocation.class); MethodInterceptor mockShiroInterceptor = createMock(MethodInterceptor.class); expect(mockShiroInterceptor.invoke(anyObject(AopAllianceMethodInvocationAdapter.class))).andAnswer(new IAnswer() { + @Override public Object answer() throws Throwable { return getCurrentArguments()[0]; } diff --git a/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java b/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java index 0bc91b8d4d..290e5b2bed 100644 --- a/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java +++ b/support/guice/src/test/java/org/apache/shiro/guice/aop/ShiroAopModuleTest.java @@ -176,6 +176,7 @@ private static class MyAnnotationMethodInterceptor extends AnnotationMethodInter super(new MyAnnotationHandler(MyTestAnnotation.class)); } + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { return null; } diff --git a/support/jaxrs/src/main/java/org/apache/shiro/web/jaxrs/ShiroSecurityContext.java b/support/jaxrs/src/main/java/org/apache/shiro/web/jaxrs/ShiroSecurityContext.java index cbc7ca833b..8018dbec4b 100644 --- a/support/jaxrs/src/main/java/org/apache/shiro/web/jaxrs/ShiroSecurityContext.java +++ b/support/jaxrs/src/main/java/org/apache/shiro/web/jaxrs/ShiroSecurityContext.java @@ -93,6 +93,7 @@ public Object getObject() { return object; } + @Override public String getName() { return getObject().toString(); } @@ -112,10 +113,12 @@ public boolean equals(Object o) { } + @Override public int hashCode() { return object.hashCode(); } + @Override public String toString() { return object.toString(); } diff --git a/support/jcache/src/main/java/org/apache/shiro/cache/jcache/JCacheManager.java b/support/jcache/src/main/java/org/apache/shiro/cache/jcache/JCacheManager.java index 9f1760f677..409744fde3 100644 --- a/support/jcache/src/main/java/org/apache/shiro/cache/jcache/JCacheManager.java +++ b/support/jcache/src/main/java/org/apache/shiro/cache/jcache/JCacheManager.java @@ -103,6 +103,7 @@ public Cache getCache(String name) throws CacheException { * * @throws org.apache.shiro.cache.CacheException if there are any CacheExceptions thrown by JCache. */ + @Override public final void init() throws CacheException { ensureCacheManager(); } @@ -141,6 +142,7 @@ private javax.cache.CacheManager ensureCacheManager() { * a non-null CacheManager into this instance before calling {@link #init() init}, this instance expects that same * component to also destroy the CacheManager instance, and it will not attempt to do so. */ + @Override public void destroy() { if (cacheManagerImplicitlyCreated) { try { @@ -211,6 +213,7 @@ public V get(K key) throws CacheException { * @param key the key. * @param value the value. */ + @Override public V put(K key, V value) throws CacheException { LOGGER.trace("Putting object in cache [{}] for key [{}]", cache.getName(), key); try { @@ -229,6 +232,7 @@ public V put(K key, V value) throws CacheException { * * @param key the key of the element to remove */ + @Override public V remove(K key) throws CacheException { LOGGER.trace("Removing object from cache [{}] for key [{}]", cache.getName(), key); try { @@ -241,6 +245,7 @@ public V remove(K key) throws CacheException { /** * Removes all elements in the cache, but leaves the cache in a usable state. */ + @Override public void clear() throws CacheException { LOGGER.trace("Clearing all objects from cache [{}]", cache.getName()); try { @@ -250,6 +255,7 @@ public void clear() throws CacheException { } } + @Override public int size() { return (int) toStream(cache.iterator()).count(); } diff --git a/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationJob.java b/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationJob.java index 5e5af4ae07..8848065d0f 100644 --- a/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationJob.java +++ b/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationJob.java @@ -68,6 +68,7 @@ public class QuartzSessionValidationJob implements Job { * * @param context the Quartz job execution context for this execution. */ + @Override public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap jobDataMap = context.getMergedJobDataMap(); diff --git a/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationScheduler.java b/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationScheduler.java index 1a76886f48..9d3e8cd3ed 100644 --- a/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationScheduler.java +++ b/support/quartz/src/main/java/org/apache/shiro/session/mgt/quartz/QuartzSessionValidationScheduler.java @@ -125,6 +125,7 @@ public void setSessionManager(ValidatingSessionManager sessionManager) { this.sessionManager = sessionManager; } + @Override public boolean isEnabled() { return this.enabled; } @@ -149,6 +150,7 @@ public void setSessionValidationInterval(long sessionValidationInterval) { * Starts session validation by creating a Quartz simple trigger, linking it to * the {@link QuartzSessionValidationJob}, and scheduling it with the Quartz scheduler. */ + @Override public void enableSessionValidation() { if (LOGGER.isDebugEnabled()) { @@ -191,6 +193,7 @@ public void enableSessionValidation() { } } + @Override @SuppressWarnings("checkstyle:NPathComplexity") public void disableSessionValidation() { if (LOGGER.isDebugEnabled()) { diff --git a/support/spring/src/main/java/org/apache/shiro/spring/LifecycleBeanPostProcessor.java b/support/spring/src/main/java/org/apache/shiro/spring/LifecycleBeanPostProcessor.java index d25296b92c..917605b183 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/LifecycleBeanPostProcessor.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/LifecycleBeanPostProcessor.java @@ -79,6 +79,7 @@ public LifecycleBeanPostProcessor(int order) { * @return the initialized bean. * @throws BeansException if any exception is thrown during initialization. */ + @Override public Object postProcessBeforeInitialization(Object object, String name) throws BeansException { if (object instanceof Initializable initializable) { try { @@ -98,6 +99,7 @@ public Object postProcessBeforeInitialization(Object object, String name) throws /** * Does nothing - merely returns the object argument immediately. */ + @Override public Object postProcessAfterInitialization(Object object, String name) throws BeansException { // Does nothing after initialization return object; @@ -111,6 +113,7 @@ public Object postProcessAfterInitialization(Object object, String name) throws * @param name the name of the bean being initialized. * @throws BeansException if any exception is thrown during initialization. */ + @Override public void postProcessBeforeDestruction(Object object, String name) throws BeansException { if (object instanceof Destroyable destroyable) { try { @@ -130,6 +133,7 @@ public void postProcessBeforeDestruction(Object object, String name) throws Bean * * @return order value. */ + @Override public int getOrder() { // LifecycleBeanPostProcessor needs Order. See https://issues.apache.org/jira/browse/SHIRO-222 return order; @@ -142,6 +146,7 @@ public int getOrder() { * @return true only if bean implements Destroyable. * @since 1.4 */ + @Override @SuppressWarnings("unused") public boolean requiresDestruction(Object bean) { return (bean instanceof Destroyable); diff --git a/support/spring/src/main/java/org/apache/shiro/spring/aop/SpringAnnotationResolver.java b/support/spring/src/main/java/org/apache/shiro/spring/aop/SpringAnnotationResolver.java index 2ed4451f4f..f4f2348745 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/aop/SpringAnnotationResolver.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/aop/SpringAnnotationResolver.java @@ -36,6 +36,7 @@ */ public class SpringAnnotationResolver implements AnnotationResolver { + @Override public Annotation getAnnotation(MethodInvocation mi, Class clazz) { Method m = mi.getMethod(); diff --git a/support/spring/src/main/java/org/apache/shiro/spring/config/ShiroAnnotationProcessorConfiguration.java b/support/spring/src/main/java/org/apache/shiro/spring/config/ShiroAnnotationProcessorConfiguration.java index e87ef3b3ae..c55caa4abd 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/config/ShiroAnnotationProcessorConfiguration.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/config/ShiroAnnotationProcessorConfiguration.java @@ -38,6 +38,7 @@ public static DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { } @Bean + @Override protected AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { return super.authorizationAttributeSourceAdvisor(securityManager); } diff --git a/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AopAllianceAnnotationsAuthorizingMethodInterceptor.java b/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AopAllianceAnnotationsAuthorizingMethodInterceptor.java index 96535d0326..4c8ec83970 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AopAllianceAnnotationsAuthorizingMethodInterceptor.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AopAllianceAnnotationsAuthorizingMethodInterceptor.java @@ -73,22 +73,27 @@ protected org.apache.shiro.aop.MethodInvocation createMethodInvocation(Object im final MethodInvocation mi = (MethodInvocation) implSpecificMethodInvocation; return new org.apache.shiro.aop.MethodInvocation() { + @Override public Method getMethod() { return mi.getMethod(); } + @Override public Object[] getArguments() { return mi.getArguments(); } + @Override public String toString() { return "Method invocation [" + mi.getMethod() + "]"; } + @Override public Object proceed() throws Throwable { return mi.proceed(); } + @Override public Object getThis() { return mi.getThis(); } @@ -118,6 +123,7 @@ protected Object continueInvocation(Object aopAllianceMethodInvocation) throws T * @return the return value from invoking the method invocation. * @throws Throwable if the underlying AOP Alliance method invocation throws a Throwable. */ + @Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { org.apache.shiro.aop.MethodInvocation mi = createMethodInvocation(methodInvocation); return super.invoke(mi); diff --git a/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisor.java b/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisor.java index f8feee4bcd..5fb466c45e 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisor.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/security/interceptor/AuthorizationAttributeSourceAdvisor.java @@ -82,6 +82,7 @@ public void setSecurityManager(org.apache.shiro.mgt.SecurityManager securityMana * @return true if the method has a Shiro annotation, false otherwise. * @see org.springframework.aop.MethodMatcher#matches(java.lang.reflect.Method, Class) */ + @Override public boolean matches(Method method, Class targetClass) { Method m = method; diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroFilterFactoryBean.java b/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroFilterFactoryBean.java index 9b8c711798..eea21fec42 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroFilterFactoryBean.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/web/ShiroFilterFactoryBean.java @@ -419,6 +419,7 @@ public Filter getObject() throws Exception { * * @return {@link org.apache.shiro.web.servlet.AbstractShiroFilter}.class */ + @Override public Class getObjectType() { return SpringShiroFilter.class; } diff --git a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebFilterConfiguration.java b/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebFilterConfiguration.java index fb91f70144..5204e18c8c 100644 --- a/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebFilterConfiguration.java +++ b/support/spring/src/main/java/org/apache/shiro/spring/web/config/ShiroWebFilterConfiguration.java @@ -44,6 +44,7 @@ protected ShiroFilterFactoryBean shiroFilterFactoryBean() { } @Bean(name = "globalFilters") + @Override protected List globalFilters() { return super.globalFilters(); } diff --git a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DefaultTestService.java b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DefaultTestService.java index 66283213c0..b29759dc00 100644 --- a/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DefaultTestService.java +++ b/support/spring/src/test/java/org/apache/shiro/spring/security/interceptor/DefaultTestService.java @@ -29,38 +29,48 @@ */ public class DefaultTestService implements TestService { + @Override @RequiresGuest public void guestImplementation() { } + @Override public void guestInterface() { } + @Override @RequiresUser public void userImplementation() { } + @Override public void userInterface() { } + @Override @RequiresAuthentication public void authenticatedImplementation() { } + @Override public void authenticatedInterface() { } + @Override @RequiresRoles("test") public void roleImplementation() { } + @Override public void roleInterface() { } + @Override @RequiresPermissions("test:execute") public void permissionImplementation() { } + @Override public void permissionInterface() { } } diff --git a/support/spring/src/test/java/org/apache/shiro/spring/testconfig/EventBusConsumersTestConfiguration.java b/support/spring/src/test/java/org/apache/shiro/spring/testconfig/EventBusConsumersTestConfiguration.java index bb1121c2b2..5f9ce97974 100644 --- a/support/spring/src/test/java/org/apache/shiro/spring/testconfig/EventBusConsumersTestConfiguration.java +++ b/support/spring/src/test/java/org/apache/shiro/spring/testconfig/EventBusConsumersTestConfiguration.java @@ -46,6 +46,7 @@ public EventBus getEventBus() { return eventBus; } + @Override public void setEventBus(EventBus eventBus) { this.eventBus = eventBus; } diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/DummyFilter.java b/support/spring/src/test/java/org/apache/shiro/spring/web/DummyFilter.java index 044824887f..83438d12cf 100644 --- a/support/spring/src/test/java/org/apache/shiro/spring/web/DummyFilter.java +++ b/support/spring/src/test/java/org/apache/shiro/spring/web/DummyFilter.java @@ -39,15 +39,18 @@ public class DummyFilter implements Filter { public DummyFilter() { } + @Override public void init(FilterConfig filterConfig) throws ServletException { //no-op } + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(request, response); } + @Override public void destroy() { //no-op } diff --git a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java index 8541146d8a..34fed91cb2 100644 --- a/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java +++ b/support/spring/src/test/java/org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.java @@ -103,6 +103,7 @@ void filterDefinitionWithInit() throws Exception { verify(mockFilterConfig); FilterChain filterChain = new FilterChain() { + @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; diff --git a/web/src/main/java/org/apache/shiro/web/env/DefaultWebEnvironment.java b/web/src/main/java/org/apache/shiro/web/env/DefaultWebEnvironment.java index 5f33b85555..74274fd9ed 100644 --- a/web/src/main/java/org/apache/shiro/web/env/DefaultWebEnvironment.java +++ b/web/src/main/java/org/apache/shiro/web/env/DefaultWebEnvironment.java @@ -45,10 +45,12 @@ public DefaultWebEnvironment() { super(); } + @Override public FilterChainResolver getFilterChainResolver() { return getObject(DEFAULT_FILTER_CHAIN_RESOLVER_NAME, FilterChainResolver.class); } + @Override public void setFilterChainResolver(FilterChainResolver filterChainResolver) { setObject(DEFAULT_FILTER_CHAIN_RESOLVER_NAME, filterChainResolver); } @@ -64,12 +66,14 @@ public void setSecurityManager(SecurityManager securityManager) { super.setSecurityManager(securityManager); } + @Override public WebSecurityManager getWebSecurityManager() { SecurityManager sm = super.getSecurityManager(); assertWebSecurityManager(sm); return (WebSecurityManager) sm; } + @Override public void setWebSecurityManager(WebSecurityManager wsm) { super.setSecurityManager(wsm); } @@ -81,10 +85,12 @@ private void assertWebSecurityManager(SecurityManager sm) { } } + @Override public ServletContext getServletContext() { return this.servletContext; } + @Override public void setServletContext(ServletContext servletContext) { this.servletContext = servletContext; } diff --git a/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoaderListener.java b/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoaderListener.java index efa6457de1..2225184a27 100644 --- a/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoaderListener.java +++ b/web/src/main/java/org/apache/shiro/web/env/EnvironmentLoaderListener.java @@ -53,6 +53,7 @@ public class EnvironmentLoaderListener extends EnvironmentLoader implements Serv * * @param sce the ServletContextEvent triggered upon application startup */ + @Override public void contextInitialized(ServletContextEvent sce) { initEnvironment(sce.getServletContext()); } @@ -63,6 +64,7 @@ public void contextInitialized(ServletContextEvent sce) { * * @param sce the ServletContextEvent triggered upon application shutdown */ + @Override public void contextDestroyed(ServletContextEvent sce) { destroyEnvironment(sce.getServletContext()); } diff --git a/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java b/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java index b6bdd5d9b4..8f048767b1 100644 --- a/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java +++ b/web/src/main/java/org/apache/shiro/web/env/IniWebEnvironment.java @@ -82,6 +82,7 @@ public IniWebEnvironment() { * Initializes this instance by resolving any potential (explicit or resource-configured) {@link Ini} * configuration and calling {@link #configure() configure} for actual instance configuration. */ + @Override public void init() { setIni(parseConfig()); diff --git a/web/src/main/java/org/apache/shiro/web/env/ResourceBasedWebEnvironment.java b/web/src/main/java/org/apache/shiro/web/env/ResourceBasedWebEnvironment.java index c747c55ae3..2868f28294 100644 --- a/web/src/main/java/org/apache/shiro/web/env/ResourceBasedWebEnvironment.java +++ b/web/src/main/java/org/apache/shiro/web/env/ResourceBasedWebEnvironment.java @@ -34,6 +34,7 @@ public String[] getConfigLocations() { return configLocations; } + @Override public void setConfigLocations(String locations) { if (!StringUtils.hasText(locations)) { throw new IllegalArgumentException("Null/empty locations argument not allowed."); @@ -42,6 +43,7 @@ public void setConfigLocations(String locations) { setConfigLocations(arr); } + @Override public void setConfigLocations(String[] configLocations) { this.configLocations = configLocations; } diff --git a/web/src/main/java/org/apache/shiro/web/filter/AccessControlFilter.java b/web/src/main/java/org/apache/shiro/web/filter/AccessControlFilter.java index 5b940b336e..950a212d85 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/AccessControlFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/AccessControlFilter.java @@ -159,6 +159,7 @@ protected boolean onAccessDenied(ServletRequest request, ServletResponse respons * {@link #onAccessDenied(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse) onAccessDenied}. * @throws Exception if an error occurs. */ + @Override public boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception { return isAccessAllowed(request, response, mappedValue) || onAccessDenied(request, response, mappedValue); } diff --git a/web/src/main/java/org/apache/shiro/web/filter/PathMatchingFilter.java b/web/src/main/java/org/apache/shiro/web/filter/PathMatchingFilter.java index 73d057ae2b..df64745174 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/PathMatchingFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/PathMatchingFilter.java @@ -81,6 +81,7 @@ public abstract class PathMatchingFilter extends AdviceFilter implements PathCon * @param config the specified for this particular filter only for the given path * @return this configured filter. */ + @Override public Filter processPathConfig(String path, String config) { String[] values = null; if (config != null) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/authc/BearerHttpAuthenticationFilter.java b/web/src/main/java/org/apache/shiro/web/filter/authc/BearerHttpAuthenticationFilter.java index 9229b294b9..34aaa64923 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/authc/BearerHttpAuthenticationFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/authc/BearerHttpAuthenticationFilter.java @@ -70,6 +70,7 @@ public BearerHttpAuthenticationFilter() { * @param response outgoing ServletResponse * @return the AuthenticationToken used to execute the login attempt */ + @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String authorizationHeader = getAuthzHeader(request); if (authorizationHeader == null || authorizationHeader.length() == 0) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/authc/FormAuthenticationFilter.java b/web/src/main/java/org/apache/shiro/web/filter/authc/FormAuthenticationFilter.java index d33804ba3e..8f98b428fe 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/authc/FormAuthenticationFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/authc/FormAuthenticationFilter.java @@ -193,16 +193,19 @@ protected boolean isLoginSubmission(ServletRequest request, ServletResponse resp return (request instanceof HttpServletRequest) && WebUtils.toHttp(request).getMethod().equalsIgnoreCase(POST_METHOD); } + @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String username = getUsername(request); String password = getPassword(request); return createToken(username, password, request, response); } + @Override protected boolean isRememberMe(ServletRequest request) { return WebUtils.isTrue(request, getRememberMeParam()); } + @Override protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest request, ServletResponse response) throws Exception { issueSuccessRedirect(request, response); @@ -210,6 +213,7 @@ protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, return false; } + @Override protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) { if (LOGGER.isDebugEnabled()) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/authc/HttpAuthenticationFilter.java b/web/src/main/java/org/apache/shiro/web/filter/authc/HttpAuthenticationFilter.java index a3dc53dc24..503a82dfa9 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/authc/HttpAuthenticationFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/authc/HttpAuthenticationFilter.java @@ -356,6 +356,7 @@ protected boolean sendChallenge(ServletRequest request, ServletResponse response * @param response outgoing ServletResponse * @return the AuthenticationToken used to execute the login attempt */ + @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String authorizationHeader = getAuthzHeader(request); if (authorizationHeader == null || authorizationHeader.length() == 0) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/authz/IpFilter.java b/web/src/main/java/org/apache/shiro/web/filter/authz/IpFilter.java index 6c80d117bb..afad6e9fa2 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/authz/IpFilter.java +++ b/web/src/main/java/org/apache/shiro/web/filter/authz/IpFilter.java @@ -50,10 +50,12 @@ public class IpFilter extends AuthorizationFilter { private static final IpSource DEFAULT_IP_SOURCE = new IpSource() { + @Override public Collection getAuthorizedIps() { return Collections.emptySet(); } + @Override public Collection getDeniedIps() { return Collections.emptySet(); } diff --git a/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java b/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java index 9c32d3a9b3..7e176905b3 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java +++ b/web/src/main/java/org/apache/shiro/web/filter/mgt/DefaultFilterChainManager.java @@ -101,6 +101,7 @@ public void setFilterConfig(FilterConfig filterConfig) { this.filterConfig = filterConfig; } + @Override public Map getFilters() { return filters; } @@ -128,14 +129,17 @@ public void setCaseInsensitive(boolean caseInsensitive) { this.caseInsensitive = caseInsensitive; } + @Override public void addFilter(String name, Filter filter) { addFilter(name, filter, false); } + @Override public void addFilter(String name, Filter filter, boolean init) { addFilter(name, filter, init, true); } + @Override public void createDefaultChain(String chainName, String chainDefinition) { // only create the defaultChain if we don't have a chain with this name already // (the global filters will already be in that chain) @@ -144,6 +148,7 @@ public void createDefaultChain(String chainName, String chainDefinition) { } } + @Override public void createChain(String chainName, String chainDefinition) { if (!StringUtils.hasText(chainName)) { throw new NullPointerException("chainName cannot be null or empty."); @@ -290,10 +295,12 @@ protected void addFilter(String name, Filter filter, boolean init, boolean overw } } + @Override public void addToChain(String chainName, String filterName) { addToChain(chainName, filterName, null); } + @Override public void addToChain(String chainName, String filterName, String chainSpecificFilterConfig) { if (!StringUtils.hasText(chainName)) { throw new IllegalArgumentException("chainName cannot be null or empty."); @@ -315,6 +322,7 @@ public List getGlobalFilterNames() { return List.copyOf(globalFilterNames); } + @Override public void setGlobalFilters(List globalFilterNames) throws ConfigurationException { // validate each filter name if (!CollectionUtils.isEmpty(globalFilterNames)) { @@ -360,18 +368,22 @@ protected NamedFilterList ensureChain(String chainName) { return chain; } + @Override public NamedFilterList getChain(String chainName) { return this.filterChains.get(chainName); } + @Override public boolean hasChains() { return !CollectionUtils.isEmpty(this.filterChains); } + @Override public Set getChainNames() { return this.filterChains != null ? this.filterChains.keySet() : Set.of(); } + @Override public FilterChain proxy(FilterChain original, String chainName) { NamedFilterList configured = getChain(chainName); if (configured == null) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java b/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java index dda7f45753..f2d24d4d56 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java +++ b/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java @@ -112,6 +112,7 @@ public void setFilterChainManager(FilterChainManager filterChainManager) { this.filterChainManager = filterChainManager; } + @Override public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) { FilterChainManager filterChainManager = getFilterChainManager(); if (!filterChainManager.hasChains()) { diff --git a/web/src/main/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterList.java b/web/src/main/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterList.java index bcfb2e0636..137545ef2f 100644 --- a/web/src/main/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterList.java +++ b/web/src/main/java/org/apache/shiro/web/filter/mgt/SimpleNamedFilterList.java @@ -75,18 +75,22 @@ protected void setName(String name) { this.name = name; } + @Override public String getName() { return name; } + @Override public FilterChain proxy(FilterChain orig) { return new ProxiedFilterChain(orig, this); } + @Override public boolean add(Filter filter) { return this.backingList.add(filter); } + @Override public void add(int index, Filter filter) { this.backingList.add(index, filter); } @@ -99,78 +103,97 @@ public boolean addAll(int index, Collection c) { return this.backingList.addAll(index, c); } + @Override public void clear() { this.backingList.clear(); } + @Override public boolean contains(Object o) { return this.backingList.contains(o); } + @Override public boolean containsAll(Collection c) { return this.backingList.containsAll(c); } + @Override public Filter get(int index) { return this.backingList.get(index); } + @Override public int indexOf(Object o) { return this.backingList.indexOf(o); } + @Override public boolean isEmpty() { return this.backingList.isEmpty(); } + @Override public Iterator iterator() { return this.backingList.iterator(); } + @Override public int lastIndexOf(Object o) { return this.backingList.lastIndexOf(o); } + @Override public ListIterator listIterator() { return this.backingList.listIterator(); } + @Override public ListIterator listIterator(int index) { return this.backingList.listIterator(index); } + @Override public Filter remove(int index) { return this.backingList.remove(index); } + @Override public boolean remove(Object o) { return this.backingList.remove(o); } + @Override public boolean removeAll(Collection c) { return this.backingList.removeAll(c); } + @Override public boolean retainAll(Collection c) { return this.backingList.retainAll(c); } + @Override public Filter set(int index, Filter filter) { return this.backingList.set(index, filter); } + @Override public int size() { return this.backingList.size(); } + @Override public List subList(int fromIndex, int toIndex) { return this.backingList.subList(fromIndex, toIndex); } + @Override public Object[] toArray() { return this.backingList.toArray(); } + @Override public T[] toArray(T[] a) { //noinspection SuspiciousToArrayCall return this.backingList.toArray(a); diff --git a/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSecurityManager.java b/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSecurityManager.java index b9ae514867..f9b12d7cd2 100644 --- a/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSecurityManager.java +++ b/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSecurityManager.java @@ -206,6 +206,7 @@ private void setInternalSessionManager(SessionManager sessionManager) { /** * @since 1.0 */ + @Override public boolean isHttpSessionMode() { SessionManager sessionManager = getSessionManager(); return sessionManager instanceof WebSessionManager wsm && wsm.isServletContainerSessions(); diff --git a/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java b/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java index a355c0030f..17a4d23e56 100644 --- a/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java +++ b/web/src/main/java/org/apache/shiro/web/mgt/DefaultWebSubjectFactory.java @@ -47,6 +47,7 @@ public DefaultWebSubjectFactory() { super(); } + @Override public Subject createSubject(SubjectContext context) { //SHIRO-646 //Check if the existing subject is NOT a WebSubject. If it isn't, then call super.createSubject instead. diff --git a/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java index a197e3682a..887e06b4fb 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java @@ -91,6 +91,7 @@ protected String getInitParam(String paramName) { * @param filterConfig the servlet container supplied FilterConfig instance. * @throws jakarta.servlet.ServletException if {@link #onFilterConfigSet() onFilterConfigSet()} throws an Exception. */ + @Override public final void init(FilterConfig filterConfig) throws ServletException { setFilterConfig(filterConfig); try { @@ -124,6 +125,7 @@ protected void onFilterConfigSet() throws Exception { /** * Default no-op implementation that can be overridden by subclasses for custom cleanup behavior. */ + @Override public void destroy() { } diff --git a/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java index 975f81a697..89f294b8d9 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java @@ -160,6 +160,7 @@ public void setStaticSecurityManagerEnabled(boolean staticSecurityManagerEnabled this.staticSecurityManagerEnabled = staticSecurityManagerEnabled; } + @Override protected final void onFilterConfigSet() throws Exception { //added in 1.2 for SHIRO-287: applyStaticSecurityManagerEnabledConfig(); @@ -361,6 +362,7 @@ protected void updateSessionLastAccessTime(ServletRequest request, ServletRespon * @throws IOException if an IO error occurs * @throws jakarta.servlet.ServletException if a Throwable other than an IOException */ + @Override protected void doFilterInternal(ServletRequest servletRequest, ServletResponse servletResponse, final FilterChain chain) throws ServletException, IOException { diff --git a/web/src/main/java/org/apache/shiro/web/servlet/AdviceFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/AdviceFilter.java index 3622120680..14662988bc 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/AdviceFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/AdviceFilter.java @@ -122,6 +122,7 @@ protected void executeChain(ServletRequest request, ServletResponse response, Fi * @throws ServletException if a servlet-related error occurs * @throws IOException if an IO error occurs */ + @Override public void doFilterInternal(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { diff --git a/web/src/main/java/org/apache/shiro/web/servlet/IniShiroFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/IniShiroFilter.java index 0a604fb53b..d82380e933 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/IniShiroFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/IniShiroFilter.java @@ -195,6 +195,7 @@ public void setConfigPath(String configPath) { this.configPath = StringUtils.clean(configPath); } + @Override public void init() throws Exception { applyInitParams(); configure(); diff --git a/web/src/main/java/org/apache/shiro/web/servlet/NameableFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/NameableFilter.java index e683f68660..49cee80097 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/NameableFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/NameableFilter.java @@ -71,6 +71,7 @@ protected String getName() { * * @param name the name of the filter. */ + @Override public void setName(String name) { this.name = name; } @@ -82,6 +83,7 @@ public void setName(String name) { * @return a StringBuilder instance to use for appending String data that will eventually be returned from a * {@code toString()} invocation. */ + @Override protected StringBuilder toStringBuilder() { String name = getName(); if (name == null) { diff --git a/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java b/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java index 59291f31ee..94bc8f3065 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java @@ -135,6 +135,7 @@ public void setFilterOncePerRequest(boolean filterOncePerRequest) { * @see #shouldNotFilter * @see #doFilterInternal */ + @Override public final void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { String alreadyFilteredAttributeName = getAlreadyFilteredAttributeName(); diff --git a/web/src/main/java/org/apache/shiro/web/servlet/ProxiedFilterChain.java b/web/src/main/java/org/apache/shiro/web/servlet/ProxiedFilterChain.java index 237c731d01..bc58941431 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/ProxiedFilterChain.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/ProxiedFilterChain.java @@ -56,6 +56,7 @@ public ProxiedFilterChain(FilterChain orig, List filters) { this.index = 0; } + @Override public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { if (this.filters == null || this.filters.size() == this.index) { //we've reached the end of the wrapped chain, so invoke the original one: diff --git a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java index 521f78fa8e..e76b2eee4e 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletRequest.java @@ -73,6 +73,7 @@ public boolean isHttpSessions() { return httpSessions; } + @Override public String getRemoteUser() { String remoteUser; Object scPrincipal = getSubjectPrincipal(); @@ -103,6 +104,7 @@ protected Object getSubjectPrincipal() { return userPrincipal; } + @Override public boolean isUserInRole(String s) { Subject subject = getSubject(); boolean inRole = (subject != null && subject.hasRole(s)); @@ -112,6 +114,7 @@ public boolean isUserInRole(String s) { return inRole; } + @Override public Principal getUserPrincipal() { Principal userPrincipal; Object scPrincipal = getSubjectPrincipal(); @@ -127,6 +130,7 @@ public Principal getUserPrincipal() { return userPrincipal; } + @Override public String getRequestedSessionId() { String requestedSessionId = null; if (isHttpSessions()) { @@ -141,6 +145,7 @@ public String getRequestedSessionId() { return requestedSessionId; } + @Override public HttpSession getSession(boolean create) { HttpSession httpSession; @@ -191,10 +196,12 @@ private DisabledSessionException newNoSessionCreationException() { return new DisabledSessionException(msg); } + @Override public HttpSession getSession() { return getSession(true); } + @Override public boolean isRequestedSessionIdValid() { if (isHttpSessions()) { return super.isRequestedSessionIdValid(); @@ -204,6 +211,7 @@ public boolean isRequestedSessionIdValid() { } } + @Override public boolean isRequestedSessionIdFromCookie() { if (isHttpSessions()) { return super.isRequestedSessionIdFromCookie(); @@ -213,6 +221,7 @@ public boolean isRequestedSessionIdFromCookie() { } } + @Override public boolean isRequestedSessionIdFromURL() { if (isHttpSessions()) { return super.isRequestedSessionIdFromURL(); @@ -238,14 +247,17 @@ public Object getObject() { return object; } + @Override public String getName() { return getObject().toString(); } + @Override public int hashCode() { return object.hashCode(); } + @Override public boolean equals(Object o) { if (o instanceof ObjectPrincipal op) { return getObject().equals(op.getObject()); @@ -253,6 +265,7 @@ public boolean equals(Object o) { return false; } + @Override public String toString() { return object.toString(); } diff --git a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletResponse.java b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletResponse.java index c2c93ae3cb..55abb4a668 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletResponse.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletResponse.java @@ -87,6 +87,7 @@ public void setRequest(ShiroHttpServletRequest request) { * * @param url URL to be encoded */ + @Override public String encodeRedirectURL(String url) { if (isEncodeable(toAbsolute(url))) { return toEncoded(url, request.getSession().getId()); @@ -107,6 +108,7 @@ public String encodeRedirectUrl(String s) { * * @param url URL to be encoded */ + @Override public String encodeURL(String url) { String absolute = toAbsolute(url); if (isEncodeable(absolute)) { diff --git a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpSession.java b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpSession.java index 8e068357cc..d33742da1f 100644 --- a/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpSession.java +++ b/web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpSession.java @@ -69,6 +69,7 @@ public Session getSession() { return this.session; } + @Override public long getCreationTime() { try { return getSession().getStartTimestamp().getTime(); @@ -77,18 +78,22 @@ public long getCreationTime() { } } + @Override public String getId() { return getSession().getId().toString(); } + @Override public long getLastAccessedTime() { return getSession().getLastAccessTime().getTime(); } + @Override public ServletContext getServletContext() { return this.servletContext; } + @Override public void setMaxInactiveInterval(int i) { try { getSession().setTimeout(i * 1000L); @@ -97,6 +102,7 @@ public void setMaxInactiveInterval(int i) { } } + @Override public int getMaxInactiveInterval() { try { return (Long.valueOf(getSession().getTimeout() / 1000)).intValue(); @@ -105,6 +111,7 @@ public int getMaxInactiveInterval() { } } + @Override public Object getAttribute(String s) { try { return getSession().getAttribute(s); @@ -137,10 +144,12 @@ public Enumeration getAttributeNames() { Set keyNames = getKeyNames(); final Iterator iterator = keyNames.iterator(); return new Enumeration<>() { + @Override public boolean hasMoreElements() { return iterator.hasNext(); } + @Override public String nextElement() { return iterator.next(); } @@ -173,6 +182,7 @@ protected void afterUnbound(String s, Object o) { } } + @Override public void setAttribute(String s, Object o) { try { getSession().setAttribute(s, o); @@ -193,6 +203,7 @@ public void putValue(String s, Object o) { setAttribute(s, o); } + @Override public void removeAttribute(String s) { try { Object attribute = getSession().removeAttribute(s); @@ -207,6 +218,7 @@ public void removeValue(String s) { removeAttribute(s); } + @Override public void invalidate() { try { getSession().stop(); @@ -215,6 +227,7 @@ public void invalidate() { } } + @Override public boolean isNew() { Boolean value = (Boolean) currentRequest.getAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_IS_NEW); return value != null && value.equals(Boolean.TRUE); diff --git a/web/src/main/java/org/apache/shiro/web/session/HttpServletSession.java b/web/src/main/java/org/apache/shiro/web/session/HttpServletSession.java index de8a6cafd6..5ef1484f4c 100644 --- a/web/src/main/java/org/apache/shiro/web/session/HttpServletSession.java +++ b/web/src/main/java/org/apache/shiro/web/session/HttpServletSession.java @@ -61,18 +61,22 @@ public HttpServletSession(HttpSession httpSession, String host) { } } + @Override public Serializable getId() { return httpSession.getId(); } + @Override public Date getStartTimestamp() { return new Date(httpSession.getCreationTime()); } + @Override public Date getLastAccessTime() { return new Date(httpSession.getLastAccessedTime()); } + @Override @SuppressWarnings("checkstyle:MagicNumber") public long getTimeout() throws InvalidSessionException { try { @@ -82,6 +86,7 @@ public long getTimeout() throws InvalidSessionException { } } + @Override @SuppressWarnings("checkstyle:MagicNumber") public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { try { @@ -96,10 +101,12 @@ protected void setHost(String host) { setAttribute(HOST_SESSION_KEY, host); } + @Override public String getHost() { return (String) getAttribute(HOST_SESSION_KEY); } + @Override public void touch() throws InvalidSessionException { //just manipulate the session to update the access time: try { @@ -110,6 +117,7 @@ public void touch() throws InvalidSessionException { } } + @Override public void stop() throws InvalidSessionException { try { httpSession.invalidate(); @@ -118,6 +126,7 @@ public void stop() throws InvalidSessionException { } } + @Override public Collection getAttributeKeys() throws InvalidSessionException { try { Enumeration namesEnum = httpSession.getAttributeNames(); @@ -143,6 +152,7 @@ private static String assertString(Object key) { return (String) key; } + @Override public Object getAttribute(Object key) throws InvalidSessionException { try { return httpSession.getAttribute(assertString(key)); @@ -151,6 +161,7 @@ public Object getAttribute(Object key) throws InvalidSessionException { } } + @Override public void setAttribute(Object key, Object value) throws InvalidSessionException { try { httpSession.setAttribute(assertString(key), value); @@ -159,6 +170,7 @@ public void setAttribute(Object key, Object value) throws InvalidSessionExceptio } } + @Override public Object removeAttribute(Object key) throws InvalidSessionException { try { String sKey = assertString(key); diff --git a/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionContext.java b/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionContext.java index 3051d9d19b..6e9161deef 100644 --- a/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionContext.java +++ b/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionContext.java @@ -45,22 +45,26 @@ public DefaultWebSessionContext(Map map) { super(map); } + @Override public void setServletRequest(ServletRequest request) { if (request != null) { put(SERVLET_REQUEST, request); } } + @Override public ServletRequest getServletRequest() { return getTypedValue(SERVLET_REQUEST, ServletRequest.class); } + @Override public void setServletResponse(ServletResponse response) { if (response != null) { put(SERVLET_RESPONSE, response); } } + @Override public ServletResponse getServletResponse() { return getTypedValue(SERVLET_RESPONSE, ServletResponse.class); } diff --git a/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionManager.java b/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionManager.java index 759e41ab5c..ab4eac3567 100644 --- a/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionManager.java +++ b/web/src/main/java/org/apache/shiro/web/session/mgt/DefaultWebSessionManager.java @@ -335,6 +335,7 @@ protected void onStop(Session session, SessionKey key) { * @return {@code false} always * @since 1.2 */ + @Override public boolean isServletContainerSessions() { return false; } diff --git a/web/src/main/java/org/apache/shiro/web/session/mgt/ServletContainerSessionManager.java b/web/src/main/java/org/apache/shiro/web/session/mgt/ServletContainerSessionManager.java index 1977e3477d..76fc41e7ef 100644 --- a/web/src/main/java/org/apache/shiro/web/session/mgt/ServletContainerSessionManager.java +++ b/web/src/main/java/org/apache/shiro/web/session/mgt/ServletContainerSessionManager.java @@ -60,10 +60,12 @@ public class ServletContainerSessionManager implements WebSessionManager { public ServletContainerSessionManager() { } + @Override public Session start(SessionContext context) throws AuthorizationException { return createSession(context); } + @Override public Session getSession(SessionKey key) throws SessionException { if (!WebUtils.isHttp(key)) { String msg = "SessionKey must be an HTTP compatible implementation."; @@ -126,6 +128,7 @@ protected Session createSession(HttpSession httpSession, String host) { * @return {@code true} always * @since 1.2 */ + @Override public boolean isServletContainerSessions() { return true; } diff --git a/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionContext.java b/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionContext.java index 55771256ec..0a574a7cdb 100644 --- a/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionContext.java +++ b/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionContext.java @@ -40,6 +40,7 @@ public interface WebSessionContext extends SessionContext, RequestPairSource { * @return the {@code ServletRequest} received by the servlet container triggering the creation of the * {@code Session} instance. */ + @Override ServletRequest getServletRequest(); /** @@ -57,6 +58,7 @@ public interface WebSessionContext extends SessionContext, RequestPairSource { * @return the paired {@code ServletResponse} corresponding to the associated * {@link #getServletRequest servletRequest}. */ + @Override ServletResponse getServletResponse(); /** diff --git a/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionKey.java b/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionKey.java index 02cded524e..573f54bfaa 100644 --- a/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionKey.java +++ b/web/src/main/java/org/apache/shiro/web/session/mgt/WebSessionKey.java @@ -50,10 +50,12 @@ public WebSessionKey(Serializable sessionId, ServletRequest request, ServletResp setSessionId(sessionId); } + @Override public ServletRequest getServletRequest() { return servletRequest; } + @Override public ServletResponse getServletResponse() { return servletResponse; } diff --git a/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java b/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java index 72c53c515d..d0599a27ee 100644 --- a/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java +++ b/web/src/main/java/org/apache/shiro/web/subject/WebSubject.java @@ -41,6 +41,7 @@ public interface WebSubject extends Subject, RequestPairSource { * * @return the {@code ServletRequest} accessible when the Subject instance was created. */ + @Override ServletRequest getServletRequest(); /** @@ -48,6 +49,7 @@ public interface WebSubject extends Subject, RequestPairSource { * * @return the {@code ServletResponse} accessible when the Subject instance was created. */ + @Override ServletResponse getServletResponse(); /** diff --git a/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java b/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java index c5757578bf..337076446d 100644 --- a/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java +++ b/web/src/main/java/org/apache/shiro/web/subject/WebSubjectContext.java @@ -39,6 +39,7 @@ public interface WebSubjectContext extends SubjectContext, RequestPairSource { * @return the {@code ServletRequest} received by the servlet container triggering the creation of the * {@code Subject} instance. */ + @Override ServletRequest getServletRequest(); /** @@ -58,6 +59,7 @@ public interface WebSubjectContext extends SubjectContext, RequestPairSource { * @return the paired {@code ServletResponse} corresponding to the associated * {@link #getServletRequest servletRequest}. */ + @Override ServletResponse getServletResponse(); /** diff --git a/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java b/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java index ee6beb6753..c35b605e0c 100644 --- a/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java +++ b/web/src/main/java/org/apache/shiro/web/subject/support/DefaultWebSubjectContext.java @@ -58,16 +58,19 @@ public String resolveHost() { return host; } + @Override public ServletRequest getServletRequest() { return getTypedValue(SERVLET_REQUEST, ServletRequest.class); } + @Override public void setServletRequest(ServletRequest request) { if (request != null) { put(SERVLET_REQUEST, request); } } + @Override public ServletRequest resolveServletRequest() { ServletRequest request = getServletRequest(); @@ -83,16 +86,19 @@ public ServletRequest resolveServletRequest() { return request; } + @Override public ServletResponse getServletResponse() { return getTypedValue(SERVLET_RESPONSE, ServletResponse.class); } + @Override public void setServletResponse(ServletResponse response) { if (response != null) { put(SERVLET_RESPONSE, response); } } + @Override public ServletResponse resolveServletResponse() { ServletResponse response = getServletResponse(); diff --git a/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java b/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java index 3eed26b7c8..cff9b3f77f 100644 --- a/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java +++ b/web/src/main/java/org/apache/shiro/web/subject/support/WebDelegatingSubject.java @@ -62,10 +62,12 @@ public WebDelegatingSubject(PrincipalCollection principals, boolean authenticate this.servletResponse = response; } + @Override public ServletRequest getServletRequest() { return servletRequest; } + @Override public ServletResponse getServletResponse() { return servletResponse; } diff --git a/web/src/main/java/org/apache/shiro/web/tags/AuthenticatedTag.java b/web/src/main/java/org/apache/shiro/web/tags/AuthenticatedTag.java index 524d51414e..a1be9a159b 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/AuthenticatedTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/AuthenticatedTag.java @@ -42,6 +42,7 @@ public class AuthenticatedTag extends SecureTag { private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticatedTag.class); + @Override public int onDoStartTag() throws JspException { if (getSubject() != null && getSubject().isAuthenticated()) { if (LOGGER.isTraceEnabled()) { diff --git a/web/src/main/java/org/apache/shiro/web/tags/GuestTag.java b/web/src/main/java/org/apache/shiro/web/tags/GuestTag.java index 662e9b4bd8..847ed5fd66 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/GuestTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/GuestTag.java @@ -38,6 +38,7 @@ public class GuestTag extends SecureTag { private static final Logger LOGGER = LoggerFactory.getLogger(GuestTag.class); + @Override public int onDoStartTag() throws JspException { if (getSubject() == null || getSubject().getPrincipal() == null) { if (LOGGER.isTraceEnabled()) { diff --git a/web/src/main/java/org/apache/shiro/web/tags/HasAnyRolesTag.java b/web/src/main/java/org/apache/shiro/web/tags/HasAnyRolesTag.java index d85acadf9b..39ae543c5c 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/HasAnyRolesTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/HasAnyRolesTag.java @@ -36,6 +36,7 @@ public class HasAnyRolesTag extends RoleTag { public HasAnyRolesTag() { } + @Override protected boolean showTagBody(String roleNames) { boolean hasAnyRole = false; diff --git a/web/src/main/java/org/apache/shiro/web/tags/HasPermissionTag.java b/web/src/main/java/org/apache/shiro/web/tags/HasPermissionTag.java index 1d3d8ab875..920ce1b486 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/HasPermissionTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/HasPermissionTag.java @@ -28,6 +28,7 @@ public class HasPermissionTag extends PermissionTag { public HasPermissionTag() { } + @Override protected boolean showTagBody(String p) { return isPermitted(p); } diff --git a/web/src/main/java/org/apache/shiro/web/tags/HasRoleTag.java b/web/src/main/java/org/apache/shiro/web/tags/HasRoleTag.java index 15f345f3d9..05806eadac 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/HasRoleTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/HasRoleTag.java @@ -28,6 +28,7 @@ public class HasRoleTag extends RoleTag { public HasRoleTag() { } + @Override protected boolean showTagBody(String roleName) { return getSubject() != null && getSubject().hasRole(roleName); } diff --git a/web/src/main/java/org/apache/shiro/web/tags/LacksPermissionTag.java b/web/src/main/java/org/apache/shiro/web/tags/LacksPermissionTag.java index a3007a0f55..d438b3da11 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/LacksPermissionTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/LacksPermissionTag.java @@ -28,6 +28,7 @@ public class LacksPermissionTag extends PermissionTag { public LacksPermissionTag() { } + @Override protected boolean showTagBody(String p) { return !isPermitted(p); } diff --git a/web/src/main/java/org/apache/shiro/web/tags/LacksRoleTag.java b/web/src/main/java/org/apache/shiro/web/tags/LacksRoleTag.java index ec31251f67..d0fd64c48c 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/LacksRoleTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/LacksRoleTag.java @@ -28,6 +28,7 @@ public class LacksRoleTag extends RoleTag { public LacksRoleTag() { } + @Override protected boolean showTagBody(String roleName) { boolean hasRole = getSubject() != null && getSubject().hasRole(roleName); return !hasRole; diff --git a/web/src/main/java/org/apache/shiro/web/tags/NotAuthenticatedTag.java b/web/src/main/java/org/apache/shiro/web/tags/NotAuthenticatedTag.java index f94a4f9460..401ea02286 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/NotAuthenticatedTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/NotAuthenticatedTag.java @@ -37,6 +37,7 @@ public class NotAuthenticatedTag extends SecureTag { private static final Logger LOGGER = LoggerFactory.getLogger(NotAuthenticatedTag.class); + @Override public int onDoStartTag() throws JspException { if (getSubject() == null || !getSubject().isAuthenticated()) { if (LOGGER.isTraceEnabled()) { diff --git a/web/src/main/java/org/apache/shiro/web/tags/PermissionTag.java b/web/src/main/java/org/apache/shiro/web/tags/PermissionTag.java index 0db1bd8748..80418b81a5 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/PermissionTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/PermissionTag.java @@ -39,6 +39,7 @@ public void setName(String name) { this.name = name; } + @Override protected void verifyAttributes() throws JspException { String permission = getName(); @@ -48,6 +49,7 @@ protected void verifyAttributes() throws JspException { } } + @Override public int onDoStartTag() throws JspException { String p = getName(); diff --git a/web/src/main/java/org/apache/shiro/web/tags/PrincipalTag.java b/web/src/main/java/org/apache/shiro/web/tags/PrincipalTag.java index 864fedbe0c..9afe1eae27 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/PrincipalTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/PrincipalTag.java @@ -113,6 +113,7 @@ public void setDefaultValue(String defaultValue) { ============================================*/ + @Override @SuppressWarnings({"unchecked"}) public int onDoStartTag() throws JspException { String strValue = null; diff --git a/web/src/main/java/org/apache/shiro/web/tags/RoleTag.java b/web/src/main/java/org/apache/shiro/web/tags/RoleTag.java index 7bbab26e0e..ba31605d31 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/RoleTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/RoleTag.java @@ -39,6 +39,7 @@ public void setName(String name) { this.name = name; } + @Override public int onDoStartTag() throws JspException { boolean show = showTagBody(getName()); if (show) { diff --git a/web/src/main/java/org/apache/shiro/web/tags/SecureTag.java b/web/src/main/java/org/apache/shiro/web/tags/SecureTag.java index 19ebdb1ed6..396e4dd896 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/SecureTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/SecureTag.java @@ -44,6 +44,7 @@ protected Subject getSubject() { protected void verifyAttributes() throws JspException { } + @Override public int doStartTag() throws JspException { verifyAttributes(); diff --git a/web/src/main/java/org/apache/shiro/web/tags/UserTag.java b/web/src/main/java/org/apache/shiro/web/tags/UserTag.java index 4e4a641514..7cc82f6f75 100644 --- a/web/src/main/java/org/apache/shiro/web/tags/UserTag.java +++ b/web/src/main/java/org/apache/shiro/web/tags/UserTag.java @@ -42,6 +42,7 @@ public class UserTag extends SecureTag { private static final Logger LOGGER = LoggerFactory.getLogger(UserTag.class); + @Override public int onDoStartTag() throws JspException { if (getSubject() != null && getSubject().getPrincipal() != null) { if (LOGGER.isTraceEnabled()) { diff --git a/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java b/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java index b0d5ca76c6..79f51fac90 100644 --- a/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java +++ b/web/src/test/java/org/apache/shiro/web/filter/authz/IpFilterTest.java @@ -84,10 +84,12 @@ void deniedTakesPrecedenceOverAllowed() throws Exception { @Test void willBlockAndAllowBasedOnIpSource() throws Exception { IpSource source = new IpSource() { + @Override public Collection getAuthorizedIps() { return Collections.singleton("192.168.0.0/16"); } + @Override public Collection getDeniedIps() { return Collections.singleton("192.168.33.0/24"); } diff --git a/web/src/test/java/org/apache/shiro/web/mgt/NonIniWebSecurityManagerTest.java b/web/src/test/java/org/apache/shiro/web/mgt/NonIniWebSecurityManagerTest.java index 3d7ecb56bb..4e38b4e796 100644 --- a/web/src/test/java/org/apache/shiro/web/mgt/NonIniWebSecurityManagerTest.java +++ b/web/src/test/java/org/apache/shiro/web/mgt/NonIniWebSecurityManagerTest.java @@ -40,6 +40,7 @@ public void setup() { } @AfterEach + @Override public void tearDown() { sm.destroy(); super.tearDown();