Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.isis.objectstore.nosql.db.file.server.FileServer.java

public FileServer() {
    org.apache.log4j.PropertyConfigurator.configure("config/logging.properties");

    try {/*w ww . j  a  va 2  s  .c  om*/
        config = new CompositeConfiguration();
        config.addConfiguration(new SystemConfiguration());
        config.addConfiguration(new PropertiesConfiguration("config/server.properties"));

        final String data = config.getString("fileserver.data");
        final String services = config.getString("fileserver.services");
        final String logs = config.getString("fileserver.logs");
        final String archive = config.getString("fileserver.archive");

        Util.setDirectory(data, services, logs, archive);
        server = new FileServerProcessor();
    } catch (final ConfigurationException e) {
        LOG.error("configuration failure", e);
        System.out.println(e.getMessage());
        System.exit(0);
    }
}

From source file:org.apache.isis.runtimes.dflt.objectstores.nosql.db.file.server.FileServer.java

public FileServer() {
    PropertyConfigurator.configure("config/logging.properties");

    try {/*from   w  w w.j a  v  a2 s  . c  o m*/
        config = new CompositeConfiguration();
        config.addConfiguration(new SystemConfiguration());
        config.addConfiguration(new PropertiesConfiguration("config/server.properties"));

        final String data = config.getString("fileserver.data");
        final String services = config.getString("fileserver.services");
        final String logs = config.getString("fileserver.logs");
        final String archive = config.getString("fileserver.archive");

        Util.setDirectory(data, services, logs, archive);
        server = new FileServerProcessor();
    } catch (final ConfigurationException e) {
        LOG.error("configuration failure", e);
        System.out.println(e.getMessage());
        System.exit(0);
    }
}

From source file:org.apache.juddi.api.impl.AuthenticatedService.java

public UddiEntityPublisher getEntityPublisher(EntityManager em, String authInfo)
        throws DispositionReportFaultMessage {

    if (authInfo == null || authInfo.length() == 0)
        throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthRequired"));

    org.apache.juddi.model.AuthToken modelAuthToken = em.find(org.apache.juddi.model.AuthToken.class, authInfo);
    if (modelAuthToken == null)
        throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));

    int allowedMinutesOfInactivity = 0;
    try {//from w  ww .  j  a  va  2s.c o  m
        allowedMinutesOfInactivity = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_TIMEOUT, 0);
    } catch (ConfigurationException ce) {
        logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
                + "the application's configuration. No automatic timeout token invalidation will occur. "
                + ce.getMessage(), ce);
    }
    int maxMinutesOfAge = 0;
    try {
        maxMinutesOfAge = AppConfig.getConfiguration().getInt(Property.JUDDI_AUTH_TOKEN_EXPIRATION, 0);
    } catch (ConfigurationException ce) {
        logger.error("Error reading property " + Property.JUDDI_AUTH_TOKEN_EXPIRATION + " from "
                + "the application's configuration. No automatic timeout token invalidation will occur. "
                + ce.getMessage(), ce);
    }
    Date now = new Date();
    // 0 or negative means token does not expire
    if (allowedMinutesOfInactivity > 0) {
        // expire tokens after # minutes of inactivity
        // compare the time in milli-seconds
        if (now.getTime() > modelAuthToken.getLastUsed().getTime() + allowedMinutesOfInactivity * 60000l) {
            logger.info("AUDIT: FAILTURE Token " + modelAuthToken.getAuthToken() + " expired due to inactivity "
                    + getRequestorsIPAddress());
            modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
        }
    }
    if (maxMinutesOfAge > 0) {
        // expire tokens when max age is reached
        // compare the time in milli-seconds
        if (now.getTime() > modelAuthToken.getCreated().getTime() + maxMinutesOfAge * 60000l) {

            logger.info("AUDIT: FAILURE - Token " + modelAuthToken.getAuthorizedName()
                    + " expired due to old age " + getRequestorsIPAddress());
            modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
        }
    }

    if (modelAuthToken.getTokenState() == AUTHTOKEN_RETIRED) {

        throw new AuthTokenExpiredException(new ErrorMessage("errors.auth.AuthTokenExpired"));
    }
    if (ctx != null) {
        try {
            boolean check = true;
            try {
                check = AppConfig.getConfiguration().getBoolean(Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP,
                        true);
            } catch (ConfigurationException ex) {
                logger.warn("Error loading config property " + Property.JUDDI_AUTH_TOKEN_ENFORCE_SAME_IP
                        + " Enforcing Same IP for Auth Tokens will be enabled by default", ex);
            }
            if (check) {
                MessageContext mc = ctx.getMessageContext();
                HttpServletRequest req = null;
                if (mc != null) {
                    req = (HttpServletRequest) mc.get(MessageContext.SERVLET_REQUEST);
                }
                if (req != null && modelAuthToken.getIPAddress() != null
                        && modelAuthToken.getIPAddress() != null
                        && !modelAuthToken.getIPAddress().equalsIgnoreCase(req.getRemoteAddr())) {
                    modelAuthToken.setTokenState(AUTHTOKEN_RETIRED);
                    logger.error(
                            "AUDIT FAILURE - Security Alert - Attempt to use issued auth token from a different IP address, user "
                                    + modelAuthToken.getAuthorizedName() + ", issued IP "
                                    + modelAuthToken.getIPAddress() + ", attempted use from "
                                    + req.getRemoteAddr() + ", forcing reauthentication.");
                    throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
                    //invalidate the token, someone's intercepted it or it was reused on another ip
                }
            }
        } catch (Exception ex) {
            if (ex instanceof AuthTokenRequiredException)
                throw (AuthTokenRequiredException) ex;
            logger.error("unexpected error caught looking up requestor's ip address", ex);
        }

    }
    Authenticator authenticator = AuthenticatorFactory.getAuthenticator();
    UddiEntityPublisher entityPublisher = authenticator.identify(authInfo, modelAuthToken.getAuthorizedName());

    // Must make sure the returned publisher has all the necessary fields filled
    if (entityPublisher == null) {
        logger.warn(
                "AUDIT FAILURE - Auth token invalided, publisher does not exist " + getRequestorsIPAddress());
        throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
    }
    if (entityPublisher.getAuthorizedName() == null) {
        logger.warn("AUDIT FAILURE - Auth token invalided, username does exist" + getRequestorsIPAddress());
        throw new AuthTokenRequiredException(new ErrorMessage("errors.auth.AuthInvalid"));
    }
    // Auth token is being used.  Adjust appropriate values so that it's internal 'expiration clock' is reset.
    modelAuthToken.setLastUsed(new Date());
    modelAuthToken.setNumberOfUses(modelAuthToken.getNumberOfUses() + 1);

    return entityPublisher;

}

From source file:org.apache.juddi.api.impl.UDDIv2InquiryImpl.java

public static String getNodeID() {
    try {//from  ww w  .  ja va2s .  c o m
        nodeId = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
    } catch (ConfigurationException ex) {
        logger.warn(ex.getMessage());
        nodeId = "JUDDI_v3";
    }
    return nodeId;
}

From source file:org.apache.juddi.api.impl.UDDIv2PublishImpl.java

private static String getNodeID() {
    try {//from www. ja v a2  s . c o m
        nodeId = AppConfig.getConfiguration().getString(Property.JUDDI_NODE_ID);
    } catch (ConfigurationException ex) {
        logger.warn(ex.getMessage());
        nodeId = "JUDDI_v3";
    }
    return nodeId;
}

From source file:org.apache.juddi.mapping.MappingModelToApi.java

public static void mapDiscoveryUrls(List<org.apache.juddi.model.DiscoveryUrl> modelDiscUrlList,
        org.uddi.api_v3.DiscoveryURLs apiDiscUrls, org.uddi.api_v3.BusinessEntity apiBusinessEntity)
        throws DispositionReportFaultMessage {
    if (modelDiscUrlList == null || modelDiscUrlList.size() == 0)
        return;/*from   www  .ja v a  2 s  . c om*/

    if (apiDiscUrls == null)
        apiDiscUrls = new org.uddi.api_v3.DiscoveryURLs();

    List<org.uddi.api_v3.DiscoveryURL> apiDiscUrlList = apiDiscUrls.getDiscoveryURL();
    apiDiscUrlList.clear();

    for (org.apache.juddi.model.DiscoveryUrl modelDiscUrl : modelDiscUrlList) {
        org.uddi.api_v3.DiscoveryURL apiDiscUrl = new org.uddi.api_v3.DiscoveryURL();
        apiDiscUrl.setUseType(modelDiscUrl.getUseType());
        String discoveryURL = modelDiscUrl.getUrl();
        try {
            String baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL);
            if (baseUrl == null) {
                logger.warn("Token '" + Property.JUDDI_BASE_URL
                        + "' not found in the juddiv3.xml, defaulting to '" + Property.DEFAULT_BASE_URL + "'");
                baseUrl = Property.DEFAULT_BASE_URL;
            }
            discoveryURL = discoveryURL.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL + "\\}", baseUrl);

            baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE);
            if (baseUrl == null) {
                logger.warn("Token '" + Property.JUDDI_BASE_URL_SECURE
                        + "' not found in the juddiv3.xml, defaulting to '" + Property.JUDDI_BASE_URL_SECURE
                        + "'");
                baseUrl = Property.DEFAULT_BASE_URL_SECURE;
            }
            discoveryURL = discoveryURL.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL_SECURE + "\\}", baseUrl);

        } catch (ConfigurationException e) {
            logger.error(e.getMessage(), e);
        }
        apiDiscUrl.setValue(discoveryURL);
        apiDiscUrlList.add(apiDiscUrl);
    }
    apiBusinessEntity.setDiscoveryURLs(apiDiscUrls);
}

From source file:org.apache.juddi.mapping.MappingModelToApi.java

public static void mapBindingTemplate(org.apache.juddi.model.BindingTemplate modelBindingTemplate,
        org.uddi.api_v3.BindingTemplate apiBindingTemplate) throws DispositionReportFaultMessage {

    apiBindingTemplate.setServiceKey(modelBindingTemplate.getBusinessService().getEntityKey());
    apiBindingTemplate.setBindingKey(modelBindingTemplate.getEntityKey());
    org.uddi.api_v3.AccessPoint apiAccessPoint = new org.uddi.api_v3.AccessPoint();
    apiAccessPoint.setUseType(modelBindingTemplate.getAccessPointType());
    String accessPointValue = modelBindingTemplate.getAccessPointUrl();
    if (accessPointValue != null) {
        try {/*w w w.  j ava 2  s . c om*/
            String baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL);
            if (baseUrl == null) {
                logger.warn("Token '" + Property.JUDDI_BASE_URL
                        + "' not found in the juddiv3.xml, defaulting to '" + Property.DEFAULT_BASE_URL + "'");
                baseUrl = Property.DEFAULT_BASE_URL;
            }
            accessPointValue = accessPointValue.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL + "\\}", baseUrl);

            baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE);
            if (baseUrl == null) {
                logger.warn("Token '" + Property.JUDDI_BASE_URL_SECURE
                        + "' not found in the juddiv3.xml, defaulting to '" + Property.JUDDI_BASE_URL_SECURE
                        + "'");
                baseUrl = Property.DEFAULT_BASE_URL_SECURE;
            }
            accessPointValue = accessPointValue.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL_SECURE + "\\}",
                    baseUrl);
        } catch (ConfigurationException e) {
            logger.error(e.getMessage(), e);
        }
    }
    apiAccessPoint.setValue(accessPointValue);
    apiBindingTemplate.setAccessPoint(apiAccessPoint);
    if (modelBindingTemplate.getHostingRedirector() != null) {
        org.uddi.api_v3.HostingRedirector apiHost = new org.uddi.api_v3.HostingRedirector();
        apiHost.setBindingKey(modelBindingTemplate.getHostingRedirector());
        apiBindingTemplate.setHostingRedirector(apiHost);
    }
    mapTModelInstanceDetails(modelBindingTemplate.getTmodelInstanceInfos(),
            apiBindingTemplate.getTModelInstanceDetails(), apiBindingTemplate);
    mapBindingDescriptions(modelBindingTemplate.getBindingDescrs(), apiBindingTemplate.getDescription());

    apiBindingTemplate.setCategoryBag(
            mapCategoryBag(modelBindingTemplate.getCategoryBag(), apiBindingTemplate.getCategoryBag()));
    mapSignature(modelBindingTemplate.getSignatures(), apiBindingTemplate.getSignature());
}

From source file:org.apache.juddi.servlets.RegistryServlet.java

/**
 * Create the shared instance of jUDDI's Registry class and call it's
 * "init()" method to initialize all core components.
 */// w w w  . j  a  va2 s . c o m
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
        Registry.start();
    } catch (ConfigurationException e) {
        logger.error("jUDDI registry could not be started." + e.getMessage(), e);
        throw new ServletException(e.getMessage(), e);
    }
}

From source file:org.apache.juddi.servlets.RegistryServlet.java

@Override
public void destroy() {
    try {//from  www. jav  a  2  s  .c o m
        Registry.stop();
    } catch (ConfigurationException e) {
        logger.error("jUDDI registry could not be stopped." + e.getMessage(), e);
    }
    super.destroy();
}

From source file:org.apache.juddi.validation.ValidatePublish.java

public void validateSaveBusiness(EntityManager em, SaveBusiness body, Configuration config)
        throws DispositionReportFaultMessage {

    if (config == null) {
        try {//from   ww w  .ja  v  a 2  s.c  om
            config = AppConfig.getConfiguration();
        } catch (ConfigurationException ce) {
            log.error("Could not optain config. " + ce.getMessage(), ce);
        }
    }
    // No null input
    if (body == null) {
        throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
    }

    // No null or empty list
    List<org.uddi.api_v3.BusinessEntity> entityList = body.getBusinessEntity();
    if (entityList == null || entityList.size() == 0) {
        throw new ValueNotAllowedException(new ErrorMessage("errors.savebusiness.NoInput"));
    }

    for (org.uddi.api_v3.BusinessEntity entity : entityList) {
        validateBusinessEntity(em, entity, config);
    }
}