Class List Method List File List

# Class: VertxAuthMongo::HashStrategy

Inherits:
  Object
  - Object
  - VertxAuthMongo::HashStrategy
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/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.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (String) compute_hash(password = nil, user = nil)
  Compute the hashed password given the unhashed password and the user.
- - (String) get_salt(user = nil)
  Retrieve the salt.
- - (:NO_SALT, ...) get_salt_style
  Get the defined HashSaltStyle of the current instance.
- - (String) get_stored_pwd(user = nil)
  Retrieve the password from the user, or as clear text or as hashed version, depending on the definition.
- - (void) set_algorithm(algorithm = nil)
  Allows the selection of the hashing algorithm.
- - (void) set_external_salt(salt = nil)
  Set an external salt.
- - (void) set_salt_style(saltStyle = nil)
  Set the saltstyle as defined by HashSaltStyle.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    19
    20
    21
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 19

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

### + (`Object`) j_api_type

    28
    29
    30
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 28

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 31

    def self.j_class
      Java::IoVertxExtAuthMongo::HashStrategy.java_class
    end

### + (`Object`) unwrap(obj)

    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 25

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

### + (`Object`) wrap(obj)

    22
    23
    24
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 22

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

## 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`)

    38
    39
    40
    41
    42
    43
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 38

    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`)

    57
    58
    59
    60
    61
    62
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 57

    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`)

    83
    84
    85
    86
    87
    88
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 83

    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:

- user (`::VertxAuthCommon::User`) (defaults to: `nil`) —
  the user to get the stored password for

Returns:

- (`String`) —
  the password, either as hashed version or as cleartext, depending on the preferences

Raises:

- (`ArgumentError`)

    47
    48
    49
    50
    51
    52
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 47

    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_algorithm(algorithm = nil)

This method returns an undefined value.

Allows the selection of the hashing algorithm.

Parameters:

- algorithm (`:SHA512`, `:PBKDF2`) (defaults to: `nil`) —
  the choosen algorithm

Raises:

- (`ArgumentError`)

    92
    93
    94
    95
    96
    97
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 92

    def set_algorithm(algorithm=nil)
      if algorithm.class == Symbol && !block_given?
        return @j_del.java_method(:setAlgorithm, [Java::IoVertxExtAuthMongo::HashAlgorithm.java_class]).call(Java::IoVertxExtAuthMongo::HashAlgorithm.valueOf(algorithm.to_s))
      end
      raise ArgumentError, "Invalid arguments when calling set_algorithm(#{algorithm})"
    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`)

    66
    67
    68
    69
    70
    71
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 66

    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`)

    75
    76
    77
    78
    79
    80
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 75

    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.to_s))
      end
      raise ArgumentError, "Invalid arguments when calling set_salt_style(#{saltStyle})"
    end