List of usage examples for org.apache.shiro.mgt AuthenticatingSecurityManager getAuthenticator
public Authenticator getAuthenticator()
Authenticator instance that this SecurityManager uses to perform all authentication operations. 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 a2s . 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) { /**/* w ww. j a v a2 s.co m*/ * 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(); }