blob: 8f4e7e49b5a50ab8723e677b27fd463e427e9873 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.qpid.server.security.access.config.connection;
import org.apache.qpid.server.security.access.config.ObjectProperties;
import org.apache.qpid.server.transport.AMQPConnection;
public class ConnectionPrincipalFrequencyLimitRule extends ConnectionPrincipalStatisticsRule
{
public ConnectionPrincipalFrequencyLimitRule(final int limit)
{
super(limit);
}
@Override
boolean matches(final AMQPConnection<?> connection)
{
return connection.getAuthenticatedPrincipalConnectionFrequency() <= getLimit();
}
@Override
public String toString()
{
return String.format("ConnectionPrincipalFrequencyLimitRule{%s=%d}",
ObjectProperties.Property.CONNECTION_FREQUENCY_LIMIT.name().toLowerCase(),
getLimit());
}
}