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();
}
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);
}
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);
}
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);
}
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();
}
Aggregations