Connect to an IWA secured portal and search for maps.
Use case
Your organization might use Integrated Windows Authentication (IWA) to secure ArcGIS Enterprise. This can be useful because the same credentials used to log into your work computer and network can be used to authenticate with ArcGIS. IWA is built into Microsoft Internet Information Server (IIS) and works well for intranet applications, but isn't always practical for internet apps.
How to use the sample
Enter the URL to your IWA-secured portal. Click the 'Search IWA Secured Portal' button to search for web maps stored on the portal. You will be prompted for a user name, password, and domain. If you authenticate successfully, portal item results will display in the list. Select a web map item to display it in the map view.
How it works
- The
AuthenticationManager
object is configured with a challenge handler that will prompt for a Windows login (username, password, and domain) if a secure resource is encountered. - When a search for portal items is performed against an IWA-secured portal, the challenge handler creates an
UserCredential
object from the information entered by the user. - If the user authenticates, the search returns a list of web map
PortalItem
s and the user can select one to display as anArcGISMap
.
Relevant API
- AuthenticationChallenge
- AuthenticationChallengeHandler
- AuthenticationChallengeResponse
- AuthenticationManager
- Portal
- UserCredential
About the data
This sample searches for web map portal items on a secure portal. To successfully run the sample, you need:
- Access to a portal secured with Integrated Windows Authentication that contains one or more web map items.
- A login that grants you access to the portal.
Additional information
More information about IWA and its use with ArcGIS can be found at the following links:
Tags
authentication, security, Windows
Sample Code
/*
* Copyright 2019 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.esri.samples.integrated_windows_authentication;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import com.esri.arcgisruntime.security.UserCredential;
class AuthenticationDialog extends Dialog<UserCredential> {
@FXML private TextField userDomain;
@FXML private PasswordField password;
@FXML private ButtonType cancelButton;
@FXML private ButtonType continueButton;
AuthenticationDialog() {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/integrated_windows_authentication/iwa_auth_dialog.fxml"));
loader.setRoot(this);
loader.setController(this);
setTitle("Authenticate");
try {
loader.load();
} catch (Exception e) {
e.printStackTrace();
}
setResultConverter(dialogButton -> {
if (dialogButton == continueButton) {
if (!userDomain.getText().equals("") && !password.getText().equals("")) {
try {
return new UserCredential(userDomain.getText(), password.getText());
} catch (Exception e) {
new Alert(Alert.AlertType.ERROR, e.getMessage()).show();
}
} else {
new Alert(Alert.AlertType.ERROR, "Missing credentials").show();
}
}
return null;
});
}
}