All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensaml.saml.common.binding.BindingDescriptor Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * Licensed to the University Corporation for Advanced Internet Development, 
 * Inc. (UCAID) under one or more contributor license agreements.  See the 
 * NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The UCAID licenses this file to You under the Apache 
 * License, Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed to the University Corporation for Advanced Internet Development, 
 * Inc. (UCAID) under one or more contributor license agreements.  See the 
 * NOTICE file distributed with this work for additional information regarding
 * copyright ownership. The UCAID licenses this file to You under the Apache 
 * License, Version 2.0 (the "License"); you may not use this file except in 
 * compliance with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.opensaml.saml.common.binding;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.utilities.java.support.logic.Constraint;

import org.opensaml.profile.context.ProfileRequestContext;

import com.google.common.base.MoreObjects;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

/**
 * A class that describes a SAML binding and encapsulates information required for
 * profile actions to interact with them.
 * 
 * 

Configuration logic should expose the usable bindings to profile actions * through instances of this class.

*/ public class BindingDescriptor extends AbstractIdentifiableInitializableComponent implements Predicate { /** Predicate that must be true for this flow to be usable for a given request. */ @Nonnull private Predicate activationCondition; /** Identifies a binding that is direct request/response between two parties (i.e., SOAP). */ private boolean synchronous; /** Identifies a binding that relies on SAML artifacts. */ private boolean artifact; /** Constructor. */ public BindingDescriptor() { synchronous = false; artifact = false; activationCondition = Predicates.alwaysTrue(); } /** * Set the activation condition in the form of a {@link Predicate} such that iff the condition * evaluates to true should the corresponding binding be allowed/possible. * * @param condition predicate that controls activation of the binding */ public void setActivationCondition(@Nonnull final Predicate condition) { activationCondition = Constraint.isNotNull(condition, "Activation condition predicate cannot be null"); } /** * Get whether the binding is synchronous (direct request/response, typically SOAP). * * @return true iff the binding is synchronous */ public boolean isSynchronous() { return synchronous; } /** * Set whether the binding is synchronous (direct request/response, typically SOAP). * * @param flag flag to set */ public void setSynchronous(final boolean flag) { synchronous = flag; } /** * Get whether the binding is artifact-based. * * @return true iff the binding is artifact-based */ public boolean isArtifact() { return artifact; } /** * Set whether the binding is artifact-based. * * @param flag flag to set */ public void setArtifact(final boolean flag) { artifact = flag; } /** {@inheritDoc} */ @Override public boolean apply(@Nullable final ProfileRequestContext input) { return activationCondition.apply(input); } /** {@inheritDoc} */ @Override public int hashCode() { return getId().hashCode(); } /** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj instanceof BindingDescriptor) { return getId().equals(((BindingDescriptor) obj).getId()); } return false; } /** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(this).add("bindingId", getId()) .add("synchronous", synchronous) .add("artifact", artifact) .toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy