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