a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: RequestAbstract.java,v 1.2 2008/06/25 05:47:57 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpotts * Portions Copyrighted 2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.saml2.protocol;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.saml.xmlsig.XMLSignatureException;
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpottsimport com.sun.identity.saml2.assertion.Issuer;
ccf9d4a5c6453fa9f8b839baeee25147865fbb7dJames Phillpottsimport com.sun.identity.saml2.common.SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.PublicKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.PrivateKey;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.cert.X509Certificate;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.security.Signature;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.saml2.xmlsig.SigManager;
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Joosteimport java.util.Date;
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Joosteimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.w3c.dom.Element;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This interface defines methods for setting and retrieving attributes and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * elements associated with a SAML request message used in SAML protocols.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @supported.all.api
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic interface RequestAbstract {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the <code>Issuer</code> object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param nameID the new <code>Issuer</code> object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * @see #getIssuer
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste */
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste public void setIssuer(Issuer nameID) throws SAML2Exception;
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste /**
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * Returns the <code>Issuer</code> Object.
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste *
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * @return the <code>Issuer</code> object.
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * @see #setIssuer(Issuer)
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste */
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste public com.sun.identity.saml2.assertion.Issuer getIssuer();
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste /**
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * Returns the <code>Signature</code> Object as a string.
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste *
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste * @return the <code>Signature</code> object as a string.
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste */
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste public String getSignature();
48a3f9d4300dcee393075c632655deb42f43bce6Jaco Jooste
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Signs the Request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param privateKey Signing key
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param cert Certificate which contain the public key correlated to
6a490d4b01fde313651d02ca8d6ac8db32266d03Mark de Reeper * the signing key; It if is not null, then the signature
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will include the certificate; Otherwise, the signature
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * will not include any certificate.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if it could not sign the Request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void sign(PrivateKey privateKey, X509Certificate cert)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the <code>Extensions</code> Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param extensions the <code>Extensions</code> object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getExtensions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setExtensions(Extensions extensions) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the <code>Extensions</code> Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the <code>Extensions</code> object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setExtensions(Extensions)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Extensions getExtensions();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the value of the <code>ID</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param id the new value of <code>ID</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getID
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setID(String id) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the <code>ID</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the value of <code>ID</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setID(String)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getID();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the value of the <code>Version</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param version the value of <code>Version</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getVersion
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setVersion(String version) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the <code>Version</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return value of <code>Version</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setVersion(String)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String getVersion();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the value of <code>IssueInstant</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param dateTime new value of the <code>IssueInstant</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getIssueInstant
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setIssueInstant(Date dateTime) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of <code>IssueInstant</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return value of the <code>IssueInstant</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setIssueInstant(Date)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public java.util.Date getIssueInstant();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the value of the <code>Destination</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param destinationURI new value of <code>Destination</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getDestination
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setDestination(String destinationURI) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the <code>Destination</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the value of <code>Destination</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setDestination(String)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getDestination();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the value of the <code>Consent</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param consent new value of <code>Consent</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the object is immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #getConsent
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setConsent(String consent) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the value of the <code>Consent</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return value of <code>Consent</code> attribute.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @see #setConsent(String)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getConsent();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns true if message is signed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if message is signed.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isSigned();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Return whether the signature is valid or not.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param verificationCerts Certificates containing the public keys which may be used for signature verification;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This certificate may also may be used to check against the certificate included in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * signature.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if the signature is valid; false otherwise.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if the signature could not be verified
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isSignatureValid(Set<X509Certificate> verificationCerts) throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a String representation of this Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a String representation of this Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if it could not create String object
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toXMLString() throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a String representation of this Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param includeNSPrefix determines whether or not the namespace
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * qualifier is prepended to the Element when converted
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param declareNS determines whether or not the namespace is declared
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * within the Element.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SAML2Exception if it could not create String object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a String representation of this Object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster **/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String toXMLString(boolean includeNSPrefix,boolean declareNS)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws SAML2Exception;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Makes this object immutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void makeImmutable() ;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns true if object is mutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if object is mutable.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isMutable();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster