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