-Folder for docker solution
\ No newline at end of file
+Local deploy example
+
+docker-compose up
\ No newline at end of file
--- /dev/null
+version: "3.5"
+
+services:
+# ves-collector:
+# restart: unless-stopped
+# ports:
+# - "8080:8080/udp"
+# image: nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest
+# container_name: vescollector
+# environment:
+# DMAAPHOST: 50.50.50.50
+
+ ves-nf-oam-adopter-ran-mock:
+ ports:
+ - "444:443/tcp"
+ network_mode: host
+ restart: unless-stopped
+ image: nexus3.o-ran-sc.org:10003/o-ran-sc/ves-nf-oam-adopter-ran-mock:latest
+ container_name: ves-nf-oam-adopter-ran-mock
+ environment:
+ KEY_PASSWORD: nf-oam-adopter
+ KEY_STORE_PASSWORD: nf-oam-adopter
+ SNMP-DESTINY: 0.0.0.0/162
+
+ ves-nf-oam-adopter:
+ ports:
+ - "162:162/udp"
+ - "443:443/tcp"
+ network_mode: host
+ restart: unless-stopped
+ image: nexus3.o-ran-sc.org:10003/o-ran-sc/ves-nf-oam-adopter:latest
+ container_name: ves-nf-oam-adopter
+ environment:
+ USERNAME: admin
+ PASSWORD: admin
+ KEY_PASSWORD: nf-oam-adopter
+ KEY_STORE_PASSWORD: nf-oam-adopter
+ TRUST_STORE_PASSWORD: nf-oam-adopter
+ VES_COLLECTOR: http://vescollector:8080/eventListener/v7
+ VES_ENCODED_AUTH: YWRtaW46YWRtaW4=
+ PM_SYNC_TIME_START: "06:05:00"
+ PM_SYNC_TIME_FREQ: "24:00:00"
\ No newline at end of file
<module>ves-nf-oam-adopter-artifacts</module>
<module>ves-nf-oam-adopter-checkstyle</module>
<module>ves-nf-oam-adopter-spotbugs</module>
+ <module>ves-nf-oam-adopter-mock</module>
<module>ves-nf-oam-adopter-api</module>
<module>ves-nf-oam-adopter-event-notifier</module>
<module>ves-nf-oam-adopter-snmp-manager</module>
<artifactId>ves-nf-oam-adopter-spotbugs</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ves-nf-oam-adopter-mock</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ves-nf-oam-adopter-api</artifactId>
--- /dev/null
+spring.devtools.restart.log-condition-evaluation-delta: false
+scheduler:
+ fixedDelay: 8000
+ initialDelay: 4000
+security:
+ auth:
+ username: admin
+ password: admin
+server:
+ port: ${SERVER_PORT:443}
+ ssl:
+ enabled: true
+ key-store-type: JKS
+ key-alias: nf-oam-adopter
+ key-store: ${KEYSTORE_PATH:ssl/nf-oam-adopter-keystore.jks}
+ key-store-password: ${KEY_STORE_PASSWORD:nf-oam-adopter}
+ key-password: ${KEY_PASSWORD:nf-oam-adopter}
+ enabled-protocols: TLSv1.3
+ ciphers: TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256, TLS_AES_128_CCM_8_SHA256, TLS_AES_128_CCM_SHA256
+snmp:
+ destiny: ${SNMP-DESTINY:0.0.0.0/162}
+ alarm-trap:
+ 1.3.6.1.2.1.1.3.0: "0:00:50.00"
+ 1.3.6.1.6.3.1.1.4.1.0: "1.3.6.1.4.1.1007.0.0.1.0.1"
+ 1.3.6.1.4.1.1007.0.0.1.0.2: "OAM-BOX"
+ 1.3.6.1.4.1.1007.0.0.1.0.3: "Port DOWN"
+ 1.3.6.1.4.1.1007.0.0.1.0.4: "1613592976108380"
+ 1.3.6.1.4.1.1007.0.0.1.0.5: "1613592976108380"
+ 1.3.6.1.4.1.1007.0.0.1.0.6: "10283"
+ 1.3.6.1.4.1.1007.0.0.1.0.7: "A0"
+ clear-trap:
+ 1.3.6.1.2.1.1.3.0: "0:00:50.00"
+ 1.3.6.1.6.3.1.1.4.1.0: "1.3.6.1.4.1.1007.0.0.1.0.2"
+ 1.3.6.1.4.1.1007.0.0.1.0.2: "OAM-BOX"
+ 1.3.6.1.4.1.1007.0.0.1.0.3: "Port UP"
+ 1.3.6.1.4.1.1007.0.0.1.0.4: "1613592976109380"
+ 1.3.6.1.4.1.1007.0.0.1.0.5: "1613592976109880"
+ 1.3.6.1.4.1.1007.0.0.1.0.6: "10283"
+ 1.3.6.1.4.1.1007.0.0.1.0.7: "A0"
--- /dev/null
+Configuration:
+ status: debug
+
+ appenders:
+ Console:
+ name: LogToConsole
+ PatternLayout:
+ Pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
+
+ RollingFile:
+ - name: LogToRollingFile
+ fileName: logs/o-ran-ves-adapter.log
+ filePattern: "logs/$${date:yyyy-MM}/o-ran-ves-adapter-%d{MM-dd-yyyy}-%i.log.gz"
+ PatternLayout:
+ pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
+ Policies:
+ SizeBasedTriggeringPolicy:
+ size: 100MB
+ DefaultRollOverStrategy:
+ max: 10
+
+ Loggers:
+ logger:
+ - name: org.o.ran.oam.nf.oam
+ level: debug
+ additivity: false
+ AppenderRef:
+ - ref: LogToConsole
+ - ref: LogToRollingFile
+ - name: org.springframework.boot.actuate.audit.listener
+ level: info
+ additivity: false
+ AppenderRef:
+ - ref: LogToConsole
+ - ref: LogToRollingFile
+ - name: org.springframework
+ level: warn
+ additivity: false
+ AppenderRef:
+ - ref: LogToConsole
+ - ref: LogToRollingFile
+
+ Root:
+ level: info
+ AppenderRef:
+ AppenderRef:
+ - ref: LogToConsole
+ - ref: LogToRollingFile
--- /dev/null
+# ============LICENSE_START=======================================================
+# Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+openapi: 3.0.3
+info:
+ title: O-RAN OAM Adopter RAN Mock
+ description: API for O-RAN OAM Adopter RAN Mock service.
+ version: "1.0.0"
+ license:
+ name: "Apache 2.0"
+ url: "http://www.apache.org/licenses/LICENSE-2.0"
+
+servers:
+ - url: https://example.io/v1
+
+paths:
+ /auth/token:
+ post:
+ security:
+ - BasicAuth: [ ]
+ tags:
+ - controller
+ summary: Generate token
+ description: Generate token
+ operationId: authenticateAndGenerateToken
+ responses:
+ '200':
+ description: Successfully returned a list of adapters host address
+ content:
+ application/json:
+ schema:
+ type: string
+ '400':
+ $ref: '#/components/responses/400Error'
+ '401':
+ $ref: '#/components/responses/401Error'
+ /pm/files:
+ post:
+ tags:
+ - controller
+ summary: Read Performance Management Files
+ description: Read Performance Management Files
+ operationId: getPerformanceManagementFiles
+ responses:
+ '200':
+ description: Successfully returned ZIP with CSV pm files
+ content:
+ application/zip:
+ schema:
+ type: string
+ format: binary
+ '400':
+ $ref: '#/components/responses/400Error'
+ '401':
+ $ref: '#/components/responses/401Error'
+ /system/timeZone:
+ post:
+ tags:
+ - controller
+ summary: Read time zone
+ description: Read time zone
+ operationId: getTimeZone
+ responses:
+ '200':
+ description: Successfully returned time zone of the RAN
+ content:
+ application/json:
+ schema:
+ type: string
+ '400':
+ $ref: '#/components/responses/400Error'
+ '401':
+ $ref: '#/components/responses/401Error'
+
+components:
+ responses:
+ 400Error:
+ description: Invalid request
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ 401Error:
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+* ============LICENSE_START=======================================================
+* O-RAN-SC
+* ================================================================================
+* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+* ================================================================================
+* 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.
+* ============LICENSE_END============================================
+*
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.o-ran-sc.oam</groupId>
+ <artifactId>ves-nf-oam-adopter-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../ves-nf-oam-adopter-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ves-nf-oam-adopter-mock</artifactId>
+
+ <properties>
+ <!--Image properties-->
+ <image.name>ves-nf-oam-adopter-ran-mock</image.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-log4j2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.snmp4j</groupId>
+ <artifactId>snmp4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <!-- Swagger code generation. -->
+ <plugin>
+ <groupId>io.swagger.codegen.v3</groupId>
+ <artifactId>swagger-codegen-maven-plugin</artifactId>
+ <version>${swagger-codegen-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <inputSpec>${project.basedir}/docs/api/swagger/openapi.yaml</inputSpec>
+ <invokerPackage>org.o.ran.oam.nf.oam.adopter.mock.app.controller</invokerPackage>
+ <modelPackage>org.o.ran.oam.nf.oam.adopter.mock.model</modelPackage>
+ <apiPackage>org.o.ran.oam.nf.oam.adopter.mock.api</apiPackage>
+ <language>spring</language>
+ <generateSupportingFiles>false</generateSupportingFiles>
+ <configOptions>
+ <sourceFolder>src/gen/java</sourceFolder>
+ <dateLibrary>java11</dateLibrary>
+ <interfaceOnly>true</interfaceOnly>
+ <useTags>true</useTags>
+ <serializableModel>true</serializableModel>
+ </configOptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <verbose>true</verbose>
+ <images>
+ <image>
+ <name>${nexus.repository}${image.name}</name>
+ <build>
+ <from>${base.image}</from>
+ <tags>
+ <tag>${project.version}</tag>
+ </tags>
+ <workdir>${image.workdir}</workdir>
+ <entryPoint>
+ <exec>
+ <args>java</args>
+ <args>-jar</args>
+ <args>${project.artifactId}-${project.version}.jar</args>
+ </exec>
+ </entryPoint>
+ <assembly>
+ <basedir>${image.workdir}</basedir>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <includes>
+ <include>${project.groupId}:${project.artifactId}</include>
+ </includes>
+ <outputFileNameMapping>${project.build.finalName}.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ <files>
+ <file>
+ <source>${base.config}application.yml</source>
+ </file>
+ <file>
+ <source>${base.config}/zip/pmFiles.zip</source>
+ <outputDirectory>.</outputDirectory>
+ <destName>./pmFiles.zip</destName>
+ </file>
+ <file>
+ <source>${base.config}log4j2.yml</source>
+ </file>
+ <file>
+ <source>${base.config}/ssl/nf-oam-adopter-keystore.jks</source>
+ <outputDirectory>./ssl</outputDirectory>
+ <destName>nf-oam-adopter-keystore.jks</destName>
+ </file>
+ </files>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>build-docker-image</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-image</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication(scanBasePackages = {"org.o.ran.oam.nf.oam.adopter"})
+public class MockRanApplication {
+ public static void main(final String[] args) {
+ SpringApplication.run(MockRanApplication.class, args);
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.io.IOException;
+import java.util.HashMap;
+import org.o.ran.oam.nf.oam.adopter.mock.app.properties.SnmpProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.snmp4j.CommunityTarget;
+import org.snmp4j.PDU;
+import org.snmp4j.Snmp;
+import org.snmp4j.mp.SnmpConstants;
+import org.snmp4j.smi.OID;
+import org.snmp4j.smi.OctetString;
+import org.snmp4j.smi.UdpAddress;
+import org.snmp4j.smi.VariableBinding;
+import org.snmp4j.transport.DefaultUdpTransportMapping;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+@Service
+@EnableScheduling
+public class SnmpNotifier {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SnmpNotifier.class);
+
+ private final HashMap<String, String> alarmTrap;
+ private final HashMap<String, String> clearTrap;
+ private final CommunityTarget target;
+
+ /**
+ * Default constructor.
+ */
+ @Autowired
+ public SnmpNotifier(final SnmpProperties snmpProperties) {
+ this.alarmTrap = snmpProperties.getAlarmTrap();
+ this.clearTrap = snmpProperties.getClearTrap();
+ this.target = new CommunityTarget();
+ target.setCommunity(new OctetString("public"));
+ target.setVersion(SnmpConstants.version2c);
+ target.setAddress(new UdpAddress(snmpProperties.getDestiny()));
+ }
+
+ @Scheduled(fixedDelayString = "${scheduler.fixedDelay}")
+ @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD")
+ private void sendAlarmTrap() throws IOException {
+ sendTrap(target, alarmTrap, "alarm");
+ }
+
+ @Scheduled(fixedDelayString = "${scheduler.fixedDelay}", initialDelayString = "${scheduler.initialDelay}")
+ @SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD")
+ private void sendClearTrap() throws IOException {
+ sendTrap(target, clearTrap, "clear");
+ }
+
+ private static void sendTrap(final CommunityTarget target, final HashMap<String, String> trap,
+ final String trapType) throws IOException {
+ final PDU pdu = new PDU();
+ pdu.setType(PDU.TRAP);
+ trap.forEach((key, value) -> {
+ try {
+ pdu.add(new VariableBinding(new OID(key), new OctetString(value)));
+ } catch (final Exception e) {
+ LOG.error("Failed to parse oid / value : {}, {}", key, value, e);
+ }
+ });
+
+
+ final Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
+ snmp.send(pdu, target, null, null);
+ snmp.close();
+ LOG.info("Trap {} sent successfully.", trapType);
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.config;
+
+import java.io.IOException;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.o.ran.oam.nf.oam.adopter.mock.app.properties.SecurityProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.util.StringUtils;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+public class AuthTokenFilter extends OncePerRequestFilter {
+ private static final Logger logger = LoggerFactory.getLogger(AuthTokenFilter.class);
+
+ public static final String TOKEN = "someRandomToken";
+ private final UsernamePasswordAuthenticationToken authentication;
+
+ public AuthTokenFilter(final SecurityProperties security) {
+ this.authentication = new UsernamePasswordAuthenticationToken(security.getUsername(), security.getPassword());
+ }
+
+ @Override
+ protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
+ final FilterChain filterChain) throws ServletException, IOException {
+ try {
+ final String token = extractToken(request);
+ if (token != null && token.equals(TOKEN)) {
+
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+ }
+ } catch (final Exception e) {
+ logger.error("Cannot set user authentication", e);
+ }
+
+ filterChain.doFilter(request, response);
+ }
+
+ private static String extractToken(final HttpServletRequest request) {
+ final String headerAuth = request.getHeader("Authorization");
+ if (StringUtils.hasText(headerAuth) && headerAuth.startsWith("Bearer ")) {
+ return headerAuth.substring(7);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.config;
+
+import org.o.ran.oam.nf.oam.adopter.mock.app.properties.SecurityProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.annotation.Order;
+import org.springframework.security.authentication.AuthenticationManager;
+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.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@EnableWebSecurity
+@Order(1)
+public class BasicAuthConfiguration extends WebSecurityConfigurerAdapter {
+
+ private static final String ADMIN_ROLE = "ADMIN";
+ private final SecurityProperties security;
+
+ @Autowired
+ public BasicAuthConfiguration(final SecurityProperties security) {
+ super();
+ this.security = security;
+ }
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.requiresChannel().anyRequest().requiresSecure();
+ http.csrf().disable()
+ .antMatcher("/auth/**")
+ .authorizeRequests().anyRequest().authenticated()
+ .and()
+ .httpBasic();
+ }
+
+ @Bean
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ /**
+ * Configure default in-memory user.
+ */
+ @Autowired
+ public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
+ auth.inMemoryAuthentication()
+ .withUser(security.getUsername())
+ .password("{noop}" + security.getPassword())
+ .roles(ADMIN_ROLE);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.config;
+
+import org.o.ran.oam.nf.oam.adopter.mock.app.properties.SecurityProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.annotation.Order;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+@EnableWebSecurity
+@Order(2)
+public class TokenSecurityConfiguration extends WebSecurityConfigurerAdapter {
+
+ private final SecurityProperties security;
+
+ @Autowired
+ public TokenSecurityConfiguration(final SecurityProperties security) {
+ super();
+ this.security = security;
+ }
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.requiresChannel().anyRequest().requiresSecure();
+ http.csrf().disable()
+ .addFilterAfter(new AuthTokenFilter(security), UsernamePasswordAuthenticationFilter.class)
+ .authorizeRequests()
+ .antMatchers(HttpMethod.POST, "/pm").permitAll()
+ .antMatchers(HttpMethod.POST, "/system").permitAll()
+ .anyRequest()
+ .authenticated();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.controller;
+
+import static org.o.ran.oam.nf.oam.adopter.mock.app.config.AuthTokenFilter.TOKEN;
+
+import com.google.gson.Gson;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import org.o.ran.oam.nf.oam.adopter.mock.api.ControllerApi;
+import org.o.ran.oam.nf.oam.adopter.mock.app.pojo.TimeZoneOffsetResponse;
+import org.o.ran.oam.nf.oam.adopter.mock.app.pojo.TokenResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.Resource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class RanController implements ControllerApi {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RanController.class);
+ private static final DateTimeFormatter OFFSET_FORMATTER = DateTimeFormatter.ofPattern("xxx");
+ private static final Gson GSON = new Gson();
+
+ @Override
+ public ResponseEntity<String> authenticateAndGenerateToken() {
+ return ResponseEntity.ok(GSON.toJson(new TokenResponse(TOKEN)));
+ }
+
+ @Override
+ public ResponseEntity<Resource> getPerformanceManagementFiles() {
+ LOG.info("Read pm files.");
+ final HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+ return new ResponseEntity<>(ZipUtil.read(), headers, HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<String> getTimeZone() {
+ final ZoneId zoneId = ZoneId.systemDefault();
+ final ZoneOffset offset = zoneId.getRules().getOffset(Instant.now());
+ LOG.info("ZoneId {} / Offset {}", zoneId, offset);
+ return ResponseEntity.ok(GSON.toJson(new TimeZoneOffsetResponse(OFFSET_FORMATTER.format(offset))));
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.controller;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import lombok.experimental.UtilityClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.core.io.Resource;
+
+@UtilityClass
+public final class ZipUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(ZipUtil.class);
+ private static final String ZIP = "pmFiles.zip";
+
+ /**
+ * Read Zip File.
+ */
+ public static Resource read() {
+ try {
+ return new InputStreamResource(new FileInputStream(new File(new File("."), ZIP)));
+ } catch (final FileNotFoundException e) {
+ LOG.error("Failed to load file.", e);
+ return null;
+ }
+ }
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.pojo;
+
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+
+@RequiredArgsConstructor
+@Getter
+@Setter
+public class TimeZoneOffsetResponse {
+
+ @NonNull
+ private String offset;
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.pojo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class TokenResponse {
+ @NonNull
+ private String token;
+}
--- /dev/null
+package org.o.ran.oam.nf.oam.adopter.mock.app.properties;
+
+import javax.validation.constraints.NotEmpty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "security.auth")
+@Data
+@NoArgsConstructor
+public class SecurityProperties {
+ @NotEmpty
+ private String username;
+ @NotEmpty
+ private String password;
+}
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * O-RAN-SC
+ * ================================================================================
+ * Copyright © 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.o.ran.oam.nf.oam.adopter.mock.app.properties;
+
+import java.util.HashMap;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "snmp")
+@Data
+@NoArgsConstructor
+public class SnmpProperties {
+ @NotEmpty
+ private String destiny;
+ @NotNull
+ private HashMap<String, String> alarmTrap;
+ @NotNull
+ private HashMap<String, String> clearTrap;
+}
</jacoco.reportDirectory.aggregate>
<sonar.coverage.jacoco.xmlReportPaths>
../ves-nf-oam-adopter-event-notifier/target/site/jacoco-ut/jacoco.xml,
- ../ves-nf-oam-adopter-event-notifier/target/site/jacoco-aggregate/jacoco.xml
+ ../ves-nf-oam-adopter-event-notifier/target/site/jacoco-aggregate/jacoco.xml,
../ves-nf-oam-adopter-snmp-manager/target/site/jacoco-ut/jacoco.xml,
../ves-nf-oam-adopter-snmp-manager/target/site/jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
+ <sonar.scanner.version>3.8.0.2131</sonar.scanner.version>
<!--Dependency Versions-->
<commons-configuration2.version>2.7</commons-configuration2.version>
<commons-io.version>2.6</commons-io.version>
<gson.version>2.8.6</gson.version>
<httpclient5.version>5.0.3</httpclient5.version>
<jdt.annotation.version>2.2.600</jdt.annotation.version>
- <junit.jupiter.version>5.7.1</junit.jupiter.version>
<lombok.version>1.18.20</lombok.version>
<rxjava.version>3.0.12</rxjava.version>
- <spotbugs-maven-plugin.version>4.2.3</spotbugs-maven-plugin.version>
- <spring.boot.version>2.4.5</spring.boot.version>
<snmp4j.version>3.4.4</snmp4j.version>
<spotbugs.version>4.2.3</spotbugs.version>
+ <spring.boot.version>2.4.5</spring.boot.version>
+ <swagger-annotations.version>2.1.9</swagger-annotations.version>
<!--Plugins Versions-->
- <sonar.scanner.version>3.8.0.2131</sonar.scanner.version>
<com.puppycrawl.tools.version>8.41</com.puppycrawl.tools.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<spotbugs-maven-plugin.version>4.2.3</spotbugs-maven-plugin.version>
+ <swagger-codegen-maven-plugin.version>3.0.25</swagger-codegen-maven-plugin.version>
+ <!--Image properties-->
+ <base.image>openjdk:11-jre-slim</base.image>
+ <base.config>${project.basedir}/configuration/</base.config>
+ <image.workdir>/o-ran-ves-adapter/</image.workdir>
+ <nexus.repository>nexus3.o-ran-sc.org:10003/o-ran-sc/</nexus.repository>
</properties>
<dependencyManagement>
<type>pom</type>
<scope>import</scope>
</dependency>
+ <dependency>
+ <groupId>io.swagger.core.v3</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>${swagger-annotations.version}</version>
+ </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <version>${spring.boot.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit.jupiter.version}</version>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <version>${junit.jupiter.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring.boot.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>