From codesite-noreply at google.com Wed Jan 2 21:00:50 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 02 Jan 2008 18:00:50 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r621 - trunk/lib/active_ldap/adapter Message-ID: <000e0cd22ee60442c7c36590122e28d5@google.com> Author: koutou Date: Wed Jan 2 18:00:11 2008 New Revision: 621 Modified: trunk/lib/active_ldap/adapter/net_ldap.rb Log: * added missing delete operation support. Modified: trunk/lib/active_ldap/adapter/net_ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/net_ldap.rb (original) +++ trunk/lib/active_ldap/adapter/net_ldap.rb Wed Jan 2 18:00:11 2008 @@ -260,7 +260,7 @@ def ensure_mod_type(type) case type - when :replace, :add + when :replace, :add, :delete type else raise ArgumentError, _("unknown type: %s") % type From codesite-noreply at google.com Wed Jan 2 21:00:50 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 02 Jan 2008 18:00:50 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r621 - trunk/lib/active_ldap/adapter Message-ID: <000e0cd22ee60442c7c36590122e28d5@google.com> Author: koutou Date: Wed Jan 2 18:00:11 2008 New Revision: 621 Modified: trunk/lib/active_ldap/adapter/net_ldap.rb Log: * added missing delete operation support. Modified: trunk/lib/active_ldap/adapter/net_ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/net_ldap.rb (original) +++ trunk/lib/active_ldap/adapter/net_ldap.rb Wed Jan 2 18:00:11 2008 @@ -260,7 +260,7 @@ def ensure_mod_type(type) case type - when :replace, :add + when :replace, :add, :delete type else raise ArgumentError, _("unknown type: %s") % type From codesite-noreply at google.com Mon Jan 7 06:20:45 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 07 Jan 2008 03:20:45 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r622 - trunk/test Message-ID: <000e0cd0ed780443200d20e006abbbf@google.com> Author: koutou Date: Mon Jan 7 03:20:11 2008 New Revision: 622 Modified: trunk/test/test_connection_per_dn.rb Log: * added tests for empty/invalid password rebind. Modified: trunk/test/test_connection_per_dn.rb ============================================================================== --- trunk/test/test_connection_per_dn.rb (original) +++ trunk/test/test_connection_per_dn.rb Mon Jan 7 03:20:11 2008 @@ -4,9 +4,37 @@ include AlTestUtils priority :must + def test_rebind_with_empty_password + make_temporary_user do |user, password| + assert_equal(user.class.connection, user.connection) + assert_nothing_raised do + user.bind(password) + end + assert_not_equal(user.class.connection, user.connection) + + # or ActiveLdap::LdapError::UnwillingToPerform? + assert_raises(ActiveLdap::AuthenticationError) do + user.bind("") + end + end + end priority :normal - def test_establish_connection + def test_rebind_with_invalid_password + make_temporary_user do |user, password| + assert_equal(user.class.connection, user.connection) + assert_nothing_raised do + user.bind(password) + end + assert_not_equal(user.class.connection, user.connection) + + assert_raises(ActiveLdap::AuthenticationError) do + user.bind(password + "-WRONG") + end + end + end + + def test_bind make_temporary_user do |user, password| assert_equal(user.class.connection, user.connection) assert_raises(ActiveLdap::AuthenticationError) do From codesite-noreply at google.com Mon Jan 7 06:20:45 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 07 Jan 2008 03:20:45 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r622 - trunk/test Message-ID: <000e0cd0ed780443200d20e006abbbf@google.com> Author: koutou Date: Mon Jan 7 03:20:11 2008 New Revision: 622 Modified: trunk/test/test_connection_per_dn.rb Log: * added tests for empty/invalid password rebind. Modified: trunk/test/test_connection_per_dn.rb ============================================================================== --- trunk/test/test_connection_per_dn.rb (original) +++ trunk/test/test_connection_per_dn.rb Mon Jan 7 03:20:11 2008 @@ -4,9 +4,37 @@ include AlTestUtils priority :must + def test_rebind_with_empty_password + make_temporary_user do |user, password| + assert_equal(user.class.connection, user.connection) + assert_nothing_raised do + user.bind(password) + end + assert_not_equal(user.class.connection, user.connection) + + # or ActiveLdap::LdapError::UnwillingToPerform? + assert_raises(ActiveLdap::AuthenticationError) do + user.bind("") + end + end + end priority :normal - def test_establish_connection + def test_rebind_with_invalid_password + make_temporary_user do |user, password| + assert_equal(user.class.connection, user.connection) + assert_nothing_raised do + user.bind(password) + end + assert_not_equal(user.class.connection, user.connection) + + assert_raises(ActiveLdap::AuthenticationError) do + user.bind(password + "-WRONG") + end + end + end + + def test_bind make_temporary_user do |user, password| assert_equal(user.class.connection, user.connection) assert_raises(ActiveLdap::AuthenticationError) do From codesite-noreply at google.com Tue Jan 8 07:02:16 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 04:02:16 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r623 - in trunk: . lib/active_ldap lib/active_ldap/adapter test Message-ID: <00163646d90c044334bf7c939ea2c3@google.com> Author: koutou Date: Tue Jan 8 04:01:37 2008 New Revision: 623 Modified: trunk/README trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/base.rb trunk/test/test_connection_per_dn.rb Log: * treated empty password for simple bind as anonymous bind. Suggested by Bodaniel Jeans. Thanks!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Tue Jan 8 04:01:37 2008 @@ -101,3 +101,4 @@ * Perry Smith: Patches, bug reports and indications. * Marc Dequ?nes: API suggestions. * Jeremy Pruitt: A bug report. +* Bodaniel Jeanes: A suggestion for behavior on simple bind with empty password. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 04:01:37 2008 @@ -53,6 +53,7 @@ else allow_anonymous = @allow_anonymous end + options = options.merge(:allow_anonymous => allow_anonymous) # Rough bind loop: # Attempt 1: SASL if available @@ -287,6 +288,16 @@ passwd = password(bind_dn, options) return false unless passwd + + if passwd.empty? + if options[:allow_anonymous] + @logger.info {_("Skip simple bind with empty password")} + return false + else + raise AuthenticationError, + _("Can't use empty password for simple bind") + end + end begin operation(options) do Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Tue Jan 8 04:01:37 2008 @@ -807,11 +807,9 @@ end end - def bind(config_or_password={}, &block) + def bind(config_or_password={}, config_or_ignore=nil, &block) if config_or_password.is_a?(String) - config = {:password => config_or_password} - elsif config_or_password.respond_to?(:call) - config = {:password_block => config_or_password} + config = (config_or_ignore || {}).merge(:password => config_or_password) else config = config_or_password end Modified: trunk/test/test_connection_per_dn.rb ============================================================================== --- trunk/test/test_connection_per_dn.rb (original) +++ trunk/test/test_connection_per_dn.rb Tue Jan 8 04:01:37 2008 @@ -4,18 +4,18 @@ include AlTestUtils priority :must - def test_rebind_with_empty_password + def test_bind_with_empty_password make_temporary_user do |user, password| assert_equal(user.class.connection, user.connection) - assert_nothing_raised do - user.bind(password) - end - assert_not_equal(user.class.connection, user.connection) - - # or ActiveLdap::LdapError::UnwillingToPerform? assert_raises(ActiveLdap::AuthenticationError) do user.bind("") end + assert_equal(user.class.connection, user.connection) + + assert_nothing_raised do + user.bind("", :allow_anonymous => true) + end + assert_not_equal(user.class.connection, user.connection) end end From codesite-noreply at google.com Tue Jan 8 07:02:16 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 04:02:16 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r623 - in trunk: . lib/active_ldap lib/active_ldap/adapter test Message-ID: <00163646d90c044334bf7c939ea2c3@google.com> Author: koutou Date: Tue Jan 8 04:01:37 2008 New Revision: 623 Modified: trunk/README trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/base.rb trunk/test/test_connection_per_dn.rb Log: * treated empty password for simple bind as anonymous bind. Suggested by Bodaniel Jeans. Thanks!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Tue Jan 8 04:01:37 2008 @@ -101,3 +101,4 @@ * Perry Smith: Patches, bug reports and indications. * Marc Dequ?nes: API suggestions. * Jeremy Pruitt: A bug report. +* Bodaniel Jeanes: A suggestion for behavior on simple bind with empty password. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 04:01:37 2008 @@ -53,6 +53,7 @@ else allow_anonymous = @allow_anonymous end + options = options.merge(:allow_anonymous => allow_anonymous) # Rough bind loop: # Attempt 1: SASL if available @@ -287,6 +288,16 @@ passwd = password(bind_dn, options) return false unless passwd + + if passwd.empty? + if options[:allow_anonymous] + @logger.info {_("Skip simple bind with empty password")} + return false + else + raise AuthenticationError, + _("Can't use empty password for simple bind") + end + end begin operation(options) do Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Tue Jan 8 04:01:37 2008 @@ -807,11 +807,9 @@ end end - def bind(config_or_password={}, &block) + def bind(config_or_password={}, config_or_ignore=nil, &block) if config_or_password.is_a?(String) - config = {:password => config_or_password} - elsif config_or_password.respond_to?(:call) - config = {:password_block => config_or_password} + config = (config_or_ignore || {}).merge(:password => config_or_password) else config = config_or_password end Modified: trunk/test/test_connection_per_dn.rb ============================================================================== --- trunk/test/test_connection_per_dn.rb (original) +++ trunk/test/test_connection_per_dn.rb Tue Jan 8 04:01:37 2008 @@ -4,18 +4,18 @@ include AlTestUtils priority :must - def test_rebind_with_empty_password + def test_bind_with_empty_password make_temporary_user do |user, password| assert_equal(user.class.connection, user.connection) - assert_nothing_raised do - user.bind(password) - end - assert_not_equal(user.class.connection, user.connection) - - # or ActiveLdap::LdapError::UnwillingToPerform? assert_raises(ActiveLdap::AuthenticationError) do user.bind("") end + assert_equal(user.class.connection, user.connection) + + assert_nothing_raised do + user.bind("", :allow_anonymous => true) + end + assert_not_equal(user.class.connection, user.connection) end end From codesite-noreply at google.com Tue Jan 8 07:08:17 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 04:08:17 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r624 - in trunk: lib/active_ldap/adapter po/en po/ja Message-ID: <001636458730044334d4f9adcfa62e@google.com> Author: koutou Date: Tue Jan 8 04:07:19 2008 New Revision: 624 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po Log: * updated messages. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 04:07:19 2008 @@ -291,11 +291,11 @@ if passwd.empty? if options[:allow_anonymous] - @logger.info {_("Skip simple bind with empty password")} + @logger.info {_("Skip simple bind with empty password.")} return false else raise AuthenticationError, - _("Can't use empty password for simple bind") + _("Can't use empty password for simple bind.") end end Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Tue Jan 8 04:07:19 2008 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.9.1\n" -"POT-Creation-Date: 2007-12-28 12:28+0900\n" +"POT-Creation-Date: 2008-01-08 21:06+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -3242,15 +3242,15 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "" -#: lib/active_ldap/object_class.rb:51 +#: lib/active_ldap/object_class.rb:52 msgid "Value in objectClass array is not a String: %s" msgstr "" -#: lib/active_ldap/object_class.rb:65 +#: lib/active_ldap/object_class.rb:66 msgid "unknown objectClass in LDAP server: %s" msgstr "" -#: lib/active_ldap/object_class.rb:83 +#: lib/active_ldap/object_class.rb:84 msgid "Can't remove required objectClass: %s" msgstr "" @@ -3281,57 +3281,65 @@ msgid "unsupported qops: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:63 msgid "Bound by SASL as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:65 msgid "Bound by simple as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:66 +#: lib/active_ldap/adapter/base.rb:67 msgid "Bound as anonymous" msgstr "" -#: lib/active_ldap/adapter/base.rb:69 +#: lib/active_ldap/adapter/base.rb:70 msgid "All authentication methods exhausted." msgstr "" -#: lib/active_ldap/adapter/base.rb:136 +#: lib/active_ldap/adapter/base.rb:137 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:154 lib/active_ldap/adapter/base.rb:164 +#: lib/active_ldap/adapter/base.rb:155 lib/active_ldap/adapter/base.rb:165 msgid "No such entry: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:168 lib/active_ldap/adapter/base.rb:170 -#: lib/active_ldap/adapter/base.rb:172 lib/active_ldap/adapter/base.rb:174 -#: lib/active_ldap/adapter/base.rb:186 +#: lib/active_ldap/adapter/base.rb:169 lib/active_ldap/adapter/base.rb:171 +#: lib/active_ldap/adapter/base.rb:173 lib/active_ldap/adapter/base.rb:175 +#: lib/active_ldap/adapter/base.rb:187 msgid "%s: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:234 +#: lib/active_ldap/adapter/base.rb:235 msgid "password_block not nil or Proc object. Ignoring." msgstr "" -#: lib/active_ldap/adapter/base.rb:253 +#: lib/active_ldap/adapter/base.rb:254 msgid "Requested action timed out." msgstr "" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:294 +msgid "Skip simple bind with empty password." +msgstr "" + +#: lib/active_ldap/adapter/base.rb:298 +msgid "Can't use empty password for simple bind." +msgstr "" + +#: lib/active_ldap/adapter/base.rb:474 msgid "invalid logical operator: %s: available operators: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:480 +#: lib/active_ldap/adapter/base.rb:491 msgid "Giving up trying to reconnect to LDAP server." msgstr "" -#: lib/active_ldap/adapter/base.rb:483 +#: lib/active_ldap/adapter/base.rb:494 msgid "Attempting to reconnect" msgstr "" -#: lib/active_ldap/adapter/base.rb:494 +#: lib/active_ldap/adapter/base.rb:505 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" @@ -3600,7 +3608,7 @@ msgid "Can't find DN '%s' to reload" msgstr "" -#: lib/active_ldap/base.rb:1273 +#: lib/active_ldap/base.rb:1271 msgid "dn_attribute isn't set for this class: %s" msgstr "" Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Tue Jan 8 04:07:19 2008 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.9.1\n" -"POT-Creation-Date: 2007-12-28 12:28+0900\n" -"PO-Revision-Date: 2007-12-28 12:29+0900\n" +"POT-Creation-Date: 2008-01-08 21:06+0900\n" +"PO-Revision-Date: 2008-01-08 21:06+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -3253,15 +3253,15 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "$B>ZL@=q0lMw(B(1.3.6.1.4.1.1466.115.121.1.9)" -#: lib/active_ldap/object_class.rb:51 +#: lib/active_ldap/object_class.rb:52 msgid "Value in objectClass array is not a String: %s" msgstr "objectClass$B$NG[Ns$NCf?H$,(BString$B$G$O$"$j$^$;$s(B: %s" -#: lib/active_ldap/object_class.rb:65 +#: lib/active_ldap/object_class.rb:66 msgid "unknown objectClass in LDAP server: %s" msgstr "LDAP$B%5!<%P$,CN$i$J$$(BobjectClass$B$G$9(B: %s" -#: lib/active_ldap/object_class.rb:83 +#: lib/active_ldap/object_class.rb:84 msgid "Can't remove required objectClass: %s" msgstr "$BI,?\$N(BobjectClass$B$O:o=|$G$-$^$;$s(B: %s" @@ -3292,57 +3292,65 @@ msgid "unsupported qops: %s" msgstr "$BBP1~$7$F$$$J$$(Bqops$B$G$9(B: %s" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:63 msgid "Bound by SASL as %s" msgstr "%s$B$H$7$F(BSASL$B$G@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:65 msgid "Bound by simple as %s" msgstr "%s$B$H$7$F%7%s%W%kG'>Z$G@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:66 +#: lib/active_ldap/adapter/base.rb:67 msgid "Bound as anonymous" msgstr "$BF?L>%f!<%6$H$7$F@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:69 +#: lib/active_ldap/adapter/base.rb:70 msgid "All authentication methods exhausted." msgstr "$B$9$Y$F$NG'>ZJ}K!$r;H$$$-$j$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:136 +#: lib/active_ldap/adapter/base.rb:137 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "$B%(%i!<(B%s(%s)$B$rL5;k$7$^$9(B: $B%U%#%k%?(B %s: $BB0 at -(B: %s" -#: lib/active_ldap/adapter/base.rb:154 lib/active_ldap/adapter/base.rb:164 +#: lib/active_ldap/adapter/base.rb:155 lib/active_ldap/adapter/base.rb:165 msgid "No such entry: %s" msgstr "$B$=$N$h$&$J%(%s%H%j$O$"$j$^$;$s(B: %s" -#: lib/active_ldap/adapter/base.rb:168 lib/active_ldap/adapter/base.rb:170 -#: lib/active_ldap/adapter/base.rb:172 lib/active_ldap/adapter/base.rb:174 -#: lib/active_ldap/adapter/base.rb:186 +#: lib/active_ldap/adapter/base.rb:169 lib/active_ldap/adapter/base.rb:171 +#: lib/active_ldap/adapter/base.rb:173 lib/active_ldap/adapter/base.rb:175 +#: lib/active_ldap/adapter/base.rb:187 msgid "%s: %s" msgstr "%s: %s" -#: lib/active_ldap/adapter/base.rb:234 +#: lib/active_ldap/adapter/base.rb:235 msgid "password_block not nil or Proc object. Ignoring." msgstr "password_block$B$,(Bnil$B$G$b(BProc$B$G$b$"$j$^$;$s!#L5;k$7(B $B$^$9!#(B" -#: lib/active_ldap/adapter/base.rb:253 +#: lib/active_ldap/adapter/base.rb:254 msgid "Requested action timed out." msgstr "$BMW5a$7$?%"%/%7%g%s$,%?%$%`%"%&%H$7$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:294 +msgid "Skip simple bind with empty password." +msgstr "$B6u%Q%9%o!<%I$G$N%7%s%W%kG'>Z$r9T$$$^$;$s$G(B $B$7$?!#(B" + +#: lib/active_ldap/adapter/base.rb:298 +msgid "Can't use empty password for simple bind." +msgstr "$B%7%s%W%kG'>Z$G$O6u$N%Q%9%o!<%I$r;H$&$3$H$O(B $B$G$-$^$;$s!#(B" + +#: lib/active_ldap/adapter/base.rb:474 msgid "invalid logical operator: %s: available operators: %s" msgstr "$BIT at 5$JO at M}1i;;;R$G$9(B: %s: $BM-8z$J1i;;;R(B: %s\n" -#: lib/active_ldap/adapter/base.rb:480 +#: lib/active_ldap/adapter/base.rb:491 msgid "Giving up trying to reconnect to LDAP server." msgstr "LDAP$B%5!<%P$X$N:F@\B3$rD|$a$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:483 +#: lib/active_ldap/adapter/base.rb:494 msgid "Attempting to reconnect" msgstr "$B:F@\B3$r;n$_$F$$$^$9(B" -#: lib/active_ldap/adapter/base.rb:494 +#: lib/active_ldap/adapter/base.rb:505 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" @@ -3593,7 +3601,9 @@ msgid "" "'%s' must be either nil, DN value as ActiveLdap::DN, String or Array or " "attributes as Hash" -msgstr "'%s'$B$O(Bnil$B!"(BActiveLdap::DN$B$"$k$$$O(BString$B$K$h$k(BDN$B!"(B DN$B$NG[Ns!"(BHash$B$K$h$kB0 at -$N$I$l$+$G$J$1$l$P$$$1$^$;$s(B" +msgstr "" +"'%s'$B$O(Bnil$B!"(BActiveLdap::DN$B$"$k$$$O(BString$B$K$h$k(BDN$B!"(BDN$B$NG[(B $BNs!"(BHash$B$K$h$kB0 at -$N$I(B" +"$B$l$+$G$J$1$l$P$$$1$^$;$s(B" #: lib/active_ldap/base.rb:576 msgid "%s's DN attribute (%s) isn't set" @@ -3615,7 +3625,7 @@ msgid "Can't find DN '%s' to reload" msgstr "$B:FFI$_9~$_$9$k(BDN '%s'$B$,8+$D$+$j$^$;$s(B" -#: lib/active_ldap/base.rb:1273 +#: lib/active_ldap/base.rb:1271 msgid "dn_attribute isn't set for this class: %s" msgstr "$B$3$N%/%i%9$N(Bdn_attribute$B$, at _Dj$5$l$F$$$^$;$s(B: %s" From codesite-noreply at google.com Tue Jan 8 07:08:17 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 04:08:17 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r624 - in trunk: lib/active_ldap/adapter po/en po/ja Message-ID: <001636458730044334d4f9adcfa62e@google.com> Author: koutou Date: Tue Jan 8 04:07:19 2008 New Revision: 624 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/po/en/active-ldap.po trunk/po/ja/active-ldap.po Log: * updated messages. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 04:07:19 2008 @@ -291,11 +291,11 @@ if passwd.empty? if options[:allow_anonymous] - @logger.info {_("Skip simple bind with empty password")} + @logger.info {_("Skip simple bind with empty password.")} return false else raise AuthenticationError, - _("Can't use empty password for simple bind") + _("Can't use empty password for simple bind.") end end Modified: trunk/po/en/active-ldap.po ============================================================================== --- trunk/po/en/active-ldap.po (original) +++ trunk/po/en/active-ldap.po Tue Jan 8 04:07:19 2008 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.9.1\n" -"POT-Creation-Date: 2007-12-28 12:28+0900\n" +"POT-Creation-Date: 2008-01-08 21:06+0900\n" "PO-Revision-Date: 2007-08-19 09:49+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: English\n" @@ -3242,15 +3242,15 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "" -#: lib/active_ldap/object_class.rb:51 +#: lib/active_ldap/object_class.rb:52 msgid "Value in objectClass array is not a String: %s" msgstr "" -#: lib/active_ldap/object_class.rb:65 +#: lib/active_ldap/object_class.rb:66 msgid "unknown objectClass in LDAP server: %s" msgstr "" -#: lib/active_ldap/object_class.rb:83 +#: lib/active_ldap/object_class.rb:84 msgid "Can't remove required objectClass: %s" msgstr "" @@ -3281,57 +3281,65 @@ msgid "unsupported qops: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:63 msgid "Bound by SASL as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:65 msgid "Bound by simple as %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:66 +#: lib/active_ldap/adapter/base.rb:67 msgid "Bound as anonymous" msgstr "" -#: lib/active_ldap/adapter/base.rb:69 +#: lib/active_ldap/adapter/base.rb:70 msgid "All authentication methods exhausted." msgstr "" -#: lib/active_ldap/adapter/base.rb:136 +#: lib/active_ldap/adapter/base.rb:137 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:154 lib/active_ldap/adapter/base.rb:164 +#: lib/active_ldap/adapter/base.rb:155 lib/active_ldap/adapter/base.rb:165 msgid "No such entry: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:168 lib/active_ldap/adapter/base.rb:170 -#: lib/active_ldap/adapter/base.rb:172 lib/active_ldap/adapter/base.rb:174 -#: lib/active_ldap/adapter/base.rb:186 +#: lib/active_ldap/adapter/base.rb:169 lib/active_ldap/adapter/base.rb:171 +#: lib/active_ldap/adapter/base.rb:173 lib/active_ldap/adapter/base.rb:175 +#: lib/active_ldap/adapter/base.rb:187 msgid "%s: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:234 +#: lib/active_ldap/adapter/base.rb:235 msgid "password_block not nil or Proc object. Ignoring." msgstr "" -#: lib/active_ldap/adapter/base.rb:253 +#: lib/active_ldap/adapter/base.rb:254 msgid "Requested action timed out." msgstr "" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:294 +msgid "Skip simple bind with empty password." +msgstr "" + +#: lib/active_ldap/adapter/base.rb:298 +msgid "Can't use empty password for simple bind." +msgstr "" + +#: lib/active_ldap/adapter/base.rb:474 msgid "invalid logical operator: %s: available operators: %s" msgstr "" -#: lib/active_ldap/adapter/base.rb:480 +#: lib/active_ldap/adapter/base.rb:491 msgid "Giving up trying to reconnect to LDAP server." msgstr "" -#: lib/active_ldap/adapter/base.rb:483 +#: lib/active_ldap/adapter/base.rb:494 msgid "Attempting to reconnect" msgstr "" -#: lib/active_ldap/adapter/base.rb:494 +#: lib/active_ldap/adapter/base.rb:505 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" @@ -3600,7 +3608,7 @@ msgid "Can't find DN '%s' to reload" msgstr "" -#: lib/active_ldap/base.rb:1273 +#: lib/active_ldap/base.rb:1271 msgid "dn_attribute isn't set for this class: %s" msgstr "" Modified: trunk/po/ja/active-ldap.po ============================================================================== --- trunk/po/ja/active-ldap.po (original) +++ trunk/po/ja/active-ldap.po Tue Jan 8 04:07:19 2008 @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Ruby/ActiveLdap 0.9.1\n" -"POT-Creation-Date: 2007-12-28 12:28+0900\n" -"PO-Revision-Date: 2007-12-28 12:29+0900\n" +"POT-Creation-Date: 2008-01-08 21:06+0900\n" +"PO-Revision-Date: 2008-01-08 21:06+0900\n" "Last-Translator: Kouhei Sutou \n" "Language-Team: Japanese\n" "MIME-Version: 1.0\n" @@ -3253,15 +3253,15 @@ msgid "LDAP|Syntax|1.3.6.1.4.1.1466.115.121.1.9" msgstr "$B>ZL@=q0lMw(B(1.3.6.1.4.1.1466.115.121.1.9)" -#: lib/active_ldap/object_class.rb:51 +#: lib/active_ldap/object_class.rb:52 msgid "Value in objectClass array is not a String: %s" msgstr "objectClass$B$NG[Ns$NCf?H$,(BString$B$G$O$"$j$^$;$s(B: %s" -#: lib/active_ldap/object_class.rb:65 +#: lib/active_ldap/object_class.rb:66 msgid "unknown objectClass in LDAP server: %s" msgstr "LDAP$B%5!<%P$,CN$i$J$$(BobjectClass$B$G$9(B: %s" -#: lib/active_ldap/object_class.rb:83 +#: lib/active_ldap/object_class.rb:84 msgid "Can't remove required objectClass: %s" msgstr "$BI,?\$N(BobjectClass$B$O:o=|$G$-$^$;$s(B: %s" @@ -3292,57 +3292,65 @@ msgid "unsupported qops: %s" msgstr "$BBP1~$7$F$$$J$$(Bqops$B$G$9(B: %s" -#: lib/active_ldap/adapter/base.rb:62 +#: lib/active_ldap/adapter/base.rb:63 msgid "Bound by SASL as %s" msgstr "%s$B$H$7$F(BSASL$B$G@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:64 +#: lib/active_ldap/adapter/base.rb:65 msgid "Bound by simple as %s" msgstr "%s$B$H$7$F%7%s%W%kG'>Z$G@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:66 +#: lib/active_ldap/adapter/base.rb:67 msgid "Bound as anonymous" msgstr "$BF?L>%f!<%6$H$7$F@\B3$7$^$7$?(B" -#: lib/active_ldap/adapter/base.rb:69 +#: lib/active_ldap/adapter/base.rb:70 msgid "All authentication methods exhausted." msgstr "$B$9$Y$F$NG'>ZJ}K!$r;H$$$-$j$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:136 +#: lib/active_ldap/adapter/base.rb:137 msgid "Ignore error %s(%s): filter %s: attributes: %s" msgstr "$B%(%i!<(B%s(%s)$B$rL5;k$7$^$9(B: $B%U%#%k%?(B %s: $BB0 at -(B: %s" -#: lib/active_ldap/adapter/base.rb:154 lib/active_ldap/adapter/base.rb:164 +#: lib/active_ldap/adapter/base.rb:155 lib/active_ldap/adapter/base.rb:165 msgid "No such entry: %s" msgstr "$B$=$N$h$&$J%(%s%H%j$O$"$j$^$;$s(B: %s" -#: lib/active_ldap/adapter/base.rb:168 lib/active_ldap/adapter/base.rb:170 -#: lib/active_ldap/adapter/base.rb:172 lib/active_ldap/adapter/base.rb:174 -#: lib/active_ldap/adapter/base.rb:186 +#: lib/active_ldap/adapter/base.rb:169 lib/active_ldap/adapter/base.rb:171 +#: lib/active_ldap/adapter/base.rb:173 lib/active_ldap/adapter/base.rb:175 +#: lib/active_ldap/adapter/base.rb:187 msgid "%s: %s" msgstr "%s: %s" -#: lib/active_ldap/adapter/base.rb:234 +#: lib/active_ldap/adapter/base.rb:235 msgid "password_block not nil or Proc object. Ignoring." msgstr "password_block$B$,(Bnil$B$G$b(BProc$B$G$b$"$j$^$;$s!#L5;k$7(B $B$^$9!#(B" -#: lib/active_ldap/adapter/base.rb:253 +#: lib/active_ldap/adapter/base.rb:254 msgid "Requested action timed out." msgstr "$BMW5a$7$?%"%/%7%g%s$,%?%$%`%"%&%H$7$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:463 +#: lib/active_ldap/adapter/base.rb:294 +msgid "Skip simple bind with empty password." +msgstr "$B6u%Q%9%o!<%I$G$N%7%s%W%kG'>Z$r9T$$$^$;$s$G(B $B$7$?!#(B" + +#: lib/active_ldap/adapter/base.rb:298 +msgid "Can't use empty password for simple bind." +msgstr "$B%7%s%W%kG'>Z$G$O6u$N%Q%9%o!<%I$r;H$&$3$H$O(B $B$G$-$^$;$s!#(B" + +#: lib/active_ldap/adapter/base.rb:474 msgid "invalid logical operator: %s: available operators: %s" msgstr "$BIT at 5$JO at M}1i;;;R$G$9(B: %s: $BM-8z$J1i;;;R(B: %s\n" -#: lib/active_ldap/adapter/base.rb:480 +#: lib/active_ldap/adapter/base.rb:491 msgid "Giving up trying to reconnect to LDAP server." msgstr "LDAP$B%5!<%P$X$N:F@\B3$rD|$a$^$7$?!#(B" -#: lib/active_ldap/adapter/base.rb:483 +#: lib/active_ldap/adapter/base.rb:494 msgid "Attempting to reconnect" msgstr "$B:F@\B3$r;n$_$F$$$^$9(B" -#: lib/active_ldap/adapter/base.rb:494 +#: lib/active_ldap/adapter/base.rb:505 msgid "" "Reconnect to server failed: %s\n" "Reconnect to server failed backtrace:\n" @@ -3593,7 +3601,9 @@ msgid "" "'%s' must be either nil, DN value as ActiveLdap::DN, String or Array or " "attributes as Hash" -msgstr "'%s'$B$O(Bnil$B!"(BActiveLdap::DN$B$"$k$$$O(BString$B$K$h$k(BDN$B!"(B DN$B$NG[Ns!"(BHash$B$K$h$kB0 at -$N$I$l$+$G$J$1$l$P$$$1$^$;$s(B" +msgstr "" +"'%s'$B$O(Bnil$B!"(BActiveLdap::DN$B$"$k$$$O(BString$B$K$h$k(BDN$B!"(BDN$B$NG[(B $BNs!"(BHash$B$K$h$kB0 at -$N$I(B" +"$B$l$+$G$J$1$l$P$$$1$^$;$s(B" #: lib/active_ldap/base.rb:576 msgid "%s's DN attribute (%s) isn't set" @@ -3615,7 +3625,7 @@ msgid "Can't find DN '%s' to reload" msgstr "$B:FFI$_9~$_$9$k(BDN '%s'$B$,8+$D$+$j$^$;$s(B" -#: lib/active_ldap/base.rb:1273 +#: lib/active_ldap/base.rb:1271 msgid "dn_attribute isn't set for this class: %s" msgstr "$B$3$N%/%i%9$N(Bdn_attribute$B$, at _Dj$5$l$F$$$^$;$s(B: %s" From codesite-noreply at google.com Tue Jan 8 20:14:35 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 17:14:35 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r625 - trunk/lib/active_ldap Message-ID: <00163646c7b604433fd104d8624caee7@google.com> Author: koutou Date: Tue Jan 8 17:14:20 2008 New Revision: 625 Modified: trunk/lib/active_ldap/connection.rb Log: * used JNDI backend as default for JRuby. Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Tue Jan 8 17:14:20 2008 @@ -88,7 +88,7 @@ end def instantiate_adapter(config) - adapter = (config[:adapter] || "ldap") + adapter = (config[:adapter] || default_adapter) normalized_adapter = adapter.downcase.gsub(/-/, "_") adapter_method = "#{normalized_adapter}_connection" unless Adapter::Base.respond_to?(adapter_method) @@ -104,6 +104,10 @@ Adapter::Base.send(adapter_method, config) end + def default_adapter + @@default_adapter ||= guess_available_adapter + end + def connected? active_connections[active_connection_name] ? true : false end @@ -178,6 +182,10 @@ @@active_connections.each_value {|conn| conn.disconnect!} end @@active_connections.clear + end + + def guess_available_adapter + defined?(java) ? "jndi" : "ldap" end end From codesite-noreply at google.com Tue Jan 8 20:14:35 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 17:14:35 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r625 - trunk/lib/active_ldap Message-ID: <00163646c7b604433fd104d8624caee7@google.com> Author: koutou Date: Tue Jan 8 17:14:20 2008 New Revision: 625 Modified: trunk/lib/active_ldap/connection.rb Log: * used JNDI backend as default for JRuby. Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Tue Jan 8 17:14:20 2008 @@ -88,7 +88,7 @@ end def instantiate_adapter(config) - adapter = (config[:adapter] || "ldap") + adapter = (config[:adapter] || default_adapter) normalized_adapter = adapter.downcase.gsub(/-/, "_") adapter_method = "#{normalized_adapter}_connection" unless Adapter::Base.respond_to?(adapter_method) @@ -104,6 +104,10 @@ Adapter::Base.send(adapter_method, config) end + def default_adapter + @@default_adapter ||= guess_available_adapter + end + def connected? active_connections[active_connection_name] ? true : false end @@ -178,6 +182,10 @@ @@active_connections.each_value {|conn| conn.disconnect!} end @@active_connections.clear + end + + def guess_available_adapter + defined?(java) ? "jndi" : "ldap" end end From codesite-noreply at google.com Wed Jan 9 00:10:10 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 21:10:10 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r626 - in trunk: . lib/active_ldap test Message-ID: <001636e0a7b80443431b89600c13b0c5@google.com> Author: koutou Date: Tue Jan 8 21:09:23 2008 New Revision: 626 Modified: trunk/README trunk/lib/active_ldap/operations.rb trunk/test/test_base.rb trunk/test/test_find.rb Log: * ensured adding "objectClass" for find's :attributes value. [#16946] Thanks to Nobody!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Tue Jan 8 21:09:23 2008 @@ -84,7 +84,7 @@ This list may not be correct. If you notice mistakes of this list, please point out. -* Nobody: Bug reports. +* Nobody: Bug reports and API improveent ideas. * James Hughes: Bug reports and advices and documentations. * Buzz Chopra: Documentations. * Christoph Lipp: Bug reports. Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Tue Jan 8 21:09:23 2008 @@ -205,6 +205,7 @@ sort_by = options.delete(:sort_by) || sort_by order = options.delete(:order) || order limit = options.delete(:limit) if sort_by or order + options[:attributes] |= ["objectClass"] if options[:attributes] results = search(options).collect do |dn, attrs| instantiate([dn, attrs, {:connection => options[:connection]}]) Modified: trunk/test/test_base.rb ============================================================================== --- trunk/test/test_base.rb (original) +++ trunk/test/test_base.rb Tue Jan 8 21:09:23 2008 @@ -4,6 +4,8 @@ include AlTestUtils priority :must + + priority :normal def test_new_with_dn cn = "XXX" dn = "cn=#{cn},#{@user_class.base}" @@ -12,7 +14,6 @@ assert_equal(dn, user.dn) end - priority :normal def test_dn_attribute_per_instance_with_invalid_value user = @user_class.new assert_equal("uid", user.dn_attribute) @@ -139,6 +140,15 @@ ou_class.required_classes += ["organization"] assert_equal([], ou_class.search(:value => name).collect {|dn, attrs| dn}) + end + + def test_search_with_attributes_without_object_class + make_temporary_user do |user, password| + entries = @user_class.search(:filter => "#{user.dn_attribute}=#{user.id}", + :attributes => ["uidNumber"]) + assert_equal([[user.dn, {"uidNumber" => [user.uid_number.to_s]}]], + entries) + end end def test_new_without_argument Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Tue Jan 8 21:09:23 2008 @@ -4,6 +4,18 @@ include AlTestUtils priority :must + + priority :normal + def test_find_with_attributes_without_object_class + make_temporary_user do |user, password| + found_user = @user_class.find(user.uid, + :attributes => ["uidNumber"]) + assert_equal(user.uid_number, found_user.uid_number) + assert_equal(user.classes, found_user.classes) + assert_nil(found_user.gid_number) + end + end + def test_find_with_integer_value make_temporary_user do |user, password| found_user = @user_class.find(:attribute => "gidNumber", @@ -12,7 +24,6 @@ end end - priority :normal def test_find_with_limit make_temporary_user(:uid => "user1") do |user1,| make_temporary_user(:uid => "user2") do |user2,| From codesite-noreply at google.com Wed Jan 9 00:10:10 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 21:10:10 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r626 - in trunk: . lib/active_ldap test Message-ID: <001636e0a7b80443431b89600c13b0c5@google.com> Author: koutou Date: Tue Jan 8 21:09:23 2008 New Revision: 626 Modified: trunk/README trunk/lib/active_ldap/operations.rb trunk/test/test_base.rb trunk/test/test_find.rb Log: * ensured adding "objectClass" for find's :attributes value. [#16946] Thanks to Nobody!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Tue Jan 8 21:09:23 2008 @@ -84,7 +84,7 @@ This list may not be correct. If you notice mistakes of this list, please point out. -* Nobody: Bug reports. +* Nobody: Bug reports and API improveent ideas. * James Hughes: Bug reports and advices and documentations. * Buzz Chopra: Documentations. * Christoph Lipp: Bug reports. Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Tue Jan 8 21:09:23 2008 @@ -205,6 +205,7 @@ sort_by = options.delete(:sort_by) || sort_by order = options.delete(:order) || order limit = options.delete(:limit) if sort_by or order + options[:attributes] |= ["objectClass"] if options[:attributes] results = search(options).collect do |dn, attrs| instantiate([dn, attrs, {:connection => options[:connection]}]) Modified: trunk/test/test_base.rb ============================================================================== --- trunk/test/test_base.rb (original) +++ trunk/test/test_base.rb Tue Jan 8 21:09:23 2008 @@ -4,6 +4,8 @@ include AlTestUtils priority :must + + priority :normal def test_new_with_dn cn = "XXX" dn = "cn=#{cn},#{@user_class.base}" @@ -12,7 +14,6 @@ assert_equal(dn, user.dn) end - priority :normal def test_dn_attribute_per_instance_with_invalid_value user = @user_class.new assert_equal("uid", user.dn_attribute) @@ -139,6 +140,15 @@ ou_class.required_classes += ["organization"] assert_equal([], ou_class.search(:value => name).collect {|dn, attrs| dn}) + end + + def test_search_with_attributes_without_object_class + make_temporary_user do |user, password| + entries = @user_class.search(:filter => "#{user.dn_attribute}=#{user.id}", + :attributes => ["uidNumber"]) + assert_equal([[user.dn, {"uidNumber" => [user.uid_number.to_s]}]], + entries) + end end def test_new_without_argument Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Tue Jan 8 21:09:23 2008 @@ -4,6 +4,18 @@ include AlTestUtils priority :must + + priority :normal + def test_find_with_attributes_without_object_class + make_temporary_user do |user, password| + found_user = @user_class.find(user.uid, + :attributes => ["uidNumber"]) + assert_equal(user.uid_number, found_user.uid_number) + assert_equal(user.classes, found_user.classes) + assert_nil(found_user.gid_number) + end + end + def test_find_with_integer_value make_temporary_user do |user, password| found_user = @user_class.find(:attribute => "gidNumber", @@ -12,7 +24,6 @@ end end - priority :normal def test_find_with_limit make_temporary_user(:uid => "user1") do |user1,| make_temporary_user(:uid => "user2") do |user2,| From codesite-noreply at google.com Wed Jan 9 01:12:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:12:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r627 - trunk/lib/active_ldap/adapter Message-ID: <00163646c82e044343fa41698337237@google.com> Author: koutou Date: Tue Jan 8 22:11:29 2008 New Revision: 627 Modified: trunk/lib/active_ldap/adapter/base.rb Log: * passed options to reconnect_if_need. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 22:11:29 2008 @@ -200,8 +200,9 @@ def operation(options) retried = false + options = options.dup begin - reconnect_if_need + reconnect_if_need(options) try_reconnect = !options.has_key?(:try_reconnect) || options[:try_reconnect] with_timeout(try_reconnect, options) do From codesite-noreply at google.com Wed Jan 9 01:12:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:12:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r627 - trunk/lib/active_ldap/adapter Message-ID: <00163646c82e044343fa41698337237@google.com> Author: koutou Date: Tue Jan 8 22:11:29 2008 New Revision: 627 Modified: trunk/lib/active_ldap/adapter/base.rb Log: * passed options to reconnect_if_need. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Tue Jan 8 22:11:29 2008 @@ -200,8 +200,9 @@ def operation(options) retried = false + options = options.dup begin - reconnect_if_need + reconnect_if_need(options) try_reconnect = !options.has_key?(:try_reconnect) || options[:try_reconnect] with_timeout(try_reconnect, options) do From codesite-noreply at google.com Wed Jan 9 01:16:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:16:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r628 - trunk/lib/active_ldap/adapter Message-ID: <00163646d8f20443440890e5394ca54f@google.com> Author: koutou Date: Tue Jan 8 22:11:55 2008 New Revision: 628 Modified: trunk/lib/active_ldap/adapter/jndi.rb Log: * removed needless comment. Modified: trunk/lib/active_ldap/adapter/jndi.rb ============================================================================== --- trunk/lib/active_ldap/adapter/jndi.rb (original) +++ trunk/lib/active_ldap/adapter/jndi.rb Tue Jan 8 22:11:55 2008 @@ -72,16 +72,6 @@ end private -# def with_timeout(try_reconnect=true, options={}, &block) -# begin -# super -# rescue LDAP::ServerDown => e -# @logger.error {_("LDAP server is down: %s") % e.message} -# retry if try_reconnect and reconnect(options) -# raise ConnectionError.new(e.message) -# end -# end - def execute(method, *args, &block) @connection.send(method, *args, &block) rescue JndiConnection::NamingException From codesite-noreply at google.com Wed Jan 9 01:16:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:16:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r628 - trunk/lib/active_ldap/adapter Message-ID: <00163646d8f20443440890e5394ca54f@google.com> Author: koutou Date: Tue Jan 8 22:11:55 2008 New Revision: 628 Modified: trunk/lib/active_ldap/adapter/jndi.rb Log: * removed needless comment. Modified: trunk/lib/active_ldap/adapter/jndi.rb ============================================================================== --- trunk/lib/active_ldap/adapter/jndi.rb (original) +++ trunk/lib/active_ldap/adapter/jndi.rb Tue Jan 8 22:11:55 2008 @@ -72,16 +72,6 @@ end private -# def with_timeout(try_reconnect=true, options={}, &block) -# begin -# super -# rescue LDAP::ServerDown => e -# @logger.error {_("LDAP server is down: %s") % e.message} -# retry if try_reconnect and reconnect(options) -# raise ConnectionError.new(e.message) -# end -# end - def execute(method, *args, &block) @connection.send(method, *args, &block) rescue JndiConnection::NamingException From codesite-noreply at google.com Wed Jan 9 01:20:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:20:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r629 - trunk/lib/active_ldap/adapter Message-ID: <00163641797504434416e6e5a1fc31c@google.com> Author: koutou Date: Tue Jan 8 22:12:14 2008 New Revision: 629 Modified: trunk/lib/active_ldap/adapter/ldap.rb Log: * removed needless implementation. Modified: trunk/lib/active_ldap/adapter/ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap.rb (original) +++ trunk/lib/active_ldap/adapter/ldap.rb Tue Jan 8 22:12:14 2008 @@ -151,16 +151,6 @@ end end - def with_timeout(try_reconnect=true, options={}, &block) - begin - super - rescue LDAP::ServerDown => e - @logger.error {_("LDAP server is down: %s") % e.message} - retry if try_reconnect and reconnect(options) - raise ConnectionError.new(e.message) - end - end - def ensure_method(method) Method.constants.each do |name| if method.to_s.downcase == name.downcase From codesite-noreply at google.com Wed Jan 9 01:20:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:20:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r629 - trunk/lib/active_ldap/adapter Message-ID: <00163641797504434416e6e5a1fc31c@google.com> Author: koutou Date: Tue Jan 8 22:12:14 2008 New Revision: 629 Modified: trunk/lib/active_ldap/adapter/ldap.rb Log: * removed needless implementation. Modified: trunk/lib/active_ldap/adapter/ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap.rb (original) +++ trunk/lib/active_ldap/adapter/ldap.rb Tue Jan 8 22:12:14 2008 @@ -151,16 +151,6 @@ end end - def with_timeout(try_reconnect=true, options={}, &block) - begin - super - rescue LDAP::ServerDown => e - @logger.error {_("LDAP server is down: %s") % e.message} - retry if try_reconnect and reconnect(options) - raise ConnectionError.new(e.message) - end - end - def ensure_method(method) Method.constants.each do |name| if method.to_s.downcase == name.downcase From codesite-noreply at google.com Wed Jan 9 01:24:28 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:24:28 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r630 - trunk/lib/active_ldap/adapter Message-ID: <00163646d8f204434425387c4e4cc8e6@google.com> Author: koutou Date: Tue Jan 8 22:12:33 2008 New Revision: 630 Modified: trunk/lib/active_ldap/adapter/jndi_connection.rb Log: * supported StartTLS. Modified: trunk/lib/active_ldap/adapter/jndi_connection.rb ============================================================================== --- trunk/lib/active_ldap/adapter/jndi_connection.rb (original) +++ trunk/lib/active_ldap/adapter/jndi_connection.rb Tue Jan 8 22:12:33 2008 @@ -14,19 +14,25 @@ module Adapter class JndiConnection HashTable = java.util.Hashtable - InitialDirContext = javax.naming.directory.InitialDirContext - SearchControls = javax.naming.directory.SearchControls - ModificationItem = javax.naming.directory.ModificationItem - BasicAttributes = javax.naming.directory.BasicAttributes - Context = javax.naming.Context - StartTlsRequest = javax.naming.ldap.StartTlsRequest + naming = javax.naming + directory = naming.directory + ldap = naming.ldap + InitialDirContext = directory.InitialDirContext + InitialLdapContext = ldap.InitialLdapContext + SearchControls = directory.SearchControls + ModificationItem = directory.ModificationItem + BasicAttributes = directory.BasicAttributes + Context = naming.Context + StartTlsRequest = ldap.StartTlsRequest + Control = ldap.Control - NamingException = javax.naming.NamingException - NameNotFoundException = javax.naming.NameNotFoundException + NamingException = naming.NamingException + NameNotFoundException = naming.NameNotFoundException class ModifyRecord - DirContext = javax.naming.directory.DirContext - BasicAttribute = javax.naming.directory.BasicAttribute + directory = javax.naming.directory + DirContext = directory.DirContext + BasicAttribute = directory.BasicAttribute ADD_ATTRIBUTE = DirContext::ADD_ATTRIBUTE REPLACE_ATTRIBUTE = DirContext::REPLACE_ATTRIBUTE @@ -149,7 +155,7 @@ Context::PROVIDER_URL => ldap_uri, } environment = HashTable.new(environment) - context = InitialDirContext.new(environment) + context = InitialLdapContext.new(environment, nil) if @method == :start_tls @tls = context.extended_operation(StartTlsRequest.new) @tls.negotiate From codesite-noreply at google.com Wed Jan 9 01:24:28 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 08 Jan 2008 22:24:28 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r630 - trunk/lib/active_ldap/adapter Message-ID: <00163646d8f204434425387c4e4cc8e6@google.com> Author: koutou Date: Tue Jan 8 22:12:33 2008 New Revision: 630 Modified: trunk/lib/active_ldap/adapter/jndi_connection.rb Log: * supported StartTLS. Modified: trunk/lib/active_ldap/adapter/jndi_connection.rb ============================================================================== --- trunk/lib/active_ldap/adapter/jndi_connection.rb (original) +++ trunk/lib/active_ldap/adapter/jndi_connection.rb Tue Jan 8 22:12:33 2008 @@ -14,19 +14,25 @@ module Adapter class JndiConnection HashTable = java.util.Hashtable - InitialDirContext = javax.naming.directory.InitialDirContext - SearchControls = javax.naming.directory.SearchControls - ModificationItem = javax.naming.directory.ModificationItem - BasicAttributes = javax.naming.directory.BasicAttributes - Context = javax.naming.Context - StartTlsRequest = javax.naming.ldap.StartTlsRequest + naming = javax.naming + directory = naming.directory + ldap = naming.ldap + InitialDirContext = directory.InitialDirContext + InitialLdapContext = ldap.InitialLdapContext + SearchControls = directory.SearchControls + ModificationItem = directory.ModificationItem + BasicAttributes = directory.BasicAttributes + Context = naming.Context + StartTlsRequest = ldap.StartTlsRequest + Control = ldap.Control - NamingException = javax.naming.NamingException - NameNotFoundException = javax.naming.NameNotFoundException + NamingException = naming.NamingException + NameNotFoundException = naming.NameNotFoundException class ModifyRecord - DirContext = javax.naming.directory.DirContext - BasicAttribute = javax.naming.directory.BasicAttribute + directory = javax.naming.directory + DirContext = directory.DirContext + BasicAttribute = directory.BasicAttribute ADD_ATTRIBUTE = DirContext::ADD_ATTRIBUTE REPLACE_ATTRIBUTE = DirContext::REPLACE_ATTRIBUTE @@ -149,7 +155,7 @@ Context::PROVIDER_URL => ldap_uri, } environment = HashTable.new(environment) - context = InitialDirContext.new(environment) + context = InitialLdapContext.new(environment, nil) if @method == :start_tls @tls = context.extended_operation(StartTlsRequest.new) @tls.negotiate From codesite-noreply at google.com Wed Jan 9 20:52:37 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 17:52:37 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r632 - trunk/examples/al-admin/config/initializers Message-ID: <001485f9a4ae04435476d9d6f82a7b@google.com> Author: koutou Date: Wed Jan 9 17:51:41 2008 New Revision: 632 Added: trunk/examples/al-admin/config/initializers/ralative_url_support.rb Log: * added a missing file. Added: trunk/examples/al-admin/config/initializers/ralative_url_support.rb ============================================================================== --- (empty file) +++ trunk/examples/al-admin/config/initializers/ralative_url_support.rb Wed Jan 9 17:51:41 2008 @@ -0,0 +1 @@ +require 'accept_http_rails_relative_url_root' From codesite-noreply at google.com Wed Jan 9 20:52:37 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 17:52:37 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r632 - trunk/examples/al-admin/config/initializers Message-ID: <001485f9a4ae04435476d9d6f82a7b@google.com> Author: koutou Date: Wed Jan 9 17:51:41 2008 New Revision: 632 Added: trunk/examples/al-admin/config/initializers/ralative_url_support.rb Log: * added a missing file. Added: trunk/examples/al-admin/config/initializers/ralative_url_support.rb ============================================================================== --- (empty file) +++ trunk/examples/al-admin/config/initializers/ralative_url_support.rb Wed Jan 9 17:51:41 2008 @@ -0,0 +1 @@ +require 'accept_http_rails_relative_url_root' From codesite-noreply at google.com Wed Jan 9 21:09:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:09:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r633 - trunk/examples/al-admin/app/controllers Message-ID: <00163645796a044354b3b7b55d358c@google.com> Author: koutou Date: Wed Jan 9 18:08:47 2008 New Revision: 633 Modified: trunk/examples/al-admin/app/controllers/account_controller.rb Log: * logout only if logged in. Modified: trunk/examples/al-admin/app/controllers/account_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/account_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/account_controller.rb Wed Jan 9 18:08:47 2008 @@ -50,7 +50,8 @@ private def force_logout - current_user.forget_me if logged_in? + return true unless logged_in? + current_user.forget_me self.current_user = nil cookies.delete :auth_token reset_session From codesite-noreply at google.com Wed Jan 9 21:09:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:09:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r633 - trunk/examples/al-admin/app/controllers Message-ID: <00163645796a044354b3b7b55d358c@google.com> Author: koutou Date: Wed Jan 9 18:08:47 2008 New Revision: 633 Modified: trunk/examples/al-admin/app/controllers/account_controller.rb Log: * logout only if logged in. Modified: trunk/examples/al-admin/app/controllers/account_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/account_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/account_controller.rb Wed Jan 9 18:08:47 2008 @@ -50,7 +50,8 @@ private def force_logout - current_user.forget_me if logged_in? + return true unless logged_in? + current_user.forget_me self.current_user = nil cookies.delete :auth_token reset_session From codesite-noreply at google.com Wed Jan 9 21:13:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:13:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r634 - trunk/examples/al-admin/app/controllers Message-ID: <001636458730044354c2085c4a2fa5@google.com> Author: koutou Date: Wed Jan 9 18:09:16 2008 New Revision: 634 Modified: trunk/examples/al-admin/app/controllers/account_controller.rb Log: * fixed notice message live time. Modified: trunk/examples/al-admin/app/controllers/account_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/account_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/account_controller.rb Wed Jan 9 18:09:16 2008 @@ -21,9 +21,9 @@ } end redirect_back_or_default(top_url) - flash[:notice] = _("Logged in successfully") + flash.now[:notice] = _("Logged in successfully") else - flash[:notice] = _("Login or Password is incorrect") + flash.now[:notice] = _("Login or Password is incorrect") end end From codesite-noreply at google.com Wed Jan 9 21:13:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:13:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r634 - trunk/examples/al-admin/app/controllers Message-ID: <001636458730044354c2085c4a2fa5@google.com> Author: koutou Date: Wed Jan 9 18:09:16 2008 New Revision: 634 Modified: trunk/examples/al-admin/app/controllers/account_controller.rb Log: * fixed notice message live time. Modified: trunk/examples/al-admin/app/controllers/account_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/account_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/account_controller.rb Wed Jan 9 18:09:16 2008 @@ -21,9 +21,9 @@ } end redirect_back_or_default(top_url) - flash[:notice] = _("Logged in successfully") + flash.now[:notice] = _("Logged in successfully") else - flash[:notice] = _("Login or Password is incorrect") + flash.now[:notice] = _("Login or Password is incorrect") end end From codesite-noreply at google.com Wed Jan 9 21:17:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:17:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r635 - in trunk/examples/al-admin/app: controllers helpers Message-ID: <00163646d230044354d058fbcc3bed@google.com> Author: koutou Date: Wed Jan 9 18:15:49 2008 New Revision: 635 Modified: trunk/examples/al-admin/app/controllers/welcome_controller.rb trunk/examples/al-admin/app/helpers/url_helper.rb Log: * populated automatically for non-setup LDAP tree. Modified: trunk/examples/al-admin/app/controllers/welcome_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/welcome_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/welcome_controller.rb Wed Jan 9 18:15:49 2008 @@ -1,6 +1,10 @@ class WelcomeController < ApplicationController + include UrlHelper + def index - unless logged_in? + if Entry.empty? + redirect_to(populate_path) + elsif !logged_in? flash.keep(:notice) redirect_to(login_path) end Modified: trunk/examples/al-admin/app/helpers/url_helper.rb ============================================================================== --- trunk/examples/al-admin/app/helpers/url_helper.rb (original) +++ trunk/examples/al-admin/app/helpers/url_helper.rb Wed Jan 9 18:15:49 2008 @@ -10,4 +10,8 @@ def sign_up_path url_for(:controller => "/account", :action => "sign_up") end + + def populate_path + url_for(:controller => "/directory", :action => "populate") + end end From codesite-noreply at google.com Wed Jan 9 21:17:38 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 18:17:38 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r635 - in trunk/examples/al-admin/app: controllers helpers Message-ID: <00163646d230044354d058fbcc3bed@google.com> Author: koutou Date: Wed Jan 9 18:15:49 2008 New Revision: 635 Modified: trunk/examples/al-admin/app/controllers/welcome_controller.rb trunk/examples/al-admin/app/helpers/url_helper.rb Log: * populated automatically for non-setup LDAP tree. Modified: trunk/examples/al-admin/app/controllers/welcome_controller.rb ============================================================================== --- trunk/examples/al-admin/app/controllers/welcome_controller.rb (original) +++ trunk/examples/al-admin/app/controllers/welcome_controller.rb Wed Jan 9 18:15:49 2008 @@ -1,6 +1,10 @@ class WelcomeController < ApplicationController + include UrlHelper + def index - unless logged_in? + if Entry.empty? + redirect_to(populate_path) + elsif !logged_in? flash.keep(:notice) redirect_to(login_path) end Modified: trunk/examples/al-admin/app/helpers/url_helper.rb ============================================================================== --- trunk/examples/al-admin/app/helpers/url_helper.rb (original) +++ trunk/examples/al-admin/app/helpers/url_helper.rb Wed Jan 9 18:15:49 2008 @@ -10,4 +10,8 @@ def sign_up_path url_for(:controller => "/account", :action => "sign_up") end + + def populate_path + url_for(:controller => "/directory", :action => "populate") + end end From codesite-noreply at google.com Wed Jan 9 22:20:43 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 19:20:43 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r636 - trunk/examples/al-admin/lib Message-ID: <0016e649d3b8044355b1f5e0313daf@google.com> Author: koutou Date: Wed Jan 9 19:20:07 2008 New Revision: 636 Modified: trunk/examples/al-admin/lib/authenticated_system.rb Log: * don't use redirect_to_url. Modified: trunk/examples/al-admin/lib/authenticated_system.rb ============================================================================== --- trunk/examples/al-admin/lib/authenticated_system.rb (original) +++ trunk/examples/al-admin/lib/authenticated_system.rb Wed Jan 9 19:20:07 2008 @@ -87,7 +87,7 @@ # Redirect to the URI stored by the most recent store_location call or # to the passed default. def redirect_back_or_default(default) - session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default) + redirect_to(session[:return_to] || default) session[:return_to] = nil end From codesite-noreply at google.com Wed Jan 9 22:20:43 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 19:20:43 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r636 - trunk/examples/al-admin/lib Message-ID: <0016e649d3b8044355b1f5e0313daf@google.com> Author: koutou Date: Wed Jan 9 19:20:07 2008 New Revision: 636 Modified: trunk/examples/al-admin/lib/authenticated_system.rb Log: * don't use redirect_to_url. Modified: trunk/examples/al-admin/lib/authenticated_system.rb ============================================================================== --- trunk/examples/al-admin/lib/authenticated_system.rb (original) +++ trunk/examples/al-admin/lib/authenticated_system.rb Wed Jan 9 19:20:07 2008 @@ -87,7 +87,7 @@ # Redirect to the URI stored by the most recent store_location call or # to the passed default. def redirect_back_or_default(default) - session[:return_to] ? redirect_to_url(session[:return_to]) : redirect_to(default) + redirect_to(session[:return_to] || default) session[:return_to] = nil end From codesite-noreply at google.com Wed Jan 9 23:36:56 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 20:36:56 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r637 - trunk/lib/active_ldap/adapter Message-ID: <00163645796a044356c281bd1a3f44@google.com> Author: koutou Date: Wed Jan 9 20:36:11 2008 New Revision: 637 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/adapter/ldap.rb trunk/lib/active_ldap/adapter/ldap_ext.rb Log: * supported auto reconnection for Ruby/LDAP backend. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Wed Jan 9 20:36:11 2008 @@ -201,20 +201,21 @@ def operation(options) retried = false options = options.dup + options[:try_reconnect] = true unless options.has_key?(:try_reconnect) + try_reconnect = false begin reconnect_if_need(options) - try_reconnect = !options.has_key?(:try_reconnect) || - options[:try_reconnect] + try_reconnect = options[:try_reconnect] with_timeout(try_reconnect, options) do yield end - rescue Errno::EPIPE - if retried or !try_reconnect - raise - else + rescue Errno::EPIPE, ConnectionError + if try_reconnect and !retried retried = true @disconnected = true retry + else + raise end end end @@ -253,7 +254,7 @@ Timeout.alarm(@timeout, &block) rescue Timeout::Error => e @logger.error {_('Requested action timed out.')} - retry if try_reconnect and @retry_on_timeout and reconnect(options) + retry if @retry_on_timeout and try_reconnect and reconnect(options) @logger.error {e.message} raise TimeoutError, e.message end Modified: trunk/lib/active_ldap/adapter/ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap.rb (original) +++ trunk/lib/active_ldap/adapter/ldap.rb Wed Jan 9 20:36:11 2008 @@ -76,6 +76,11 @@ break if limit and limit <= i end rescue RuntimeError + begin + @connection.assert_error_code + rescue LDAP::ServerDown + raise ConnectionError, $!.message + end if $!.message == "no result returned by search" @logger.debug do args = [filter, attrs.inspect] Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap_ext.rb (original) +++ trunk/lib/active_ldap/adapter/ldap_ext.rb Wed Jan 9 20:36:11 2008 @@ -3,6 +3,10 @@ require 'ldap/schema' module LDAP + unless const_defined?(:LDAP_OPT_ERROR_NUMBER) + LDAP_OPT_ERROR_NUMBER = 0x0031 + end + class Mod unless instance_method(:to_s).arity.zero? alias_method :original_to_s, :to_s @@ -47,12 +51,18 @@ class Conn def failed? - not err.zero? + not error_code.zero? + end + + def error_code + code = err + code = get_option(LDAP_OPT_ERROR_NUMBER) if code.zero? + code end def error_message if failed? - LDAP.err2string(err) + LDAP.err2string(error_code) else nil end @@ -60,10 +70,11 @@ def assert_error_code return unless failed? - klass = ActiveLdap::LdapError::ERRORS[err] - klass ||= IMPLEMENT_SPECIFIC_ERRORS[err] + code = error_code + klass = ActiveLdap::LdapError::ERRORS[code] + klass ||= IMPLEMENT_SPECIFIC_ERRORS[code] klass ||= ActiveLdap::LdapError - raise klass, LDAP.err2string(err) + raise klass, LDAP.err2string(code) end end end From codesite-noreply at google.com Wed Jan 9 23:36:56 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 20:36:56 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r637 - trunk/lib/active_ldap/adapter Message-ID: <00163645796a044356c281bd1a3f44@google.com> Author: koutou Date: Wed Jan 9 20:36:11 2008 New Revision: 637 Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/adapter/ldap.rb trunk/lib/active_ldap/adapter/ldap_ext.rb Log: * supported auto reconnection for Ruby/LDAP backend. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Wed Jan 9 20:36:11 2008 @@ -201,20 +201,21 @@ def operation(options) retried = false options = options.dup + options[:try_reconnect] = true unless options.has_key?(:try_reconnect) + try_reconnect = false begin reconnect_if_need(options) - try_reconnect = !options.has_key?(:try_reconnect) || - options[:try_reconnect] + try_reconnect = options[:try_reconnect] with_timeout(try_reconnect, options) do yield end - rescue Errno::EPIPE - if retried or !try_reconnect - raise - else + rescue Errno::EPIPE, ConnectionError + if try_reconnect and !retried retried = true @disconnected = true retry + else + raise end end end @@ -253,7 +254,7 @@ Timeout.alarm(@timeout, &block) rescue Timeout::Error => e @logger.error {_('Requested action timed out.')} - retry if try_reconnect and @retry_on_timeout and reconnect(options) + retry if @retry_on_timeout and try_reconnect and reconnect(options) @logger.error {e.message} raise TimeoutError, e.message end Modified: trunk/lib/active_ldap/adapter/ldap.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap.rb (original) +++ trunk/lib/active_ldap/adapter/ldap.rb Wed Jan 9 20:36:11 2008 @@ -76,6 +76,11 @@ break if limit and limit <= i end rescue RuntimeError + begin + @connection.assert_error_code + rescue LDAP::ServerDown + raise ConnectionError, $!.message + end if $!.message == "no result returned by search" @logger.debug do args = [filter, attrs.inspect] Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap_ext.rb (original) +++ trunk/lib/active_ldap/adapter/ldap_ext.rb Wed Jan 9 20:36:11 2008 @@ -3,6 +3,10 @@ require 'ldap/schema' module LDAP + unless const_defined?(:LDAP_OPT_ERROR_NUMBER) + LDAP_OPT_ERROR_NUMBER = 0x0031 + end + class Mod unless instance_method(:to_s).arity.zero? alias_method :original_to_s, :to_s @@ -47,12 +51,18 @@ class Conn def failed? - not err.zero? + not error_code.zero? + end + + def error_code + code = err + code = get_option(LDAP_OPT_ERROR_NUMBER) if code.zero? + code end def error_message if failed? - LDAP.err2string(err) + LDAP.err2string(error_code) else nil end @@ -60,10 +70,11 @@ def assert_error_code return unless failed? - klass = ActiveLdap::LdapError::ERRORS[err] - klass ||= IMPLEMENT_SPECIFIC_ERRORS[err] + code = error_code + klass = ActiveLdap::LdapError::ERRORS[code] + klass ||= IMPLEMENT_SPECIFIC_ERRORS[code] klass ||= ActiveLdap::LdapError - raise klass, LDAP.err2string(err) + raise klass, LDAP.err2string(code) end end end From codesite-noreply at google.com Thu Jan 10 01:00:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 22:00:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r638 - trunk/examples/al-admin/app/models Message-ID: <00163646d136044357ef168453404f@google.com> Author: koutou Date: Wed Jan 9 22:00:36 2008 New Revision: 638 Modified: trunk/examples/al-admin/app/models/ldap_user.rb Log: * added system_user for convenience. Modified: trunk/examples/al-admin/app/models/ldap_user.rb ============================================================================== --- trunk/examples/al-admin/app/models/ldap_user.rb (original) +++ trunk/examples/al-admin/app/models/ldap_user.rb Wed Jan 9 22:00:36 2008 @@ -38,6 +38,10 @@ (ActiveLdap::DN.parse(dn) - ActiveLdap::DN.parse(self.class.base)).to_s end + def system_user + @system_user ||= User.find_by_dn(dn) + end + private def encrypt_password return if password.blank? From codesite-noreply at google.com Thu Jan 10 01:00:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 22:00:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r638 - trunk/examples/al-admin/app/models Message-ID: <00163646d136044357ef168453404f@google.com> Author: koutou Date: Wed Jan 9 22:00:36 2008 New Revision: 638 Modified: trunk/examples/al-admin/app/models/ldap_user.rb Log: * added system_user for convenience. Modified: trunk/examples/al-admin/app/models/ldap_user.rb ============================================================================== --- trunk/examples/al-admin/app/models/ldap_user.rb (original) +++ trunk/examples/al-admin/app/models/ldap_user.rb Wed Jan 9 22:00:36 2008 @@ -38,6 +38,10 @@ (ActiveLdap::DN.parse(dn) - ActiveLdap::DN.parse(self.class.base)).to_s end + def system_user + @system_user ||= User.find_by_dn(dn) + end + private def encrypt_password return if password.blank? From codesite-noreply at google.com Thu Jan 10 01:06:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 22:06:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r639 - in trunk/examples/al-admin/app/views: _entry _schema _switcher account attributes director... Message-ID: <00163645796a044358048e802a45e6@google.com> Author: koutou Date: Wed Jan 9 22:06:55 2008 New Revision: 639 Added: trunk/examples/al-admin/app/views/_entry/_attributes_information.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_entry/_attributes_information.rhtml trunk/examples/al-admin/app/views/_entry/_entry.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_entry/_entry.rhtml trunk/examples/al-admin/app/views/_schema/_aliases.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_schema/_aliases.rhtml trunk/examples/al-admin/app/views/_switcher/_after.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_switcher/_after.rhtml trunk/examples/al-admin/app/views/_switcher/_before.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_switcher/_before.rhtml trunk/examples/al-admin/app/views/account/login.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/account/login.rhtml trunk/examples/al-admin/app/views/account/sign_up.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/account/sign_up.rhtml trunk/examples/al-admin/app/views/attributes/_attributes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/_attributes.rhtml trunk/examples/al-admin/app/views/attributes/_detail.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/_detail.rhtml trunk/examples/al-admin/app/views/attributes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/index.rhtml trunk/examples/al-admin/app/views/attributes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/show.rhtml trunk/examples/al-admin/app/views/directory/_tree.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/_tree.rhtml trunk/examples/al-admin/app/views/directory/_tree_view_js.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/_tree_view_js.rhtml trunk/examples/al-admin/app/views/directory/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/index.rhtml trunk/examples/al-admin/app/views/directory/populate.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/populate.rhtml trunk/examples/al-admin/app/views/layouts/_footer.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_footer.rhtml trunk/examples/al-admin/app/views/layouts/_header_menu.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_header_menu.rhtml trunk/examples/al-admin/app/views/layouts/_main_menu.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_main_menu.rhtml trunk/examples/al-admin/app/views/layouts/application.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/application.rhtml trunk/examples/al-admin/app/views/object_classes/_attributes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/_attributes.rhtml trunk/examples/al-admin/app/views/object_classes/_object_classes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/_object_classes.rhtml trunk/examples/al-admin/app/views/object_classes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/index.rhtml trunk/examples/al-admin/app/views/object_classes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/show.rhtml trunk/examples/al-admin/app/views/syntaxes/_detail.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/_detail.rhtml trunk/examples/al-admin/app/views/syntaxes/_syntaxes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml trunk/examples/al-admin/app/views/syntaxes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/index.rhtml trunk/examples/al-admin/app/views/syntaxes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/show.rhtml trunk/examples/al-admin/app/views/users/_attributes_update_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_attributes_update_form.rhtml trunk/examples/al-admin/app/views/users/_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_form.rhtml trunk/examples/al-admin/app/views/users/_object_classes_update_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_object_classes_update_form.rhtml trunk/examples/al-admin/app/views/users/_password_change_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_password_change_form.rhtml trunk/examples/al-admin/app/views/users/edit.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/edit.rhtml trunk/examples/al-admin/app/views/users/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/index.rhtml trunk/examples/al-admin/app/views/users/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/show.rhtml trunk/examples/al-admin/app/views/welcome/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/welcome/index.rhtml Removed: trunk/examples/al-admin/app/views/_entry/_attributes_information.rhtml trunk/examples/al-admin/app/views/_entry/_entry.rhtml trunk/examples/al-admin/app/views/_schema/_aliases.rhtml trunk/examples/al-admin/app/views/_switcher/_after.rhtml trunk/examples/al-admin/app/views/_switcher/_before.rhtml trunk/examples/al-admin/app/views/account/login.rhtml trunk/examples/al-admin/app/views/account/sign_up.rhtml trunk/examples/al-admin/app/views/attributes/_attributes.rhtml trunk/examples/al-admin/app/views/attributes/_detail.rhtml trunk/examples/al-admin/app/views/attributes/index.rhtml trunk/examples/al-admin/app/views/attributes/show.rhtml trunk/examples/al-admin/app/views/directory/_tree.rhtml trunk/examples/al-admin/app/views/directory/_tree_view_js.rhtml trunk/examples/al-admin/app/views/directory/index.rhtml trunk/examples/al-admin/app/views/directory/populate.rhtml trunk/examples/al-admin/app/views/layouts/_footer.rhtml trunk/examples/al-admin/app/views/layouts/_header_menu.rhtml trunk/examples/al-admin/app/views/layouts/_main_menu.rhtml trunk/examples/al-admin/app/views/layouts/application.rhtml trunk/examples/al-admin/app/views/object_classes/_attributes.rhtml trunk/examples/al-admin/app/views/object_classes/_object_classes.rhtml trunk/examples/al-admin/app/views/object_classes/index.rhtml trunk/examples/al-admin/app/views/object_classes/show.rhtml trunk/examples/al-admin/app/views/syntaxes/_detail.rhtml trunk/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml trunk/examples/al-admin/app/views/syntaxes/index.rhtml trunk/examples/al-admin/app/views/syntaxes/show.rhtml trunk/examples/al-admin/app/views/users/_attributes_update_form.rhtml trunk/examples/al-admin/app/views/users/_form.rhtml trunk/examples/al-admin/app/views/users/_object_classes_update_form.rhtml trunk/examples/al-admin/app/views/users/_password_change_form.rhtml trunk/examples/al-admin/app/views/users/edit.rhtml trunk/examples/al-admin/app/views/users/index.rhtml trunk/examples/al-admin/app/views/users/show.rhtml trunk/examples/al-admin/app/views/welcome/index.rhtml Log: * .rhtml -> .html.erb. From codesite-noreply at google.com Thu Jan 10 01:06:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 09 Jan 2008 22:06:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r639 - in trunk/examples/al-admin/app/views: _entry _schema _switcher account attributes director... Message-ID: <00163645796a044358048e802a45e6@google.com> Author: koutou Date: Wed Jan 9 22:06:55 2008 New Revision: 639 Added: trunk/examples/al-admin/app/views/_entry/_attributes_information.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_entry/_attributes_information.rhtml trunk/examples/al-admin/app/views/_entry/_entry.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_entry/_entry.rhtml trunk/examples/al-admin/app/views/_schema/_aliases.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_schema/_aliases.rhtml trunk/examples/al-admin/app/views/_switcher/_after.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_switcher/_after.rhtml trunk/examples/al-admin/app/views/_switcher/_before.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/_switcher/_before.rhtml trunk/examples/al-admin/app/views/account/login.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/account/login.rhtml trunk/examples/al-admin/app/views/account/sign_up.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/account/sign_up.rhtml trunk/examples/al-admin/app/views/attributes/_attributes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/_attributes.rhtml trunk/examples/al-admin/app/views/attributes/_detail.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/_detail.rhtml trunk/examples/al-admin/app/views/attributes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/index.rhtml trunk/examples/al-admin/app/views/attributes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/attributes/show.rhtml trunk/examples/al-admin/app/views/directory/_tree.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/_tree.rhtml trunk/examples/al-admin/app/views/directory/_tree_view_js.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/_tree_view_js.rhtml trunk/examples/al-admin/app/views/directory/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/index.rhtml trunk/examples/al-admin/app/views/directory/populate.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/directory/populate.rhtml trunk/examples/al-admin/app/views/layouts/_footer.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_footer.rhtml trunk/examples/al-admin/app/views/layouts/_header_menu.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_header_menu.rhtml trunk/examples/al-admin/app/views/layouts/_main_menu.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/_main_menu.rhtml trunk/examples/al-admin/app/views/layouts/application.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/layouts/application.rhtml trunk/examples/al-admin/app/views/object_classes/_attributes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/_attributes.rhtml trunk/examples/al-admin/app/views/object_classes/_object_classes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/_object_classes.rhtml trunk/examples/al-admin/app/views/object_classes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/index.rhtml trunk/examples/al-admin/app/views/object_classes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/object_classes/show.rhtml trunk/examples/al-admin/app/views/syntaxes/_detail.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/_detail.rhtml trunk/examples/al-admin/app/views/syntaxes/_syntaxes.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml trunk/examples/al-admin/app/views/syntaxes/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/index.rhtml trunk/examples/al-admin/app/views/syntaxes/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/syntaxes/show.rhtml trunk/examples/al-admin/app/views/users/_attributes_update_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_attributes_update_form.rhtml trunk/examples/al-admin/app/views/users/_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_form.rhtml trunk/examples/al-admin/app/views/users/_object_classes_update_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_object_classes_update_form.rhtml trunk/examples/al-admin/app/views/users/_password_change_form.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/_password_change_form.rhtml trunk/examples/al-admin/app/views/users/edit.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/edit.rhtml trunk/examples/al-admin/app/views/users/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/index.rhtml trunk/examples/al-admin/app/views/users/show.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/users/show.rhtml trunk/examples/al-admin/app/views/welcome/index.html.erb - copied unchanged from r624, /trunk/examples/al-admin/app/views/welcome/index.rhtml Removed: trunk/examples/al-admin/app/views/_entry/_attributes_information.rhtml trunk/examples/al-admin/app/views/_entry/_entry.rhtml trunk/examples/al-admin/app/views/_schema/_aliases.rhtml trunk/examples/al-admin/app/views/_switcher/_after.rhtml trunk/examples/al-admin/app/views/_switcher/_before.rhtml trunk/examples/al-admin/app/views/account/login.rhtml trunk/examples/al-admin/app/views/account/sign_up.rhtml trunk/examples/al-admin/app/views/attributes/_attributes.rhtml trunk/examples/al-admin/app/views/attributes/_detail.rhtml trunk/examples/al-admin/app/views/attributes/index.rhtml trunk/examples/al-admin/app/views/attributes/show.rhtml trunk/examples/al-admin/app/views/directory/_tree.rhtml trunk/examples/al-admin/app/views/directory/_tree_view_js.rhtml trunk/examples/al-admin/app/views/directory/index.rhtml trunk/examples/al-admin/app/views/directory/populate.rhtml trunk/examples/al-admin/app/views/layouts/_footer.rhtml trunk/examples/al-admin/app/views/layouts/_header_menu.rhtml trunk/examples/al-admin/app/views/layouts/_main_menu.rhtml trunk/examples/al-admin/app/views/layouts/application.rhtml trunk/examples/al-admin/app/views/object_classes/_attributes.rhtml trunk/examples/al-admin/app/views/object_classes/_object_classes.rhtml trunk/examples/al-admin/app/views/object_classes/index.rhtml trunk/examples/al-admin/app/views/object_classes/show.rhtml trunk/examples/al-admin/app/views/syntaxes/_detail.rhtml trunk/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml trunk/examples/al-admin/app/views/syntaxes/index.rhtml trunk/examples/al-admin/app/views/syntaxes/show.rhtml trunk/examples/al-admin/app/views/users/_attributes_update_form.rhtml trunk/examples/al-admin/app/views/users/_form.rhtml trunk/examples/al-admin/app/views/users/_object_classes_update_form.rhtml trunk/examples/al-admin/app/views/users/_password_change_form.rhtml trunk/examples/al-admin/app/views/users/edit.rhtml trunk/examples/al-admin/app/views/users/index.rhtml trunk/examples/al-admin/app/views/users/show.rhtml trunk/examples/al-admin/app/views/welcome/index.rhtml Log: * .rhtml -> .html.erb. From codesite-noreply at google.com Sun Jan 13 07:08:36 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 13 Jan 2008 04:08:36 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r640 - in trunk: . lib/active_ldap/schema test Message-ID: <000e0cd118260443996b4e962911a24@google.com> Author: koutou Date: Sun Jan 13 04:08:17 2008 New Revision: 640 Modified: trunk/README trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * fixed GeneralizedTime type casting. Reported by Bodaniel Jeanes. Thanks!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Sun Jan 13 04:08:17 2008 @@ -101,4 +101,6 @@ * Perry Smith: Patches, bug reports and indications. * Marc Dequ?nes: API suggestions. * Jeremy Pruitt: A bug report. -* Bodaniel Jeanes: A suggestion for behavior on simple bind with empty password. +* Bodaniel Jeanes: + * A suggestion for behavior on simple bind with empty password. + * Bug reports. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sun Jan 13 04:08:17 2008 @@ -165,12 +165,32 @@ class GeneralizedTime < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.24"] = self + FORMAT = /\A + (\d{4,4})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + ([,.]\d+)? + ([+-]\d{4,4}|Z)? + \z/x def type_cast(value) return value if value.nil? or value.is_a?(Time) - begin - Time.parse(value) - rescue ArgumentError + match_data = FORMAT.match(value) + if match_data + required_components = match_data.to_a[1, 6] + return value if required_components.any?(&:nil?) + year, month, day, hour, minute, second = + required_components.collect(&:to_i) + fraction = match_data[-2] + fraction = fraction.to_f if fraction + time_zone = match_data[-1] + Time.send(:make_time, + year, month, day, hour, minute, second, fraction, + time_zone, Time.now) + else value end end @@ -190,20 +210,12 @@ private def validate_normalized_value(value, original_value) - match_data = /\A - (\d{4,4})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2}(?:[,.]\d+)?)? - ([+-]\d{4,4}|Z)? - \z/x.match(value) + match_data = FORMAT.match(value) if match_data - year, month, day, hour, minute, second, time_zone = + year, month, day, hour, minute, second, fraction, time_zone = match_data.to_a[1..-1] missing_components = [] - %w(year month day hour minute).each do |component| + %w(year month day hour minute second).each do |component| missing_components << component unless eval(component) end if missing_components.empty? Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sun Jan 13 04:08:17 2008 @@ -84,11 +84,12 @@ def test_generalized_time_type_cast assert_type_cast_without_validation(nil, nil, "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32"), "199412161032", + assert_type_cast(Time.parse("1994/12/16 10:32:12"), "19941216103212", "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32Z"), "199412161032Z", + assert_type_cast(Time.parse("1994/12/16 10:32:12Z"), "19941216103212Z", "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32 +09:00"), "199412161032+0900", + assert_type_cast(Time.parse("1994/12/16 10:32:12.345 +09:00"), + "19941216103212.345+0900", "Generalized Time") end @@ -165,12 +166,18 @@ end def test_generalized_time_validate - assert_valid("199412161032", "Generalized Time") - assert_valid("199412161032Z", "Generalized Time") - assert_valid("199412161032+0900", "Generalized Time") + assert_valid("19941216103201", "Generalized Time") + assert_valid("19941216103212Z", "Generalized Time") + assert_valid("19941216103230+0900", "Generalized Time") + assert_valid("20080107034615.0Z", "Generalized Time") + assert_valid("20080107034615,123-0900", "Generalized Time") value = "1994" - params = [value.inspect, %w(month day hour minute).join(", ")] + params = [value.inspect, %w(month day hour minute second).join(", ")] + assert_invalid(_("%s has missing components: %s") % params, + value, "Generalized Time") + value = "199412161032" + params = [value.inspect, %w(second).join(", ")] assert_invalid(_("%s has missing components: %s") % params, value, "Generalized Time") end From codesite-noreply at google.com Sun Jan 13 07:08:36 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 13 Jan 2008 04:08:36 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r640 - in trunk: . lib/active_ldap/schema test Message-ID: <000e0cd118260443996b4e962911a24@google.com> Author: koutou Date: Sun Jan 13 04:08:17 2008 New Revision: 640 Modified: trunk/README trunk/lib/active_ldap/schema/syntaxes.rb trunk/test/test_syntax.rb Log: * fixed GeneralizedTime type casting. Reported by Bodaniel Jeanes. Thanks!!! Modified: trunk/README ============================================================================== --- trunk/README (original) +++ trunk/README Sun Jan 13 04:08:17 2008 @@ -101,4 +101,6 @@ * Perry Smith: Patches, bug reports and indications. * Marc Dequ?nes: API suggestions. * Jeremy Pruitt: A bug report. -* Bodaniel Jeanes: A suggestion for behavior on simple bind with empty password. +* Bodaniel Jeanes: + * A suggestion for behavior on simple bind with empty password. + * Bug reports. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Sun Jan 13 04:08:17 2008 @@ -165,12 +165,32 @@ class GeneralizedTime < Base SYNTAXES["1.3.6.1.4.1.1466.115.121.1.24"] = self + FORMAT = /\A + (\d{4,4})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + (\d{2,2})? + ([,.]\d+)? + ([+-]\d{4,4}|Z)? + \z/x def type_cast(value) return value if value.nil? or value.is_a?(Time) - begin - Time.parse(value) - rescue ArgumentError + match_data = FORMAT.match(value) + if match_data + required_components = match_data.to_a[1, 6] + return value if required_components.any?(&:nil?) + year, month, day, hour, minute, second = + required_components.collect(&:to_i) + fraction = match_data[-2] + fraction = fraction.to_f if fraction + time_zone = match_data[-1] + Time.send(:make_time, + year, month, day, hour, minute, second, fraction, + time_zone, Time.now) + else value end end @@ -190,20 +210,12 @@ private def validate_normalized_value(value, original_value) - match_data = /\A - (\d{4,4})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2})? - (\d{2,2}(?:[,.]\d+)?)? - ([+-]\d{4,4}|Z)? - \z/x.match(value) + match_data = FORMAT.match(value) if match_data - year, month, day, hour, minute, second, time_zone = + year, month, day, hour, minute, second, fraction, time_zone = match_data.to_a[1..-1] missing_components = [] - %w(year month day hour minute).each do |component| + %w(year month day hour minute second).each do |component| missing_components << component unless eval(component) end if missing_components.empty? Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Sun Jan 13 04:08:17 2008 @@ -84,11 +84,12 @@ def test_generalized_time_type_cast assert_type_cast_without_validation(nil, nil, "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32"), "199412161032", + assert_type_cast(Time.parse("1994/12/16 10:32:12"), "19941216103212", "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32Z"), "199412161032Z", + assert_type_cast(Time.parse("1994/12/16 10:32:12Z"), "19941216103212Z", "Generalized Time") - assert_type_cast(Time.parse("1994/12/16 10:32 +09:00"), "199412161032+0900", + assert_type_cast(Time.parse("1994/12/16 10:32:12.345 +09:00"), + "19941216103212.345+0900", "Generalized Time") end @@ -165,12 +166,18 @@ end def test_generalized_time_validate - assert_valid("199412161032", "Generalized Time") - assert_valid("199412161032Z", "Generalized Time") - assert_valid("199412161032+0900", "Generalized Time") + assert_valid("19941216103201", "Generalized Time") + assert_valid("19941216103212Z", "Generalized Time") + assert_valid("19941216103230+0900", "Generalized Time") + assert_valid("20080107034615.0Z", "Generalized Time") + assert_valid("20080107034615,123-0900", "Generalized Time") value = "1994" - params = [value.inspect, %w(month day hour minute).join(", ")] + params = [value.inspect, %w(month day hour minute second).join(", ")] + assert_invalid(_("%s has missing components: %s") % params, + value, "Generalized Time") + value = "199412161032" + params = [value.inspect, %w(second).join(", ")] assert_invalid(_("%s has missing components: %s") % params, value, "Generalized Time") end From codesite-noreply at google.com Sun Jan 13 08:32:44 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 13 Jan 2008 05:32:44 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r641 - trunk/lib/active_ldap Message-ID: <000e0cd151de04439a982f65c111b4d@google.com> Author: koutou Date: Sun Jan 13 05:31:58 2008 New Revision: 641 Modified: trunk/lib/active_ldap/base.rb Log: * hide attribute map from inspect. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Sun Jan 13 05:31:58 2008 @@ -875,6 +875,9 @@ connection, @connection = @connection, nil schema, @schema = @schema, nil attribute_schemata, @attribute_schemata = @attribute_schemata, nil + normalized_attribute_names, @normalized_attribute_names = + @normalized_attribute_names, nil + attribute_aliases, @attribute_aliases = @attribute_aliases, nil must, may = @must, @may object_classes = @object_classes unless @abbreviating @@ -887,6 +890,8 @@ @connection = connection @schema = schema @attribute_schemata = attribute_schemata + @normalized_attribute_names = normalized_attribute_names + @attribute_aliases = attribute_aliases @must = must @may = may @object_classes = object_classes From codesite-noreply at google.com Sun Jan 13 08:32:44 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Sun, 13 Jan 2008 05:32:44 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r641 - trunk/lib/active_ldap Message-ID: <000e0cd151de04439a982f65c111b4d@google.com> Author: koutou Date: Sun Jan 13 05:31:58 2008 New Revision: 641 Modified: trunk/lib/active_ldap/base.rb Log: * hide attribute map from inspect. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Sun Jan 13 05:31:58 2008 @@ -875,6 +875,9 @@ connection, @connection = @connection, nil schema, @schema = @schema, nil attribute_schemata, @attribute_schemata = @attribute_schemata, nil + normalized_attribute_names, @normalized_attribute_names = + @normalized_attribute_names, nil + attribute_aliases, @attribute_aliases = @attribute_aliases, nil must, may = @must, @may object_classes = @object_classes unless @abbreviating @@ -887,6 +890,8 @@ @connection = connection @schema = schema @attribute_schemata = attribute_schemata + @normalized_attribute_names = normalized_attribute_names + @attribute_aliases = attribute_aliases @must = must @may = may @object_classes = object_classes From codesite-noreply at google.com Mon Jan 14 05:11:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 02:11:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r642 - trunk/lib/active_ldap Message-ID: <000e0cd146640443abe553e5c012e3b@google.com> Author: koutou Date: Mon Jan 14 02:10:38 2008 New Revision: 642 Modified: trunk/lib/active_ldap/base.rb Log: * improved speed. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 02:10:38 2008 @@ -900,17 +900,13 @@ def extract_object_class(attributes) classes = [] - attrs = attributes.stringify_keys.reject do |key, value| - if key == 'objectClass' or - key.underscore == 'object_class' or - key.downcase == 'objectclass' - classes |= [value].flatten - true - else - false - end + attributes = attributes.stringify_keys + %w(objectClass object_class objectclass).each do |key| + value = attributes.delete(key) + next if value.nil? + classes.concat(value.to_a) end - [classes, attrs] + [classes.uniq, attributes] end def init_base From codesite-noreply at google.com Mon Jan 14 05:11:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 02:11:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r642 - trunk/lib/active_ldap Message-ID: <000e0cd146640443abe553e5c012e3b@google.com> Author: koutou Date: Mon Jan 14 02:10:38 2008 New Revision: 642 Modified: trunk/lib/active_ldap/base.rb Log: * improved speed. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 02:10:38 2008 @@ -900,17 +900,13 @@ def extract_object_class(attributes) classes = [] - attrs = attributes.stringify_keys.reject do |key, value| - if key == 'objectClass' or - key.underscore == 'object_class' or - key.downcase == 'objectclass' - classes |= [value].flatten - true - else - false - end + attributes = attributes.stringify_keys + %w(objectClass object_class objectclass).each do |key| + value = attributes.delete(key) + next if value.nil? + classes.concat(value.to_a) end - [classes, attrs] + [classes.uniq, attributes] end def init_base From codesite-noreply at google.com Mon Jan 14 06:23:19 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 03:23:19 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r643 - trunk/lib/active_ldap Message-ID: <000e0cd2bd280443ace73d0f1d12e38@google.com> Author: koutou Date: Mon Jan 14 03:22:39 2008 New Revision: 643 Modified: trunk/lib/active_ldap/base.rb Log: * improved perfomance really a bit. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 03:22:39 2008 @@ -900,13 +900,16 @@ def extract_object_class(attributes) classes = [] - attributes = attributes.stringify_keys - %w(objectClass object_class objectclass).each do |key| - value = attributes.delete(key) - next if value.nil? - classes.concat(value.to_a) + attrs = {} + attributes.each do |key, value| + key = key.to_s + if /\Aobject_?class\z/i =~ key + classes.concat(value.to_a) + else + attrs[key] = value + end end - [classes.uniq, attributes] + [classes, attributes] end def init_base From codesite-noreply at google.com Mon Jan 14 06:23:19 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 03:23:19 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r643 - trunk/lib/active_ldap Message-ID: <000e0cd2bd280443ace73d0f1d12e38@google.com> Author: koutou Date: Mon Jan 14 03:22:39 2008 New Revision: 643 Modified: trunk/lib/active_ldap/base.rb Log: * improved perfomance really a bit. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 03:22:39 2008 @@ -900,13 +900,16 @@ def extract_object_class(attributes) classes = [] - attributes = attributes.stringify_keys - %w(objectClass object_class objectclass).each do |key| - value = attributes.delete(key) - next if value.nil? - classes.concat(value.to_a) + attrs = {} + attributes.each do |key, value| + key = key.to_s + if /\Aobject_?class\z/i =~ key + classes.concat(value.to_a) + else + attrs[key] = value + end end - [classes.uniq, attributes] + [classes, attributes] end def init_base From codesite-noreply at google.com Mon Jan 14 07:30:24 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 04:30:24 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r644 - trunk/lib/active_ldap Message-ID: <00163646c8be0443add726a9a085d9c@google.com> Author: koutou Date: Mon Jan 14 04:29:52 2008 New Revision: 644 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb Log: * cached DN but performance isn't improved. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 04:29:52 2008 @@ -485,7 +485,7 @@ real_key = to_real_attribute_name(key) || key normalized_attributes[real_key] = value end - self.dn = normalized_attributes[dn_attribute] + self.dn = normalized_attributes.delete(dn_attribute) self.attributes = normalized_attributes else format = _("'%s' must be either nil, DN value as ActiveLdap::DN, " \ @@ -568,16 +568,7 @@ # # Return the authoritative dn def dn - return base if @dn_is_base - - dn_value = id - if dn_value.nil? - raise DistinguishedNameNotSetError.new, - _("%s's DN attribute (%s) isn't set") % [self, dn_attribute] - end - _base = base - _base = nil if _base.empty? - ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") + @dn ||= compute_dn end def id @@ -590,6 +581,7 @@ def dn=(value) set_attribute(dn_attribute, value) + @dn = nil end alias_method(:id=, :dn=) @@ -843,6 +835,7 @@ undef_method :base= def base=(object_local_base) + @dn = nil @base = object_local_base end @@ -918,6 +911,7 @@ def initialize_by_ldap_data(dn, attributes) init_base + @dn = dn @new_entry = false @dn_is_base = false @ldap_data = attributes @@ -986,6 +980,7 @@ @dn_attribute = nil @base = nil @scope = nil + @dn = nil @connection ||= nil end @@ -1107,6 +1102,7 @@ end def update_dn(attr, value) + @dn = nil @dn_is_base = false return [attr, value] if value.blank? @@ -1153,6 +1149,19 @@ dn_attribute_name, dn_attribute_value = val.to_a[0] [dn_attribute_name, dn_attribute_value, bases.empty? ? nil : DN.new(*bases).to_s] + end + + def compute_dn + return base if @dn_is_base + + dn_value = id + if dn_value.nil? + raise DistinguishedNameNotSetError.new, + _("%s's DN attribute (%s) isn't set") % [self, dn_attribute] + end + _base = base + _base = nil if _base.empty? + ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") end # define_attribute_methods Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 04:29:52 2008 @@ -205,7 +205,7 @@ def connection conn = @connection - if get_attribute_before_type_cast(dn_attribute)[1] + if @dn or get_attribute_before_type_cast(dn_attribute)[1] conn ||= self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection From codesite-noreply at google.com Mon Jan 14 07:30:24 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 04:30:24 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r644 - trunk/lib/active_ldap Message-ID: <00163646c8be0443add726a9a085d9c@google.com> Author: koutou Date: Mon Jan 14 04:29:52 2008 New Revision: 644 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb Log: * cached DN but performance isn't improved. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 04:29:52 2008 @@ -485,7 +485,7 @@ real_key = to_real_attribute_name(key) || key normalized_attributes[real_key] = value end - self.dn = normalized_attributes[dn_attribute] + self.dn = normalized_attributes.delete(dn_attribute) self.attributes = normalized_attributes else format = _("'%s' must be either nil, DN value as ActiveLdap::DN, " \ @@ -568,16 +568,7 @@ # # Return the authoritative dn def dn - return base if @dn_is_base - - dn_value = id - if dn_value.nil? - raise DistinguishedNameNotSetError.new, - _("%s's DN attribute (%s) isn't set") % [self, dn_attribute] - end - _base = base - _base = nil if _base.empty? - ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") + @dn ||= compute_dn end def id @@ -590,6 +581,7 @@ def dn=(value) set_attribute(dn_attribute, value) + @dn = nil end alias_method(:id=, :dn=) @@ -843,6 +835,7 @@ undef_method :base= def base=(object_local_base) + @dn = nil @base = object_local_base end @@ -918,6 +911,7 @@ def initialize_by_ldap_data(dn, attributes) init_base + @dn = dn @new_entry = false @dn_is_base = false @ldap_data = attributes @@ -986,6 +980,7 @@ @dn_attribute = nil @base = nil @scope = nil + @dn = nil @connection ||= nil end @@ -1107,6 +1102,7 @@ end def update_dn(attr, value) + @dn = nil @dn_is_base = false return [attr, value] if value.blank? @@ -1153,6 +1149,19 @@ dn_attribute_name, dn_attribute_value = val.to_a[0] [dn_attribute_name, dn_attribute_value, bases.empty? ? nil : DN.new(*bases).to_s] + end + + def compute_dn + return base if @dn_is_base + + dn_value = id + if dn_value.nil? + raise DistinguishedNameNotSetError.new, + _("%s's DN attribute (%s) isn't set") % [self, dn_attribute] + end + _base = base + _base = nil if _base.empty? + ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") end # define_attribute_methods Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 04:29:52 2008 @@ -205,7 +205,7 @@ def connection conn = @connection - if get_attribute_before_type_cast(dn_attribute)[1] + if @dn or get_attribute_before_type_cast(dn_attribute)[1] conn ||= self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection From codesite-noreply at google.com Mon Jan 14 07:47:26 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 04:47:26 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r645 - in trunk/lib/active_ldap: . adapter Message-ID: <00163646c82e0443ae14058c7087437@google.com> Author: koutou Date: Mon Jan 14 04:46:51 2008 New Revision: 645 Added: trunk/lib/active_ldap/entry_attribute.rb Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/validations.rb Log: * cached attribute name <-> Rubyish name mapping into each connection not each instance. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Mon Jan 14 04:46:51 2008 @@ -1,4 +1,5 @@ require 'active_ldap/schema' +require 'active_ldap/entry_attribute' require 'active_ldap/ldap_error' module ActiveLdap @@ -16,6 +17,7 @@ def initialize(configuration={}) @connection = nil @disconnected = false + @entry_attributes = {} @configuration = configuration.dup @logger = @configuration.delete(:logger) @configuration.assert_valid_keys(VALID_ADAPTER_CONFIGURATION_KEYS) @@ -108,6 +110,11 @@ :attributes => attrs).first Schema.new(attributes) end + end + + def entry_attribute(object_classes) + @entry_attributes[object_classes.uniq.sort] ||= + EntryAttribute.new(schema, object_classes) end def search(options={}) Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 04:46:51 2008 @@ -520,12 +520,12 @@ def may ensure_apply_object_class - @may + entry_attribute.may end def must ensure_apply_object_class - @must + entry_attribute.must end # attributes @@ -534,14 +534,7 @@ # attributes dynamically without schema awareness def attribute_names(normalize=false) ensure_apply_object_class - names = @attribute_names.keys - if normalize - names.collect do |name| - to_real_attribute_name(name) - end.uniq - else - names - end + entry_attribute.attribute_names(normalize) end def attribute_present?(name) @@ -670,7 +663,7 @@ # Add available attributes to the methods def methods(inherited_too=true) ensure_apply_object_class - target_names = @attribute_names.keys + @attribute_aliases.keys + target_names = entry_attribute.all_names target_names -= ['objectClass', Inflector.underscore('objectClass')] super + target_names.uniq.collect do |x| [x, "#{x}=", "#{x}?", "#{x}_before_type_cast"] @@ -720,14 +713,7 @@ _schema = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| - setter = "#{key}=" - unless respond_to?(setter) - _schema ||= schema - attribute = _schema.attribute(key) - next if attribute.id.nil? - define_attribute_methods(attribute) - end - send(setter, value) + send("#{key}=", value) end end @@ -815,6 +801,7 @@ connection.connect @connection = connection @schema = nil + @entry_attribute = nil clear_association_cache rescue ActiveLdap::Error remove_connection @@ -863,31 +850,21 @@ end private + def entry_attribute + @entry_attribute ||= connection.entry_attribute(@data["objectClass"] || []) + end + def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil schema, @schema = @schema, nil - attribute_schemata, @attribute_schemata = @attribute_schemata, nil - normalized_attribute_names, @normalized_attribute_names = - @normalized_attribute_names, nil - attribute_aliases, @attribute_aliases = @attribute_aliases, nil - must, may = @must, @may - object_classes = @object_classes unless @abbreviating @abbreviating = true - @must, @may = @must.collect(&:name), @may.collect(&:name) - @object_classes = @object_classes.collect(&:name) end yield ensure @connection = connection @schema = schema - @attribute_schemata = attribute_schemata - @normalized_attribute_names = normalized_attribute_names - @attribute_aliases = attribute_aliases - @must = must - @may = may - @object_classes = object_classes @abbreviating = false end @@ -938,16 +915,7 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? ensure_apply_object_class - name = name.to_s - real_name = @attribute_names[name] - real_name ||= @attribute_aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_attribute_names[normalize_attribute_name(name)] - else - nil - end + entry_attribute.normalize(name, allow_normalized_name) end def ensure_apply_object_class @@ -971,11 +939,6 @@ @mutex = Mutex.new @data = {} # where the r/w entry data is stored @ldap_data = {} # original ldap entry data - @attribute_schemata = {} - @attribute_names = {} # list of valid method calls for attributes used - # for dereferencing - @normalized_attribute_names = {} # list of normalized attribute name - @attribute_aliases = {} # aliases of @attribute_names @last_oc = false # for use in other methods for "caching" @dn_attribute = nil @base = nil @@ -997,35 +960,9 @@ new_oc = new_oc.uniq return new_oc if @last_oc == new_oc - # Store for caching purposes @last_oc = new_oc.dup - - # Set the actual objectClass data - define_attribute_methods(schema.attribute('objectClass')) replace_class(*new_oc) - - # Build |data| from schema - # clear attribute name mapping first - @attribute_schemata = {} - @attribute_names = {} - @normalized_attribute_names = {} - @attribute_aliases = {} - @must = [] - @may = [] - @object_classes = [] - new_oc.each do |objc| - # get all attributes for the class - object_class = schema.object_class(objc) - @object_classes << object_class - @must.concat(object_class.must) - @may.concat(object_class.may) - end - @must.uniq! - @may.uniq! - (@must + @may).each do |attr| - # Update attr_method with appropriate - define_attribute_methods(attr) - end + @entry_attribute = nil end # get_attribute @@ -1162,21 +1099,6 @@ _base = base _base = nil if _base.empty? ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") - end - - # define_attribute_methods - # - # Make a method entry for _every_ alias of a valid attribute and map it - # onto the first attribute passed in. - def define_attribute_methods(attribute) - real_name = attribute.name - return if @attribute_schemata.has_key?(real_name) - @attribute_schemata[real_name] = attribute - ([real_name] + attribute.aliases).each do |name| - @attribute_names[name] = real_name - @attribute_aliases[Inflector.underscore(name)] = real_name - @normalized_attribute_names[normalize_attribute_name(name)] = real_name - end end # array_of Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 04:46:51 2008 @@ -205,7 +205,8 @@ def connection conn = @connection - if @dn or get_attribute_before_type_cast(dn_attribute)[1] + if @dn or + (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) conn ||= self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection Added: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- (empty file) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 04:46:51 2008 @@ -0,0 +1,77 @@ +require "active_ldap/attributes" + +module ActiveLdap + class EntryAttribute + include Attributes::Normalize + + attr_reader :must, :may, :object_classes, :attribute_schemata + def initialize(schema, object_classes) + @attribute_schemata = {} + @attribute_names = {} + @normalized_attribute_names = {} + @attribute_aliases = {} + @must = [] + @may = [] + @object_classes = [] + define_attribute_methods(schema.attribute('objectClass')) + object_classes.each do |objc| + # get all attributes for the class + object_class = schema.object_class(objc) + @object_classes << object_class + @must.concat(object_class.must) + @may.concat(object_class.may) + end + @must.uniq! + @may.uniq! + (@must + @may).each do |attr| + # Update attr_method with appropriate + define_attribute_methods(attr) + end + end + + def attribute_names(normalize=false) + names = @attribute_names.keys + if normalize + names.collect do |name| + normalize(name) + end.uniq + else + names + end + end + + def normalize(name, allow_normalized_name=false) + return name if name.nil? + name = name.to_s + real_name = @attribute_names[name] + real_name ||= @attribute_aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_attribute_names[normalize_attribute_name(name)] + else + nil + end + end + + def all_names + @attribute_names.keys + @attribute_aliases.keys + end + + private + # define_attribute_methods + # + # Make a method entry for _every_ alias of a valid attribute and map it + # onto the first attribute passed in. + def define_attribute_methods(attribute) + real_name = attribute.name + return if @attribute_schemata.has_key?(real_name) + @attribute_schemata[real_name] = attribute + ([real_name] + attribute.aliases).each do |name| + @attribute_names[name] = real_name + @attribute_aliases[Inflector.underscore(name)] = real_name + @normalized_attribute_names[normalize_attribute_name(name)] = real_name + end + end + end +end Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 04:46:51 2008 @@ -85,7 +85,7 @@ def validate_required_ldap_values _schema = nil # Make sure all MUST attributes have a value - @object_classes.each do |object_class| + entry_attribute.object_classes.each do |object_class| object_class.must.each do |required_attribute| # Normalize to ensure we catch schema problems # needed? @@ -123,7 +123,7 @@ end def validate_ldap_values - @attribute_schemata.each do |name, attribute| + entry_attribute.attribute_schemata.each do |name, attribute| self[name, true].each do |value| validate_ldap_value(attribute, name, value) end From codesite-noreply at google.com Mon Jan 14 07:47:26 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 04:47:26 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r645 - in trunk/lib/active_ldap: . adapter Message-ID: <00163646c82e0443ae14058c7087437@google.com> Author: koutou Date: Mon Jan 14 04:46:51 2008 New Revision: 645 Added: trunk/lib/active_ldap/entry_attribute.rb Modified: trunk/lib/active_ldap/adapter/base.rb trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/validations.rb Log: * cached attribute name <-> Rubyish name mapping into each connection not each instance. Modified: trunk/lib/active_ldap/adapter/base.rb ============================================================================== --- trunk/lib/active_ldap/adapter/base.rb (original) +++ trunk/lib/active_ldap/adapter/base.rb Mon Jan 14 04:46:51 2008 @@ -1,4 +1,5 @@ require 'active_ldap/schema' +require 'active_ldap/entry_attribute' require 'active_ldap/ldap_error' module ActiveLdap @@ -16,6 +17,7 @@ def initialize(configuration={}) @connection = nil @disconnected = false + @entry_attributes = {} @configuration = configuration.dup @logger = @configuration.delete(:logger) @configuration.assert_valid_keys(VALID_ADAPTER_CONFIGURATION_KEYS) @@ -108,6 +110,11 @@ :attributes => attrs).first Schema.new(attributes) end + end + + def entry_attribute(object_classes) + @entry_attributes[object_classes.uniq.sort] ||= + EntryAttribute.new(schema, object_classes) end def search(options={}) Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 04:46:51 2008 @@ -520,12 +520,12 @@ def may ensure_apply_object_class - @may + entry_attribute.may end def must ensure_apply_object_class - @must + entry_attribute.must end # attributes @@ -534,14 +534,7 @@ # attributes dynamically without schema awareness def attribute_names(normalize=false) ensure_apply_object_class - names = @attribute_names.keys - if normalize - names.collect do |name| - to_real_attribute_name(name) - end.uniq - else - names - end + entry_attribute.attribute_names(normalize) end def attribute_present?(name) @@ -670,7 +663,7 @@ # Add available attributes to the methods def methods(inherited_too=true) ensure_apply_object_class - target_names = @attribute_names.keys + @attribute_aliases.keys + target_names = entry_attribute.all_names target_names -= ['objectClass', Inflector.underscore('objectClass')] super + target_names.uniq.collect do |x| [x, "#{x}=", "#{x}?", "#{x}_before_type_cast"] @@ -720,14 +713,7 @@ _schema = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| - setter = "#{key}=" - unless respond_to?(setter) - _schema ||= schema - attribute = _schema.attribute(key) - next if attribute.id.nil? - define_attribute_methods(attribute) - end - send(setter, value) + send("#{key}=", value) end end @@ -815,6 +801,7 @@ connection.connect @connection = connection @schema = nil + @entry_attribute = nil clear_association_cache rescue ActiveLdap::Error remove_connection @@ -863,31 +850,21 @@ end private + def entry_attribute + @entry_attribute ||= connection.entry_attribute(@data["objectClass"] || []) + end + def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil schema, @schema = @schema, nil - attribute_schemata, @attribute_schemata = @attribute_schemata, nil - normalized_attribute_names, @normalized_attribute_names = - @normalized_attribute_names, nil - attribute_aliases, @attribute_aliases = @attribute_aliases, nil - must, may = @must, @may - object_classes = @object_classes unless @abbreviating @abbreviating = true - @must, @may = @must.collect(&:name), @may.collect(&:name) - @object_classes = @object_classes.collect(&:name) end yield ensure @connection = connection @schema = schema - @attribute_schemata = attribute_schemata - @normalized_attribute_names = normalized_attribute_names - @attribute_aliases = attribute_aliases - @must = must - @may = may - @object_classes = object_classes @abbreviating = false end @@ -938,16 +915,7 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? ensure_apply_object_class - name = name.to_s - real_name = @attribute_names[name] - real_name ||= @attribute_aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_attribute_names[normalize_attribute_name(name)] - else - nil - end + entry_attribute.normalize(name, allow_normalized_name) end def ensure_apply_object_class @@ -971,11 +939,6 @@ @mutex = Mutex.new @data = {} # where the r/w entry data is stored @ldap_data = {} # original ldap entry data - @attribute_schemata = {} - @attribute_names = {} # list of valid method calls for attributes used - # for dereferencing - @normalized_attribute_names = {} # list of normalized attribute name - @attribute_aliases = {} # aliases of @attribute_names @last_oc = false # for use in other methods for "caching" @dn_attribute = nil @base = nil @@ -997,35 +960,9 @@ new_oc = new_oc.uniq return new_oc if @last_oc == new_oc - # Store for caching purposes @last_oc = new_oc.dup - - # Set the actual objectClass data - define_attribute_methods(schema.attribute('objectClass')) replace_class(*new_oc) - - # Build |data| from schema - # clear attribute name mapping first - @attribute_schemata = {} - @attribute_names = {} - @normalized_attribute_names = {} - @attribute_aliases = {} - @must = [] - @may = [] - @object_classes = [] - new_oc.each do |objc| - # get all attributes for the class - object_class = schema.object_class(objc) - @object_classes << object_class - @must.concat(object_class.must) - @may.concat(object_class.may) - end - @must.uniq! - @may.uniq! - (@must + @may).each do |attr| - # Update attr_method with appropriate - define_attribute_methods(attr) - end + @entry_attribute = nil end # get_attribute @@ -1162,21 +1099,6 @@ _base = base _base = nil if _base.empty? ["#{dn_attribute}=#{dn_value}", _base].compact.join(",") - end - - # define_attribute_methods - # - # Make a method entry for _every_ alias of a valid attribute and map it - # onto the first attribute passed in. - def define_attribute_methods(attribute) - real_name = attribute.name - return if @attribute_schemata.has_key?(real_name) - @attribute_schemata[real_name] = attribute - ([real_name] + attribute.aliases).each do |name| - @attribute_names[name] = real_name - @attribute_aliases[Inflector.underscore(name)] = real_name - @normalized_attribute_names[normalize_attribute_name(name)] = real_name - end end # array_of Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 04:46:51 2008 @@ -205,7 +205,8 @@ def connection conn = @connection - if @dn or get_attribute_before_type_cast(dn_attribute)[1] + if @dn or + (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) conn ||= self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection Added: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- (empty file) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 04:46:51 2008 @@ -0,0 +1,77 @@ +require "active_ldap/attributes" + +module ActiveLdap + class EntryAttribute + include Attributes::Normalize + + attr_reader :must, :may, :object_classes, :attribute_schemata + def initialize(schema, object_classes) + @attribute_schemata = {} + @attribute_names = {} + @normalized_attribute_names = {} + @attribute_aliases = {} + @must = [] + @may = [] + @object_classes = [] + define_attribute_methods(schema.attribute('objectClass')) + object_classes.each do |objc| + # get all attributes for the class + object_class = schema.object_class(objc) + @object_classes << object_class + @must.concat(object_class.must) + @may.concat(object_class.may) + end + @must.uniq! + @may.uniq! + (@must + @may).each do |attr| + # Update attr_method with appropriate + define_attribute_methods(attr) + end + end + + def attribute_names(normalize=false) + names = @attribute_names.keys + if normalize + names.collect do |name| + normalize(name) + end.uniq + else + names + end + end + + def normalize(name, allow_normalized_name=false) + return name if name.nil? + name = name.to_s + real_name = @attribute_names[name] + real_name ||= @attribute_aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_attribute_names[normalize_attribute_name(name)] + else + nil + end + end + + def all_names + @attribute_names.keys + @attribute_aliases.keys + end + + private + # define_attribute_methods + # + # Make a method entry for _every_ alias of a valid attribute and map it + # onto the first attribute passed in. + def define_attribute_methods(attribute) + real_name = attribute.name + return if @attribute_schemata.has_key?(real_name) + @attribute_schemata[real_name] = attribute + ([real_name] + attribute.aliases).each do |name| + @attribute_names[name] = real_name + @attribute_aliases[Inflector.underscore(name)] = real_name + @normalized_attribute_names[normalize_attribute_name(name)] = real_name + end + end + end +end Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 04:46:51 2008 @@ -85,7 +85,7 @@ def validate_required_ldap_values _schema = nil # Make sure all MUST attributes have a value - @object_classes.each do |object_class| + entry_attribute.object_classes.each do |object_class| object_class.must.each do |required_attribute| # Normalize to ensure we catch schema problems # needed? @@ -123,7 +123,7 @@ end def validate_ldap_values - @attribute_schemata.each do |name, attribute| + entry_attribute.attribute_schemata.each do |name, attribute| self[name, true].each do |value| validate_ldap_value(attribute, name, value) end From codesite-noreply at google.com Mon Jan 14 08:01:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:01:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r646 - trunk/benchmark Message-ID: <0016364176f10443ae462d4a6487b5c@google.com> Author: koutou Date: Mon Jan 14 05:01:25 2008 New Revision: 646 Modified: trunk/benchmark/bench-al.rb Log: * do rehearsal and GC. Modified: trunk/benchmark/bench-al.rb ============================================================================== --- trunk/benchmark/bench-al.rb (original) +++ trunk/benchmark/bench-al.rb Mon Jan 14 05:01:25 2008 @@ -166,19 +166,23 @@ al_count_without_object_creation = 0 ldap_count = 0 net_ldap_count = 0 - Benchmark.bm(20) do |x| + Benchmark.bmbm(20) do |x| [1].each do |n| + GC.start x.report("%3dx: AL" % n) {n.times {al_count = search_al}} + GC.start x.report("%3dx: AL(No Obj)" % n) do n.times do al_count_without_object_creation = search_al_without_object_creation end end + GC.start if ldap_conn x.report("%3dx: LDAP" % n) do n.times {ldap_count = search_ldap(ldap_conn)} end end + GC.start if net_ldap_conn x.report("%3dx: Net::LDAP" % n) do n.times {net_ldap_count = search_net_ldap(net_ldap_conn)} From codesite-noreply at google.com Mon Jan 14 08:01:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:01:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r646 - trunk/benchmark Message-ID: <0016364176f10443ae462d4a6487b5c@google.com> Author: koutou Date: Mon Jan 14 05:01:25 2008 New Revision: 646 Modified: trunk/benchmark/bench-al.rb Log: * do rehearsal and GC. Modified: trunk/benchmark/bench-al.rb ============================================================================== --- trunk/benchmark/bench-al.rb (original) +++ trunk/benchmark/bench-al.rb Mon Jan 14 05:01:25 2008 @@ -166,19 +166,23 @@ al_count_without_object_creation = 0 ldap_count = 0 net_ldap_count = 0 - Benchmark.bm(20) do |x| + Benchmark.bmbm(20) do |x| [1].each do |n| + GC.start x.report("%3dx: AL" % n) {n.times {al_count = search_al}} + GC.start x.report("%3dx: AL(No Obj)" % n) do n.times do al_count_without_object_creation = search_al_without_object_creation end end + GC.start if ldap_conn x.report("%3dx: LDAP" % n) do n.times {ldap_count = search_ldap(ldap_conn)} end end + GC.start if net_ldap_conn x.report("%3dx: Net::LDAP" % n) do n.times {net_ldap_count = search_net_ldap(net_ldap_conn)} From codesite-noreply at google.com Mon Jan 14 08:10:28 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:10:28 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r647 - trunk/lib/active_ldap Message-ID: <00163646c7740443ae6667bee6881ef@google.com> Author: koutou Date: Mon Jan 14 05:10:18 2008 New Revision: 647 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/entry_attribute.rb trunk/lib/active_ldap/validations.rb Log: * cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 05:10:18 2008 @@ -534,7 +534,7 @@ # attributes dynamically without schema awareness def attribute_names(normalize=false) ensure_apply_object_class - entry_attribute.attribute_names(normalize) + entry_attribute.names(normalize) end def attribute_present?(name) Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 05:10:18 2008 @@ -205,9 +205,11 @@ def connection conn = @connection + return conn if conn + if @dn or (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) - conn ||= self.class.active_connections[dn] || retrieve_connection + conn = self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection end Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 05:10:18 2008 @@ -4,12 +4,12 @@ class EntryAttribute include Attributes::Normalize - attr_reader :must, :may, :object_classes, :attribute_schemata + attr_reader :must, :may, :object_classes, :schemata def initialize(schema, object_classes) - @attribute_schemata = {} - @attribute_names = {} - @normalized_attribute_names = {} - @attribute_aliases = {} + @schemata = {} + @names = {} + @normalized_names = {} + @aliases = {} @must = [] @may = [] @object_classes = [] @@ -29,8 +29,8 @@ end end - def attribute_names(normalize=false) - names = @attribute_names.keys + def names(normalize=false) + names = @names.keys if normalize names.collect do |name| normalize(name) @@ -43,19 +43,19 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - real_name = @attribute_names[name] - real_name ||= @attribute_aliases[Inflector.underscore(name)] + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] if real_name real_name elsif allow_normalized_name - @normalized_attribute_names[normalize_attribute_name(name)] + @normalized_names[normalize_attribute_name(name)] else nil end end def all_names - @attribute_names.keys + @attribute_aliases.keys + @names.keys + @aliases.keys end private @@ -65,12 +65,12 @@ # onto the first attribute passed in. def define_attribute_methods(attribute) real_name = attribute.name - return if @attribute_schemata.has_key?(real_name) - @attribute_schemata[real_name] = attribute + return if @schemata.has_key?(real_name) + @schemata[real_name] = attribute ([real_name] + attribute.aliases).each do |name| - @attribute_names[name] = real_name - @attribute_aliases[Inflector.underscore(name)] = real_name - @normalized_attribute_names[normalize_attribute_name(name)] = real_name + @names[name] = real_name + @aliases[Inflector.underscore(name)] = real_name + @normalized_names[normalize_attribute_name(name)] = real_name end end end Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 05:10:18 2008 @@ -123,7 +123,7 @@ end def validate_ldap_values - entry_attribute.attribute_schemata.each do |name, attribute| + entry_attribute.schemata.each do |name, attribute| self[name, true].each do |value| validate_ldap_value(attribute, name, value) end From codesite-noreply at google.com Mon Jan 14 08:10:28 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:10:28 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r647 - trunk/lib/active_ldap Message-ID: <00163646c7740443ae6667bee6881ef@google.com> Author: koutou Date: Mon Jan 14 05:10:18 2008 New Revision: 647 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/entry_attribute.rb trunk/lib/active_ldap/validations.rb Log: * cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names.* cleanup names. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 05:10:18 2008 @@ -534,7 +534,7 @@ # attributes dynamically without schema awareness def attribute_names(normalize=false) ensure_apply_object_class - entry_attribute.attribute_names(normalize) + entry_attribute.names(normalize) end def attribute_present?(name) Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Mon Jan 14 05:10:18 2008 @@ -205,9 +205,11 @@ def connection conn = @connection + return conn if conn + if @dn or (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) - conn ||= self.class.active_connections[dn] || retrieve_connection + conn = self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection end Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 05:10:18 2008 @@ -4,12 +4,12 @@ class EntryAttribute include Attributes::Normalize - attr_reader :must, :may, :object_classes, :attribute_schemata + attr_reader :must, :may, :object_classes, :schemata def initialize(schema, object_classes) - @attribute_schemata = {} - @attribute_names = {} - @normalized_attribute_names = {} - @attribute_aliases = {} + @schemata = {} + @names = {} + @normalized_names = {} + @aliases = {} @must = [] @may = [] @object_classes = [] @@ -29,8 +29,8 @@ end end - def attribute_names(normalize=false) - names = @attribute_names.keys + def names(normalize=false) + names = @names.keys if normalize names.collect do |name| normalize(name) @@ -43,19 +43,19 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - real_name = @attribute_names[name] - real_name ||= @attribute_aliases[Inflector.underscore(name)] + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] if real_name real_name elsif allow_normalized_name - @normalized_attribute_names[normalize_attribute_name(name)] + @normalized_names[normalize_attribute_name(name)] else nil end end def all_names - @attribute_names.keys + @attribute_aliases.keys + @names.keys + @aliases.keys end private @@ -65,12 +65,12 @@ # onto the first attribute passed in. def define_attribute_methods(attribute) real_name = attribute.name - return if @attribute_schemata.has_key?(real_name) - @attribute_schemata[real_name] = attribute + return if @schemata.has_key?(real_name) + @schemata[real_name] = attribute ([real_name] + attribute.aliases).each do |name| - @attribute_names[name] = real_name - @attribute_aliases[Inflector.underscore(name)] = real_name - @normalized_attribute_names[normalize_attribute_name(name)] = real_name + @names[name] = real_name + @aliases[Inflector.underscore(name)] = real_name + @normalized_names[normalize_attribute_name(name)] = real_name end end end Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 05:10:18 2008 @@ -123,7 +123,7 @@ end def validate_ldap_values - entry_attribute.attribute_schemata.each do |name, attribute| + entry_attribute.schemata.each do |name, attribute| self[name, true].each do |value| validate_ldap_value(attribute, name, value) end From codesite-noreply at google.com Mon Jan 14 08:17:29 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:17:29 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r648 - trunk/lib/active_ldap Message-ID: <00163646c8be0443ae7f7ce8118859b@google.com> Author: koutou Date: Mon Jan 14 05:16:32 2008 New Revision: 648 Modified: trunk/lib/active_ldap/entry_attribute.rb Log: * cached normalized attribute name. Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 05:16:32 2008 @@ -9,6 +9,8 @@ @schemata = {} @names = {} @normalized_names = {} + @cached_names = {} + @cached_normalized_names = {} @aliases = {} @must = [] @may = [] @@ -43,15 +45,14 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - real_name = @names[name] - real_name ||= @aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_names[normalize_attribute_name(name)] + if allow_normalized_name + cache = @cached_names else - nil + cache = @cached_normalized_names end + + return cache[name] if cache.has_key?(name) + cache[name] = compute_normalized_name(name, allow_normalized_name) end def all_names @@ -71,6 +72,18 @@ @names[name] = real_name @aliases[Inflector.underscore(name)] = real_name @normalized_names[normalize_attribute_name(name)] = real_name + end + end + + def compute_normalized_name(name, allow_normalized_name=false) + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_names[normalize_attribute_name(name)] + else + nil end end end From codesite-noreply at google.com Mon Jan 14 08:17:29 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:17:29 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r648 - trunk/lib/active_ldap Message-ID: <00163646c8be0443ae7f7ce8118859b@google.com> Author: koutou Date: Mon Jan 14 05:16:32 2008 New Revision: 648 Modified: trunk/lib/active_ldap/entry_attribute.rb Log: * cached normalized attribute name. Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 05:16:32 2008 @@ -9,6 +9,8 @@ @schemata = {} @names = {} @normalized_names = {} + @cached_names = {} + @cached_normalized_names = {} @aliases = {} @must = [] @may = [] @@ -43,15 +45,14 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - real_name = @names[name] - real_name ||= @aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_names[normalize_attribute_name(name)] + if allow_normalized_name + cache = @cached_names else - nil + cache = @cached_normalized_names end + + return cache[name] if cache.has_key?(name) + cache[name] = compute_normalized_name(name, allow_normalized_name) end def all_names @@ -71,6 +72,18 @@ @names[name] = real_name @aliases[Inflector.underscore(name)] = real_name @normalized_names[normalize_attribute_name(name)] = real_name + end + end + + def compute_normalized_name(name, allow_normalized_name=false) + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_names[normalize_attribute_name(name)] + else + nil end end end From codesite-noreply at google.com Mon Jan 14 08:27:30 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:27:30 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r649 - trunk/lib/active_ldap Message-ID: <0016364c5add0443aea3580f4e891a9@google.com> Author: koutou Date: Mon Jan 14 05:26:29 2008 New Revision: 649 Modified: trunk/lib/active_ldap/attributes.rb Log: * removed needless method call. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 05:26:29 2008 @@ -92,7 +92,7 @@ raise TypeError, message end if value.empty? - if schema.attribute(name).binary_required? + if attribute.binary_required? [{'binary' => value}] else value From codesite-noreply at google.com Mon Jan 14 08:27:30 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:27:30 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r649 - trunk/lib/active_ldap Message-ID: <0016364c5add0443aea3580f4e891a9@google.com> Author: koutou Date: Mon Jan 14 05:26:29 2008 New Revision: 649 Modified: trunk/lib/active_ldap/attributes.rb Log: * removed needless method call. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 05:26:29 2008 @@ -92,7 +92,7 @@ raise TypeError, message end if value.empty? - if schema.attribute(name).binary_required? + if attribute.binary_required? [{'binary' => value}] else value From codesite-noreply at google.com Mon Jan 14 08:54:34 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:54:34 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r650 - trunk/lib/active_ldap Message-ID: <00163646c5a80443af0424dc968ba43@google.com> Author: koutou Date: Mon Jan 14 05:53:59 2008 New Revision: 650 Modified: trunk/lib/active_ldap/attributes.rb Log: * cached schema attribute. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 05:53:59 2008 @@ -47,13 +47,7 @@ end name = normalize_attribute_name(name) - rubyish_class_name = Inflector.underscore(value.class.name) - handler = "normalize_attribute_value_of_#{rubyish_class_name}" - if respond_to?(handler, true) - [name, send(handler, name, value)] - else - [name, [schema.attribute(name).normalize_value(value)]] - end + [name, normalize_attribute_value(name, value, nil, nil)] end def unnormalize_attributes(attributes) @@ -84,8 +78,20 @@ end private - def normalize_attribute_value_of_array(name, value) - attribute = schema.attribute(name) + def normalize_attribute_value(name, value, rubyish_class_name, attribute) + rubyish_class_name ||= Inflector.underscore(value.class.name) + handler = "normalize_attribute_value_of_#{rubyish_class_name}" + if respond_to?(handler, true) + send(handler, name, value, rubyish_class_name, attribute) + else + attribute ||= schema.attribute(name) + [attribute.normalize_value(value)] + end + end + + def normalize_attribute_value_of_array(name, value, rubyish_class_name, + attribute) + attribute ||= schema.attribute(name) if value.size > 1 and attribute.single_value? format = _("Attribute %s can only have a single value") message = format % self.class.human_attribute_name(attribute) @@ -99,12 +105,13 @@ end else value.collect do |entry| - normalize_attribute(name, entry)[1][0] + normalize_attribute_value(name, entry, nil, attribute)[0] end end end - def normalize_attribute_value_of_hash(name, value) + def normalize_attribute_value_of_hash(name, value, rubyish_class_name, + attribute) if value.keys.size > 1 format = _("Hashes must have one key-value pair only: %s") raise TypeError, format % value.inspect @@ -115,8 +122,10 @@ format % value.keys[0] end end + # Contents MUST be a String or an Array - if !value.has_key?('binary') and schema.attribute(name).binary_required? + attribute ||= schema.attribute(name) + if !value.has_key?('binary') and attribute.binary_required? suffix, real_value = extract_attribute_options(value) name, values = normalize_attribute_options("#{name}#{suffix};binary", real_value) @@ -126,41 +135,48 @@ end end - def normalize_attribute_value_of_nil_class(name, value) - if schema.attribute(name).binary_required? + def normalize_attribute_value_of_nil_class(name, value, + rubyish_class_name, attribute) + attribute ||= schema.attribute(name) + if attribute.binary_required? [{'binary' => []}] else [] end end - def normalize_attribute_value_of_string(name, value) - if schema.attribute(name).binary_required? + def normalize_attribute_value_of_string(name, value, rubyish_class_name, + attribute) + attribute ||= schema.attribute(name) + if attribute.binary_required? [{'binary' => [value]}] else [value] end end - def normalize_attribute_value_of_date(name, value) + def normalize_attribute_value_of_date(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', value.year, value.month, value.mday, 0, 0, 0, '+0000') - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end - def normalize_attribute_value_of_time(name, value) + def normalize_attribute_value_of_time(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', 0, 0, 0, value.hour, value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end - def normalize_attribute_value_of_date_time(name, value) + def normalize_attribute_value_of_date_time(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', value.year, value.month, value.mday, value.hour, value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end # normalize_attribute_options From codesite-noreply at google.com Mon Jan 14 08:54:34 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 05:54:34 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r650 - trunk/lib/active_ldap Message-ID: <00163646c5a80443af0424dc968ba43@google.com> Author: koutou Date: Mon Jan 14 05:53:59 2008 New Revision: 650 Modified: trunk/lib/active_ldap/attributes.rb Log: * cached schema attribute. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 05:53:59 2008 @@ -47,13 +47,7 @@ end name = normalize_attribute_name(name) - rubyish_class_name = Inflector.underscore(value.class.name) - handler = "normalize_attribute_value_of_#{rubyish_class_name}" - if respond_to?(handler, true) - [name, send(handler, name, value)] - else - [name, [schema.attribute(name).normalize_value(value)]] - end + [name, normalize_attribute_value(name, value, nil, nil)] end def unnormalize_attributes(attributes) @@ -84,8 +78,20 @@ end private - def normalize_attribute_value_of_array(name, value) - attribute = schema.attribute(name) + def normalize_attribute_value(name, value, rubyish_class_name, attribute) + rubyish_class_name ||= Inflector.underscore(value.class.name) + handler = "normalize_attribute_value_of_#{rubyish_class_name}" + if respond_to?(handler, true) + send(handler, name, value, rubyish_class_name, attribute) + else + attribute ||= schema.attribute(name) + [attribute.normalize_value(value)] + end + end + + def normalize_attribute_value_of_array(name, value, rubyish_class_name, + attribute) + attribute ||= schema.attribute(name) if value.size > 1 and attribute.single_value? format = _("Attribute %s can only have a single value") message = format % self.class.human_attribute_name(attribute) @@ -99,12 +105,13 @@ end else value.collect do |entry| - normalize_attribute(name, entry)[1][0] + normalize_attribute_value(name, entry, nil, attribute)[0] end end end - def normalize_attribute_value_of_hash(name, value) + def normalize_attribute_value_of_hash(name, value, rubyish_class_name, + attribute) if value.keys.size > 1 format = _("Hashes must have one key-value pair only: %s") raise TypeError, format % value.inspect @@ -115,8 +122,10 @@ format % value.keys[0] end end + # Contents MUST be a String or an Array - if !value.has_key?('binary') and schema.attribute(name).binary_required? + attribute ||= schema.attribute(name) + if !value.has_key?('binary') and attribute.binary_required? suffix, real_value = extract_attribute_options(value) name, values = normalize_attribute_options("#{name}#{suffix};binary", real_value) @@ -126,41 +135,48 @@ end end - def normalize_attribute_value_of_nil_class(name, value) - if schema.attribute(name).binary_required? + def normalize_attribute_value_of_nil_class(name, value, + rubyish_class_name, attribute) + attribute ||= schema.attribute(name) + if attribute.binary_required? [{'binary' => []}] else [] end end - def normalize_attribute_value_of_string(name, value) - if schema.attribute(name).binary_required? + def normalize_attribute_value_of_string(name, value, rubyish_class_name, + attribute) + attribute ||= schema.attribute(name) + if attribute.binary_required? [{'binary' => [value]}] else [value] end end - def normalize_attribute_value_of_date(name, value) + def normalize_attribute_value_of_date(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', value.year, value.month, value.mday, 0, 0, 0, '+0000') - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end - def normalize_attribute_value_of_time(name, value) + def normalize_attribute_value_of_time(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', 0, 0, 0, value.hour, value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end - def normalize_attribute_value_of_date_time(name, value) + def normalize_attribute_value_of_date_time(name, value, rubyish_class_name, + attribute) new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', value.year, value.month, value.mday, value.hour, value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value) + normalize_attribute_value_of_string(name, new_value, nil, attribute) end # normalize_attribute_options From codesite-noreply at google.com Mon Jan 14 09:07:36 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 06:07:36 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r651 - trunk/lib/active_ldap Message-ID: <00163646d64e0443af32c2285a8d1b2@google.com> Author: koutou Date: Mon Jan 14 06:07:00 2008 New Revision: 651 Modified: trunk/lib/active_ldap/base.rb Log: * improved respond_to? performance. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 06:07:00 2008 @@ -672,10 +672,12 @@ alias_method :respond_to_without_attributes?, :respond_to? def respond_to?(name, include_priv=false) - have_attribute?(name.to_s) or - (/(?:=|\?|_before_type_cast)$/ =~ name.to_s and - have_attribute?($PREMATCH)) or - super + return true if super + + name = name.to_s + return true if have_attribute?(name) + return false if /(?:=|\?|_before_type_cast)$/ !~ name + have_attribute?($PREMATCH) end # Updates a given attribute and saves immediately From codesite-noreply at google.com Mon Jan 14 09:07:36 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 06:07:36 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r651 - trunk/lib/active_ldap Message-ID: <00163646d64e0443af32c2285a8d1b2@google.com> Author: koutou Date: Mon Jan 14 06:07:00 2008 New Revision: 651 Modified: trunk/lib/active_ldap/base.rb Log: * improved respond_to? performance. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 06:07:00 2008 @@ -672,10 +672,12 @@ alias_method :respond_to_without_attributes?, :respond_to? def respond_to?(name, include_priv=false) - have_attribute?(name.to_s) or - (/(?:=|\?|_before_type_cast)$/ =~ name.to_s and - have_attribute?($PREMATCH)) or - super + return true if super + + name = name.to_s + return true if have_attribute?(name) + return false if /(?:=|\?|_before_type_cast)$/ !~ name + have_attribute?($PREMATCH) end # Updates a given attribute and saves immediately From codesite-noreply at google.com Mon Jan 14 09:12:37 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 06:12:37 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r652 - trunk/lib/active_ldap Message-ID: <0016364592460443af44b3fca18cf41@google.com> Author: koutou Date: Mon Jan 14 06:12:15 2008 New Revision: 652 Modified: trunk/lib/active_ldap/base.rb Log: * hid @entry_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 06:12:15 2008 @@ -859,6 +859,7 @@ def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil + entry_attribute, @entry_attribute = @entry_attribute, nil schema, @schema = @schema, nil unless @abbreviating @abbreviating = true @@ -866,6 +867,7 @@ yield ensure @connection = connection + @entry_attribute = entry_attribute @schema = schema @abbreviating = false end From codesite-noreply at google.com Mon Jan 14 09:12:37 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 06:12:37 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r652 - trunk/lib/active_ldap Message-ID: <0016364592460443af44b3fca18cf41@google.com> Author: koutou Date: Mon Jan 14 06:12:15 2008 New Revision: 652 Modified: trunk/lib/active_ldap/base.rb Log: * hid @entry_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 06:12:15 2008 @@ -859,6 +859,7 @@ def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil + entry_attribute, @entry_attribute = @entry_attribute, nil schema, @schema = @schema, nil unless @abbreviating @abbreviating = true @@ -866,6 +867,7 @@ yield ensure @connection = connection + @entry_attribute = entry_attribute @schema = schema @abbreviating = false end From codesite-noreply at google.com Mon Jan 14 18:39:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:39:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r653 - trunk/benchmark Message-ID: <0016e64af3560443b72ef76b44b3a3a@google.com> Author: koutou Date: Mon Jan 14 15:38:25 2008 New Revision: 653 Modified: trunk/benchmark/bench-al.rb Log: * supported method: :tls. Modified: trunk/benchmark/bench-al.rb ============================================================================== --- trunk/benchmark/bench-al.rb (original) +++ trunk/benchmark/bench-al.rb Mon Jan 14 15:38:25 2008 @@ -26,6 +26,7 @@ LDAP_PREFIX = options.prefix LDAP_USER = config[:bind_dn] LDAP_PASSWORD = config[:password] +LDAP_METHOD = config[:method] class ALUser < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid', :prefix => LDAP_PREFIX, @@ -74,7 +75,11 @@ def ldap_connection require 'ldap' - conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT) + if LDAP_METHOD == :tls + conn = LDAP::SSLConn.new(LDAP_HOST, LDAP_PORT, true) + else + conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT) + end conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3) conn.bind(LDAP_USER, LDAP_PASSWORD) if LDAP_USER and LDAP_PASSWORD conn @@ -87,6 +92,7 @@ net_ldap_conn = Net::LDAP::Connection.new(:host => LDAP_HOST, :port => LDAP_PORT) if LDAP_USER and LDAP_PASSWORD + net_ldap_conn.setup_encryption(:method => :start_tls) if LDAP_METHOD == :tls net_ldap_conn.bind(:method => :simple, :username => LDAP_USER, :password => LDAP_PASSWORD) From codesite-noreply at google.com Mon Jan 14 18:39:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:39:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r653 - trunk/benchmark Message-ID: <0016e64af3560443b72ef76b44b3a3a@google.com> Author: koutou Date: Mon Jan 14 15:38:25 2008 New Revision: 653 Modified: trunk/benchmark/bench-al.rb Log: * supported method: :tls. Modified: trunk/benchmark/bench-al.rb ============================================================================== --- trunk/benchmark/bench-al.rb (original) +++ trunk/benchmark/bench-al.rb Mon Jan 14 15:38:25 2008 @@ -26,6 +26,7 @@ LDAP_PREFIX = options.prefix LDAP_USER = config[:bind_dn] LDAP_PASSWORD = config[:password] +LDAP_METHOD = config[:method] class ALUser < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid', :prefix => LDAP_PREFIX, @@ -74,7 +75,11 @@ def ldap_connection require 'ldap' - conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT) + if LDAP_METHOD == :tls + conn = LDAP::SSLConn.new(LDAP_HOST, LDAP_PORT, true) + else + conn = LDAP::Conn.new(LDAP_HOST, LDAP_PORT) + end conn.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3) conn.bind(LDAP_USER, LDAP_PASSWORD) if LDAP_USER and LDAP_PASSWORD conn @@ -87,6 +92,7 @@ net_ldap_conn = Net::LDAP::Connection.new(:host => LDAP_HOST, :port => LDAP_PORT) if LDAP_USER and LDAP_PASSWORD + net_ldap_conn.setup_encryption(:method => :start_tls) if LDAP_METHOD == :tls net_ldap_conn.bind(:method => :simple, :username => LDAP_USER, :password => LDAP_PASSWORD) From codesite-noreply at google.com Mon Jan 14 18:48:14 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:48:14 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r654 - trunk/lib/active_ldap Message-ID: <00163646d7ec0443b74f428017b2c16@google.com> Author: koutou Date: Mon Jan 14 15:47:19 2008 New Revision: 654 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/object_class.rb trunk/lib/active_ldap/validations.rb Log: * removed ensure_apply_object_class. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 15:47:19 2008 @@ -473,13 +473,13 @@ initial_classes = required_classes | recommended_classes case attributes when nil - apply_object_class(initial_classes) + self.classes = initial_classes when String, Array, DN - apply_object_class(initial_classes) + self.classes = initial_classes self.dn = attributes when Hash classes, attributes = extract_object_class(attributes) - apply_object_class(classes | initial_classes) + self.classes = classes | initial_classes normalized_attributes = {} attributes.each do |key, value| real_key = to_real_attribute_name(key) || key @@ -519,12 +519,10 @@ end def may - ensure_apply_object_class entry_attribute.may end def must - ensure_apply_object_class entry_attribute.must end @@ -533,7 +531,6 @@ # Return attribute methods so that a program can determine available # attributes dynamically without schema awareness def attribute_names(normalize=false) - ensure_apply_object_class entry_attribute.names(normalize) end @@ -626,8 +623,6 @@ # using class_eval instead of using method_missing. This would # give tab completion in irb. def method_missing(name, *args, &block) - ensure_apply_object_class - key = name.to_s case key when /=$/ @@ -662,7 +657,6 @@ # Add available attributes to the methods def methods(inherited_too=true) - ensure_apply_object_class target_names = entry_attribute.all_names target_names -= ['objectClass', Inflector.underscore('objectClass')] super + target_names.uniq.collect do |x| @@ -763,7 +757,7 @@ @ldap_data.update(attributes) classes, attributes = extract_object_class(attributes) - apply_object_class(classes) + self.classes = classes self.attributes = attributes @new_entry = false self @@ -897,7 +891,7 @@ @dn_is_base = false @ldap_data = attributes classes, attributes = extract_object_class(attributes) - apply_object_class(classes) + self.classes = classes self.dn = dn self.attributes = attributes yield self if block_given? @@ -918,23 +912,15 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? - ensure_apply_object_class entry_attribute.normalize(name, allow_normalized_name) end - def ensure_apply_object_class - current_object_class = @data['objectClass'] - return if current_object_class.nil? or current_object_class == @last_oc - apply_object_class(current_object_class) - end - # enforce_type # # enforce_type applies your changes without attempting to write to LDAP. # This means that if you set userCertificate to somebinary value, it will # wrap it up correctly. def enforce_type(key, value) - ensure_apply_object_class # Enforce attribute value formatting normalize_attribute(key, value)[1] end @@ -943,30 +929,11 @@ @mutex = Mutex.new @data = {} # where the r/w entry data is stored @ldap_data = {} # original ldap entry data - @last_oc = false # for use in other methods for "caching" @dn_attribute = nil @base = nil @scope = nil @dn = nil @connection ||= nil - end - - # apply_object_class - # - # objectClass= special case for updating appropriately - # This updates the objectClass entry in @data. It also - # updating all required and allowed attributes while - # removing defined attributes that are no longer valid - # given the new objectclasses. - def apply_object_class(val) - new_oc = val - new_oc = [val] if new_oc.class != Array - new_oc = new_oc.uniq - return new_oc if @last_oc == new_oc - - @last_oc = new_oc.dup - replace_class(*new_oc) - @entry_attribute = nil end # get_attribute Modified: trunk/lib/active_ldap/object_class.rb ============================================================================== --- trunk/lib/active_ldap/object_class.rb (original) +++ trunk/lib/active_ldap/object_class.rb Mon Jan 14 15:47:19 2008 @@ -29,6 +29,7 @@ assert_object_classes(new_classes) if new_classes.sort != classes.sort set_attribute('objectClass', new_classes) + @entry_attribute = nil end end alias_method(:classes=, :replace_class) Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 15:47:19 2008 @@ -51,11 +51,6 @@ end alias_method_chain :save!, :active_ldap_support - def valid? - ensure_apply_object_class - super - end - private def run_validations_with_active_ldap_support(validation_method) run_validations_without_active_ldap_support(validation_method) From codesite-noreply at google.com Mon Jan 14 18:48:14 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:48:14 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r654 - trunk/lib/active_ldap Message-ID: <00163646d7ec0443b74f428017b2c16@google.com> Author: koutou Date: Mon Jan 14 15:47:19 2008 New Revision: 654 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/object_class.rb trunk/lib/active_ldap/validations.rb Log: * removed ensure_apply_object_class. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 15:47:19 2008 @@ -473,13 +473,13 @@ initial_classes = required_classes | recommended_classes case attributes when nil - apply_object_class(initial_classes) + self.classes = initial_classes when String, Array, DN - apply_object_class(initial_classes) + self.classes = initial_classes self.dn = attributes when Hash classes, attributes = extract_object_class(attributes) - apply_object_class(classes | initial_classes) + self.classes = classes | initial_classes normalized_attributes = {} attributes.each do |key, value| real_key = to_real_attribute_name(key) || key @@ -519,12 +519,10 @@ end def may - ensure_apply_object_class entry_attribute.may end def must - ensure_apply_object_class entry_attribute.must end @@ -533,7 +531,6 @@ # Return attribute methods so that a program can determine available # attributes dynamically without schema awareness def attribute_names(normalize=false) - ensure_apply_object_class entry_attribute.names(normalize) end @@ -626,8 +623,6 @@ # using class_eval instead of using method_missing. This would # give tab completion in irb. def method_missing(name, *args, &block) - ensure_apply_object_class - key = name.to_s case key when /=$/ @@ -662,7 +657,6 @@ # Add available attributes to the methods def methods(inherited_too=true) - ensure_apply_object_class target_names = entry_attribute.all_names target_names -= ['objectClass', Inflector.underscore('objectClass')] super + target_names.uniq.collect do |x| @@ -763,7 +757,7 @@ @ldap_data.update(attributes) classes, attributes = extract_object_class(attributes) - apply_object_class(classes) + self.classes = classes self.attributes = attributes @new_entry = false self @@ -897,7 +891,7 @@ @dn_is_base = false @ldap_data = attributes classes, attributes = extract_object_class(attributes) - apply_object_class(classes) + self.classes = classes self.dn = dn self.attributes = attributes yield self if block_given? @@ -918,23 +912,15 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? - ensure_apply_object_class entry_attribute.normalize(name, allow_normalized_name) end - def ensure_apply_object_class - current_object_class = @data['objectClass'] - return if current_object_class.nil? or current_object_class == @last_oc - apply_object_class(current_object_class) - end - # enforce_type # # enforce_type applies your changes without attempting to write to LDAP. # This means that if you set userCertificate to somebinary value, it will # wrap it up correctly. def enforce_type(key, value) - ensure_apply_object_class # Enforce attribute value formatting normalize_attribute(key, value)[1] end @@ -943,30 +929,11 @@ @mutex = Mutex.new @data = {} # where the r/w entry data is stored @ldap_data = {} # original ldap entry data - @last_oc = false # for use in other methods for "caching" @dn_attribute = nil @base = nil @scope = nil @dn = nil @connection ||= nil - end - - # apply_object_class - # - # objectClass= special case for updating appropriately - # This updates the objectClass entry in @data. It also - # updating all required and allowed attributes while - # removing defined attributes that are no longer valid - # given the new objectclasses. - def apply_object_class(val) - new_oc = val - new_oc = [val] if new_oc.class != Array - new_oc = new_oc.uniq - return new_oc if @last_oc == new_oc - - @last_oc = new_oc.dup - replace_class(*new_oc) - @entry_attribute = nil end # get_attribute Modified: trunk/lib/active_ldap/object_class.rb ============================================================================== --- trunk/lib/active_ldap/object_class.rb (original) +++ trunk/lib/active_ldap/object_class.rb Mon Jan 14 15:47:19 2008 @@ -29,6 +29,7 @@ assert_object_classes(new_classes) if new_classes.sort != classes.sort set_attribute('objectClass', new_classes) + @entry_attribute = nil end end alias_method(:classes=, :replace_class) Modified: trunk/lib/active_ldap/validations.rb ============================================================================== --- trunk/lib/active_ldap/validations.rb (original) +++ trunk/lib/active_ldap/validations.rb Mon Jan 14 15:47:19 2008 @@ -51,11 +51,6 @@ end alias_method_chain :save!, :active_ldap_support - def valid? - ensure_apply_object_class - super - end - private def run_validations_with_active_ldap_support(validation_method) run_validations_without_active_ldap_support(validation_method) From codesite-noreply at google.com Mon Jan 14 18:52:15 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:52:15 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r655 - trunk/lib/active_ldap Message-ID: <00163646d64e0443b75d96a619b4399@google.com> Author: koutou Date: Mon Jan 14 15:51:23 2008 New Revision: 655 Modified: trunk/lib/active_ldap/base.rb Log: * cleanup. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 15:51:23 2008 @@ -796,8 +796,7 @@ @connection = nil connection.connect @connection = connection - @schema = nil - @entry_attribute = nil + clear_connection_based_cache clear_association_cache rescue ActiveLdap::Error remove_connection @@ -805,6 +804,11 @@ raise end true + end + + def clear_connection_based_cache + @schema = nil + @entry_attribute = nil end def schema From codesite-noreply at google.com Mon Jan 14 18:52:15 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 15:52:15 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r655 - trunk/lib/active_ldap Message-ID: <00163646d64e0443b75d96a619b4399@google.com> Author: koutou Date: Mon Jan 14 15:51:23 2008 New Revision: 655 Modified: trunk/lib/active_ldap/base.rb Log: * cleanup. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 15:51:23 2008 @@ -796,8 +796,7 @@ @connection = nil connection.connect @connection = connection - @schema = nil - @entry_attribute = nil + clear_connection_based_cache clear_association_cache rescue ActiveLdap::Error remove_connection @@ -805,6 +804,11 @@ raise end true + end + + def clear_connection_based_cache + @schema = nil + @entry_attribute = nil end def schema From codesite-noreply at google.com Mon Jan 14 19:32:22 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 16:32:22 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r656 - trunk/lib/active_ldap Message-ID: <000e0cd32cca0443b7ed10ca22604c@google.com> Author: koutou Date: Mon Jan 14 16:32:03 2008 New Revision: 656 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/entry_attribute.rb Log: * cleanup. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 16:32:03 2008 @@ -3,8 +3,8 @@ def self.included(base) base.class_eval do extend(ClassMethods) - extend(Normalize) - include(Normalize) + extend(Normalizable) + include(Normalizable) end end @@ -32,7 +32,7 @@ end end - module Normalize + module Normalizable def normalize_attribute_name(name) name.to_s.downcase end @@ -47,7 +47,7 @@ end name = normalize_attribute_name(name) - [name, normalize_attribute_value(name, value, nil, nil)] + [name, Normalizer.new(name, value, self).normalize] end def unnormalize_attributes(attributes) @@ -64,7 +64,7 @@ else values.each do |value| if value.is_a?(Hash) - suffix, real_value = extract_attribute_options(value) + suffix, real_value = unnormalize_attribute_options(value) new_name = name + suffix result[new_name] ||= [] result[new_name].concat(real_value) @@ -77,108 +77,6 @@ result end - private - def normalize_attribute_value(name, value, rubyish_class_name, attribute) - rubyish_class_name ||= Inflector.underscore(value.class.name) - handler = "normalize_attribute_value_of_#{rubyish_class_name}" - if respond_to?(handler, true) - send(handler, name, value, rubyish_class_name, attribute) - else - attribute ||= schema.attribute(name) - [attribute.normalize_value(value)] - end - end - - def normalize_attribute_value_of_array(name, value, rubyish_class_name, - attribute) - attribute ||= schema.attribute(name) - if value.size > 1 and attribute.single_value? - format = _("Attribute %s can only have a single value") - message = format % self.class.human_attribute_name(attribute) - raise TypeError, message - end - if value.empty? - if attribute.binary_required? - [{'binary' => value}] - else - value - end - else - value.collect do |entry| - normalize_attribute_value(name, entry, nil, attribute)[0] - end - end - end - - def normalize_attribute_value_of_hash(name, value, rubyish_class_name, - attribute) - if value.keys.size > 1 - format = _("Hashes must have one key-value pair only: %s") - raise TypeError, format % value.inspect - end - unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) - logger.warn do - format = _("unknown option did not match lang-* or binary: %s") - format % value.keys[0] - end - end - - # Contents MUST be a String or an Array - attribute ||= schema.attribute(name) - if !value.has_key?('binary') and attribute.binary_required? - suffix, real_value = extract_attribute_options(value) - name, values = - normalize_attribute_options("#{name}#{suffix};binary", real_value) - values - else - [value] - end - end - - def normalize_attribute_value_of_nil_class(name, value, - rubyish_class_name, attribute) - attribute ||= schema.attribute(name) - if attribute.binary_required? - [{'binary' => []}] - else - [] - end - end - - def normalize_attribute_value_of_string(name, value, rubyish_class_name, - attribute) - attribute ||= schema.attribute(name) - if attribute.binary_required? - [{'binary' => [value]}] - else - [value] - end - end - - def normalize_attribute_value_of_date(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, 0, 0, 0, - '+0000') - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - - def normalize_attribute_value_of_time(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - 0, 0, 0, value.hour, value.min, value.sec, - value.zone) - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - - def normalize_attribute_value_of_date_time(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, value.hour, - value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - # normalize_attribute_options # # Makes the Hashized value from the full attribute name @@ -192,23 +90,132 @@ [options.reverse.inject(value) {|result, option| {option => result}}]] end - # extract_attribute_options + # unnormalize_attribute_options # - # Extracts all of the subtypes from a given set of nested hashes + # Unnormalizes all of the subtypes from a given set of nested hashes # and returns the attribute suffix and the final true value - def extract_attribute_options(value) + def unnormalize_attribute_options(value) options = '' ret_val = value if value.class == Hash options = ';' + value.keys[0] ret_val = value[value.keys[0]] if ret_val.class == Hash - sub_options, ret_val = extract_attribute_options(ret_val) + sub_options, ret_val = unnormalize_attribute_options(ret_val) options += sub_options end end ret_val = [ret_val] unless ret_val.class == Array [options, ret_val] + end + + class Normalizer + include GetTextSupport + + def initialize(name, value, target) + @name = name + @value = value + @target = target + @attribute = nil + end + + def normalize + _normalize(@value) + end + + private + def attribute + @attribute ||= @target.schema.attribute(@name) + end + + def _normalize(value) + rubyish_class_name = Inflector.underscore(value.class.name) + handler = "normalize_#{rubyish_class_name}" + if respond_to?(handler, true) + send(handler, value) + else + [attribute.normalize_value(value)] + end + end + + def normalize_array(value) + if value.size > 1 and attribute.single_value? + format = _("Attribute %s can only have a single value") + message = format % target.class.human_attribute_name(attribute) + raise TypeError, message + end + if value.empty? + if attribute.binary_required? + [{'binary' => value}] + else + value + end + else + value.collect do |entry| + _normalize(entry)[0] + end + end + end + + def normalize_hash(value) + if value.keys.size > 1 + format = _("Hashes must have one key-value pair only: %s") + raise TypeError, format % value.inspect + end + unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) + logger.warn do + format = _("unknown option did not match lang-* or binary: %s") + format % value.keys[0] + end + end + + # Contents MUST be a String or an Array + if !value.has_key?('binary') and attribute.binary_required? + suffix, real_value = @target.unnormalize_attribute_options(value) + name = "#{@name}#{suffix};binary" + name, values = @target.normalize_attribute_options(name, real_value) + values + else + [value] + end + end + + def normalize_nil_class(value) + if attribute.binary_required? + [{'binary' => []}] + else + [] + end + end + + def normalize_string(value) + if attribute.binary_required? + [{'binary' => [value]}] + else + [value] + end + end + + def normalize_date(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + value.year, value.month, value.mday, 0, 0, 0, + '+0000') + normalize_string(new_value) + end + + def normalize_time(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + 0, 0, 0, value.hour, value.min, value.sec, + value.zone) + normalize_string(new_value) + end + + def normalize_date_time(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + value.year, value.month, value.mday, value.hour, + value.min, value.sec, value.zone) + normalize_string(new_value) + end end end Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 16:32:03 2008 @@ -2,7 +2,7 @@ module ActiveLdap class EntryAttribute - include Attributes::Normalize + include Attributes::Normalizable attr_reader :must, :may, :object_classes, :schemata def initialize(schema, object_classes) From codesite-noreply at google.com Mon Jan 14 19:32:22 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 16:32:22 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r656 - trunk/lib/active_ldap Message-ID: <000e0cd32cca0443b7ed10ca22604c@google.com> Author: koutou Date: Mon Jan 14 16:32:03 2008 New Revision: 656 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/entry_attribute.rb Log: * cleanup. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 16:32:03 2008 @@ -3,8 +3,8 @@ def self.included(base) base.class_eval do extend(ClassMethods) - extend(Normalize) - include(Normalize) + extend(Normalizable) + include(Normalizable) end end @@ -32,7 +32,7 @@ end end - module Normalize + module Normalizable def normalize_attribute_name(name) name.to_s.downcase end @@ -47,7 +47,7 @@ end name = normalize_attribute_name(name) - [name, normalize_attribute_value(name, value, nil, nil)] + [name, Normalizer.new(name, value, self).normalize] end def unnormalize_attributes(attributes) @@ -64,7 +64,7 @@ else values.each do |value| if value.is_a?(Hash) - suffix, real_value = extract_attribute_options(value) + suffix, real_value = unnormalize_attribute_options(value) new_name = name + suffix result[new_name] ||= [] result[new_name].concat(real_value) @@ -77,108 +77,6 @@ result end - private - def normalize_attribute_value(name, value, rubyish_class_name, attribute) - rubyish_class_name ||= Inflector.underscore(value.class.name) - handler = "normalize_attribute_value_of_#{rubyish_class_name}" - if respond_to?(handler, true) - send(handler, name, value, rubyish_class_name, attribute) - else - attribute ||= schema.attribute(name) - [attribute.normalize_value(value)] - end - end - - def normalize_attribute_value_of_array(name, value, rubyish_class_name, - attribute) - attribute ||= schema.attribute(name) - if value.size > 1 and attribute.single_value? - format = _("Attribute %s can only have a single value") - message = format % self.class.human_attribute_name(attribute) - raise TypeError, message - end - if value.empty? - if attribute.binary_required? - [{'binary' => value}] - else - value - end - else - value.collect do |entry| - normalize_attribute_value(name, entry, nil, attribute)[0] - end - end - end - - def normalize_attribute_value_of_hash(name, value, rubyish_class_name, - attribute) - if value.keys.size > 1 - format = _("Hashes must have one key-value pair only: %s") - raise TypeError, format % value.inspect - end - unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) - logger.warn do - format = _("unknown option did not match lang-* or binary: %s") - format % value.keys[0] - end - end - - # Contents MUST be a String or an Array - attribute ||= schema.attribute(name) - if !value.has_key?('binary') and attribute.binary_required? - suffix, real_value = extract_attribute_options(value) - name, values = - normalize_attribute_options("#{name}#{suffix};binary", real_value) - values - else - [value] - end - end - - def normalize_attribute_value_of_nil_class(name, value, - rubyish_class_name, attribute) - attribute ||= schema.attribute(name) - if attribute.binary_required? - [{'binary' => []}] - else - [] - end - end - - def normalize_attribute_value_of_string(name, value, rubyish_class_name, - attribute) - attribute ||= schema.attribute(name) - if attribute.binary_required? - [{'binary' => [value]}] - else - [value] - end - end - - def normalize_attribute_value_of_date(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, 0, 0, 0, - '+0000') - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - - def normalize_attribute_value_of_time(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - 0, 0, 0, value.hour, value.min, value.sec, - value.zone) - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - - def normalize_attribute_value_of_date_time(name, value, rubyish_class_name, - attribute) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, value.hour, - value.min, value.sec, value.zone) - normalize_attribute_value_of_string(name, new_value, nil, attribute) - end - # normalize_attribute_options # # Makes the Hashized value from the full attribute name @@ -192,23 +90,132 @@ [options.reverse.inject(value) {|result, option| {option => result}}]] end - # extract_attribute_options + # unnormalize_attribute_options # - # Extracts all of the subtypes from a given set of nested hashes + # Unnormalizes all of the subtypes from a given set of nested hashes # and returns the attribute suffix and the final true value - def extract_attribute_options(value) + def unnormalize_attribute_options(value) options = '' ret_val = value if value.class == Hash options = ';' + value.keys[0] ret_val = value[value.keys[0]] if ret_val.class == Hash - sub_options, ret_val = extract_attribute_options(ret_val) + sub_options, ret_val = unnormalize_attribute_options(ret_val) options += sub_options end end ret_val = [ret_val] unless ret_val.class == Array [options, ret_val] + end + + class Normalizer + include GetTextSupport + + def initialize(name, value, target) + @name = name + @value = value + @target = target + @attribute = nil + end + + def normalize + _normalize(@value) + end + + private + def attribute + @attribute ||= @target.schema.attribute(@name) + end + + def _normalize(value) + rubyish_class_name = Inflector.underscore(value.class.name) + handler = "normalize_#{rubyish_class_name}" + if respond_to?(handler, true) + send(handler, value) + else + [attribute.normalize_value(value)] + end + end + + def normalize_array(value) + if value.size > 1 and attribute.single_value? + format = _("Attribute %s can only have a single value") + message = format % target.class.human_attribute_name(attribute) + raise TypeError, message + end + if value.empty? + if attribute.binary_required? + [{'binary' => value}] + else + value + end + else + value.collect do |entry| + _normalize(entry)[0] + end + end + end + + def normalize_hash(value) + if value.keys.size > 1 + format = _("Hashes must have one key-value pair only: %s") + raise TypeError, format % value.inspect + end + unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) + logger.warn do + format = _("unknown option did not match lang-* or binary: %s") + format % value.keys[0] + end + end + + # Contents MUST be a String or an Array + if !value.has_key?('binary') and attribute.binary_required? + suffix, real_value = @target.unnormalize_attribute_options(value) + name = "#{@name}#{suffix};binary" + name, values = @target.normalize_attribute_options(name, real_value) + values + else + [value] + end + end + + def normalize_nil_class(value) + if attribute.binary_required? + [{'binary' => []}] + else + [] + end + end + + def normalize_string(value) + if attribute.binary_required? + [{'binary' => [value]}] + else + [value] + end + end + + def normalize_date(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + value.year, value.month, value.mday, 0, 0, 0, + '+0000') + normalize_string(new_value) + end + + def normalize_time(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + 0, 0, 0, value.hour, value.min, value.sec, + value.zone) + normalize_string(new_value) + end + + def normalize_date_time(value) + new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', + value.year, value.month, value.mday, value.hour, + value.min, value.sec, value.zone) + normalize_string(new_value) + end end end Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 16:32:03 2008 @@ -2,7 +2,7 @@ module ActiveLdap class EntryAttribute - include Attributes::Normalize + include Attributes::Normalizable attr_reader :must, :may, :object_classes, :schemata def initialize(schema, object_classes) From codesite-noreply at google.com Mon Jan 14 20:32:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 17:32:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r657 - trunk/lib/active_ldap Message-ID: <000e0cd228820443b8c3f2b227610a@google.com> Author: koutou Date: Mon Jan 14 17:31:25 2008 New Revision: 657 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/base.rb Log: * cached rubyish class name. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 17:31:25 2008 @@ -112,6 +112,8 @@ class Normalizer include GetTextSupport + @@rubyish_class_names = {} + def initialize(name, value, target) @name = name @value = value @@ -128,9 +130,13 @@ @attribute ||= @target.schema.attribute(@name) end + def rubyish_class_name(value) + klass = value.class + @@rubyish_class_names[klass] ||= Inflector.underscore(klass.name) + end + def _normalize(value) - rubyish_class_name = Inflector.underscore(value.class.name) - handler = "normalize_#{rubyish_class_name}" + handler = "normalize_#{rubyish_class_name(value)}" if respond_to?(handler, true) send(handler, value) else Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 17:31:25 2008 @@ -706,7 +706,6 @@ # Do not let URL/form hackers supply the keys. def attributes=(new_attributes) return if new_attributes.nil? - _schema = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| send("#{key}=", value) From codesite-noreply at google.com Mon Jan 14 20:32:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 17:32:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r657 - trunk/lib/active_ldap Message-ID: <000e0cd228820443b8c3f2b227610a@google.com> Author: koutou Date: Mon Jan 14 17:31:25 2008 New Revision: 657 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/base.rb Log: * cached rubyish class name. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 17:31:25 2008 @@ -112,6 +112,8 @@ class Normalizer include GetTextSupport + @@rubyish_class_names = {} + def initialize(name, value, target) @name = name @value = value @@ -128,9 +130,13 @@ @attribute ||= @target.schema.attribute(@name) end + def rubyish_class_name(value) + klass = value.class + @@rubyish_class_names[klass] ||= Inflector.underscore(klass.name) + end + def _normalize(value) - rubyish_class_name = Inflector.underscore(value.class.name) - handler = "normalize_#{rubyish_class_name}" + handler = "normalize_#{rubyish_class_name(value)}" if respond_to?(handler, true) send(handler, value) else Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 17:31:25 2008 @@ -706,7 +706,6 @@ # Do not let URL/form hackers supply the keys. def attributes=(new_attributes) return if new_attributes.nil? - _schema = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| send("#{key}=", value) From codesite-noreply at google.com Mon Jan 14 21:13:33 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:13:33 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r658 - trunk/lib/active_ldap Message-ID: <001636e0a64a0443b956f3208060c4@google.com> Author: koutou Date: Mon Jan 14 18:12:57 2008 New Revision: 658 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/schema.rb Log: * cleanup. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 18:12:57 2008 @@ -47,7 +47,7 @@ end name = normalize_attribute_name(name) - [name, Normalizer.new(name, value, self).normalize] + [name, schema.attribute(name).normalize_value(value)] end def unnormalize_attributes(attributes) @@ -107,121 +107,6 @@ end ret_val = [ret_val] unless ret_val.class == Array [options, ret_val] - end - - class Normalizer - include GetTextSupport - - @@rubyish_class_names = {} - - def initialize(name, value, target) - @name = name - @value = value - @target = target - @attribute = nil - end - - def normalize - _normalize(@value) - end - - private - def attribute - @attribute ||= @target.schema.attribute(@name) - end - - def rubyish_class_name(value) - klass = value.class - @@rubyish_class_names[klass] ||= Inflector.underscore(klass.name) - end - - def _normalize(value) - handler = "normalize_#{rubyish_class_name(value)}" - if respond_to?(handler, true) - send(handler, value) - else - [attribute.normalize_value(value)] - end - end - - def normalize_array(value) - if value.size > 1 and attribute.single_value? - format = _("Attribute %s can only have a single value") - message = format % target.class.human_attribute_name(attribute) - raise TypeError, message - end - if value.empty? - if attribute.binary_required? - [{'binary' => value}] - else - value - end - else - value.collect do |entry| - _normalize(entry)[0] - end - end - end - - def normalize_hash(value) - if value.keys.size > 1 - format = _("Hashes must have one key-value pair only: %s") - raise TypeError, format % value.inspect - end - unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) - logger.warn do - format = _("unknown option did not match lang-* or binary: %s") - format % value.keys[0] - end - end - - # Contents MUST be a String or an Array - if !value.has_key?('binary') and attribute.binary_required? - suffix, real_value = @target.unnormalize_attribute_options(value) - name = "#{@name}#{suffix};binary" - name, values = @target.normalize_attribute_options(name, real_value) - values - else - [value] - end - end - - def normalize_nil_class(value) - if attribute.binary_required? - [{'binary' => []}] - else - [] - end - end - - def normalize_string(value) - if attribute.binary_required? - [{'binary' => [value]}] - else - [value] - end - end - - def normalize_date(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, 0, 0, 0, - '+0000') - normalize_string(new_value) - end - - def normalize_time(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - 0, 0, 0, value.hour, value.min, value.sec, - value.zone) - normalize_string(new_value) - end - - def normalize_date_time(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, value.hour, - value.min, value.sec, value.zone) - normalize_string(new_value) - end end end Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:12:57 2008 @@ -349,6 +349,8 @@ end class Attribute < Entry + include GetTextSupport + attr_reader :super_attribute def initialize(name, schema) super(name, schema, "attributeTypes") @@ -403,7 +405,23 @@ end def normalize_value(value) - send_to_syntax(value, :normalize_value, value) + case value + when Array + normalize_array_value(value) + when Hash + normalize_hash_value(value) + else + if value.nil? + value = [] + else + value = send_to_syntax(value, :normalize_value, value) + end + if binary_required? + [{'binary' => value}] + else + [value] + end + end end def syntax_description @@ -447,6 +465,54 @@ _syntax.send(method_name, *args) else default_value + end + end + + def normalize_array_value(value) + if value.size > 1 and single_value? + format = _("Attribute %s can only have a single value") + message = format % target.class.human_attribute_name(attribute) + raise TypeError, message + end + if value.empty? + if binary_required? + [{'binary' => value}] + else + value + end + else + value.collect do |entry| + normalize_value(entry)[0] + end + end + end + + def normalize_hash_value(value) + if value.size > 1 + format = _("Hashes must have one key-value pair only: %s") + raise TypeError, format % value.inspect + end + + if binary_required? and !have_binary_key?(value) + [append_binary_key(value)] + else + [value] + end + end + + def have_binary_key?(hash) + key, value = hash.to_a[0] + return true if key == "binary" + return have_binary_key?(value) if value.is_a?(Hash) + false + end + + def append_binary_key(hash) + key, value = hash.to_a[0] + if value.is_a?(Hash) + append_binary_key(value) + else + hash.merge(key => {"binary" => value}) end end end From codesite-noreply at google.com Mon Jan 14 21:13:33 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:13:33 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r658 - trunk/lib/active_ldap Message-ID: <001636e0a64a0443b956f3208060c4@google.com> Author: koutou Date: Mon Jan 14 18:12:57 2008 New Revision: 658 Modified: trunk/lib/active_ldap/attributes.rb trunk/lib/active_ldap/schema.rb Log: * cleanup. Modified: trunk/lib/active_ldap/attributes.rb ============================================================================== --- trunk/lib/active_ldap/attributes.rb (original) +++ trunk/lib/active_ldap/attributes.rb Mon Jan 14 18:12:57 2008 @@ -47,7 +47,7 @@ end name = normalize_attribute_name(name) - [name, Normalizer.new(name, value, self).normalize] + [name, schema.attribute(name).normalize_value(value)] end def unnormalize_attributes(attributes) @@ -107,121 +107,6 @@ end ret_val = [ret_val] unless ret_val.class == Array [options, ret_val] - end - - class Normalizer - include GetTextSupport - - @@rubyish_class_names = {} - - def initialize(name, value, target) - @name = name - @value = value - @target = target - @attribute = nil - end - - def normalize - _normalize(@value) - end - - private - def attribute - @attribute ||= @target.schema.attribute(@name) - end - - def rubyish_class_name(value) - klass = value.class - @@rubyish_class_names[klass] ||= Inflector.underscore(klass.name) - end - - def _normalize(value) - handler = "normalize_#{rubyish_class_name(value)}" - if respond_to?(handler, true) - send(handler, value) - else - [attribute.normalize_value(value)] - end - end - - def normalize_array(value) - if value.size > 1 and attribute.single_value? - format = _("Attribute %s can only have a single value") - message = format % target.class.human_attribute_name(attribute) - raise TypeError, message - end - if value.empty? - if attribute.binary_required? - [{'binary' => value}] - else - value - end - else - value.collect do |entry| - _normalize(entry)[0] - end - end - end - - def normalize_hash(value) - if value.keys.size > 1 - format = _("Hashes must have one key-value pair only: %s") - raise TypeError, format % value.inspect - end - unless value.keys[0].match(/^(lang-[a-z][a-z]*)|(binary)$/) - logger.warn do - format = _("unknown option did not match lang-* or binary: %s") - format % value.keys[0] - end - end - - # Contents MUST be a String or an Array - if !value.has_key?('binary') and attribute.binary_required? - suffix, real_value = @target.unnormalize_attribute_options(value) - name = "#{@name}#{suffix};binary" - name, values = @target.normalize_attribute_options(name, real_value) - values - else - [value] - end - end - - def normalize_nil_class(value) - if attribute.binary_required? - [{'binary' => []}] - else - [] - end - end - - def normalize_string(value) - if attribute.binary_required? - [{'binary' => [value]}] - else - [value] - end - end - - def normalize_date(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, 0, 0, 0, - '+0000') - normalize_string(new_value) - end - - def normalize_time(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - 0, 0, 0, value.hour, value.min, value.sec, - value.zone) - normalize_string(new_value) - end - - def normalize_date_time(value) - new_value = sprintf('%.04d%.02d%.02d%.02d%.02d%.02d%s', - value.year, value.month, value.mday, value.hour, - value.min, value.sec, value.zone) - normalize_string(new_value) - end end end Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:12:57 2008 @@ -349,6 +349,8 @@ end class Attribute < Entry + include GetTextSupport + attr_reader :super_attribute def initialize(name, schema) super(name, schema, "attributeTypes") @@ -403,7 +405,23 @@ end def normalize_value(value) - send_to_syntax(value, :normalize_value, value) + case value + when Array + normalize_array_value(value) + when Hash + normalize_hash_value(value) + else + if value.nil? + value = [] + else + value = send_to_syntax(value, :normalize_value, value) + end + if binary_required? + [{'binary' => value}] + else + [value] + end + end end def syntax_description @@ -447,6 +465,54 @@ _syntax.send(method_name, *args) else default_value + end + end + + def normalize_array_value(value) + if value.size > 1 and single_value? + format = _("Attribute %s can only have a single value") + message = format % target.class.human_attribute_name(attribute) + raise TypeError, message + end + if value.empty? + if binary_required? + [{'binary' => value}] + else + value + end + else + value.collect do |entry| + normalize_value(entry)[0] + end + end + end + + def normalize_hash_value(value) + if value.size > 1 + format = _("Hashes must have one key-value pair only: %s") + raise TypeError, format % value.inspect + end + + if binary_required? and !have_binary_key?(value) + [append_binary_key(value)] + else + [value] + end + end + + def have_binary_key?(hash) + key, value = hash.to_a[0] + return true if key == "binary" + return have_binary_key?(value) if value.is_a?(Hash) + false + end + + def append_binary_key(hash) + key, value = hash.to_a[0] + if value.is_a?(Hash) + append_binary_key(value) + else + hash.merge(key => {"binary" => value}) end end end From codesite-noreply at google.com Mon Jan 14 21:24:35 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:24:35 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r659 - trunk/lib/active_ldap Message-ID: <000e0cd29bbc0443b97e6075e820967@google.com> Author: koutou Date: Mon Jan 14 18:23:43 2008 New Revision: 659 Modified: trunk/lib/active_ldap/schema.rb Log: * cleanup. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:23:43 2008 @@ -389,7 +389,7 @@ end def syntax - (@derived_syntax ||= [derived_syntax])[0] + @derived_syntax end def valid?(value) @@ -447,16 +447,12 @@ if @syntax @binary_required = @syntax.binary_transfer_required? @binary = (@binary_required or !@syntax.human_readable?) + @derived_syntax = @syntax else @binary_required = false @binary = false + @derived_syntax = @super_attribute.syntax if @super_attribute end - end - - def derived_syntax - return @syntax if @syntax - return @super_attribute.syntax if @super_attribute - nil end def send_to_syntax(default_value, method_name, *args) From codesite-noreply at google.com Mon Jan 14 21:24:35 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:24:35 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r659 - trunk/lib/active_ldap Message-ID: <000e0cd29bbc0443b97e6075e820967@google.com> Author: koutou Date: Mon Jan 14 18:23:43 2008 New Revision: 659 Modified: trunk/lib/active_ldap/schema.rb Log: * cleanup. Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:23:43 2008 @@ -389,7 +389,7 @@ end def syntax - (@derived_syntax ||= [derived_syntax])[0] + @derived_syntax end def valid?(value) @@ -447,16 +447,12 @@ if @syntax @binary_required = @syntax.binary_transfer_required? @binary = (@binary_required or !@syntax.human_readable?) + @derived_syntax = @syntax else @binary_required = false @binary = false + @derived_syntax = @super_attribute.syntax if @super_attribute end - end - - def derived_syntax - return @syntax if @syntax - return @super_attribute.syntax if @super_attribute - nil end def send_to_syntax(default_value, method_name, *args) From codesite-noreply at google.com Mon Jan 14 21:41:45 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:41:45 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r660 - trunk/lib/active_ldap Message-ID: <000e0cd213de0443b9bbc7aa74206e7@google.com> Author: koutou Date: Mon Jan 14 18:41:26 2008 New Revision: 660 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/schema.rb Log: * cached parsed base of class. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 18:41:26 2008 @@ -370,6 +370,16 @@ end.join(",") end + alias_method :base_without_parsed_cache_clear=, :base= + def base=(value) + self.base_without_parsed_cache_clear = value + @parsed_base = nil + end + + def parsed_base + @parsed_base ||= DN.parse(base) + end + alias_method :scope_without_validation=, :scope= def scope=(scope) validate_scope(scope) @@ -1046,7 +1056,7 @@ end begin - relative_dn_value = dn_value - DN.parse(base_of_class) + relative_dn_value = dn_value - self.class.parsed_base if relative_dn_value.rdns.empty? val = [] bases = dn_value.rdns Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:41:26 2008 @@ -451,6 +451,7 @@ else @binary_required = false @binary = false + @derived_syntax = nil @derived_syntax = @super_attribute.syntax if @super_attribute end end From codesite-noreply at google.com Mon Jan 14 21:41:45 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:41:45 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r660 - trunk/lib/active_ldap Message-ID: <000e0cd213de0443b9bbc7aa74206e7@google.com> Author: koutou Date: Mon Jan 14 18:41:26 2008 New Revision: 660 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/schema.rb Log: * cached parsed base of class. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 18:41:26 2008 @@ -370,6 +370,16 @@ end.join(",") end + alias_method :base_without_parsed_cache_clear=, :base= + def base=(value) + self.base_without_parsed_cache_clear = value + @parsed_base = nil + end + + def parsed_base + @parsed_base ||= DN.parse(base) + end + alias_method :scope_without_validation=, :scope= def scope=(scope) validate_scope(scope) @@ -1046,7 +1056,7 @@ end begin - relative_dn_value = dn_value - DN.parse(base_of_class) + relative_dn_value = dn_value - self.class.parsed_base if relative_dn_value.rdns.empty? val = [] bases = dn_value.rdns Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 18:41:26 2008 @@ -451,6 +451,7 @@ else @binary_required = false @binary = false + @derived_syntax = nil @derived_syntax = @super_attribute.syntax if @super_attribute end end From codesite-noreply at google.com Mon Jan 14 21:46:46 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:46:46 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r661 - trunk/lib/active_ldap Message-ID: <000e0cd217a40443b9cdc29e1520720@google.com> Author: koutou Date: Mon Jan 14 18:46:30 2008 New Revision: 661 Modified: trunk/lib/active_ldap/base.rb Log: * cleanup. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 18:46:30 2008 @@ -1027,17 +1027,17 @@ @dn_is_base = false return [attr, value] if value.blank? - new_dn_attribute, new_value, base = split_dn_value(value) + new_dn_attribute, new_value, bases = split_dn_value(value) if new_dn_attribute.nil? and new_value.nil? @dn_is_base = true @base = nil - attr, value = DN.parse(base).rdns[0].to_a[0] + attr, value = bases[0].to_a[0] @dn_attribute = attr else new_dn_attribute = to_real_attribute_name(new_dn_attribute) if new_dn_attribute value = new_value - @base = base + @base = bases.empty? ? nil : DN.new(*bases).to_s if dn_attribute != new_dn_attribute @dn_attribute = attr = new_dn_attribute end @@ -1068,8 +1068,7 @@ end dn_attribute_name, dn_attribute_value = val.to_a[0] - [dn_attribute_name, dn_attribute_value, - bases.empty? ? nil : DN.new(*bases).to_s] + [dn_attribute_name, dn_attribute_value, bases] end def compute_dn From codesite-noreply at google.com Mon Jan 14 21:46:46 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 18:46:46 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r661 - trunk/lib/active_ldap Message-ID: <000e0cd217a40443b9cdc29e1520720@google.com> Author: koutou Date: Mon Jan 14 18:46:30 2008 New Revision: 661 Modified: trunk/lib/active_ldap/base.rb Log: * cleanup. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 18:46:30 2008 @@ -1027,17 +1027,17 @@ @dn_is_base = false return [attr, value] if value.blank? - new_dn_attribute, new_value, base = split_dn_value(value) + new_dn_attribute, new_value, bases = split_dn_value(value) if new_dn_attribute.nil? and new_value.nil? @dn_is_base = true @base = nil - attr, value = DN.parse(base).rdns[0].to_a[0] + attr, value = bases[0].to_a[0] @dn_attribute = attr else new_dn_attribute = to_real_attribute_name(new_dn_attribute) if new_dn_attribute value = new_value - @base = base + @base = bases.empty? ? nil : DN.new(*bases).to_s if dn_attribute != new_dn_attribute @dn_attribute = attr = new_dn_attribute end @@ -1068,8 +1068,7 @@ end dn_attribute_name, dn_attribute_value = val.to_a[0] - [dn_attribute_name, dn_attribute_value, - bases.empty? ? nil : DN.new(*bases).to_s] + [dn_attribute_name, dn_attribute_value, bases] end def compute_dn From codesite-noreply at google.com Mon Jan 14 22:17:51 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:17:51 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r662 - trunk/lib/active_ldap/schema Message-ID: <000e0cd259b80443ba3ce09a7e20592@google.com> Author: koutou Date: Mon Jan 14 19:17:29 2008 New Revision: 662 Modified: trunk/lib/active_ldap/schema/syntaxes.rb Log: * fixed name resolving bug. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Jan 14 19:17:29 2008 @@ -243,7 +243,7 @@ end def normalize_value(value) - if value.is_a?(Integer) + if value.is_a?(::Integer) value.to_s else value From codesite-noreply at google.com Mon Jan 14 22:17:51 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:17:51 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r662 - trunk/lib/active_ldap/schema Message-ID: <000e0cd259b80443ba3ce09a7e20592@google.com> Author: koutou Date: Mon Jan 14 19:17:29 2008 New Revision: 662 Modified: trunk/lib/active_ldap/schema/syntaxes.rb Log: * fixed name resolving bug. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Jan 14 19:17:29 2008 @@ -243,7 +243,7 @@ end def normalize_value(value) - if value.is_a?(Integer) + if value.is_a?(::Integer) value.to_s else value From codesite-noreply at google.com Mon Jan 14 22:21:51 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:21:51 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r663 - trunk/lib/active_ldap Message-ID: <000e0cd14c9a0443ba4b327a6b205b4@google.com> Author: koutou Date: Mon Jan 14 19:17:49 2008 New Revision: 663 Modified: trunk/lib/active_ldap/base.rb Log: * removed needless codes. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 19:17:49 2008 @@ -1008,17 +1008,6 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? - case value - when nil, "" - value = [] - when Array - value = value.collect {|c| c.blank? ? [] : c}.flatten - when String - value = [value] - when Numeric - value = [value.to_s] - end - @data[attr] = enforce_type(attr, value) end From codesite-noreply at google.com Mon Jan 14 22:21:51 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:21:51 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r663 - trunk/lib/active_ldap Message-ID: <000e0cd14c9a0443ba4b327a6b205b4@google.com> Author: koutou Date: Mon Jan 14 19:17:49 2008 New Revision: 663 Modified: trunk/lib/active_ldap/base.rb Log: * removed needless codes. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 19:17:49 2008 @@ -1008,17 +1008,6 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? - case value - when nil, "" - value = [] - when Array - value = value.collect {|c| c.blank? ? [] : c}.flatten - when String - value = [value] - when Numeric - value = [value.to_s] - end - @data[attr] = enforce_type(attr, value) end From codesite-noreply at google.com Mon Jan 14 22:25:53 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:25:53 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r664 - trunk/lib/active_ldap/schema Message-ID: <000e0cd22cd80443ba599a945e2089d@google.com> Author: koutou Date: Mon Jan 14 19:19:29 2008 New Revision: 664 Modified: trunk/lib/active_ldap/schema/syntaxes.rb Log: * improved error message. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Jan 14 19:19:29 2008 @@ -321,7 +321,7 @@ DN.parse("#{value}=dummy") nil rescue DistinguishedNameInvalid - _("%s is invalid OID format") % original_value.inspect + _("%s is invalid OID format: %s") % [original_value.inspect, $!.reason] end end From codesite-noreply at google.com Mon Jan 14 22:25:53 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 19:25:53 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r664 - trunk/lib/active_ldap/schema Message-ID: <000e0cd22cd80443ba599a945e2089d@google.com> Author: koutou Date: Mon Jan 14 19:19:29 2008 New Revision: 664 Modified: trunk/lib/active_ldap/schema/syntaxes.rb Log: * improved error message. Modified: trunk/lib/active_ldap/schema/syntaxes.rb ============================================================================== --- trunk/lib/active_ldap/schema/syntaxes.rb (original) +++ trunk/lib/active_ldap/schema/syntaxes.rb Mon Jan 14 19:19:29 2008 @@ -321,7 +321,7 @@ DN.parse("#{value}=dummy") nil rescue DistinguishedNameInvalid - _("%s is invalid OID format") % original_value.inspect + _("%s is invalid OID format: %s") % [original_value.inspect, $!.reason] end end From codesite-noreply at google.com Mon Jan 14 23:34:07 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 20:34:07 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r666 - trunk/lib/active_ldap Message-ID: <00163646d90c0443bb4d9e5d16b6c8e@google.com> Author: koutou Date: Mon Jan 14 20:33:54 2008 New Revision: 666 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/entry_attribute.rb Log: * cached real names per instance. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 20:33:54 2008 @@ -818,6 +818,7 @@ def clear_connection_based_cache @schema = nil @entry_attribute = nil + @real_names = {} end def schema @@ -866,16 +867,18 @@ def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil - entry_attribute, @entry_attribute = @entry_attribute, nil schema, @schema = @schema, nil + entry_attribute, @entry_attribute = @entry_attribute, nil + real_names, @real_names = @real_names, nil unless @abbreviating @abbreviating = true end yield ensure @connection = connection - @entry_attribute = entry_attribute @schema = schema + @entry_attribute = entry_attribute + @real_names = real_names @abbreviating = false end @@ -925,7 +928,11 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? - entry_attribute.normalize(name, allow_normalized_name) + if allow_normalized_name + entry_attribute.normalize(name, allow_normalized_name) + else + @real_names[name] ||= entry_attribute.normalize(name, false) + end end # enforce_type @@ -947,6 +954,7 @@ @scope = nil @dn = nil @connection ||= nil + clear_connection_based_cache end # get_attribute Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 20:33:54 2008 @@ -9,8 +9,6 @@ @schemata = {} @names = {} @normalized_names = {} - @cached_names = {} - @cached_normalized_names = {} @aliases = {} @must = [] @may = [] @@ -45,14 +43,15 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - if allow_normalized_name - cache = @cached_names + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_names[normalize_attribute_name(name)] else - cache = @cached_normalized_names + nil end - - return cache[name] if cache.has_key?(name) - cache[name] = compute_normalized_name(name, allow_normalized_name) end def all_names @@ -72,18 +71,6 @@ @names[name] = real_name @aliases[Inflector.underscore(name)] = real_name @normalized_names[normalize_attribute_name(name)] = real_name - end - end - - def compute_normalized_name(name, allow_normalized_name=false) - real_name = @names[name] - real_name ||= @aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_names[normalize_attribute_name(name)] - else - nil end end end From codesite-noreply at google.com Mon Jan 14 23:34:07 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 20:34:07 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r666 - trunk/lib/active_ldap Message-ID: <00163646d90c0443bb4d9e5d16b6c8e@google.com> Author: koutou Date: Mon Jan 14 20:33:54 2008 New Revision: 666 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/entry_attribute.rb Log: * cached real names per instance. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 20:33:54 2008 @@ -818,6 +818,7 @@ def clear_connection_based_cache @schema = nil @entry_attribute = nil + @real_names = {} end def schema @@ -866,16 +867,18 @@ def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil - entry_attribute, @entry_attribute = @entry_attribute, nil schema, @schema = @schema, nil + entry_attribute, @entry_attribute = @entry_attribute, nil + real_names, @real_names = @real_names, nil unless @abbreviating @abbreviating = true end yield ensure @connection = connection - @entry_attribute = entry_attribute @schema = schema + @entry_attribute = entry_attribute + @real_names = real_names @abbreviating = false end @@ -925,7 +928,11 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? - entry_attribute.normalize(name, allow_normalized_name) + if allow_normalized_name + entry_attribute.normalize(name, allow_normalized_name) + else + @real_names[name] ||= entry_attribute.normalize(name, false) + end end # enforce_type @@ -947,6 +954,7 @@ @scope = nil @dn = nil @connection ||= nil + clear_connection_based_cache end # get_attribute Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Mon Jan 14 20:33:54 2008 @@ -9,8 +9,6 @@ @schemata = {} @names = {} @normalized_names = {} - @cached_names = {} - @cached_normalized_names = {} @aliases = {} @must = [] @may = [] @@ -45,14 +43,15 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? name = name.to_s - if allow_normalized_name - cache = @cached_names + real_name = @names[name] + real_name ||= @aliases[Inflector.underscore(name)] + if real_name + real_name + elsif allow_normalized_name + @normalized_names[normalize_attribute_name(name)] else - cache = @cached_normalized_names + nil end - - return cache[name] if cache.has_key?(name) - cache[name] = compute_normalized_name(name, allow_normalized_name) end def all_names @@ -72,18 +71,6 @@ @names[name] = real_name @aliases[Inflector.underscore(name)] = real_name @normalized_names[normalize_attribute_name(name)] = real_name - end - end - - def compute_normalized_name(name, allow_normalized_name=false) - real_name = @names[name] - real_name ||= @aliases[Inflector.underscore(name)] - if real_name - real_name - elsif allow_normalized_name - @normalized_names[normalize_attribute_name(name)] - else - nil end end end From codesite-noreply at google.com Mon Jan 14 23:47:07 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 20:47:07 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r667 - trunk/lib/active_ldap Message-ID: <001636456fd60443bb7c281fedb5be5@google.com> Author: koutou Date: Mon Jan 14 20:46:37 2008 New Revision: 667 Modified: trunk/lib/active_ldap/base.rb Log: * reverted needed code. :< Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 20:46:37 2008 @@ -1016,6 +1016,17 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? + case value + when nil, "" + value = [] + when Array + value = value.collect {|c| c.blank? ? [] : c}.flatten + when String + value = [value] + when Numeric + value = [value.to_s] + end + @data[attr] = enforce_type(attr, value) end From codesite-noreply at google.com Mon Jan 14 23:47:07 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 20:47:07 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r667 - trunk/lib/active_ldap Message-ID: <001636456fd60443bb7c281fedb5be5@google.com> Author: koutou Date: Mon Jan 14 20:46:37 2008 New Revision: 667 Modified: trunk/lib/active_ldap/base.rb Log: * reverted needed code. :< Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 20:46:37 2008 @@ -1016,6 +1016,17 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? + case value + when nil, "" + value = [] + when Array + value = value.collect {|c| c.blank? ? [] : c}.flatten + when String + value = [value] + when Numeric + value = [value.to_s] + end + @data[attr] = enforce_type(attr, value) end From codesite-noreply at google.com Tue Jan 15 00:15:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:15:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r668 - trunk/test Message-ID: <00163646c8be0443bbe092965eb56ec@google.com> Author: koutou Date: Mon Jan 14 21:14:30 2008 New Revision: 668 Modified: trunk/test/test_syntax.rb Log: * followed message update. Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Jan 14 21:14:30 2008 @@ -311,9 +311,13 @@ value, "Numeric String") end - def assert_invalid_oid(value) - assert_invalid(_("%s is invalid OID format") % value.inspect, - value, "OID") + def assert_invalid_oid(value, reason=nil) + if reason + message = _("%s is invalid OID format: %s") % [value.inspect, _(reason)] + else + message = _("%s is invalid OID format") % value.inspect + end + assert_invalid(message, value, "OID") end def assert_type_cast_without_validation(type_casted_value, original_value, From codesite-noreply at google.com Tue Jan 15 00:15:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:15:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r668 - trunk/test Message-ID: <00163646c8be0443bbe092965eb56ec@google.com> Author: koutou Date: Mon Jan 14 21:14:30 2008 New Revision: 668 Modified: trunk/test/test_syntax.rb Log: * followed message update. Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Jan 14 21:14:30 2008 @@ -311,9 +311,13 @@ value, "Numeric String") end - def assert_invalid_oid(value) - assert_invalid(_("%s is invalid OID format") % value.inspect, - value, "OID") + def assert_invalid_oid(value, reason=nil) + if reason + message = _("%s is invalid OID format: %s") % [value.inspect, _(reason)] + else + message = _("%s is invalid OID format") % value.inspect + end + assert_invalid(message, value, "OID") end def assert_type_cast_without_validation(type_casted_value, original_value, From codesite-noreply at google.com Tue Jan 15 00:19:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:19:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r669 - trunk/test Message-ID: <00163646c7b60443bbeee4205eb7382@google.com> Author: koutou Date: Mon Jan 14 21:16:54 2008 New Revision: 669 Modified: trunk/test/test_syntax.rb Log: * followed message update. Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Jan 14 21:16:54 2008 @@ -224,7 +224,7 @@ assert_valid("1.2.3.4", "OID") assert_valid("cn", "OID") - assert_invalid_oid("\#@!") + assert_invalid_oid("\#@!", "attribute type is missing") end def test_other_mailbox_validate From codesite-noreply at google.com Tue Jan 15 00:19:12 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:19:12 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r669 - trunk/test Message-ID: <00163646c7b60443bbeee4205eb7382@google.com> Author: koutou Date: Mon Jan 14 21:16:54 2008 New Revision: 669 Modified: trunk/test/test_syntax.rb Log: * followed message update. Modified: trunk/test/test_syntax.rb ============================================================================== --- trunk/test/test_syntax.rb (original) +++ trunk/test/test_syntax.rb Mon Jan 14 21:16:54 2008 @@ -224,7 +224,7 @@ assert_valid("1.2.3.4", "OID") assert_valid("cn", "OID") - assert_invalid_oid("\#@!") + assert_invalid_oid("\#@!", "attribute type is missing") end def test_other_mailbox_validate From codesite-noreply at google.com Tue Jan 15 00:46:14 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:46:14 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r670 - in trunk: lib/active_ldap test Message-ID: <0016364c5c090443bc4f90ce8cb8257@google.com> Author: koutou Date: Mon Jan 14 21:45:48 2008 New Revision: 670 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/object_class.rb trunk/lib/active_ldap/schema.rb trunk/test/test_base.rb Log: * converted data on get_attribute instead of on set_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 21:45:48 2008 @@ -817,6 +817,10 @@ def clear_connection_based_cache @schema = nil + clear_object_class_based_cache + end + + def clear_object_class_based_cache @entry_attribute = nil @real_names = {} end @@ -987,11 +991,7 @@ name = to_real_attribute_name(name) value = @data[name] || [] - if force_array - [name, value.dup] - else - [name, array_of(value.dup, false)] - end + [name, array_of(enforce_type(name, value), force_array)] end def get_attribute_as_query(name, force_array=false) @@ -1016,24 +1016,13 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? - case value - when nil, "" - value = [] - when Array - value = value.collect {|c| c.blank? ? [] : c}.flatten - when String - value = [value] - when Numeric - value = [value.to_s] - end - - @data[attr] = enforce_type(attr, value) + @data[attr] = value end def update_dn(attr, value) @dn = nil @dn_is_base = false - return [attr, value] if value.blank? + return [attr, nil] if value.blank? new_dn_attribute, new_value, bases = split_dn_value(value) if new_dn_attribute.nil? and new_value.nil? @@ -1100,7 +1089,7 @@ case value when Array if to_a or value.size > 1 - value.collect {|v| array_of(v, to_a)} + value.collect {|v| array_of(v, false)}.compact else if value.empty? nil @@ -1117,7 +1106,7 @@ result end else - to_a ? [value.to_s] : value.to_s + to_a ? [value] : value end end @@ -1131,7 +1120,7 @@ real_name ||= key next if _schema.attribute(real_name).id.nil? result[real_name] ||= [] - result[real_name].concat(values) + result[real_name].concat(enforce_type(real_name, values)) end result end Modified: trunk/lib/active_ldap/object_class.rb ============================================================================== --- trunk/lib/active_ldap/object_class.rb (original) +++ trunk/lib/active_ldap/object_class.rb Mon Jan 14 21:45:48 2008 @@ -29,7 +29,7 @@ assert_object_classes(new_classes) if new_classes.sort != classes.sort set_attribute('objectClass', new_classes) - @entry_attribute = nil + clear_object_class_based_cache end end alias_method(:classes=, :replace_class) Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 21:45:48 2008 @@ -411,7 +411,7 @@ when Hash normalize_hash_value(value) else - if value.nil? + if value.blank? value = [] else value = send_to_syntax(value, :normalize_value, value) @@ -419,7 +419,7 @@ if binary_required? [{'binary' => value}] else - [value] + value.is_a?(Array) ? value : [value] end end end Modified: trunk/test/test_base.rb ============================================================================== --- trunk/test/test_base.rb (original) +++ trunk/test/test_base.rb Mon Jan 14 21:45:48 2008 @@ -360,7 +360,9 @@ user2.attributes.reject {|k, v| k == "cn"}) user2.reload - assert_equal(user1.attributes, user2.attributes) + assert_equal(user1.cn, user2.cn) + assert_equal(user1.attributes.reject {|k, v| k == "cn"}, + user2.attributes.reject {|k, v| k == "cn"}) end end From codesite-noreply at google.com Tue Jan 15 00:46:14 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 21:46:14 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r670 - in trunk: lib/active_ldap test Message-ID: <0016364c5c090443bc4f90ce8cb8257@google.com> Author: koutou Date: Mon Jan 14 21:45:48 2008 New Revision: 670 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/object_class.rb trunk/lib/active_ldap/schema.rb trunk/test/test_base.rb Log: * converted data on get_attribute instead of on set_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 21:45:48 2008 @@ -817,6 +817,10 @@ def clear_connection_based_cache @schema = nil + clear_object_class_based_cache + end + + def clear_object_class_based_cache @entry_attribute = nil @real_names = {} end @@ -987,11 +991,7 @@ name = to_real_attribute_name(name) value = @data[name] || [] - if force_array - [name, value.dup] - else - [name, array_of(value.dup, false)] - end + [name, array_of(enforce_type(name, value), force_array)] end def get_attribute_as_query(name, force_array=false) @@ -1016,24 +1016,13 @@ attr, value = update_dn(attr, value) if attr == dn_attribute raise UnknownAttribute.new(name) if attr.nil? - case value - when nil, "" - value = [] - when Array - value = value.collect {|c| c.blank? ? [] : c}.flatten - when String - value = [value] - when Numeric - value = [value.to_s] - end - - @data[attr] = enforce_type(attr, value) + @data[attr] = value end def update_dn(attr, value) @dn = nil @dn_is_base = false - return [attr, value] if value.blank? + return [attr, nil] if value.blank? new_dn_attribute, new_value, bases = split_dn_value(value) if new_dn_attribute.nil? and new_value.nil? @@ -1100,7 +1089,7 @@ case value when Array if to_a or value.size > 1 - value.collect {|v| array_of(v, to_a)} + value.collect {|v| array_of(v, false)}.compact else if value.empty? nil @@ -1117,7 +1106,7 @@ result end else - to_a ? [value.to_s] : value.to_s + to_a ? [value] : value end end @@ -1131,7 +1120,7 @@ real_name ||= key next if _schema.attribute(real_name).id.nil? result[real_name] ||= [] - result[real_name].concat(values) + result[real_name].concat(enforce_type(real_name, values)) end result end Modified: trunk/lib/active_ldap/object_class.rb ============================================================================== --- trunk/lib/active_ldap/object_class.rb (original) +++ trunk/lib/active_ldap/object_class.rb Mon Jan 14 21:45:48 2008 @@ -29,7 +29,7 @@ assert_object_classes(new_classes) if new_classes.sort != classes.sort set_attribute('objectClass', new_classes) - @entry_attribute = nil + clear_object_class_based_cache end end alias_method(:classes=, :replace_class) Modified: trunk/lib/active_ldap/schema.rb ============================================================================== --- trunk/lib/active_ldap/schema.rb (original) +++ trunk/lib/active_ldap/schema.rb Mon Jan 14 21:45:48 2008 @@ -411,7 +411,7 @@ when Hash normalize_hash_value(value) else - if value.nil? + if value.blank? value = [] else value = send_to_syntax(value, :normalize_value, value) @@ -419,7 +419,7 @@ if binary_required? [{'binary' => value}] else - [value] + value.is_a?(Array) ? value : [value] end end end Modified: trunk/test/test_base.rb ============================================================================== --- trunk/test/test_base.rb (original) +++ trunk/test/test_base.rb Mon Jan 14 21:45:48 2008 @@ -360,7 +360,9 @@ user2.attributes.reject {|k, v| k == "cn"}) user2.reload - assert_equal(user1.attributes, user2.attributes) + assert_equal(user1.cn, user2.cn) + assert_equal(user1.attributes.reject {|k, v| k == "cn"}, + user2.attributes.reject {|k, v| k == "cn"}) end end From codesite-noreply at google.com Tue Jan 15 01:12:18 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 22:12:18 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r671 - in trunk: lib/active_ldap test Message-ID: <00163646d97f0443bcacca01b2b6bdd@google.com> Author: koutou Date: Mon Jan 14 22:11:21 2008 New Revision: 671 Modified: trunk/lib/active_ldap/base.rb trunk/test/test_user.rb trunk/test/test_useradd-binary.rb trunk/test/test_usermod-binary-add-time.rb trunk/test/test_usermod-binary-add.rb Log: * [API CHANGE]: removed "'binary' =>" from getter result. e.g. before: user.user_certificate # => {"binary" => "..."} now: user.user_certificate # => "..." Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 22:11:21 2008 @@ -977,7 +977,11 @@ value.each do |option, val| result[option] = type_cast(attribute, val) end - result + if result.size == 1 and result.has_key?("binary") + result["binary"] + else + result + end when Array value.collect do |val| type_cast(attribute, val) @@ -991,7 +995,7 @@ name = to_real_attribute_name(name) value = @data[name] || [] - [name, array_of(enforce_type(name, value), force_array)] + [name, array_of(value, force_array)] end def get_attribute_as_query(name, force_array=false) Modified: trunk/test/test_user.rb ============================================================================== --- trunk/test/test_user.rb (original) +++ trunk/test/test_user.rb Mon Jan 14 22:11:21 2008 @@ -38,17 +38,15 @@ 'This should have returned an array of a ' + 'normal cn and a lang-en-us cn.') - uid_number = 9000 + uid_number = "9000" user.uid_number = uid_number - # Test to_s on Fixnums - assert_equal(uid_number, user.uid_number) - assert_equal(uid_number.to_s, user.uid_number_before_type_cast) + assert_equal(uid_number.to_i, user.uid_number) + assert_equal(uid_number, user.uid_number_before_type_cast) gid_number = 9000 user.gid_number = gid_number - # Test to_s on Fixnums assert_equal(gid_number, user.gid_number) - assert_equal(gid_number.to_s, user.gid_number_before_type_cast) + assert_equal(gid_number, user.gid_number_before_type_cast) home_directory = '/home/foo' user.home_directory = home_directory @@ -108,39 +106,31 @@ make_temporary_user do |user, password| # validate add user.user_certificate = nil - assert_equal({'binary' => nil}, user.user_certificate) + assert_nil(user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'binary' => nil}, user.user_certificate) + assert_nil(user.user_certificate) user.user_certificate = {"binary" => [certificate]} - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) # now test modify user.user_certificate = nil - assert_equal({"binary" => nil}, user.user_certificate) + assert_nil(user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({"binary" => nil}, user.user_certificate) + assert_nil(user.user_certificate) user.user_certificate = certificate - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) assert_nothing_raised() { user.save! } # validate modify user = @user_class.find(user.uid) - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) expected_cert = OpenSSL::X509::Certificate.new(certificate) - actual_cert = user.user_certificate['binary'] + actual_cert = user.user_certificate actual_cert = OpenSSL::X509::Certificate.new(actual_cert) assert_equal(expected_cert.subject.to_s, actual_cert.subject.to_s, @@ -151,10 +141,10 @@ def test_binary_required_nested make_temporary_user do |user, password| user.user_certificate = {"lang-en" => [certificate]} - assert_equal({'lang-en' => {'binary' => certificate}}, + assert_equal({'lang-en' => certificate}, user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'lang-en' => {'binary' => certificate}}, + assert_equal({'lang-en' => certificate}, user.user_certificate) end end Modified: trunk/test/test_useradd-binary.rb ============================================================================== --- trunk/test/test_useradd-binary.rb (original) +++ trunk/test/test_useradd-binary.rb Mon Jan 14 22:11:21 2008 @@ -46,7 +46,7 @@ assert_equal(['person', 'posixAccount', 'shadowAccount', 'strongAuthenticationUser'].sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end Modified: trunk/test/test_usermod-binary-add-time.rb ============================================================================== --- trunk/test/test_usermod-binary-add-time.rb (original) +++ trunk/test/test_usermod-binary-add-time.rb Mon Jan 14 22:11:21 2008 @@ -48,7 +48,7 @@ assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end Modified: trunk/test/test_usermod-binary-add.rb ============================================================================== --- trunk/test/test_usermod-binary-add.rb (original) +++ trunk/test/test_usermod-binary-add.rb Mon Jan 14 22:11:21 2008 @@ -48,7 +48,7 @@ assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end From codesite-noreply at google.com Tue Jan 15 01:12:18 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Mon, 14 Jan 2008 22:12:18 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r671 - in trunk: lib/active_ldap test Message-ID: <00163646d97f0443bcacca01b2b6bdd@google.com> Author: koutou Date: Mon Jan 14 22:11:21 2008 New Revision: 671 Modified: trunk/lib/active_ldap/base.rb trunk/test/test_user.rb trunk/test/test_useradd-binary.rb trunk/test/test_usermod-binary-add-time.rb trunk/test/test_usermod-binary-add.rb Log: * [API CHANGE]: removed "'binary' =>" from getter result. e.g. before: user.user_certificate # => {"binary" => "..."} now: user.user_certificate # => "..." Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Mon Jan 14 22:11:21 2008 @@ -977,7 +977,11 @@ value.each do |option, val| result[option] = type_cast(attribute, val) end - result + if result.size == 1 and result.has_key?("binary") + result["binary"] + else + result + end when Array value.collect do |val| type_cast(attribute, val) @@ -991,7 +995,7 @@ name = to_real_attribute_name(name) value = @data[name] || [] - [name, array_of(enforce_type(name, value), force_array)] + [name, array_of(value, force_array)] end def get_attribute_as_query(name, force_array=false) Modified: trunk/test/test_user.rb ============================================================================== --- trunk/test/test_user.rb (original) +++ trunk/test/test_user.rb Mon Jan 14 22:11:21 2008 @@ -38,17 +38,15 @@ 'This should have returned an array of a ' + 'normal cn and a lang-en-us cn.') - uid_number = 9000 + uid_number = "9000" user.uid_number = uid_number - # Test to_s on Fixnums - assert_equal(uid_number, user.uid_number) - assert_equal(uid_number.to_s, user.uid_number_before_type_cast) + assert_equal(uid_number.to_i, user.uid_number) + assert_equal(uid_number, user.uid_number_before_type_cast) gid_number = 9000 user.gid_number = gid_number - # Test to_s on Fixnums assert_equal(gid_number, user.gid_number) - assert_equal(gid_number.to_s, user.gid_number_before_type_cast) + assert_equal(gid_number, user.gid_number_before_type_cast) home_directory = '/home/foo' user.home_directory = home_directory @@ -108,39 +106,31 @@ make_temporary_user do |user, password| # validate add user.user_certificate = nil - assert_equal({'binary' => nil}, user.user_certificate) + assert_nil(user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'binary' => nil}, user.user_certificate) + assert_nil(user.user_certificate) user.user_certificate = {"binary" => [certificate]} - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) # now test modify user.user_certificate = nil - assert_equal({"binary" => nil}, user.user_certificate) + assert_nil(user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({"binary" => nil}, user.user_certificate) + assert_nil(user.user_certificate) user.user_certificate = certificate - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) assert_nothing_raised() { user.save! } # validate modify user = @user_class.find(user.uid) - assert_equal({'binary' => certificate}, - user.user_certificate, - 'This should have been forced to be a binary subtype.') + assert_equal(certificate, user.user_certificate) expected_cert = OpenSSL::X509::Certificate.new(certificate) - actual_cert = user.user_certificate['binary'] + actual_cert = user.user_certificate actual_cert = OpenSSL::X509::Certificate.new(actual_cert) assert_equal(expected_cert.subject.to_s, actual_cert.subject.to_s, @@ -151,10 +141,10 @@ def test_binary_required_nested make_temporary_user do |user, password| user.user_certificate = {"lang-en" => [certificate]} - assert_equal({'lang-en' => {'binary' => certificate}}, + assert_equal({'lang-en' => certificate}, user.user_certificate) assert_nothing_raised() { user.save! } - assert_equal({'lang-en' => {'binary' => certificate}}, + assert_equal({'lang-en' => certificate}, user.user_certificate) end end Modified: trunk/test/test_useradd-binary.rb ============================================================================== --- trunk/test/test_useradd-binary.rb (original) +++ trunk/test/test_useradd-binary.rb Mon Jan 14 22:11:21 2008 @@ -46,7 +46,7 @@ assert_equal(['person', 'posixAccount', 'shadowAccount', 'strongAuthenticationUser'].sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end Modified: trunk/test/test_usermod-binary-add-time.rb ============================================================================== --- trunk/test/test_usermod-binary-add-time.rb (original) +++ trunk/test/test_usermod-binary-add-time.rb Mon Jan 14 22:11:21 2008 @@ -48,7 +48,7 @@ assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end Modified: trunk/test/test_usermod-binary-add.rb ============================================================================== --- trunk/test/test_usermod-binary-add.rb (original) +++ trunk/test/test_usermod-binary-add.rb Mon Jan 14 22:11:21 2008 @@ -48,7 +48,7 @@ assert_equal((previous_classes + ['strongAuthenticationUser']).sort, user.classes.sort) cert = File.read(File.join(@examples_dir, 'example.der')) - assert_equal({"binary" => cert}, user.user_certificate) + assert_equal(cert, user.user_certificate) end end From codesite-noreply at google.com Tue Jan 15 05:53:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 15 Jan 2008 02:53:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r672 - trunk Message-ID: <000e0cd24ed40443c09c25928120904@google.com> Author: koutou Date: Tue Jan 15 02:53:35 2008 New Revision: 672 Modified: trunk/TODO Log: * ldap_mapping :exclude_classes. (:excluded_classes is more better?) Modified: trunk/TODO ============================================================================== --- trunk/TODO (original) +++ trunk/TODO Tue Jan 15 02:53:35 2008 @@ -1,3 +1,4 @@ +- ldap_mapping :exclude_classes. (:excluded_classes is more better?) - Provide FormHelper for LDAP entry's attribute to handle multiple values (["foo", "bar", ...]) and option value ({"binary" => "..."}, {"lang-en-us" => "..."}) From codesite-noreply at google.com Tue Jan 15 05:53:59 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Tue, 15 Jan 2008 02:53:59 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r672 - trunk Message-ID: <000e0cd24ed40443c09c25928120904@google.com> Author: koutou Date: Tue Jan 15 02:53:35 2008 New Revision: 672 Modified: trunk/TODO Log: * ldap_mapping :exclude_classes. (:excluded_classes is more better?) Modified: trunk/TODO ============================================================================== --- trunk/TODO (original) +++ trunk/TODO Tue Jan 15 02:53:35 2008 @@ -1,3 +1,4 @@ +- ldap_mapping :exclude_classes. (:excluded_classes is more better?) - Provide FormHelper for LDAP entry's attribute to handle multiple values (["foo", "bar", ...]) and option value ({"binary" => "..."}, {"lang-en-us" => "..."}) From codesite-noreply at google.com Wed Jan 16 19:55:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 16:55:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r673 - in trunk: lib/active_ldap test Message-ID: <00163646c5a80443e07b566b9a3726@google.com> Author: koutou Date: Wed Jan 16 16:55:04 2008 New Revision: 673 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/entry_attribute.rb trunk/test/test_find.rb Log: * re-supported not defined attribute accessor in objectClass but defined in schema. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Wed Jan 16 16:55:04 2008 @@ -716,9 +716,18 @@ # Do not let URL/form hackers supply the keys. def attributes=(new_attributes) return if new_attributes.nil? + _schema = _local_entry_attribute = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| - send("#{key}=", value) + setter = "#{key}=" + unless respond_to?(setter) + _schema ||= schema + attribute = _schema.attribute(key) + next if attribute.id.nil? + _local_entry_attribute ||= local_entry_attribute + _local_entry_attribute.register(attribute) + end + send(setter, value) end end @@ -817,6 +826,7 @@ def clear_connection_based_cache @schema = nil + @local_entry_attribute = nil clear_object_class_based_cache end @@ -864,10 +874,18 @@ end private + def attribute_name_resolvable_without_connection? + @entry_attribute and @local_entry_attribute + end + def entry_attribute @entry_attribute ||= connection.entry_attribute(@data["objectClass"] || []) end + def local_entry_attribute + @local_entry_attribute ||= connection.entry_attribute([]) + end + def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil @@ -933,9 +951,12 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? if allow_normalized_name - entry_attribute.normalize(name, allow_normalized_name) + entry_attribute.normalize(name, allow_normalized_name) || + local_entry_attribute.normalize(name, allow_normalized_name) else - @real_names[name] ||= entry_attribute.normalize(name, false) + @real_names[name] ||= + entry_attribute.normalize(name, false) || + local_entry_attribute.normalize(name, false) end end Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Wed Jan 16 16:55:04 2008 @@ -208,7 +208,8 @@ return conn if conn if @dn or - (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) + (attribute_name_resolvable_without_connection? and + get_attribute_before_type_cast(dn_attribute)[1]) conn = self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Wed Jan 16 16:55:04 2008 @@ -13,7 +13,7 @@ @must = [] @may = [] @object_classes = [] - define_attribute_methods(schema.attribute('objectClass')) + register(schema.attribute('objectClass')) object_classes.each do |objc| # get all attributes for the class object_class = schema.object_class(objc) @@ -25,7 +25,7 @@ @may.uniq! (@must + @may).each do |attr| # Update attr_method with appropriate - define_attribute_methods(attr) + register(attr) end end @@ -42,12 +42,14 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? + return nil if @names.empty? and @aliases.empty? name = name.to_s real_name = @names[name] real_name ||= @aliases[Inflector.underscore(name)] if real_name real_name elsif allow_normalized_name + return nil if @normalized_names.empty? @normalized_names[normalize_attribute_name(name)] else nil @@ -58,12 +60,11 @@ @names.keys + @aliases.keys end - private - # define_attribute_methods + # register # # Make a method entry for _every_ alias of a valid attribute and map it # onto the first attribute passed in. - def define_attribute_methods(attribute) + def register(attribute) real_name = attribute.name return if @schemata.has_key?(real_name) @schemata[real_name] = attribute Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 16:55:04 2008 @@ -4,12 +4,18 @@ include AlTestUtils priority :must + def test_find_operational_attributes + make_temporary_user do |user, password| + found_user = @user_class.find(user.uid, :attributes => ["*", "+"]) + assert_equal(Time.now.utc.iso8601, + found_user.modify_timestamp.utc.iso8601) + end + end priority :normal def test_find_with_attributes_without_object_class make_temporary_user do |user, password| - found_user = @user_class.find(user.uid, - :attributes => ["uidNumber"]) + found_user = @user_class.find(user.uid, :attributes => ["uidNumber"]) assert_equal(user.uid_number, found_user.uid_number) assert_equal(user.classes, found_user.classes) assert_nil(found_user.gid_number) From codesite-noreply at google.com Wed Jan 16 19:55:27 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 16:55:27 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r673 - in trunk: lib/active_ldap test Message-ID: <00163646c5a80443e07b566b9a3726@google.com> Author: koutou Date: Wed Jan 16 16:55:04 2008 New Revision: 673 Modified: trunk/lib/active_ldap/base.rb trunk/lib/active_ldap/connection.rb trunk/lib/active_ldap/entry_attribute.rb trunk/test/test_find.rb Log: * re-supported not defined attribute accessor in objectClass but defined in schema. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Wed Jan 16 16:55:04 2008 @@ -716,9 +716,18 @@ # Do not let URL/form hackers supply the keys. def attributes=(new_attributes) return if new_attributes.nil? + _schema = _local_entry_attribute = nil targets = remove_attributes_protected_from_mass_assignment(new_attributes) targets.each do |key, value| - send("#{key}=", value) + setter = "#{key}=" + unless respond_to?(setter) + _schema ||= schema + attribute = _schema.attribute(key) + next if attribute.id.nil? + _local_entry_attribute ||= local_entry_attribute + _local_entry_attribute.register(attribute) + end + send(setter, value) end end @@ -817,6 +826,7 @@ def clear_connection_based_cache @schema = nil + @local_entry_attribute = nil clear_object_class_based_cache end @@ -864,10 +874,18 @@ end private + def attribute_name_resolvable_without_connection? + @entry_attribute and @local_entry_attribute + end + def entry_attribute @entry_attribute ||= connection.entry_attribute(@data["objectClass"] || []) end + def local_entry_attribute + @local_entry_attribute ||= connection.entry_attribute([]) + end + def abbreviate_instance_variables @abbreviating ||= nil connection, @connection = @connection, nil @@ -933,9 +951,12 @@ def to_real_attribute_name(name, allow_normalized_name=false) return name if name.nil? if allow_normalized_name - entry_attribute.normalize(name, allow_normalized_name) + entry_attribute.normalize(name, allow_normalized_name) || + local_entry_attribute.normalize(name, allow_normalized_name) else - @real_names[name] ||= entry_attribute.normalize(name, false) + @real_names[name] ||= + entry_attribute.normalize(name, false) || + local_entry_attribute.normalize(name, false) end end Modified: trunk/lib/active_ldap/connection.rb ============================================================================== --- trunk/lib/active_ldap/connection.rb (original) +++ trunk/lib/active_ldap/connection.rb Wed Jan 16 16:55:04 2008 @@ -208,7 +208,8 @@ return conn if conn if @dn or - (@entry_attribute and get_attribute_before_type_cast(dn_attribute)[1]) + (attribute_name_resolvable_without_connection? and + get_attribute_before_type_cast(dn_attribute)[1]) conn = self.class.active_connections[dn] || retrieve_connection end conn || self.class.connection Modified: trunk/lib/active_ldap/entry_attribute.rb ============================================================================== --- trunk/lib/active_ldap/entry_attribute.rb (original) +++ trunk/lib/active_ldap/entry_attribute.rb Wed Jan 16 16:55:04 2008 @@ -13,7 +13,7 @@ @must = [] @may = [] @object_classes = [] - define_attribute_methods(schema.attribute('objectClass')) + register(schema.attribute('objectClass')) object_classes.each do |objc| # get all attributes for the class object_class = schema.object_class(objc) @@ -25,7 +25,7 @@ @may.uniq! (@must + @may).each do |attr| # Update attr_method with appropriate - define_attribute_methods(attr) + register(attr) end end @@ -42,12 +42,14 @@ def normalize(name, allow_normalized_name=false) return name if name.nil? + return nil if @names.empty? and @aliases.empty? name = name.to_s real_name = @names[name] real_name ||= @aliases[Inflector.underscore(name)] if real_name real_name elsif allow_normalized_name + return nil if @normalized_names.empty? @normalized_names[normalize_attribute_name(name)] else nil @@ -58,12 +60,11 @@ @names.keys + @aliases.keys end - private - # define_attribute_methods + # register # # Make a method entry for _every_ alias of a valid attribute and map it # onto the first attribute passed in. - def define_attribute_methods(attribute) + def register(attribute) real_name = attribute.name return if @schemata.has_key?(real_name) @schemata[real_name] = attribute Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 16:55:04 2008 @@ -4,12 +4,18 @@ include AlTestUtils priority :must + def test_find_operational_attributes + make_temporary_user do |user, password| + found_user = @user_class.find(user.uid, :attributes => ["*", "+"]) + assert_equal(Time.now.utc.iso8601, + found_user.modify_timestamp.utc.iso8601) + end + end priority :normal def test_find_with_attributes_without_object_class make_temporary_user do |user, password| - found_user = @user_class.find(user.uid, - :attributes => ["uidNumber"]) + found_user = @user_class.find(user.uid, :attributes => ["uidNumber"]) assert_equal(user.uid_number, found_user.uid_number) assert_equal(user.classes, found_user.classes) assert_nil(found_user.gid_number) From codesite-noreply at google.com Wed Jan 16 21:44:52 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 18:44:52 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r674 - trunk/lib/active_ldap Message-ID: <000e0cd228820443e202a623cf187@google.com> Author: koutou Date: Wed Jan 16 18:43:51 2008 New Revision: 674 Modified: trunk/lib/active_ldap/base.rb Log: * hide @local_entry_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Wed Jan 16 18:43:51 2008 @@ -891,6 +891,7 @@ connection, @connection = @connection, nil schema, @schema = @schema, nil entry_attribute, @entry_attribute = @entry_attribute, nil + local_entry_attribute, @local_entry_attribute = @local_entry_attribute, nil real_names, @real_names = @real_names, nil unless @abbreviating @abbreviating = true @@ -900,6 +901,7 @@ @connection = connection @schema = schema @entry_attribute = entry_attribute + @local_entry_attribute = local_entry_attribute @real_names = real_names @abbreviating = false end From codesite-noreply at google.com Wed Jan 16 21:44:52 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 18:44:52 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r674 - trunk/lib/active_ldap Message-ID: <000e0cd228820443e202a623cf187@google.com> Author: koutou Date: Wed Jan 16 18:43:51 2008 New Revision: 674 Modified: trunk/lib/active_ldap/base.rb Log: * hide @local_entry_attribute. Modified: trunk/lib/active_ldap/base.rb ============================================================================== --- trunk/lib/active_ldap/base.rb (original) +++ trunk/lib/active_ldap/base.rb Wed Jan 16 18:43:51 2008 @@ -891,6 +891,7 @@ connection, @connection = @connection, nil schema, @schema = @schema, nil entry_attribute, @entry_attribute = @entry_attribute, nil + local_entry_attribute, @local_entry_attribute = @local_entry_attribute, nil real_names, @real_names = @real_names, nil unless @abbreviating @abbreviating = true @@ -900,6 +901,7 @@ @connection = connection @schema = schema @entry_attribute = entry_attribute + @local_entry_attribute = local_entry_attribute @real_names = real_names @abbreviating = false end From codesite-noreply at google.com Wed Jan 16 23:41:00 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 20:41:00 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r675 - trunk/test Message-ID: <000e0cd243ba0443e3a1ecf2d428b@google.com> Author: koutou Date: Wed Jan 16 20:40:18 2008 New Revision: 675 Modified: trunk/test/test_find.rb Log: * added a test for :sort_by in ldap_mapping. Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 20:40:18 2008 @@ -4,6 +4,29 @@ include AlTestUtils priority :must + def test_find_with_sort_by_in_ldap_mapping + @user_class.ldap_mapping(:dn_attribute => @user_class.dn_attribute, + :prefix => @user_class.prefix, + :scope => @user_class.scope, + :classes => @user_class_classes, + :sort_by => "uid", + :order => "asc") + make_temporary_user(:uid => "user1") do |user1,| + make_temporary_user(:uid => "user2") do |user2,| + make_temporary_user(:uid => "user3") do |user3,| + users = @user_class.find(:all) + assert_equal(["user3", "user2", "user1"].sort, + users.collect {|u| u.uid}.sort) + + users = @user_class.find(:all, :order => "desc") + assert_equal(["user1", "user2", "user3"].sort, + users.collect {|u| u.uid}.sort) + end + end + end + end + + priority :normal def test_find_operational_attributes make_temporary_user do |user, password| found_user = @user_class.find(user.uid, :attributes => ["*", "+"]) @@ -12,7 +35,6 @@ end end - priority :normal def test_find_with_attributes_without_object_class make_temporary_user do |user, password| found_user = @user_class.find(user.uid, :attributes => ["uidNumber"]) From codesite-noreply at google.com Wed Jan 16 23:41:00 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 20:41:00 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r675 - trunk/test Message-ID: <000e0cd243ba0443e3a1ecf2d428b@google.com> Author: koutou Date: Wed Jan 16 20:40:18 2008 New Revision: 675 Modified: trunk/test/test_find.rb Log: * added a test for :sort_by in ldap_mapping. Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 20:40:18 2008 @@ -4,6 +4,29 @@ include AlTestUtils priority :must + def test_find_with_sort_by_in_ldap_mapping + @user_class.ldap_mapping(:dn_attribute => @user_class.dn_attribute, + :prefix => @user_class.prefix, + :scope => @user_class.scope, + :classes => @user_class_classes, + :sort_by => "uid", + :order => "asc") + make_temporary_user(:uid => "user1") do |user1,| + make_temporary_user(:uid => "user2") do |user2,| + make_temporary_user(:uid => "user3") do |user3,| + users = @user_class.find(:all) + assert_equal(["user3", "user2", "user1"].sort, + users.collect {|u| u.uid}.sort) + + users = @user_class.find(:all, :order => "desc") + assert_equal(["user1", "user2", "user3"].sort, + users.collect {|u| u.uid}.sort) + end + end + end + end + + priority :normal def test_find_operational_attributes make_temporary_user do |user, password| found_user = @user_class.find(user.uid, :attributes => ["*", "+"]) @@ -12,7 +35,6 @@ end end - priority :normal def test_find_with_attributes_without_object_class make_temporary_user do |user, password| found_user = @user_class.find(user.uid, :attributes => ["uidNumber"]) From codesite-noreply at google.com Thu Jan 17 00:17:03 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 21:17:03 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r676 - in trunk: lib/active_ldap test Message-ID: <000e0cd296b40443e422d9155a627@google.com> Author: koutou Date: Wed Jan 16 21:16:19 2008 New Revision: 676 Modified: trunk/lib/active_ldap/operations.rb trunk/test/test_find.rb Log: * fixed a bug that ldap_mapping sort_by/order is ignored. Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Wed Jan 16 21:16:19 2008 @@ -202,8 +202,8 @@ def find_every(options) options = options.dup - sort_by = options.delete(:sort_by) || sort_by - order = options.delete(:order) || order + sort_by = options.delete(:sort_by) || self.sort_by + order = options.delete(:order) || self.order limit = options.delete(:limit) if sort_by or order options[:attributes] |= ["objectClass"] if options[:attributes] Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 21:16:19 2008 @@ -10,17 +10,17 @@ :scope => @user_class.scope, :classes => @user_class_classes, :sort_by => "uid", - :order => "asc") + :order => "desc") make_temporary_user(:uid => "user1") do |user1,| make_temporary_user(:uid => "user2") do |user2,| make_temporary_user(:uid => "user3") do |user3,| users = @user_class.find(:all) - assert_equal(["user3", "user2", "user1"].sort, - users.collect {|u| u.uid}.sort) + assert_equal(["user3", "user2", "user1"], + users.collect {|u| u.uid}) - users = @user_class.find(:all, :order => "desc") - assert_equal(["user1", "user2", "user3"].sort, - users.collect {|u| u.uid}.sort) + users = @user_class.find(:all, :order => "asc") + assert_equal(["user1", "user2", "user3"], + users.collect {|u| u.uid}) end end end From codesite-noreply at google.com Thu Jan 17 00:17:03 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 21:17:03 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r676 - in trunk: lib/active_ldap test Message-ID: <000e0cd296b40443e422d9155a627@google.com> Author: koutou Date: Wed Jan 16 21:16:19 2008 New Revision: 676 Modified: trunk/lib/active_ldap/operations.rb trunk/test/test_find.rb Log: * fixed a bug that ldap_mapping sort_by/order is ignored. Modified: trunk/lib/active_ldap/operations.rb ============================================================================== --- trunk/lib/active_ldap/operations.rb (original) +++ trunk/lib/active_ldap/operations.rb Wed Jan 16 21:16:19 2008 @@ -202,8 +202,8 @@ def find_every(options) options = options.dup - sort_by = options.delete(:sort_by) || sort_by - order = options.delete(:order) || order + sort_by = options.delete(:sort_by) || self.sort_by + order = options.delete(:order) || self.order limit = options.delete(:limit) if sort_by or order options[:attributes] |= ["objectClass"] if options[:attributes] Modified: trunk/test/test_find.rb ============================================================================== --- trunk/test/test_find.rb (original) +++ trunk/test/test_find.rb Wed Jan 16 21:16:19 2008 @@ -10,17 +10,17 @@ :scope => @user_class.scope, :classes => @user_class_classes, :sort_by => "uid", - :order => "asc") + :order => "desc") make_temporary_user(:uid => "user1") do |user1,| make_temporary_user(:uid => "user2") do |user2,| make_temporary_user(:uid => "user3") do |user3,| users = @user_class.find(:all) - assert_equal(["user3", "user2", "user1"].sort, - users.collect {|u| u.uid}.sort) + assert_equal(["user3", "user2", "user1"], + users.collect {|u| u.uid}) - users = @user_class.find(:all, :order => "desc") - assert_equal(["user1", "user2", "user3"].sort, - users.collect {|u| u.uid}.sort) + users = @user_class.find(:all, :order => "asc") + assert_equal(["user1", "user2", "user3"], + users.collect {|u| u.uid}) end end end From codesite-noreply at google.com Thu Jan 17 02:23:49 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 23:23:49 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r677 - trunk/lib/active_ldap/adapter Message-ID: <0016364180090443e5e83cfac75558@google.com> Author: koutou Date: Wed Jan 16 23:23:23 2008 New Revision: 677 Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb Log: * detected server down. Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap_ext.rb (original) +++ trunk/lib/active_ldap/adapter/ldap_ext.rb Wed Jan 16 23:23:23 2008 @@ -73,6 +73,9 @@ code = error_code klass = ActiveLdap::LdapError::ERRORS[code] klass ||= IMPLEMENT_SPECIFIC_ERRORS[code] + if klass.nil? and error_message == "Can't contact LDAP server" + klass = LDAP::ServerDown + end klass ||= ActiveLdap::LdapError raise klass, LDAP.err2string(code) end From codesite-noreply at google.com Thu Jan 17 02:23:49 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Wed, 16 Jan 2008 23:23:49 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r677 - trunk/lib/active_ldap/adapter Message-ID: <0016364180090443e5e83cfac75558@google.com> Author: koutou Date: Wed Jan 16 23:23:23 2008 New Revision: 677 Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb Log: * detected server down. Modified: trunk/lib/active_ldap/adapter/ldap_ext.rb ============================================================================== --- trunk/lib/active_ldap/adapter/ldap_ext.rb (original) +++ trunk/lib/active_ldap/adapter/ldap_ext.rb Wed Jan 16 23:23:23 2008 @@ -73,6 +73,9 @@ code = error_code klass = ActiveLdap::LdapError::ERRORS[code] klass ||= IMPLEMENT_SPECIFIC_ERRORS[code] + if klass.nil? and error_message == "Can't contact LDAP server" + klass = LDAP::ServerDown + end klass ||= ActiveLdap::LdapError raise klass, LDAP.err2string(code) end From codesite-noreply at google.com Thu Jan 31 22:09:05 2008 From: codesite-noreply at google.com (codesite-noreply at google.com) Date: Thu, 31 Jan 2008 19:09:05 -0800 Subject: [Ruby-activeldap-commit] [ruby-activeldap commit] r678 - trunk Message-ID: <000e0cd509c204451018d769231748ad@google.com> Author: koutou Date: Thu Jan 31 19:08:33 2008 New Revision: 678 Modified: trunk/TODO Log: * TODO: Log LDAP request with elapsed time. Modified: trunk/TODO ============================================================================== --- trunk/TODO (original) +++ trunk/TODO Thu Jan 31 19:08:33 2008 @@ -1,3 +1,4 @@ +- Log LDAP request with elapsed time. - ldap_mapping :exclude_classes. (:excluded_classes is more better?) - Provide FormHelper for LDAP entry's attribute to handle multiple values (["foo", "bar", ...]) and option value ({"binary" => "..."},