import agcaldav-0.2.5.3

ruby-agcaldav is yet another great Ruby client for CalDAV calendar and
tasks.

ok jeremy@
This commit is contained in:
jasper 2013-03-18 20:22:50 +00:00
parent 4fd2e84642
commit 5bf21f5978
7 changed files with 307 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# $OpenBSD: Makefile,v 1.1.1.1 2013/03/18 20:22:50 jasper Exp $
COMMENT= Ruby client for CalDAV calendars
DISTNAME= agcaldav-0.2.5.3
CATEGORIES= net
HOMEPAGE= https://github.com/agilastic/agcaldav
# MIT
PERMIT_PACKAGE_CDROM= Yes
MODULES= lang/ruby
CONFIGURE_STYLE= gem
BUILD_DEPENDS= ${RUN_DEPENDS}
RUN_DEPENDS= devel/ruby-uuid,${MODRUBY_FLAVOR} \
net/ruby-net-http-digest_auth,${MODRUBY_FLAVOR} \
textproc/ruby-builder,${MODRUBY_FLAVOR} \
textproc/ruby-icalendar,${MODRUBY_FLAVOR}
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (agcaldav-0.2.5.3.gem) = pb1bejre7aIFwBKKvEpoINk09aUW6qbxeybc7GryepY=
SIZE (agcaldav-0.2.5.3.gem) = 12288

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-agcaldav_gemspec,v 1.1.1.1 2013/03/18 20:22:50 jasper Exp $
commit c13ea74da87d56c526f0187abe30e9d185f43374
Author: Geoff Evans <gbeevans@me.com>
Date: Wed Feb 20 11:01:50 2013 +1300
Subject:Adds Digest Authentication
--- agcaldav.gemspec.orig Thu Jan 1 01:00:00 1970
+++ agcaldav.gemspec Mon Mar 18 10:09:33 2013
@@ -18,8 +18,10 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'icalendar'
s.add_runtime_dependency 'uuid'
s.add_runtime_dependency 'builder'
+ s.add_runtime_dependency 'net-http-digest_auth'
s.add_development_dependency "rspec"
- s.add_development_dependency "fakeweb"
+ s.add_development_dependency "fakeweb"
+
s.description = <<-DESC

View File

@ -0,0 +1,217 @@
$OpenBSD: patch-lib_agcaldav_client_rb,v 1.1.1.1 2013/03/18 20:22:50 jasper Exp $
commit c13ea74da87d56c526f0187abe30e9d185f43374
Author: Geoff Evans <gbeevans@me.com>
Date: Wed Feb 20 11:01:50 2013 +1300
Subject:Adds Digest Authentication
commit 20687529a3c3554d0f51dabd81e06b172a96b940
Author: Geoff Evans <gbeevans@me.com>
Date: Wed Mar 6 12:34:46 2013 +1300
Subject:Fix Digest to work over ssl.
--- lib/agcaldav/client.rb.orig Thu Jan 1 01:00:00 1970
+++ lib/agcaldav/client.rb Mon Mar 18 11:06:49 2013
@@ -17,6 +17,7 @@ module AgCalDAV
@proxy_host = proxy_uri.host
@proxy_port = proxy_uri.port.to_i
end
+
uri = URI(data[:uri])
@host = uri.host
@port = uri.port.to_i
@@ -24,6 +25,24 @@ module AgCalDAV
@user = data[:user]
@password = data[:password]
@ssl = uri.scheme == 'https'
+
+ unless data[:authtype].nil?
+ @authtype = data[:authtype]
+ if @authtype == 'digest'
+
+ @digest_auth = Net::HTTP::DigestAuth.new
+ @duri = URI.parse data[:uri]
+ @duri.user = @user
+ @duri.password = @password
+
+ elsif @authtype == 'basic'
+ #Don't Raise or do anything else
+ else
+ raise "Authentication Type Specified Is Not Valid. Please use basic or digest"
+ end
+ else
+ @authtype = 'basic'
+ end
end
def __create_http
@@ -44,14 +63,22 @@ module AgCalDAV
events = []
res = nil
__create_http.start {|http|
+
req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml'} )
- req.basic_auth @user, @password
- req.body = AgCalDAV::Request::ReportVEVENT.new(DateTime.parse(data[:start]).strftime("%Y%m%dT%H%M"),
- DateTime.parse(data[:end]).strftime("%Y%m%dT%H%M") ).to_xml
+
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('REPORT')
+ end
+
+ req.body = AgCalDAV::Request::ReportVEVENT.new(DateTime.parse(data[:start]).utc.strftime("%Y%m%dT%H%M%S"),
+ DateTime.parse(data[:end]).utc.strftime("%Y%m%dT%H%M%S") ).to_xml
res = http.request(req)
}
errorhandling res
result = ""
+
xml = REXML::Document.new(res.body)
REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << c.text}
r = Icalendar.parse(result)
@@ -70,8 +97,12 @@ module AgCalDAV
def find_event uuid
res = nil
__create_http.start {|http|
- req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
- req.basic_auth @user, @password
+ req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('GET')
+ end
res = http.request( req )
}
errorhandling res
@@ -89,7 +120,11 @@ module AgCalDAV
res = nil
__create_http.start {|http|
req = Net::HTTP::Delete.new("#{@url}/#{uuid}.ics")
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('DELETE')
+ end
res = http.request( req )
}
errorhandling res
@@ -126,7 +161,11 @@ module AgCalDAV
__create_http.start { |http|
req = Net::HTTP::Put.new("#{@url}/#{uuid}.ics")
req['Content-Type'] = 'text/calendar'
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('PUT')
+ end
req.body = cstring
res = http.request( req )
}
@@ -159,7 +198,11 @@ module AgCalDAV
res = nil
__create_http.start {|http|
req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('GET')
+ end
res = http.request( req )
}
errorhandling res
@@ -196,7 +239,11 @@ module AgCalDAV
__create_http.start { |http|
req = Net::HTTP::Put.new("#{@url}/#{uuid}.ics")
req['Content-Type'] = 'text/calendar'
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('PUT')
+ end
req.body = cstring
res = http.request( req )
}
@@ -210,7 +257,11 @@ module AgCalDAV
__create_http.start {|http|
req = Net::HTTP::Report.new(@url, initheader = {'Content-Type'=>'application/xml'} )
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('REPORT')
+ end
req.body = AgCalDAV::Request::ReportVTODO.new.to_xml
res = http.request( req )
}
@@ -219,29 +270,54 @@ module AgCalDAV
end
private
+
+ def digestauth method
+
+ h = Net::HTTP.new @duri.host, @duri.port
+
+ req = Net::HTTP::Get.new @duri.request_uri
+
+ if @ssl
+ h.use_ssl = @ssl
+ h.verify_mode = OpenSSL::SSL::VERIFY_NONE
+ end
+
+ res = h.request req
+ # res is a 401 response with a WWW-Authenticate header
+
+ auth = @digest_auth.auth_header @duri, res['www-authenticate'], method
+
+ return auth
+ end
+
def entry_with_uuid_exists? uuid
res = nil
+
__create_http.start {|http|
req = Net::HTTP::Get.new("#{@url}/#{uuid}.ics")
- req.basic_auth @user, @password
+ if not @authtype == 'digest'
+ req.basic_auth @user, @password
+ else
+ req.add_field 'Authorization', digestauth('GET')
+ end
+
res = http.request( req )
- }
- if res.body.empty?
- return false
+
+ }
+ begin
+ Icalendar.parse(res.body)
+ rescue
+ return false
else
- return true
+ return true
end
end
-
def errorhandling response
raise AuthenticationError if response.code.to_i == 401
raise NotExistError if response.code.to_i == 410
raise APIError if response.code.to_i >= 500
end
end
-
-
-
class AgCalDAVError < StandardError

View File

@ -0,0 +1,15 @@
$OpenBSD: patch-lib_agcaldav_rb,v 1.1.1.1 2013/03/18 20:22:50 jasper Exp $
commit c13ea74da87d56c526f0187abe30e9d185f43374
Author: Geoff Evans <gbeevans@me.com>
Date: Wed Feb 20 11:01:50 2013 +1300
Subject:Adds Digest Authentication
--- lib/agcaldav.rb.orig Thu Jan 1 01:00:00 1970
+++ lib/agcaldav.rb Mon Mar 18 10:09:33 2013
@@ -1,4 +1,5 @@
require 'net/https'
+require 'net/http/digest_auth'
require 'uuid'
require 'rexml/document'
require 'rexml/xpath'

View File

@ -0,0 +1,2 @@
ruby-agcaldav is yet another great Ruby client for CalDAV calendar and
tasks.

View File

@ -0,0 +1,27 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2013/03/18 20:22:50 jasper Exp $
${GEM_LIB}/cache/${DISTNAME}.gem
${GEM_LIB}/gems/${DISTNAME}/
${GEM_LIB}/gems/${DISTNAME}/.gitignore
${GEM_LIB}/gems/${DISTNAME}/.rspec
${GEM_LIB}/gems/${DISTNAME}/CHANGELOG.rdoc
${GEM_LIB}/gems/${DISTNAME}/README.md
${GEM_LIB}/gems/${DISTNAME}/Rakefile
${GEM_LIB}/gems/${DISTNAME}/agcaldav.gemspec
${GEM_LIB}/gems/${DISTNAME}/lib/
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/client.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/event.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/filter.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/format.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/net.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/query.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/request.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/todo.rb
${GEM_LIB}/gems/${DISTNAME}/lib/agcaldav/version.rb
${GEM_LIB}/gems/${DISTNAME}/spec/
${GEM_LIB}/gems/${DISTNAME}/spec/agcaldav/
${GEM_LIB}/gems/${DISTNAME}/spec/agcaldav/client_spec.rb
${GEM_LIB}/gems/${DISTNAME}/spec/spec.opts
${GEM_LIB}/gems/${DISTNAME}/spec/spec_helper.rb
${GEM_LIB}/specifications/${DISTNAME}.gemspec