Class: VertxAuthOauth2::OAuth2Auth

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb

Overview

Factory interface for creating OAuth2 based VertxAuthCommon::AuthProvider instances.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


20
21
22
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 20

def @@j_api_type.accept?(obj)
  obj.class == OAuth2Auth
end

+ (::VertxAuthOauth2::OAuth2Auth) create(vertx = nil, flow = nil, config = nil)

Create a OAuth2 auth provider

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • flow (:AUTH_CODE, :CLIENT, :PASSWORD, :AUTH_JWT) (defaults to: nil)
  • config (Hash) (defaults to: nil)
    the config

Returns:

Raises:

  • (ArgumentError)


66
67
68
69
70
71
72
73
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 66

def self.create(vertx=nil,flow=nil,config=nil)
  if vertx.class.method_defined?(:j_del) && flow.class == Symbol && !block_given? && config == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s)),::VertxAuthOauth2::OAuth2Auth)
  elsif vertx.class.method_defined?(:j_del) && flow.class == Symbol && config.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s),Java::IoVertxExtAuthOauth2::OAuth2ClientOptions.new(::Vertx::Util::Utils.to_json_object(config))),::VertxAuthOauth2::OAuth2Auth)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{flow},#{config})"
end

+ (::VertxAuthOauth2::OAuth2Auth) create_keycloak(vertx = nil, flow = nil, config = nil)

Returns the auth provider

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance
  • flow (:AUTH_CODE, :CLIENT, :PASSWORD, :AUTH_JWT) (defaults to: nil)
  • config (Hash{String => Object}) (defaults to: nil)
    the config as exported from the admin console

Returns:

Raises:

  • (ArgumentError)


55
56
57
58
59
60
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 55

def self.create_keycloak(vertx=nil,flow=nil,config=nil)
  if vertx.class.method_defined?(:j_del) && flow.class == Symbol && config.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthOauth2::OAuth2Auth.java_method(:createKeycloak, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtAuthOauth2::OAuth2FlowType.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,Java::IoVertxExtAuthOauth2::OAuth2FlowType.valueOf(flow.to_s),::Vertx::Util::Utils.to_json_object(config)),::VertxAuthOauth2::OAuth2Auth)
  end
  raise ArgumentError, "Invalid arguments when calling create_keycloak(#{vertx},#{flow},#{config})"
end

+ (Object) j_api_type



29
30
31
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 29

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



32
33
34
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 32

def self.j_class
  Java::IoVertxExtAuthOauth2::OAuth2Auth.java_class
end

+ (Object) unwrap(obj)



26
27
28
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 26

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



23
24
25
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 23

def @@j_api_type.wrap(obj)
  OAuth2Auth.new(obj)
end

Instance Method Details

- (void) authenticate(arg0 = nil) { ... }

This method returns an undefined value.

Parameters:

  • arg0 (Hash{String => Object}) (defaults to: nil)

Yields:

Raises:

  • (ArgumentError)


38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 38

def authenticate(arg0=nil)
  if arg0.class == Hash && block_given?
    return @j_del.java_method(:authenticate, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(arg0),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthCommon::User) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling authenticate(#{arg0})"
end

- (String) authorize_url(params = nil)

Generate a redirect URL to the authN/Z backend. It only applies to auth_code flow.

Parameters:

  • params (Hash{String => Object}) (defaults to: nil)

Returns:

  • (String)

Raises:

  • (ArgumentError)


77
78
79
80
81
82
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 77

def authorize_url(params=nil)
  if params.class == Hash && !block_given?
    return @j_del.java_method(:authorizeURL, [Java::IoVertxCoreJson::JsonObject.java_class]).call(::Vertx::Util::Utils.to_json_object(params))
  end
  raise ArgumentError, "Invalid arguments when calling authorize_url(#{params})"
end

- (self) decode_token(token = nil) { ... }

Decode a token to a AccessToken object. This is useful to handle bearer JWT tokens.

Parameters:

  • token (String) (defaults to: nil)
    the access token (base64 string)

Yields:

  • A handler to receive the event

Returns:

  • (self)

Raises:

  • (ArgumentError)


112
113
114
115
116
117
118
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 112

def decode_token(token=nil)
  if token.class == String && block_given?
    @j_del.java_method(:decodeToken, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling decode_token(#{token})"
end

- (:AUTH_CODE, ...) get_flow_type

Returns the configured flow type for the Oauth2 provider.

Returns:

  • (:AUTH_CODE, :CLIENT, :PASSWORD, :AUTH_JWT)
    the flow type.

Raises:

  • (ArgumentError)


148
149
150
151
152
153
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 148

def get_flow_type
  if !block_given?
    return @j_del.java_method(:getFlowType, []).call().name.intern
  end
  raise ArgumentError, "Invalid arguments when calling get_flow_type()"
end

- (String) get_scope_separator

Returns the scope separator. The RFC 6749 states that a scope is expressed as a set of case-sensitive and space-delimited strings, however vendors tend not to agree on this and we see the following cases being used: space, plus sign, comma.

Returns:

  • (String)
    what value was used in the configuration of the object, falling back to the default value which is a space.

Raises:

  • (ArgumentError)


140
141
142
143
144
145
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 140

def get_scope_separator
  if !block_given?
    return @j_del.java_method(:getScopeSeparator, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling get_scope_separator()"
end

- (void) get_token(params = nil) { ... }

This method returns an undefined value.

Returns the Access Token object.

Parameters:

  • params (Hash{String => Object}) (defaults to: nil)
    - JSON with the options, each flow requires different options.

Yields:

  • - The handler returning the results.

Raises:

  • (ArgumentError)


87
88
89
90
91
92
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 87

def get_token(params=nil)
  if params.class == Hash && block_given?
    return @j_del.java_method(:getToken, [Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(::Vertx::Util::Utils.to_json_object(params),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling get_token(#{params})"
end

- (true, false) has_jwt_token?

Returns true if this provider supports JWT tokens as the access_token. This is typically true if the provider implements the `openid-connect` protocol. This is a plain return from the config option jwtToken, which is false by default. This information is important to validate grants. Since pure OAuth2 should be used for authorization and when a token is requested all grants should be declared, in case of openid-connect this is not true. OpenId will issue a token and all grants will be encoded on the token itself so the requester does not need to list the required grants.

Returns:

  • (true, false)
    true if openid-connect is used.

Raises:

  • (ArgumentError)


102
103
104
105
106
107
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 102

def has_jwt_token?
  if !block_given?
    return @j_del.java_method(:hasJWTToken, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling has_jwt_token?()"
end

- (self) introspect_token(token = nil, tokenType = nil) { ... }

Query an OAuth 2.0 authorization server to determine the active state of an OAuth 2.0 token and to determine meta-information about this token.

Parameters:

  • token (String) (defaults to: nil)
    the access token (base64 string)
  • tokenType (String) (defaults to: nil)
    hint to the token type e.g.: `access_token`

Yields:

  • A handler to receive the event

Returns:

  • (self)

Raises:

  • (ArgumentError)


125
126
127
128
129
130
131
132
133
134
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 125

def introspect_token(token=nil,tokenType=nil)
  if token.class == String && block_given? && tokenType == nil
    @j_del.java_method(:introspectToken, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) }))
    return self
  elsif token.class == String && tokenType.class == String && block_given?
    @j_del.java_method(:introspectToken, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(token,tokenType,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxAuthOauth2::AccessToken) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling introspect_token(#{token},#{tokenType})"
end

- (void) verify_is_using_password

This method returns an undefined value.

Raises:

  • (ArgumentError)


45
46
47
48
49
50
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-oauth2/o_auth2_auth.rb', line 45

def verify_is_using_password
  if !block_given?
    return @j_del.java_method(:verifyIsUsingPassword, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling verify_is_using_password()"
end