Skip to content

Commit

Permalink
revert some unncessary changes, remove unncessary suppressions and cl…
Browse files Browse the repository at this point in the history
…ean up code exposed due to suppression cleanup
  • Loading branch information
lprimak committed Oct 4, 2023
1 parent f28082d commit f33dd71
Show file tree
Hide file tree
Showing 49 changed files with 174 additions and 255 deletions.
1 change: 0 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0


- name: Cache local Maven repository
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
Expand Down
2 changes: 1 addition & 1 deletion config/core/src/main/java/org/apache/shiro/config/Ini.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private Section(String name, String sectionContent) {
if (StringUtils.hasText(sectionContent)) {
props = toMapProps(sectionContent);
} else {
props = new LinkedHashMap<String, String>();
props = new LinkedHashMap<>();
}
this.props = props;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public Object convert(String value, Class clazz) {
this.interpolator = createInterpolator();

this.objects = createDefaultObjectMap();
this.registeredEventSubscribers = new LinkedHashMap<String, Object>();
this.registeredEventSubscribers = new LinkedHashMap<>();
apply(defaults);
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/shiro/jndi/JndiLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class JndiLocator {

/**
* JNDI prefix used in a J2EE container
* JNDI prefix used in a Jakarta EE container
*/
public static final String CONTAINER_PREFIX = "java:comp/env/";

Expand Down Expand Up @@ -91,7 +91,7 @@ public Properties getJndiEnvironment() {
}

/**
* Set whether the lookup occurs in a J2EE container, i.e. if the prefix
* Set whether the lookup occurs in a Jakarta EE container, i.e. if the prefix
* "java:comp/env/" needs to be added if the JNDI name doesn't already
* contain it. Default is "false".
* <p>Note: Will only get applied if no other scheme (e.g. "java:") is given.
Expand All @@ -101,7 +101,7 @@ public void setResourceRef(boolean resourceRef) {
}

/**
* Return whether the lookup occurs in a J2EE container.
* Return whether the lookup occurs in a Jakarta EE container.
*/
public boolean isResourceRef() {
return this.resourceRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Objects;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -276,8 +275,7 @@ public void setCipherKey(byte[] cipherKey) {
* @return true if remember me services should be performed as a result of the successful authentication attempt.
*/
protected boolean isRememberMe(AuthenticationToken token) {
return Objects.nonNull(token) && (token instanceof RememberMeAuthenticationToken)
&& ((RememberMeAuthenticationToken) token).isRememberMe();
return token instanceof RememberMeAuthenticationToken && ((RememberMeAuthenticationToken) token).isRememberMe();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
*/
public class DefaultSecurityManagerTest extends AbstractSecurityManagerTest {

@SuppressWarnings("checkstyle:ExplicitInitialization")
DefaultSecurityManager sm = null;
DefaultSecurityManager sm;

@BeforeEach
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public class ActiveDirectoryRealmTest {
private static final int USER_ID = 12345;
private static final String ROLE = "admin";

@SuppressWarnings("checkstyle:ExplicitInitialization")
DefaultSecurityManager securityManager = null;
DefaultSecurityManager securityManager;
AuthorizingRealm realm;

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
*/
public class JDBCRealmTest {

@SuppressWarnings("checkstyle:ExplicitInitialization")
protected DefaultSecurityManager securityManager = null;
protected DefaultSecurityManager securityManager;
protected AuthorizingRealm realm;
protected final String username = "testUser";
protected final String plainTextPassword = "testPassword";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ private class TestThread implements Runnable {
private Runnable test;
private volatile AssertionError ae;

@SuppressWarnings("checkstyle:RedundantModifier")
public TestThread(Runnable test) {
TestThread(Runnable test) {
this.test = test;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
*/
public class DefaultSessionManagerTest {

@SuppressWarnings("checkstyle:ExplicitInitialization")
DefaultSessionManager sm = null;
DefaultSessionManager sm;

@BeforeEach
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
*/
public class DelegatingSessionTest {

@SuppressWarnings("checkstyle:ExplicitInitialization")
DelegatingSession session = null;
@SuppressWarnings("checkstyle:ExplicitInitialization")
DefaultSessionManager sm = null;
DelegatingSession session;
DefaultSessionManager sm;

@BeforeEach
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,9 @@ protected Class getHashFormatClass(String token) {
* @param token the string token from which a class name will be heuristically determined.
* @return the discovered HashFormat class implementation or {@code null} if no class could be heuristically determined.
*/
@SuppressWarnings("unchecked")
protected Class getHashFormatClass(String packageName, String token) {
protected Class<?> getHashFormatClass(String packageName, String token) {
String test = token;
Class clazz = null;
Class<?> clazz;
String pkg = packageName == null ? "" : packageName;

//1. Assume the arg is a fully qualified class name in the classpath:
Expand Down Expand Up @@ -316,7 +315,7 @@ protected Class getHashFormatClass(String packageName, String token) {
return clazz;
}

protected Class lookupHashFormatClass(String name) {
protected Class<?> lookupHashFormatClass(String name) {
try {
return ClassUtils.forName(name);
} catch (UnknownClassException ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
# specific language governing permissions and limitations
# under the License.
#

# suppress inspection "UnusedProperty" for whole file
configuration.ordinal=1000

configuration.ordinal = 1000

# avoid warns on java 11 - but prevents package scoped methods in proxies
org.apache.webbeans.spi.DefiningClassService=org.apache.webbeans.service.ClassLoaderProxyService
org.apache.webbeans.spi.DefiningClassService = org.apache.webbeans.service.ClassLoaderProxyService

# flat classpath so capture the startup classloader,
# avoids surprises at runtime when classloader is not app one at startup (rare but happens in maven plugins)
org.apache.webbeans.spi.ApplicationBoundaryService=org.apache.webbeans.corespi.se.SimpleApplicationBoundaryService
org.apache.webbeans.spi.ApplicationBoundaryService = org.apache.webbeans.corespi.se.SimpleApplicationBoundaryService

# faster and more controlled - requires META-INF/beans.xml for scanning
org.apache.webbeans.scanBeansXmlOnly=true
org.apache.webbeans.scanBeansXmlOnly = true

# don't use loadClass(package-info) to check @Vetoed, this slows down boot for nothing
org.apache.webbeans.spi.deployer.skipVetoedOnPackages=true
org.apache.webbeans.spi.deployer.skipVetoedOnPackages = true

# speed up startup if no classpath issue
org.apache.webbeans.spi.deployer.skipNoClassDefFoundTriggers=true
org.apache.webbeans.spi.deployer.skipNoClassDefFoundTriggers = true
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<enableRulesSummary>true</enableRulesSummary>
<excludes>**/Quickstart.java,**/QuickstartGuice.java,**/QuickstartShiroModule.java</excludes>
<resourceExcludes>test-keystore.jks,test-keystore.pem</resourceExcludes>
<propertyExpansion>root.dir=${root.dir}</propertyExpansion>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void configureShiroWeb() {
this.addFilterChain("/login.jsp", AUTHC);
this.addFilterChain("/logout", LOGOUT);
this.addFilterChain("/account/**", AUTHC);
this.addFilterChain("/account/**",
this.addFilterChain("/remoting/**",
filterConfig(AUTHC),
filterConfig(ROLES, "b2bClient"),
filterConfig(PERMS, "remote:invoke:lan,wan"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
# specific language governing permissions and limitations
# under the License.
#
shiro.loginUrl=/login.html

shiro.loginUrl = /login.html

# Let Shiro Manage the sessions
shiro.userNativeSessionManager=true
shiro.userNativeSessionManager = true

# disable URL session rewriting
shiro.sessionManager.sessionIdUrlRewritingEnabled=false
shiro.sessionManager.sessionIdUrlRewritingEnabled = false
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
# specific language governing permissions and limitations
# under the License.
#
shiro.loginUrl=/login.html

shiro.loginUrl = /login.html

# Let Shiro Manage the sessions
shiro.userNativeSessionManager=true
shiro.userNativeSessionManager = true

# disable URL session rewriting
shiro.sessionManager.sessionIdUrlRewritingEnabled=false
shiro.sessionManager.sessionIdUrlRewritingEnabled = false
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
# specific language governing permissions and limitations
# under the License.
#

logging.level.org.springframework.web=INFO
logging.level.org.hibernate=ERROR
logging.level.org.hibernate=ERROR
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
@Component
public class SampleRealm extends AuthorizingRealm {

@SuppressWarnings("checkstyle:ExplicitInitialization")
protected UserDAO userDAO = null;
protected UserDAO userDAO;

public SampleRealm() {
//This name must match the name in the User class's getPrincipals() method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* The tables created by this class follow the default table and column names that
* {@link org.apache.shiro.realm.jdbc.JdbcRealm} uses.
*/
@SuppressWarnings("checkstyle:ExplicitInitialization")
public class BootstrapDataPopulator implements InitializingBean {

private static final String CREATE_TABLES = "create table users (\n"
Expand All @@ -58,7 +57,7 @@ public class BootstrapDataPopulator implements InitializingBean {

private static final Logger LOGGER = LoggerFactory.getLogger(BootstrapDataPopulator.class);

protected DataSource dataSource = null;
protected DataSource dataSource;

public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
Expand Down
8 changes: 1 addition & 7 deletions src/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@
-->

<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="basedir" value="${root.dir}"/>

<!-- Activation here is needed for IntelliJ CheckstyleIDEA plugin -->
<module name="SuppressionFilter">
Expand Down
5 changes: 2 additions & 3 deletions src/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<suppress checks="JavadocPackage" files="org[\\/]apache[\\/]shiro[\\/]tools[\\/]hasher[\\/]*"/>
<suppress checks="JavadocPackage" files="org[\\/]apache[\\/]shiro[\\/]config[\\/]ogdl[\\/]*"/>
<suppress checks="JavadocPackage" files="org[\\/]apache[\\/]shiro[\\/]cache[\\/]ehcache[\\/]*"/>

<suppress checks="ConstantName" lines="41-44"
files="com[\\/]flowlogix[\\/]shiro[\\/]ee[\\/]filters[\\/]CryptoSupport"/>
<suppress checks=".*" files="Quickstart.*.java"/>
<suppress checks=".*" files="application.properties"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class ShiroSecurityExtension implements Extension {
public static class ShiroSecureAnnotated {
}

;

public <T> void addSecurity(@Observes @WithAnnotations({
RequiresAuthentication.class, RequiresGuest.class, RequiresPermissions.class,
RequiresRoles.class, RequiresUser.class, RolesAllowed.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ class BeanTypeListener implements TypeListener {

static final Key<?> MAP_KEY = Key.get(Types.mapOf(TypeLiteral.class, BeanTypeKey.class), Names.named(BEAN_TYPE_MAP_NAME));

static Matcher<Class> shiroMatcher = Matchers.inSubpackage(SHIRO_PACKAGE.getName());
static Matcher<Class> shiroGuiceMatcher = Matchers.inSubpackage(SHIRO_GUICE_PACKAGE.getName());
static Matcher<Class> classMatcher = ShiroMatchers.anyPackage.and(shiroMatcher.and(Matchers.not(shiroGuiceMatcher)));
private static final Matcher<Class> SHIRO_MATCHER = Matchers.inSubpackage(SHIRO_PACKAGE.getName());
private static final Matcher<Class> SHIRO_GUICE_MATCHER = Matchers.inSubpackage(SHIRO_GUICE_PACKAGE.getName());
private static final Matcher<Class> CLASS_MATCHER = ShiroMatchers.anyPackage
.and(SHIRO_MATCHER.and(Matchers.not(SHIRO_GUICE_MATCHER)));

static final Matcher<TypeLiteral> MATCHER = ShiroMatchers.typeLiteral(classMatcher);
static final Matcher<TypeLiteral> MATCHER = ShiroMatchers.typeLiteral(CLASS_MATCHER);

private static final Set<Class<?>> WRAPPER_TYPES = new HashSet<Class<?>>(Arrays.asList(
Byte.class,
Expand Down
Loading

0 comments on commit f33dd71

Please sign in to comment.