Class: VertxAuthMongo::HashStrategy

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

Overview

Determines how the hashing is computed in the implementation You can implement this to provide a different hashing strategy to the default.

Instance Method Summary (collapse)

Instance Method Details

- (String) compute_hash(password = nil, user = nil)

Compute the hashed password given the unhashed password and the user

Parameters:

  • password (String) (defaults to: nil)
    the unhashed password
  • user (::VertxAuthCommon::User) (defaults to: nil)
    the user to get the salt for. This paramter is needed, if the is declared to be used

Returns:

  • (String)
    the hashed password

Raises:

  • (ArgumentError)


22
23
24
25
26
27
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 22

def compute_hash(password=nil,user=nil)
  if password.class == String && user.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:computeHash, [Java::java.lang.String.java_class,Java::IoVertxExtAuth::User.java_class]).call(password,user.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling compute_hash(password,user)"
end

- (String) get_salt(user = nil)

Retrieve the salt. The source of the salt can be the external salt or the propriate column of the given user, depending on the defined HashSaltStyle

Parameters:

  • user (::VertxAuthCommon::User) (defaults to: nil)
    the user to get the salt for. This paramter is needed, if the is declared to be used

Returns:

  • (String)
    null in case of the salt of the user or a defined external salt

Raises:

  • (ArgumentError)


41
42
43
44
45
46
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 41

def get_salt(user=nil)
  if user.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getSalt, [Java::IoVertxExtAuth::User.java_class]).call(user.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling get_salt(user)"
end

- (:NO_SALT, ...) get_salt_style

Get the defined HashSaltStyle of the current instance

Returns:

  • (:NO_SALT, :COLUMN, :EXTERNAL)
    the saltStyle

Raises:

  • (ArgumentError)


67
68
69
70
71
72
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 67

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

- (String) get_stored_pwd(user = nil)

Retrieve the password from the user, or as clear text or as hashed version, depending on the definition

Parameters:

Returns:

  • (String)
    the password, either as hashed version or as cleartext, depending on the preferences

Raises:

  • (ArgumentError)


31
32
33
34
35
36
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 31

def get_stored_pwd(user=nil)
  if user.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getStoredPwd, [Java::IoVertxExtAuth::User.java_class]).call(user.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling get_stored_pwd(user)"
end

- (void) set_external_salt(salt = nil)

This method returns an undefined value.

Set an external salt. This method should be used in case of

Parameters:

  • salt (String) (defaults to: nil)
    the salt, which shall be used

Raises:

  • (ArgumentError)


50
51
52
53
54
55
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 50

def set_external_salt(salt=nil)
  if salt.class == String && !block_given?
    return @j_del.java_method(:setExternalSalt, [Java::java.lang.String.java_class]).call(salt)
  end
  raise ArgumentError, "Invalid arguments when calling set_external_salt(salt)"
end

- (void) set_salt_style(saltStyle = nil)

This method returns an undefined value.

Set the saltstyle as defined by HashSaltStyle.

Parameters:

  • saltStyle (:NO_SALT, :COLUMN, :EXTERNAL) (defaults to: nil)
    the HashSaltStyle to be used

Raises:

  • (ArgumentError)


59
60
61
62
63
64
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-auth-mongo/hash_strategy.rb', line 59

def set_salt_style(saltStyle=nil)
  if saltStyle.class == Symbol && !block_given?
    return @j_del.java_method(:setSaltStyle, [Java::IoVertxExtAuthMongo::HashSaltStyle.java_class]).call(Java::IoVertxExtAuthMongo::HashSaltStyle.valueOf(saltStyle))
  end
  raise ArgumentError, "Invalid arguments when calling set_salt_style(saltStyle)"
end