Changeset 16484


Ignore:
Timestamp:
Aug 4, 2016, 3:51:53 PM (3 years ago)
Author:
dcorreia
Message:

Added get card subject feature without needing PIN.
Fixed empty binary strings in debug information.

Location:
internals/2016/linuxloginsmartcardwizard
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/.idea/workspace.xml

    r16483 r16484  
    44    <list default="true" readonly="true" id="fbd8e757-714d-41c6-a2b9-8558c09dbd04" name="Default" comment="">
    55      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/trunk/proto1/cardHelper.py" />
    6       <change type="DELETED" beforePath="$PROJECT_DIR$/trunk/proto1/simple_example.py" afterPath="" />
    7       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/dictionaries/danielcorreia.xml" afterPath="$PROJECT_DIR$/.idea/dictionaries/danielcorreia.xml" />
    86      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
    9       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/carduser.py" afterPath="$PROJECT_DIR$/trunk/proto1/carduser.py" />
    107      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/config.py" afterPath="$PROJECT_DIR$/trunk/proto1/config.py" />
    11       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/eidlibPython_Wrapper/examples/simple_example.py" afterPath="$PROJECT_DIR$/trunk/proto1/eidlibPython_Wrapper/examples/simple_example.py" />
    12       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/final.py" afterPath="$PROJECT_DIR$/trunk/proto1/final.py" />
    13       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/system.py" afterPath="$PROJECT_DIR$/trunk/proto1/system.py" />
    14       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/w4pages.py" afterPath="$PROJECT_DIR$/trunk/proto1/w4pages.py" />
    15       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/welcome.py" afterPath="$PROJECT_DIR$/trunk/proto1/welcome.py" />
    168    </list>
    179    <ignored path="estagiopycharm.iws" />
     
    705697      <updated>1470237196802</updated>
    706698    </task>
    707     <option name="localTasksCounter" value="24" />
     699    <task id="LOCAL-00024" summary="Fixed page initialization and help messageBox calls.&#10;Added input validation to carduser when next is clicked.">
     700      <created>1470327680977</created>
     701      <option name="number" value="00024" />
     702      <option name="presentableId" value="LOCAL-00024" />
     703      <option name="project" value="LOCAL" />
     704      <updated>1470327680977</updated>
     705    </task>
     706    <option name="localTasksCounter" value="25" />
    708707    <servers />
    709708  </component>
     
    802801    <MESSAGE value="Updated middleware Python wrapper files" />
    803802    <MESSAGE value="Added help message dialogs and function execution after showing the page." />
    804     <option name="LAST_COMMIT_MESSAGE" value="Added help message dialogs and function execution after showing the page." />
     803    <MESSAGE value="Fixed page initialization and help messageBox calls.&#10;Added input validation to carduser when next is clicked." />
     804    <option name="LAST_COMMIT_MESSAGE" value="Fixed page initialization and help messageBox calls.&#10;Added input validation to carduser when next is clicked." />
    805805  </component>
    806806  <component name="XDebuggerManager">
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16479 r16484  
    55import shutil
    66import inspect
     7import cardHelper
    78
    89
     
    2425REMOVEDIRS_COMMAND = "rm -r "
    2526TEMP_LOCALUSERS = "/tmp/tmp_localusers"
     27TEMP_CERTDATA = "/tmp/tmp_certdata"
     28OPENSSLX509_COMMAND = "openssl x509 -inform der -subject -noout -in "
    2629
    2730
     
    3639        process = subprocess.Popen(command, shell=True, stdout=outputPath, stderr=subprocess.PIPE)
    3740        process.wait()
    38         print("DEBUG: executeCommand (%s) - %s" % (command, process.stderr.read()), file=sys.stderr)
     41        stderrData = process.stderr.read().decode().strip()
     42        if stderrData != "":
     43            print("DEBUG: executeCommand (%s) - %s" % (command, stderrData), file=sys.stderr)
    3944    except subprocess.CalledProcessError as error:
    4045        print("DEBUG: executeCommand (%s) - %s" % (command, error), file=sys.stderr)
     
    238243
    239244
    240 def getCardAuthCertificate():
    241     """
    242     Gets authentication certificate from the card
    243     :return: certificate in string format
    244     """
    245     executeCommand(INSPECT_COMMAND, open(TEMP_OUTPUT, mode="w"))
    246     cardData = readFileToList(TEMP_OUTPUT)
    247     for line in cardData:
    248         if "Autentica" in line and "serialNumber=" in line:
    249             return line
     245def getCardSubject():
     246    cardHelper.init()
     247    baseOutputFileName, totalCerts = cardHelper.start()
     248    cardHelper.release()
     249    cardSubject = ""
     250    for i in range(totalCerts):
     251        certFile = baseOutputFileName+str(i)
     252        executeCommand(OPENSSLX509_COMMAND+certFile, open(TEMP_CERTDATA, mode="w"))
     253        deleteFile(certFile)
     254        certSubject = readFileToString(TEMP_CERTDATA)
     255        if "Autentica" in certSubject and "serialNumber=" in certSubject:
     256            # we only want the value so we remove the starting "subject= " -> 9 characters
     257            cardSubject = certSubject[9::]
     258    return cardSubject
    250259
    251260
     
    257266    :return: True on success and False otherwise
    258267    """
    259     certificate = getCardAuthCertificate()
     268    certificate = getCardSubject()
    260269    try:
    261270        combo = certificate.strip() + " -> " + username + "\n"
     
    297306    deleteFile(TEMP_OUTPUT)
    298307    deleteFile(TEMP_LOCALUSERS)
     308    deleteFile(TEMP_CERTDATA)
    299309
    300310
     
    323333    executeCommand(awkCmd, open(TEMP_LOCALUSERS, mode="w"))
    324334    return [s.strip() for s in readFileToList(TEMP_LOCALUSERS)]
    325 
    326 
    327 #def getCardSubject():
    328     # call python module scripts to generate der files for each certificate
    329     # execute openssl command to convert der file to readable string
Note: See TracChangeset for help on using the changeset viewer.