Search in sources :

Example 11 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class ArchivaLdapRoleMapperConfiguration method removeLdapMapping.

@Override
public void removeLdapMapping(String group) throws MappingException {
    try {
        RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
        boolean removed = redbackRuntimeConfiguration.getLdapGroupMappings().remove(new LdapGroupMapping(group));
        redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
        logger.debug("removeLdapMapping ldapGroup: {}, removed: {}", group, removed);
    } catch (RepositoryAdminException e) {
        throw new MappingException(e.getMessage(), e);
    }
}
Also used : LdapGroupMapping(org.apache.archiva.admin.model.beans.LdapGroupMapping) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) MappingException(org.apache.archiva.redback.common.ldap.MappingException)

Example 12 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRuntimeInfoService method getApplicationRuntimeInfo.

@Override
public ApplicationRuntimeInfo getApplicationRuntimeInfo(String locale) throws ArchivaRestServiceException {
    ApplicationRuntimeInfo applicationRuntimeInfo = new ApplicationRuntimeInfo();
    applicationRuntimeInfo.setBuildNumber(this.archivaRuntimeInfo.getBuildNumber());
    applicationRuntimeInfo.setTimestamp(this.archivaRuntimeInfo.getTimestamp());
    applicationRuntimeInfo.setVersion(this.archivaRuntimeInfo.getVersion());
    applicationRuntimeInfo.setBaseUrl(getBaseUrl(httpServletRequest));
    SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz", new Locale(StringUtils.isEmpty(locale) ? "en" : locale));
    applicationRuntimeInfo.setTimestampStr(sfd.format(new Date(archivaRuntimeInfo.getTimestamp())));
    CookieInformation cookieInformation = new CookieInformation();
    RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationService.getRedbackRuntimeConfiguration();
    cookieInformation.setDomain(redbackRuntimeConfiguration.getConfigurationProperties().get(UserConfigurationKeys.REMEMBER_ME_DOMAIN));
    cookieInformation.setPath(redbackRuntimeConfiguration.getConfigurationProperties().get(UserConfigurationKeys.REMEMBER_ME_PATH));
    cookieInformation.setSecure(redbackRuntimeConfiguration.getConfigurationProperties().get(UserConfigurationKeys.REMEMBER_ME_SECURE));
    cookieInformation.setTimeout(redbackRuntimeConfiguration.getConfigurationProperties().get(UserConfigurationKeys.REMEMBER_ME_TIMEOUT));
    cookieInformation.setRememberMeEnabled(BooleanUtils.toBoolean(redbackRuntimeConfiguration.getConfigurationProperties().get(UserConfigurationKeys.REMEMBER_ME_ENABLED)));
    applicationRuntimeInfo.setCookieInformation(cookieInformation);
    return applicationRuntimeInfo;
}
Also used : Locale(java.util.Locale) ApplicationRuntimeInfo(org.apache.archiva.web.model.ApplicationRuntimeInfo) CookieInformation(org.apache.archiva.web.model.CookieInformation) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 13 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRedbackRuntimeConfigurationService method getRedbackRuntimeConfiguration.

@Override
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() throws ArchivaRestServiceException {
    try {
        RedbackRuntimeConfiguration redbackRuntimeConfiguration = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
        log.debug("getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration);
        return redbackRuntimeConfiguration;
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(e.getMessage(), e);
    }
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 14 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class RedbackRuntimeConfigurationServiceTest method nonnullConfiguration.

@Test
public void nonnullConfiguration() throws Exception {
    RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfigurationService().getRedbackRuntimeConfiguration();
    assertEquals("jpa", redbackRuntimeConfiguration.getUserManagerImpls().get(0));
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) Test(org.junit.Test)

Example 15 with RedbackRuntimeConfiguration

use of org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration in project archiva by apache.

the class DefaultRedbackRuntimeConfigurationAdmin method getString.

@Override
public String getString(String key, String defaultValue) {
    if (UserConfigurationKeys.LDAP_HOSTNAME.equals(key)) {
        return getRedbackRuntimeConfiguration().getLdapConfiguration().getHostName();
    }
    if (UserConfigurationKeys.LDAP_CONTEX_FACTORY.equals(key)) {
        return getRedbackRuntimeConfiguration().getLdapConfiguration().getContextFactory();
    }
    if (UserConfigurationKeys.LDAP_PASSWORD.equals(key)) {
        return getRedbackRuntimeConfiguration().getLdapConfiguration().getPassword();
    }
    if (UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD.equals(key)) {
        return getRedbackRuntimeConfiguration().getLdapConfiguration().getAuthenticationMethod();
    }
    RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
    if (conf.getConfigurationProperties().containsKey(key)) {
        return conf.getConfigurationProperties().get(key);
    }
    String value = userConfiguration.getString(key, defaultValue);
    if (value == null) {
        return null;
    }
    conf.getConfigurationProperties().put(key, value);
    try {
        updateRedbackRuntimeConfiguration(conf);
    } catch (RepositoryAdminException e) {
        log.error("fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
    return value;
}
Also used : RedbackRuntimeConfiguration(org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Aggregations

RedbackRuntimeConfiguration (org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration)18 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)14 LdapGroupMapping (org.apache.archiva.admin.model.beans.LdapGroupMapping)7 MappingException (org.apache.archiva.redback.common.ldap.MappingException)5 ArrayList (java.util.ArrayList)3 CacheConfiguration (org.apache.archiva.admin.model.beans.CacheConfiguration)3 LdapConfiguration (org.apache.archiva.admin.model.beans.LdapConfiguration)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 Configuration (org.apache.archiva.configuration.Configuration)1 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)1 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)1