Search in sources :

Example 6 with PropertyInfoUpdate

use of com.emc.storageos.model.property.PropertyInfoUpdate in project coprhd-controller by CoprHD.

the class PasswordPolicyConfigTest method setViprProperty.

private void setViprProperty(String name, String value) throws Exception {
    waitForClusterStable();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(name, value);
    PropertyInfoUpdate propertyInfoUpdate = new PropertyInfoUpdate();
    propertyInfoUpdate.setProperties(properties);
    systemClient.config().setProperties(propertyInfoUpdate);
}
Also used : HashMap(java.util.HashMap) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 7 with PropertyInfoUpdate

use of com.emc.storageos.model.property.PropertyInfoUpdate in project coprhd-controller by CoprHD.

the class LocalPasswordHandler method updateUserPasswordProperty.

/**
 * when updating localuser's encpassword property, this method should be call instead of
 * updateProperty method.
 *
 * it will update encpassword property, it also update user's expiry_date property and
 * user's password history.
 *
 * expiry_date system properties is for generate /etc/shadow file to block ssh login after
 * user's password expired.
 *
 * @param username
 * @param value
 * @throws CoordinatorClientException
 * @throws LocalRepositoryException
 */
private void updateUserPasswordProperty(String username, String value, boolean bReset) throws CoordinatorClientException, LocalRepositoryException {
    String encpasswordProperty = String.format(SYSTEM_ENCPASSWORD_FORMAT, username);
    PropertyInfoUpdate props = new PropertyInfoUpdate();
    props.addProperty(encpasswordProperty, value);
    Calendar newExpireTime = getExpireTimeFromNow();
    if (username.equals("root") || username.equals("svcuser")) {
        // add expiry_date system property
        String configExpireDays = getPasswordUtils().getConfigProperty(Constants.PASSWORD_EXPIRE_DAYS);
        int intConfigExpireDays = NumberUtils.toInt(configExpireDays);
        int daysAfterEpoch = 0;
        if (intConfigExpireDays != 0) {
            daysAfterEpoch = PasswordUtils.getDaysAfterEpoch(newExpireTime);
        }
        String expirydaysProperty = String.format(Constants.SYSTEM_PASSWORD_EXPIRY_FORMAT, username);
        _log.info("updating " + expirydaysProperty + " to " + daysAfterEpoch);
        props.addProperty(expirydaysProperty, String.valueOf(daysAfterEpoch));
    }
    try {
        _cfg.setProperties(props);
        if (username.equals("proxyuser")) {
            value = _passwordUtils.getEncryptedString(value);
        }
        _passwordUtils.updatePasswordHistory(username, value, newExpireTime, bReset);
    } catch (Exception e) {
        throw APIException.internalServerErrors.updateObjectError("properties", e);
    }
}
Also used : Calendar(java.util.Calendar) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 8 with PropertyInfoUpdate

use of com.emc.storageos.model.property.PropertyInfoUpdate in project coprhd-controller by CoprHD.

the class LocalPasswordHandler method updateProperty.

public void updateProperty(String key, String value) throws CoordinatorClientException, LocalRepositoryException {
    PropertyInfoUpdate props = new PropertyInfoUpdate();
    props.addProperty(key, value);
    _log.info("Calling ConfigService to update property: ", key);
    try {
        _cfg.setProperties(props);
    } catch (Exception e) {
        throw APIException.internalServerErrors.updateObjectError("properties", e);
    }
}
Also used : APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 9 with PropertyInfoUpdate

use of com.emc.storageos.model.property.PropertyInfoUpdate in project coprhd-controller by CoprHD.

the class ConfigServiceTest method testEmailUsingAuthWithNoUsernamePassword.

@Test
public void testEmailUsingAuthWithNoUsernamePassword() {
    ConnectEmcEmail email = new ConnectEmcEmail();
    email.setEmailSender("DONOTREPLY@customer.com");
    email.setEmailServer("mailhub.lss.emc.com");
    email.setNotifyEmailAddress("joe.customer@customer.com");
    email.setPrimaryEmailAddress("emailalertesg@emc.com");
    email.setSafeEncryption("no");
    email.setSmtpAuthType("login");
    PropertyInfoUpdate propInfo = null;
    try {
        propInfo = ConfigService.ConfigureConnectEmc.configureEmail(email);
    } catch (Exception e) {
        Assert.assertNull(propInfo);
        return;
    }
    Assert.fail();
}
Also used : ConnectEmcEmail(com.emc.vipr.model.sys.eventhandler.ConnectEmcEmail) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate) Test(org.junit.Test)

Example 10 with PropertyInfoUpdate

use of com.emc.storageos.model.property.PropertyInfoUpdate in project coprhd-controller by CoprHD.

the class ConfigServiceTest method testEmailUsingNoAuth.

@Test
public void testEmailUsingNoAuth() {
    ConnectEmcEmail email = new ConnectEmcEmail();
    email.setEmailSender("DONOTREPLY@customer.com");
    email.setEmailServer("mailhub.lss.emc.com");
    email.setNotifyEmailAddress("joe.customer@customer.com");
    email.setPrimaryEmailAddress("emailalertesg@emc.com");
    email.setSafeEncryption("no");
    email.setStartTls("no");
    PropertyInfoUpdate propInfo = ConfigService.ConfigureConnectEmc.configureEmail(email);
    Assert.assertEquals(propInfo.getProperty("system_connectemc_smtp_server"), email.getEmailServer());
    Assert.assertEquals(propInfo.getProperty("system_connectemc_smtp_emcto"), email.getPrimaryEmailAddress());
    Assert.assertEquals(propInfo.getProperty("system_connectemc_smtp_from"), email.getEmailSender());
    Assert.assertEquals(propInfo.getProperty("system_connectemc_smtp_to"), email.getNotifyEmailAddress());
    Assert.assertEquals(propInfo.getProperty("system_connectemc_smtp_enabletls"), email.getStartTls());
    Assert.assertEquals(propInfo.getProperty("system_connectemc_encrypt"), email.getSafeEncryption());
    Assert.assertNull(propInfo.getProperty("system_connectemc_smtp_authtype"));
    Assert.assertNull(propInfo.getProperty("system_connectemc_smtp_username"));
    Assert.assertNull(propInfo.getProperty("system_connectemc_smtp_password"));
}
Also used : ConnectEmcEmail(com.emc.vipr.model.sys.eventhandler.ConnectEmcEmail) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate) Test(org.junit.Test)

Aggregations

PropertyInfoUpdate (com.emc.storageos.model.property.PropertyInfoUpdate)12 Test (org.junit.Test)5 ConnectEmcEmail (com.emc.vipr.model.sys.eventhandler.ConnectEmcEmail)4 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)2 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)2 ConnectEmcFtps (com.emc.vipr.model.sys.eventhandler.ConnectEmcFtps)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1