[java-opensaml] branch main updated: Slap on a few annotations.

Scott Cantor cantor.2 at osu.edu
Wed Apr 19 12:43:16 UTC 2023


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

scantor pushed a commit to branch main
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=5a98815617cf336eb88f50aca831c7847e882654

The following commit(s) were added to refs/heads/main by this push:
     new 5a9881561 Slap on a few annotations.
5a9881561 is described below

commit 5a98815617cf336eb88f50aca831c7847e882654
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Apr 19 08:43:13 2023 -0400

    Slap on a few annotations.
---
 .../config/impl/XMLObjectProviderInitializer.java  |  8 +++--
 .../ctx/provider/impl/BaseObligationHandler.java   | 16 ++++++----
 .../provider/impl/ObligationProcessingContext.java |  8 +++--
 .../xacml/ctx/provider/impl/ObligationService.java | 34 ++++++++++++----------
 .../config/impl/XMLObjectProviderInitializer.java  |  6 ++--
 5 files changed, 43 insertions(+), 29 deletions(-)

diff --git a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/config/impl/XMLObjectProviderInitializer.java b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/config/impl/XMLObjectProviderInitializer.java
index 7e4c2aad4..64114e31b 100644
--- a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/config/impl/XMLObjectProviderInitializer.java
+++ b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/config/impl/XMLObjectProviderInitializer.java
@@ -17,6 +17,8 @@
 
 package org.opensaml.xacml.config.impl;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer;
 
 /**
@@ -25,14 +27,14 @@ import org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer;
 public class XMLObjectProviderInitializer extends AbstractXMLObjectProviderInitializer {
     
     /** Config resources. */
-    private static String[] configs = {
+    @Nonnull private static String[] configs = {
         "/xacml20-context-config.xml",
         "/xacml20-policy-config.xml",
         };
 
     /** {@inheritDoc} */
-    protected String[] getConfigResources() {
+    @Nonnull protected String[] getConfigResources() {
         return configs;
     }
 
-}
+}
\ No newline at end of file
diff --git a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/BaseObligationHandler.java b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/BaseObligationHandler.java
index 11fb1b071..673bf27f5 100644
--- a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/BaseObligationHandler.java
+++ b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/BaseObligationHandler.java
@@ -19,8 +19,11 @@ package org.opensaml.xacml.ctx.provider.impl;
 
 import java.util.Objects;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.xacml.policy.ObligationType;
 
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
 import net.shibboleth.shared.primitive.StringSupport;
 
 /**
@@ -34,7 +37,7 @@ import net.shibboleth.shared.primitive.StringSupport;
 public abstract class BaseObligationHandler {
 
     /** ID of the handled obligation. */
-    private String id;
+    @Nonnull @NotEmpty private String id;
 
     /** Precedence of this handler. */
     private int precedence;
@@ -44,7 +47,7 @@ public abstract class BaseObligationHandler {
      * 
      * @param obligationId ID of the handled obligation
      */
-    protected BaseObligationHandler(final String obligationId) {
+    protected BaseObligationHandler(@Nonnull @NotEmpty final String obligationId) {
         this(obligationId, Integer.MIN_VALUE);
     }
 
@@ -54,7 +57,7 @@ public abstract class BaseObligationHandler {
      * @param obligationId ID of the handled obligation
      * @param handlerPrecedence precedence of this handler
      */
-    protected BaseObligationHandler(final String obligationId, final int handlerPrecedence) {
+    protected BaseObligationHandler(@Nonnull @NotEmpty final String obligationId, final int handlerPrecedence) {
         id = StringSupport.trimOrNull(obligationId);
         if (id == null) {
             throw new IllegalArgumentException("Provided obligation ID may not be null or empty");
@@ -68,7 +71,7 @@ public abstract class BaseObligationHandler {
      * 
      * @return ID of the handled obligation
      */
-    public String getObligationId() {
+    @Nonnull @NotEmpty public String getObligationId() {
         return id;
     }
 
@@ -89,8 +92,8 @@ public abstract class BaseObligationHandler {
      * 
      * @throws ObligationProcessingException thrown if there is a problem evaluating this handler
      */
-    public abstract void evaluateObligation(ObligationProcessingContext context, ObligationType obligation)
-            throws ObligationProcessingException;
+    public abstract void evaluateObligation(@Nonnull final ObligationProcessingContext context,
+            @Nonnull final ObligationType obligation) throws ObligationProcessingException;
 
     /** {@inheritDoc} */
     public int hashCode() {
@@ -109,4 +112,5 @@ public abstract class BaseObligationHandler {
 
         return false;
     }
+
 }
\ No newline at end of file
diff --git a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationProcessingContext.java b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationProcessingContext.java
index 5b7d13e15..9500564f5 100644
--- a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationProcessingContext.java
+++ b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationProcessingContext.java
@@ -17,6 +17,8 @@
 
 package org.opensaml.xacml.ctx.provider.impl;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.xacml.ctx.ResultType;
 
 /**
@@ -25,14 +27,14 @@ import org.opensaml.xacml.ctx.ResultType;
 public class ObligationProcessingContext {
 
     /** Result of a XACML authorization request. */
-    private ResultType result;
+    @Nonnull private ResultType result;
 
     /**
      * Constructor.
      * 
      * @param authzResult result of a XACML authorization request
      */
-    public ObligationProcessingContext(final ResultType authzResult) {
+    public ObligationProcessingContext(@Nonnull final ResultType authzResult) {
         if (authzResult == null) {
             throw new IllegalArgumentException("Authorization request result may not be null");
         }
@@ -44,7 +46,7 @@ public class ObligationProcessingContext {
      * 
      * @return result of a XACML authorization request
      */
-    public ResultType getAuthorizationDecisionResult() {
+    @Nonnull public ResultType getAuthorizationDecisionResult() {
         return result;
     }
 }
\ No newline at end of file
diff --git a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationService.java b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationService.java
index 883eec792..fc1ca0ec1 100644
--- a/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationService.java
+++ b/opensaml-xacml-impl/src/main/java/org/opensaml/xacml/ctx/provider/impl/ObligationService.java
@@ -28,19 +28,25 @@ import java.util.TreeSet;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.xacml.ctx.DecisionType.DECISION;
 import org.opensaml.xacml.policy.EffectType;
 import org.opensaml.xacml.policy.ObligationType;
 import org.opensaml.xacml.policy.ObligationsType;
 
+import net.shibboleth.shared.annotation.constraint.Live;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.logic.Constraint;
+
 /** A service for evaluating the obligations within a context. */
 public class ObligationService {
 
     /** Read/write lock around the registered obligation handlers. */
-    private ReentrantReadWriteLock rwLock;
+    @Nonnull private ReentrantReadWriteLock rwLock;
 
     /** Registered obligation handlers. */
-    private Set<BaseObligationHandler> obligationHandlers;
+    @Nonnull private Set<BaseObligationHandler> obligationHandlers;
 
     /** Constructor. */
     public ObligationService() {
@@ -53,7 +59,7 @@ public class ObligationService {
      * 
      * @return registered obligation handlers
      */
-    public Set<BaseObligationHandler> getObligationHandlers() {
+    @Nonnull @Unmodifiable @Live public Set<BaseObligationHandler> getObligationHandlers() {
         return Collections.unmodifiableSet(obligationHandlers);
     }
 
@@ -64,10 +70,8 @@ public class ObligationService {
      * 
      * @param handler the handler to add to the list of registered handlers.
      */
-    public void addObligationhandler(final BaseObligationHandler handler) {
-        if (handler == null) {
-            return;
-        }
+    public void addObligationhandler(@Nonnull final BaseObligationHandler handler) {
+        Constraint.isNotNull(handler, "Handler cannot be null");
 
         final Lock writeLock = rwLock.writeLock();
         writeLock.lock();
@@ -85,8 +89,9 @@ public class ObligationService {
      * 
      * @param handlers the collection of handlers to add to the list of registered handlers.
      */
-    public void addObligationhandler(final Collection<BaseObligationHandler> handlers) {
-        if (handlers == null || handlers.isEmpty()) {
+    public void addObligationhandler(@Nonnull final Collection<BaseObligationHandler> handlers) {
+        Constraint.isNotNull(handlers, "Handlers cannot be null");
+        if (handlers.isEmpty()) {
             return;
         }
 
@@ -106,10 +111,8 @@ public class ObligationService {
      * 
      * @param handler the handler to remove from the list of registered handlers.
      */
-    public void removeObligationHandler(final BaseObligationHandler handler) {
-        if (handler == null) {
-            return;
-        }
+    public void removeObligationHandler(@Nonnull final BaseObligationHandler handler) {
+        Constraint.isNotNull(handler, "Handler cannot be null");
 
         final Lock writeLock = rwLock.writeLock();
         writeLock.lock();
@@ -129,7 +132,8 @@ public class ObligationService {
      * 
      * @throws ObligationProcessingException thrown if there is a problem evaluating an obligation
      */
-    public void processObligations(final ObligationProcessingContext context) throws ObligationProcessingException {
+    public void processObligations(@Nonnull final ObligationProcessingContext context)
+            throws ObligationProcessingException {
         final Lock readLock = rwLock.readLock();
         readLock.lock();
         try {
@@ -157,7 +161,7 @@ public class ObligationService {
      * 
      * @return preprocessed obligations
      */
-    protected Map<String, ObligationType> preprocessObligations(final ObligationProcessingContext context) {
+    @Nonnull protected Map<String, ObligationType> preprocessObligations(@Nonnull final ObligationProcessingContext context) {
         final HashMap<String, ObligationType> effectiveObligations = new HashMap<>();
 
         final ObligationsType obligations = context.getAuthorizationDecisionResult().getObligations();
diff --git a/opensaml-xacml-saml-impl/src/main/java/org/opensaml/xacml/profile/saml/config/impl/XMLObjectProviderInitializer.java b/opensaml-xacml-saml-impl/src/main/java/org/opensaml/xacml/profile/saml/config/impl/XMLObjectProviderInitializer.java
index 2713a214f..4e0b5fa55 100644
--- a/opensaml-xacml-saml-impl/src/main/java/org/opensaml/xacml/profile/saml/config/impl/XMLObjectProviderInitializer.java
+++ b/opensaml-xacml-saml-impl/src/main/java/org/opensaml/xacml/profile/saml/config/impl/XMLObjectProviderInitializer.java
@@ -17,6 +17,8 @@
 
 package org.opensaml.xacml.profile.saml.config.impl;
 
+import javax.annotation.Nonnull;
+
 import org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer;
 
 /**
@@ -25,7 +27,7 @@ import org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer;
 public class XMLObjectProviderInitializer extends AbstractXMLObjectProviderInitializer {
     
     /** Config resources. */
-    private static String[] configs = {
+    @Nonnull private static String[] configs = {
         "/xacml10-saml2-profile-config.xml",
         "/xacml11-saml2-profile-config.xml",
         "/xacml2-saml2-profile-config.xml",
@@ -33,7 +35,7 @@ public class XMLObjectProviderInitializer extends AbstractXMLObjectProviderIniti
         };
 
     /** {@inheritDoc} */
-    protected String[] getConfigResources() {
+    @Nonnull protected String[] getConfigResources() {
         return configs;
     }
 

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


More information about the commits mailing list