KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > protocol > xkms > generators > ValidateResponseGenerator


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.core.protocol.xkms.generators;
15
16 import java.security.cert.X509Certificate JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.ejbca.core.protocol.xkms.common.XKMSConstants;
21 import org.w3._2002._03.xkms_.KeyBindingType;
22 import org.w3._2002._03.xkms_.ValidateRequestType;
23 import org.w3._2002._03.xkms_.ValidateResultType;
24
25 /**
26  * Class generating a response for a locate call
27  *
28  *
29  * @author Philip Vendil 2006 sep 27
30  *
31  * @version $Id: ValidateResponseGenerator.java,v 1.2 2007/01/05 05:32:51 herrvendil Exp $
32  */

33
34 public class ValidateResponseGenerator extends
35         KISSResponseGenerator {
36     
37
38     public ValidateResponseGenerator(String JavaDoc remoteIP, ValidateRequestType req) {
39         super(remoteIP, req);
40     }
41     
42     /**
43      * Returns a locate response
44      */

45     public ValidateResultType getResponse(boolean requestVerifies){
46         ValidateResultType result = xkmsFactory.createValidateResultType();
47         super.populateResponse(result, requestVerifies);
48         ValidateRequestType req = (ValidateRequestType) this.req;
49
50         
51         if(resultMajor == null){
52             if(!checkValidRespondWithRequest(req.getRespondWith())){
53                 resultMajor = XKMSConstants.RESULTMAJOR_SENDER;
54                 resultMinor = XKMSConstants.RESULTMINOR_MESSAGENOTSUPPORTED;
55             }
56
57             if(resultMajor == null){
58                 List JavaDoc<X509Certificate JavaDoc> queryResult = processRequest(req.getQueryKeyBinding());
59
60                 if(resultMajor == null){
61                     Iterator JavaDoc<X509Certificate JavaDoc> iter = queryResult.iterator();
62                     while(iter.hasNext()){
63                         X509Certificate JavaDoc nextCert = iter.next();
64                         result.getKeyBinding().add((KeyBindingType) getResponseValues(req.getQueryKeyBinding(),nextCert,true,false));
65
66                     }
67                 }
68             }
69         }
70         
71         if(resultMajor == null){
72             resultMajor = XKMSConstants.RESULTMAJOR_SUCCESS;
73         }
74                    
75         setResult(result);
76         
77
78         
79         
80         return result;
81     }
82     
83
84     
85     
86
87
88 }
89
Popular Tags