@@ -18,6 +18,21 @@ def find_workspace(wspace = nil)
18
18
self . framework . db . workspace
19
19
end
20
20
21
+ def fix_cred_options ( opts )
22
+ new_opts = fix_options ( opts )
23
+
24
+ # Convert some of are data back to symbols
25
+ if new_opts [ :origin_type ]
26
+ new_opts [ :origin_type ] = new_opts [ :origin_type ] . to_sym
27
+ end
28
+
29
+ if new_opts [ :private_type ]
30
+ new_opts [ :private_type ] = new_opts [ :private_type ] . to_sym
31
+ end
32
+
33
+ new_opts
34
+ end
35
+
21
36
def fix_options ( opts )
22
37
newopts = { }
23
38
opts . each do |k , v |
@@ -91,11 +106,39 @@ def init_db_opts_workspace(xopts)
91
106
92
107
public
93
108
94
- def rpc_create_credential ( xopts )
95
- create_credential ( xopts )
109
+ def rpc_create_cracked_credential ( xopts )
110
+ opts = fix_cred_options ( xopts )
111
+ create_credential ( opts )
96
112
end
97
113
114
+ def rpc_create_credential ( xopts )
115
+ opts = fix_cred_options ( xopts )
116
+ core = create_credential ( opts )
117
+
118
+ ret = {
119
+ username : core . public . try ( :username ) ,
120
+ private : core . private . try ( :data ) ,
121
+ private_type : core . private . try ( :type ) ,
122
+ realm_value : core . realm . try ( :value ) ,
123
+ realm_key : core . realm . try ( :key )
124
+ }
125
+
126
+ if opts [ :last_attempted_at ] && opts [ :status ]
127
+ opts [ :core ] = core
128
+ opts [ :last_attempted_at ] = opts [ :last_attempted_at ] . to_datetime
129
+ login = create_credential_login ( opts )
130
+
131
+ ret [ :host ] = login . service . host . address ,
132
+ ret [ :sname ] = login . service . name
133
+ ret [ :status ] = login . status
134
+ end
135
+ ret
136
+ end
98
137
138
+ def rpc_invalidate_login ( xopts )
139
+ opts = fix_cred_options ( xopts )
140
+ invalidate_login ( opts )
141
+ end
99
142
100
143
def rpc_hosts ( xopts )
101
144
::ActiveRecord ::Base . connection_pool . with_connection {
0 commit comments