Search in sources :

Example 11 with DIDGet

use of iso.std.iso_iec._24727.tech.schema.DIDGet in project open-ecard by ecsec.

the class PINCompareProtocolTest method testDIDGet.

@Test(enabled = TESTS_ENABLED)
public void testDIDGet() {
    CardApplicationPath cardApplicationPath = new CardApplicationPath();
    CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(this.appIdentifier_ROOT);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
    cardApplicationPathType = cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0);
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathType);
    CardApplicationConnectResponse result1 = instance.cardApplicationConnect(cardApplicationConnect);
    DIDGet didGet = new DIDGet();
    didGet.setDIDName("PIN.home");
    didGet.setConnectionHandle(result1.getConnectionHandle());
    DIDGetResponse result = instance.didGet(didGet);
    assertEquals(result.getResult().getResultMajor(), "http://www.bsi.bund.de/ecard/api/1.1/resultmajor#ok");
    assertEquals(result.getDIDStructure().getDIDName(), "PIN.home");
    assertEquals(result.getDIDStructure().getDIDMarker().getClass(), PinCompareMarkerType.class);
    PINCompareMarkerType pinCompareMarkerType = new PINCompareMarkerType((PinCompareMarkerType) result.getDIDStructure().getDIDMarker());
    assertEquals(ByteUtils.toHexString(pinCompareMarkerType.getPINRef().getKeyRef()), "02");
    // test with given correct scope
    didGet = new DIDGet();
    didGet.setDIDName("PIN.home");
    didGet.setDIDScope(DIDScopeType.GLOBAL);
    didGet.setConnectionHandle(result1.getConnectionHandle());
    result = instance.didGet(didGet);
    assertEquals(result.getResult().getResultMajor(), ECardConstants.Major.OK);
    assertEquals(result.getDIDStructure().getDIDName(), "PIN.home");
    assertEquals(result.getDIDStructure().getDIDMarker().getClass(), PinCompareMarkerType.class);
    pinCompareMarkerType = new PINCompareMarkerType((PinCompareMarkerType) result.getDIDStructure().getDIDMarker());
    assertEquals(ByteUtils.toHexString(pinCompareMarkerType.getPINRef().getKeyRef()), "02");
    cardApplicationPath = new CardApplicationPath();
    cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(this.appIdentifier_ESIGN);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    cardApplicationConnect = new CardApplicationConnect();
    cardApplicationPathType = cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0);
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathType);
    result1 = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(result1.getResult().getResultMajor(), ECardConstants.Major.OK);
    didGet = new DIDGet();
    didGet.setDIDName("PIN.home");
    didGet.setDIDScope(DIDScopeType.LOCAL);
    didGet.setConnectionHandle(result1.getConnectionHandle());
    result = instance.didGet(didGet);
    assertEquals(result.getResult().getResultMajor(), ECardConstants.Major.ERROR);
    assertEquals(result.getResult().getResultMinor(), ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND);
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) PinCompareMarkerType(iso.std.iso_iec._24727.tech.schema.PinCompareMarkerType) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DIDGet(iso.std.iso_iec._24727.tech.schema.DIDGet) DIDGetResponse(iso.std.iso_iec._24727.tech.schema.DIDGetResponse) PINCompareMarkerType(org.openecard.common.anytype.pin.PINCompareMarkerType) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Aggregations

DIDGetResponse (iso.std.iso_iec._24727.tech.schema.DIDGetResponse)10 DIDGet (iso.std.iso_iec._24727.tech.schema.DIDGet)9 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)6 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)6 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)6 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)6 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)6 DIDList (iso.std.iso_iec._24727.tech.schema.DIDList)6 DIDListResponse (iso.std.iso_iec._24727.tech.schema.DIDListResponse)6 Test (org.testng.annotations.Test)6 DIDQualifierType (iso.std.iso_iec._24727.tech.schema.DIDQualifierType)5 CardAppPathResultSet (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse.CardAppPathResultSet)4 CryptoMarkerType (iso.std.iso_iec._24727.tech.schema.CryptoMarkerType)4 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)4 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)3 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)3 PinCompareDIDAuthenticateInputType (iso.std.iso_iec._24727.tech.schema.PinCompareDIDAuthenticateInputType)3 Sign (iso.std.iso_iec._24727.tech.schema.Sign)2 SignResponse (iso.std.iso_iec._24727.tech.schema.SignResponse)2 Result (oasis.names.tc.dss._1_0.core.schema.Result)2