You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by "bmarwell (via GitHub)" <gi...@apache.org> on 2024/06/12 09:06:18 UTC

Re: [PR] [#1381] enh: Build on JDK 22 [shiro]

bmarwell commented on code in PR #1530:
URL: https://github.com/apache/shiro/pull/1530#discussion_r1636096449


##########
tools/hasher/src/main/java/org/apache/shiro/tools/hasher/Hasher.java:
##########
@@ -504,6 +507,15 @@ private static char[] readPassword(boolean confirm) throws IOException {
         return first;
     }
 
+    private static boolean isTerminal(java.io.Console console) throws IOException {
+        try {
+            // isTerminal is only available in Java 22 or later
+            return console != null && (Boolean) PropertyUtils.getProperty(console, "terminal");

Review Comment:
   Can we use standard reflection here? I dont want to introduce a dependency just for one line.
   
   Also, newer JDKs will bring better Reflection tools iirc.



##########
tools/hasher/pom.xml:
##########
@@ -38,14 +38,6 @@
         <dependency>
             <groupId>org.apache.shiro</groupId>
             <artifactId>shiro-core</artifactId>
-            <exclusions>
-                <!-- BeanUtils is for ini config - this simple command line program
-                     does not init a shiro environment, so we don't need it: -->
-                <exclusion>
-                    <groupId>commons-beanutils</groupId>
-                    <artifactId>commons-beanutils</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>

Review Comment:
   Do you really want to introduce one extra dependency for just one invocation?



##########
tools/hasher/pom.xml:
##########
@@ -71,6 +63,11 @@
             <artifactId>log4j-slf4j2-impl</artifactId>
             <scope>runtime</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>runtime</scope>
+        </dependency>

Review Comment:
   Can be removed if  we get rid of bean utils



##########
tools/hasher/src/main/java/org/apache/shiro/tools/hasher/Hasher.java:
##########
@@ -495,6 +495,9 @@ private static char[] readPassword(boolean confirm) throws IOException {
             throw new IllegalArgumentException("No password specified.");
         }
         if (confirm) {
+            if (!isTerminal(console)) {
+                throw new IllegalStateException("Cannot confirm password when console is not available.");
+            }

Review Comment:
   Maybe on non-Terminals, just  use one input instead of to (i.e.  do not throw an exception and just go for it).
   Otherwise this might break script invocations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@shiro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org