Friday 6 August 2010

Activate Token - script practice on Deepnet Authentication Server (< 5.0)

This is a piece of code for activating all inactive tokens in token stock.

import base64
import xmlrpclib
import sys

def main():
global server

if len(sys.argv)==1:
print 'Usage: acttoken serveraddr [port] [ssl]'
print '\tdefault port = 8080'
print
sys.exit(1)
addr = 'localhost'
if len(sys.argv)>1:
addr = sys.argv[1]

port = '8080'
if len(sys.argv)>2:
port = sys.argv[2]

proto='http://'
if len(sys.argv)>3:
if sys.argv[3]=='ssl':
proto='https://'

serverurl = proto + addr + ':' + port + '/das/xmlrpc'
print serverurl
server=xmlrpclib.Server(serverurl)

result = server.das.listStockTokens({'status':'INACTIVE'})
if result[0]!='OK':
print "Error:", result
sys.exit(2)

tokens = result[1]

for t in tokens:
print t, server.das.enableToken(t, True)



if __name__ == '__main__':
main()

Send Token - script practice on Deepnet Authentication Server (< 5.0)

If you are using Deepnet two factor authentication server, probably you will agree with me that you can do almost everything with its management console. However, sometimes you may wonder if they provide script to do the trivial and repeatable job. Yes, they do, you can use python script to instruct the authentication server.

Here it is an example of sending token.


import base64
import xmlrpclib
import sys


def main():
global server
addr = '192.168.222.149'
port = '8080'
proto='http://'

serverurl = proto + addr + ':' + port + '/das/xmlrpc'
print serverurl
server=xmlrpclib.Server(serverurl)
r = server.das.sendToken('77004280', False, 'SMTP')
##Use 'SMS' to send token by SMS
print r
return

if __name__ == '__main__':
main()

Monday 2 August 2010

icon dimensions (0 x 0) don't meet the size requirements

I tried to upload the binary of my updated iphone app, and found Apple forced us to use Application Loader instead of the original iTunesConnect.

With the new approach, I got the following error

iPhone/iPod Touch: Icon.png: icon dimensions (0 x 0) don't meet the size requirements. The icon file must be 57x57 pixels, in .png format

I double-checked the image file, the size IS 57x57. I was puzzled, as it had no problem before(with iTunesConnect).

Luckily, I found the following link on Internet

http://www.iphonedevsdk.com/forum/iphone-sdk-development/54784-icon-dimensions-0-x-0-dont-meet-size-requirements.html

where tonymy suggested

Edit Project Settings -> Build -> uncheck Compress PNG Files


As you can imagine, this glitch is not hard to avoid. I always try not to make a fetish of Apple's products, as I believe nobody is perfect.

Next time, Apple should submit their applications to get our approval before publishing, just as our apps have to wait to be approved.

Sunday 1 August 2010

xcode build error

I haven't touched iphone development for one year. Today I have to update my app which has some problem on iphone OS 4.x, however I got a mystery when I rebuilt the project after renewing the iphone development certificate.

Command /bin/sh failed with exit code 1
Justis Publishing Ltd:no such identity Line Location Tool:0




I have to admit that I did try this code sign certificate(Justis Publishing Ltd) last year before I opened an account with Apple (costed $99), and this cert was expired, so I deleted it in Keychain.

I am quite sure I chose the correct development certificate which was downloaded from my account on iphone development portal. In XCode IDE, I poked around every corner, but failed to get rid of this error.


My gut feeling told me this problem lied in the project setting, so I decided to have a look with the Terminal.

First of all, I went to the project setting folder(the ".xcodeproj" actually is a folder).

grep -i "Justis" *.*

The above grep command result said the string "Justis" did exist in the file project.pbxproj!

With nano, I saw the following in this file

/* Begin PBXShellScriptBuildPhase section */
3F3B364F0FD01DF6001754F2 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${PLATFORM_NAME}\" == \"iphoneos\" ]; then\nplatform=/Developer/Platforms/iPhoneOS.platform\nallocate=${platform}/Developer/usr/bin/codesign_allocate\nexport CODESIGN_ALLOCATE=${allocate}\ncodesign -fs \"Justis Publishing Ltd\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */


I have no idea how and when I added this section to this project, but I think I don't need this section at all, so I deleted it and saved the file, then reopened Xcode, and rebuilt my project, Bingo! I got everything right!

Like all other IDE, Xcode is not omnipotent. Sometime, you have to look into Makefile(here the project.pbxproj file), isn't it?