Search in sources :

Example 1 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class EAC1OutputType method getAuthDataType.

/**
 * Returns the DIDAuthenticationDataType.
 *
 * @return DIDAuthenticationDataType
 */
public DIDAuthenticationDataType getAuthDataType() {
    AuthDataResponse authResponse = authMap.createResponse(new iso.std.iso_iec._24727.tech.schema.EAC1OutputType());
    boolean carAsString = Boolean.valueOf(OpenecardProperties.getProperty("legacy.car"));
    if (retryCounter != null) {
        authResponse.addElement(RETRY_COUNTER, String.valueOf(retryCounter));
    }
    authResponse.addElement(CHAT, ByteUtils.toHexString(chat));
    authResponse.addElement(CAR, carAsString ? new String(currentCar) : ByteUtils.toHexString(currentCar));
    if (previousCar != null) {
        authResponse.addElement(CAR, carAsString ? new String(previousCar) : ByteUtils.toHexString(previousCar));
    }
    authResponse.addElement(EF_CARDACCESS, ByteUtils.toHexString(efCardAccess));
    authResponse.addElement(ID_PICC, ByteUtils.toHexString(idpicc));
    authResponse.addElement(CHALLENGE, ByteUtils.toHexString(challenge));
    return authResponse.getResponse();
}
Also used : AuthDataResponse(org.openecard.common.anytype.AuthDataResponse)

Example 2 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class GenericPINAction method performPACEWithCAN.

private EstablishChannelResponse performPACEWithCAN(Map<String, ExecutionResults> oldResults) throws ParserConfigurationException {
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp = new AuthDataMap(paceInput);
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField canField = (PasswordField) executionResults.getResult(GenericPINStep.CAN_FIELD);
        String canValue = new String(canField.getValue());
        if (canValue.length() != 6) {
            // let the user enter the can again, when input verification failed
            return null;
        } else {
            paceInputMap.addElement(PACEInputType.PIN, canValue);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_CAN);
    // perform PACE by EstablishChannelCommand
    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) PasswordField(org.openecard.gui.definition.PasswordField)

Example 3 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class GenericPINAction method performPACEWithPUK.

private EstablishChannelResponse performPACEWithPUK(Map<String, ExecutionResults> oldResults) throws ParserConfigurationException {
    DIDAuthenticationDataType paceInput = new DIDAuthenticationDataType();
    paceInput.setProtocol(ECardConstants.Protocol.PACE);
    AuthDataMap tmp = new AuthDataMap(paceInput);
    AuthDataResponse paceInputMap = tmp.createResponse(paceInput);
    if (capturePin) {
        ExecutionResults executionResults = oldResults.get(getStepID());
        PasswordField pukField = (PasswordField) executionResults.getResult(GenericPINStep.PUK_FIELD);
        String pukValue = new String(pukField.getValue());
        if (pukValue.length() != 10) {
            // TODO inform user that something with his input is wrong
            return null;
        } else {
            paceInputMap.addElement(PACEInputType.PIN, pukValue);
        }
    }
    paceInputMap.addElement(PACEInputType.PIN_ID, PIN_ID_PUK);
    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) PasswordField(org.openecard.gui.definition.PasswordField)

Example 4 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse 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 5 with AuthDataResponse

use of org.openecard.common.anytype.AuthDataResponse in project open-ecard by ecsec.

the class PACEOutputType method getAuthDataType.

/**
 * Returns the DIDAuthenticationDataType.
 *
 * @return DIDAuthenticationDataType
 */
public DIDAuthenticationDataType getAuthDataType() {
    AuthDataResponse authResponse = authMap.createResponse(new iso.std.iso_iec._24727.tech.schema.PACEOutputType());
    authResponse.addElement(RETRY_COUNTER, String.valueOf(retryCounter));
    authResponse.addElement(EF_CARD_ACCESS, ByteUtils.toHexString(efCardAccess));
    if (currentCAR != null) {
        authResponse.addElement(CURRENT_CAR, ByteUtils.toHexString(currentCAR));
    }
    if (previousCAR != null) {
        authResponse.addElement(PREVIOUS_CAR, ByteUtils.toHexString(previousCAR));
    }
    if (idpicc != null) {
        authResponse.addElement(ID_PICC, ByteUtils.toHexString(idpicc));
    }
    return authResponse.getResponse();
}
Also used : AuthDataResponse(org.openecard.common.anytype.AuthDataResponse)

Aggregations

AuthDataResponse (org.openecard.common.anytype.AuthDataResponse)11 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)8 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)8 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)8 AuthDataMap (org.openecard.common.anytype.AuthDataMap)8 ExecutionResults (org.openecard.gui.executor.ExecutionResults)8 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 PasswordField (org.openecard.gui.definition.PasswordField)5 WSException (org.openecard.common.WSHelper.WSException)3 StepActionResult (org.openecard.gui.executor.StepActionResult)3 Step (org.openecard.gui.definition.Step)2 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)1 APDUException (org.openecard.common.apdu.exception.APDUException)1 StepAction (org.openecard.gui.executor.StepAction)1 IFDException (org.openecard.ifd.scio.IFDException)1