001package com.box.sdkgen.box.ccgauth; 002 003import com.box.sdkgen.box.tokenstorage.InMemoryTokenStorage; 004import com.box.sdkgen.box.tokenstorage.TokenStorage; 005 006public class CCGConfig { 007 008 /** Box API key used for identifying the application the user is authenticating with */ 009 public final String clientId; 010 011 /** Box API secret used for making auth requests. */ 012 public final String clientSecret; 013 014 /** The ID of the Box Developer Edition enterprise. */ 015 public String enterpriseId; 016 017 /** 018 * The user id to authenticate. This value is not required. But if it is provided, then the user 019 * will be auto-authenticated at the time of the first API call. 020 */ 021 public String userId; 022 023 /** 024 * Object responsible for storing token. If no custom implementation provided,the token will be 025 * stored in memory. 026 */ 027 public TokenStorage tokenStorage; 028 029 public CCGConfig(String clientId, String clientSecret) { 030 this.clientId = clientId; 031 this.clientSecret = clientSecret; 032 this.tokenStorage = new InMemoryTokenStorage(); 033 } 034 035 protected CCGConfig(Builder builder) { 036 this.clientId = builder.clientId; 037 this.clientSecret = builder.clientSecret; 038 this.enterpriseId = builder.enterpriseId; 039 this.userId = builder.userId; 040 this.tokenStorage = builder.tokenStorage; 041 } 042 043 public String getClientId() { 044 return clientId; 045 } 046 047 public String getClientSecret() { 048 return clientSecret; 049 } 050 051 public String getEnterpriseId() { 052 return enterpriseId; 053 } 054 055 public String getUserId() { 056 return userId; 057 } 058 059 public TokenStorage getTokenStorage() { 060 return tokenStorage; 061 } 062 063 public static class Builder { 064 065 protected final String clientId; 066 067 protected final String clientSecret; 068 069 protected String enterpriseId; 070 071 protected String userId; 072 073 protected TokenStorage tokenStorage; 074 075 public Builder(String clientId, String clientSecret) { 076 this.clientId = clientId; 077 this.clientSecret = clientSecret; 078 } 079 080 public Builder enterpriseId(String enterpriseId) { 081 this.enterpriseId = enterpriseId; 082 return this; 083 } 084 085 public Builder userId(String userId) { 086 this.userId = userId; 087 return this; 088 } 089 090 public Builder tokenStorage(TokenStorage tokenStorage) { 091 this.tokenStorage = tokenStorage; 092 return this; 093 } 094 095 public CCGConfig build() { 096 if (this.tokenStorage == null) { 097 this.tokenStorage = new InMemoryTokenStorage(); 098 } 099 return new CCGConfig(this); 100 } 101 } 102}