[java-opensaml COMMIT] in /trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common: binding/BindingDescriptor....

noreply at shibboleth.net noreply at shibboleth.net
Sat Oct 31 17:47:13 EDT 2015


Author: scantor
Date: Sat Oct 31 17:47:13 2015
New Revision: 4371

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4371&view=rev
Log:
Add signature-capable flag to SAML binding descriptors, and a predicate to check it.

Added:
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/logic/
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/logic/SignatureCapableBindingPredicate.java   (with props)
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/logic/package-info.java   (with props)
Modified:
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BindingDescriptor.java
    trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java

Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BindingDescriptor.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BindingDescriptor.java?rev=4371&r1=4370&r2=4371&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BindingDescriptor.java	(original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BindingDescriptor.java	Sat Oct 31 17:47:13 2015
@@ -65,10 +65,14 @@
     /** Identifies a binding that relies on SAML artifacts. */
     private boolean artifact;
     
+    /** Indicates whether the binding provides a built-in signing mechanism. */
+    private boolean signatureCapable;
+    
     /** Constructor. */
     public BindingDescriptor() {
         synchronous = false;
         artifact = false;
+        signatureCapable = false;
         activationCondition = Predicates.alwaysTrue();
     }
     
@@ -117,6 +121,24 @@
     public void setArtifact(final boolean flag) {
         artifact = flag;
     }
+    
+    /**
+     * Get whether the binding provides a message signature capability.
+     * 
+     * @return true iff the binding provides a message signature capability
+     */
+    public boolean isSignatureCapable() {
+        return signatureCapable;
+    }
+    
+    /**
+     * Set whether the binding provides a message signature capability.
+     * 
+     * @param flag flag to set
+     */
+    public void setSignatureCapable(final boolean flag) {
+        signatureCapable = flag;
+    }
 
     /** {@inheritDoc} */
     @Override
@@ -154,6 +176,7 @@
         return MoreObjects.toStringHelper(this).add("bindingId", getId())
                 .add("synchronous", synchronous)
                 .add("artifact", artifact)
+                .add("signatureCapable", signatureCapable)
                 .toString();
     }
 

Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java?rev=4371&r1=4370&r2=4371&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java	(original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/SAMLBindingSupport.java	Sat Oct 31 17:47:13 2015
@@ -188,7 +188,6 @@
      * {@link SAMLBindingContext#hasBindingSignature()}.
      * </p>
      * 
-     * 
      * @param messageContext current message context
      * @return true if the message is considered to be digitally signed, false otherwise
      */
@@ -206,7 +205,28 @@
             }
         }
     }
-    
+
+    /**
+     * Determine whether the SAML binding to be used by the message context supports signatures
+     * at the binding layer.
+     * 
+     * <p>
+     * The capability of the binding is determined by extracting a {@link BindingDescriptor} from a
+     * {@link SAMLBindingContext}.
+     * </p>
+     * 
+     * @param messageContext current message context
+     * @return true if the message is considered to be digitally signed, false otherwise
+     */
+    public static boolean isSigningCapableBinding(@Nonnull final MessageContext<SAMLObject> messageContext) {
+        final SAMLBindingContext bindingContext = messageContext.getSubcontext(SAMLBindingContext.class);
+        if (bindingContext != null && bindingContext.getBindingDescriptor() != null) {
+            return bindingContext.getBindingDescriptor().isSignatureCapable();
+        } else {
+            return false;
+        }
+    }
+
     /**
      * Determine whether the binding in use requires the presence within the message 
      * of information indicating the intended message destination endpoint URI.



More information about the commits mailing list