use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class WindowsHostConnectionValidator method validateConnection.
@Override
public boolean validateConnection(HostParam hostParam, Host existingHost) {
HostType hostType = HostType.valueOf(hostParam.getType());
if (getType().equals(hostType) == false) {
throw new IllegalStateException(String.format("Invalid HostType [%s]", hostParam.getType()));
}
String password = hostParam.getPassword();
if (password == null && existingHost != null) {
password = existingHost.getPassword();
}
List<URI> authProviderIds = dbClient.queryByType(AuthnProvider.class, true);
List<AuthnProvider> authProviders = dbClient.queryObject(AuthnProvider.class, authProviderIds);
KerberosUtil.initializeKerberos(authProviders);
WinRMTarget target = new WinRMTarget(hostParam.getHostName(), hostParam.getPortNumber(), hostParam.getUseSsl(), hostParam.getUserName(), password);
WindowsSystemWinRM cli = new WindowsSystemWinRM(target);
try {
cli.listDiskDrives();
return true;
} catch (Exception e) {
log.error(String.format("Error Validating Host %s", hostParam.getName()), e);
}
return false;
}
use of com.emc.storageos.db.client.model.AuthnProvider in project coprhd-controller by CoprHD.
the class KerberosUtil method generateKerberosConfigFile.
public static String generateKerberosConfigFile(List<AuthnProvider> authProviders) {
Map<String, List<String>> domainToKDCs = Maps.newHashMap();
log.debug("Generating kerberos config file from all " + authProviders.size() + " authentication providers");
for (AuthnProvider authProvider : authProviders) {
for (String domain : authProvider.getDomains()) {
List<String> kdcAddresses = Lists.newArrayList();
for (String kdcAddress : authProvider.getServerUrls()) {
try {
URI uri = new URI(kdcAddress);
kdcAddresses.add(uri.getHost());
} catch (URISyntaxException e) {
log.error("Error processing AD " + domain + " address " + kdcAddress, e);
}
}
domainToKDCs.put(domain, kdcAddresses);
}
}
return Krb5ConfBuilder.build(domainToKDCs);
}
Aggregations