001package com.box.sdk; 002 003/** 004 * This API connection uses a shared link (along with an optional password) to authenticate with the 005 * Box API. It wraps a preexisting BoxAPIConnection in order to provide additional access to items 006 * that are accessible with a shared link. 007 * 008 * @deprecated Use {@link BoxItem#getSharedItem(BoxAPIConnection, String, String, String...)} 009 * instead 010 */ 011public class SharedLinkAPIConnection extends BoxAPIConnection { 012 private final BoxAPIConnection wrappedConnection; 013 private final String sharedLink; 014 private final String sharedLinkPassword; 015 016 public SharedLinkAPIConnection(BoxAPIConnection connection, String sharedLink) { 017 this(connection, sharedLink, null); 018 } 019 020 public SharedLinkAPIConnection( 021 BoxAPIConnection connection, String sharedLink, String sharedLinkPassword) { 022 // this is a hack to maintain backward compatibility and to prevent confusing the compiler 023 // between two possible BoxApiConnection constructors for super(null) 024 super(""); 025 026 this.wrappedConnection = connection; 027 this.sharedLink = sharedLink; 028 this.sharedLinkPassword = sharedLinkPassword; 029 } 030 031 @Override 032 public long getExpires() { 033 return this.wrappedConnection.getExpires(); 034 } 035 036 @Override 037 public void setExpires(long milliseconds) { 038 this.wrappedConnection.setExpires(milliseconds); 039 } 040 041 @Override 042 public String getBaseURL() { 043 return this.wrappedConnection.getBaseURL(); 044 } 045 046 @Override 047 public void setBaseURL(String baseURL) { 048 this.wrappedConnection.setBaseURL(baseURL); 049 } 050 051 @Override 052 public String getBaseUploadURL() { 053 return this.wrappedConnection.getBaseUploadURL(); 054 } 055 056 @Override 057 public void setBaseUploadURL(String baseUploadURL) { 058 this.wrappedConnection.setBaseUploadURL(baseUploadURL); 059 } 060 061 @Override 062 public String getUserAgent() { 063 return this.wrappedConnection.getUserAgent(); 064 } 065 066 @Override 067 public void setUserAgent(String userAgent) { 068 this.wrappedConnection.setUserAgent(userAgent); 069 } 070 071 @Override 072 public String getAccessToken() { 073 return this.wrappedConnection.getAccessToken(); 074 } 075 076 @Override 077 public void setAccessToken(String accessToken) { 078 this.wrappedConnection.setAccessToken(accessToken); 079 } 080 081 @Override 082 public String getRefreshToken() { 083 return this.wrappedConnection.getRefreshToken(); 084 } 085 086 @Override 087 public void setRefreshToken(String refreshToken) { 088 this.wrappedConnection.setRefreshToken(refreshToken); 089 } 090 091 @Override 092 public boolean getAutoRefresh() { 093 return this.wrappedConnection.getAutoRefresh(); 094 } 095 096 @Override 097 public void setAutoRefresh(boolean autoRefresh) { 098 this.wrappedConnection.setAutoRefresh(autoRefresh); 099 } 100 101 /** 102 * Gets the maximum number of times an API request will be retried after an error response is 103 * received. 104 * 105 * @return the maximum number of request attempts. 106 */ 107 @Override 108 public int getMaxRetryAttempts() { 109 return this.wrappedConnection.getMaxRetryAttempts(); 110 } 111 112 /** 113 * Sets the maximum number of times an API request will be retried after an error response is 114 * received. 115 * 116 * @param attempts the maximum number of request attempts. 117 */ 118 @Override 119 public void setMaxRetryAttempts(int attempts) { 120 this.wrappedConnection.setMaxRetryAttempts(attempts); 121 } 122 123 @Override 124 public boolean canRefresh() { 125 return this.wrappedConnection.canRefresh(); 126 } 127 128 @Override 129 public boolean needsRefresh() { 130 return this.wrappedConnection.needsRefresh(); 131 } 132 133 @Override 134 public void refresh() { 135 this.wrappedConnection.refresh(); 136 } 137 138 @Override 139 String lockAccessToken() { 140 return this.wrappedConnection.lockAccessToken(); 141 } 142 143 @Override 144 void unlockAccessToken() { 145 this.wrappedConnection.unlockAccessToken(); 146 } 147 148 @Override 149 public RequestInterceptor getRequestInterceptor() { 150 return this.wrappedConnection.getRequestInterceptor(); 151 } 152 153 /** 154 * Gets the shared link used for accessing shared items. 155 * 156 * @return the shared link used for accessing shared items. 157 */ 158 String getSharedLink() { 159 return this.sharedLink; 160 } 161 162 /** 163 * Gets the shared link password used for accessing shared items. 164 * 165 * @return the shared link password used for accessing shared items. 166 */ 167 String getSharedLinkPassword() { 168 return this.sharedLinkPassword; 169 } 170}