rubygems-update 3.5.5 → 3.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +107 -0
- data/Manifest.txt +84 -64
- data/POLICIES.md +75 -6
- data/bundler/CHANGELOG.md +75 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/binstubs.rb +1 -1
- data/bundler/lib/bundler/cli/gem.rb +1 -1
- data/bundler/lib/bundler/cli/lock.rb +5 -4
- data/bundler/lib/bundler/cli/plugin.rb +3 -2
- data/bundler/lib/bundler/cli.rb +7 -24
- data/bundler/lib/bundler/definition.rb +111 -56
- data/bundler/lib/bundler/dependency.rb +2 -1
- data/bundler/lib/bundler/dsl.rb +16 -1
- data/bundler/lib/bundler/environment_preserver.rb +5 -23
- data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
- data/bundler/lib/bundler/fetcher.rb +2 -2
- data/bundler/lib/bundler/gem_version_promoter.rb +42 -38
- data/bundler/lib/bundler/injector.rb +3 -2
- data/bundler/lib/bundler/installer.rb +2 -2
- data/bundler/lib/bundler/man/bundle-add.1 +1 -1
- data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
- data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
- data/bundler/lib/bundler/man/bundle-check.1 +3 -1
- data/bundler/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
- data/bundler/lib/bundler/man/bundle-config.1 +1 -3
- data/bundler/lib/bundler/man/bundle-config.1.ronn +0 -3
- data/bundler/lib/bundler/man/bundle-console.1 +1 -1
- data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
- data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
- data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
- data/bundler/lib/bundler/man/bundle-help.1 +1 -1
- data/bundler/lib/bundler/man/bundle-info.1 +1 -1
- data/bundler/lib/bundler/man/bundle-init.1 +1 -1
- data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
- data/bundler/lib/bundler/man/bundle-install.1 +3 -3
- data/bundler/lib/bundler/man/bundle-install.1.ronn +2 -2
- data/bundler/lib/bundler/man/bundle-list.1 +1 -1
- data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
- data/bundler/lib/bundler/man/bundle-open.1 +1 -1
- data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
- data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
- data/bundler/lib/bundler/man/bundle-plugin.1 +7 -4
- data/bundler/lib/bundler/man/bundle-plugin.1.ronn +7 -3
- data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
- data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
- data/bundler/lib/bundler/man/bundle-show.1 +1 -1
- data/bundler/lib/bundler/man/bundle-update.1 +1 -1
- data/bundler/lib/bundler/man/bundle-version.1 +1 -1
- data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
- data/bundler/lib/bundler/man/bundle.1 +1 -1
- data/bundler/lib/bundler/man/gemfile.5 +3 -3
- data/bundler/lib/bundler/man/gemfile.5.ronn +2 -2
- data/bundler/lib/bundler/mirror.rb +3 -3
- data/bundler/lib/bundler/plugin/api/source.rb +2 -2
- data/bundler/lib/bundler/plugin/installer/path.rb +18 -0
- data/bundler/lib/bundler/plugin/installer.rb +36 -16
- data/bundler/lib/bundler/plugin/source_list.rb +4 -4
- data/bundler/lib/bundler/resolver/candidate.rb +1 -1
- data/bundler/lib/bundler/resolver.rb +54 -24
- data/bundler/lib/bundler/rubygems_ext.rb +12 -0
- data/bundler/lib/bundler/runtime.rb +1 -1
- data/bundler/lib/bundler/self_manager.rb +1 -1
- data/bundler/lib/bundler/settings.rb +14 -12
- data/bundler/lib/bundler/setup.rb +3 -0
- data/bundler/lib/bundler/source/git/git_proxy.rb +1 -1
- data/bundler/lib/bundler/source/git.rb +1 -1
- data/bundler/lib/bundler/source/rubygems/remote.rb +1 -1
- data/bundler/lib/bundler/source/rubygems.rb +7 -20
- data/bundler/lib/bundler/source_list.rb +17 -4
- data/bundler/lib/bundler/spec_set.rb +1 -1
- data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -3
- data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/bundler/lib/bundler/uri_credentials_filter.rb +2 -2
- data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +22 -22
- data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
- data/bundler/lib/bundler/vendored_net_http.rb +7 -3
- data/bundler/lib/bundler/vendored_timeout.rb +7 -3
- data/bundler/lib/bundler/vendored_uri.rb +18 -1
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/lib/bundler/yaml_serializer.rb +12 -0
- data/bundler/lib/bundler.rb +23 -2
- data/lib/rubygems/command.rb +1 -1
- data/lib/rubygems/command_manager.rb +2 -1
- data/lib/rubygems/commands/build_command.rb +2 -11
- data/lib/rubygems/commands/help_command.rb +2 -2
- data/lib/rubygems/commands/rdoc_command.rb +1 -8
- data/lib/rubygems/commands/rebuild_command.rb +264 -0
- data/lib/rubygems/commands/sources_command.rb +2 -2
- data/lib/rubygems/commands/update_command.rb +8 -9
- data/lib/rubygems/config_file.rb +20 -8
- data/lib/rubygems/defaults.rb +4 -4
- data/lib/rubygems/dependency.rb +2 -2
- data/lib/rubygems/dependency_list.rb +1 -1
- data/lib/rubygems/deprecate.rb +79 -77
- data/lib/rubygems/ext/cargo_builder.rb +1 -1
- data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +1 -1
- data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -1
- data/lib/rubygems/gemcutter_utilities.rb +40 -23
- data/lib/rubygems/gemspec_helpers.rb +19 -0
- data/lib/rubygems/local_remote_options.rb +6 -6
- data/lib/rubygems/package.rb +13 -7
- data/lib/rubygems/remote_fetcher.rb +3 -3
- data/lib/rubygems/request.rb +5 -5
- data/lib/rubygems/request_set.rb +1 -1
- data/lib/rubygems/requirement.rb +5 -0
- data/lib/rubygems/resolver/api_set.rb +1 -1
- data/lib/rubygems/resolver/best_set.rb +1 -1
- data/lib/rubygems/resolver/spec_specification.rb +7 -0
- data/lib/rubygems/resolver.rb +5 -5
- data/lib/rubygems/s3_uri_signer.rb +3 -3
- data/lib/rubygems/safe_yaml.rb +10 -1
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/source/git.rb +2 -2
- data/lib/rubygems/source_list.rb +1 -1
- data/lib/rubygems/specification.rb +6 -6
- data/lib/rubygems/specification_policy.rb +15 -7
- data/lib/rubygems/uri.rb +6 -6
- data/lib/rubygems/util/licenses.rb +43 -0
- data/lib/rubygems/util.rb +1 -1
- data/lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/delegates/specification_provider.rb +11 -11
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/log.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/vertex.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph.rb +2 -2
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/errors.rb +1 -1
- data/lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/specification_provider.rb +2 -2
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/ui.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolution.rb +3 -3
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolver.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/state.rb +1 -1
- data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/generic_request.rb +9 -9
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/header.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/request.rb +3 -3
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/requests.rb +30 -30
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/response.rb +2 -2
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/responses.rb +6 -6
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/status.rb +1 -1
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http.rb +15 -15
- data/lib/rubygems/{net-http → vendor/net-http}/lib/net/https.rb +1 -1
- data/lib/rubygems/vendor/optparse/lib/optparse/uri.rb +7 -0
- data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse.rb +11 -11
- data/lib/rubygems/{timeout → vendor/timeout}/lib/timeout.rb +1 -1
- data/lib/rubygems/{tsort → vendor/tsort}/lib/tsort.rb +2 -2
- data/lib/rubygems/vendor/uri/.document +1 -0
- data/lib/rubygems/vendor/uri/LICENSE.txt +22 -0
- data/lib/rubygems/vendor/uri/lib/uri/common.rb +853 -0
- data/lib/rubygems/vendor/uri/lib/uri/file.rb +100 -0
- data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/rubygems/vendor/uri/lib/uri/generic.rb +1588 -0
- data/lib/rubygems/vendor/uri/lib/uri/http.rb +125 -0
- data/lib/rubygems/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/rubygems/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/rubygems/vendor/uri/lib/uri/ldaps.rb +22 -0
- data/lib/rubygems/vendor/uri/lib/uri/mailto.rb +293 -0
- data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
- data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +183 -0
- data/lib/rubygems/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/rubygems/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/rubygems/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/rubygems/vendor/uri/lib/uri.rb +104 -0
- data/lib/rubygems/vendored_molinillo.rb +3 -0
- data/lib/rubygems/vendored_net_http.rb +5 -0
- data/lib/rubygems/vendored_optparse.rb +3 -0
- data/lib/rubygems/vendored_timeout.rb +5 -0
- data/lib/rubygems/vendored_tsort.rb +3 -0
- data/lib/rubygems/yaml_serializer.rb +12 -0
- data/lib/rubygems.rb +2 -2
- data/rubygems-update.gemspec +7 -2
- metadata +90 -67
- data/lib/rubygems/net/http.rb +0 -3
- data/lib/rubygems/optparse/lib/optparse/uri.rb +0 -7
- data/lib/rubygems/optparse.rb +0 -3
- data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/rubygems/resolver/molinillo.rb +0 -3
- data/lib/rubygems/timeout.rb +0 -3
- data/lib/rubygems/tsort.rb +0 -3
- /data/lib/rubygems/{net-http → vendor/molinillo}/.document +0 -0
- /data/lib/rubygems/{resolver → vendor}/molinillo/LICENSE +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-http}/.document +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/LICENSE.txt +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/backward.rb +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/exceptions.rb +0 -0
- /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/proxy_delta.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/net-protocol}/.document +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-protocol}/LICENSE.txt +0 -0
- /data/lib/rubygems/{net-protocol → vendor/net-protocol}/lib/net/protocol.rb +0 -0
- /data/lib/rubygems/{resolv → vendor/optparse}/.document +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/COPYING +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optionparser.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/ac.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/date.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/kwargs.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/shellwords.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/time.rb +0 -0
- /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/version.rb +0 -0
- /data/lib/rubygems/{resolver/molinillo → vendor/resolv}/.document +0 -0
- /data/lib/rubygems/{resolv → vendor/resolv}/LICENSE.txt +0 -0
- /data/lib/rubygems/{resolv → vendor/resolv}/lib/resolv.rb +0 -0
- /data/lib/rubygems/{timeout → vendor/timeout}/.document +0 -0
- /data/lib/rubygems/{timeout → vendor/timeout}/LICENSE.txt +0 -0
- /data/lib/rubygems/{tsort → vendor/tsort}/.document +0 -0
- /data/lib/rubygems/{tsort → vendor/tsort}/LICENSE.txt +0 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/http.rb
|
3
|
+
#
|
4
|
+
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
+
#
|
7
|
+
# See Gem::URI for general documentation
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'generic'
|
11
|
+
|
12
|
+
module Gem::URI
|
13
|
+
|
14
|
+
#
|
15
|
+
# The syntax of HTTP URIs is defined in RFC1738 section 3.3.
|
16
|
+
#
|
17
|
+
# Note that the Ruby Gem::URI library allows HTTP URLs containing usernames and
|
18
|
+
# passwords. This is not legal as per the RFC, but used to be
|
19
|
+
# supported in Internet Explorer 5 and 6, before the MS04-004 security
|
20
|
+
# update. See <URL:http://support.microsoft.com/kb/834489>.
|
21
|
+
#
|
22
|
+
class HTTP < Generic
|
23
|
+
# A Default port of 80 for Gem::URI::HTTP.
|
24
|
+
DEFAULT_PORT = 80
|
25
|
+
|
26
|
+
# An Array of the available components for Gem::URI::HTTP.
|
27
|
+
COMPONENT = %i[
|
28
|
+
scheme
|
29
|
+
userinfo host port
|
30
|
+
path
|
31
|
+
query
|
32
|
+
fragment
|
33
|
+
].freeze
|
34
|
+
|
35
|
+
#
|
36
|
+
# == Description
|
37
|
+
#
|
38
|
+
# Creates a new Gem::URI::HTTP object from components, with syntax checking.
|
39
|
+
#
|
40
|
+
# The components accepted are userinfo, host, port, path, query, and
|
41
|
+
# fragment.
|
42
|
+
#
|
43
|
+
# The components should be provided either as an Array, or as a Hash
|
44
|
+
# with keys formed by preceding the component names with a colon.
|
45
|
+
#
|
46
|
+
# If an Array is used, the components must be passed in the
|
47
|
+
# order <code>[userinfo, host, port, path, query, fragment]</code>.
|
48
|
+
#
|
49
|
+
# Example:
|
50
|
+
#
|
51
|
+
# uri = Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
|
52
|
+
#
|
53
|
+
# uri = Gem::URI::HTTP.build([nil, "www.example.com", nil, "/path",
|
54
|
+
# "query", 'fragment'])
|
55
|
+
#
|
56
|
+
# Currently, if passed userinfo components this method generates
|
57
|
+
# invalid HTTP URIs as per RFC 1738.
|
58
|
+
#
|
59
|
+
def self.build(args)
|
60
|
+
tmp = Util.make_components_hash(self, args)
|
61
|
+
super(tmp)
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# == Description
|
66
|
+
#
|
67
|
+
# Returns the full path for an HTTP request, as required by Net::HTTP::Get.
|
68
|
+
#
|
69
|
+
# If the Gem::URI contains a query, the full path is Gem::URI#path + '?' + Gem::URI#query.
|
70
|
+
# Otherwise, the path is simply Gem::URI#path.
|
71
|
+
#
|
72
|
+
# Example:
|
73
|
+
#
|
74
|
+
# uri = Gem::URI::HTTP.build(path: '/foo/bar', query: 'test=true')
|
75
|
+
# uri.request_uri # => "/foo/bar?test=true"
|
76
|
+
#
|
77
|
+
def request_uri
|
78
|
+
return unless @path
|
79
|
+
|
80
|
+
url = @query ? "#@path?#@query" : @path.dup
|
81
|
+
url.start_with?(?/.freeze) ? url : ?/ + url
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# == Description
|
86
|
+
#
|
87
|
+
# Returns the authority for an HTTP uri, as defined in
|
88
|
+
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
|
89
|
+
#
|
90
|
+
#
|
91
|
+
# Example:
|
92
|
+
#
|
93
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
|
94
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
|
95
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
|
96
|
+
#
|
97
|
+
def authority
|
98
|
+
if port == default_port
|
99
|
+
host
|
100
|
+
else
|
101
|
+
"#{host}:#{port}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# == Description
|
107
|
+
#
|
108
|
+
# Returns the origin for an HTTP uri, as defined in
|
109
|
+
# https://datatracker.ietf.org/doc/html/rfc6454.
|
110
|
+
#
|
111
|
+
#
|
112
|
+
# Example:
|
113
|
+
#
|
114
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
|
115
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
|
116
|
+
# Gem::URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
|
117
|
+
# Gem::URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
|
118
|
+
#
|
119
|
+
def origin
|
120
|
+
"#{scheme}://#{authority}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
register_scheme 'HTTP', HTTP
|
125
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/https.rb
|
3
|
+
#
|
4
|
+
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
+
#
|
7
|
+
# See Gem::URI for general documentation
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'http'
|
11
|
+
|
12
|
+
module Gem::URI
|
13
|
+
|
14
|
+
# The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
|
15
|
+
# than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
|
16
|
+
# see Gem::URI::HTTP.
|
17
|
+
class HTTPS < HTTP
|
18
|
+
# A Default port of 443 for Gem::URI::HTTPS
|
19
|
+
DEFAULT_PORT = 443
|
20
|
+
end
|
21
|
+
|
22
|
+
register_scheme 'HTTPS', HTTPS
|
23
|
+
end
|
@@ -0,0 +1,261 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/ldap.rb
|
3
|
+
#
|
4
|
+
# Author::
|
5
|
+
# Takaaki Tateishi <ttate@jaist.ac.jp>
|
6
|
+
# Akira Yamada <akira@ruby-lang.org>
|
7
|
+
# License::
|
8
|
+
# Gem::URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
|
9
|
+
# You can redistribute it and/or modify it under the same term as Ruby.
|
10
|
+
#
|
11
|
+
# See Gem::URI for general documentation
|
12
|
+
#
|
13
|
+
|
14
|
+
require_relative 'generic'
|
15
|
+
|
16
|
+
module Gem::URI
|
17
|
+
|
18
|
+
#
|
19
|
+
# LDAP Gem::URI SCHEMA (described in RFC2255).
|
20
|
+
#--
|
21
|
+
# ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
|
22
|
+
#++
|
23
|
+
class LDAP < Generic
|
24
|
+
|
25
|
+
# A Default port of 389 for Gem::URI::LDAP.
|
26
|
+
DEFAULT_PORT = 389
|
27
|
+
|
28
|
+
# An Array of the available components for Gem::URI::LDAP.
|
29
|
+
COMPONENT = [
|
30
|
+
:scheme,
|
31
|
+
:host, :port,
|
32
|
+
:dn,
|
33
|
+
:attributes,
|
34
|
+
:scope,
|
35
|
+
:filter,
|
36
|
+
:extensions,
|
37
|
+
].freeze
|
38
|
+
|
39
|
+
# Scopes available for the starting point.
|
40
|
+
#
|
41
|
+
# * SCOPE_BASE - the Base DN
|
42
|
+
# * SCOPE_ONE - one level under the Base DN, not including the base DN and
|
43
|
+
# not including any entries under this
|
44
|
+
# * SCOPE_SUB - subtrees, all entries at all levels
|
45
|
+
#
|
46
|
+
SCOPE = [
|
47
|
+
SCOPE_ONE = 'one',
|
48
|
+
SCOPE_SUB = 'sub',
|
49
|
+
SCOPE_BASE = 'base',
|
50
|
+
].freeze
|
51
|
+
|
52
|
+
#
|
53
|
+
# == Description
|
54
|
+
#
|
55
|
+
# Creates a new Gem::URI::LDAP object from components, with syntax checking.
|
56
|
+
#
|
57
|
+
# The components accepted are host, port, dn, attributes,
|
58
|
+
# scope, filter, and extensions.
|
59
|
+
#
|
60
|
+
# The components should be provided either as an Array, or as a Hash
|
61
|
+
# with keys formed by preceding the component names with a colon.
|
62
|
+
#
|
63
|
+
# If an Array is used, the components must be passed in the
|
64
|
+
# order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
|
65
|
+
#
|
66
|
+
# Example:
|
67
|
+
#
|
68
|
+
# uri = Gem::URI::LDAP.build({:host => 'ldap.example.com',
|
69
|
+
# :dn => '/dc=example'})
|
70
|
+
#
|
71
|
+
# uri = Gem::URI::LDAP.build(["ldap.example.com", nil,
|
72
|
+
# "/dc=example;dc=com", "query", nil, nil, nil])
|
73
|
+
#
|
74
|
+
def self.build(args)
|
75
|
+
tmp = Util::make_components_hash(self, args)
|
76
|
+
|
77
|
+
if tmp[:dn]
|
78
|
+
tmp[:path] = tmp[:dn]
|
79
|
+
end
|
80
|
+
|
81
|
+
query = []
|
82
|
+
[:extensions, :filter, :scope, :attributes].collect do |x|
|
83
|
+
next if !tmp[x] && query.size == 0
|
84
|
+
query.unshift(tmp[x])
|
85
|
+
end
|
86
|
+
|
87
|
+
tmp[:query] = query.join('?')
|
88
|
+
|
89
|
+
return super(tmp)
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# == Description
|
94
|
+
#
|
95
|
+
# Creates a new Gem::URI::LDAP object from generic Gem::URI components as per
|
96
|
+
# RFC 2396. No LDAP-specific syntax checking is performed.
|
97
|
+
#
|
98
|
+
# Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
|
99
|
+
# +opaque+, +query+, and +fragment+, in that order.
|
100
|
+
#
|
101
|
+
# Example:
|
102
|
+
#
|
103
|
+
# uri = Gem::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
|
104
|
+
# "/dc=example;dc=com", nil, "query", nil)
|
105
|
+
#
|
106
|
+
# See also Gem::URI::Generic.new.
|
107
|
+
#
|
108
|
+
def initialize(*arg)
|
109
|
+
super(*arg)
|
110
|
+
|
111
|
+
if @fragment
|
112
|
+
raise InvalidURIError, 'bad LDAP URL'
|
113
|
+
end
|
114
|
+
|
115
|
+
parse_dn
|
116
|
+
parse_query
|
117
|
+
end
|
118
|
+
|
119
|
+
# Private method to cleanup +dn+ from using the +path+ component attribute.
|
120
|
+
def parse_dn
|
121
|
+
raise InvalidURIError, 'bad LDAP URL' unless @path
|
122
|
+
@dn = @path[1..-1]
|
123
|
+
end
|
124
|
+
private :parse_dn
|
125
|
+
|
126
|
+
# Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
|
127
|
+
# from using the +query+ component attribute.
|
128
|
+
def parse_query
|
129
|
+
@attributes = nil
|
130
|
+
@scope = nil
|
131
|
+
@filter = nil
|
132
|
+
@extensions = nil
|
133
|
+
|
134
|
+
if @query
|
135
|
+
attrs, scope, filter, extensions = @query.split('?')
|
136
|
+
|
137
|
+
@attributes = attrs if attrs && attrs.size > 0
|
138
|
+
@scope = scope if scope && scope.size > 0
|
139
|
+
@filter = filter if filter && filter.size > 0
|
140
|
+
@extensions = extensions if extensions && extensions.size > 0
|
141
|
+
end
|
142
|
+
end
|
143
|
+
private :parse_query
|
144
|
+
|
145
|
+
# Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
|
146
|
+
def build_path_query
|
147
|
+
@path = '/' + @dn
|
148
|
+
|
149
|
+
query = []
|
150
|
+
[@extensions, @filter, @scope, @attributes].each do |x|
|
151
|
+
next if !x && query.size == 0
|
152
|
+
query.unshift(x)
|
153
|
+
end
|
154
|
+
@query = query.join('?')
|
155
|
+
end
|
156
|
+
private :build_path_query
|
157
|
+
|
158
|
+
# Returns dn.
|
159
|
+
def dn
|
160
|
+
@dn
|
161
|
+
end
|
162
|
+
|
163
|
+
# Private setter for dn +val+.
|
164
|
+
def set_dn(val)
|
165
|
+
@dn = val
|
166
|
+
build_path_query
|
167
|
+
@dn
|
168
|
+
end
|
169
|
+
protected :set_dn
|
170
|
+
|
171
|
+
# Setter for dn +val+.
|
172
|
+
def dn=(val)
|
173
|
+
set_dn(val)
|
174
|
+
val
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns attributes.
|
178
|
+
def attributes
|
179
|
+
@attributes
|
180
|
+
end
|
181
|
+
|
182
|
+
# Private setter for attributes +val+.
|
183
|
+
def set_attributes(val)
|
184
|
+
@attributes = val
|
185
|
+
build_path_query
|
186
|
+
@attributes
|
187
|
+
end
|
188
|
+
protected :set_attributes
|
189
|
+
|
190
|
+
# Setter for attributes +val+.
|
191
|
+
def attributes=(val)
|
192
|
+
set_attributes(val)
|
193
|
+
val
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns scope.
|
197
|
+
def scope
|
198
|
+
@scope
|
199
|
+
end
|
200
|
+
|
201
|
+
# Private setter for scope +val+.
|
202
|
+
def set_scope(val)
|
203
|
+
@scope = val
|
204
|
+
build_path_query
|
205
|
+
@scope
|
206
|
+
end
|
207
|
+
protected :set_scope
|
208
|
+
|
209
|
+
# Setter for scope +val+.
|
210
|
+
def scope=(val)
|
211
|
+
set_scope(val)
|
212
|
+
val
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns filter.
|
216
|
+
def filter
|
217
|
+
@filter
|
218
|
+
end
|
219
|
+
|
220
|
+
# Private setter for filter +val+.
|
221
|
+
def set_filter(val)
|
222
|
+
@filter = val
|
223
|
+
build_path_query
|
224
|
+
@filter
|
225
|
+
end
|
226
|
+
protected :set_filter
|
227
|
+
|
228
|
+
# Setter for filter +val+.
|
229
|
+
def filter=(val)
|
230
|
+
set_filter(val)
|
231
|
+
val
|
232
|
+
end
|
233
|
+
|
234
|
+
# Returns extensions.
|
235
|
+
def extensions
|
236
|
+
@extensions
|
237
|
+
end
|
238
|
+
|
239
|
+
# Private setter for extensions +val+.
|
240
|
+
def set_extensions(val)
|
241
|
+
@extensions = val
|
242
|
+
build_path_query
|
243
|
+
@extensions
|
244
|
+
end
|
245
|
+
protected :set_extensions
|
246
|
+
|
247
|
+
# Setter for extensions +val+.
|
248
|
+
def extensions=(val)
|
249
|
+
set_extensions(val)
|
250
|
+
val
|
251
|
+
end
|
252
|
+
|
253
|
+
# Checks if Gem::URI has a path.
|
254
|
+
# For Gem::URI::LDAP this will return +false+.
|
255
|
+
def hierarchical?
|
256
|
+
false
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
register_scheme 'LDAP', LDAP
|
261
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/ldap.rb
|
3
|
+
#
|
4
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
5
|
+
#
|
6
|
+
# See Gem::URI for general documentation
|
7
|
+
#
|
8
|
+
|
9
|
+
require_relative 'ldap'
|
10
|
+
|
11
|
+
module Gem::URI
|
12
|
+
|
13
|
+
# The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
|
14
|
+
# than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
|
15
|
+
# see Gem::URI::LDAP.
|
16
|
+
class LDAPS < LDAP
|
17
|
+
# A Default port of 636 for Gem::URI::LDAPS
|
18
|
+
DEFAULT_PORT = 636
|
19
|
+
end
|
20
|
+
|
21
|
+
register_scheme 'LDAPS', LDAPS
|
22
|
+
end
|