Вынос MAC адреса из cisco-avp-pair в Calling-Station-Id для модуля Inet
Материал из BiTel WiKi
(Различия между версиями)
Dimonyga (Обсуждение | вклад) (Новая страница: «Вынос MAC адреса из cisco-avp-pair в Calling-Station-Id. В результате MAC адрес отображается в номере звоняще…») |
Dimonyga (Обсуждение | вклад) |
||
(1 промежуточная версия не показана) | |||
Строка 18: | Строка 18: | ||
extends AbstractRadiusProtocolHandler | extends AbstractRadiusProtocolHandler | ||
implements RadiusProtocolHandler | implements RadiusProtocolHandler | ||
- | { | + | { |
- | + | private static final Logger logger = Logger.getLogger( DeviceProtoHandler.class ); | |
- | + | ||
- | + | private void setMAC( RadiusPacket request ) | |
- | + | { | |
- | + | String MacAddressPrefix = "client-mac-address="; | |
- | + | boolean FoundMacAddress=false; | |
- | + | List<RadiusAttribute<?>> attributes = request.getAttributes(9,1); | |
- | + | if( attributes != null ) | |
- | + | { | |
- | + | for( RadiusAttribute<?> attr : attributes ) | |
- | + | { | |
- | + | String value = ((RadiusAttribute<String>)attr).getValue(); | |
- | + | if( value.startsWith( MacAddressPrefix ) ) | |
- | + | { | |
- | + | request.setStringAttribute( RadiusStandartAttributes.Calling_Station_Id, value.replaceAll(MacAddressPrefix,"") ); | |
- | + | FoundMacAddress=true; | |
- | + | } | |
- | + | } | |
- | + | if (!FoundMacAddress) | |
- | + | { | |
- | + | logger.warn( "Not found 'client-mac-address=' prefix" ); | |
- | + | } | |
- | + | } else { | |
- | + | logger.warn( "Not found attributes" ); | |
- | + | } | |
- | + | ||
- | + | } | |
- | + | ||
- | + | @Override | |
- | + | public void preprocessAccessRequest( RadiusPacket request, RadiusPacket response, ConnectionSet connectionSet ) | |
- | + | throws Exception | |
- | + | { | |
- | + | super.preprocessAccessRequest( request, response, connectionSet ); | |
- | + | setMAC( request ); | |
- | + | } | |
- | + | ||
- | + | ||
- | + | ||
} | } | ||
</source> | </source> | ||
- | Авторские права [http://dimonyga.ru Dimonyga] | + | Авторские права [http://dimonyga.ru Dimonyga] [http://loctelecom.ru Локтелеком Чита.] |
Текущая версия на 01:00, 2 февраля 2012
Вынос MAC адреса из cisco-avp-pair в Calling-Station-Id. В результате MAC адрес отображается в номере звонящего и может быть использован в ограничениях по номеру звонящего для разрешения входа логина с определенного MACа.
Для версии 5.2
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 MacAddressPrefix = "client-mac-address="; boolean FoundMacAddress=false; List<RadiusAttribute<?>> attributes = request.getAttributes(9,1); if( attributes != null ) { for( RadiusAttribute<?> attr : attributes ) { String value = ((RadiusAttribute<String>)attr).getValue(); if( value.startsWith( MacAddressPrefix ) ) { request.setStringAttribute( RadiusStandartAttributes.Calling_Station_Id, value.replaceAll(MacAddressPrefix,"") ); FoundMacAddress=true; } } if (!FoundMacAddress) { logger.warn( "Not found 'client-mac-address=' prefix" ); } } else { logger.warn( "Not found attributes" ); } } @Override public void preprocessAccessRequest( RadiusPacket request, RadiusPacket response, ConnectionSet connectionSet ) throws Exception { super.preprocessAccessRequest( request, response, connectionSet ); setMAC( request ); } }
Авторские права Dimonyga Локтелеком Чита.