class Sharepoint::Session
Attributes
site[RW]
Public Class Methods
new(site)
click to toggle source
# File lib/sharepoint-session.rb, line 40 def initialize site @site = site end
Public Instance Methods
authenticate(user, password, sts_url = nil)
click to toggle source
# File lib/sharepoint-session.rb, line 44 def authenticate user, password, sts_url = nil sts_url ||= MICROSOFT_STS_URL authenticate_to_sts user, password, sts_url get_access_token end
Private Instance Methods
authenticate_to_sts(user, password, sts_url)
click to toggle source
# File lib/sharepoint-session.rb, line 55 def authenticate_to_sts user, password, sts_url query = Soap::Authenticate.new username: user, password: password, url: @site.authentication_path response = Curl::Easy.http_post sts_url, query.render rescue raise ConnexionToStsFailed.new response.body_str.scan(/<wsse:BinarySecurityToken[^>]*>([^<]+)</) do offset = ($~.offset 1) @security_token = response.body[offset[0]..offset[1] - 1] end authentication_failed response.body_str if @security_token.nil? end
authentication_failed(xml)
click to toggle source
# File lib/sharepoint-session.rb, line 82 def authentication_failed xml message = 'Unknown authentication error' xml.scan(/<psf:text[^>]*>([^<]+)</) do offset = ($~.offset 1) message = xml[offset[0]..offset[1] - 1] end raise AuthenticationFailed.new message end
get_access_token()
click to toggle source
# File lib/sharepoint-session.rb, line 75 def get_access_token http = Curl::Easy.http_post @site.authentication_path, @security_token @rtFa = get_cookie_from_header http.header_str, 'rtFa' @fed_auth = get_cookie_from_header http.header_str, 'FedAuth' raise UnknownAuthenticationError.new if @fed_auth.nil? or @rtFa.nil? end