001/** 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved 005 * 006 * The contents of this file are subject to the terms 007 * of the Common Development and Distribution License 008 * (the License). You may not use this file except in 009 * compliance with the License. 010 * 011 * You can obtain a copy of the License at 012 * https://opensso.dev.java.net/public/CDDLv1.0.html or 013 * opensso/legal/CDDLv1.0.txt 014 * See the License for the specific language governing 015 * permission and limitations under the License. 016 * 017 * When distributing Covered Code, include this CDDL 018 * Header Notice in each file and include the License file 019 * at opensso/legal/CDDLv1.0.txt. 020 * If applicable, add the following below the CDDL Header, 021 * with the fields enclosed by brackets [] replaced by 022 * your own identifying information: 023 * "Portions Copyrighted [year] [name of copyright owner]" 024 * 025 * $Id: RequestAbstract.java,v 1.2 2008/06/25 05:47:57 qcheng Exp $ 026 * 027 */ 028 029 030package com.sun.identity.saml2.protocol; 031 032import com.sun.identity.saml.xmlsig.XMLSignatureException; 033import com.sun.identity.saml2.assertion.Issuer; 034import com.sun.identity.saml2.common.SAML2Exception; 035import java.security.PublicKey; 036import java.security.PrivateKey; 037import java.security.cert.X509Certificate; 038import java.security.Signature; 039import com.sun.identity.saml2.xmlsig.SigManager; 040import java.util.Date; 041import org.w3c.dom.Element; 042 043/** 044 * This interface defines methods for setting and retrieving attributes and 045 * elements associated with a SAML request message used in SAML protocols. 046 * 047 * @supported.all.api 048 */ 049 050public interface RequestAbstract { 051 052 /** 053 * Sets the <code>Issuer</code> object. 054 * 055 * @param nameID the new <code>Issuer</code> object. 056 * @throws SAML2Exception if the object is immutable. 057 * @see #getIssuer 058 */ 059 public void setIssuer(Issuer nameID) throws SAML2Exception; 060 061 /** 062 * Returns the <code>Issuer</code> Object. 063 * 064 * @return the <code>Issuer</code> object. 065 * @see #setIssuer(Issuer) 066 */ 067 public com.sun.identity.saml2.assertion.Issuer getIssuer(); 068 069 /** 070 * Returns the <code>Signature</code> Object as a string. 071 * 072 * @return the <code>Signature</code> object as a string. 073 */ 074 public String getSignature(); 075 076 /** 077 * Signs the Request. 078 * 079 * @param privateKey Signing key 080 * @param cert Certificate which contain the public key correlated to 081 * the signing key; It if is not null, then the signature 082 * will include the certificate; Otherwise, the signature 083 * will not include any certificate. 084 * @throws SAML2Exception if it could not sign the Request. 085 */ 086 public void sign(PrivateKey privateKey, X509Certificate cert) 087 throws SAML2Exception; 088 089 /** 090 * Sets the <code>Extensions</code> Object. 091 * 092 * @param extensions the <code>Extensions</code> object. 093 * @throws SAML2Exception if the object is immutable. 094 * @see #getExtensions 095 */ 096 public void setExtensions(Extensions extensions) throws SAML2Exception; 097 098 /** 099 * Returns the <code>Extensions</code> Object. 100 * 101 * @return the <code>Extensions</code> object. 102 * @see #setExtensions(Extensions) 103 */ 104 public Extensions getExtensions(); 105 106 /** 107 * Sets the value of the <code>ID</code> attribute. 108 * 109 * @param id the new value of <code>ID</code> attribute. 110 * @throws SAML2Exception if the object is immutable. 111 * @see #getID 112 */ 113 public void setID(String id) throws SAML2Exception; 114 115 /** 116 * Returns the value of the <code>ID</code> attribute. 117 * 118 * @return the value of <code>ID</code> attribute. 119 * @see #setID(String) 120 */ 121 public String getID(); 122 123 /** 124 * Sets the value of the <code>Version</code> attribute. 125 * 126 * @param version the value of <code>Version</code> attribute. 127 * @throws SAML2Exception if the object is immutable. 128 * @see #getVersion 129 */ 130 public void setVersion(String version) throws SAML2Exception; 131 132 /** 133 * Returns the value of the <code>Version</code> attribute. 134 * 135 * @return value of <code>Version</code> attribute. 136 * @see #setVersion(String) 137 */ 138 String getVersion(); 139 140 /** 141 * Sets the value of <code>IssueInstant</code> attribute. 142 * 143 * @param dateTime new value of the <code>IssueInstant</code> attribute. 144 * @throws SAML2Exception if the object is immutable. 145 * @see #getIssueInstant 146 */ 147 public void setIssueInstant(Date dateTime) throws SAML2Exception; 148 149 /** 150 * Returns the value of <code>IssueInstant</code> attribute. 151 * 152 * @return value of the <code>IssueInstant</code> attribute. 153 * @see #setIssueInstant(Date) 154 */ 155 public java.util.Date getIssueInstant(); 156 157 /** 158 * Sets the value of the <code>Destination</code> attribute. 159 * 160 * @param destinationURI new value of <code>Destination</code> attribute. 161 * @throws SAML2Exception if the object is immutable. 162 * @see #getDestination 163 */ 164 public void setDestination(String destinationURI) throws SAML2Exception; 165 166 /** 167 * Returns the value of the <code>Destination</code> attribute. 168 * 169 * @return the value of <code>Destination</code> attribute. 170 * @see #setDestination(String) 171 */ 172 public String getDestination(); 173 174 /** 175 * Sets the value of the <code>Consent</code> attribute. 176 * 177 * @param consent new value of <code>Consent</code> attribute. 178 * @throws SAML2Exception if the object is immutable. 179 * @see #getConsent 180 */ 181 public void setConsent(String consent) throws SAML2Exception; 182 183 /** 184 * Returns the value of the <code>Consent</code> attribute. 185 * 186 * @return value of <code>Consent</code> attribute. 187 * @see #setConsent(String) 188 */ 189 public String getConsent(); 190 191 192 /** 193 * Returns true if message is signed. 194 * 195 * @return true if message is signed. 196 */ 197 198 public boolean isSigned(); 199 200 201 /** 202 * Return whether the signature is valid or not. 203 * 204 * @param senderCert Certificate containing the public key 205 * which may be used for signature verification; 206 * This certificate may also may be used to check 207 * against the certificate included in the signature 208 * @return true if the signature is valid; false otherwise. 209 * @throws SAML2Exception if the signature could not be verified 210 */ 211 public boolean isSignatureValid(X509Certificate senderCert) 212 throws SAML2Exception; 213 214 /** 215 * Returns a String representation of this Object. 216 * 217 * @return a String representation of this Object. 218 * @throws SAML2Exception if it could not create String object 219 */ 220 public String toXMLString() throws SAML2Exception; 221 222 /** 223 * Returns a String representation of this Object. 224 * 225 * @param includeNSPrefix determines whether or not the namespace 226 * qualifier is prepended to the Element when converted 227 * @param declareNS determines whether or not the namespace is declared 228 * within the Element. 229 * @throws SAML2Exception if it could not create String object. 230 * @return a String representation of this Object. 231 **/ 232 233 public String toXMLString(boolean includeNSPrefix,boolean declareNS) 234 throws SAML2Exception; 235 236 237 /** 238 * Makes this object immutable. 239 */ 240 public void makeImmutable() ; 241 242 /** 243 * Returns true if object is mutable. 244 * 245 * @return true if object is mutable. 246 */ 247 public boolean isMutable(); 248}