KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.w3._2002._03.xkms_.AuthenticationType;
17 import org.w3._2002._03.xkms_.KeyBindingAbstractType;
18 import org.w3._2002._03.xkms_.PrivateKeyType;
19 import org.w3._2002._03.xkms_.ProofOfPossessionType;
20 import org.w3._2002._03.xkms_.RecoverRequestType;
21 import org.w3._2002._03.xkms_.RecoverResultType;
22 import org.w3._2002._03.xkms_.RegisterRequestType;
23 import org.w3._2002._03.xkms_.RegisterResultType;
24 import org.w3._2002._03.xkms_.ReissueRequestType;
25 import org.w3._2002._03.xkms_.RequestAbstractType;
26 import org.w3._2002._03.xkms_.ResultType;
27 import org.w3._2002._03.xkms_.RevokeRequestType;
28
29 /**
30  * A Help class used to generalize the different KRSS calls
31  *
32  * Needed since there isn't any good inheritense between
33  * the request
34  *
35  *
36  * @author Philip Vendil 2007 jan 1
37  *
38  * @version $Id: GeneralizedKRSSMessageHelper.java,v 1.1 2007/01/05 05:32:52 herrvendil Exp $
39  */

40
41 public class GeneralizedKRSSMessageHelper {
42     
43     public static AuthenticationType getAuthenticationType(RequestAbstractType request){
44         if(request instanceof RegisterRequestType){
45             return ((RegisterRequestType)request).getAuthentication();
46         }
47         if(request instanceof ReissueRequestType){
48             return ((ReissueRequestType)request).getAuthentication();
49         }
50         if(request instanceof RecoverRequestType){
51             return ((RecoverRequestType)request).getAuthentication();
52         }
53             
54         return null;
55     }
56     
57     
58     public static ProofOfPossessionType getProofOfPossessionType(RequestAbstractType request){
59         if(request instanceof RegisterRequestType){
60             return ((RegisterRequestType)request).getProofOfPossession();
61         }
62         if(request instanceof ReissueRequestType){
63             return ((ReissueRequestType)request).getProofOfPossession();
64         }
65             
66         return null;
67     }
68     
69     public static KeyBindingAbstractType getKeyBindingAbstractType(RequestAbstractType request){
70         if(request instanceof RegisterRequestType){
71             return ((RegisterRequestType)request).getPrototypeKeyBinding();
72         }
73         if(request instanceof ReissueRequestType){
74             return ((ReissueRequestType)request).getReissueKeyBinding();
75         }
76         if(request instanceof RecoverRequestType){
77             return ((RecoverRequestType)request).getRecoverKeyBinding();
78         }
79         if(request instanceof RevokeRequestType){
80             return ((RevokeRequestType)request).getRevokeKeyBinding();
81         }
82             
83         return null;
84     }
85     
86     public static void setPrivateKey(ResultType response, PrivateKeyType privateKeyType){
87         if(response instanceof RegisterResultType){
88             ((RegisterResultType)response).setPrivateKey(privateKeyType);
89         }
90         if(response instanceof RecoverResultType){
91             ((RecoverResultType)response).setPrivateKey(privateKeyType);
92         }
93     }
94     
95
96
97 }
98
Popular Tags