Class: VertxAuthJdbc::JDBCAuth

Inherits:
VertxAuthCommon::AuthProvider show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb

Overview

Factory interface for creating VertxAuthCommon::AuthProvider instances that use the Vert.x JDBC client. By default the hashing strategy is SHA-512. If you're already running in production this is backwards compatible, however for new deployments or security upgrades it is recommended to use the PBKDF2 strategy as it is the current OWASP recommendation for password storage.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)

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

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

+ (::VertxAuthJdbc::JDBCAuth) create(vertx = nil, client = nil)

Create a JDBC auth provider implementation

Parameters:

Returns:

Raises:

  • (ArgumentError)

54
55
56
57
58
59
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 54

def self.create(vertx=nil,client=nil)
  if vertx.class.method_defined?(:j_del) && client.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtAuthJdbc::JDBCAuth.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtJdbc::JDBCClient.java_class]).call(vertx.j_del,client.j_del),::VertxAuthJdbc::JDBCAuth)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{client})"
end

+ (Object) j_api_type


35
36
37
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class


38
39
40
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 38

def self.j_class
  Java::IoVertxExtAuthJdbc::JDBCAuth.java_class
end

+ (Object) unwrap(obj)


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

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

+ (Object) wrap(obj)


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

def @@j_api_type.wrap(obj)
  JDBCAuth.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)

44
45
46
47
48
49
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 44

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) compute_hash(password = nil, salt = nil, version = nil)

Compute the hashed password given the unhashed password and the salt The implementation relays to the JDBCHashStrategy provided.

Parameters:

  • password (String) (defaults to: nil)
    the unhashed password
  • salt (String) (defaults to: nil)
    the salt
  • version (Fixnum) (defaults to: nil)
    the nonce version to use

Returns:

  • (String)
    the hashed password

Raises:

  • (ArgumentError)

107
108
109
110
111
112
113
114
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 107

def compute_hash(password=nil,salt=nil,version=nil)
  if password.class == String && salt.class == String && !block_given? && version == nil
    return @j_del.java_method(:computeHash, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(password,salt)
  elsif password.class == String && salt.class == String && version.class == Fixnum && !block_given?
    return @j_del.java_method(:computeHash, [Java::java.lang.String.java_class,Java::java.lang.String.java_class,Java::int.java_class]).call(password,salt,version)
  end
  raise ArgumentError, "Invalid arguments when calling compute_hash(#{password},#{salt},#{version})"
end

- (String) generate_salt

Compute a salt string. The implementation relays to the JDBCHashStrategy provided.

Returns:

  • (String)
    a non null salt value

Raises:

  • (ArgumentError)

119
120
121
122
123
124
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 119

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

- (self) set_authentication_query(authenticationQuery = nil)

Set the authentication query to use. Use this if you want to override the default authentication query.

Parameters:

  • authenticationQuery (String) (defaults to: nil)
    the authentication query

Returns:

  • (self)

Raises:

  • (ArgumentError)

63
64
65
66
67
68
69
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 63

def set_authentication_query(authenticationQuery=nil)
  if authenticationQuery.class == String && !block_given?
    @j_del.java_method(:setAuthenticationQuery, [Java::java.lang.String.java_class]).call(authenticationQuery)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_authentication_query(#{authenticationQuery})"
end

- (self) set_nonces(nonces = nil)

Provide a application configuration level on hash nonce's as a ordered list of nonces where each position corresponds to a version. The nonces are supposed not to be stored in the underlying jdbc storage but to be provided as a application configuration. The idea is to add one extra variable to the hash function in order to make breaking the passwords using rainbow tables or precomputed hashes harder. Leaving the attacker only with the brute force approach. The implementation relays to the JDBCHashStrategy provided.

Parameters:

  • nonces (Array<String,Object>) (defaults to: nil)
    a List of non null Strings.

Returns:

  • (self)

Raises:

  • (ArgumentError)

137
138
139
140
141
142
143
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 137

def set_nonces(nonces=nil)
  if nonces.class == Array && !block_given?
    @j_del.java_method(:setNonces, [Java::IoVertxCoreJson::JsonArray.java_class]).call(::Vertx::Util::Utils.to_json_array(nonces))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_nonces(#{nonces})"
end

- (self) set_permissions_query(permissionsQuery = nil)

Set the permissions query to use. Use this if you want to override the default permissions query.

Parameters:

  • permissionsQuery (String) (defaults to: nil)
    the permissions query

Returns:

  • (self)

Raises:

  • (ArgumentError)

83
84
85
86
87
88
89
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 83

def set_permissions_query(permissionsQuery=nil)
  if permissionsQuery.class == String && !block_given?
    @j_del.java_method(:setPermissionsQuery, [Java::java.lang.String.java_class]).call(permissionsQuery)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_permissions_query(#{permissionsQuery})"
end

- (self) set_role_prefix(rolePrefix = nil)

Set the role prefix to distinguish from permissions when checking for isPermitted requests.

Parameters:

  • rolePrefix (String) (defaults to: nil)
    a Prefix e.g.: "role:"

Returns:

  • (self)

Raises:

  • (ArgumentError)

93
94
95
96
97
98
99
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 93

def set_role_prefix(rolePrefix=nil)
  if rolePrefix.class == String && !block_given?
    @j_del.java_method(:setRolePrefix, [Java::java.lang.String.java_class]).call(rolePrefix)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_role_prefix(#{rolePrefix})"
end

- (self) set_roles_query(rolesQuery = nil)

Set the roles query to use. Use this if you want to override the default roles query.

Parameters:

  • rolesQuery (String) (defaults to: nil)
    the roles query

Returns:

  • (self)

Raises:

  • (ArgumentError)

73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-jdbc/jdbc_auth.rb', line 73

def set_roles_query(rolesQuery=nil)
  if rolesQuery.class == String && !block_given?
    @j_del.java_method(:setRolesQuery, [Java::java.lang.String.java_class]).call(rolesQuery)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling set_roles_query(#{rolesQuery})"
end