cisco-ise 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ require 'cisco-ise/acct-status-element'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make an Acct Status API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ # mac_address<String>:: The MAC address that is being search for
11
+ # duration(Fixnum) How many seconds to look back for the account status
12
+ #
13
+ # @examples
14
+ # #Create session
15
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
16
+ #
17
+ # #Create and Acct Status session
18
+ # acct = CiscoISE::AcctStatusApi.new(ise_session, '00:17:89:01:23:45', 20000)
19
+ #
20
+ # acct.each do |element|
21
+ # puts element.calling_station_id + ':' + element.paks_in
22
+ # end
23
+ #
24
+ class AcctStatusApi < CommonList
25
+
26
+ def initialize(session, mac_address, duration = 0)
27
+ super(session, "AcctStatus/MACAddress/#{mac_address}/#{duration}")
28
+ end
29
+
30
+ def each
31
+ super('/acctStatusOutputList/acctStatusList/acctStatusElements',CiscoISE::AcctStatusElement)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Class to store parsed data from a AcctStatusElement objects. Refer to acct-status-api.rb for usage examples.
5
+ #
6
+ class AcctStatusElement < CommonElement
7
+ attr_accessor :calling_station_id,
8
+ :audit_session_id,
9
+ :paks_in,
10
+ :paks_out,
11
+ :bytes_in,
12
+ :bytes_out,
13
+ :session_time,
14
+ :username,
15
+ :server
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'cisco-ise/session-count'
2
+
3
+ module CiscoISE
4
+
5
+
6
+ #
7
+ # Make an Active Count API call
8
+ #
9
+ # #Parameters
10
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
11
+ #
12
+ # @examples
13
+ # #Create session
14
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
15
+ #
16
+ # #Access the count
17
+ # count = CiscoISE::ActiveCountApi.new(ise_session).count
18
+ #
19
+
20
+ class ActiveCountApi < CommonCount
21
+
22
+ def initialize(session)
23
+ super(session, 'Session/ActiveCount')
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ require 'cisco-ise/active-session'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make an Active List API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ #
11
+ # @examples
12
+ # #Create session
13
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
14
+ #
15
+ # #Create and Auth List query
16
+ # active = CiscoISE::ActiveListApi.new(ise_session)
17
+ #
18
+ # #Iterate through each active status
19
+ # active.each do |record|
20
+ # puts record.user_name
21
+ # end
22
+ #
23
+
24
+ class ActiveListApi < CommonList
25
+
26
+ def initialize(session)
27
+ super(session, 'Session/ActiveList')
28
+ end
29
+
30
+ def each
31
+ super("*/activeSession",CiscoISE::ActiveSession)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Class to store parsed data from a ActiveSession objects. Refer to active-list-api.rb for usage examples.
5
+ #
6
+ class ActiveSession < CommonElement
7
+ attr_accessor :user_name, :nas_ip_address, :server, :calling_station_id,
8
+ :acct_session_id, :audit_session_id, :framed_ip_address
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ require 'cisco-ise/active-session'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make an Auth List API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ # start_time<String>:: Limits the auth list query by a time
11
+ # end_time<String>:: Limits the auth list query by a time
12
+ #
13
+ # @examples
14
+ # #Create session
15
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
16
+ #
17
+ # #Create and Auth List query
18
+ # auth = CiscoISE::AuthListApi.new(ise_session)
19
+ #
20
+ # #Iterate through each auth status
21
+ # auth.each do |record|
22
+ # puts record.user_name
23
+ # end
24
+ #
25
+ class AuthListApi < CommonList
26
+
27
+ def initialize(session, start_time = nil, end_time = nil)
28
+ super(session, "Session/AuthList/#{start_time ? start_time : 'null'}/#{end_time ? end_time : 'null'}")
29
+ end
30
+
31
+ def each
32
+ super("*/activeSession",CiscoISE::ActiveSession)
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'cisco-ise/auth-status-element'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make an Auth Status API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ # seconds<Fixnum>:: Limits results to those that occurred in the past <seconds>
11
+ # records<Fixnum>:: Limits the amount of records returned
12
+ #
13
+ # @examples
14
+ # #Create session
15
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
16
+ #
17
+ # #Create and Auth Status session. By default this query returns records that occurred in the last 10 days
18
+ # #(864000 seconds) and limits the records to 200.
19
+ # auth = CiscoISE::AuthStatusApi.new(ise_session, '00:17:89:01:23:45')
20
+ #
21
+ # #To limit the results to events in the last hour (60 seconds x 60 minutes = 3600 seconds) and limit the records to 100:
22
+ # auth = CiscoISE::AuthStatusApi.new(ise_session, '00:17:89:01:23:45',3600,100)
23
+
24
+ # #Iterate through each auth status
25
+ # auth.each do |element|
26
+ # puts "doing something with " + element.username
27
+ # end
28
+ #
29
+ class AuthStatusApi < CommonList
30
+
31
+ def initialize(session, mac_address, seconds = 0, records = 0 )
32
+ super(session, "AuthStatus/MACAddress/#{mac_address}/#{seconds}/#{records}/All")
33
+ end
34
+
35
+ def each
36
+ super('/authStatusOutputList/authStatusList/authStatusElements',CiscoISE::AuthStatusElement)
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Class to store parsed data from a AuthStatusElement objects. Refer to auth-status-api.rb for usage examples.
5
+ #
6
+ class AuthStatusElement < CommonElement
7
+ attr_accessor :passed, :failed, :user_name, :nas_ip_address, :calling_station_id, :nas_port, :identity_group,
8
+ :network_device_name, :acs_server, :framed_ip_address, :network_device_groups, :access_service,
9
+ :acs_timestamp, :authentication_method, :execution_steps, :audit_session_id, :nas_port_id,
10
+ :nac_policy_compliance, :selected_azn_profiles, :service_type, :message_code, :destination_ip_address,
11
+ :nas_port_type, :id, :acsview_timestamp, :acs_session_id, :service_selection_policy, :authorization_policy,
12
+ :identity_store, :response, :use_case, :cisco_av_pair, :acs_username, :radius_username,
13
+ :authentication_identity_store,:response_time, :other_attributes
14
+ end # AuthStatusElement
15
+ end
@@ -0,0 +1,54 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Generic class to be inherited by any class performing CoA functionality.
5
+ # Refer to disconnect-api.rb and reauth-api.rb for usage examples.
6
+ #
7
+ class Coa < CommonElement
8
+
9
+ def initialize(session)
10
+ @session = session
11
+ self
12
+ end
13
+
14
+ def success?
15
+ success = @xml.elements["//results"]
16
+ success.nil? ? false : success.text == 'true'
17
+ end
18
+
19
+ private
20
+
21
+ #
22
+ # Perform a type zero reauth or disconnect
23
+ #
24
+ def type_zero(active, method)
25
+ coa(active, method, 0)
26
+ self
27
+ end
28
+
29
+ #
30
+ # Perform a type one reauth or disconnect
31
+ #
32
+ def type_one(active, method)
33
+ coa(active, method, 1)
34
+ self
35
+ end
36
+
37
+ #
38
+ # Perform a type two reauth or disconnect
39
+ #
40
+ def type_two(active, method)
41
+ coa(active, method, 2)
42
+ self
43
+ end
44
+
45
+ #
46
+ # Construct and execute the CoA API call
47
+ #
48
+ def coa(active, method, type)
49
+ @xml = @session.call_api("CoA/#{method == :reauth ? 'ReauthApi' : 'DisconnectApi'}/#{active.server}/#{active.calling_station_id}/#{type.to_s}")
50
+ end
51
+
52
+
53
+ end
54
+ end
@@ -0,0 +1,55 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Make a Delete API call
5
+ #
6
+ # #Parameters
7
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
8
+ #
9
+ # @examples
10
+ # #Create session
11
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
12
+ #
13
+ # #Create a Delete API session
14
+ # delete = CiscoISE::DeleteApi.new(ise_session)
15
+ #
16
+ # #delete a specific MAC address
17
+ # delete.mac_address('00:17:89:01:23:45')
18
+ #
19
+ # #verify last delete
20
+ # puts delete.success?.to_s
21
+ #
22
+ # #delete all sessions
23
+ # delete.all
24
+ #
25
+ class DeleteApi
26
+
27
+ attr_reader :xml
28
+
29
+ def initialize(session)
30
+ @session = session
31
+ self
32
+ end
33
+
34
+ def mac_address(mac_address)
35
+ @xml = @session.call_api("Session/Delete/MACAddress/#{mac_address}", true)
36
+ self
37
+ end
38
+
39
+ def session_id(session_id)
40
+ @xml = @session.call_api("Session/Delete/SessionID/#{session_id}", true)
41
+ self
42
+ end
43
+
44
+ def all
45
+ @xml = @session.call_api("Session/Delete/All", true)
46
+ self
47
+ end
48
+
49
+ def success?
50
+ success = @xml.elements["/mnt-request-result/status"]
51
+ success.nil? ? false : success.text == 'SUCCESSFUL'
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,49 @@
1
+ module CiscoISE
2
+
3
+ #
4
+ # Make a Disconnect API call
5
+ #
6
+ # #Parameters
7
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
8
+ #
9
+ # @examples
10
+ # #Create session
11
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
12
+ #
13
+ # #Get a list of active users
14
+ # auth = CiscoISE::AuthListApi.new(ise_session)
15
+ #
16
+ # #Reauth a specific user
17
+ # active.each do |record|
18
+ # if record.user_name == 'someuser'
19
+ # puts "Ooops, something went wrong" unless CiscoISE::DisconnectApi.new(ise_session).bounce(record).success?
20
+ # end
21
+ #
22
+ class DisconnectApi < Coa
23
+
24
+ #
25
+ # Disconnect type DYNAMIC_AUTHZ_PORT_DEFAULT = 0
26
+ #
27
+ def default(active)
28
+ type_zero(active, :disconnect)
29
+ self
30
+ end
31
+
32
+ #
33
+ # Disconnect type DYNAMIC_AUTHZ_PORT_BOUNCE = 1
34
+ #
35
+ def bounce(active)
36
+ type_one(active, :disconnect)
37
+ self
38
+ end
39
+
40
+ #
41
+ # Disconnect type DYNAMIC_AUTHZ_PORT_SHUTDOWN = 2
42
+ #
43
+ def shutdown(active)
44
+ type_two(active, :disconnect)
45
+ self
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,33 @@
1
+ require 'cisco-ise/session-parameters'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make a End Point IP Address API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ #
11
+ # @examples
12
+ # #Create session
13
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
14
+ #
15
+ # #Obtain a list of sessions for a specific end point IP Address
16
+ # session = CiscoISE::EndPointIpAddressApi.new(ise_session,'10.10.10.10')
17
+ #
18
+ # #Iterate through each session record
19
+ # session.each do |record|
20
+ # puts record.user_name + ":" + record.nas_ip_address
21
+ # end
22
+ #
23
+ # #Output the raw XML
24
+ # puts session.xml.to_s
25
+ #
26
+ class EndPointIpAddressApi < CommonSession
27
+
28
+ def initialize(session, ip_address)
29
+ super(session, "Session/EndPointIPAddress/#{ip_address}")
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ module CiscoISE
2
+ #
3
+ # Class to store parsed data from a FailureReason objects. Refer to failure-reason-api.rb for usage examples.
4
+ #
5
+ class FailureReason < CommonElement
6
+ attr_accessor :id, :code, :cause, :resolution
7
+ end
8
+ end
@@ -0,0 +1,46 @@
1
+ require 'cisco-ise/failure-reason'
2
+
3
+ module CiscoISE
4
+
5
+ #
6
+ # Make a Failure Reason API call
7
+ #
8
+ # #Parameters
9
+ # session<CiscoISE::HttpSession>:: The ISE http session that the API call should be made against
10
+ #
11
+ # @examples
12
+ # #Create session
13
+ # ise_session = CiscoISE::HttpSession.new("device-name","myusername","mypassword")
14
+ #
15
+ # #Failure Reason List example
16
+ # failure = CiscoISE::FailureReasonsApi.new(ise_session)
17
+ #
18
+ # #Retrieve a specific code
19
+ # code = failure.find_code('86023')
20
+ # puts code.failure_id + '|' + code.cause
21
+ #
22
+ # #Iterate through each failure code
23
+ # failure.each do |code|
24
+ # puts code.id + code.cause
25
+ # end
26
+ #
27
+ # #Output the raw XML
28
+ # puts failure.xml.to_s
29
+ #
30
+
31
+ class FailureReasonsApi < CommonList
32
+
33
+ def initialize(session)
34
+ super(session, 'FailureReasons')
35
+ end
36
+
37
+ def each
38
+ super("*/failureReason",CiscoISE::FailureReason)
39
+ end
40
+
41
+ def find_code(code)
42
+ find("*/failureReason[@id='#{code}']", CiscoISE::FailureReason)
43
+ end
44
+
45
+ end
46
+ end