Skip to content

Commit

Permalink
chore(): code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Hiemer committed Feb 22, 2019
1 parent 02895a1 commit d590d23
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 200 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/bosh/client/Authentication.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.bosh.client;

/**
* Created by jannikheyl on 09.02.18.
* @author Jannik Heyl.
*/
public enum Authentication {
BASIC,OAUTH
BASIC, OAUTH;
}
13 changes: 9 additions & 4 deletions src/main/java/io/bosh/client/OAuthCredentialsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@
import java.util.Arrays;

/**
* Created by jannikheyl on 09.02.18.
* @author Jannik Heyl.
*/
public class OAuthCredentialsProvider implements Header {

private OAuth2AccessToken token;

private AccessTokenProviderChain CHAIN = new AccessTokenProviderChain(
Arrays.<AccessTokenProvider> asList(new UnsecureClientCredentialsAccessTokenProvider()));
Arrays.asList(new UnsecureClientCredentialsAccessTokenProvider()));

private ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();


public OAuthCredentialsProvider(String host, String username,
String password){
public OAuthCredentialsProvider(String host, String username, String password){
host="https://" + host + ":8443/oauth/token";
getCredentials(host, username, password);
requestToken();
}

private void requestToken(){

if (token == null) {
Expand All @@ -47,11 +50,13 @@ else if (token.isExpired()) {
}

}

private void refreshAccessToken() {
Assert.notNull(token);

token = CHAIN.refreshAccessToken(credentials, token.getRefreshToken(), new DefaultAccessTokenRequest());
}

private ClientCredentialsResourceDetails getCredentials(String host, String username,
String password){
credentials.setAccessTokenUri(host);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/bosh/client/RequestLoggingInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import java.nio.charset.Charset;

/**
* Created by jannikheyl on 12.02.18.
* @author Jannik Heyl.
*/
public class RequestLoggingInterceptor implements ClientHttpRequestInterceptor {

private final static org.slf4j.Logger log = LoggerFactory.getLogger(RequestLoggingInterceptor.class);

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/bosh/client/Scheme.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.bosh.client;

/**
* @author Jannik Heyl.
*/
public enum Scheme {
https, http
}
17 changes: 1 addition & 16 deletions src/main/java/io/bosh/client/SpringDirectorClient.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client;

import io.bosh.client.deployments.Deployments;
Expand All @@ -37,7 +22,7 @@
import org.springframework.web.client.RestTemplate;

/**
* @author David Ehringer
* @author David Ehringer, Jannik Heyl.
*/
public class SpringDirectorClient implements DirectorClient {

Expand Down
21 changes: 5 additions & 16 deletions src/main/java/io/bosh/client/SpringDirectorClientBuilder.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client;

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

import javax.net.ssl.SSLContext;

import io.bosh.client.Authentication;
import io.bosh.client.DirectorException;
import io.bosh.client.RequestLoggingInterceptor;
import io.bosh.client.SpringDirectorClient;
import org.apache.http.Header;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
Expand Down Expand Up @@ -57,7 +46,7 @@
import org.springframework.security.oauth2.common.*;

/**
* @author David Ehringer
* @author David Ehringer, Jannik Heyl.
*/
public class SpringDirectorClientBuilder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import java.security.cert.X509Certificate;

/**
* Created by jannikheyl on 12.02.18.
* @author Jannik Heyl.
*/
public class UnsecureClientCredentialsAccessTokenProvider extends ClientCredentialsAccessTokenProvider {

@Override
protected RestOperations getRestTemplate(){
RestTemplate restOperations = (RestTemplate) super.getRestTemplate();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.bosh.client.authentication;

/**
* Created by jannikheyl on 09.02.18.
* @author Jannik Heyl.
*/
public interface Authentication {

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/bosh/client/authentication/BasicAuth.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.bosh.client.authentication;

/**
* @author Jannik Heyl.
*/
public class BasicAuth implements Authentication {

}
3 changes: 3 additions & 0 deletions src/main/java/io/bosh/client/authentication/OAuth.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.bosh.client.authentication;

/**
* @author Jannik Heyl.
*/
public class OAuth implements Authentication {

private boolean strictHostKeyChecking;
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/io/bosh/client/deployments/Deployment.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.deployments;

import java.util.Collections;
Expand All @@ -23,13 +8,15 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author David Ehringer
* @author David Ehringer, Jannik Heyl.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Deployment {

private String name;

private String manifest;

private Map<String, Object> manifestMap = new HashMap<String, Object>();

public void setName(String name) {
Expand Down
17 changes: 1 addition & 16 deletions src/main/java/io/bosh/client/deployments/Deployments.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.deployments;

import io.bosh.client.tasks.Task;
Expand All @@ -22,7 +7,7 @@
import java.util.List;

/**
* @author David Ehringer
* @author David Ehringer, Jannik Heyl.
*/
public interface Deployments {

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/bosh/client/deployments/SSHConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author Johannes Hiemer.
*/
public class SSHConfig {

public SSHConfig(String deploymentName, String username, String publicKey, String jobTarget, int indexes) {
Expand Down
19 changes: 1 addition & 18 deletions src/main/java/io/bosh/client/deployments/SpringDeployments.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.deployments;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -41,7 +26,7 @@
import java.util.function.Consumer;

/**
* @author David Ehringer
* @author David Ehringer, Jannik Heyl, Johannes Hiemer.
*/
public class SpringDeployments extends AbstractSpringOperations implements Deployments {

Expand Down Expand Up @@ -117,6 +102,4 @@ public Observable<List<Problem>> cloudcheck(String deploymentName) {
.map(problems -> Arrays.asList(problems));
}



}
17 changes: 1 addition & 16 deletions src/main/java/io/bosh/client/errands/Errands.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.errands;

import java.util.List;
Expand All @@ -21,7 +6,7 @@
import rx.Observable;

/**
* @author David Ehringer
* @author David Ehringer, Yannic Remmet.
*/
public interface Errands {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.internal;

import io.bosh.client.DirectorException;
Expand All @@ -34,7 +19,7 @@
import java.util.regex.Pattern;

/**
* @author David Ehringer
* @author David Ehringer, Yannic Remmet.
*/
public abstract class AbstractSpringOperations {

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/io/bosh/client/vms/SpringVms.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.vms;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
17 changes: 1 addition & 16 deletions src/main/java/io/bosh/client/vms/Vm.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.bosh.client.vms;

import java.util.ArrayList;
Expand All @@ -22,7 +7,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author David Ehringer
* @author David Ehringer, Yannic Remmet.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Vm {
Expand Down
Loading

0 comments on commit d590d23

Please sign in to comment.