Skip to content

Commit

Permalink
fixes #1213 (#1257)
Browse files Browse the repository at this point in the history
* Add option to only supply http server and port

Signed-off-by: Fritz Otlinghaus <[email protected]>

* Fixes issue #1213

Signed-off-by: Fritz Otlinghaus <[email protected]>

Fixing docker build

* Fix license header and dockerfile

Signed-off-by: Fritz Otlinghaus <[email protected]>

* Add docker nightly builds

Signed-off-by: Fritz Otlinghaus <[email protected]>

* Fix codacy issues
  • Loading branch information
Fritz Otlinghaus authored and aedelmann committed Dec 11, 2018
1 parent cd2578b commit 61690b5
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 485 deletions.
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ script:
- remark -i .remark_ignore -f -u validate-links .
- remark -i .remark_ignore -u lint-no-dead-urls .
- mvn -q clean install -P checkstyle
- docker build -f repository/repository-server/Dockerfile -t eclipsevorto/vorto-repo:latest ./repository/repository-server;
- docker build -f generators/generator-runner/Dockerfile -t eclipsevorto/vorto-generators:latest ./generators/generator-runner;
- docker build --build-arg JAR_FILE=./infomodelrepository.jar -f repository/repository-server/Dockerfile -t eclipsevorto/vorto-repo:nightly ./repository/repository-server;
- docker build --build-arg JAR_FILE=./generator-runner-exec.jar -f generators/generator-runner/Dockerfile -t eclipsevorto/vorto-generators:nightly ./generators/generator-runner;
- docker push eclipsevorto/vorto-repo:nightly;
- docker push eclipsevorto/vorto-generators:nightly;
- if [ -n "$TRAVIS_TAG" ]; then
docker build --build-arg JAR_FILE=./infomodelrepository.jar -f repository/repository-server/Dockerfile -t eclipsevorto/vorto-repo:latest ./repository/repository-server;
docker build --build-arg JAR_FILE=./generator-runner-exec.jar -f generators/generator-runner/Dockerfile -t eclipsevorto/vorto-generators:latest ./generators/generator-runner;
docker build --build-arg JAR_FILE=./infomodelrepository.jar -f repository/repository-server/Dockerfile -t eclipsevorto/vorto-repo:$TRAVIS_TAG ./repository/repository-server;
docker build --build-arg JAR_FILE=./generator-runner-exec.jar -f generators/generator-runner/Dockerfile -t eclipsevorto/vorto-generators:$TRAVIS_TAG ./generators/generator-runner;
fi;

deploy:
provider: script
Expand Down
1 change: 1 addition & 0 deletions generators/generator-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
</dependencies>
</dependencyManagement>
<build>
<finalName>generator-runner</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
*/
package org.eclipse.vorto.model;

public class Dictionary implements IReferenceType {
public class DictionaryType implements IReferenceType {

private IReferenceType key;
private IReferenceType value;
private String type = "dictionary";

public Dictionary(IReferenceType key, IReferenceType value) {
public DictionaryType(IReferenceType key, IReferenceType value) {
this.key = key;
this.value = value;
}

protected Dictionary() {}
protected DictionaryType() {}

public IReferenceType getKey() {
return key;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void setType(String type) {

@Override
public String toString() {
return "Dictionary [key=" + key + ", value=" + value + "]";
return "DictionaryType [key=" + key + ", value=" + value + "]";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.vorto.repository.sso;

import java.util.Arrays;

import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
Expand All @@ -31,53 +32,77 @@
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider;

public class TokenUtils {
public static AccessTokenProvider proxiedAccessTokenProvider(String proxyHost, int proxyPort,
String proxyUser, String proxyPassword) {
ClientHttpRequestFactory requestFactory =
proxyAuthenticatedRequestFactory(proxyHost, proxyPort, proxyUser, proxyPassword);

AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider =
new AuthorizationCodeAccessTokenProvider();
authorizationCodeAccessTokenProvider.setRequestFactory(requestFactory);

ImplicitAccessTokenProvider implicitAccessTokenProvider = new ImplicitAccessTokenProvider();
implicitAccessTokenProvider.setRequestFactory(requestFactory);

return new AccessTokenProviderChain(
Arrays.<AccessTokenProvider>asList(authorizationCodeAccessTokenProvider,
implicitAccessTokenProvider, new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()));
}

public static AccessTokenProvider accessTokenProvider() {
AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider =
new AuthorizationCodeAccessTokenProvider();

ImplicitAccessTokenProvider implicitAccessTokenProvider = new ImplicitAccessTokenProvider();

return new AccessTokenProviderChain(
Arrays.<AccessTokenProvider>asList(authorizationCodeAccessTokenProvider,
implicitAccessTokenProvider, new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()));
}

public static ClientHttpRequestFactory proxyAuthenticatedRequestFactory(String proxyHost,
int proxyPort, String proxyUser, String proxyPassword) {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
new UsernamePasswordCredentials(proxyUser, proxyPassword));
HttpClientBuilder clientBuilder = HttpClientBuilder.create();

clientBuilder.useSystemProperties();
clientBuilder.setProxy(new HttpHost(proxyHost, proxyPort));
clientBuilder.setDefaultCredentialsProvider(credsProvider);
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());

CloseableHttpClient client = clientBuilder.build();

HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(client);

return factory;
}
public static AccessTokenProvider proxiedAccessTokenProvider(String proxyHost, int proxyPort,
String proxyUser, String proxyPassword) {
ClientHttpRequestFactory requestFactory =
proxyAuthenticatedRequestFactory(proxyHost, proxyPort, proxyUser, proxyPassword);
return buildAccessTokenProvider(requestFactory);
}

public static AccessTokenProvider proxiedAccessTokenProvider(String proxyHost, int proxyPort) {
ClientHttpRequestFactory requestFactory =
proxyAuthenticatedRequestFactory(proxyHost, proxyPort);
return buildAccessTokenProvider(requestFactory);
}

private static AccessTokenProvider buildAccessTokenProvider(
ClientHttpRequestFactory requestFactory) {
AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider =
new AuthorizationCodeAccessTokenProvider();
authorizationCodeAccessTokenProvider.setRequestFactory(requestFactory);

ImplicitAccessTokenProvider implicitAccessTokenProvider = new ImplicitAccessTokenProvider();
implicitAccessTokenProvider.setRequestFactory(requestFactory);

return new AccessTokenProviderChain(
Arrays.<AccessTokenProvider>asList(authorizationCodeAccessTokenProvider,
implicitAccessTokenProvider, new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()));
}

public static AccessTokenProvider accessTokenProvider() {
AuthorizationCodeAccessTokenProvider authorizationCodeAccessTokenProvider =
new AuthorizationCodeAccessTokenProvider();

ImplicitAccessTokenProvider implicitAccessTokenProvider = new ImplicitAccessTokenProvider();

return new AccessTokenProviderChain(
Arrays.<AccessTokenProvider>asList(authorizationCodeAccessTokenProvider,
implicitAccessTokenProvider, new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()));
}

public static ClientHttpRequestFactory proxyAuthenticatedRequestFactory(String proxyHost,
int proxyPort, String proxyUser, String proxyPassword) {
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxyHost, proxyPort),
new UsernamePasswordCredentials(proxyUser, proxyPassword));
return getClientBuilder(proxyHost, proxyPort, credsProvider);
}

private static ClientHttpRequestFactory proxyAuthenticatedRequestFactory(String proxyHost,
int proxyPort) {
return getClientBuilder(proxyHost, proxyPort, null);
}

private static ClientHttpRequestFactory getClientBuilder(String proxyHost, int proxyPort,
CredentialsProvider credsProvider) {
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.useSystemProperties();
clientBuilder.setProxy(new HttpHost(proxyHost, proxyPort));
if (credsProvider != null){
clientBuilder.setDefaultCredentialsProvider(credsProvider);
}
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());

CloseableHttpClient client = clientBuilder.build();

HttpComponentsClientHttpRequestFactory factory =
new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(client);

return factory;
}


}
Loading

0 comments on commit 61690b5

Please sign in to comment.