Skip to content

Commit 0f41fd5

Browse files
replace tokenManagement with fixed api token
1 parent 86de7e0 commit 0f41fd5

File tree

6 files changed

+129
-108
lines changed

6 files changed

+129
-108
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mvn -DskipTests install
1515
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
1616

1717
IMAGE_NAME=aas-env-oauth
18-
IMAGE_VERSION=0.3.22
18+
IMAGE_VERSION=0.3.28
1919
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
2020
JAR_NAME="$(basename "$JAR" .jar)"
2121
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -40,7 +40,7 @@ mvn -DskipTests install
4040
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
4141

4242
IMAGE_NAME=aas-env-oauth
43-
IMAGE_VERSION=0.3.22
43+
IMAGE_VERSION=0.3.28
4444
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
4545
JAR_NAME="$(basename "$JAR" .jar)"
4646
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -66,7 +66,7 @@ mvn -DskipTests install
6666
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdocker -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
6767

6868
IMAGE_NAME=aas-discovery-oauth
69-
IMAGE_VERSION=0.3.22
69+
IMAGE_VERSION=0.3.28
7070
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
7171
JAR_NAME="$(basename "$JAR" .jar)"
7272
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -91,7 +91,7 @@ mvn -DskipTests install
9191
mvn -f "$MODULE/pom.xml" clean package -DskipTests
9292

9393
IMAGE_NAME=aas-discovery-oauth
94-
IMAGE_VERSION=0.3.22
94+
IMAGE_VERSION=0.3.28
9595
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
9696
JAR_NAME="$(basename "$JAR" .jar)"
9797
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -117,7 +117,7 @@ mvn -DskipTests install
117117
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
118118

119119
IMAGE_NAME=aas-registry-log-mem-oauth
120-
IMAGE_VERSION=0.3.22
120+
IMAGE_VERSION=0.3.28
121121
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
122122
JAR_NAME="$(basename "$JAR" .jar)"
123123
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -146,7 +146,7 @@ mvn -DskipTests install
146146
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
147147

148148
IMAGE_NAME=aas-registry-log-mem-oauth
149-
IMAGE_VERSION=0.3.22
149+
IMAGE_VERSION=0.3.28
150150
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
151151
JAR_NAME="$(basename "$JAR" .jar)"
152152
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -176,7 +176,7 @@ mvn -DskipTests install
176176
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
177177

178178
IMAGE_NAME=aas-submodel-registry-log-mem-oauth
179-
IMAGE_VERSION=0.3.22
179+
IMAGE_VERSION=0.3.28
180180
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
181181
JAR_NAME="$(basename "$JAR" .jar)"
182182
JAR_NAME_WITH_EXT=${JAR_NAME}.jar
@@ -205,7 +205,7 @@ mvn -DskipTests install
205205
mvn -f "$MODULE/pom.xml" clean package -DskipTests -Pdockerbuild -Ddocker.namespace=letsdev -Ddocker.image.tag="$ARTIFACT_VERSION"
206206

207207
IMAGE_NAME=aas-submodel-registry-log-mem-oauth
208-
IMAGE_VERSION=0.3.22
208+
IMAGE_VERSION=0.3.28
209209
JAR="$(find "$MODULE/target" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' ! -name '*-tests.jar' | head -n1)"
210210
JAR_NAME="$(basename "$JAR" .jar)"
211211
JAR_NAME_WITH_EXT=${JAR_NAME}.jar

basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/AasEnvironmentPreconfigurationLoader.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.IOException;
3131
import java.io.InputStream;
3232
import java.nio.charset.StandardCharsets;
33+
import java.nio.file.NoSuchFileException;
3334
import java.security.interfaces.RSAPublicKey;
3435
import java.util.ArrayList;
3536

@@ -127,7 +128,14 @@ private File getFile(String filePath) throws IOException {
127128

128129

129130
private List<File> extractFilesToLoadFromEnvironmentDirectory(String directoryToLoad) throws IllegalArgumentException, IOException {
130-
File rootDirectory = getFile(directoryToLoad);
131+
File rootDirectory;
132+
133+
try {
134+
rootDirectory = getFile(directoryToLoad);
135+
} catch (NoSuchFileException e) {
136+
return new ArrayList<>();
137+
}
138+
131139
RecursiveDirectoryScanner directoryScanner = new RecursiveDirectoryScanner();
132140

133141
List<File> potentialEnvironments = directoryScanner.listFiles(rootDirectory);
@@ -141,4 +149,4 @@ private void logLoadingProcess(int current, int overall, String filename) {
141149
}
142150

143151

144-
}
152+
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*******************************************************************************
22
* Copyright (C) 2023 the Eclipse BaSyx Authors
3-
*
3+
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
66
* "Software"), to deal in the Software without restriction, including
77
* without limitation the rights to use, copy, modify, merge, publish,
88
* distribute, sublicense, and/or sell copies of the Software, and to
99
* permit persons to whom the Software is furnished to do so, subject to
1010
* the following conditions:
11-
*
11+
*
1212
* The above copyright notice and this permission notice shall be
1313
* included in all copies or substantial portions of the Software.
14-
*
14+
*
1515
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1616
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1717
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1818
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1919
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2020
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2121
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22-
*
22+
*
2323
* SPDX-License-Identifier: MIT
2424
******************************************************************************/
2525

@@ -46,7 +46,7 @@
4646

4747
/**
4848
* Configuration for integrating {@link AasRepository} with AasRegistry
49-
*
49+
*
5050
* @author danish
5151
*/
5252
@Configuration
@@ -59,38 +59,41 @@ public class RegistryIntegrationAasRepositoryConfiguration {
5959
@Value("#{'${basyx.externalurl}'.split(',')}")
6060
private List<String> aasRepositoryBaseURLs;
6161

62-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.enabled:false}")
63-
private boolean isAuthorizationEnabledOnRegistry;
64-
65-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.token-endpoint:#{null}}")
66-
private String authenticationServerTokenEndpoint;
67-
68-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.grant-type:#{null}}")
69-
private String grantType;
70-
71-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.client-id:#{null}}")
72-
private String clientId;
73-
74-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.client-secret:#{null}}")
75-
private String clientSecret;
76-
77-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.username:#{null}}")
78-
private String username;
79-
80-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.password:#{null}}")
81-
private String password;
82-
83-
@Value("${basyx.aasrepository.feature.registryintegration.authorization.scopes:#{null}}")
84-
private Collection<String> scopes;
62+
@Value("${ld-sso.api-token}")
63+
private String apiToken;
64+
65+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.enabled:false}")
66+
// private boolean isAuthorizationEnabledOnRegistry;
67+
//
68+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.token-endpoint:#{null}}")
69+
// private String authenticationServerTokenEndpoint;
70+
//
71+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.grant-type:#{null}}")
72+
// private String grantType;
73+
//
74+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.client-id:#{null}}")
75+
// private String clientId;
76+
//
77+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.client-secret:#{null}}")
78+
// private String clientSecret;
79+
//
80+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.username:#{null}}")
81+
// private String username;
82+
//
83+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.password:#{null}}")
84+
// private String password;
85+
//
86+
// @Value("${basyx.aasrepository.feature.registryintegration.authorization.scopes:#{null}}")
87+
// private Collection<String> scopes;
8588

8689
@Bean
8790
@ConditionalOnMissingBean
8891
public AasRepositoryRegistryLink getAasRepositoryRegistryLink() {
89-
90-
if (!isAuthorizationEnabledOnRegistry)
91-
return new AasRepositoryRegistryLink(new RegistryAndDiscoveryInterfaceApi(registryBasePath), aasRepositoryBaseURLs);
9292

93-
TokenManager tokenManager = new TokenManager(authenticationServerTokenEndpoint, createAccessTokenProvider());
93+
// if (!isAuthorizationEnabledOnRegistry)
94+
// return new AasRepositoryRegistryLink(new RegistryAndDiscoveryInterfaceApi(registryBasePath), aasRepositoryBaseURLs);
95+
96+
TokenManager tokenManager = new TokenManager(apiToken);//(authenticationServerTokenEndpoint, createAccessTokenProvider());
9497

9598
return new AasRepositoryRegistryLink(new AuthorizedConnectedAasRegistry(registryBasePath, tokenManager), aasRepositoryBaseURLs);
9699
}
@@ -102,13 +105,13 @@ public AttributeMapper getAasAttributeMapper(ObjectMapper objectMapper) {
102105
return new AttributeMapper(objectMapper);
103106
}
104107

105-
private AccessTokenProvider createAccessTokenProvider() {
106-
107-
AccessTokenProviderFactory factory = new AccessTokenProviderFactory(GrantType.valueOf(grantType), scopes);
108-
factory.setClientCredentials(clientId, clientSecret);
109-
factory.setPasswordCredentials(username, password);
110-
111-
return factory.create();
112-
}
108+
// private AccessTokenProvider createAccessTokenProvider() {
109+
//
110+
// AccessTokenProviderFactory factory = new AccessTokenProviderFactory(GrantType.valueOf(grantType), scopes);
111+
// factory.setClientCredentials(clientId, clientSecret);
112+
// factory.setPasswordCredentials(username, password);
113+
//
114+
// return factory.create();
115+
// }
113116

114117
}

basyx.common/basyx.client/src/main/java/org/eclipse/digitaltwin/basyx/client/internal/authorization/TokenManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ public class TokenManager {
5757

5858
private static final Logger LOGGER = LoggerFactory.getLogger(TokenManager.class);
5959

60-
@Value("${ld-sso.api-token}")
6160
private String apiToken;
6261

62+
public TokenManager(String apiToken) {
63+
this.apiToken = apiToken;
64+
}
65+
6366
public TokenManager(String tokenEndpoint, AccessTokenProvider accessTokenProvider) {
6467
}
6568

@@ -71,6 +74,10 @@ public TokenManager(String tokenEndpoint, AccessTokenProvider accessTokenProvide
7174
* if an error occurs while retrieving the token
7275
*/
7376
public String getAccessToken() throws IOException {
77+
if (LOGGER.isInfoEnabled()) {
78+
LOGGER.info("Returning access token: " + apiToken.substring(apiToken.length() - 10));
79+
}
80+
7481
return apiToken;
7582
}
7683
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*******************************************************************************
22
* Copyright (C) 2023 the Eclipse BaSyx Authors
3-
*
3+
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
66
* "Software"), to deal in the Software without restriction, including
77
* without limitation the rights to use, copy, modify, merge, publish,
88
* distribute, sublicense, and/or sell copies of the Software, and to
99
* permit persons to whom the Software is furnished to do so, subject to
1010
* the following conditions:
11-
*
11+
*
1212
* The above copyright notice and this permission notice shall be
1313
* included in all copies or substantial portions of the Software.
14-
*
14+
*
1515
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1616
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1717
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1818
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1919
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2020
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2121
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22-
*
22+
*
2323
* SPDX-License-Identifier: MIT
2424
******************************************************************************/
2525

@@ -46,69 +46,72 @@
4646

4747
/**
4848
* Configuration for integrating {@link SubmodelRepository} with SubmodelRegistry
49-
*
49+
*
5050
* @author danish
5151
*/
5252
@Configuration
5353
@ConditionalOnExpression("!T(org.springframework.util.StringUtils).isEmpty('${basyx.submodelrepository.feature.registryintegration:}') && !T(org.springframework.util.StringUtils).isEmpty('${basyx.externalurl:}')")
5454
public class RegistryIntegrationSubmodelRepositoryConfiguration {
55-
55+
5656
@Value("${basyx.submodelrepository.feature.registryintegration:#{null}}")
5757
private String registryBasePath;
5858

5959
@Value("#{'${basyx.externalurl}'.split(',')}")
6060
private List<String> submodelRepositoryBaseURLs;
6161

62-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.enabled:false}")
63-
private boolean isAuthorizationEnabledOnRegistry;
64-
65-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.token-endpoint:#{null}}")
66-
private String authenticationServerTokenEndpoint;
67-
68-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.grant-type:#{null}}")
69-
private String grantType;
70-
71-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.client-id:#{null}}")
72-
private String clientId;
73-
74-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.client-secret:#{null}}")
75-
private String clientSecret;
76-
77-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.username:#{null}}")
78-
private String username;
79-
80-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.password:#{null}}")
81-
private String password;
82-
83-
@Value("${basyx.submodelrepository.feature.registryintegration.authorization.scopes:#{null}}")
84-
private Collection<String> scopes;
62+
@Value("${ld-sso.api-token}")
63+
private String apiToken;
64+
65+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.enabled:false}")
66+
// private boolean isAuthorizationEnabledOnRegistry;
67+
//
68+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.token-endpoint:#{null}}")
69+
// private String authenticationServerTokenEndpoint;
70+
//
71+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.grant-type:#{null}}")
72+
// private String grantType;
73+
//
74+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.client-id:#{null}}")
75+
// private String clientId;
76+
//
77+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.client-secret:#{null}}")
78+
// private String clientSecret;
79+
//
80+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.username:#{null}}")
81+
// private String username;
82+
//
83+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.password:#{null}}")
84+
// private String password;
85+
//
86+
// @Value("${basyx.submodelrepository.feature.registryintegration.authorization.scopes:#{null}}")
87+
// private Collection<String> scopes;
8588

8689
@Bean
8790
@ConditionalOnMissingBean
8891
public SubmodelRepositoryRegistryLink getSubmodelRepositoryRegistryLink() {
89-
90-
if (!isAuthorizationEnabledOnRegistry)
91-
return new SubmodelRepositoryRegistryLink(new SubmodelRegistryApi(registryBasePath), submodelRepositoryBaseURLs);
9292

93-
TokenManager tokenManager = new TokenManager(authenticationServerTokenEndpoint, createAccessTokenProvider());
93+
// if (!isAuthorizationEnabledOnRegistry)
94+
// return new SubmodelRepositoryRegistryLink(new SubmodelRegistryApi(registryBasePath), submodelRepositoryBaseURLs);
95+
96+
TokenManager tokenManager = new TokenManager(apiToken);//authenticationServerTokenEndpoint, createAccessTokenProvider());
9497

9598
return new SubmodelRepositoryRegistryLink(new AuthorizedConnectedSubmodelRegistry(registryBasePath, tokenManager), submodelRepositoryBaseURLs);
9699
}
97-
100+
98101
@Bean
99102
@ConditionalOnMissingBean
100103
public AttributeMapper getSubmodelAttributeMapper(ObjectMapper objectMapper) {
101-
104+
102105
return new AttributeMapper(objectMapper);
103106
}
104-
105-
private AccessTokenProvider createAccessTokenProvider() {
106-
107-
AccessTokenProviderFactory factory = new AccessTokenProviderFactory(GrantType.valueOf(grantType), scopes);
108-
factory.setClientCredentials(clientId, clientSecret);
109-
factory.setPasswordCredentials(username, password);
110107

111-
return factory.create();
112-
}
108+
// private AccessTokenProvider createAccessTokenProvider() {
109+
//
110+
// AccessTokenProviderFactory factory = new AccessTokenProviderFactory(GrantType.valueOf(grantType), scopes);
111+
// factory.setClientCredentials(clientId, clientSecret);
112+
// factory.setPasswordCredentials(username, password);
113+
//
114+
// return factory.create();
115+
// }
113116

114117
}

0 commit comments

Comments
 (0)