summaryrefslogtreecommitdiffstats
path: root/adapters/mso-ve-vnfm-adapter/src/main/java
diff options
context:
space:
mode:
authorPiotr Borelowski <p.borelowski@partner.samsung.com>2020-01-15 17:58:27 +0100
committerPiotr Borelowski <p.borelowski@partner.samsung.com>2020-01-30 13:20:26 +0100
commit903cfb96ee4d3fdcce5f731cb4685d5ff8836c00 (patch)
treefaa63e459d39494ca1a75b7c529fd38782e12b6c /adapters/mso-ve-vnfm-adapter/src/main/java
parent74a3c19549a12db2e196a6141f6fc2dcda1c5826 (diff)
Added Basic Authorization in receiving Notification
Ve-Vnfm (SOL002) Adapter project Issue-ID: SO-2574 Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com> Change-Id: Ib01bf2301dad5a699751c060cfb28eac6858e003
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/main/java')
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java29
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java18
2 files changed, 40 insertions, 7 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
index 32c2559d7b..cc56048262 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
@@ -21,15 +21,38 @@
package org.onap.so.adapters.vevnfm.configuration;
import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
+@EnableWebSecurity
public class SecurityConfiguration extends SoBasicWebSecurityConfigurerAdapter {
+ @Value("${notification.url}")
+ private String notificationUrl;
+
+ @Value("${notification.username}")
+ private String notificationUsername;
+
+ @Value("${notification.password}")
+ private String notificationPassword;
+
+ @Autowired
+ private PasswordEncoder passwordEncoder;
+
+ @Override
+ protected void configure(final HttpSecurity https) throws Exception {
+ https.csrf().disable().authorizeRequests().antMatchers(notificationUrl).authenticated().and().httpBasic();
+ }
+
@Override
- protected void configure(final HttpSecurity http) throws Exception {
- http.authorizeRequests().antMatchers().permitAll().and().requestMatchers().antMatchers("/").and()
- .authorizeRequests().anyRequest().authenticated();
+ protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
+ auth.inMemoryAuthentication().withUser(notificationUsername)
+ .password(passwordEncoder.encode(notificationPassword)).authorities("ROLE_USER");
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
index e413124b4b..aa07ed65a2 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
@@ -20,6 +20,7 @@
package org.onap.so.adapters.vevnfm.service;
+import java.util.Collections;
import org.onap.so.adapters.vevnfm.subscription.SubscribeSender;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication;
@@ -33,14 +34,20 @@ public class SubscriberService {
private static final char COLON = ':';
- @Value("${notification.url}")
- private String notificationUrl;
+ @Value("${system.url}")
+ private String systemUrl;
@Value("${server.port}")
private String serverPort;
- @Value("${system.url}")
- private String systemUrl;
+ @Value("${notification.url}")
+ private String notificationUrl;
+
+ @Value("${notification.username}")
+ private String notificationUsername;
+
+ @Value("${notification.password}")
+ private String notificationPassword;
@Autowired
private SubscribeSender sender;
@@ -55,6 +62,9 @@ public class SubscriberService {
request.callbackUri(getCallbackUri());
final SubscriptionsAuthenticationParamsBasic paramsBasic = new SubscriptionsAuthenticationParamsBasic();
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
+ paramsBasic.setUserName(notificationUsername);
+ paramsBasic.setPassword(notificationPassword);
+ authentication.setAuthType(Collections.singletonList(SubscriptionsAuthentication.AuthTypeEnum.BASIC));
authentication.setParamsBasic(paramsBasic);
request.authentication(authentication);