use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfGetRecognitionTreeResponse.
@Test
public void testConversionOfGetRecognitionTreeResponse() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Object o = m.unmarshal(m.str2doc(RECOGNITION_TREE_RESPONSE_XML));
if (o instanceof GetRecognitionTreeResponse) {
RecognitionTree tree = ((GetRecognitionTreeResponse) o).getRecognitionTree();
StringWriter sw = new StringWriter();
JAXB.marshal(tree, sw);
Document d = m.marshal(tree);
String s = m.doc2str(d);
LOG.debug(s);
} else {
throw new Exception("Object should be an instace of GetRecognitionTreeResponse");
}
}
use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfDisconnectResponse.
@Test
public void testConversionOfDisconnectResponse() throws Exception {
WSMarshaller m = new AndroidMarshaller();
DisconnectResponse dr = new DisconnectResponse();
dr.setResult(WSHelper.makeResultOK());
Document d = m.marshal(dr);
assertEquals(m.doc2str(d), DISCONNECT_RESPONSE);
}
use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfCardInfo.
@Test
public void testConversionOfCardInfo() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Object o = m.unmarshal(m.str2doc(NPA_CIF));
if (!(o instanceof CardInfo)) {
throw new Exception("Object should be an instace of CardInfo");
}
CardInfo cardInfo = (CardInfo) o;
assertEquals("http://bsi.bund.de/cif/npa.xml", cardInfo.getCardType().getObjectIdentifier());
assertEquals(new byte[] { 0x3F, 0x00 }, cardInfo.getApplicationCapabilities().getImplicitlySelectedApplication());
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().size(), 3);
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getApplicationName(), "MF");
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getRequirementLevel(), BasicRequirementsType.PERSONALIZATION_MANDATORY);
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().size(), 40);
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().get(0).getCardApplicationServiceName(), "CardApplicationServiceAccess");
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().get(0).getAction().getAPIAccessEntryPoint(), APIAccessEntryPointName.INITIALIZE);
assertTrue(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().get(0).getSecurityCondition().isAlways());
// last accessrule
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().get(39).getAction().getAuthorizationServiceAction(), AuthorizationServiceActionName.ACL_MODIFY);
assertFalse(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getCardApplicationACL().getAccessRule().get(39).getSecurityCondition().isNever());
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getDIDInfo().get(0).getRequirementLevel(), BasicRequirementsType.PERSONALIZATION_MANDATORY);
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(0).getDIDInfo().get(0).getDIDACL().getAccessRule().get(0).getCardApplicationServiceName(), "DifferentialIdentityService");
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(1).getDataSetInfo().get(0).getRequirementLevel(), BasicRequirementsType.PERSONALIZATION_MANDATORY);
assertEquals(cardInfo.getApplicationCapabilities().getCardApplication().get(1).getDataSetInfo().get(0).getDataSetACL().getAccessRule().get(0).getCardApplicationServiceName(), "NamedDataService");
for (DataSetInfoType dataSetInfo : cardInfo.getApplicationCapabilities().getCardApplication().get(2).getDataSetInfo()) {
if (dataSetInfo.getDataSetName().equals("EF.C.ZDA.QES")) {
assertEquals(dataSetInfo.getLocalDataSetName().get(0).getLang(), "DE");
assertEquals(dataSetInfo.getLocalDataSetName().get(0).getValue(), "Zertifikat des ZDA für die QES");
}
}
// Test eGK
o = m.unmarshal(m.str2doc(EGK_CIF));
if (!(o instanceof CardInfo)) {
throw new Exception("Object should be an instace of CardInfo");
}
cardInfo = (CardInfo) o;
assertEquals("http://ws.gematik.de/egk/1.0.0", cardInfo.getCardType().getObjectIdentifier());
CardApplicationType cardApplicationESIGN = cardInfo.getApplicationCapabilities().getCardApplication().get(2);
DIDInfoType didInfo = cardApplicationESIGN.getDIDInfo().get(2);
DifferentialIdentityType differentialIdentity = didInfo.getDifferentialIdentity();
assertEquals(differentialIdentity.getDIDName(), "PrK.CH.AUT_signPKCS1_V1_5");
assertEquals(differentialIdentity.getDIDProtocol(), "urn:oid:1.3.162.15480.3.0.25");
CryptoMarkerType cryptoMarkerType = new CryptoMarkerType(differentialIdentity.getDIDMarker().getCryptoMarker());
assertEquals(cryptoMarkerType.getProtocol(), "urn:oid:1.3.162.15480.3.0.25");
assertEquals(cryptoMarkerType.getAlgorithmInfo().getSupportedOperations().get(0), "Compute-signature");
// uncomment to get output files to make a diff
/*WSMarshaller jaxbMarshaller = new JAXBMarshaller();
CardInfo cardInfoJM = (CardInfo) jaxbMarshaller.unmarshal(jaxbMarshaller.str2doc(egkCif));
File f = new File("cifJM.xml");
FileOutputStream fos = new FileOutputStream(f);
File f2 = new File("cifAM.xml");
FileOutputStream fos2 = new FileOutputStream(f2);
marshalLog(cardInfoJM, fos);
marshalLog(cardInfo, fos2);*/
// Test ecard AT 0.9.0
o = m.unmarshal(m.str2doc(ECARD_AT_CIF));
if (!(o instanceof CardInfo)) {
throw new Exception("Object should be an instance of CardInfo");
}
cardInfo = (CardInfo) o;
}
use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfConclusion.
@Test
public void testConversionOfConclusion() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Object o = m.unmarshal(m.str2doc(CONCLUSION));
Conclusion c = (Conclusion) o;
assertEquals("http://ws.gematik.de/egk/1.0.0", c.getRecognizedCardType());
Conclusion cc = JAXB.unmarshal(new StringReader(CONCLUSION), Conclusion.class);
// TODO
// assertEquals(c.getTLSMarker().getAny().get(0),
// cc.getTLSMarker().getAny().get(0));
}
use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfInitializeFramework.
@Test
public void testConversionOfInitializeFramework() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Document d = m.str2doc(INITIALIZE_FRAMEWORK);
Object o = m.unmarshal(d);
if (!(o instanceof InitializeFramework)) {
throw new Exception("Object should be an instace of InitializeFramework");
}
}
Aggregations