001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *      Nelson Silva
018 */
019package org.nuxeo.ecm.platform.oauth2.providers;
020
021import org.nuxeo.common.xmap.annotation.XNode;
022import org.nuxeo.common.xmap.annotation.XNodeList;
023import org.nuxeo.common.xmap.annotation.XObject;
024
025/**
026 * @since 7.3
027 */
028@XObject("provider")
029public class OAuth2ServiceProviderDescriptor {
030
031    public static final String DEFAULT_ACCESS_TOKEN_KEY = "access_token";
032
033    public static final Class<? extends OAuth2ServiceProvider> DEFAULT_PROVIDER_CLASS = NuxeoOAuth2ServiceProvider.class;
034
035    @XNode("@enabled")
036    protected boolean enabled = true;
037
038    @XNode("name")
039    protected String name;
040
041    @XNode("tokenServerURL")
042    protected String tokenServerURL;
043
044    @XNode("authorizationServerURL")
045    protected String authorizationServerURL;
046
047    @XNode("userInfoURL")
048    protected String userInfoURL;
049
050    @XNode("accessTokenKey")
051    protected String accessTokenKey = DEFAULT_ACCESS_TOKEN_KEY;
052
053    @XNode("clientId")
054    protected String clientId;
055
056    @XNode("clientSecret")
057    protected String clientSecret;
058
059    @XNodeList(value = "scope", type = String[].class, componentType = String.class)
060    protected String[] scopes;
061
062    @XNode("icon")
063    protected String icon;
064
065    @XNode("label")
066    protected String label;
067
068    @XNode("description")
069    protected String description;
070
071    @XNode("class")
072    protected Class<? extends OAuth2ServiceProvider> providerClass = DEFAULT_PROVIDER_CLASS;
073
074    public String getName() {
075        return name;
076    }
077
078    public String getTokenServerURL() {
079        return tokenServerURL;
080    }
081
082    public String getAuthorizationServerURL() {
083        return authorizationServerURL;
084    }
085
086    public String getClientId() {
087        return clientId;
088    }
089
090    public String getClientSecret() {
091        return clientSecret;
092    }
093
094    public String[] getScopes() {
095        return scopes;
096    }
097
098    public String getIcon() {
099        return icon;
100    }
101
102    public boolean isEnabled() {
103        return enabled;
104    }
105
106    public void setEnabled(boolean enabled) {
107        this.enabled = enabled;
108    }
109
110    public String getLabel() {
111        return label;
112    }
113
114    public String getDescription() {
115        return description;
116    }
117
118    public Class<? extends OAuth2ServiceProvider> getProviderClass() {
119        return providerClass;
120    }
121}