License exception fix when info is not available

Fellow Hampei,

I’ve fixed an exception in license parse logic which happens when information on AppLicense (that is optional and not always available) makes your gem useless. 

According to the information on RM Unify Dashboard for SSO, the following parameters are optional and not always available on callback page: 

AppLicence  	http://schemas.rm.com/identity/claims/applicence
AppEstablishmentKey  	http://schemas.rm.com/identity/claims/appestablishmentkey
AppUserId  	http://schemas.rm.com/identity/claims/appuserid

As a result of this, Rails raises exception on line 43 of your code:
licence = Hash[licence_str[1..-2].split('|').map{|kv|

This commit fixes it.

If you need more information or full log that contains exception, feel free to drop me a line.

P.S. This code is probably not 100% perfect and I assume that there would be a more elegant solution. I'm relatively new to Ruby On Rails and study it ATM.

Thanks!
Actually licence_str is always defined, but if it's set to null then Ruby will return that it's defined and null? check is true.
I made this test in order to understand what is the value of licence_str in case if the parameter not exists:

CODE:
Rails.logger.debug("Printing license_str: #{licence_str}")
Rails.logger.debug("Printing defined?: #{defined?(licence_str)}")
Rails.logger.debug("Printing licence_str != '': #{(licence_str != '')}")
Rails.logger.debug("Printing .nil? : #{(licence_str.nil?)}")

PRINT in log:
Started GET "/auth/saml_rmunify" for 10.202.0.217 at 2014-11-26 15:10:24 +0200
Created AuthnRequest: <samlp:AuthnRequest AssertionConsumerServiceURL='http://10.202.0.217:3000/auth/saml_rmunify/callback' Destination='http://sts.platform.rmunify.com/issue/saml/?binding=redirect' ID='_82143750-579b-0132-4afd-3c970e6425e1' IssueInstant='2014-11-26T13:10:24Z' Version='2.0' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'><saml:Issuer xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>http://app.petrasplanetforschools.com/rmunify</saml:Issuer></samlp:AuthnRequest>
(saml_rmunify) Callback phase initiated.
Started POST "/auth/saml_rmunify/callback" for 10.202.0.217 at 2014-11-26 15:10:57 +0200
Printing license_str: 
Printing defined?: local-variable
Printing licence_str != '': true
Printing .nil? : true
Licensing information not available

As you can see check for defined return local-variable (defined), check for non empty string returns true, since it set to null, check for nil? return true

Now, the exception happens when you try to invoke method on variable that set to nil.
Here is an exception output:
 NoMethodError
undefined method `[]' for nil:NilClass
Rails.root: /home/igor/projects/test_rm_unify_saml2
Application Trace | Framework Trace | Full Trace
config/initializers/saml-rmunify.rb:42:in `licence'
config/initializers/saml-rmunify.rb:32:in `block in <class:SAMLRMUnify>'
Framework trace:
omniauth (1.2.2) lib/omniauth/strategy.rb:105:in `instance_eval'
omniauth (1.2.2) lib/omniauth/strategy.rb:105:in `block in compile_stack'
omniauth (1.2.2) lib/omniauth/strategy.rb:104:in `each'
omniauth (1.2.2) lib/omniauth/strategy.rb:104:in `inject'
omniauth (1.2.2) lib/omniauth/strategy.rb:104:in `compile_stack'
(eval):7:in `info_stack'
omniauth (1.2.2) lib/omniauth/strategy.rb:321:in `info'
omniauth (1.2.2) lib/omniauth/strategy.rb:334:in `auth_hash'
omniauth (1.2.2) lib/omniauth/strategy.rb:361:in `callback_phase'
omniauth-saml (1.1.0) lib/omniauth/strategies/saml.rb:44:in `callback_phase'
omniauth (1.2.2) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.2.2) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.18) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `_run__863100979617141682__call__2991704010781436499__callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.18) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.18) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.18) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.18) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.18) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.18) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.18) lib/rails/engine.rb:484:in `call'
railties (3.2.18) lib/rails/application.rb:231:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.18) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/home/igor/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/home/igor/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/home/igor/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'

So, if I understand you correctly, you advising to do this:
licence = Hash[licence_str[1..-2].split('|').map{|kv|
-          (k,v) = kv.split(':')
-          [k.underscore, v]
-        }] unless licence_str.nil?

Is it correct?