List of usage examples for org.apache.shiro.authc AbstractAuthenticator getAuthenticationListeners
@SuppressWarnings({ "UnusedDeclaration" })
public Collection<AuthenticationListener> getAuthenticationListeners()
From source file:com.company.sdn.impl.ConnectorRpcProvider.java
License:Open Source License
public ConnectorRpcProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, RpcProviderRegistry rpcRegistry) { this.dataBroker = dataBroker; this.notificationPublishService = notificationPublishService; this.rpcRegistry = rpcRegistry; this.rpcRegistry.addRpcImplementation(SystemConnectorXyzRpcService.class, this); /**//w w w.j a v a 2 s . com * This block never worked as it needs static security manager which needs staticSecurityManagerEnabled to be set. */ try { AuthenticatingSecurityManager securityMgr = (AuthenticatingSecurityManager) SecurityUtils .getSecurityManager(); LOG.info("security mgr {}", securityMgr); AbstractAuthenticator authentication = (AbstractAuthenticator) securityMgr.getAuthenticator(); authentication.getAuthenticationListeners().add(new CustomAuthenticationListener()); } catch (Exception e) { LOG.error("error {}", e); } }
From source file:com.company.sdn.impl.ConnectorRpcProvider.java
License:Open Source License
@Override public Future<RpcResult<AddConnectorOutput>> addConnector(AddConnectorInput input) { /**//from w ww. ja v a 2 s.c om * Temporary code here. * */ try { AuthenticatingSecurityManager securityMgr = (AuthenticatingSecurityManager) SecurityUtils .getSecurityManager(); LOG.info("security mgr {}", securityMgr); AbstractAuthenticator authentication = (AbstractAuthenticator) securityMgr.getAuthenticator(); authentication.getAuthenticationListeners().add(new CustomAuthenticationListener()); } catch (Exception e) { LOG.error("error {}", e); } RpcResultBuilder<AddConnectorOutput> rpcResultBuilder = RpcResultBuilder.success(); String connectorIdString = CONNECTOR_PREFIX + Long.toString(Calendar.getInstance().getTimeInMillis()); ConnectorId connectorId = new ConnectorId(connectorIdString); ConnectorKey connectorKey = new ConnectorKey(connectorId); InstanceIdentifier<Connector> connectorIID = InstanceIdentifier.builder(System.class) .augmentation(SystemConnectors.class).child(Connectors.class).child(Connector.class, connectorKey) .build(); input.getConfig(); Connector connector = new ConnectorBuilder().setConfig(input.getConfig()).setId(connectorId) .setKey(connectorKey).build(); ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); transaction.merge(LogicalDatastoreType.CONFIGURATION, connectorIID, connector, true); transaction.submit(); ConnectorLifecycleEventBuilder connectorEventBuilder = new ConnectorLifecycleEventBuilder(connector) .setEventType(SystemEventType.Add).setId(connectorId); try { notificationPublishService.putNotification(connectorEventBuilder.build()); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return rpcResultBuilder.withResult(new AddConnectorOutputBuilder().setId(connectorId).build()) .buildFuture(); }
From source file:io.bootique.shiro.web.mdc.ShiroWebMDCModuleIT.java
License:Apache License
@Test public void testContainerState_InitializerListener() { Realm mockRealm = mock(Realm.class); BQRuntime runtime = testFactory.app().module(b -> ShiroModule.extend(b).addRealm(mockRealm)) .autoLoadModules().createRuntime(); DefaultSecurityManager securityManager = (DefaultSecurityManager) runtime .getInstance(SecurityManager.class); AbstractAuthenticator authenticator = (AbstractAuthenticator) securityManager.getAuthenticator(); assertEquals(1, authenticator.getAuthenticationListeners().size()); assertTrue(authenticator.getAuthenticationListeners().iterator().next() instanceof OnAuthMDCInitializer); }