I’m a beta tester a crypto stick from GPF.

The crypto stick is an USB card to secure gpg keys on a smartcard.

cryptostick

The card was tested under some Linux and Windows systems successfully.

Running under MacOS Snow Leopard (Jan 2010) brought some issue with the card driver.

Current progress can be followed in the gnupg-users mailing-list.


Running pcscd in debug mode

Following the debug hint from driver developer’s page


LIBCCID_ifdLogLevel=0x0007
export LIBCCID_ifdLogLevel
ps -ef | grep pcsc
pcscd --foreground --debug --apdu

Inserting the cryptostick to the USB port, i get two different debug outputs:

Variante 1: debug output after inserting the card (card red light is blinking)


bash-3.2# pcscd --foreground --debug --apdu
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:240:DebugLogSetLevel() debug level=debug
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:269:DebugLogSetCategory() Debug options: APDU
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:585:main() pcsc-lite 1.4.0 daemon ready.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1545:ReaderCheckArchitecture() Send respawn signal to pcscd (pid=275)
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:678:signal_respawn() Got signal to respawn in 32 bit mode
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:294:SVCServiceRunLoop() Preparing to exit...
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1048:RFCleanupReaders() entering cleaning function
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:240:DebugLogSetLevel() debug level=debug
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:269:DebugLogSetCategory() Debug options: APDU
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:585:main() pcsc-lite 1.4.0 daemon ready.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:781:RFInitializeReader() Attempting startup of Gemplus GemPC Twin 00 00 using /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:507:RFBindFunctions() Binding driver functions
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:643:RFBindFunctions() Loading IFD Handler 3.0
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1323:init_driver() Driver version: 1.3.8
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1346:init_driver() LogLevel from LIBCCID_ifdLogLevel: 0x0007
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1356:init_driver() DriverOptions: 0x0000
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:81:IFDHCreateChannelByName() lun: 0, device: Gemplus GemPC Twin
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:158:OpenUSBByName() Reader index: 0, Device: Gemplus GemPC Twin
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:236:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr)
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:246:OpenUSBByName() ProductString: Generic CCID driver
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:252:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:311:OpenUSBByName() Checking device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:361:OpenUSBByName() Trying to open USB bus/device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:408:OpenUSBByName() Found Vendor/Product: 08E6/3437 (Gemplus GemPC Twin)
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:410:OpenUSBByName() Using USB bus/device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:836:ControlUSB() request: 0x03
receive: 01 2A 00 00 01 38 00 00 09 3D 00 00 34 43 00 00 61 51 00 00 01 54 00 00 8E 5B 00 00 CE 64 00 00 02 70 00 00 12 7A 00 00 02 7E 00 00 69 86 00 00 97 98 00 00 C3 A2 00 00 03 A8 00 00 1B B7 00 00 73 CB 00 00 03 D2 00 00 04 E0 00 00 24 F4 00 00 04 FC 00 00 D1 0C 01 00 05 18 01 00 2D 31 01 00 85 45 01 00 06 50 01 00 36 6E 01 00 E7 96 01 00 07 A4 01 00 07 C0 01 00 48 E8 01 00 08 F8 01 00 09 30 02 00 5A 62 02 00 0B 8B 02 00 0B A0 02 00 0E 48 03 00 0F 80 03 00 90 D0 03 00 16 40 05 00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 10753 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 14337 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 15625 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 17204 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 20833 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 21505 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 23438 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 25806 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 28674 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 31250 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 32258 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 34409 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 39063 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 41667 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 43011 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 46875 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 52083 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 53763 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 57348 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 62500 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 64516 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 68817 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 71685 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 78125 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 83333 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 86022 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 93750 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 104167 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 107527 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 114695 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 125000 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 129032 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 143369 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 156250 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 166667 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 172043 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 215054 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 229391 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 250000 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:816:get_data_rates() declared: 344086 bps
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:307:IFDHGetCapabilities() lun: 0, tag: 0xFAE
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:353:IFDHGetCapabilities() Reader supports 1 slot(s)
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:924:IFDHPowerICC() lun: 0, action: PowerUp
-> 000000 62 00 00 00 00 00 04 01 00 00
<- 000000 80 00 00 00 00 00 04 41 03 00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/commands.c:203:CmdPowerOn error on byte 3
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:964:IFDHPowerICC() PowerUp failed
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/eventhandler.cpp:314:EHStatusHandlerThread() Error powering up card: -2146435050 0x80100016
^C/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:662:signal_trap() Preparing for suicide
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:294:SVCServiceRunLoop() Preparing to exit...
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1048:RFCleanupReaders() entering cleaning function
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1057:RFCleanupReaders() Stopping reader: Gemplus GemPC Twin 00 00
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/eventhandler.cpp:177:EHDestroyEventHandler() Stomping thread.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/eventhandler.cpp:194:EHDestroyEventHandler() Thread stomped.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:832:RFUnInitializeReader() Attempting shutdown of Gemplus GemPC Twin 00 00.
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:226:IFDHCloseChannel() lun: 0
-> 000000 63 00 00 00 00 00 1C 00 00 00
<- 000000 81 00 00 00 00 00 1C 01 00 00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:569:CloseUSB() Closing USB device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:584:CloseUSB() Last slot closed. Release resources
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:675:RFUnBindFunctions() Unbinding driver functions
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:687:RFUnloadReader() Unloading reader driver.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:690:RFUnloadReader() --- closing dynamic library
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:611:at_exit() cleaning /var/run

Variante 2: insert card another time (card red light is permanent on)


bash-3.2# pcscd --foreground --debug --apdu
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:240:DebugLogSetLevel() debug level=debug
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:269:DebugLogSetCategory() Debug options: APDU
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:585:main() pcsc-lite 1.4.0 daemon ready.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1545:ReaderCheckArchitecture() Send respawn signal to pcscd (pid=389)
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:678:signal_respawn() Got signal to respawn in 32 bit mode
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:294:SVCServiceRunLoop() Preparing to exit...
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:1048:RFCleanupReaders() entering cleaning function
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:240:DebugLogSetLevel() debug level=debug
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/debuglog.c:269:DebugLogSetCategory() Debug options: APDU
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/pcscdaemon.c:585:main() pcsc-lite 1.4.0 daemon ready.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:781:RFInitializeReader() Attempting startup of Gemplus GemPC Twin 00 00 using /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:507:RFBindFunctions() Binding driver functions
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:643:RFBindFunctions() Loading IFD Handler 3.0
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1323:init_driver() Driver version: 1.3.8
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1346:init_driver() LogLevel from LIBCCID_ifdLogLevel: 0x0007
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:1356:init_driver() DriverOptions: 0x0000
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:81:IFDHCreateChannelByName() lun: 0, device: Gemplus GemPC Twin
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:158:OpenUSBByName() Reader index: 0, Device: Gemplus GemPC Twin
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:236:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr)
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:246:OpenUSBByName() ProductString: Generic CCID driver
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:252:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version.
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:311:OpenUSBByName() Checking device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:361:OpenUSBByName() Trying to open USB bus/device: 003/004-08e6-3437-00-00
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ccid_usb.c:402:OpenUSBByName() Can't claim interface 003/004-08e6-3437-00-00: Unknown error: 0
/SourceCache/SmartcardCCID/SmartcardCCID-35253/ccid/ccid/src/ifdhandler.c:99:IFDHCreateChannelByName() failed
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:820:RFInitializeReader() Open Port 6400000 Failed (Gemplus GemPC Twin)
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:675:RFUnBindFunctions() Unbinding driver functions
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:687:RFUnloadReader() Unloading reader driver.
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:690:RFUnloadReader() --- closing dynamic library
/SourceCache/SmartCardServices/SmartCardServices-36160/src/PCSC/readerfactory.c:261:RFAddReader() RFAddReader: Gemplus GemPC Twin init failed: -2146435067

Tags: ,

I have setup a small example that demonstrates how to use grails validation on non domain objects using the command pattern.
Collecting all required information was not that easy. Forums do not yet cover many G&G related topics, at least if you want to look under the hood of it

In general, my blogs target G&G developers. You should have at least an idea of how to use it, how to setup a project and what a controller is. My code is tested against Grails 1.1

Short summary

We are going to setup a simple controller with two closures. The one we use is responsible for logging a user into any platform.
Our controller uses a command to gather all params and to validate its values.

The controller

First thing you should create is the controller.
grails create-controller my
You might now copy and paste the following code into your controller class.

grails-app/controllers/MyController.groovy class MyController { def index = { } def run = { MyCommand cmd -> if(cmd.hasErrors()){ render(view:"error") }else{ render(view:"ok") } } } class MyCommand { String login String passwd1 String passwd2 static constraints = { login(blank:false, size:5..15, validator: { it=="foobar" }) passwd1(blank:false, validator: { val, obj -> obj.properties['passwd2']==val }) } }

The important closure for the upcoming test is called “run”.
As an argument it takes a command object.
The springframework behind the scenes is taking care, that all request params are properly mapped to the command object (MyCommand).
Furthermore the command object’s constraints are executed prior any other line of code in the “run” closure.
A powerful feature if you ask me :O)

The command class itself is in charge of all the validation work. As outlined in the grails docs (very good ones indeed) all domain oriented constraints
can be applied to non domain validation objects as well.

The contraint:

login(blank:false, size:5..15, validator: { it=="foobar" })

for example adds an error if the param login is null, if its length is smaller 5 chars or greate 15, or if the validator is returning anything else than null.
Adding an error ?
Grails is making extensive use of spring’s error handling. Have a look at their excellent docs.
For each error, an error object is added to the command object. The controller checks for errors in the command validation and can redirect back to the form if needed.

The test class

test/integration/MyControllerTests.groovy import grails.test.* class MyControllerTests extends ControllerUnitTestCase { protected void setUp() { super.setUp() } protected void tearDown() { super.tearDown() } void testValidCommand() { def cmd = new MyCommand(login:"foobar", passwd1:"password", passwd2:"password") def cntr = new MyController() cntr.run(cmd) assert "ok" == cntr.modelAndView.view } void testInvalidCommand() { def cmd = new MyCommand(login:"foobar", passwd1:"password", passwd2:"not-equals") def cntr = new MyController() cntr.run(cmd) //println cmd.errors.allErrors println "field error " + cmd.errors.fieldError assert 'passwd1' == cmd.errors.getFieldError('passwd1').field assert 'validator.invalid' == cmd.errors.getFieldError('passwd1').code } }

The test itself is simple. You have to create a command object that you use as the request object when calling the “run” closure within the controller.
The way I evaluate an error is ok, but not as good as I wanted it to be.
Grails ships with an enhanced way to handle message codes. Instead of letting the developer create a message key for each error, Grails makes strong usage of their convention over configuration approach by automatically assigning errors to dedicated message keys.
The error key for the login:blank constraint would be mapped in grails-app/i18n/messages.properties as:myCommand.login.blank.
Again the time consuming job of assigning messages keys to errors is omitted.

What I was not yet able to achieve is to fetch the associated error key for a given constraint within a test case.
So, what I am looking for is a line like:

assert 'myCommand.login.blank' == cmd.errors.getField('login').???

Well, I hope that this blog helped you a bit. Yo may leave a comment or try to reach my directly using the steademy plugin and invite me (tmaus@steademy.com) from within the firefox plugin.

Have a nice day

Thorsten

Tags: , ,

Steademy exposes a public API that allows any third party tool to directly connect to steademy.
My first blog outlines the groovy & grails way to login against the steademy platform and to receive a valid sessionKey.

The steademy sessionKey uniquely identifies a user at our platform. You have to deliver it with every consequent request.

We accept simple POST based requests and return JSON strings.

Setup:

You basically need to setup a grails project (grails create-app std), and create your service (grails create-service steademy)
Furthermore the xfire plugin needs to be nstalled into your grails project.
I downloaded release 0.8.1 from here

Adjust config

Getting rid of static properties in our class is our first goal
We therefore add a couple of new lines into grails-conf/Config.groovy
Grails provides a very elegant way to read properties from the config file.

grails-app/conf/Config.groovy std{ msapi{ url = "https://steademy.com login.path="/msapi/Login" } }

SteademyService

Our groovy driven service only needs a couple of code-lines for proper execution.

grails-service/SteademyService.groovy ... class SteademyService implements InitializingBean{ boolean transactional = true def grailsApplication def msapi def crs void afterPropertiesSet(){ msapi = grailsApplication.config.std.msapi crs = grailsApplication.config.std.crs } ... String loginUser(String login, String password){ log.debug "remote login to steademy using [login:${login}] [password:${password}]" def builder = new HTTPBuilder(msapi.url+msapi.login.path) builder.request(POST, JSON){ req -> send URLENC,[login:login, password:password, appId:"12345678", appversion:"1.0"] response.success = {resp,json -> if(json.error){ log.debug "ERROR: ${json.error}" return null } return json.steademy.sessionKey } response.failure = { log.debug "url ${msapi.url}/${msapi.login.path} not valid" return null } } } }

  • The service implements the Initalizing Bean. Thus the method afterPropertiesSet is called once all properties have been initialized by spring.
  • We directly reference the properties set in the grails-app/conf/Config.groovy file by defining the grailsApplication object. Grails/Spring in the backend takes care for its proper binding. The command grailsApplication.config.std.crs finally reads the corresponding property from with the config file.

The actual login method is quite simple. Due to grails perfect support for JSON and thanks to the http-builder project, some simple lines of code connect to the steademy api and process the user login.

SteademyServiceTest

Lets step forward to our test. If you created the service in the grails way, there should exist a groovy class called. test/integration/SteademyServiceTest.

SteademyServicetest ... def steademyService void testSteademyLogin(){ steademyService.loginUser("foo", "bar") }

Thats it basically.
The next blog will outline a couple of more API calls that allow us to send messages through steademy.

Thorsten Maus

Tags: ,

I have started to investigate in Groovy & Grails more by accident than by practical means. A Berlin company was looking for a freelancer with knowhow in G&G that I was not able to deliver.
I consequently used my spare time to dive into G&G for a couple of months.
The upcoming blogs will outline topics that might be interesting for others to follow.
At steademy, we use G&G for chatroom administration and chatroom communication where as the rest of our platform runs on s2ap from springsource.

Thorsten Maus

Tags: , ,

Steademy is live

steademy January 15th, 2009

After months of private beta development, we put our public beta live today.

Steademy integrates messaging into a small toolbar to Firefox browser. If you register and install our Firefox extension for free, you can chat with you friend inside your browser.

Thanks to all involved in development and testing!

Check it out: http://steademy.com

Tags:

maven-par-plugin

OSGI, technology May 29th, 2008

Introduction
The maven-par-plugin was designed to allow developers create s2ap compliant par packages and deploy them to the platform. This plugin might not work for any other purpose.

Usage

A long howto is not required as the purpose of this plugin should be clear. Thus I will concentrate on the configuration and a simple usage pattern.

The infrastructure pom.xml acts as an example of how this plugin is used on our platform.
The initial directory structure looks like:

infrastructure
  | --> hsqldb
  | --> par

par/pom.xml

      

              4.0.0
              infrastructure-par
              ${service.version}
              S2AP Par bundle
par
              So long and thanks for all the fish
              
         
           steademy
           Staademy repository
           http://repo.steademy.com/beta/maven2
         
       

                com.steademy.service.infrastructure
                parent
                SNAPSHOT
              

              
                      
                              com.steademy.service.infrastructure
                              hsqldb
                              ${service.version}
                      
              

              


                    org.apache.maven.plugins
                    maven-par-plugin
                    0.2.0
                    
                       true
                       com.steademy.service.infrastructure
                       1.0.0
                       The db infrastructure
                       Application DB infrastructure
                   
                 
              
             
      

The repository

In order to properly use the maven-par-plugin, you have to pick it up from our repository.
The following repository entry must be added to your pom’s repository entries:

     
          
            steademy
            Steademy repository
            http://repo.steademy.com/beta/maven2
          
       

The packaging must be changed to par.

par

Dependencies
The par/pom.xml simply aggregates all direct dependencies it finds. It does neither care about scopes nor indirect dependencies.

Plugin configuration


        org.apache.maven.plugins
        maven-par-plugin
        0.2.0
        
             true
             com.steademy.service.infrastructure
             1.0.0
             The db infrastructure
             Application DB infrastructure
        
     

Explaining the tags in right order:

1. groupId -> We use the default maven groupId
2. artifactId -> Do I need to tell you about it ???
3. version -> latest “stable” version is 0.2.0

You will use the configuration in order to describe the final .par related META-INF/MANIFEST.MF file.
The tags applicationSymbolicName, applicationVersion, applicationDescription & applicationName have been defined and set mandatory by the springsource guys. Our plugin will pickup your personal settings and create the MANIFEST.MF file accordingly.

The fqn (fully qualified naming) allows to create artifact files using the pattern

${groupId}.${artifactId}

Example:
Our infrastructure par with fqn=true looks echos the following log entries:

[INFO] infrastructure-par
[INFO] artifact hsqldb is copied with fully qualified name com.steademy.service.infrastructure.hsqldb-SNAPSHOT
[INFO] added com.steademy.service.infrastructure.hsqldb-SNAPSHOT.jar
[INFO] [install:install]
[INFO] Installing /home/tmaus/workspaces/beta-01/infrastructure/par/target/infrastructure-par-SNAPSHOT.par to /home/tmaus/.m2/repository/com/steademy/service/infrastructure/infrastructure-par/SNAPSHOT/infrastructure-par-SNAPSHOT.par

The same maven build using fqn=false would produce the following log:

[INFO] infrastructure-par
[INFO] added hsqldb.jar
[INFO] [install:install]
[INFO] Installing /home/tmaus/workspaces/beta-01/infrastructure/par/target/infrastructure-par-SNAPSHOT.par to /home/tmaus/.m2/repository/com/steademy/service/infrastructure/infrastructure-par/SNAPSHOT/infrastructure-par-SNAPSHOT.par

Switching this tag to true increases the readability of the deployed bundles within your s2ap/admin extremely.

So long and thanks for all the fish

t.maus

Tags:

Steademy technology is based on SOA with OSGI and Spring.

Tags: