Skip to content

Commit

Permalink
initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
alopintsev committed Jun 17, 2021
0 parents commit 9577e1d
Show file tree
Hide file tree
Showing 38 changed files with 1,563 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
gradlew*
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apply plugin: 'java'

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
76 changes: 76 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}

group = 'plus.fort'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'


repositories {
mavenCentral()
}
configurations {
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
dependencies {

implementation group: 'org.apache.sshd', name: 'sshd-core', version: '2.6.0'


implementation 'org.springframework.boot:spring-boot-starter'
implementation 'junit:junit:4.13.1'
implementation 'org.projectlombok:lombok:1.18.18'

compileOnly 'org.projectlombok:lombok:1.18.18'
annotationProcessor 'org.projectlombok:lombok:1.18.18'

testImplementation 'org.springframework.boot:spring-boot-starter-test'


implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-test'

implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'


compile('org.springframework.boot:spring-boot-starter-log4j2')


testImplementation 'org.springframework.boot:spring-boot-starter-test'

implementation 'org.hibernate:hibernate-core:5.4.29.Final'
testImplementation 'org.hibernate:hibernate-core:5.4.29.Final'

implementation group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
testImplementation group: 'org.postgresql', name: 'postgresql', version: '42.1.4'

implementation 'org.jeasy:easy-random-core:5.0.0'

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.2.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.9'


testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')


}
bootJar {
enabled = false
}

jar {
enabled = true
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package plus.fort.itinform.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import plus.fort.itinform.service.InMemoryUserDetailsService;
import plus.fort.itinform.service.UserDetailsService;

@Configuration
public class CredentialsConfiguration {

@Bean
public UserDetailsService userDetailsService() {
return new InMemoryUserDetailsService();
}

// @Bean
// public PasswordEncoder passwordEncoder() {
// return NoOpPasswordEncoder.getInstance();
// }

}
20 changes: 20 additions & 0 deletions library/src/main/java/plus/fort/itinform/domain/CdpRecord.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package plus.fort.itinform.domain;

public class CdpRecord {
public Interface localInterface = new Interface();
public Interface remoteInterface = new Interface();
public String remotePlatform = "";

public boolean isValid() {
return localInterface.name.length() > 0;
}

public String toString() {
return localInterface.device.getName() +
":" + localInterface.getName() +
" - " + remoteInterface.device.getName() +
":" + remoteInterface.getName();
}
}


25 changes: 25 additions & 0 deletions library/src/main/java/plus/fort/itinform/domain/Connection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package plus.fort.itinform.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;

@Entity
@Table(name = "connection")
@Data
@EqualsAndHashCode(of = {"name"})
public class Connection {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@Column(unique = true, nullable = false)
private String name;

public Connection(){}
public Connection(String name) {
this.name = name;
}
}
39 changes: 39 additions & 0 deletions library/src/main/java/plus/fort/itinform/domain/Device.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package plus.fort.itinform.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "Device")
@Data
@EqualsAndHashCode(of = {"name"})
public class Device {
@Id
@GeneratedValue
private Long id;

@Column(name = "device_name", unique = true, nullable = false)
private String name;

@Column(name = "device_address")
private String address;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "device", cascade = {CascadeType.ALL})
@JsonIgnore
private List<Interface> interfaces;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
private DeviceType deviceType;

public Device() {
deviceType = new DeviceType();
}

public String toString() {
return name;
}
}
25 changes: 25 additions & 0 deletions library/src/main/java/plus/fort/itinform/domain/DeviceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package plus.fort.itinform.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;

@Entity
@Table(name = "device_type")
@Data
@EqualsAndHashCode(of = {"name"})
public class DeviceType {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@Column(unique = true, nullable = false)
private String name="-";

public DeviceType() {
}
public DeviceType(String name) {
this.name = name;
}
}
42 changes: 42 additions & 0 deletions library/src/main/java/plus/fort/itinform/domain/Interface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package plus.fort.itinform.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;

@Entity
@Table( name = "Interface" ,
uniqueConstraints=
@UniqueConstraint(columnNames={"device_id", "name"}))
@Data
@EqualsAndHashCode(of = {"name", "device"})
public class Interface {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
@JoinColumn(name = "device_id", foreignKey=@ForeignKey(name="FK_INTERFACE__DEVICE"))
public Device device;// = new Device();

@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
@JoinColumn(name = "connection_id", foreignKey=@ForeignKey(name="FK_INTERFACE__CONNECTION"))
public Connection connection;

@Column(nullable = false)
public String name;

public Interface(){}
public Interface(String name, Device device) {
this.name = name;
this.device = device;
}
public Interface(Interface interf) {
this.name = interf.getName();
this.device = interf.getDevice();
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package plus.fort.itinform.domain;

import lombok.Data;

@Data
public class NetworkDiscoveryRecord {

private Boolean knownHost=false;
private Boolean discoveryFail=false;
private Boolean scanned=false;
private Device device = new Device();

private String failMessage;

public NetworkDiscoveryRecord(String address) {
device.setAddress(address);
}

public NetworkDiscoveryRecord() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package plus.fort.itinform.domain;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class NetworkDiscoveryRecords {

List<NetworkDiscoveryRecord> records;

public NetworkDiscoveryRecords() {
records = new ArrayList<>();
}

public List<NetworkDiscoveryRecord> getRecords() {
return records;
}

public int addRecords(Set<String> records) {
int response=0;
for(String record :records) {
if(!this.records.stream().anyMatch( o -> o.getDevice().getAddress().equals(record))) {
this.records.add(new NetworkDiscoveryRecord(record));
response ++;
}
}
return response;
}
}
Loading

0 comments on commit 9577e1d

Please sign in to comment.