Skip to content

Commit d590d23

Browse files
author
Johannes Hiemer
committed
chore(): code cleanup
1 parent 02895a1 commit d590d23

21 files changed

Lines changed: 43 additions & 200 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package io.bosh.client;
22

33
/**
4-
* Created by jannikheyl on 09.02.18.
4+
* @author Jannik Heyl.
55
*/
66
public enum Authentication {
7-
BASIC,OAUTH
7+
BASIC, OAUTH;
88
}

src/main/java/io/bosh/client/OAuthCredentialsProvider.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,24 @@
2222
import java.util.Arrays;
2323

2424
/**
25-
* Created by jannikheyl on 09.02.18.
25+
* @author Jannik Heyl.
2626
*/
2727
public class OAuthCredentialsProvider implements Header {
28+
2829
private OAuth2AccessToken token;
30+
2931
private AccessTokenProviderChain CHAIN = new AccessTokenProviderChain(
30-
Arrays.<AccessTokenProvider> asList(new UnsecureClientCredentialsAccessTokenProvider()));
32+
Arrays.asList(new UnsecureClientCredentialsAccessTokenProvider()));
33+
3134
private ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
3235

3336

34-
public OAuthCredentialsProvider(String host, String username,
35-
String password){
37+
public OAuthCredentialsProvider(String host, String username, String password){
3638
host="https://" + host + ":8443/oauth/token";
3739
getCredentials(host, username, password);
3840
requestToken();
3941
}
42+
4043
private void requestToken(){
4144

4245
if (token == null) {
@@ -47,11 +50,13 @@ else if (token.isExpired()) {
4750
}
4851

4952
}
53+
5054
private void refreshAccessToken() {
5155
Assert.notNull(token);
5256

5357
token = CHAIN.refreshAccessToken(credentials, token.getRefreshToken(), new DefaultAccessTokenRequest());
5458
}
59+
5560
private ClientCredentialsResourceDetails getCredentials(String host, String username,
5661
String password){
5762
credentials.setAccessTokenUri(host);

src/main/java/io/bosh/client/RequestLoggingInterceptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
import java.nio.charset.Charset;
1111

1212
/**
13-
* Created by jannikheyl on 12.02.18.
13+
* @author Jannik Heyl.
1414
*/
1515
public class RequestLoggingInterceptor implements ClientHttpRequestInterceptor {
16+
1617
private final static org.slf4j.Logger log = LoggerFactory.getLogger(RequestLoggingInterceptor.class);
1718

1819
@Override
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.bosh.client;
22

3+
/**
4+
* @author Jannik Heyl.
5+
*/
36
public enum Scheme {
47
https, http
58
}

src/main/java/io/bosh/client/SpringDirectorClient.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
* Copyright 2015 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package io.bosh.client;
172

183
import io.bosh.client.deployments.Deployments;
@@ -37,7 +22,7 @@
3722
import org.springframework.web.client.RestTemplate;
3823

3924
/**
40-
* @author David Ehringer
25+
* @author David Ehringer, Jannik Heyl.
4126
*/
4227
public class SpringDirectorClient implements DirectorClient {
4328

src/main/java/io/bosh/client/SpringDirectorClientBuilder.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
* Copyright 2015 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
161
package io.bosh.client;
172

183
import static org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.DEFAULT_CHARSET;
@@ -29,6 +14,10 @@
2914

3015
import javax.net.ssl.SSLContext;
3116

17+
import io.bosh.client.Authentication;
18+
import io.bosh.client.DirectorException;
19+
import io.bosh.client.RequestLoggingInterceptor;
20+
import io.bosh.client.SpringDirectorClient;
3221
import org.apache.http.Header;
3322
import org.apache.http.auth.AuthScope;
3423
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -57,7 +46,7 @@
5746
import org.springframework.security.oauth2.common.*;
5847

5948
/**
60-
* @author David Ehringer
49+
* @author David Ehringer, Jannik Heyl.
6150
*/
6251
public class SpringDirectorClientBuilder {
6352

src/main/java/io/bosh/client/UnsecureClientCredentialsAccessTokenProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
import java.security.cert.X509Certificate;
1919

2020
/**
21-
* Created by jannikheyl on 12.02.18.
21+
* @author Jannik Heyl.
2222
*/
2323
public class UnsecureClientCredentialsAccessTokenProvider extends ClientCredentialsAccessTokenProvider {
24+
2425
@Override
2526
protected RestOperations getRestTemplate(){
2627
RestTemplate restOperations = (RestTemplate) super.getRestTemplate();

src/main/java/io/bosh/client/authentication/Authentication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.bosh.client.authentication;
22

33
/**
4-
* Created by jannikheyl on 09.02.18.
4+
* @author Jannik Heyl.
55
*/
66
public interface Authentication {
77

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.bosh.client.authentication;
22

3+
/**
4+
* @author Jannik Heyl.
5+
*/
36
public class BasicAuth implements Authentication {
47

58
}

src/main/java/io/bosh/client/authentication/OAuth.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.bosh.client.authentication;
22

3+
/**
4+
* @author Jannik Heyl.
5+
*/
36
public class OAuth implements Authentication {
47

58
private boolean strictHostKeyChecking;

0 commit comments

Comments
 (0)