Search in sources :

Example 16 with IConfiguration

use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.

the class PentahoSystem method setSystemProperties.

private static void setSystemProperties() {
    ISystemConfig systemConfig = PentahoSystem.get(ISystemConfig.class);
    if (systemConfig == null) {
        return;
    }
    final IConfiguration configuration = systemConfig.getConfiguration(JAVA_SYSTEM_PROPERTIES);
    if (configuration != null) {
        try {
            final Properties systemSettingsProperties = configuration.getProperties();
            for (String propName : systemSettingsProperties.stringPropertyNames()) {
                System.setProperty(propName, systemSettingsProperties.getProperty(propName));
            }
        } catch (IOException e) {
            Logger.warn(PentahoSystem.class.getName(), Messages.getInstance().getErrorString("PentahoSystem.WARN_SYSTEM_PROPERTIES_READ_FAIL", // $NON-NLS-1$
            JAVA_SYSTEM_PROPERTIES));
        }
    }
}
Also used : ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) IOException(java.io.IOException) IConfiguration(org.pentaho.platform.api.engine.IConfiguration) Properties(java.util.Properties)

Example 17 with IConfiguration

use of org.pentaho.platform.api.engine.IConfiguration in project pentaho-platform by pentaho.

the class SystemResource method getAuthenticationProvider.

/**
 * Return JSON string reporting which authentication provider is currently in use
 *
 * Response sample: { "authenticationType": "JCR_BASED_AUTHENTICATION" }
 *
 * @return AuthenticationProvider represented as JSON response
 * @throws Exception
 */
@GET
@Path("/authentication-provider")
@Produces({ MediaType.APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getAuthenticationProvider() throws Exception {
    try {
        if (canAdminister()) {
            IConfiguration config = this.systemConfig.getConfiguration("security");
            String provider = config.getProperties().getProperty("provider");
            return Response.ok(new AuthenticationProvider(provider)).type(MediaType.APPLICATION_JSON).build();
        } else {
            return Response.status(UNAUTHORIZED).build();
        }
    } catch (Throwable t) {
        // $NON-NLS-1$
        logger.error(Messages.getInstance().getString("SystemResource.GENERAL_ERROR"), t);
        throw new Exception(t);
    }
}
Also used : IConfiguration(org.pentaho.platform.api.engine.IConfiguration) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Aggregations

IConfiguration (org.pentaho.platform.api.engine.IConfiguration)17 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)10 Properties (java.util.Properties)9 Test (org.junit.Test)9 File (java.io.File)4 IOException (java.io.IOException)4 Matchers.anyString (org.mockito.Matchers.anyString)3 Before (org.junit.Before)2 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)2 LinkedList (java.util.LinkedList)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1