001/*
002 * Syncany, www.syncany.org
003 * Copyright (C) 2011-2016 Philipp C. Heckel <philipp.heckel@gmail.com>
004 *
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU 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,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU General Public License for more details.
014 *
015 * You should have received a copy of the GNU General Public License
016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
017 */
018package org.syncany.plugins.transfer.oauth;
019
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Retention;
022import java.lang.annotation.RetentionPolicy;
023import java.lang.annotation.Target;
024
025import org.syncany.plugins.transfer.TransferSettings;
026
027/**
028 * This annotation is used to identify OAuth plugins by marking the corresponding
029 * {@link TransferSettings} class. An OAuth plugin will provide a 'token' field
030 * during the initialization process and the {@link OAuthGenerator} (provided via the
031 * help of the {@link #value()} field) will be able to check that token.
032 *
033 * @author Philipp Heckel (philipp.heckel@gmail.com)
034 * @author Christian Roth (christian.roth@port17.de)
035 */
036@Target(ElementType.TYPE)
037@Retention(RetentionPolicy.RUNTIME)
038public @interface OAuth {
039        String PLUGIN_ID = "%pluginid%";
040        int RANDOM_PORT = -1;
041
042        /**
043         * @see OAuthGenerator
044         */
045        Class<? extends OAuthGenerator> value();
046
047        /**
048         * The default Mode is {@link OAuthMode#SERVER}
049         *
050         * @see OAuthMode
051         */
052        OAuthMode mode() default OAuthMode.SERVER;
053
054        /**
055         * If no specific port is provided (or {@value #RANDOM_PORT} is used), the {@link OAuthTokenWebListener} will choose a
056         * random port from the range of {@value OAuthTokenWebListener#PORT_LOWER} and
057         * {@value OAuthTokenWebListener#PORT_UPPER}.<br>
058         * Needed if an OAuth provider uses preset and strict redirect URLs.
059         */
060        int callbackPort() default RANDOM_PORT; // -1 is random
061
062        /**
063         * If no specific name is provided (or {@value #PLUGIN_ID} is used), the {@link OAuthTokenWebListener} will choose a
064         * random identifier for the OAuth process.<br>
065         * Needed if an OAuth provider uses preset and strict redirect URLs.
066         */
067        String callbackId() default PLUGIN_ID; // equals plugin id
068}