<commit_before>/***********************************************************************
 * Copyright (c) 2000-2006 The Apache Software Foundation.             *
 * All rights reserved.                                                *
 * ------------------------------------------------------------------- *
 * Licensed under the Apache License, Version 2.0 (the "License"); you *
 * may not use this file except in compliance with the License. You    *
 * may obtain a copy of the License at:                                *
 *                                                                     *
 *     http://www.apache.org/licenses/LICENSE-2.0                      *
 *                                                                     *
 * Unless required by applicable law or agreed to in writing, software *
 * distributed under the License is distributed on an "AS IS" BASIS,   *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
 * implied.  See the License for the specific language governing       *
 * permissions and limitations under the License.                      *
 ***********************************************************************/
package org.apache.james.smtpserver.core;

import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.james.smtpserver.ConnectHandler;
import org.apache.james.smtpserver.SMTPSession;
import org.apache.james.util.RoaminUsersHelper;
import org.apache.james.util.TimeConverter;

/**
 * This ConnectHandler can be used to activate pop-before-smtp
 */
public class RoaminUsersHandler implements ConnectHandler, Configurable {

    /**
     * The time after which ipAddresses should be handled as expired
     */
    private long expireTime;

    /**
     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
     */
    public void configure(Configuration arg0) throws ConfigurationException {
        Configuration config = arg0.getChild("expireTime", false);

        if (config != null) {
            try {
                setExpireTime(config.getValue(null));
            } catch (NumberFormatException e) {
                throw new ConfigurationException(
                        "Please configure a valid expireTime: "
                                + e.getMessage());
            }
        }
    }

    /**
     * Set the time after which an ipAddresses should be handled as expired
     * 
     * @param expireTime
     *            The time
     */
    public void setExpireTime(String rawExpireTime) {
        if (rawExpireTime != null) {
            this.expireTime = TimeConverter.getMilliSeconds(rawExpireTime);
        } else {
            this.expireTime = RoaminUsersHelper.EXPIRE_TIME;
        }
    }

    /**
     * @see org.apache.james.smtpserver.ConnectHandler#onConnect(SMTPSession)
     */<commit_msg>Fix a bug in setting expireTime.<commit_after>/***********************************************************************
 * Copyright (c) 2000-2006 The Apache Software Foundation.             *
 * All rights reserved.                                                *
 * ------------------------------------------------------------------- *
 * Licensed under the Apache License, Version 2.0 (the "License"); you *
 * may not use this file except in compliance with the License. You    *
 * may obtain a copy of the License at:                                *
 *                                                                     *
 *     http://www.apache.org/licenses/LICENSE-2.0                      *
 *                                                                     *
 * Unless required by applicable law or agreed to in writing, software *
 * distributed under the License is distributed on an "AS IS" BASIS,   *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
 * implied.  See the License for the specific language governing       *
 * permissions and limitations under the License.                      *
 ***********************************************************************/
package org.apache.james.smtpserver.core;

import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.james.smtpserver.ConnectHandler;
import org.apache.james.smtpserver.SMTPSession;
import org.apache.james.util.RoaminUsersHelper;
import org.apache.james.util.TimeConverter;

/**
 * This ConnectHandler can be used to activate pop-before-smtp
 */
public class RoaminUsersHandler implements ConnectHandler, Configurable {

    /**
     * The time after which ipAddresses should be handled as expired
     */
    private long expireTime = RoaminUsersHelper.EXPIRE_TIME;

    /**
     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
     */
    public void configure(Configuration arg0) throws ConfigurationException {
        Configuration config = arg0.getChild("expireTime", false);

        if (config != null) {
            try {
                setExpireTime(config.getValue(null));
            } catch (NumberFormatException e) {
                throw new ConfigurationException(
                        "Please configure a valid expireTime: "
                                + e.getMessage());
            }
        }
    }

    /**
     * Set the time after which an ipAddresses should be handled as expired
     * 
     * @param expireTime
     *            The time
     */
    public void setExpireTime(String rawExpireTime) {
        if (rawExpireTime != null) {
            this.expireTime = TimeConverter.getMilliSeconds(rawExpireTime);
        } 
    }

    /**
     * @see org.apache.james.smtpserver.ConnectHandler#onConnect(SMTPSession)
     */
{'fraction_non_alphanumeric': 0.14450770261219023, 'fraction_numerical': 0.004688546550569324, 'mean_word_length': 1.9583952451708766, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3317588', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1335, 'n_words': 385}