io.undertow.security.api.NotificationReceiver Java Examples
The following examples show how to use
io.undertow.security.api.NotificationReceiver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSamlAuthMech.java From keycloak with Apache License 2.0 | 6 votes |
protected void registerNotifications(final SecurityContext securityContext) { final NotificationReceiver logoutReceiver = new NotificationReceiver() { @Override public void handleNotification(SecurityNotification notification) { if (notification.getEventType() != SecurityNotification.EventType.LOGGED_OUT) return; HttpServerExchange exchange = notification.getExchange(); UndertowHttpFacade facade = createFacade(exchange); SamlDeployment deployment = deploymentContext.resolveDeployment(facade); SamlSessionStore sessionStore = getTokenStore(exchange, facade, deployment, securityContext); sessionStore.logoutAccount(); } }; securityContext.registerNotificationReceiver(logoutReceiver); }
Example #2
Source File: AbstractUndertowKeycloakAuthMech.java From keycloak with Apache License 2.0 | 6 votes |
protected void registerNotifications(final SecurityContext securityContext) { final NotificationReceiver logoutReceiver = new NotificationReceiver() { @Override public void handleNotification(SecurityNotification notification) { if (notification.getEventType() != SecurityNotification.EventType.LOGGED_OUT) return; HttpServerExchange exchange = notification.getExchange(); UndertowHttpFacade facade = createFacade(exchange); KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade); KeycloakSecurityContext ksc = exchange.getAttachment(OIDCUndertowHttpFacade.KEYCLOAK_SECURITY_CONTEXT_KEY); if (!deployment.isBearerOnly() && ksc != null && ksc instanceof RefreshableKeycloakSecurityContext) { ((RefreshableKeycloakSecurityContext) ksc).logout(deployment); } AdapterTokenStore tokenStore = getTokenStore(exchange, facade, deployment, securityContext); tokenStore.logout(); } }; securityContext.registerNotificationReceiver(logoutReceiver); }
Example #3
Source File: AbstractSecurityContext.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void removeNotificationReceiver(NotificationReceiver receiver) { Node<NotificationReceiver> cur = notificationReceivers; if(receiver.equals(cur.item)) { notificationReceivers = cur.next; } else { Node<NotificationReceiver> old = cur; while (cur.next != null) { cur = cur.next; if(receiver.equals(cur.item)) { old.next = cur.next; } old = cur; } } }
Example #4
Source File: AbstractSecurityContext.java From quarkus-http with Apache License 2.0 | 6 votes |
@Override public void removeNotificationReceiver(NotificationReceiver receiver) { Node<NotificationReceiver> cur = notificationReceivers; if(receiver.equals(cur.item)) { notificationReceivers = cur.next; } else { Node<NotificationReceiver> old = cur; while (cur.next != null) { cur = cur.next; if(receiver.equals(cur.item)) { old.next = cur.next; } old = cur; } } }
Example #5
Source File: SingleSignOnAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) { Cookie cookie = exchange.getRequestCookies().get(cookieName); if (cookie != null) { final String ssoId = cookie.getValue(); log.tracef("Found SSO cookie %s", ssoId); try (SingleSignOn sso = this.singleSignOnManager.findSingleSignOn(ssoId)) { if (sso != null) { if(log.isTraceEnabled()) { log.tracef("SSO session with ID: %s found.", ssoId); } Account verified = getIdentityManager(securityContext).verify(sso.getAccount()); if (verified == null) { if(log.isTraceEnabled()) { log.tracef("Account not found. Returning 'not attempted' here."); } //we return not attempted here to allow other mechanisms to proceed as normal return AuthenticationMechanismOutcome.NOT_ATTEMPTED; } final Session session = getSession(exchange); registerSessionIfRequired(sso, session); securityContext.authenticationComplete(verified, sso.getMechanismName(), false); securityContext.registerNotificationReceiver(new NotificationReceiver() { @Override public void handleNotification(SecurityNotification notification) { if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) { singleSignOnManager.removeSingleSignOn(sso); } } }); log.tracef("Authenticated account %s using SSO", verified.getPrincipal().getName()); return AuthenticationMechanismOutcome.AUTHENTICATED; } } clearSsoCookie(exchange); } exchange.addResponseWrapper(responseListener); return AuthenticationMechanismOutcome.NOT_ATTEMPTED; }
Example #6
Source File: AbstractSecurityContext.java From lams with GNU General Public License v2.0 | 5 votes |
private void sendNoticiation(final SecurityNotification notification) { Node<NotificationReceiver> cur = notificationReceivers; while (cur != null) { cur.item.handleNotification(notification); cur = cur.next; } }
Example #7
Source File: AbstractSecurityContext.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void registerNotificationReceiver(NotificationReceiver receiver) { if(notificationReceivers == null) { notificationReceivers = new Node<>(receiver); } else { Node<NotificationReceiver> cur = notificationReceivers; while (cur.next != null) { cur = cur.next; } cur.next = new Node<>(receiver); } }
Example #8
Source File: AbstractSecurityContext.java From quarkus-http with Apache License 2.0 | 5 votes |
private void sendNoticiation(final SecurityNotification notification) { Node<NotificationReceiver> cur = notificationReceivers; while (cur != null) { cur.item.handleNotification(notification); cur = cur.next; } }
Example #9
Source File: AbstractSecurityContext.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public void registerNotificationReceiver(NotificationReceiver receiver) { if(notificationReceivers == null) { notificationReceivers = new Node<>(receiver); } else { Node<NotificationReceiver> cur = notificationReceivers; while (cur.next != null) { cur = cur.next; } cur.next = new Node<>(receiver); } }
Example #10
Source File: SingleSignOnAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) { Cookie cookie = exchange.getRequestCookies().get(cookieName); if (cookie != null) { final String ssoId = cookie.getValue(); log.tracef("Found SSO cookie %s", ssoId); try (SingleSignOn sso = this.singleSignOnManager.findSingleSignOn(ssoId)) { if (sso != null) { if (log.isTraceEnabled()) { log.tracef("SSO session with ID: %s found.", ssoId); } Account verified = getIdentityManager(securityContext).verify(sso.getAccount()); if (verified == null) { if (log.isTraceEnabled()) { log.tracef("Account not found. Returning 'not attempted' here."); } //we return not attempted here to allow other mechanisms to proceed as normal return AuthenticationMechanismOutcome.NOT_ATTEMPTED; } final Session session = getSession(exchange); registerSessionIfRequired(sso, session); securityContext.authenticationComplete(verified, sso.getMechanismName(), false); securityContext.registerNotificationReceiver(new NotificationReceiver() { @Override public void handleNotification(SecurityNotification notification) { if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) { singleSignOnManager.removeSingleSignOn(sso); } } }); log.tracef("Authenticated account %s using SSO", verified.getPrincipal().getName()); return AuthenticationMechanismOutcome.AUTHENTICATED; } } clearSsoCookie(exchange); } exchange.addResponseCommitListener(responseListener); return AuthenticationMechanismOutcome.NOT_ATTEMPTED; }
Example #11
Source File: NotificationReceiverHandler.java From lams with GNU General Public License v2.0 | 4 votes |
public NotificationReceiverHandler(final HttpHandler next, final Collection<NotificationReceiver> receivers) { this.next = next; this.receivers = receivers.toArray(new NotificationReceiver[receivers.size()]); }
Example #12
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 4 votes |
public DeploymentInfo addNotificationReceiver(final NotificationReceiver notificationReceiver) { this.notificationReceivers.add(notificationReceiver); return this; }
Example #13
Source File: NotificationReceiverHandler.java From quarkus-http with Apache License 2.0 | 4 votes |
public NotificationReceiverHandler(final HttpHandler next, final Collection<NotificationReceiver> receivers) { this.next = next; this.receivers = receivers.toArray(new NotificationReceiver[receivers.size()]); }
Example #14
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 4 votes |
public List<NotificationReceiver> getNotificationReceivers() { return notificationReceivers; }
Example #15
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 4 votes |
public DeploymentInfo addNotificationReceiver(final NotificationReceiver notificationReceiver) { this.notificationReceivers.add(notificationReceiver); return this; }
Example #16
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 4 votes |
public DeploymentInfo addNotificactionReceivers(final NotificationReceiver... notificationReceivers) { this.notificationReceivers.addAll(Arrays.asList(notificationReceivers)); return this; }
Example #17
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 4 votes |
public DeploymentInfo addNotificationReceivers(final Collection<NotificationReceiver> notificationReceivers) { this.notificationReceivers.addAll(notificationReceivers); return this; }
Example #18
Source File: DeploymentInfo.java From lams with GNU General Public License v2.0 | 4 votes |
public List<NotificationReceiver> getNotificationReceivers() { return notificationReceivers; }
Example #19
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 4 votes |
public DeploymentInfo addNotificationReceivers(final Collection<NotificationReceiver> notificationReceivers) { this.notificationReceivers.addAll(notificationReceivers); return this; }
Example #20
Source File: DeploymentInfo.java From quarkus-http with Apache License 2.0 | 4 votes |
public DeploymentInfo addNotificactionReceivers(final NotificationReceiver... notificationReceivers) { this.notificationReceivers.addAll(Arrays.asList(notificationReceivers)); return this; }