Копирайт:
http://loctelecom.ruКопирайт:
http://dimonyga.ruКласс: ru.locotelecom.bgbilling.modules.inet.dyn;
Код:
package ru.locotelecom.bgbilling.modules.inet.dyn;
import org.apache.log4j.Logger;
import java.util.List;
import bitel.billing.server.radius.RadiusStandartAttributes;
import ru.bitel.bgbilling.kernel.network.radius.RadiusAttribute;
import ru.bitel.bgbilling.kernel.network.radius.RadiusPacket;
import ru.bitel.bgbilling.kernel.network.radius.RadiusProtocolHandler;
import ru.bitel.bgbilling.modules.inet.dyn.device.radius.AbstractRadiusProtocolHandler;
import ru.bitel.common.sql.ConnectionSet;
public class DeviceProtoHandler
extends AbstractRadiusProtocolHandler
implements RadiusProtocolHandler
{
private static final Logger logger = Logger.getLogger( DeviceProtoHandler.class );
private void setMAC( RadiusPacket request )
{
String prefix = "client-mac-address=";
boolean flag=false;
List<RadiusAttribute<?>> attributes = request.getAttributes(9,1);
if( attributes != null )
{
for( RadiusAttribute<?> attr : attributes )
{
String value = ((RadiusAttribute<String>)attr).getValue();
if( value.startsWith( prefix ) )
{
request.setStringAttribute( RadiusStandartAttributes.Calling_Station_Id, value.replaceAll(prefix,"") );
flag=true;
}
}
if (!flag)
{
flag=true;
logger.warn( "Not found 'client-mac-address=' prefix" );
}
}
if (!flag)
{
logger.warn( "Not found attributes" );
}
}
@Override
public void preprocessAccessRequest( RadiusPacket request, RadiusPacket response, ConnectionSet connectionSet )
throws Exception
{
super.preprocessAccessRequest( request, response, connectionSet );
setMAC( request );
}
}