class SoftwareSmartcard implements Smartcard, Serializable {

    @Override
    public SmartcardStatusCode storeCredential(int pin, URI credentialId, Credential cred, CredentialSerializer serializer){
        byte[] credBytes = serializer.serializeCredential(cred);
        log.fine("CredBytes length: " + credBytes.length);
        int nextCredBlobUri = 1;
        SmartcardStatusCode returnCode = SmartcardStatusCode.OK;

        int bytesLeft = credBytes.length;
        int i = 0;
        boolean done = false;
        while(!done){
            SmartcardBlob blob = new SmartcardBlob();
            if(bytesLeft > MAX_BLOB_LEN_BYTES){
                blob.blob = new byte[MAX_BLOB_LEN_BYTES];
                bytesLeft -= MAX_BLOB_LEN_BYTES;
                System.arraycopy(credBytes, i*MAX_BLOB_LEN_BYTES, blob.blob, 0, MAX_BLOB_LEN_BYTES);
            }else{
                blob.blob = new byte[bytesLeft];
                System.arraycopy(credBytes, i*MAX_BLOB_LEN_BYTES, blob.blob, 0, bytesLeft);
                done = true; //We know we are done as we put the last bytes in the blob.
            }
            URI credUri = URI.create(credentialId.toASCIIString()+"_"+nextCredBlobUri++);
            log.fine("storing a blob of size: " + blob.blob.length + " with uri: " + credUri.toASCIIString());
            returnCode = this.storeBlob(pin, credUri, blob);
            log.fine("Return from storeBlob: " + returnCode);
            if(returnCode != SmartcardStatusCode.OK){
                return returnCode;
            }
            i++;
        }
        return returnCode;
    }

    public  SoftwareSmartcard();
    public  SoftwareSmartcard(Random random);

}