/*
 * Copyright 2006-2008 Sxip Identity Corporation
 */

package org.openid4java.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author Sutra Zhou
 * 
 */
public class OpenID4JavaUtils
{
    private static Log _log = LogFactory.getLog(OpenID4JavaUtils.class);

    private static final Properties _appProperties;

    static
    {
        _appProperties = new Properties();
        _appProperties.putAll(loadProperties("openid4java-default.properties"));
        Properties custom = loadProperties("/openid4java.properties");
        if (custom != null)
        {
            _appProperties.putAll(custom);
        }
    }

    private static Properties loadProperties(String name)
    {
        Properties p = null;
        InputStream is = OpenID4JavaUtils.class.getResourceAsStream(name);
        if (is != null)
        {
            p = new Properties();
            try
            {
                p.load(is);
            }
            catch (IOException e)
            {
                _log.error("Load properties from " + name + " failed.", e);
            }
            finally
            {
                try
                {
                    is.close();
                }
                catch (IOException e)
                {
                }
            }
        }
        else
        {
            _log.debug("Resource " + name + " not found.");
        }
        return p;
    }

    public static String getProperty(String key)
    {
        return _appProperties.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue)
    {
        return _appProperties.getProperty(key, defaultValue);
    }

    private OpenID4JavaUtils()
    {
    }

}

@@ -257,16 +257,240 @@
 y;%0A%0A/**%0A
+ * Load properties from classpath:%3Ccode%3Eorg.openid4java.util.openid4java-default.properties%3C/code%3E,%0A * then load custom properties from classpath:%3Ccode%3Eopenid4java.properties%3C/code%3E%0A * to replace the default if exists..%0A * %0A
  * @auth
@@ -683,24 +683,128 @@
 tatic%0A    %7B%0A
+        // Load default properties first, then use custom properties to replace%0A        // the default.%0A
         _app

Add comment for OpenID4JavaUtils.