001package com.box.sdkgen.box.oauth; 002 003import com.box.sdkgen.box.tokenstorage.InMemoryTokenStorage; 004import com.box.sdkgen.box.tokenstorage.TokenStorage; 005 006public class OAuthConfig { 007 008 public final String clientId; 009 010 public final String clientSecret; 011 012 public TokenStorage tokenStorage; 013 014 public OAuthConfig(String clientId, String clientSecret) { 015 this.clientId = clientId; 016 this.clientSecret = clientSecret; 017 this.tokenStorage = new InMemoryTokenStorage(); 018 } 019 020 protected OAuthConfig(Builder builder) { 021 this.clientId = builder.clientId; 022 this.clientSecret = builder.clientSecret; 023 this.tokenStorage = builder.tokenStorage; 024 } 025 026 public String getClientId() { 027 return clientId; 028 } 029 030 public String getClientSecret() { 031 return clientSecret; 032 } 033 034 public TokenStorage getTokenStorage() { 035 return tokenStorage; 036 } 037 038 public static class Builder { 039 040 protected final String clientId; 041 042 protected final String clientSecret; 043 044 protected TokenStorage tokenStorage; 045 046 public Builder(String clientId, String clientSecret) { 047 this.clientId = clientId; 048 this.clientSecret = clientSecret; 049 } 050 051 public Builder tokenStorage(TokenStorage tokenStorage) { 052 this.tokenStorage = tokenStorage; 053 return this; 054 } 055 056 public OAuthConfig build() { 057 if (this.tokenStorage == null) { 058 this.tokenStorage = new InMemoryTokenStorage(); 059 } 060 return new OAuthConfig(this); 061 } 062 } 063}