[java-idp-plugin-webauthn] branch main updated: Fix checkstyle

Phil Smart philip.smart at jisc.ac.uk
Fri Mar 7 14:37:50 UTC 2025


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

philsmart pushed a commit to branch main
in repository java-idp-plugin-webauthn.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-webauthn.git;a=commit;h=6b5f44c7a9862177a17c9d54dd3a4e93ce945dc8

The following commit(s) were added to refs/heads/main by this push:
     new 6b5f44c  Fix checkstyle
6b5f44c is described below

commit 6b5f44c7a9862177a17c9d54dd3a4e93ce945dc8
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Fri Mar 7 14:37:47 2025 +0000

    Fix checkstyle
---
 .../plugin/authn/webauthn/context/WebAuthnGuardContext.java  |  8 +++++---
 .../authn/webauthn/context/WebAuthnRegistrationContext.java  |  2 ++
 .../idp/plugin/authn/webauthn/storage/CredentialRecord.java  |  2 +-
 .../admin/impl/RequireStrongFreshAuthnAccessPredicate.java   |  1 -
 .../impl/CheckUserHandleExistsIfNoAllowCredentials.java      |  3 ++-
 .../authn/webauthn/impl/FilterCredentialsOnPolicy.java       |  4 ++--
 .../impl/LookupRegisteredCredentialsFromUserHandle.java      |  3 +++
 .../authn/webauthn/impl/ValidateWebAuthnAssertion.java       |  4 ++--
 .../idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java      |  7 ++++---
 .../storage/impl/IdPStorageServiceCredentialRespository.java | 12 ++++++++----
 10 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnGuardContext.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnGuardContext.java
index 7252df2..4dca5be 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnGuardContext.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnGuardContext.java
@@ -30,9 +30,9 @@ public class WebAuthnGuardContext extends BaseContext {
     
     /** 
      * A flag that can be set to indicate the user just (fresh) performed some kind of 'strong' authentication. This 
-     * can be used in conjunction with an access control policy to determine if the user should be granted access to the 
-     * registration page if other conditions are met e.g. if the user has FIDO2 credentials and the flag is not set, 
-     * deny access.
+     * can be used in conjunction with an access control policy to determine if the user should be granted access to 
+     * the registration page if other conditions are met e.g. if the user has FIDO2 credentials and the flag is not 
+     * set, deny access.
      * 
      * <p>This is not intended to replace AuthenticationContextClasses, but can be used in certain cases where the
      * flow might legally change behaviour from one authentication to the next e.g. allow password login for the first
@@ -46,6 +46,8 @@ public class WebAuthnGuardContext extends BaseContext {
      * Set a flag to indicate the user performed some kind of 'strong' authentication. 
      * 
      * @param flag The flag to set.
+     * 
+     * @return this context
      */
     @Nonnull public WebAuthnGuardContext setStronglyAuthenticated(final boolean flag) {
         stronglyAuthenticated = flag;
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
index 143a64f..0781695 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
@@ -99,6 +99,8 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
      * 
      * @param flag the flag to set
      * 
+     * @return this context
+     * 
      * @since 1.1.0
      */
     public BaseWebAuthnContext setNicknameRequired(final boolean flag) {
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRecord.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRecord.java
index 9d2d18e..b89d079 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRecord.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/CredentialRecord.java
@@ -208,7 +208,7 @@ public final class CredentialRecord {
     }
     
     /**
-     * Get the time the credential was last used for authentication
+     * Get the time the credential was last used for authentication.
      * 
      * @return the last used time of the credential.
      * 
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RequireStrongFreshAuthnAccessPredicate.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RequireStrongFreshAuthnAccessPredicate.java
index 1281e07..c8f42ec 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RequireStrongFreshAuthnAccessPredicate.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RequireStrongFreshAuthnAccessPredicate.java
@@ -28,7 +28,6 @@ import org.slf4j.Logger;
 import net.shibboleth.idp.authn.context.AuthenticationContext;
 import net.shibboleth.idp.authn.context.SubjectContext;
 import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnGuardContext;
-import net.shibboleth.idp.plugin.authn.webauthn.context.WebAuthnRegistrationContext;
 import net.shibboleth.idp.plugin.authn.webauthn.storage.CredentialRecord;
 import net.shibboleth.idp.plugin.authn.webauthn.storage.WebAuthnCredentialRepository;
 import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CheckUserHandleExistsIfNoAllowCredentials.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CheckUserHandleExistsIfNoAllowCredentials.java
index 4d3c0ac..b5f5cb9 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CheckUserHandleExistsIfNoAllowCredentials.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/CheckUserHandleExistsIfNoAllowCredentials.java
@@ -108,7 +108,8 @@ public class CheckUserHandleExistsIfNoAllowCredentials extends AbstractWebAuthnA
             return;
         }
         
-        if (allowCredentials.isEmpty() || allowCredentials.get() == null || allowCredentials.get().isEmpty()) {            
+        if (allowCredentials.isEmpty() || allowCredentials.get() == null || 
+                allowCredentials.get().isEmpty()) {            
             if (userHandle.isEmpty()) {
                 log.debug("{} Allow credentials is empty and the userHandle was not returned in the response, the "
                         + "userHandle is required", getLogPrefix());
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/FilterCredentialsOnPolicy.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/FilterCredentialsOnPolicy.java
index 3fb7f32..e12be13 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/FilterCredentialsOnPolicy.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/FilterCredentialsOnPolicy.java
@@ -100,8 +100,8 @@ public class FilterCredentialsOnPolicy extends AbstractWebAuthnAction<WebAuthnAu
         final Collection<EnhancedCredentialRecord> existingCredentials = context.getExistingCredentials();
 
         if (existingCredentials.isEmpty()) {
-            log.trace("{} User '{}' does not have any registered credentials, policy can not be applied",getLogPrefix(), 
-                    context.getUsername());
+            log.trace("{} User '{}' does not have any registered credentials, policy can not be applied",
+                    getLogPrefix(), context.getUsername());
             return;
         }
         
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/LookupRegisteredCredentialsFromUserHandle.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/LookupRegisteredCredentialsFromUserHandle.java
index 5eae2ad..77f8a94 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/LookupRegisteredCredentialsFromUserHandle.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/LookupRegisteredCredentialsFromUserHandle.java
@@ -160,6 +160,7 @@ public class LookupRegisteredCredentialsFromUserHandle extends AbstractWebAuthnA
         return true;
     }
 
+ // Checkstyle: CyclomaticComplexity OFF
     /** {@inheritDoc} */
     @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final WebAuthnAuthenticationContext context) {
@@ -214,5 +215,7 @@ public class LookupRegisteredCredentialsFromUserHandle extends AbstractWebAuthnA
             return;
         } 
     }
+    
+ // Checkstyle: CyclomaticComplexity ON
 
 }
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/ValidateWebAuthnAssertion.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/ValidateWebAuthnAssertion.java
index 85016a3..c2f6af0 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/ValidateWebAuthnAssertion.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/ValidateWebAuthnAssertion.java
@@ -256,8 +256,8 @@ public class ValidateWebAuthnAssertion extends AbstractAuditingValidationAction
      * 
      * @throws AssertionFailureException on error updating the counter
      */
-    private void updateLastUsedTime(@Nonnull final String username, 
-          @Nonnull final PublicKeyCredential<AuthenticatorAssertionResponse, ClientAssertionExtensionOutputs> assertion) 
+    private void updateLastUsedTime(@Nonnull final String username, @Nonnull
+           final PublicKeyCredential<AuthenticatorAssertionResponse, ClientAssertionExtensionOutputs> assertion) 
                     throws AssertionFailureException {
         
         final ByteArray credentialId = assertion.getId();
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
index 8243340..97c77a5 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/impl/WebAuthnEncoder.java
@@ -99,7 +99,7 @@ public final class WebAuthnEncoder {
      */
     @Nonnull @NotEmpty public static String formatInstant(@Nullable final Instant time) {
         return formatInstant(time, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmXXX")
-                .withZone((ZoneId.of("UTC"))));
+                .withZone(ZoneId.of("UTC")));
     }
     
     /**
@@ -117,7 +117,7 @@ public final class WebAuthnEncoder {
         if (time == null || pattern == null) { 
             return "";
         }
-        return formatInstant(time, DateTimeFormatter.ofPattern(pattern).withZone((ZoneId.of("UTC"))));           
+        return formatInstant(time, DateTimeFormatter.ofPattern(pattern).withZone(ZoneId.of("UTC")));           
     }
     
     /**
@@ -170,8 +170,9 @@ public final class WebAuthnEncoder {
         assert second != null;
         if (first.isAfter(second)) {
             return formatInstant(first);
+        } else {
+            return formatInstant(second);
         }
-        else return formatInstant(second);
     }
     
     /**
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
index f6583a2..b7fde72 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/storage/impl/IdPStorageServiceCredentialRespository.java
@@ -523,6 +523,8 @@ public class IdPStorageServiceCredentialRespository extends AbstractIdentifiable
         }      
     }
 
+    
+ // Checkstyle: CyclomaticComplexity|MethodLength OFF
     /** {@inheritDoc} */
     @Override
     public boolean updateSignatureCounter(@Nonnull final String username, @Nonnull final ByteArray credentialId, 
@@ -594,7 +596,7 @@ public class IdPStorageServiceCredentialRespository extends AbstractIdentifiable
                         existingRegistrations.getVersion(), STORAGE_CONTEXT, username, updateCredentialSet, 
                         serializer, null);                
                 return updatedVersion != null;
-            } catch (IOException | VersionMismatchException e) {
+            } catch (final IOException | VersionMismatchException e) {
                 throw new CredentialRepositoryException(e);    
             } 
             
@@ -603,6 +605,9 @@ public class IdPStorageServiceCredentialRespository extends AbstractIdentifiable
         } 
     }
     
+    
+ // Checkstyle: CyclomaticComplexity|MethodLength ON
+
     /** {@inheritDoc} */
     @Override
     public boolean updateLastUsedTime(@Nonnull final String username, @Nonnull final ByteArray credentialId, 
@@ -644,14 +649,13 @@ public class IdPStorageServiceCredentialRespository extends AbstractIdentifiable
                         existingRegistrations.getVersion(), STORAGE_CONTEXT, username, updateCredentialSet, 
                         serializer, null);                
                 return updatedVersion != null;
-            } catch (IOException | VersionMismatchException e) {
+            } catch (final IOException | VersionMismatchException e) {
                 throw new CredentialRepositoryException(e);    
             } 
             
         } finally {
             writeLock.unlock();
-        } 
-        
+        }        
     }
 
     /** {@inheritDoc} */

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


More information about the commits mailing list