-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code that over-rides process IWA credentials when user provides c…
…redentials in the properties file.
- Loading branch information
1 parent
12560f5
commit 9b19fb5
Showing
4 changed files
with
135 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/esri/geoevent/datastore/HttpClientCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.esri.geoevent.datastore; | ||
|
||
import org.apache.http.auth.AuthScope; | ||
import org.apache.http.auth.Credentials; | ||
import org.apache.http.auth.NTCredentials; | ||
import org.apache.http.client.config.AuthSchemes; | ||
import org.apache.http.impl.client.SystemDefaultCredentialsProvider; | ||
|
||
public class HttpClientCredentialsProvider extends SystemDefaultCredentialsProvider | ||
{ | ||
Credentials credentials; | ||
NTCredentials ntCredentials; | ||
|
||
HttpClientCredentialsProvider(Credentials credentials, NTCredentials ntCredentials) | ||
{ | ||
this.credentials = credentials; | ||
this.ntCredentials = ntCredentials; | ||
} | ||
|
||
@Override | ||
public Credentials getCredentials(AuthScope authscope) | ||
{ | ||
Credentials retCredentials = null; | ||
String host = authscope.getHost(); | ||
int port = authscope.getPort(); | ||
if (host != AuthScope.ANY_HOST && port != AuthScope.ANY_PORT) | ||
{ | ||
String scheme = authscope.getScheme().toUpperCase(); | ||
switch (scheme) | ||
{ | ||
case "BASIC": | ||
case "DIGEST": | ||
retCredentials = credentials; | ||
break; | ||
case AuthSchemes.NTLM: | ||
retCredentials = ntCredentials; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
if (retCredentials == null) | ||
{ | ||
retCredentials = super.getCredentials(authscope); | ||
} | ||
return retCredentials; | ||
} | ||
} |