diff options
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main')
4 files changed, 104 insertions, 59 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java index 79b3fa86..b4657922 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/config/ApplicationConfig.java @@ -32,7 +32,7 @@ public class ApplicationConfig implements ApplicationRunner { @Override public void run(final ApplicationArguments args) throws Exception { - baseUrl = "https://" + serverDnsName + ":" + environment.getProperty(PORT); + baseUrl = "http://" + serverDnsName + ":" + environment.getProperty(PORT); } public String getBaseUrl() { diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/oauth/AuthorizationServerConfig.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/oauth/AuthorizationServerConfig.java index a97c41fa..026ac0fc 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/oauth/AuthorizationServerConfig.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/oauth/AuthorizationServerConfig.java @@ -1,5 +1,7 @@ package org.onap.so.svnfm.simulator.oauth; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; @@ -14,13 +16,15 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.E * "oauth-authentication" is active */ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationServerConfig.class); private static final int ONE_DAY = 60 * 60 * 24; @Override public void configure(final ClientDetailsServiceConfigurer clients) throws Exception { - clients.inMemory().withClient("vnfmadapter") - .secret("$2a$10$dHzTlqSBcm8hdO52LBvnX./zNTvUzzJy.lZrc4bCBL5gkln0wX6T6") //123456 + LOGGER.info("configuring oauth-authentication ..."); + clients.inMemory().withClient("vnfm") + .secret("$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke") //password1$ .authorizedGrantTypes("client_credentials").scopes("write").accessTokenValiditySeconds(ONE_DAY) .refreshTokenValiditySeconds(ONE_DAY); } diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/OperationProgressor.java b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/OperationProgressor.java index 5c27665e..e6e16e40 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/OperationProgressor.java +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/java/org/onap/so/svnfm/simulator/services/OperationProgressor.java @@ -1,12 +1,33 @@ package org.onap.so.svnfm.simulator.services; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManager; +import javax.net.ssl.KeyManagerFactory; +import javax.ws.rs.core.MediaType; import org.apache.commons.codec.binary.Base64; import org.modelmapper.ModelMapper; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiResponse; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.*; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiClient; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.ApiException; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api.DefaultApi; @@ -19,7 +40,11 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperatio import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.NotificationTypeEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201InstantiatedVnfInfoVnfcResourceInfo; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials; import org.onap.so.svnfm.simulator.api.VeVnfmApi; import org.onap.so.svnfm.simulator.config.ApplicationConfig; import org.onap.so.svnfm.simulator.model.VnfOperation; @@ -30,23 +55,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import javax.ws.rs.core.MediaType; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.util.*; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; public abstract class OperationProgressor implements Runnable { @@ -211,10 +221,12 @@ public abstract class OperationProgressor implements Runnable { try { final SubscriptionsAuthenticationParamsBasic subscriptionAuthentication = getLastLccnSubscriptionRequest().getAuthentication().getParamsBasic(); - final String auth = subscriptionAuthentication.getUserName() + ":" + subscriptionAuthentication.getPassword(); + final String auth = + subscriptionAuthentication.getUserName() + ":" + subscriptionAuthentication.getPassword(); final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1)); String authHeader = "Basic " + new String(encodedAuth); - notificationClient.lcnVnfLcmOperationOccurrenceNotificationPostWithHttpInfo(notification, MediaType.APPLICATION_JSON, authHeader); + notificationClient.lcnVnfLcmOperationOccurrenceNotificationPostWithHttpInfo(notification, + MediaType.APPLICATION_JSON, authHeader); } catch (final ApiException exception) { LOGGER.error("Error sending notification: " + notification, exception); LOGGER.error("Response code: {}, body: {}, basePath: {}", exception.getCode(), exception.getResponseBody(), @@ -260,14 +272,22 @@ public abstract class OperationProgressor implements Runnable { try { final SubscriptionsAuthenticationParamsOauth2ClientCredentials subscriptionAuthentication = getLastLccnSubscriptionRequest().getAuthentication().getParamsOauth2ClientCredentials(); + SubscriptionsAuthenticationParamsBasic paramsBasic = + getLastLccnSubscriptionRequest().getAuthentication().getParamsBasic(); + final String authHeader = applicationConfig.getGrantAuth().equals("oauth") ? "Bearer " + getToken(notificationClient.getApiClient(), subscriptionAuthentication) - : null; + : getAuthorizationHeader(paramsBasic.getUserName(), paramsBasic.getPassword()); + + LOGGER.info("Sending grant request with authorization: {}", authHeader); final ApiResponse<InlineResponse201> response = grantClient.grantsPostWithHttpInfo(grantRequest, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, authHeader); LOGGER.info("Grant Response: {}", response); return response.getData(); } catch (final org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.ApiException exception) { + LOGGER.error("Status: {}", exception.getCode()); + LOGGER.error("ResponseHeaders: {}", exception.getResponseHeaders()); + LOGGER.error("ResponseBody: {}", exception.getResponseBody()); LOGGER.error("Error sending notification: " + grantRequest, exception); return null; } @@ -308,7 +328,11 @@ public abstract class OperationProgressor implements Runnable { private String getAuthorizationHeader( final SubscriptionsAuthenticationParamsOauth2ClientCredentials oauthClientCredentials) { - final String auth = oauthClientCredentials.getClientId() + ":" + oauthClientCredentials.getClientPassword(); + return getAuthorizationHeader(oauthClientCredentials.getClientId(), oauthClientCredentials.getClientPassword()); + } + + private String getAuthorizationHeader(final String username, final String password) { + final String auth = username + ":" + password; final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8)); return "Basic " + new String(encodedAuth); } @@ -338,4 +362,4 @@ public abstract class OperationProgressor implements Runnable { return last; } -} +}
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml index ffae8eb2..db2a6d4c 100644 --- a/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml +++ b/plans/so/integration-etsi-testing/so-simulators/vnfm-simulator/vnfm-service/src/main/resources/application.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. spring: + profiles: + active: oauth-authentication h2: console: null enabled: true @@ -35,40 +37,55 @@ server: tomcat: max-threads: 50 ssl: - key-alias: so@so.onap.org - key--store-password: 7Em3&j4.19xYiMelhD5?xbQ. - key-store: classpath:so-vnfm-simulator.p12 - key-store-type: PKCS12 -http: - client: - ssl: - trust-store: classpath:so-vnfm-adapter.p12 - trust-store-password: ywsqCy:EEo#j}HJHM7z^Rk[L + enabled: false + request: + grant: + auth: none endpoint: - callbackUri: https://so-vnfm-simulator.onap:9093/vnfpkgm/v1/notification + callbackUri: http://so-vnfm-simulator.onap:9093/vnfpkgm/v1/notification vnfm-adapter: auth: name: vnfm password: password1$ vnfds: vnfdlist: - - vnfdid: 1 - vnfclist: - - vnfcid: VNFC1 - resourceTemplateId: vnfd1_vnfc1 - vduId: vnfd1_vduForVnfc1 - type: COMPUTE - - vnfcid: VNFC2 - resourceTemplateId: vnfd1_vnfc2 - vduId: vnfd1_vduForVnfc2 - type: COMPUTE - - vnfdid: 2 - vnfclist: - - vnfcid: VNFC3 - resourceTemplateId: vnfd2_vnfc3 - vduId: vnfd2_vduForVnfc3 - type: COMPUTE - - vnfcid: VNFC4 - resourceTemplateId: vnfd2_vnfc4 - vduId: vnfd2_vduForVnfc4 - type: COMPUTE + - vnfdid: 1 + vnfclist: + - vnfcid: VNFC1 + resourceTemplateId: vnfd1_vnfc1 + vduId: vnfd1_vduForVnfc1 + type: COMPUTE + - vnfcid: VNFC2 + resourceTemplateId: vnfd1_vnfc2 + vduId: vnfd1_vduForVnfc2 + type: COMPUTE + - vnfdid: 2 + vnfclist: + - vnfcid: VNFC3 + resourceTemplateId: vnfd2_vnfc3 + vduId: vnfd2_vduForVnfc3 + type: COMPUTE + - vnfcid: VNFC4 + resourceTemplateId: vnfd2_vnfc4 + vduId: vnfd2_vduForVnfc4 + type: COMPUTE + - vnfdid: b1bb0ce7-2222-4fa7-95ed-4840d70a1177 + vnfclist: + - vnfcid: VNFC5 + resourceTemplateId: vnfd3_vnfc4 + vduId: vnfd3_vduForVnfc4 + type: COMPUTE + - vnfcid: VNFC6 + resourceTemplateId: vnfd3_vnfc5 + vduId: vnfd3_vduForVnfc5 + type: COMPUTE + - vnfdid: 0c960b3a-d88f-11ea-87d0-0242ac130003 + vnfclist: + - vnfcid: VNFC7 + resourceTemplateId: vnfd4_vnfc5 + vduId: vnfd4_vduForVnfc5 + type: COMPUTE + - vnfcid: VNFC8 + resourceTemplateId: vnfd4_vnfc6 + vduId: vnfd4_vduForVnfc6 + type: COMPUTE
\ No newline at end of file |