1 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 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 |