All Downloads are FREE. Search and download functionalities are using the official Maven repository.

flex.messaging.services.AuthenticationEvent Maven / Gradle / Ivy

There is a newer version: 4.8.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package flex.messaging.services;

import flex.messaging.FlexSession;
import flex.messaging.client.FlexClient;
import java.security.Principal;
import java.util.EventObject;

/**
 * An event that indicates a user has either logged in or logged out successfully.
 * The event object provides access to the AuthenticationService that handled the
 * login or logout, which is the event source, as well as the Principal, FlexSession,
 * and FlexClient for the user. Following a logout, these objects may have been invalidated
 * so exercise caution with accessing and using them.
 */
public class AuthenticationEvent extends EventObject
{
    private static final long serialVersionUID = 6002063582698638736L;

    //--------------------------------------------------------------------------
    //
    // Constructor
    //
    //--------------------------------------------------------------------------

    /**
     * Constructs an AuthenticationEvent.
     * 
     * @param source The AuthenticationService dispatching this event.
     * @param username The username used to authenticate
     * @param credentials The password or secret used to authenticate.
     * @param principal The user's Principal.
     * @param flexSession The user's FlexSession.
     * @param flexClient The user's FlexClient.
     */
    public AuthenticationEvent(final AuthenticationService source, final String username, final Object credentials, final Principal principal, final FlexSession flexSession, final FlexClient flexClient)
    {
        super(source);
        this.username = username;
        this.credentials = credentials;
        this.principal = principal;
        this.flexSession = flexSession;
        this.flexClient = flexClient;
    }

    //--------------------------------------------------------------------------
    //
    // Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
    //  credentials
    //----------------------------------    
    
    private final Object credentials;
    
    /**
     * Returns the credentials used for authentication, null for logout events.
     * 
     * @return The credentials used for authentication, null for logout events.
     */
    public Object getCredentials()
    {
        return credentials;
    }
    
    //----------------------------------
    //  flexClient
    //----------------------------------

    private final FlexClient flexClient;
    
    /**
     * Returns the FlexClient associated with this event.
     * 
     * @return The FlexClient associated with this event.
     */
    public FlexClient getFlexClient()
    {
        return flexClient;
    }

    //----------------------------------
    //  flexSession
    //----------------------------------

    private final FlexSession flexSession;
    
    /**
     * Returns the FlexSession associated with this event.
     * 
     * @return The FlexSession associated with this event.
     */
    public FlexSession getFlexSession()
    {
        return flexSession;
    }    
    
    //----------------------------------
    //  principal
    //----------------------------------

    private final Principal principal;
    
    /**
     * Returns the Principal associated with this event.
     * 
     * @return The Principal associated with this event.
     */
    public Principal getPrincipal()
    {
        return principal;
    }
    
    //----------------------------------
    //  source
    //----------------------------------
    
    public AuthenticationService getSource()
    {
        return AuthenticationService.class.cast(super.getSource());
    }
    
    //----------------------------------
    //  username
    //----------------------------------
    
    private String username;
    
    /**
     * Returns the username for authentication, null for logout events.
     * 
     * @return The username for authentication, null for logout events.
     */
    public String getUsername()
    {
        return username;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy