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
025import java.io.Serializable;
026
027/**
028 * @since 7.3
029 */
030@XObject("provider")
031public class OAuth2ServiceProviderDescriptor implements Serializable {
032    protected static final long serialVersionUID = 1L;
033
034    public static final String DEFAULT_ACCESS_TOKEN_KEY = "access_token";
035
036    public static final Class<? extends OAuth2ServiceProvider> DEFAULT_PROVIDER_CLASS = NuxeoOAuth2ServiceProvider.class;
037
038    @XNode("@enabled")
039    protected boolean enabled = true;
040
041    @XNode("name")
042    protected String name;
043
044    @XNode("tokenServerURL")
045    protected String tokenServerURL;
046
047    @XNode("authorizationServerURL")
048    protected String authorizationServerURL;
049
050    @XNode("userInfoURL")
051    protected String userInfoURL;
052
053    @XNode("accessTokenKey")
054    protected String accessTokenKey = DEFAULT_ACCESS_TOKEN_KEY;
055
056    @XNode("clientId")
057    protected String clientId;
058
059    @XNode("clientSecret")
060    protected String clientSecret;
061
062    @XNodeList(value = "scope", type = String[].class, componentType = String.class)
063    protected String[] scopes;
064
065    @XNode("icon")
066    protected String icon;
067
068    @XNode("label")
069    protected String label;
070
071    @XNode("description")
072    protected String description;
073
074    @XNode("class")
075    protected Class<? extends OAuth2ServiceProvider> providerClass = DEFAULT_PROVIDER_CLASS;
076
077    public static long getSerialversionuid() {
078        return serialVersionUID;
079    }
080
081    public String getName() {
082        return name;
083    }
084
085    public String getTokenServerURL() {
086        return tokenServerURL;
087    }
088
089    public String getAuthorizationServerURL() {
090        return authorizationServerURL;
091    }
092
093    public String getClientId() {
094        return clientId;
095    }
096
097    public String getClientSecret() {
098        return clientSecret;
099    }
100
101    public String[] getScopes() {
102        return scopes;
103    }
104
105    public String getIcon() {
106        return icon;
107    }
108
109    public boolean isEnabled() {
110        return enabled;
111    }
112
113    public void setEnabled(boolean enabled) {
114        this.enabled = enabled;
115    }
116
117    public String getLabel() {
118        return label;
119    }
120
121    public String getDescription() {
122        return description;
123    }
124
125    public Class<? extends OAuth2ServiceProvider> getProviderClass() {
126        return providerClass;
127    }
128}