Class: Net::SSH::Kerberos::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ssh/kerberos/context.rb

Defined Under Namespace

Classes: GeneralError, State

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



13
14
15
# File 'lib/net/ssh/kerberos/context.rb', line 13

def initialize
  raise "Don't create this class directly - use a subclass" if self.class == Context
end

Instance Attribute Details

#cred_krb_nameObject (readonly)

Returns the value of attribute cred_krb_name.



11
12
13
# File 'lib/net/ssh/kerberos/context.rb', line 11

def cred_krb_name
  @cred_krb_name
end

#cred_nameObject (readonly)

Returns the value of attribute cred_name.



11
12
13
# File 'lib/net/ssh/kerberos/context.rb', line 11

def cred_name
  @cred_name
end

#server_krb_nameObject (readonly)

Returns the value of attribute server_krb_name.



11
12
13
# File 'lib/net/ssh/kerberos/context.rb', line 11

def server_krb_name
  @server_krb_name
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



11
12
13
# File 'lib/net/ssh/kerberos/context.rb', line 11

def server_name
  @server_name
end

Instance Method Details

#create(user, host) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/net/ssh/kerberos/context.rb', line 17

def create(user, host)
  dispose if @credentials or @target or @handle
	
  creds, name = acquire_current_credentials
  begin
    @cred_name = name.to_s.sub(/^[^\\\/]*[\\\/]/, '')
    @cred_krb_name = @cred_name.gsub('@', '/');
	
    z = (user.include?('@') ? user.gsub('@','/') : user+'/')
    unless z.downcase == @cred_krb_name[0,z.length].downcase
      raise GeneralError, "Credentials mismatch: current is #{@cred_name}, requested is #{user}"
    end
    @credentials = creds
  ensure
    if @credentials.nil?
      release_credentials creds
      @cred_name = @cred_krb_name = nil
    end
  end
	
  @server_name = Socket.gethostbyname(host)[0]
  @target, @server_krb_name = import_server_name host
	
  true
end

#credentials?Boolean

Returns:

  • (Boolean)


43
# File 'lib/net/ssh/kerberos/context.rb', line 43

def credentials?; ! @credentials.nil? end

#disposeObject



51
52
53
54
55
56
57
58
59
# File 'lib/net/ssh/kerberos/context.rb', line 51

def dispose
  @handle and delete_context @handle
  @credentials and release_credentials @credentials
  @target and release_server_name @target
ensure
  @credentials = @cred_name = @cred_krb_name = nil
  @target = @server_name = @server_krb_name = nil
  @handle = @state = nil
end

#established?Boolean

Returns:

  • (Boolean)


45
# File 'lib/net/ssh/kerberos/context.rb', line 45

def established?; ! @handle.nil? && (@state.nil? || @state.complete?) end

#get_mic(token) ⇒ Object

Raises:

  • (NotImplementedError)


49
# File 'lib/net/ssh/kerberos/context.rb', line 49

def get_mic(token); raise NotImplementedError, "subclasses must implement this method" end

#init(token = nil) ⇒ Object

Raises:

  • (NotImplementedError)


47
# File 'lib/net/ssh/kerberos/context.rb', line 47

def init(token=nil); raise NotImplementedError, "subclasses must implement this method" end