001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2022 Michael N. Lipp
004 * 
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 * 
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.webconlet.oidclogin;
020
021import java.util.Locale;
022import org.jgrapes.core.Channel;
023import org.jgrapes.core.Components;
024import org.jgrapes.core.Event;
025
026/**
027 * The Class StartOidcLogin.
028 */
029public class StartOidcLogin extends Event<Void> {
030
031    private final OidcProviderData provider;
032    private final Locale[] locales;
033
034    /**
035     * Instantiates a new event.
036     *
037     * @param provider the provider
038     * @param locales the UI locales by preference
039     */
040    @SuppressWarnings("PMD.ArrayIsStoredDirectly")
041    public StartOidcLogin(OidcProviderData provider, Locale... locales) {
042        this.provider = provider;
043        this.locales = locales;
044    }
045
046    /**
047     * Gets the provider.
048     *
049     * @return the provider
050     */
051    public OidcProviderData provider() {
052        return provider;
053    }
054
055    /**
056     * Gets the locales.
057     *
058     * @return the locales
059     */
060    @SuppressWarnings("PMD.MethodReturnsInternalArray")
061    public Locale[] locales() {
062        return locales;
063    }
064
065    /*
066     * (non-Javadoc)
067     * 
068     * @see java.lang.Object#toString()
069     */
070    @Override
071    public String toString() {
072        StringBuilder builder = new StringBuilder(30);
073        builder.append(Components.objectName(this)).append(" [provider=")
074            .append(provider.name());
075        if (channels() != null) {
076            builder.append(", channels=").append(Channel.toString(channels()));
077        }
078        builder.append(']');
079        return builder.toString();
080    }
081}