/*
 * Copyright [2009] [University Corporation for Advanced Internet Development, Inc.]
 *
 * Licensed 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 edu.internet2.middleware.openid.message.impl;

import edu.internet2.middleware.openid.common.ParameterMap;
import edu.internet2.middleware.openid.common.OpenIDConstants.Parameter;
import edu.internet2.middleware.openid.message.VerifyRequest;
import edu.internet2.middleware.openid.message.encoding.EncodingUtils;

/**
 * Marshaller for {@link VerifyRequest} messages.
 */
public class VerifyRequestMarshaller extends AbstractMessageMarshaller<VerifyRequest> {

    /** {@inheritDoc} */
    public void marshallParameters(VerifyRequest request, ParameterMap parameters) {
        parameters.put(Parameter.assoc_handle.QNAME, request.getAssociationHandle());
        parameters.put(Parameter.claimed_id.QNAME, request.getClaimedId());
        parameters.put(Parameter.op_endpoint.QNAME, request.getEndpoint());
        parameters.put(Parameter.identity.QNAME, request.getIdentity());
        parameters.put(Parameter.invalidate_handle.QNAME, request.getInvalidateHandle());
        parameters.put(Parameter.response_nonce.QNAME, request.getResponseNonce());
        parameters.put(Parameter.return_to.QNAME, request.getReturnTo().toString());
        parameters.put(Parameter.sig.QNAME, request.getSignature());

        if (!request.getSignedFields().isEmpty()) {
            String signedFields = EncodingUtils.encodeFieldList(request.getSignedFields(), parameters
                    .getNamespaces());
            parameters.put(Parameter.signed.QNAME, signedFields);
        }

    }

}
@@ -1215,24 +1215,82 @@
 rameters) %7B%0A
+        if (request.getAssociationHandle() != null) %7B%0A    
         para
@@ -1355,32 +1355,92 @@
 ationHandle());%0A
+        %7D%0A        if (request.getClaimedId() != null) %7B%0A    
         paramete
@@ -1495,24 +1495,83 @@
 aimedId());%0A
+        %7D%0A        if (request.getEndpoint() != null) %7B%0A    
         para
@@ -1630,24 +1630,83 @@
 ndpoint());%0A
+        %7D%0A        if (request.getIdentity() != null) %7B%0A    
         para
@@ -1762,24 +1762,91 @@
 dentity());%0A
+        %7D%0A        if (request.getInvalidateHandle() != null) %7B%0A    
         para
@@ -1915,32 +1915,96 @@
 idateHandle());%0A
+        %7D%0A        if (request.getResponseNonce() != null) %7B%0A    
         paramete
@@ -2067,24 +2067,83 @@
 seNonce());%0A
+        %7D%0A        if (request.getReturnTo() != null) %7B%0A    
         para
@@ -2211,24 +2211,84 @@
 oString());%0A
+        %7D%0A        if (request.getSignature() != null) %7B%0A    
         para
@@ -2343,16 +2343,128 @@
 ture());
+%0A        %7D%0A%0A        // marshall extensions before signed fields%0A        marshallExtensions(request, parameters);
 %0A%0A      
@@ -2614,29 +2614,8 @@
 ters
-%0A                    
 .get
@@ -2701,21 +2701,20 @@
 ;%0A        %7D%0A
-%0A
     %7D%0A%0A%7D

add null checking and message extensions to verify request marshaller