Example usage for org.apache.commons.logging LogFactory getLog

List of usage examples for org.apache.commons.logging LogFactory getLog

Introduction

In this page you can find the example usage for org.apache.commons.logging LogFactory getLog.

Prototype

public static Log getLog(String name) 

Source Link

Document

Convenience method to return a named logger.

Usage

From source file:com.liveneo.plat.utils.StringUtil.java

/**
 * Encodes a string using algorithm specified in web.xml and return the
 * resulting encrypted password. If exception, the plain credentials string
 * is returned/*  www . ja va 2  s .  co  m*/
 * 
 * @param password
 *            Password or other credentials to use in authenticating this
 *            username
 * @param algorithm
 *            Algorithm used to do the digest
 * @return encypted password based on the algorithm.
 */
public static String encodePassword(String password, String algorithm) {

    if (password == null) {
        return null;
    }

    Log log = LogFactory.getLog(StringUtil.class);
    byte[] unencodedPassword = password.getBytes();

    MessageDigest md = null;

    try {
        // first create an instance, given the provider
        md = MessageDigest.getInstance(algorithm);
    } catch (Exception e) {
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        if (log.isErrorEnabled()) {
            log.error(sw.toString());
        }
        return password;
    }

    md.reset();

    // call the update method one or more times
    // (useful when you don't know the size of your data, e.g. stream)
    md.update(unencodedPassword);

    // now calculate the hash
    byte[] encodedPassword = md.digest();

    StringBuffer buf = new StringBuffer();

    for (int i = 0; i < encodedPassword.length; i++) {
        if ((encodedPassword[i] & 0xff) < 0x10) {
            buf.append("0");
        }

        buf.append(Long.toString(encodedPassword[i] & 0xff, 16));
    }

    return buf.toString();
}

From source file:fr.putnami.pwt.core.service.server.service.CommandExecutorImpl.java

public CommandExecutorImpl(Object service, Method method) {
    this.service = service;
    this.method = method;

    String[] paramTypes = new String[method.getParameterTypes().length];

    for (int i = 0; i < method.getParameterTypes().length; i++) {
        paramTypes[i] = method.getParameterTypes()[i].getCanonicalName();
    }//ww w  .j  av  a  2s . co  m
    CommandDefinition definition = new CommandDefinition(method.getDeclaringClass().getName(), method.getName(),
            method.getReturnType().getCanonicalName(), paramTypes);
    this.setCommandDefinition(definition);

    this.executorLogger = LogFactory.getLog(method.getDeclaringClass().getCanonicalName());
}

From source file:com.alfaariss.oa.engine.authentication.jdbc.JDBCMethod.java

/**
 * Creates a method object.// ww w .  j  a v  a 2 s .  com
 * @param oResultSet A resultset containing a row with method information
 * @throws AuthenticationException if creation fails
 */
public JDBCMethod(ResultSet oResultSet) throws AuthenticationException {
    super();
    try {
        _logger = LogFactory.getLog(JDBCMethod.class);
        _sID = oResultSet.getString(COLUMN_METHOD_ID);
    } catch (Exception e) {
        _logger.fatal("Internal error during initialization", e);
        throw new AuthenticationException(SystemErrors.ERROR_INTERNAL);
    }
}

From source file:com.alfaariss.oa.util.configuration.handler.dummy.DummyConfigurationHandler.java

/**
 * Create a new <code>FileConfigHandler</code>.
 */
public DummyConfigurationHandler() {
    _logger = LogFactory.getLog(DummyConfigurationHandler.class);
}

From source file:com.acc.web.manager.LogManager.java

private Log getLogger(Object logTypeObject) {
    if (logTypeObject == null) {
        return LogFactory.getLog(this.getDefaultLogTypeString());
    }//www.java  2s  .c  o m
    if (logTypeObject instanceof String) {
        return LogFactory.getLog((String) logTypeObject);
    } else if (logTypeObject instanceof Class) {
        return LogFactory.getLog((Class) logTypeObject);
    } else {
        return LogFactory.getLog((logTypeObject.getClass()));
    }
}

From source file:com.alfaariss.oa.authentication.password.digest.HtPasswdMD5Digest.java

/**
 * Constructor.
 */
public HtPasswdMD5Digest() {
    super();
    _sCommand = DEFAULT_COMMAND;
    _systemLogger = LogFactory.getLog(this.getClass());
}

From source file:demo.config.CommonsJdbcLogger.java

@Override
public void logDaoMethodExiting(String callerClassName, String callerMethodName, Object result) {
    Log log = LogFactory.getLog(callerClassName);
    log.info("END   " + callerClassName + "#" + callerMethodName);
}

From source file:com.alfaariss.oa.util.web.CookieTool.java

/**
 * Constructor. //from  www .j  a  va2s  . co m
 * @param configurationManager The configuration manager
 * @param config The cookie configuration
 * @throws OAException 
 */
public CookieTool(IConfigurationManager configurationManager, Element config) throws OAException {
    _logger = LogFactory.getLog(CookieTool.class);

    _bSecureCookie = false;
    _sCookieDomain = null;
    _iCookieVersion = -1;

    readCookieConfiguration(configurationManager, config);
}

From source file:fr.aliasource.webmail.common.cache.AccountCache.java

/**
 * Creates a cache for the given account. The cache is xml-based and is
 * periodicaly updated once start method has been called.
 * //from w w w . j  av  a  2s. com
 * @param account
 * @param accountConf
 */
public AccountCache(IAccount account) {
    logger = LogFactory.getLog(getClass());

    this.account = account;
}

From source file:gridool.dht.ops.AddGridNodeOperation.java

public Serializable execute(ILocalDirectory directory) throws GridException {
    final byte[] v = node.toBytes();
    try {//www .  j a v  a2  s. c o  m
        directory.addMapping(keys, v);
    } catch (IndexException e) {
        LogFactory.getLog(getClass()).error(e.getMessage(), e);
        throw new GridException("Exception caused while adding a mapping", e);
    }
    return null;
}