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;
}
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");
}
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());
}
}
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);
}
}
Aggregations