Search in sources :

Example 41 with CardApplicationPathType

use of iso.std.iso_iec._24727.tech.schema.CardApplicationPathType 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

CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)39 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)35 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)34 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)34 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)33 Test (org.testng.annotations.Test)26 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)11 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)6 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)6 DIDGet (iso.std.iso_iec._24727.tech.schema.DIDGet)6 DIDGetResponse (iso.std.iso_iec._24727.tech.schema.DIDGetResponse)6 DIDList (iso.std.iso_iec._24727.tech.schema.DIDList)6 DIDListResponse (iso.std.iso_iec._24727.tech.schema.DIDListResponse)6 DIDQualifierType (iso.std.iso_iec._24727.tech.schema.DIDQualifierType)6 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)6 DataSetListResponse (iso.std.iso_iec._24727.tech.schema.DataSetListResponse)6 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)5 CardAppPathResultSet (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse.CardAppPathResultSet)5 ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)4 CryptoMarkerType (iso.std.iso_iec._24727.tech.schema.CryptoMarkerType)4