Search in sources :

Example 1 with AuthenticationRecord

use of org.opencord.aaa.AuthenticationRecord in project aaa by opencord.

the class AaaManager method removeAuthenticationStateByMac.

@Override
public boolean removeAuthenticationStateByMac(MacAddress mac) {
    Optional<AuthenticationRecord> r = authentications.values().stream().filter(v -> v.supplicantAddress().equals(mac)).findFirst();
    if (r.isEmpty()) {
        return false;
    }
    AuthenticationRecord removed = authentications.remove(r.get().supplicantConnectPoint());
    return removed != null;
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) Arrays(java.util.Arrays) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) ScheduledFuture(java.util.concurrent.ScheduledFuture) CoreService(org.onosproject.core.CoreService) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) APP_SUBJECT_FACTORY(org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) SecretKeySpec(javax.crypto.spec.SecretKeySpec) RadiusOperationalStatusEvaluationMode(org.opencord.aaa.RadiusOperationalStatusService.RadiusOperationalStatusEvaluationMode) ByteBuffer(java.nio.ByteBuffer) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) AaaMachineStatisticsService(org.opencord.aaa.AaaMachineStatisticsService) ConnectPoint(org.onosproject.net.ConnectPoint) InetAddress(java.net.InetAddress) Ethernet(org.onlab.packet.Ethernet) AuthenticationEventListener(org.opencord.aaa.AuthenticationEventListener) StorageService(org.onosproject.store.service.StorageService) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) Serializer(org.onosproject.store.service.Serializer) StateMachineDelegate(org.opencord.aaa.StateMachineDelegate) RadiusCommunicator(org.opencord.aaa.RadiusCommunicator) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Deactivate(org.osgi.service.component.annotations.Deactivate) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) Mac(javax.crypto.Mac) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) PacketService(org.onosproject.net.packet.PacketService) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) OsgiPropertyConstants(org.opencord.aaa.impl.OsgiPropertyConstants) AaaConfig(org.opencord.aaa.AaaConfig) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) BaseInformationService(org.opencord.sadis.BaseInformationService) EthType(org.onlab.packet.EthType) List(java.util.List) ConfigFactory(org.onosproject.net.config.ConfigFactory) EAPOL(org.onlab.packet.EAPOL) InboundPacket(org.onosproject.net.packet.InboundPacket) AaaSupplicantMachineStats(org.opencord.aaa.AaaSupplicantMachineStats) AaaMachineStatisticsEvent(org.opencord.aaa.AaaMachineStatisticsEvent) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) PacketContext(org.onosproject.net.packet.PacketContext) Entry(java.util.Map.Entry) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) RadiusOperationalStatusEvent(org.opencord.aaa.RadiusOperationalStatusEvent) AuthenticationService(org.opencord.aaa.AuthenticationService) RadiusOperationalStatusService(org.opencord.aaa.RadiusOperationalStatusService) Tools(org.onlab.util.Tools) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) ComponentContext(org.osgi.service.component.ComponentContext) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) RADIUSAttribute(org.onlab.packet.RADIUSAttribute) KryoNamespace(org.onlab.util.KryoNamespace) AuthenticationStatisticsService(org.opencord.aaa.AuthenticationStatisticsService) MapEventListener(org.onosproject.store.service.MapEventListener) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) DeserializationException(org.onlab.packet.DeserializationException) OutboundPacket(org.onosproject.net.packet.OutboundPacket) SadisService(org.opencord.sadis.SadisService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Activate(org.osgi.service.component.annotations.Activate) RADIUS(org.onlab.packet.RADIUS) ExecutorService(java.util.concurrent.ExecutorService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) Maps(com.google.common.collect.Maps) UnknownHostException(java.net.UnknownHostException) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TimeUnit(java.util.concurrent.TimeUnit) EAP(org.onlab.packet.EAP) AuthenticationEvent(org.opencord.aaa.AuthenticationEvent) MapEvent(org.onosproject.store.service.MapEvent) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Modified(org.osgi.service.component.annotations.Modified) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord)

Example 2 with AuthenticationRecord

use of org.opencord.aaa.AuthenticationRecord in project aaa by opencord.

the class AaaManager method activate.

@Activate
public void activate(ComponentContext context) {
    idManager = new IdentifierManager();
    stateMachines = Maps.newConcurrentMap();
    appId = coreService.registerApplication(APP_NAME);
    KryoNamespace authSerializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(AuthenticationRecord.class).build();
    authenticationsConsistentMap = storageService.<ConnectPoint, AuthenticationRecord>consistentMapBuilder().withApplicationId(appId).withName("authentications").withSerializer(Serializer.using(authSerializer)).build();
    authenticationsConsistentMap.addListener(mapListener);
    authentications = authenticationsConsistentMap.asJavaMap();
    eventDispatcher.addSink(AuthenticationEvent.class, listenerRegistry);
    netCfgService.addListener(cfgListener);
    netCfgService.registerConfigFactory(factory);
    cfgService.registerProperties(getClass());
    modified(context);
    if (sadisService != null) {
        subsService = sadisService.getSubscriberInfoService();
    } else {
        log.warn(SADIS_NOT_RUNNING);
    }
    if (customInfo == null) {
        customInfo = new CustomizationInfo(subsService, deviceService);
    }
    cfgListener.reconfigureNetwork(netCfgService.getConfig(appId, AaaConfig.class));
    log.info("Starting with config {} {}", this, newCfg);
    configureRadiusCommunication(false);
    // register our event handler
    packetService.addProcessor(processor, PacketProcessor.director(2));
    StateMachine.setDelegate(delegate);
    cleanupTimerTimeOutInMins = newCfg.sessionCleanupTimer();
    StateMachine.setcleanupTimerTimeOutInMins(cleanupTimerTimeOutInMins);
    impl.initializeLocalState(newCfg);
    impl.requestIntercepts();
    deviceService.addListener(deviceListener);
    getConfiguredAaaServerAddress();
    radiusOperationalStatusService.initialize(nasIpAddress.getAddress(), radiusSecret, impl);
    serverStatusAndStateMachineTimeoutExecutor = Executors.newScheduledThreadPool(STATE_MACHINE_THREADS, groupedThreads("onos/aaa", "machine-%d", log));
    scheduledStatusServerChecker = serverStatusAndStateMachineTimeoutExecutor.scheduleAtFixedRate(new ServerStatusChecker(), 0, operationalStatusEventGenerationPeriodInSeconds, TimeUnit.SECONDS);
    log.info("Started");
}
Also used : AaaConfig(org.opencord.aaa.AaaConfig) KryoNamespace(org.onlab.util.KryoNamespace) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with AuthenticationRecord

use of org.opencord.aaa.AuthenticationRecord in project aaa by opencord.

the class AaaResetAllCommand method doExecute.

@Override
protected void doExecute() {
    AuthenticationService authService = get(AuthenticationService.class);
    List<AuthenticationRecord> authentications = newArrayList(authService.getAuthenticationRecords());
    for (AuthenticationRecord auth : authentications) {
        authService.removeAuthenticationStateByMac(auth.supplicantAddress());
    }
}
Also used : AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) AuthenticationService(org.opencord.aaa.AuthenticationService)

Example 4 with AuthenticationRecord

use of org.opencord.aaa.AuthenticationRecord in project aaa by opencord.

the class AaaShowUsersCommand method doExecute.

@Override
protected void doExecute() {
    final Comparator<AuthenticationRecord> authenticationRecordComparator = (a1, a2) -> Comparators.CONNECT_POINT_COMPARATOR.compare(a1.supplicantConnectPoint(), a2.supplicantConnectPoint());
    DeviceService devService = get(DeviceService.class);
    SadisService sadisService = get(SadisService.class);
    AuthenticationService authService = get(AuthenticationService.class);
    List<AuthenticationRecord> authentications = newArrayList(authService.getAuthenticationRecords());
    authentications.sort(authenticationRecordComparator);
    if (strDeviceId != null && !strDeviceId.isEmpty()) {
        DeviceId deviceId = DeviceId.deviceId(strDeviceId);
        authentications = authentications.stream().filter(a -> a.supplicantConnectPoint().deviceId().equals(deviceId)).collect(Collectors.toList());
    }
    for (AuthenticationRecord auth : authentications) {
        String username = UNKNOWN;
        if (auth.username() != null) {
            username = new String(auth.username());
        }
        String mac = UNKNOWN;
        if (auth.supplicantAddress() != null) {
            mac = auth.supplicantAddress().toString();
        }
        Port port = devService.getPort(auth.supplicantConnectPoint());
        String nasPortId = UNKNOWN;
        if (port != null) {
            nasPortId = devService.getPort(auth.supplicantConnectPoint()).annotations().value(AnnotationKeys.PORT_NAME);
        }
        String subsId = UNKNOWN;
        SubscriberAndDeviceInformation subscriber = sadisService.getSubscriberInfoService().get(nasPortId);
        if (subscriber != null) {
            subsId = subscriber.nasPortId();
        }
        print("%s: %s, last-changed=%s, mac=%s, subid=%s, username=%s", auth.supplicantConnectPoint(), auth.state(), Tools.timeAgo(auth.lastChanged()), mac, subsId, username);
    }
}
Also used : Comparators(org.onosproject.utils.Comparators) AuthenticationService(org.opencord.aaa.AuthenticationService) Tools(org.onlab.util.Tools) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) DeviceService(org.onosproject.net.device.DeviceService) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) Argument(org.apache.karaf.shell.api.action.Argument) AnnotationKeys(org.onosproject.net.AnnotationKeys) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) SadisService(org.opencord.sadis.SadisService) Port(org.onosproject.net.Port) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Completion(org.apache.karaf.shell.api.action.Completion) DeviceId(org.onosproject.net.DeviceId) Comparator(java.util.Comparator) DeviceIdCompleter(org.onosproject.cli.net.DeviceIdCompleter) SadisService(org.opencord.sadis.SadisService) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) SubscriberAndDeviceInformation(org.opencord.sadis.SubscriberAndDeviceInformation) AuthenticationRecord(org.opencord.aaa.AuthenticationRecord) AuthenticationService(org.opencord.aaa.AuthenticationService)

Aggregations

AuthenticationRecord (org.opencord.aaa.AuthenticationRecord)4 List (java.util.List)2 KryoNamespace (org.onlab.util.KryoNamespace)2 Tools (org.onlab.util.Tools)2 AaaConfig (org.opencord.aaa.AaaConfig)2 AuthenticationService (org.opencord.aaa.AuthenticationService)2 Activate (org.osgi.service.component.annotations.Activate)2 Strings (com.google.common.base.Strings)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ByteBuffer (java.nio.ByteBuffer)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 Dictionary (java.util.Dictionary)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1