Class: Plus4uCodebase::Security
- Inherits:
-
Object
- Object
- Plus4uCodebase::Security
- Defined in:
- lib/plus4u_codebase/security.rb,
lib/plus4u_codebase/security/ssh_key.rb,
lib/plus4u_codebase/security/ssh_key_type.rb
Defined Under Namespace
Classes: SSHKey, SSHKeyType
Constant Summary
- DEFAULT_TYPE =
'rsa'
- DEFAULT_BITS =
2048
Class Method Summary collapse
-
.add_key(uu_uri, params = {}) ⇒ void
Add public ssh key for actual logged user.
-
.generate_key(params = {}) ⇒ Plus4uCodebase::Security::SSHKey
Generate a new ssh keypair.
-
.remove_key(uu_uri) ⇒ void
Remove public ssh key for actual logged user.
Instance Method Summary collapse
-
#add_key(uu_uri, params = {}) ⇒ void
Add public ssh key for actual logged user.
-
#initialize(session, options = nil) ⇒ Security
constructor
Creates a new instance of
Security
. -
#remove_key(uu_uri) ⇒ void
Remove public ssh key for actual logged user.
Constructor Details
#initialize(session, options = nil) ⇒ Security
Creates a new instance of Security
.
20 21 22 |
# File 'lib/plus4u_codebase/security.rb', line 20 def initialize(session, = nil) @cmd = UU::OS::CMD::CommandClient.new("plus4u-codebase", session, ) end |
Class Method Details
.add_key(uu_uri, params = {}) ⇒ void
This method returns an undefined value.
Add public ssh key for actual logged user. Public key is valid for all hubs and repositories in same territory, this means that you don't need to set key for every repository but set it only once. Only one key per user is allowed, so if you set more keys for same user, the last one is used.
113 114 115 116 |
# File 'lib/plus4u_codebase/security.rb', line 113 def self.add_key(uu_uri, params = {}) session = UU::OS::Security::Session.current_session self.new(session).add_key(uu_uri, params) end |
.generate_key(params = {}) ⇒ Plus4uCodebase::Security::SSHKey
Generate a new ssh keypair. The default key type is 2048-bit RSA.
164 165 166 167 168 169 170 171 172 |
# File 'lib/plus4u_codebase/security.rb', line 164 def self.generate_key(params = {}) opts = {} opts[:type] = params[:type] || DEFAULT_TYPE opts[:bits] = params[:bits] || DEFAULT_BITS opts[:comment] = params[:comment] if params[:comment] opts[:passphrase] = params[:passphrase] if params[:passphrase] key = ::SSHKey.generate(opts) return Plus4uCodebase::Security::SSHKey.new(key) end |
.remove_key(uu_uri) ⇒ void
This method returns an undefined value.
Remove public ssh key for actual logged user. Public key is removed for all hubs and repositories in same territory, this means that you don't need to remove key for every repository or hub.
131 132 133 134 |
# File 'lib/plus4u_codebase/security.rb', line 131 def self.remove_key(uu_uri) session = UU::OS::Security::Session.current_session self.new(session).remove_key(uu_uri) end |
Instance Method Details
#add_key(uu_uri, params = {}) ⇒ void
This method returns an undefined value.
Add public ssh key for actual logged user. Public key is valid for all hubs and repositories in same territory, this means that you don't need to set key for every repository but set it only once. Only one key per user is allowed, so if you set more keys for same user, the last one is used.
58 59 60 61 62 |
# File 'lib/plus4u_codebase/security.rb', line 58 def add_key(uu_uri, params = {}) ssh_key = input(params) validate_ssh_key(ssh_key) @cmd.invoke('Security/addKey', uu_uri, parameters: {sshKey: ssh_key}) end |
#remove_key(uu_uri) ⇒ void
This method returns an undefined value.
Remove public ssh key for actual logged user. Public key is removed for all hubs and repositories in same territory, this means that you don't need to remove key for every repository or hub.
77 78 79 |
# File 'lib/plus4u_codebase/security.rb', line 77 def remove_key(uu_uri) @cmd.invoke('Security/removeKey', uu_uri) end |