Java源码示例:io.undertow.security.api.NotificationReceiver

示例1
@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;
        }
    }
}
 
示例2
@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;
        }
    }
}
 
示例3
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);
    }
 
示例4
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);
    }
 
示例5
@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;
}
 
示例6
@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);
    }
}
 
示例7
private void sendNoticiation(final SecurityNotification notification) {
    Node<NotificationReceiver> cur = notificationReceivers;
    while (cur != null) {
        cur.item.handleNotification(notification);
        cur = cur.next;
    }
}
 
示例8
@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;
}
 
示例9
@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);
    }
}
 
示例10
private void sendNoticiation(final SecurityNotification notification) {
    Node<NotificationReceiver> cur = notificationReceivers;
    while (cur != null) {
        cur.item.handleNotification(notification);
        cur = cur.next;
    }
}
 
示例11
public DeploymentInfo addNotificationReceiver(final NotificationReceiver notificationReceiver) {
    this.notificationReceivers.add(notificationReceiver);
    return this;
}
 
示例12
public DeploymentInfo addNotificactionReceivers(final NotificationReceiver... notificationReceivers) {
    this.notificationReceivers.addAll(Arrays.asList(notificationReceivers));
    return this;
}
 
示例13
public DeploymentInfo addNotificationReceivers(final Collection<NotificationReceiver> notificationReceivers) {
    this.notificationReceivers.addAll(notificationReceivers);
    return this;
}
 
示例14
public List<NotificationReceiver> getNotificationReceivers() {
    return notificationReceivers;
}
 
示例15
public NotificationReceiverHandler(final HttpHandler next, final Collection<NotificationReceiver> receivers) {
    this.next = next;
    this.receivers = receivers.toArray(new NotificationReceiver[receivers.size()]);
}
 
示例16
public NotificationReceiverHandler(final HttpHandler next, final Collection<NotificationReceiver> receivers) {
    this.next = next;
    this.receivers = receivers.toArray(new NotificationReceiver[receivers.size()]);
}
 
示例17
public DeploymentInfo addNotificationReceiver(final NotificationReceiver notificationReceiver) {
    this.notificationReceivers.add(notificationReceiver);
    return this;
}
 
示例18
public DeploymentInfo addNotificactionReceivers(final NotificationReceiver... notificationReceivers) {
    this.notificationReceivers.addAll(Arrays.asList(notificationReceivers));
    return this;
}
 
示例19
public DeploymentInfo addNotificationReceivers(final Collection<NotificationReceiver> notificationReceivers) {
    this.notificationReceivers.addAll(notificationReceivers);
    return this;
}
 
示例20
public List<NotificationReceiver> getNotificationReceivers() {
    return notificationReceivers;
}