Search in sources :

Example 1 with AppConfiguration

use of org.xdi.config.oxtrust.AppConfiguration in project oxTrust by GluuFederation.

the class JsonConfigurationAction method getProtectedOxTrustappConfiguration.

private String getProtectedOxTrustappConfiguration(AppConfiguration oxTrustappConfiguration) {
    try {
        AppConfiguration resultOxTrustappConfiguration = (AppConfiguration) BeanUtils.cloneBean(oxTrustappConfiguration);
        resultOxTrustappConfiguration.setSvnConfigurationStorePassword(HIDDEN_PASSWORD_TEXT);
        resultOxTrustappConfiguration.setKeystorePassword(HIDDEN_PASSWORD_TEXT);
        resultOxTrustappConfiguration.setIdpSecurityKeyPassword(HIDDEN_PASSWORD_TEXT);
        resultOxTrustappConfiguration.setIdpBindPassword(HIDDEN_PASSWORD_TEXT);
        resultOxTrustappConfiguration.setCaCertsPassphrase(HIDDEN_PASSWORD_TEXT);
        resultOxTrustappConfiguration.setOxAuthClientPassword(HIDDEN_PASSWORD_TEXT);
        return jsonService.objectToJson(resultOxTrustappConfiguration);
    } catch (Exception ex) {
        log.error("Failed to prepare JSON from appConfiguration: '{}'", ex, oxTrustappConfiguration);
    }
    return null;
}
Also used : AppConfiguration(org.xdi.config.oxtrust.AppConfiguration) EncryptionException(org.xdi.util.security.StringEncrypter.EncryptionException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with AppConfiguration

use of org.xdi.config.oxtrust.AppConfiguration in project oxTrust by GluuFederation.

the class JsonConfigurationService method processScimTestModeIsTrue.

public void processScimTestModeIsTrue(AppConfiguration source, AppConfiguration current) throws Exception {
    AppConfiguration appConfiguration = getOxTrustappConfiguration();
    /*
		if (current.isScimTestMode()) {
			OpenIdConfigurationResponse openIdConfiguration = openIdService.getOpenIdConfiguration();

			String clientPassword = encryptionService.decrypt(appConfiguration.getOxAuthClientPassword());

			if (source.getScimTestModeAccessToken() != null && !source.getScimTestModeAccessToken().isEmpty()) {
				// Check if current token is still valid
				String validateTokenEndpoint = openIdConfiguration.getValidateTokenEndpoint();

				ValidateTokenClient validateTokenClient = new ValidateTokenClient(validateTokenEndpoint);
				ValidateTokenResponse validateTokenResponse = validateTokenClient.execValidateToken(source.getScimTestModeAccessToken());

				log.info(" (JsonConfigurationService) validateToken token = " + current.getScimTestModeAccessToken());
				log.info(" (JsonConfigurationService) validateToken status = " + validateTokenResponse.getStatus());
				log.info(" (JsonConfigurationService) validateToken entity = " + validateTokenResponse.getEntity());
				log.info(" (JsonConfigurationService) validateToken isValid = " + validateTokenResponse.isValid());
				log.info(" (JsonConfigurationService) validateToken expires = " + validateTokenResponse.getExpiresIn());

				if (!validateTokenResponse.isValid() ||
					(validateTokenResponse.getExpiresIn() == null || (validateTokenResponse.getExpiresIn() != null && validateTokenResponse.getExpiresIn() <= 0)) ||
					(validateTokenResponse.getStatus() != Response.Status.OK.getStatusCode())) {

					log.info(" (processScimTestModeIsTrue) Current long-lived token has expired, requesting a new one...");

					//  Request new long-lived access token
					TokenRequest longLivedTokenRequest = new TokenRequest(GrantType.OXAUTH_EXCHANGE_TOKEN);
					longLivedTokenRequest.setOxAuthExchangeToken(source.getScimTestModeAccessToken());
					longLivedTokenRequest.setAuthUsername(appConfiguration.getOxAuthClientId());
					longLivedTokenRequest.setAuthPassword(clientPassword);
					longLivedTokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);

					TokenClient longLivedTokenClient = new TokenClient(openIdConfiguration.getTokenEndpoint());
					longLivedTokenClient.setRequest(longLivedTokenRequest);
					TokenResponse longLivedTokenResponse = longLivedTokenClient.exec();

					String longLivedAccessToken = longLivedTokenResponse.getAccessToken();
					log.info(" longLivedAccessToken = " + longLivedAccessToken);

					current.setScimTestModeAccessToken(longLivedAccessToken);
					source.setScimTestModeAccessToken(longLivedAccessToken);

				} else {
					log.info(" (processScimTestModeIsTrue) Current long-lived token still valid");
				}
			} else {
				log.info(" (processScimTestModeIsTrue) Requesting for a first time long-lived access token...");

				// 1. Request short-lived access token
				TokenRequest tokenRequest = new TokenRequest(GrantType.CLIENT_CREDENTIALS);
				tokenRequest.setScope(appConfiguration.getOxAuthClientScope());
				tokenRequest.setAuthUsername(appConfiguration.getOxAuthClientId());
				tokenRequest.setAuthPassword(clientPassword);
				tokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);

				TokenClient tokenClient = new TokenClient(openIdConfiguration.getTokenEndpoint());
				tokenClient.setRequest(tokenRequest);
				TokenResponse tokenResponse = tokenClient.exec();

				String accessToken = tokenResponse.getAccessToken();
				log.info(" accessToken = " + accessToken);

				// 2. Exchange for long-lived access token
				TokenRequest longLivedTokenRequest = new TokenRequest(GrantType.OXAUTH_EXCHANGE_TOKEN);
				longLivedTokenRequest.setOxAuthExchangeToken(accessToken);
				longLivedTokenRequest.setAuthUsername(appConfiguration.getOxAuthClientId());
				longLivedTokenRequest.setAuthPassword(clientPassword);
				longLivedTokenRequest.setAuthenticationMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);

				TokenClient longLivedTokenClient = new TokenClient(openIdConfiguration.getTokenEndpoint());
				longLivedTokenClient.setRequest(longLivedTokenRequest);
				TokenResponse longLivedTokenResponse = longLivedTokenClient.exec();

				String longLivedAccessToken = longLivedTokenResponse.getAccessToken();
				log.info(" longLivedAccessToken = " + longLivedAccessToken);

				current.setScimTestModeAccessToken(longLivedAccessToken);
				source.setScimTestModeAccessToken(longLivedAccessToken);
			}
		}
*/
    source.setScimTestMode(current.isScimTestMode());
}
Also used : AppConfiguration(org.xdi.config.oxtrust.AppConfiguration)

Example 3 with AppConfiguration

use of org.xdi.config.oxtrust.AppConfiguration in project oxTrust by GluuFederation.

the class StatusCheckerDaily method processInt.

/**
	 * Gather periodically site and server status
	 * 
	 * @param when
	 *            Date
	 * @param interval
	 *            Interval
	 */
private void processInt() {
    log.debug("Starting daily status checker");
    AppConfiguration appConfiguration = configurationFactory.getAppConfiguration();
    if (!appConfiguration.isUpdateApplianceStatus()) {
        return;
    }
    GluuAppliance appliance;
    try {
        appliance = applianceService.getAppliance();
    } catch (LdapMappingException ex) {
        log.error("Failed to load current appliance", ex);
        return;
    }
    // Set LDAP attributes
    setLdapAttributes(appliance);
    Date currentDateTime = new Date();
    appliance.setLastUpdate(currentDateTime);
    try {
        applianceService.updateAppliance(appliance);
    } catch (LdapMappingException ex) {
        log.error("Failed to update current appliance", ex);
        return;
    }
    if (centralLdapService.isUseCentralServer()) {
        try {
            GluuAppliance tmpAppliance = new GluuAppliance();
            tmpAppliance.setDn(appliance.getDn());
            boolean existAppliance = centralLdapService.containsAppliance(tmpAppliance);
            if (existAppliance) {
                centralLdapService.updateAppliance(appliance);
            } else {
                centralLdapService.addAppliance(appliance);
            }
        } catch (LdapMappingException ex) {
            log.error("Failed to update appliance at central server", ex);
            return;
        }
    }
    log.debug("Daily Appliance status update finished");
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) AppConfiguration(org.xdi.config.oxtrust.AppConfiguration) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) Date(java.util.Date)

Example 4 with AppConfiguration

use of org.xdi.config.oxtrust.AppConfiguration in project oxTrust by GluuFederation.

the class StatusCheckerTimer method setHttpdAttributes.

private void setHttpdAttributes(GluuAppliance appliance) {
    log.debug("Setting httpd attributes");
    AppConfiguration appConfiguration = configurationFactory.getAppConfiguration();
    String page = getHttpdPage(appConfiguration.getIdpUrl(), OxTrustConstants.HTTPD_TEST_PAGE_NAME);
    appliance.setGluuHttpStatus(Boolean.toString(OxTrustConstants.HTTPD_TEST_PAGE_CONTENT.equals(page)));
}
Also used : AppConfiguration(org.xdi.config.oxtrust.AppConfiguration)

Example 5 with AppConfiguration

use of org.xdi.config.oxtrust.AppConfiguration in project oxTrust by GluuFederation.

the class ConfigurationFactory method reloadAppConfFromFile.

private boolean reloadAppConfFromFile() {
    final AppConfiguration appConfiguration = loadAppConfFromFile();
    if (appConfiguration != null) {
        log.info("Reloaded application configuration from file: " + configFilePath);
        this.appConfiguration = appConfiguration;
        return true;
    } else {
        log.error("Failed to load application configuration from file: " + configFilePath);
    }
    return false;
}
Also used : AppConfiguration(org.xdi.config.oxtrust.AppConfiguration)

Aggregations

AppConfiguration (org.xdi.config.oxtrust.AppConfiguration)8 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Date (java.util.Date)2 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)2 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)2 File (java.io.File)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParseException (java.text.ParseException)1 ConfigurationException (org.xdi.exception.ConfigurationException)1