Method: GSSAPI::Simple#acquire_credentials

Defined in:
lib/gssapi/simple.rb

#acquire_credentials(princ = @int_svc_name, opts = {:usage => :accept}) ⇒ true

Acquire security credentials. This does not log you in. It grabs the credentials from a cred cache or keytab.

Parameters:

  • opts (Hash) (defaults to: {:usage => :accept})

    options to pass to the gss_acquire_cred function.

Options Hash (opts):

  • :usage (String)

    The credential usage type (:accept, :initiate, :both). It defaults to ‘accept’ since this method is most usually called on the server only.

Returns:

  • (true)

    It will return true if everything succeeds and the @scred variable will be set for future methods. If an error ocurrs an exception will be raised.

Raises:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/gssapi/simple.rb', line 141

def acquire_credentials(princ = @int_svc_name, opts = {:usage => :accept})
  min_stat = FFI::MemoryPointer.new :OM_uint32
  scred = FFI::MemoryPointer.new :pointer

  case opts[:usage]
  when :accept
    usage = LibGSSAPI::GSS_C_ACCEPT
  when :initiate
    usage = LibGSSAPI::GSS_C_INITIATE
  when :both
    usage = LibGSSAPI::GSS_C_BOTH
  else
    raise GssApiError, "Bad option passed to #{self.class.name}#acquire_credentials"
  end

  maj_stat = LibGSSAPI.gss_acquire_cred(min_stat, princ, 0, LibGSSAPI::GSS_C_NO_OID_SET, usage, scred, nil, nil)
  raise GssApiError.new(maj_stat, min_stat), "gss_acquire_cred did not return GSS_S_COMPLETE" if maj_stat != 0

  @scred = LibGSSAPI::GssCredIdT.new(scred.get_pointer(0))
  true
end