001/*
002 * Stallion Core: A Modern Web Framework
003 *
004 * Copyright (C) 2015 - 2016 Stallion Software LLC.
005 *
006 * This program is free software: you can redistribute it and/or modify it under the terms of the
007 * GNU General Public License as published by the Free Software Foundation, either version 2 of
008 * the License, or (at your option) any later version. This program is distributed in the hope that
009 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
011 * License for more details. You should have received a copy of the GNU General Public License
012 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
013 *
014 *
015 *
016 */
017
018package io.stallion.settings.childSections;
019
020import io.stallion.settings.SettingMeta;
021import io.stallion.users.OAuthClient;
022
023import java.util.ArrayList;
024import java.util.HashMap;
025import java.util.List;
026import java.util.Map;
027
028
029public class OAuthSettings implements SettingsSection {
030
031    @SettingMeta(valBoolean = false, help = "Is OAuth enabled for this application.")
032    private Boolean enabled;
033    @SettingMeta(valBoolean = false)
034    private Boolean requireHmac;
035    @SettingMeta(valBoolean = false)
036    private Boolean enableRefreshTokens;
037    @SettingMeta(valBoolean = false, help = "If true, any valid user can use the built-in API's to create an OAuth client application.")
038    private Boolean allowClientRegistration;
039    @SettingMeta(help = "A list of pre-defined OAuth clients.", cls=ArrayList.class)
040    private List<OAuthClient> clients;
041    @SettingMeta(valBoolean = true, help = "If true, check if an access token is valid on every single request. If false, an access token will be valid until it expires, or until the user's secret session key is reset (which will expire every single token and access token).")
042    private Boolean alwaysCheckAccessTokenValid;
043    @SettingMeta(valLong = 43200, help = "How long access tokens live for. If zero they live forever.")
044    private Long accessTokenValidSeconds;
045    @SettingMeta(valLong = 315360000000L, help = "How long refresh tokens live for. Default is forever.")
046    private Long refreshTokenValidSeconds;
047    @SettingMeta(help="A map of scope names to a short publicly readable description.", cls=HashMap.class)
048    private Map<String, String> scopeDescriptions;
049
050
051    public Boolean getEnabled() {
052        return enabled;
053    }
054
055    public OAuthSettings setEnabled(Boolean enabled) {
056        this.enabled = enabled;
057        return this;
058    }
059
060    public Boolean getRequireHmac() {
061        return requireHmac;
062    }
063
064    public OAuthSettings setRequireHmac(Boolean requireHmac) {
065        this.requireHmac = requireHmac;
066        return this;
067    }
068
069    public Boolean getAllowClientRegistration() {
070        return allowClientRegistration;
071    }
072
073    public OAuthSettings setAllowClientRegistration(Boolean allowClientRegistration) {
074        this.allowClientRegistration = allowClientRegistration;
075        return this;
076    }
077
078    public List<OAuthClient> getClients() {
079        return clients;
080    }
081
082    public OAuthSettings setClients(List<OAuthClient> clients) {
083        this.clients = clients;
084        return this;
085    }
086
087    public Boolean getAlwaysCheckAccessTokenValid() {
088        return alwaysCheckAccessTokenValid;
089    }
090
091    public OAuthSettings setAlwaysCheckAccessTokenValid(Boolean alwaysCheckAccessTokenValid) {
092        this.alwaysCheckAccessTokenValid = alwaysCheckAccessTokenValid;
093        return this;
094    }
095
096    public Long getAccessTokenValidSeconds() {
097        return accessTokenValidSeconds;
098    }
099
100    public OAuthSettings setAccessTokenValidSeconds(Long accessTokenValidSeconds) {
101        this.accessTokenValidSeconds = accessTokenValidSeconds;
102        return this;
103    }
104
105    public Long getRefreshTokenValidSeconds() {
106        return refreshTokenValidSeconds;
107    }
108
109    public OAuthSettings setRefreshTokenValidSeconds(Long refreshTokenValidSeconds) {
110        this.refreshTokenValidSeconds = refreshTokenValidSeconds;
111        return this;
112    }
113
114    public Map<String, String> getScopeDescriptions() {
115        return scopeDescriptions;
116    }
117
118    public OAuthSettings setScopeDescriptions(Map<String, String> scopeDescriptions) {
119        this.scopeDescriptions = scopeDescriptions;
120        return this;
121    }
122}