Class: VertxAuthMongo::HashStrategy

Inherits:
Object
  • Object
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)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (String) computeHash(password, user)

Compute the hashed password given the unhashed password and the user

Parameters:

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

Returns:

  • (String)
    the hashed password


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

def compute_hash(*args)
  if args[0].class == String && args[1].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(args[0],args[1].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling compute_hash(#{args[0]},#{args[1]})"
  end
end

- (String) getSalt(user)

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


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

def get_salt(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getSalt, [Java::IoVertxExtAuth::User.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_salt(#{args[0]})"
  end
end

- (:NO_SALT, ...) getSaltStyle

Get the defined HashSaltStyle of the current instance

Returns:

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


124
125
126
127
128
129
130
131
132
133
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 124

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

- (String) getStoredPwd(user)

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


68
69
70
71
72
73
74
75
76
77
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 68

def get_stored_pwd(*args)
  if args[0].class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:getStoredPwd, [Java::IoVertxExtAuth::User.java_class]).call(args[0].j_del)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_stored_pwd(#{args[0]})"
  end
end

- (void) setAlgorithm(algorithm)

This method returns an undefined value.

Allows the selection of the hashing algorithm.

Parameters:

  • algorithm (:SHA512, :PBKDF2)
    the choosen algorithm


97
98
99
100
101
102
103
104
105
106
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 97

def set_algorithm(*args)
  if args[0].class == Symbol && !block_given?
    return @j_del.java_method(:setAlgorithm, [Java::IoVertxExtAuthMongo::HashAlgorithm.java_class]).call(Java::IoVertxExtAuthMongo::HashAlgorithm.valueOf(args[0].to_s))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_algorithm(#{args[0]})"
  end
end

- (void) setExternalSalt(salt)

This method returns an undefined value.

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

Parameters:

  • salt (String)
    the salt, which shall be used


111
112
113
114
115
116
117
118
119
120
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-auth-mongo/hash_strategy.rb', line 111

def set_external_salt(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:setExternalSalt, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_external_salt(#{args[0]})"
  end
end

- (void) setSaltStyle(saltStyle)

This method returns an undefined value.

Set the saltstyle as defined by HashSaltStyle.

Parameters:

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


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

def set_salt_style(*args)
  if args[0].class == Symbol && !block_given?
    return @j_del.java_method(:setSaltStyle, [Java::IoVertxExtAuthMongo::HashSaltStyle.java_class]).call(Java::IoVertxExtAuthMongo::HashSaltStyle.valueOf(args[0].to_s))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling set_salt_style(#{args[0]})"
  end
end