28
28
import lombok .Getter ;
29
29
import lombok .Setter ;
30
30
import org .apache .commons .lang .StringUtils ;
31
+ import org .apache .hop .core .encryption .Encr ;
31
32
import org .apache .hop .core .exception .HopException ;
32
33
import org .apache .hop .core .util .HttpClientManager ;
33
34
import org .apache .hop .core .util .Utils ;
@@ -76,7 +77,7 @@ public class RestConnection extends HopMetadataBase implements IHopMetadata {
76
77
@ HopMetadataProperty (key = "username" )
77
78
private String username ;
78
79
79
- @ HopMetadataProperty (key = "username " , password = true )
80
+ @ HopMetadataProperty (key = "password " , password = true )
80
81
private String password ;
81
82
82
83
// Bearer auth
@@ -90,7 +91,7 @@ public class RestConnection extends HopMetadataBase implements IHopMetadata {
90
91
@ HopMetadataProperty (key = "auth_header_prefix" )
91
92
private String authorizationPrefix ;
92
93
93
- @ HopMetadataProperty (key = "auth_header_value" )
94
+ @ HopMetadataProperty (key = "auth_header_value" , password = true )
94
95
private String authorizationHeaderValue ;
95
96
96
97
public RestConnection (IVariables variables ) {
@@ -129,7 +130,11 @@ public Invocation.Builder getInvocationBuilder(String url) throws HopException {
129
130
}
130
131
if (authType .equals ("Basic" )) {
131
132
if (!StringUtils .isEmpty (username ) && !StringUtils .isEmpty (password )) {
132
- client .register (HttpAuthenticationFeature .basic (username , password ));
133
+
134
+ client .register (
135
+ HttpAuthenticationFeature .basic (
136
+ variables .resolve (username ),
137
+ Encr .decryptPasswordOptionallyEncrypted (variables .resolve (password ))));
133
138
target = client .target (url );
134
139
invocationBuilder = target .request ();
135
140
}
@@ -139,11 +144,12 @@ public Invocation.Builder getInvocationBuilder(String url) throws HopException {
139
144
variables .resolve (authorizationHeaderName ),
140
145
variables .resolve (authorizationPrefix )
141
146
+ " "
142
- + variables .resolve (authorizationHeaderValue ));
147
+ + Encr .decryptPasswordOptionallyEncrypted (
148
+ variables .resolve (authorizationHeaderValue )));
143
149
} else {
144
150
invocationBuilder .header (
145
151
variables .resolve (authorizationHeaderName ),
146
- variables .resolve (authorizationHeaderValue ));
152
+ Encr . decryptPasswordOptionallyEncrypted ( variables .resolve (authorizationHeaderValue ) ));
147
153
}
148
154
} else if (authType .equals ("Bearer" )) {
149
155
if (!StringUtils .isEmpty (bearerToken )) {
0 commit comments