Search in sources :

Example 21 with AuthnProvider

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;
}
Also used : HostType(com.emc.storageos.db.client.model.Host.HostType) WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) WinRMTarget(com.iwave.ext.windows.winrm.WinRMTarget) URI(java.net.URI)

Example 22 with AuthnProvider

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);
}
Also used : AuthnProvider(com.emc.storageos.db.client.model.AuthnProvider) List(java.util.List) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

AuthnProvider (com.emc.storageos.db.client.model.AuthnProvider)22 URI (java.net.URI)10 StringSet (com.emc.storageos.db.client.model.StringSet)9 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 DbClient (com.emc.storageos.db.client.DbClient)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 StorageOSUserDAO (com.emc.storageos.db.client.model.StorageOSUserDAO)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 Vcenter (com.emc.storageos.db.client.model.Vcenter)2 InternalDbClient (com.emc.storageos.db.client.upgrade.InternalDbClient)2 UserMapping (com.emc.storageos.security.authorization.BasePermissionsHelper.UserMapping)2 List (java.util.List)2 AixSystem (com.emc.aix.AixSystem)1 HpuxSystem (com.emc.hpux.HpuxSystem)1