List of usage examples for javax.smartcardio CardException printStackTrace
public void printStackTrace()
From source file:eu.abc4trust.smartcard.HardwareSmartcard.java
@Override public SmartcardStatusCode addIssuerParametersWithAttendanceCheck(RSAKeyPair rootKey, URI parametersUri, int keyIDForCounter, CredentialBases credBases, RSAVerificationKey courseKey, int minimumAttendance) { byte issuerID = this.getNewIssuerID(parametersUri); byte groupID = issuerID; byte genID1 = 1; byte genID2 = 2; byte numPres = 0; //unlimited presentations - limit not used in the pilot byte counterID = issuerID; ByteBuffer buf = ByteBuffer.allocate(11); //SET ISSUER(BYTE issuerID, groupID, genID1, genID2, numpres, counterID) byte[] data = new byte[] { issuerID, groupID, genID1, genID2, numPres, counterID }; buf.put(new byte[] { (byte) this.ABC4TRUSTCMD, this.setIssuer, 0, 0, 6 }); buf.put(data);/*from w ww . j a va2 s. c o m*/ buf.position(0); try { //Before setting the issuer, we must create a group, generators as well as a counter int mode = this.getMode(); this.setGroupComponent(mode, credBases.n.toByteArray(), groupID, 0, rootKey); this.setGenerator(mode, credBases.R0.toByteArray(), groupID, genID1, rootKey); this.setGenerator(mode, credBases.S.toByteArray(), groupID, genID2, rootKey); byte[] cursor = this.getNewCursor(0); //Create a new key with keyID that counter can use. this.setAuthenticationKey(courseKey.n, keyIDForCounter, rootKey); this.setCounter(counterID, keyIDForCounter, 0, minimumAttendance, cursor, rootKey); //prior to the actual command,if we are in working mode, //we have to authenticate the input data first. if (mode == 2) { System.out.println("Can only use addIssuerParameters in root mode"); return SmartcardStatusCode.UNAUTHORIZED; } System.out.println("Input to setIssuer: " + Arrays.toString(buf.array())); ResponseAPDU response = this.transmitCommand(new CommandAPDU(buf)); System.out.println("Response from setIssuer: " + response); if (evaluateStatus(response) == SmartcardStatusCode.OK) { // SmartcardStatusCode code = this.storeIssuerUriAndID(pin, parametersUri, issuerID); // if(code != SmartcardStatusCode.OK){ // System.err.println("Could not store the issuerURI and ID on the card, but the issuer itself is still stored on the card. Returned code: " + code); // return code; // } } return this.evaluateStatus(response); } catch (CardException e) { //TODO: Error handling. Remove stuff again if something fails. e.printStackTrace(); return SmartcardStatusCode.NOT_FOUND; } }
From source file:eu.abc4trust.smartcard.HardwareSmartcard.java
public SmartcardStatusCode addUProveIssuerParametersWithAttendanceCheck(RSAKeyPair rootKey, URI parametersUri, int keyIDForCounter, UProveParams uProveParams, RSAVerificationKey courseKey, int minimumAttendance) { byte issuerID = this.getNewIssuerID(parametersUri); byte groupID = issuerID; byte genID1 = 1; byte genID2 = 0; //Not used in UProve, thus set to 0. byte numPres = 0; //unlimited presentations - limit not used in the pilot byte counterID = issuerID; ByteBuffer buf = ByteBuffer.allocate(11); //SET ISSUER(BYTE issuerID, groupID, genID1, genID2, numpres, counterID) byte[] data = new byte[] { issuerID, groupID, genID1, genID2, numPres, counterID }; buf.put(new byte[] { (byte) this.ABC4TRUSTCMD, this.setIssuer, 0, 0, 6 }); buf.put(data);/*from w w w. j a va2 s . c o m*/ buf.position(0); try { //Before setting the issuer, we must create a group, generators as well as a counter int mode = this.getMode(); this.setGroupComponent(mode, uProveParams.p.toByteArray(), groupID, 0, rootKey); this.setGroupComponent(mode, uProveParams.q.toByteArray(), groupID, 1, rootKey); this.setGroupComponent(mode, uProveParams.f.toByteArray(), groupID, 2, rootKey); System.out.println("p: " + uProveParams.p); System.out.println("q: " + uProveParams.q); System.out.println("g: " + uProveParams.g); System.out.println("f: " + uProveParams.f); this.setGenerator(mode, uProveParams.g.toByteArray(), groupID, genID1, rootKey); byte[] cursor = this.getNewCursor(0); //Create a new key with keyID that counter can use. this.setAuthenticationKey(courseKey.n, keyIDForCounter, rootKey); this.setCounter(counterID, keyIDForCounter, 0, minimumAttendance, cursor, rootKey); //prior to the actual command,if we are in working mode, //we have to authenticate the input data first. if (mode == 2) { System.out.println("Can only use addIssuerParameters in root mode"); return SmartcardStatusCode.UNAUTHORIZED; } System.out.println("Input for setIssuer: " + Arrays.toString(buf.array())); ResponseAPDU response = this.transmitCommand(new CommandAPDU(buf)); System.out.println("Response from setIssuer: " + response); if (evaluateStatus(response) == SmartcardStatusCode.OK) { // SmartcardStatusCode code = this.storeIssuerUriAndID(pin, parametersUri, issuerID); // if(code != SmartcardStatusCode.OK){ // System.err.println("Could not store the issuerURI and ID on the card, but the issuer itself is still stored on the card. Returned code: " + code); // return code; // } } return this.evaluateStatus(response); } catch (CardException e) { //TODO: Error handling. Remove stuff again if something fails. e.printStackTrace(); return SmartcardStatusCode.NOT_FOUND; } }