2 * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package edu.internet2.middleware.shibboleth.idp.profile;
19 import javax.servlet.http.HttpServletResponse;
21 import org.opensaml.common.SAMLObject;
22 import org.opensaml.common.binding.BindingException;
23 import org.opensaml.common.binding.MessageEncoder;
24 import org.opensaml.xml.XMLObject;
26 import edu.internet2.middleware.shibboleth.common.profile.ProfileResponse;
29 * Shibboleth {@link ProfileResponse}.
31 public class ShibbolethProfileResponse implements ProfileResponse<HttpServletResponse> {
33 /** Encoder used to send the response. */
34 private MessageEncoder<HttpServletResponse> messageEncoder;
36 /** The outgoing response. */
37 private HttpServletResponse rawResponse;
42 * @param response the raw response
43 * @param encoder the encoder used to encode the response
45 public ShibbolethProfileResponse(HttpServletResponse response, MessageEncoder<HttpServletResponse> encoder) {
46 rawResponse = response;
47 messageEncoder = encoder;
51 public MessageEncoder<HttpServletResponse> getMessageEncoder() {
52 return messageEncoder;
56 public HttpServletResponse getRawResponse() {
63 * @throws BindingException thrown if the message can not be encoded and sent to the relying party
65 public void sendResponse(XMLObject response) throws BindingException {
66 messageEncoder.setResponse(rawResponse);
67 messageEncoder.setSAMLMessage((SAMLObject) response);
68 messageEncoder.encode();