<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2429166803430996285</id><updated>2011-12-04T21:49:09.698-08:00</updated><title type='text'>import org.kangzhang.*</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-4961752354921258727</id><published>2009-08-26T02:38:00.000-07:00</published><updated>2011-12-04T21:48:39.428-08:00</updated><title type='text'>Python keyring lib, new blog address</title><content type='html'>After three days full-time working on Java and ActionScript 3.0, I finally get time to write a post about recent news.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#1 Python keyring lib released&lt;/span&gt;&lt;br /&gt;We've released python keyring lib four days ago. It's exciting to see my work get released, and I've created a site for it.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://home.python-keyring.org/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_u84Z54raibU/SpUB4D4bBoI/AAAAAAAABOg/iYCe3GLAwRo/s320/python-keyring-website.jpeg.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Address of the site: &lt;a href="http://home.python-keyring.org/"&gt;http://home.python-keyring.org&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can find our mailing list, documentation page, repository and issue list on the site. If you've any advice or question, don't hesitate to tell us.&lt;br /&gt;Someone reported installation problems on our tracker. I'll try to fix these bugs and release v0.2 at this weekend.&lt;br /&gt;&lt;br /&gt;I'd like to thanks &lt;a href="http://ziade.org/blog"&gt;Tarek&lt;/a&gt; again for his great help on this project. I've learned a lot from him on this project, and I'll continue with the project to make it better. A new post about the tips and experiences I've got in this summer will be published later, when I get a new break. :-)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;#2 New domain name for this blog and new homepage for myself&lt;/span&gt;&lt;br /&gt;I'm going to move this blog to &lt;a href="http://blog-en.kangzhang.org/"&gt;http://blog-en.kangzhang.org&lt;/a&gt;.  To let the subscribers of this blog see this post and re-subscribe it at new address, it will be ready after the next 12 hours.&lt;br /&gt;&lt;a href="http://home.kangzhang.org/"&gt;http://home.kangzhang.org&lt;/a&gt; is also available now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-4961752354921258727?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/4961752354921258727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/08/python-keyring-lib-new-blog-address.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4961752354921258727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4961752354921258727'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/08/python-keyring-lib-new-blog-address.html' title='Python keyring lib, new blog address'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_u84Z54raibU/SpUB4D4bBoI/AAAAAAAABOg/iYCe3GLAwRo/s72-c/python-keyring-website.jpeg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-6577204600265174425</id><published>2009-07-26T19:22:00.000-07:00</published><updated>2009-07-26T19:22:41.862-07:00</updated><title type='text'>Win32CryptoKeyring and CryptedFileKeyring</title><content type='html'>We've finished the keyring for Windows: Win32CryptoKeyring. It is based on the Windows's &lt;a href="http://msdn.microsoft.com/en-us/library/ms947420.aspx"&gt;CryptAPI&lt;/a&gt;. CryptAPI is a set of APIs which can encrypt/decrpty the data using the login user's info. Thus, the user dose not need to type in the password when he/she is going to unlock the data.&lt;br /&gt;&lt;br /&gt;We've also created a CryptedFileKeyring in the similar way. The difference between Win32CryptoKeyring and CryptedFileKeyring is that CryptedFileKeyring uses the &lt;a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard"&gt;AES&lt;/a&gt; algorithm provided by &lt;a href="http://www.pycrypto.org"&gt;PyCrypto&lt;/a&gt; to encrypt/decrypt users' passwords. This results that CryptedFileKeyring need the user input their password in encryption/decryption. This may be annoying, so this keyring is not encouraged for daily use. &lt;br /&gt;&lt;br /&gt;Both keyrings extend the BasicFileKeyring in the lib. BasicFileKeyring is the abstract base class for general file keyring which supports encryption/decryption. You can created a keyring with your encrypt/decrypt algorithms by easily extending BasicFileKeyring.&lt;br /&gt;&lt;br /&gt;For example, here is the source code for the UncryptedFileKeyring of the lib. &lt;br /&gt;&lt;pre class="python" name="code"&gt;class UncrpytedFileKeyring(BasicFileKeyring):&lt;br /&gt;    """A simple filekeyring which dose not encrypt the password.&lt;br /&gt;    """&lt;br /&gt;    def filename(self):&lt;br /&gt;        """Return the filename of the password file. It should be&lt;br /&gt;        "keyring_password.cfg" for Windows, ".keyring_password" for other&lt;br /&gt;        platforms.&lt;br /&gt;        """&lt;br /&gt;        import sys&lt;br /&gt;        if sys.platform in ['win32']:&lt;br /&gt;            return "keyring_password.cfg"&lt;br /&gt;        return ".keyring_password"&lt;br /&gt;&lt;br /&gt;    def encrypt(self, password):&lt;br /&gt;        """Directly return the password itself.&lt;br /&gt;        """&lt;br /&gt;        return password&lt;br /&gt;    def decrypt(self, password_encrypted):&lt;br /&gt;        """Directly return encrypted password.&lt;br /&gt;        """&lt;br /&gt;        return password_encrypted&lt;br /&gt;&lt;br /&gt;    def supported(self):&lt;br /&gt;        """Applicable for all platforms, but do not recommend.&lt;br /&gt;        """&lt;br /&gt;        return 0&lt;/pre&gt;Since UncryptFileKeyring dose not encrypt the password, its implementation is simple. The BasicFileKeyring handle all file parsing/stroring affairs. Here we just need due with the encryption/decryption.&lt;br /&gt;&lt;br /&gt;Notice that there is a supported() method for the keyring. It is a new abstract method added for the KeyringBackend. Every keyring needs implement this method to tell if it is applicable for current environment. &lt;br /&gt;&lt;br /&gt;We've also polish the code according to &lt;a href="www.python.org/dev/peps/pep-0008/"&gt;PEP 008&lt;/a&gt;. So some method names have been changed. Here is the new definition for the KeyringBackend.  &lt;br /&gt;&lt;pre class="python" name="code"&gt;class KeyringBackend():&lt;br /&gt;    """The abstract base class of the keyring, every backend must implement&lt;br /&gt;    this interface.&lt;br /&gt;    """&lt;br /&gt;    __metaclass__ = ABCMeta&lt;br /&gt;&lt;br /&gt;    @abstractmethod&lt;br /&gt;    def supported(self):&lt;br /&gt;        """Return if this keyring supports current enviroment.&lt;br /&gt;        -1: not applicable&lt;br /&gt;         0: suitable&lt;br /&gt;         1: recommended&lt;br /&gt;        """&lt;br /&gt;        return -1&lt;br /&gt;&lt;br /&gt;    @abstractmethod&lt;br /&gt;    def get_password(self, service, username): &lt;br /&gt;        """Get password of the username for the service&lt;br /&gt;        """&lt;br /&gt;        pass&lt;br /&gt;&lt;br /&gt;    @abstractmethod&lt;br /&gt;    def set_password(self, service, username, password): &lt;br /&gt;        """Set password for the username of the service&lt;br /&gt;        """&lt;br /&gt;        return -1&lt;/pre&gt;&lt;br /&gt;For more information, please visit our &lt;a href="http://bitbucket.org/kang/python-keyring-lib/"&gt;repository&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-6577204600265174425?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/6577204600265174425/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/07/win32cryptokeyring-and.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/6577204600265174425'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/6577204600265174425'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/07/win32cryptokeyring-and.html' title='Win32CryptoKeyring and CryptedFileKeyring'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-1368460613722427173</id><published>2009-07-12T19:58:00.000-07:00</published><updated>2009-07-12T23:47:50.970-07:00</updated><title type='text'>KWallet Porting and the Keyring Backend Selection</title><content type='html'>Last week I've finished the &lt;a href="http://docs.kde.org/stable/en/kdeutils/kwallet/index.html"&gt;KDE KWallet&lt;/a&gt; porting of the keyring lib. And now I'm working on the keyring backend selection feature of the lib. We are going to enable the user choosing the keyring both in runtime and by the config file.&lt;br /&gt;&lt;br /&gt;There's already a pototype demo in our demo folder(demo/keyring_demo.py). Here's some snippets from the demo.&lt;br /&gt;&lt;pre class="python" name="code"&gt;KEYRINGRC = ".keyringrc"&lt;br /&gt;&lt;br /&gt;def load_keyring_by_config():&lt;br /&gt;    """&lt;br /&gt;    This function shows how to enable a keyring using config file&lt;br /&gt;    """&lt;br /&gt;&lt;br /&gt;    # create the config file&lt;br /&gt;    f = open(KEYRINGRC,'w')&lt;br /&gt;    f.writelines(["[backend]\n",&lt;br /&gt;                  # the path for the user created keyring&lt;br /&gt;                  "keyring-path= %s\n" % str(os.path.abspath(__file__))[:-16],&lt;br /&gt;                  # the name of the keyring class &lt;br /&gt;                  "default-keyring=simplekeyring.SimpleKeyring\n" ])&lt;br /&gt;    f.close()&lt;br /&gt;&lt;br /&gt;    # import the keyring lib, the lib will automaticlly load the &lt;br /&gt;    # config file and load the user defined module&lt;br /&gt;    import keyring&lt;br /&gt;&lt;br /&gt;    # invoke the keyring to store and fetch the password&lt;br /&gt;    if keyring.setpass("demo-service","tarek","passexample") == 0:&lt;br /&gt;        print "password stored sucessful"&lt;br /&gt;    print "password", keyring.getpass("demo-service","tarek")&lt;br /&gt;&lt;br /&gt;    os.remove(KEYRINGRC)&lt;br /&gt;&lt;br /&gt;def set_keyring_in_runtime():&lt;br /&gt;    """&lt;br /&gt;    This function shows how to create a keyring manully and use it in runtime&lt;br /&gt;    """&lt;br /&gt;&lt;br /&gt;    # define a new keyring class which extends the KeyringBackend&lt;br /&gt;    import keyring.backend&lt;br /&gt;    class TestKeyring(keyring.backend.KeyringBackend):&lt;br /&gt;        def setpass(self,servicename,username,password): return 0 &lt;br /&gt;        def getpass(self,servicename,username): return "password from TestKeyring"&lt;br /&gt;    &lt;br /&gt;    # set the keyring for keyring lib&lt;br /&gt;    import keyring&lt;br /&gt;    keyring.set_keyring(TestKeyring())&lt;br /&gt;&lt;br /&gt;    # invoke the keyring lib&lt;br /&gt;    if keyring.setpass("demo-service","tarek","passexample") == 0:&lt;br /&gt;        print "password stored successful"&lt;br /&gt;    print "password", keyring.getpass("demo-service","tarek")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That two funtions illustrate the process of enabling a user created keyring by the config file and set the keyring in the runtime. The keyring class that load from disk is stored in demo/simplekeyring.py. Here's the definition of the keyring class.&lt;br /&gt;&lt;pre class="python" name="code"&gt;class SimpleKeyring(KeyringBackend):&lt;br /&gt;    """Simple Keyring is a keyring which can store only one&lt;br /&gt;    password in memory.&lt;br /&gt;    """&lt;br /&gt;    def __init__(self):&lt;br /&gt;        self.password = ''&lt;br /&gt;    def getpass(self,servicename,username):&lt;br /&gt;        return self.password&lt;br /&gt;    def setpass(self,servicename,username,password):&lt;br /&gt;        print "calling SimpleKeyring.setpass()"&lt;br /&gt;        self.password = password&lt;br /&gt;        return 0 &lt;br /&gt;&lt;/pre&gt;For more details, please refer to &lt;a href="http://bitbucket.org/kang/python-keyring-lib/"&gt;our repository&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-1368460613722427173?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/1368460613722427173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/07/kwallet-porting-and-keyring-backend.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/1368460613722427173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/1368460613722427173'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/07/kwallet-porting-and-keyring-backend.html' title='KWallet Porting and the Keyring Backend Selection'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-4735485639220146562</id><published>2009-06-30T06:21:00.000-07:00</published><updated>2009-06-30T06:21:07.041-07:00</updated><title type='text'>Porting to Gnome Keyring</title><content type='html'>I've finished porting the API to Gnome keyring. The latest code on the repository includes this feature. To compile the lib for gnome-keyring, you need &lt;a href="http://ftp.gnu.org/gnu/glibc/"&gt;Glibc&lt;/a&gt; 2.0, &lt;a href="http://dbus.freedesktop.org/"&gt;D-Bus&lt;/a&gt; 1.0 and &lt;a href="http://live.gnome.org/GnomeKeyring"&gt;Gnome Keyring&lt;/a&gt; 1.0. The changes that the keyring api made on your os can be see in the &lt;a href="http://live.gnome.org/Seahorse"&gt;Seahorse&lt;/a&gt; or Gnome Keyring Manager( Deprecated).&lt;br /&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_u84Z54raibU/SkoORYjd5WI/AAAAAAAABLA/GfbhBghmPcA/s1600-h/gnome-keyring1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_u84Z54raibU/SkoORYjd5WI/AAAAAAAABLA/GfbhBghmPcA/s320/gnome-keyring1.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_u84Z54raibU/SkoOaBcnhBI/AAAAAAAABLI/0uONWGWkMZM/s1600-h/gnome-keyring2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_u84Z54raibU/SkoOaBcnhBI/AAAAAAAABLI/0uONWGWkMZM/s320/gnome-keyring2.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Next platform is &lt;a href="http://docs.kde.org/stable/en/kdeutils/kwallet/index.html"&gt;KDE Kwallet&lt;/a&gt;, &lt;a href="http://web.mst.edu/~tauritzd/courses/CyberSecurityR&amp;D/sp2008/libpurple_slides.ppt"&gt;here&lt;/a&gt;'s some interesting materials .&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-4735485639220146562?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/4735485639220146562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/06/porting-to-gnome-keyring.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4735485639220146562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4735485639220146562'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/06/porting-to-gnome-keyring.html' title='Porting to Gnome Keyring'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_u84Z54raibU/SkoORYjd5WI/AAAAAAAABLA/GfbhBghmPcA/s72-c/gnome-keyring1.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-2208781238304973385</id><published>2009-06-17T04:05:00.000-07:00</published><updated>2009-06-17T04:05:10.495-07:00</updated><title type='text'>Keyring Lib on OSX</title><content type='html'>&lt;a href="http://bitbucket.org/kang/python-keyring-lib/" target="_blank"&gt;Python Keyring Lib&lt;/a&gt;&amp;nbsp;has been created on &lt;a href="http://bitbucket.org/" target="_blank"&gt;bitbucket.org&lt;/a&gt;. Anyone who has interest in this project can check out the latest code from that address using &lt;a href="http://www.selenic.com/mercurial" target="_blank"&gt;Mercurial&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://draft.blogger.com/post-edit.g?blogID=2429166803430996285&amp;amp;postID=2208781238304973385" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;/a&gt;We've finished the basic part on Mac OS X. It supports getting and setting password in &lt;a href="http://en.wikipedia.org/wiki/Keychain_%28Mac_OS%29" target="_blank"&gt;Keychain&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Following screenshots show a demo. The demo stored the password, and read it from the keychain. Notice that OS X prompted a dialog to let the user unlock the keychain.&lt;br /&gt;&lt;a href="http://2.bp.blogspot.com/_u84Z54raibU/SjjMEmXdF3I/AAAAAAAABKw/g4aLet18Y4Q/s1600-h/keyring-osx-demo-1.png" imageanchor="1" &gt;&lt;img border="0" src="http://2.bp.blogspot.com/_u84Z54raibU/SjjMEmXdF3I/AAAAAAAABKw/g4aLet18Y4Q/s320/keyring-osx-demo-1.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_u84Z54raibU/SjjMI-ImhmI/AAAAAAAABK4/xqzC1MaibUw/s1600-h/keyring-osx-demo-2.png" imageanchor="1" &gt;&lt;img border="0" src="http://4.bp.blogspot.com/_u84Z54raibU/SjjMI-ImhmI/AAAAAAAABK4/xqzC1MaibUw/s320/keyring-osx-demo-2.png" /&gt;&lt;/a&gt;&lt;br /&gt;The source code of this demo can be accessed from test/demo.py in the repository.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-2208781238304973385?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/2208781238304973385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/06/keyring-lib-on-osx.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/2208781238304973385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/2208781238304973385'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/06/keyring-lib-on-osx.html' title='Keyring Lib on OSX'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_u84Z54raibU/SjjMEmXdF3I/AAAAAAAABKw/g4aLet18Y4Q/s72-c/keyring-osx-demo-1.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-5117749365494583494</id><published>2009-05-03T22:48:00.000-07:00</published><updated>2009-05-03T23:07:54.869-07:00</updated><title type='text'>Call for Advices: The design issues in the Python keyring lib</title><content type='html'>About this project's idea, here's the proposal's abstract:&lt;br /&gt;&lt;blockquote&gt;As the Python desktop applications grew very fast, the need for a general, platform independent keyring API ,becomes important for development. Many services require authentication before they can be used. Application always needs to store these authentications safely.&lt;br /&gt;&lt;br /&gt;This lib is aimed to address this problem. By making a single call to this library, an application can store login information on a keyring where the application can retrieve the information—also with a single call—when needed.&lt;/blockquote&gt;For more information, you may refer to Tarek's post on the &lt;a href="http://tarekziade.wordpress.com/2009/03/27/pycon-hallway-session-1-a-keyring-library-for-python/"&gt;original idea&lt;/a&gt; and &lt;a href="http://tarekziade.wordpress.com/2009/05/03/gsoc-keyring-library-work-started/"&gt;the introduction of this project&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;The design of this lib has been started. Here's the main issues in the design phase:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Issue #1, the architecture of the keyring lib&lt;/span&gt;.&lt;br /&gt;There are several ways to implement an OS related lib. I've surveyed many related work on the python binding for the keyring service. These libs are designed for GTK (&lt;a href="http://www.rittau.org/blog/20070726-01"&gt;Gnome-python&lt;/a&gt; and &lt;a href="http://michael.susens-schurter.com/blog/2008/10/30/listing-all-passwords-stored-in-gnome-keyring/"&gt;Micheal's work&lt;/a&gt; ) or OSX(&lt;a href="https://launchpad.net/keychain.py/"&gt;Keychain.py&lt;/a&gt; and &lt;a href="http://code.google.com/p/pymacadmin/source/browse/trunk/lib/PyMacAdmin/Security/Keychain.py"&gt;PcMacAdmin&lt;/a&gt;) . Generally speaking, there are three way to implement such a lib.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Method 1, use the c/c++'s python extension. This method is used by &lt;a href="http://ftp.gnome.org/pub/GNOME/sources/gnome-python-desktop/"&gt;Gnome-python&lt;/a&gt; for their gnomekeyring binding.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Method 2, load the system's library through the ctypes. &lt;a href="http://code.google.com/p/pymacadmin/source/browse/trunk/lib/PyMacAdmin/Security/Keychain.py"&gt;PyMacAdmin&lt;/a&gt; use this way to wrap the Keychain service of OSX.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Method 3, execute a external tool using commonds. &lt;a href="https://launchpad.net/keychain.py/"&gt;Keychain.py&lt;/a&gt; uses this method.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;We prefer method 1, since it is faster and integrated with Python better.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Issue #2, about the lib's Windows implementation&lt;/span&gt;.&lt;br /&gt;Windows dose not provided any keyring services like the &lt;a href="http://live.gnome.org/GnomeKeyring/"&gt;Gnome keyring&lt;/a&gt; and &lt;a href="http://developer.apple.com/documentation/Security/Conceptual/keychainServConcepts/01introduction/introduction.html"&gt;KeyChain&lt;/a&gt;. One good option for Windows will be to provide our own lightweight keyring system, as we have everything needed in Python itself to do so. Another possible solution is using the &lt;a href="http://msdn.microsoft.com/en-us/library/aa380255%28VS.85%29.aspx"&gt;CryptoAPI&lt;/a&gt; as &lt;a href="http://subversion.tigris.org/"&gt;Subversion&lt;/a&gt; did.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Issue #3, the API interface of this keyring lib&lt;/span&gt;.&lt;br /&gt;We want to hear more voice from the potential developers who'll use this lib. An initial draft can be seen in the &lt;a href="http://tarekziade.wordpress.com/2009/03/27/pycon-hallway-session-1-a-keyring-library-for-python/"&gt;Tarek's post&lt;/a&gt;. I've also made some &lt;a href="http://docs.google.com/Doc?id=dgrxc9tq_30hs7prj37"&gt;rough thoughts&lt;/a&gt; after &lt;a href="http://kangzhang-en.blogspot.com/2009/04/overview-of-svn-authentication-system.html"&gt;looked into Subversion's code&lt;/a&gt;.&lt;br /&gt;Since we've decided to construct the whole lib from bottom to up, and to make the API better. This issue is not in a hurry. It will always be waiting for your suggestions.&lt;br /&gt;&lt;br /&gt;Any advice given will be credited. Don't hesitate to leave your thoughts here.:-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-5117749365494583494?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/5117749365494583494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/05/call-for-advices-design-issues-in.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/5117749365494583494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/5117749365494583494'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/05/call-for-advices-design-issues-in.html' title='Call for Advices: The design issues in the Python keyring lib'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-4181127731878134538</id><published>2009-04-26T07:03:00.000-07:00</published><updated>2009-04-26T07:03:39.170-07:00</updated><title type='text'>Overview of the SVN authentication system</title><content type='html'>In the PM with Tarek on API design of the Python keyring library, he mentioned&lt;br /&gt;that we should take a look at the unified authentication API used in Subversion.&lt;br /&gt;So I've read the related code yesterday. And I found the work done by the &lt;br /&gt;Subversion folks is really interesting and helpful for our Python keyring library.&lt;br /&gt;This post is going to introduce the security model and API interface used in &lt;br /&gt;Subversion project.&lt;br /&gt;&lt;br /&gt;Following paragraphs comes from the comments in Subversion's source code.&lt;br /&gt;Filename: &lt;i&gt;subversion/include/auth.h &lt;/i&gt;&lt;br /&gt;&lt;blockquote&gt;We define an authentication "provider" as a module that is able to&lt;br /&gt;return a specific set of credentials. (e.g. username/password,&lt;br /&gt;certificate, etc.)  Each provider implements a vtable that&lt;br /&gt;&lt;br /&gt;- can fetch initial credentials&lt;br /&gt;- can retry the fetch (or try to fetch something different)&lt;br /&gt;- can store the credentials for future use&lt;br /&gt;&lt;br /&gt;For any given type of credentials, there can exist any number of&lt;br /&gt;separate providers -- each provider has a different method of&lt;br /&gt;fetching. (i.e. from a disk store, by prompting the user, etc.)&lt;br /&gt;&lt;br /&gt;The application begins by creating an auth baton object, and&lt;br /&gt;"registers" some number of providers with the auth baton, in a&lt;br /&gt;specific order.  (For example, it may first register a&lt;br /&gt;username/password provider that looks in disk store, then register&lt;br /&gt;a username/password provider that prompts the user.)&lt;br /&gt;&lt;br /&gt;Later on, when any svn library is challenged, it asks the auth&lt;br /&gt;baton for the specific credentials.  If the initial credentials&lt;br /&gt;fail to authenticate, the caller keeps requesting new credentials.&lt;br /&gt;Under the hood, libsvn_auth effectively "walks" over each provider&lt;br /&gt;(in order of registry), one at a time, until all the providers have&lt;br /&gt;exhausted all their retry options.&lt;br /&gt;&lt;br /&gt;This system allows an application to flexibly define authentication&lt;br /&gt;behaviors (by changing registration order), and very easily write&lt;br /&gt;new authentication providers.&lt;br /&gt;&lt;br /&gt;An auth_baton also contains an internal hashtable of run-time&lt;br /&gt;parameters; any provider or library layer can set these run-time&lt;br /&gt;parameters at any time, so that the provider has access to the&lt;br /&gt;data.  (For example, certain run-time data may not be available&lt;br /&gt;until an authentication challenge is made.)  Each credential type&lt;br /&gt;must document the run-time parameters that are made available to&lt;br /&gt;its providers.&lt;/blockquote&gt;In &lt;i&gt;subversion/libsvn_subr/auth.c&lt;/i&gt;, we can find following key &lt;br /&gt;function interface used in Subversion's authentication system.&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;void  svn_auth_open (svn_auth_baton_t **auth_baton, apr_array_header_t *providers, apr_pool_t *pool)&lt;br /&gt;void  svn_auth_set_parameter (svn_auth_baton_t *auth_baton, const char *name, const void *value)&lt;br /&gt;const void *  svn_auth_get_parameter (svn_auth_baton_t *auth_baton, const char *name)&lt;br /&gt;svn_error_t *  svn_auth_first_credentials (void **credentials, svn_auth_iterstate_t **state, const char *cred_kind, const char *realmstring, svn_auth_baton_t *auth_baton, apr_pool_t *pool)&lt;br /&gt;svn_error_t *  svn_auth_next_credentials (void **credentials, svn_auth_iterstate_t *state, apr_pool_t *pool)&lt;br /&gt;svn_error_t *  svn_auth_save_credentials (svn_auth_iterstate_t *state, apr_pool_t *pool)&lt;/pre&gt;When the SVN library asked for the authentication, it first initialize the baton&lt;br /&gt;by calling &lt;i&gt;svn_auth_open()&lt;/i&gt;. Then it'll set the needed parameter through &lt;br /&gt;&lt;i&gt;svn_auth_set_parameter()&lt;/i&gt;. Finally, it can get the credentials using &lt;br /&gt;&lt;i&gt;svn_auth_first_credentials&lt;/i&gt; and &lt;i&gt;svn_auth_next_credentials&lt;/i&gt;. Note that the &lt;br /&gt;baton is initialize with a list of providers. When it is asked for credentials, &lt;br /&gt;it'll try to fetch the credentials in that list's order.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-4181127731878134538?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/4181127731878134538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/04/overview-of-svn-authentication-system.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4181127731878134538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4181127731878134538'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/04/overview-of-svn-authentication-system.html' title='Overview of the SVN authentication system'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-8505407806509666685</id><published>2009-04-25T19:48:00.000-07:00</published><updated>2009-04-25T20:42:30.156-07:00</updated><title type='text'>Space Optimized Tree</title><content type='html'>To learn the &lt;a href="http://flare.prefuse.org"&gt;Flare&lt;/a&gt; toolkit, I've implemented the space optimized tree using the toolkit. &lt;br /&gt;Click &lt;i&gt;Layouts&lt;/i&gt;-&gt;&lt;i&gt;Space Optimized Tree&lt;/i&gt; to view it.&lt;br /&gt;&lt;embed src="http://temphost.googlepages.com/demos2.swf" quality="high" bgcolor="#ffffff"    width="700" height="490" name="demos" align="middle"    play="true"    loop="false"    quality="high"    allowScriptAccess="sameDomain"    type="application/x-shockwave-flash"    pluginspage="http://www.adobe.com/go/getflashplayer"&gt;&lt;br /&gt;&lt;/embed&gt;&lt;br /&gt;The tree in this demo has about 1500 nodes. The algorithm performs very well.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-8505407806509666685?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/8505407806509666685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/04/space-optimized-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/8505407806509666685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/8505407806509666685'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/04/space-optimized-tree.html' title='Space Optimized Tree'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2429166803430996285.post-4134004429838273357</id><published>2009-04-24T01:48:00.000-07:00</published><updated>2009-04-24T01:48:28.269-07:00</updated><title type='text'>Hello world!</title><content type='html'>Yes, this is the first post. :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2429166803430996285-4134004429838273357?l=blog-en.kangzhang.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog-en.kangzhang.org/feeds/4134004429838273357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog-en.kangzhang.org/2009/04/hello-world.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4134004429838273357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2429166803430996285/posts/default/4134004429838273357'/><link rel='alternate' type='text/html' href='http://blog-en.kangzhang.org/2009/04/hello-world.html' title='Hello world!'/><author><name>Kang Zhang</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh3.googleusercontent.com/-UsXjxNNs0oo/AAAAAAAAAAI/AAAAAAAABU8/73hiS3DnDqM/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry></feed>
