View Javadoc
1   /*
2    * Copyright (C) 2015, Matthias Sohn <matthias.sohn@sap.com>
3    * Copyright (C) 2015, Sasa Zivkov <sasa.zivkov@sap.com> and others
4    *
5    * This program and the accompanying materials are made available under the
6    * terms of the Eclipse Distribution License v. 1.0 which is available at
7    * https://www.eclipse.org/org/documents/edl-v10.php.
8    *
9    * SPDX-License-Identifier: BSD-3-Clause
10   */
11  package org.eclipse.jgit.lfs.server.s3;
12  
13  /**
14   * Configuration for an Amazon AWS S3 bucket
15   *
16   * @since 4.3
17   */
18  public class S3Config {
19  	private final String hostname;
20  	private final String region;
21  	private final String bucket;
22  	private final String storageClass;
23  	private final String accessKey;
24  	private final String secretKey;
25  	private final int expirationSeconds;
26  	private final boolean disableSslVerify;
27  
28  	/**
29  	 * <p>
30  	 * Constructor for S3Config.
31  	 * </p>
32  	 *
33  	 * @param hostname
34  	 *            S3 API host
35  	 * @param region
36  	 *            AWS region
37  	 * @param bucket
38  	 *            S3 storage bucket
39  	 * @param storageClass
40  	 *            S3 storage class
41  	 * @param accessKey
42  	 *            access key for authenticating to AWS
43  	 * @param secretKey
44  	 *            secret key for authenticating to AWS
45  	 * @param expirationSeconds
46  	 *            period in seconds after which requests signed for this bucket
47  	 *            will expire
48  	 * @param disableSslVerify
49  	 *            if {@code true} disable Amazon server certificate and hostname
50  	 *            verification
51  	 * @since 5.8
52  	 */
53  	public S3Config(String hostname, String region, String bucket, String storageClass,
54  			String accessKey, String secretKey, int expirationSeconds,
55  			boolean disableSslVerify) {
56  		this.hostname = hostname;
57  		this.region = region;
58  		this.bucket = bucket;
59  		this.storageClass = storageClass;
60  		this.accessKey = accessKey;
61  		this.secretKey = secretKey;
62  		this.expirationSeconds = expirationSeconds;
63  		this.disableSslVerify = disableSslVerify;
64  	}
65  
66  	/**
67  	 * <p>Constructor for S3Config.</p>
68  	 *
69  	 * @param region
70  	 *            AWS region
71  	 * @param bucket
72  	 *            S3 storage bucket
73  	 * @param storageClass
74  	 *            S3 storage class
75  	 * @param accessKey
76  	 *            access key for authenticating to AWS
77  	 * @param secretKey
78  	 *            secret key for authenticating to AWS
79  	 * @param expirationSeconds
80  	 *            period in seconds after which requests signed for this bucket
81  	 *            will expire
82  	 * @param disableSslVerify
83  	 *            if {@code true} disable Amazon server certificate and hostname
84  	 *            verification
85  	 */
86  	public S3Config(String region, String bucket, String storageClass,
87  			String accessKey, String secretKey, int expirationSeconds,
88  			boolean disableSslVerify) {
89  		this(String.format("s3-%s.amazonaws.com", region), region, bucket, //$NON-NLS-1$
90  				storageClass, accessKey, secretKey, expirationSeconds,
91  				disableSslVerify);
92  	}
93  
94  	/**
95  	 * Get the <code>hostname</code>.
96  	 *
97  	 * @return Get the S3 API host
98  	 * @since 5.8
99  	 */
100 	public String getHostname() {
101 		return hostname;
102 	}
103 
104 	/**
105 	 * Get the <code>region</code>.
106 	 *
107 	 * @return Get name of AWS region this bucket resides in
108 	 */
109 	public String getRegion() {
110 		return region;
111 	}
112 
113 	/**
114 	 * Get the <code>bucket</code>.
115 	 *
116 	 * @return Get S3 storage bucket name
117 	 */
118 	public String getBucket() {
119 		return bucket;
120 	}
121 
122 	/**
123 	 * Get the <code>storageClass</code>.
124 	 *
125 	 * @return S3 storage class to use for objects stored in this bucket
126 	 */
127 	public String getStorageClass() {
128 		return storageClass;
129 	}
130 
131 	/**
132 	 * Get the <code>accessKey</code>.
133 	 *
134 	 * @return access key for authenticating to AWS
135 	 */
136 	public String getAccessKey() {
137 		return accessKey;
138 	}
139 
140 	/**
141 	 * Get the <code>secretKey</code>.
142 	 *
143 	 * @return secret key for authenticating to AWS
144 	 */
145 	public String getSecretKey() {
146 		return secretKey;
147 	}
148 
149 	/**
150 	 * Get the <code>expirationSeconds</code>.
151 	 *
152 	 * @return period in seconds after which requests signed for this bucket
153 	 *         will expire
154 	 */
155 	public int getExpirationSeconds() {
156 		return expirationSeconds;
157 	}
158 
159 	/**
160 	 * @return {@code true} if Amazon server certificate and hostname
161 	 *         verification is disabled
162 	 */
163 	boolean isDisableSslVerify() {
164 		return disableSslVerify;
165 	}
166 
167 }