it_tools 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'it_tools/it_tools'
4
+
5
+ vpnTools = ItTools::VpnTools.new
6
+ puts vpnTools.login_to_url
@@ -1,5 +1,6 @@
1
1
  require 'socket'
2
2
  require 'timeout'
3
+ require 'net/http'
3
4
 
4
5
  module ItTools
5
6
  class VpnTools
@@ -26,6 +27,48 @@ module ItTools
26
27
  return TRUE
27
28
  end
28
29
  end
30
+
31
+ def login_to_url
32
+ desired_url = "https://secure-ausomxnga.crmondemand.com/"
33
+ port = 443
34
+ username = 'fenton.travers@oracle.com'
35
+ password = 'Veronica8Li'
36
+ puts "[URL]: " + desired_url
37
+ puts "[PORT]: #{port}"
38
+ puts "[USERNAME]: " + username
39
+
40
+ # Failed: Oracle Access Manager Version: 11.1.1.5.0
41
+
42
+
43
+ login_to_url2(desired_url, port, username, password)
44
+ end
45
+
46
+ def login_to_url2(url, port, username, password, limit = 10)
47
+ # You should choose a better exception.
48
+ raise ArgumentError, 'too many HTTP redirects' if limit == 0
49
+
50
+ uri = URI(url)
51
+
52
+ req = Net::HTTP::Get.new(uri.request_uri)
53
+ req.basic_auth username, password
54
+
55
+ res = Net::HTTP.start(uri.host, port, :use_ssl => uri.scheme == 'https') {|http|
56
+ http.request(req)
57
+ }
58
+
59
+ case res
60
+ when Net::HTTPSuccess then
61
+ puts "Successfully logged in." # res.body
62
+ when Net::HTTPRedirection then
63
+ location = res['location']
64
+ warn "redirected to #{location}"
65
+ login_to_url2(location, port, username, password, limit - 1)
66
+ else
67
+ response.value
68
+ end
69
+ end
70
+
71
+
29
72
  end
30
73
  end
31
74
 
@@ -0,0 +1,21 @@
1
+ require 'pony'
2
+
3
+ module ItTools
4
+ class MailTools
5
+ def sendSmtpSslMail(from,to,subject,body,user, password, host, port)
6
+ Pony.mail(:to => to, :from => from, :subject => subject, :body => body, :via => :smtp, :smtp => {
7
+ :host => host,
8
+ :port => port,
9
+ :user => user,
10
+ :password => password,
11
+ :auth => :login})
12
+ end
13
+ def sendMailToBeehive(from,to,subject,body,user, password)
14
+ sendSmtpSslMail(from,to,subject,body,user, password, "stbeehive.oracle.com", 465)
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+
21
+
@@ -1,3 +1,3 @@
1
1
  module ItTools
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: it_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,13 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-12 00:00:00.000000000Z
12
+ date: 2012-01-27 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: tasks include checking in all of my repositories either internal or externally
15
15
  email:
16
16
  - fenton.travers@oracle.com
17
17
  executables:
18
+ - loginToUrl
18
19
  - onVpn
19
20
  - onVpn~
20
21
  extensions: []
@@ -23,11 +24,13 @@ files:
23
24
  - .gitignore
24
25
  - Gemfile
25
26
  - Rakefile
27
+ - bin/loginToUrl
26
28
  - bin/onVpn
27
29
  - bin/onVpn~
28
30
  - it_tools.gemspec
29
31
  - lib/it_tools.rb
30
32
  - lib/it_tools/it_tools.rb
33
+ - lib/it_tools/mail.rb
31
34
  - lib/it_tools/version.rb
32
35
  homepage: ''
33
36
  licenses: []
@@ -49,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
52
  version: '0'
50
53
  requirements: []
51
54
  rubyforge_project: it_tools
52
- rubygems_version: 1.8.10
55
+ rubygems_version: 1.8.15
53
56
  signing_key:
54
57
  specification_version: 3
55
58
  summary: automate repetitive tasks