[java-idp-plugin-totp] branch main updated: Fixes to CLI and revamp of POM/assembly process.

Scott Cantor cantor.2 at osu.edu
Wed Aug 12 17:25:16 UTC 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-idp-plugin-totp.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-totp.git;a=commit;h=510902c72cd01c34fc0f3e07183a392a8a0b4ded

The following commit(s) were added to refs/heads/main by this push:
       new  510902c   Fixes to CLI and revamp of POM/assembly process.
510902c is described below

commit 510902c72cd01c34fc0f3e07183a392a8a0b4ded
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Aug 12 13:26:46 2020 -0400

    Fixes to CLI and revamp of POM/assembly process.
---
 totp-dist/src/main/assembly/totp-assembly.xml      | 27 ++++++++++++++++++++++
 totp-dist/src/main/resources/bin/totpauth.bat      |  4 ++++
 totp-dist/src/main/resources/bin/totpauth.sh       |  7 ++++++
 .../src/main/resources/conf/totp-authn-config.xml  |  0
 .../src/main/resources/views/totp-error.vm         |  0
 .../src/main/resources/views/totp.vm               |  0
 totp-impl/pom.xml                                  | 12 ++++++++--
 .../totp/impl/TOTPAuthenticatorArguments.java      |  8 ++-----
 .../idp/plugin/totp/impl/TOTPAuthenticatorCLI.java |  2 --
 .../idp/flows/authn/TOTP/TOTP-authenticator.xml}   | 21 ++++++++---------
 .../shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml |  6 ++---
 11 files changed, 62 insertions(+), 25 deletions(-)

diff --git a/totp-dist/src/main/assembly/totp-assembly.xml b/totp-dist/src/main/assembly/totp-assembly.xml
index ac3e243..6a3e2e8 100644
--- a/totp-dist/src/main/assembly/totp-assembly.xml
+++ b/totp-dist/src/main/assembly/totp-assembly.xml
@@ -17,6 +17,26 @@
                 <exclude>*sources.jar</exclude>
             </excludes>
         </fileSet>
+        <fileSet>
+            <directory>../totp-impl/target/dependency</directory>
+            <outputDirectory>edit-webapp/WEB-INF/lib</outputDirectory>
+            <includes>
+                <include>*.jar</include>
+            </includes>
+            <excludes>
+                <exclude>*test*.jar</exclude>
+                <exclude>*javadoc.jar</exclude>
+                <exclude>*sources.jar</exclude>
+            </excludes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/bin</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>*.sh</include>
+                <include>*.bat</include>
+            </includes>
+        </fileSet>
         <fileSet>
             <directory>src/main/resources/conf</directory>
             <outputDirectory>conf</outputDirectory>
@@ -32,6 +52,13 @@
                 <include>*.vm</include>
             </includes>
         </fileSet>
+        <fileSet>
+            <directory>src/main/resources/doc</directory>
+            <outputDirectory>doc</outputDirectory>
+            <includes>
+                <include>*.txt</include>
+            </includes>
+        </fileSet>
         <fileSet>
             <directory>src/main/resources/bootstrap</directory>
             <outputDirectory>bootstrap</outputDirectory>
diff --git a/totp-dist/src/main/resources/bin/totpauth.bat b/totp-dist/src/main/resources/bin/totpauth.bat
new file mode 100644
index 0000000..0bd9095
--- /dev/null
+++ b/totp-dist/src/main/resources/bin/totpauth.bat
@@ -0,0 +1,4 @@
+ at echo off
+setlocal
+
+"%~dp0\runclass.bat" net.shibboleth.idp.plugin.totp.impl.TOTPAuthenticatorCLI classpath:/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-authenticator.xml %*
diff --git a/totp-dist/src/main/resources/bin/totpauth.sh b/totp-dist/src/main/resources/bin/totpauth.sh
new file mode 100755
index 0000000..cf1c8df
--- /dev/null
+++ b/totp-dist/src/main/resources/bin/totpauth.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+declare LOCATION
+
+LOCATION=$(dirname $0)
+
+$LOCATION/runclass.sh net.shibboleth.idp.plugin.totp.impl.TOTPAuthenticatorCLI classpath:/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-authenticator.xml "$@"
\ No newline at end of file
diff --git a/totp-impl/src/main/resources/conf/totp-authn-config.xml b/totp-dist/src/main/resources/conf/totp-authn-config.xml
similarity index 100%
copy from totp-impl/src/main/resources/conf/totp-authn-config.xml
copy to totp-dist/src/main/resources/conf/totp-authn-config.xml
diff --git a/totp-impl/src/main/resources/views/totp-error.vm b/totp-dist/src/main/resources/views/totp-error.vm
similarity index 100%
rename from totp-impl/src/main/resources/views/totp-error.vm
rename to totp-dist/src/main/resources/views/totp-error.vm
diff --git a/totp-impl/src/main/resources/views/totp.vm b/totp-dist/src/main/resources/views/totp.vm
similarity index 100%
rename from totp-impl/src/main/resources/views/totp.vm
rename to totp-dist/src/main/resources/views/totp.vm
diff --git a/totp-impl/pom.xml b/totp-impl/pom.xml
index c8d846b..8b837fa 100644
--- a/totp-impl/pom.xml
+++ b/totp-impl/pom.xml
@@ -29,6 +29,12 @@
         </dependency>
                 
         <!-- provided dependencies -->
+        <dependency>
+            <groupId>${slf4j.groupId}</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>${slf4j.version}</version>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>
@@ -165,12 +171,14 @@
                 <executions>
                     <execution>
                         <id>copy-dependencies</id>
-                        <phase>install</phase>
+                        <phase>package</phase>
                         <goals>
                             <goal>copy-dependencies</goal>
                         </goals>
                         <configuration>
-                            <outputDirectory>target</outputDirectory>
+                            <outputDirectory>${project.target.directory}</outputDirectory>
+                            <includeScope>runtime</includeScope>
+                            <excludeTransitive>true</excludeTransitive>
                         </configuration>
                     </execution>
                 </executions>
diff --git a/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorArguments.java b/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorArguments.java
index c6eadef..2e04202 100644
--- a/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorArguments.java
+++ b/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorArguments.java
@@ -29,7 +29,7 @@ import net.shibboleth.utilities.java.support.codec.Base32Support;
 import net.shibboleth.utilities.java.support.codec.DecodingException;
 
 /**
- * Arguments for DataSealer CLI.
+ * Arguments for {@link TOTPAuthenticatorCLI}.
  */
 public class TOTPAuthenticatorArguments extends AbstractCommandLineArguments {
 
@@ -76,10 +76,6 @@ public class TOTPAuthenticatorArguments extends AbstractCommandLineArguments {
     public void validate() throws IllegalArgumentException {
         super.validate();
         
-        if (getOtherArgs().size() < 1) {
-            throw new IllegalArgumentException("Missing one or more required arguments");
-        }
-        
         if (getOtherArgs().size() == 3) {
             try {
                 seed = Base32Support.decode(getOtherArgs().get(1));
@@ -87,7 +83,7 @@ public class TOTPAuthenticatorArguments extends AbstractCommandLineArguments {
                 throw new IllegalArgumentException(e);
             }
             tokenCode = Integer.valueOf(getOtherArgs().get(2));
-        } else {
+        } else if (getOtherArgs().size() != 1) {
             throw new IllegalArgumentException(
                     "Invalid operation requested, must have zero or two additional arguments");
         }
diff --git a/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorCLI.java b/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorCLI.java
index 82bbf87..7178491 100644
--- a/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorCLI.java
+++ b/totp-impl/src/main/java/net/shibboleth/idp/plugin/totp/impl/TOTPAuthenticatorCLI.java
@@ -88,8 +88,6 @@ public class TOTPAuthenticatorCLI extends AbstractCommandLine<TOTPAuthenticatorA
             // Create a new token.
             final TOTPCredential tc = authenticator.createCredential();
             System.out.println("Seed: " + Base32Support.encode(tc.getKey(), false));
-            System.out.println("Scratch Codes:");
-            tc.getScratchCodes().forEach(c -> System.out.println(c));
             
         } catch (final Exception e) {
             if (args.isVerboseOutput()) {
diff --git a/totp-impl/src/main/resources/conf/totp-authn-config.xml b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-authenticator.xml
similarity index 63%
rename from totp-impl/src/main/resources/conf/totp-authn-config.xml
rename to totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-authenticator.xml
index ab7a175..29454ea 100644
--- a/totp-impl/src/main/resources/conf/totp-authn-config.xml
+++ b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-authenticator.xml
@@ -11,16 +11,15 @@
                            
        default-init-method="initialize"
        default-destroy-method="destroy">
+       
+    <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"
+        p:placeholderPrefix="%{" p:placeholderSuffix="}" />
+
+    <bean class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
+    <bean class="net.shibboleth.idp.profile.impl.ProfileActionBeanPostProcessor" />
+
+    <import resource="conditional:%{idp.home}/conf/authn/totp-authn-config.xml" />
+
+    <bean id="DefaultAuthenticator" class="net.shibboleth.idp.plugin.totp.impl.GoogleTOTPAuthenticator" lazy-init="true" />
 
-    <!-- Override default header/field extraction. -->
-    <!--
-    <bean id="shibboleth.authn.TOTP.HeaderName" class="java.lang.String" c:_0="X-Shibboleth-TOTP" />
-    <bean id="shibboleth.authn.TOTP.FieldName" class="java.lang.String" c:_0="tokencode" />
-    -->
-    
-    <!-- Override default attribute to resolve to locate token seeds for users. -->
-    <!--
-    <bean id="shibboleth.authn.TOTP.TokenSeedAttribute" class="java.lang.String" c:_0="tokenSeeds" />
-    -->
-    
 </beans>
diff --git a/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
index 9fa48d9..961fef1 100644
--- a/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
+++ b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
@@ -18,13 +18,13 @@
     <bean class="net.shibboleth.ext.spring.config.IdentifiableBeanPostProcessor" />
     <bean class="net.shibboleth.idp.profile.impl.ProfileActionBeanPostProcessor" />
 
+    <import resource="TOTP-authenticator.xml" />
+
     <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
             p:cacheSeconds="%{idp.message.cacheSeconds:300}"
             p:basenames="classpath:/net/shibboleth/idp/plugin/totp/messages"
             p:defaultEncoding="UTF-8" />
 
-    <import resource="conditional:%{idp.home}/conf/authn/totp-authn-config.xml" />
-
     <bean id="ExtractTOTPFromHeader"
         class="net.shibboleth.idp.plugin.totp.impl.ExtractTOTPFromHeader" scope="prototype"
         p:httpServletRequest-ref="shibboleth.HttpServletRequest"
@@ -60,6 +60,4 @@
         p:attributeResolver-ref="shibboleth.AttributeResolverService"
         p:sourceAttribute="#{getObject('shibboleth.authn.TOTP.TokenSeedAttribute') ?: T(net.shibboleth.idp.plugin.totp.impl.AttributeResolverSeedSource).DEFAULT_ATTRIBUTE_ID}" />
 
-    <bean id="DefaultAuthenticator" class="net.shibboleth.idp.plugin.totp.impl.GoogleTOTPAuthenticator" lazy-init="true" />
-
 </beans>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list