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.users; 019 020import io.stallion.dataAccess.AlternativeKey; 021import io.stallion.dataAccess.ModelBase; 022import io.stallion.dataAccess.UniqueKey; 023import io.stallion.dataAccess.db.Converter; 024 025import javax.persistence.Column; 026 027import java.util.HashSet; 028import java.util.Set; 029 030 031public class OAuthApproval extends ModelBase { 032 private long accessTokenExpiresAt = 0; 033 private long refreshTokenExpiresAt = 0; 034 private String refreshToken; 035 private String accessToken; 036 private long createdAt = 0; 037 private String code; 038 private boolean verified = false; 039 private long userId = 0; 040 private String clientId = ""; 041 private Set<String> scopes = new HashSet(); 042 private boolean scoped = false; 043 private String internalSecret = ""; 044 private boolean revoked = false; 045 046 047 @Column 048 public long getAccessTokenExpiresAt() { 049 return accessTokenExpiresAt; 050 } 051 052 public OAuthApproval setAccessTokenExpiresAt(long accessTokenExpiresAt) { 053 this.accessTokenExpiresAt = accessTokenExpiresAt; 054 return this; 055 } 056 057 @Column 058 public long getRefreshTokenExpiresAt() { 059 return refreshTokenExpiresAt; 060 } 061 062 public OAuthApproval setRefreshTokenExpiresAt(long refreshTokenExpiresAt) { 063 this.refreshTokenExpiresAt = refreshTokenExpiresAt; 064 return this; 065 } 066 067 @Column 068 @UniqueKey 069 public String getRefreshToken() { 070 return refreshToken; 071 } 072 073 public OAuthApproval setRefreshToken(String refreshToken) { 074 this.refreshToken = refreshToken; 075 return this; 076 } 077 078 @Column 079 @UniqueKey 080 public String getAccessToken() { 081 return accessToken; 082 } 083 084 public OAuthApproval setAccessToken(String accessToken) { 085 this.accessToken = accessToken; 086 return this; 087 } 088 089 @Column 090 public long getCreatedAt() { 091 return createdAt; 092 } 093 094 public OAuthApproval setCreatedAt(long createdAt) { 095 this.createdAt = createdAt; 096 return this; 097 } 098 099 @Column 100 @UniqueKey 101 public String getCode() { 102 return code; 103 } 104 105 public OAuthApproval setCode(String code) { 106 this.code = code; 107 return this; 108 } 109 110 @Column 111 public boolean isVerified() { 112 return verified; 113 } 114 115 public OAuthApproval setVerified(boolean verified) { 116 this.verified = verified; 117 return this; 118 } 119 120 @Column 121 @AlternativeKey 122 public long getUserId() { 123 return userId; 124 } 125 126 public OAuthApproval setUserId(long userId) { 127 this.userId = userId; 128 return this; 129 } 130 131 132 public String getClientId() { 133 return clientId; 134 } 135 136 public OAuthApproval setClientId(String clientId) { 137 this.clientId = clientId; 138 return this; 139 } 140 141 @Override 142 public String getBucket() { 143 return "oauth_approvals"; 144 } 145 146 @Column 147 @Converter(name="io.stallion.dataAccess.db.converters.JsonSetConverter") 148 public Set<String> getScopes() { 149 return scopes; 150 } 151 152 public OAuthApproval setScopes(Set<String> scopes) { 153 this.scopes = scopes; 154 return this; 155 } 156 157 public String getInternalSecret() { 158 return internalSecret; 159 } 160 161 public OAuthApproval setInternalSecret(String internalSecret) { 162 this.internalSecret = internalSecret; 163 return this; 164 } 165 166 public boolean isRevoked() { 167 return revoked; 168 } 169 170 public OAuthApproval setRevoked(boolean revoked) { 171 this.revoked = revoked; 172 return this; 173 } 174 175 public boolean isScoped() { 176 return scoped; 177 } 178 179 public OAuthApproval setScoped(boolean scoped) { 180 this.scoped = scoped; 181 return this; 182 } 183}