Search in sources :

Example 6 with CardInfo

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

the class PINStepAction method performPACEWithPIN.

private EstablishChannelResponse performPACEWithPIN(Map<String, ExecutionResults> oldResults) {
    DIDAuthenticationDataType protoData = eacData.didRequest.getAuthenticationProtocolData();
    AuthDataMap paceAuthMap;
    try {
        paceAuthMap = new AuthDataMap(protoData);
    } catch (ParserConfigurationException ex) {
        LOG.error("Failed to read EAC Protocol data.", ex);
        return null;
    }
    AuthDataResponse paceInputMap = paceAuthMap.createResponse(protoData);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField p = (PasswordField) executionResults.getResult(PINStep.PIN_FIELD);
        char[] pinIn = p.getValue();
        // TODO: check pin length and possibly allowed charset with CardInfo file
        if (pinIn.length == 0) {
            return null;
        } else {
            // NOTE: saving pin as string prevents later removal of the value from memory !!!
            paceInputMap.addElement(PACEInputType.PIN, new String(pinIn));
        }
    }
    // perform PACE
    paceInputMap.addElement(PACEInputType.PIN_ID, PasswordID.parse(eacData.pinID).getByteAsString());
    paceInputMap.addElement(PACEInputType.CHAT, eacData.selectedCHAT.toString());
    String certDesc = ByteUtils.toHexString(eacData.rawCertificateDescription);
    paceInputMap.addElement(PACEInputType.CERTIFICATE_DESCRIPTION, certDesc);
    EstablishChannel eChannel = createEstablishChannelStructure(paceInputMap);
    return (EstablishChannelResponse) dispatcher.safeDeliver(eChannel);
}
Also used : EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) AuthDataMap(org.openecard.common.anytype.AuthDataMap) ExecutionResults(org.openecard.gui.executor.ExecutionResults) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) AuthDataResponse(org.openecard.common.anytype.AuthDataResponse) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PasswordField(org.openecard.gui.definition.PasswordField)

Example 7 with CardInfo

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

the class CardApplicationWrapperTest method test.

/**
 * Simple test for CardApplicationWrapper-class. After getting the CardApplicationWrapper for the root application
 * we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardAppWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    assertEquals(cardAppWrapper.getApplicationIdentifier(), rootApplication);
    assertEquals(cardAppWrapper.getDataSetNameList().getDataSetName().size(), 5);
    assertEquals(cardAppWrapper.getDIDInfoList().size(), 9);
    assertEquals(cardAppWrapper.getCardApplicationACL().getAccessRule().size(), 40);
    assertNotNull(cardAppWrapper.getSecurityCondition(CardApplicationServiceActionName.CARD_APPLICATION_LIST));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 8 with CardInfo

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

the class DIDInfoWrapperTest method test.

/**
 * Simple test for DIDInfoWrapper-class. After getting the DIDInfoWrapper for the CAN DID in the
 * root applicaton of the npa we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DIDInfoWrapper didInfoWrapper = cardApplicationWrapper.getDIDInfo("CAN");
    assertSame(didInfoWrapper, cardApplicationWrapper.getDIDInfo("CAN"));
    assertNotNull(didInfoWrapper.getDIDInfo());
    assertNotNull(didInfoWrapper.getSecurityCondition(DifferentialIdentityServiceActionName.DID_GET));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 9 with CardInfo

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

the class DataSetInfoWrapperTest method test.

/**
 * Simple test for DataSetInfoWrapper-class. After getting the DataSetInfoWrapper for the EF.DIR data set in the
 * root applicaton of the npa we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DataSetInfoWrapper dataSetInfoWrapper = cardApplicationWrapper.getDataSetInfo("EF.DIR");
    assertSame(dataSetInfoWrapper, cardApplicationWrapper.getDataSetInfo("EF.DIR"));
    assertNotNull(dataSetInfoWrapper.getDataSetInfo());
    assertNotNull(dataSetInfoWrapper.getSecurityCondition(NamedDataServiceActionName.DSI_READ));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 10 with CardInfo

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

the class Status method resolveCardType.

private String resolveCardType(String cardType) {
    if (cardType.equals("http://bsi.bund.de/cif/unknown")) {
        return lang.translationForKey("status.unknowncard");
    } else {
        // read CardTypeName from CardInfo file
        String cardTypeName = cardType;
        CardInfoType cif = env.getCIFProvider().getCardInfo(cardType);
        if (cif != null) {
            CardTypeType type = cif.getCardType();
            if (type != null) {
                boolean found = false;
                String[] languages = new String[] { Locale.getDefault().getLanguage(), "en" };
                // check native lang, then english
                for (String language : languages) {
                    if (found) {
                        // stop when the inner loop terminated
                        break;
                    }
                    List<InternationalStringType> cardTypeNames = type.getCardTypeName();
                    for (InternationalStringType ist : cardTypeNames) {
                        if (ist.getLang().equalsIgnoreCase(language)) {
                            cardTypeName = ist.getValue();
                            found = true;
                            break;
                        }
                    }
                }
            }
        }
        return cardTypeName;
    }
}
Also used : CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) CardTypeType(iso.std.iso_iec._24727.tech.schema.CardTypeType) InternationalStringType(oasis.names.tc.dss._1_0.core.schema.InternationalStringType)

Aggregations

CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)11 Test (org.testng.annotations.Test)5 Expectations (mockit.Expectations)4 ClientEnv (org.openecard.common.ClientEnv)4 Environment (org.openecard.common.interfaces.Environment)4 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)4 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 CardApplicationType (iso.std.iso_iec._24727.tech.schema.CardApplicationType)2 CardInfo (iso.std.iso_iec._24727.tech.schema.CardInfo)2 CardTypeType (iso.std.iso_iec._24727.tech.schema.CardTypeType)2 DIDInfoType (iso.std.iso_iec._24727.tech.schema.DIDInfoType)2 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)2 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)2 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)2 GetCardInfoOrACD (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACD)2 GetCardInfoOrACDResponse (iso.std.iso_iec._24727.tech.schema.GetCardInfoOrACDResponse)2 Serializable (java.io.Serializable)2 InternationalStringType (oasis.names.tc.dss._1_0.core.schema.InternationalStringType)2 WSMarshaller (org.openecard.ws.marshal.WSMarshaller)2 WSMarshallerException (org.openecard.ws.marshal.WSMarshallerException)2