Compare commits

..

No commits in common. 'master' and 'v1.8.0' have entirely different histories.

2
.gitignore vendored

@ -12,5 +12,3 @@ out/
.project
.classpath
.metadata/
**/bin/main/
**/bin/test/

@ -1,4 +1,4 @@
# IEC61850bean
IEC61850bean (previously known as OpenIEC61850) is a library implementing the IEC 61850 standard based on the MMS mapping for client and server communication.
# OpenIEC61850
OpenIEC61850 is a library implementing the IEC 61850 standard based on the MMS mapping for client and server communication.
For detailed information on IEC61850bean visit https://www.beanit.com/iec-61850/.
For detailed information on OpenIEC61850 visit https://www.beanit.com/iec-61850/. OpenIEC61850 has recently been moved from openmuc.org to beanit.com.

@ -1,12 +0,0 @@
#!/bin/bash
cd `dirname $0`
rm ../src/main/java-gen/com/beanit/josistack/internal/acse/asn1/*
asn1bean-compiler -o "../src/main/java-gen/" -p "com.beanit.josistack.internal.acse" -f iso-acse-layer.asn -dv
rm ../src/main/java-gen/com/beanit/josistack/internal/presentation/asn1/*
asn1bean-compiler -o "../src/main/java-gen/" -p "com.beanit.josistack.internal.presentation" -f iso-presentation-layer.asn -dv
rm -r ../src/main/java-gen/com/beanit/iec61850bean/internal/mms/asn1/*
asn1bean-compiler -o "../src/main/java-gen" -p "com.beanit.iec61850bean.internal.mms" -f mms.asn -dv

@ -0,0 +1,7 @@
#!/bin/bash
cd `dirname $0`
rm ../../src/main/java-gen/com/beanit/josistack/internal/acse/asn1/*
jasn1-compiler -o "../../src/main/java-gen/" -p "com.beanit.josistack.internal.acse" -f iso-acse-layer.asn -dv

@ -0,0 +1,6 @@
#!/bin/bash
cd `dirname $0`
rm ../../src/main/java-gen/com/beanit/josistack/internal/presentation/asn1/*.java
jasn1-compiler -o ../../src/main/java-gen/ -p com.beanit.josistack.internal.presentation -f iso-presentation-layer.asn -dv

@ -0,0 +1,7 @@
#!/bin/bash
cd `dirname $0`
rm -r ../../src/main/java-gen/com/beanit/openiec61850/internal/mms/asn1/*
jasn1-compiler -o "../../src/main/java-gen" -p "com.beanit.openiec61850.internal.mms" -f mms.asn -dv

@ -0,0 +1,5 @@
#!/bin/bash
cd `dirname $0`
find ../../ -iname "*.java" | xargs sed -i 's/import com\.beanit\.jasn1\.ber\.types\.BerBoolean/import com\.beanit\.openiec61850\.internal\.BerBoolean/g'

@ -1,10 +0,0 @@
steps to follow:
1) compile classes by executing compile.sh
2) format everything using IntelliJ
3) execute replace-berboolean.sh (this step does not work if step 2
is not executed)
4) again format everyting using IntelliJ

@ -1,6 +0,0 @@
#!/bin/bash
cd `dirname $0`
# replace BerBoolean from ASN1bean with special one for IEC 61850 so that true is coded as 0x01 instead of 0xff
find ../ -iname "*.java" | xargs sed -i 's/import com\.beanit\.asn1bean\.ber\.types\.BerBoolean/import com\.beanit\.iec61850bean\.internal\.BerBoolean/g'

@ -0,0 +1,20 @@
#!/bin/bash
JARS_LOCATION="../../build/libs-all"
MAIN_CLASS="com.beanit.openiec61850.app.ConsoleClient"
SYSPROPS=""
PARAMS=""
SCRIPT_HOME=`dirname $0`
CLASSPATH=$(JARS=("$SCRIPT_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
for i in $@; do
if [[ $i == -D* ]]; then
SYSPROPS="$SYSPROPS $i";
else
PARAMS="$PARAMS $i";
fi
done
java $SYSPROPS -cp $CLASSPATH $MAIN_CLASS $PARAMS

@ -0,0 +1,6 @@
::BATCH file for windows
set BATDIR=%~dp0
set LIBDIR=%BATDIR%..\..\build\libs-all
java -Djava.ext.dirs=%LIBDIR% com.beanit.openiec61850.app.ConsoleClient %*

@ -1,10 +1,11 @@
#!/bin/bash
JARS_LOCATION="build/libs-all"
MAIN_CLASS="com.beanit.iec61850bean.app.ConsoleServer"
JARS_LOCATION="../../build/libs-all"
MAIN_CLASS="com.beanit.openiec61850.app.ConsoleServer"
SYSPROPS="-Dlogback.configurationFile=logback.xml"
# Attempt to set APP_HOME (from Gradle start script)
# from gradle start script:
# Attempt to set SCRIPT_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
@ -18,20 +19,19 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >/dev/null
APP_HOME="`pwd -P`"
cd "`dirname \"$PRG\"`/" >/dev/null
SCRIPT_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$(JARS=("$APP_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
PARAMS=( )
SYSPROPS=( )
for i in "$@"; do
CLASSPATH=$(JARS=("$SCRIPT_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
for i in $@; do
if [[ $i == -D* ]]; then
SYSPROPS+=( "$i" )
SYSPROPS="$SYSPROPS $i";
else
PARAMS+=( "$i" )
PARAMS="$PARAMS $i";
fi
done
java "${SYSPROPS[@]}" -cp "$CLASSPATH" $MAIN_CLASS "${PARAMS[@]}"
java $SYSPROPS -cp $CLASSPATH $MAIN_CLASS $PARAMS

@ -0,0 +1,6 @@
::BATCH file to windows
set BATDIR=%~dp0
set LIBDIR=%BATDIR%..\..\build\libs-all
java -Dlogback.configurationFile=logback.xml -Djava.ext.dirs=%LIBDIR% com.beanit.openiec61850.app.ConsoleServer %*

@ -0,0 +1,39 @@
#!/bin/bash
JARS_LOCATION="../../build/libs-all"
MAIN_CLASS="com.beanit.openiec61850.clientgui.ClientGui"
SYSPROPS=""
PARAMS=""
# from gradle start script:
# Attempt to set SCRIPT_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
SCRIPT_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$(JARS=("$SCRIPT_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
for i in $@; do
if [[ $i == -D* ]]; then
SYSPROPS="$SYSPROPS $i";
else
PARAMS="$PARAMS $i";
fi
done
java $SYSPROPS -cp $CLASSPATH $MAIN_CLASS $PARAMS

@ -0,0 +1,6 @@
::BATCH file to windows
set BATDIR=%~dp0
set LIBDIR=%BATDIR%..\..\build\libs-all
java -Djava.ext.dirs=%LIBDIR% com.beanit.openiec61850.clientgui.ClientGui %*

@ -1,38 +0,0 @@
#!/bin/bash
JARS_LOCATION="build/libs-all"
MAIN_CLASS="com.beanit.iec61850bean.app.ConsoleClient"
SYSPROPS=""
PARAMS=""
# Attempt to set APP_HOME (from Gradle start script)
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$(JARS=("$APP_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
PARAMS=( )
SYSPROPS=( )
for i in "$@"; do
if [[ $i == -D* ]]; then
SYSPROPS+=( "$i" )
else
PARAMS+=( "$i" )
fi
done
java "${SYSPROPS[@]}" -cp "$CLASSPATH" $MAIN_CLASS "${PARAMS[@]}"

@ -1,7 +0,0 @@
::BATCH file to windows
@echo off
set BATDIR=%~dp0
set LIBDIR="%BATDIR%..\build\libs-all\*"
java -cp %LIBDIR% com.beanit.iec61850bean.app.ConsoleClient %*

@ -1,8 +0,0 @@
::BATCH file to windows
@echo off
set BATDIR=%~dp0
set LIBDIR="%BATDIR%..\build\libs-all\*"
java -Dlogback.configurationFile=logback.xml -cp %LIBDIR% com.beanit.iec61850bean.app.ConsoleServer %*

@ -1,38 +0,0 @@
#!/bin/bash
JARS_LOCATION="build/libs-all"
MAIN_CLASS="com.beanit.iec61850bean.clientgui.ClientGui"
SYSPROPS=""
PARAMS=""
# Attempt to set APP_HOME (from Gradle start script)
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$(JARS=("$APP_HOME"/"$JARS_LOCATION"/*.jar); IFS=:; echo "${JARS[*]}")
PARAMS=( )
SYSPROPS=( )
for i in "$@"; do
if [[ $i == -D* ]]; then
SYSPROPS+=( "$i" )
else
PARAMS+=( "$i" )
fi
done
java "${SYSPROPS[@]}" -cp "$CLASSPATH" $MAIN_CLASS "${PARAMS[@]}"

@ -1,7 +0,0 @@
::BATCH file to windows
@echo off
set BATDIR=%~dp0
set LIBDIR="%BATDIR%..\build\libs-all\*"
java -cp %LIBDIR% com.beanit.iec61850bean.clientgui.ClientGui %*

@ -0,0 +1,219 @@
plugins {
id("biz.aQute.bnd.builder") version "4.1.0"
id("com.diffplug.gradle.spotless") version "3.19.0" apply false
id("io.codearte.nexus-staging") version "0.20.0"
}
apply from: "configuration.gradle"
configure(allprojects) {
version = cfgVersion
}
nexusStaging {
packageGroup = cfgGroup
username = cfgRepositoryUser
password = cfgRepositoryPass
stagingProfileId = cfgStagingProfileId
}
configure(javaProjects) {
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "signing"
apply plugin: "biz.aQute.bnd.builder"
apply plugin: "com.diffplug.gradle.spotless"
uploadArchives.enabled = false
group = cfgGroup
if (!project.properties.containsKey('cfgJavaVersion')) {
project.ext {
cfgJavaVersion = '1.8'
}
}
sourceCompatibility = cfgJavaVersion
targetCompatibility = cfgJavaVersion
repositories {
mavenCentral()
mavenLocal()
}
sourceSets {
itest {
compileClasspath += sourceSets.main.runtimeClasspath
}
}
dependencies {
testCompile group: "junit", name: "junit", version: "4.12"
itestCompile group: "junit", name: "junit", version: "4.12"
}
jar {
manifest {
version = project.version.replace("-", ".")
}
}
spotless {
java {
googleJavaFormat()
}
}
tasks.withType(JavaCompile) {
doFirst {
if (sourceCompatibility == '1.7' && System.env.JDK7_HOME != null) {
options.fork = true
options.bootstrapClasspath = files("$System.env.JDK7_HOME/jre/lib/rt.jar")
}
}
}
task jarAll(type: Copy) {
dependsOn(configurations.default.getAllArtifacts().getBuildDependencies())
//only the jar file created:
from configurations.default.getAllArtifacts().getFiles()
if (cfgCopyDependencies) {
if (cfgCopyToRoot) {
into rootDir.getPath() + "/build/libs-all"
} else {
into "build/libs-all"
}
//includes all the dependencies:
from configurations.default
} else {
if (cfgCopyToRoot) {
into rootDir.getPath() + "/build/libs-all"
} else {
into "build/libs-all"
}
}
}
build.dependsOn { jarAll }
eclipse.pathVariables([GRADLE_USER_HOME: file(gradle.gradleUserHomeDir)])
tasks.eclipse.dependsOn(cleanEclipse)
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
javadoc {
exclude "**/internal/**"
exclude "**/java-gen/**"
exclude "**/app/**"
}
}
configure(repositoryProjects) {
uploadArchives.enabled = true
if (cfgSignPom) {
signing {
if (project.hasProperty("signing.keyId")) {
sign configurations.archives
}
}
}
uploadArchives {
repositories {
mavenDeployer {
if (cfgSignPom) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
repository(url: cfgRepository) {
authentication(userName: cfgRepositoryUser, password: cfgRepositoryPass)
if (cfgRepository != null && System.getProperty("https.proxyHost") != null && ((System.getProperty("https.nonProxyHosts") == null) || !cfgRepository.contains(System.getProperty("https.nonProxyHosts")))) {
proxy(host: System.getProperty("https.proxyHost"), port: Integer.parseInt(System.getProperty("https.proxyPort")), type: "https")
}
}
snapshotRepository(url: cfgSnapshotRepository) {
authentication(userName: cfgRepositoryUser, password: cfgRepositoryPass)
if (cfgSnapshotRepository != null && System.getProperty("https.proxyHost") != null && ((System.getProperty("https.nonProxyHosts") == null) || !cfgSnapshotRepository.contains(System.getProperty("https.nonProxyHosts")))) {
proxy(host: System.getProperty("https.proxyHost"), port: Integer.parseInt(System.getProperty("https.proxyPort")), type: "https")
}
}
pom.project {
//additional pom information can be found in subproject build.gradle files
packaging "jar"
url "http://www.beanit.com/"
scm {
url "none"
connection "none"
}
developers {
developer {
id "beanit"
name "Beanit GmbH"
}
}
}
}
}
}
}
task javadocAll(type: Javadoc) {
source docProjects.collect {
project -> project.sourceSets.main.allJava
}
exclude "**/internal/**"
exclude "**/java-gen/**"
exclude "**/app/**"
destinationDir = new File(buildDir, "docs/javadoc-all")
classpath = files(distributionProjects.collect { project ->
project.sourceSets.main.compileClasspath
})
classpath += files(distributionProjects.collect { project ->
project.sourceSets.main.output
})
}
tasks.withType(Tar) {
dependsOn(distributionProjects.build)
dependsOn(javadocAll)
compression = Compression.GZIP
destinationDir = file("build/distributions/")
}
task(tar, type: Tar) {
archiveName = project.name + "-" + project.version + ".tgz"
}

@ -1,317 +0,0 @@
import net.ltgt.gradle.errorprone.errorprone
plugins {
`java-library`
`maven-publish`
signing
eclipse
id("biz.aQute.bnd.builder") version "5.1.1"
id("com.diffplug.spotless") version "5.9.0"
id("io.codearte.nexus-staging") version "0.22.0"
id("net.ltgt.errorprone") version "1.3.0"
}
var cfgJavaVersion = JavaVersion.VERSION_1_8
val sonatypeRepository: String? by project
val sonatypeSnapshotRepository: String? by project
val sonatypeUser: String? by project
val sonatypePass: String? by project
val sonatypeStagingProfileId: String? by project
//----------- project specific configuration start --------------------
val cfgVersion = "1.9.1-SNAPSHOT"
val cfgGroup = "com.beanit"
val cfgCopyToRoot = false
val cfgSignPom = true
val cfgRepository: String? = sonatypeRepository
val cfgSnapshotRepository: String? = sonatypeSnapshotRepository
val cfgRepositoryUser: String? = sonatypeUser
val cfgRepositoryPass: String? = sonatypePass
val cfgStagingProfileId: String? = sonatypeStagingProfileId
val javaProjects: Set<Project> = allprojects
val distributionProjects = javaProjects
val docProjects = javaProjects
val repositoryProjects = javaProjects
val cfgModuleName = "com.beanit.iec61850bean"
tasks.register<Tar>("tar") {
into(project.name) {
from("./") {
include("build.gradle.kts")
include("LICENSE.txt")
include("doc/**")
include("bin/**")
exclude("bin/main/")
exclude("bin/test/")
include("gradle/wrapper/**")
include("gradlew")
include("gradlew.bat")
include("build/libs-all/**")
include("src/**")
include("asn1/**")
}
}
into(project.name + "/doc/") {
from("./build/docs/") {
include("javadoc/**")
}
}
}
//-----java root project configurations
dependencies {
implementation("com.beanit:asn1bean:1.12.0")
implementation("org.slf4j:slf4j-api:1.7.25")
runtimeOnly("ch.qos.logback:logback-classic:1.2.3")
}
project.extra["cfgModuleName"] = "com.beanit.iec61850bean"
tasks["jar"].withConvention(aQute.bnd.gradle.BundleTaskConvention::class) {
bnd("""
Bundle-Name: IEC61850bean
Bundle-SymbolicName: ${project.extra["cfgModuleName"]}
-exportcontents: !*.internal.*,*
Import-Package: com.beanit.asn1bean.*,javax.net,*;resolution:=optional
""")
}
sourceSets {
main {
java {
setSrcDirs(listOf("src/main/java", "src/main/java-gen"))
}
}
}
publishing {
publications {
maybeCreate<MavenPublication>("mavenJava").pom {
name.set("IEC61850bean")
description.set("IEC61850bean is a Java library implementing the IEC 61850 MMS communication standard for clients and servers.")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
//----------- project specific configuration end ---------------------
configure(allprojects) {
version = cfgVersion
group = cfgGroup
}
nexusStaging {
packageGroup = cfgGroup
username = cfgRepositoryUser
password = cfgRepositoryPass
stagingProfileId = cfgStagingProfileId
}
configure(javaProjects) {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "eclipse")
apply(plugin = "biz.aQute.bnd.builder")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "net.ltgt.errorprone")
tasks.publish {
enabled = false
}
repositories {
mavenCentral()
}
java {
sourceCompatibility = cfgJavaVersion
targetCompatibility = cfgJavaVersion
withSourcesJar()
withJavadocJar()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.7.0")
testImplementation("com.tngtech.archunit:archunit-junit5:0.15.0")
errorprone("com.google.errorprone:error_prone_core:2.5.1")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<JavaCompile>().configureEach {
options.errorprone.excludedPaths.set(".*java-gen.*")
if (!JavaVersion.current().isJava9Compatible) {
options.errorprone.isEnabled.set(false)
}
}
afterEvaluate {
tasks.jar {
manifest {
attributes["Automatic-Module-Name"] = project.extra["cfgModuleName"]
}
}
}
spotless {
java {
googleJavaFormat()
}
}
tasks.register<Copy>("jarAll") {
from(configurations.runtimeClasspath) // all runtime dependencies
from(tasks.jar) // the jar file created
if (cfgCopyToRoot) {
into(rootDir.path + "/build/libs-all")
} else {
into("build/libs-all")
}
}
tasks.build {
dependsOn("jarAll")
}
eclipse.pathVariables(mapOf("GRADLE_USER_HOME" to file(gradle.gradleUserHomeDir)))
tasks.eclipse { dependsOn(tasks.cleanEclipse) }
tasks.javadoc {
exclude("**/internal/**")
exclude("**/java-gen/**")
exclude("**/app/**")
//linking Javadoc in version prior 9 does not work well because Javadoc uses html frames.
if (cfgJavaVersion.isJava9Compatible) {
if (cfgJavaVersion.isJava11Compatible) {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/en/java/javase/${cfgJavaVersion.majorVersion}/docs/api/")
} else {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/javase/${cfgJavaVersion.majorVersion}/docs/api/")
}
}
}
}
configure(repositoryProjects) {
tasks.publish {
enabled = true
}
}
configure(repositoryProjects) {
publishing {
publications {
val mvnPublication: MavenPublication = maybeCreate<MavenPublication>("mavenJava")
mvnPublication.from(components["java"])
mvnPublication.versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
mvnPublication.pom {
url.set("http://www.beanit.com/")
developers {
developer {
id.set("beanit")
name.set("Beanit GmbH")
}
}
scm {
connection.set("none")
url.set("none")
}
}
}
repositories {
maven {
val releasesRepoUrl = uri(cfgRepository ?: "")
val snapshotsRepoUrl = uri(cfgSnapshotRepository ?: "")
// val releasesRepoUrl = uri("$buildDir/repos/releases")
// val snapshotsRepoUrl = uri("$buildDir/repos/snapshots")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = cfgRepositoryUser
password = cfgRepositoryPass
}
}
}
}
if (cfgSignPom) {
signing {
sign(publishing.publications["mavenJava"])
}
}
}
tasks.register<Javadoc>("javadocAll") {
source(docProjects.map { project ->
project.sourceSets["main"].allJava
})
exclude("**/internal/**")
exclude("**/java-gen/**")
exclude("**/app/**")
setDestinationDir(File(buildDir, "docs/javadoc-all"))
classpath = files(distributionProjects.map { project ->
project.sourceSets["main"].compileClasspath
})
classpath += files(distributionProjects.map { project ->
project.sourceSets["main"].output
})
//linking Javadoc in version prior 9 does not work well because Javadoc uses html frames.
if (cfgJavaVersion.isJava9Compatible) {
if (cfgJavaVersion.isJava11Compatible) {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/en/java/javase/${cfgJavaVersion.majorVersion}/docs/api/")
} else {
(options as StandardJavadocDocletOptions).links?.add("https://docs.oracle.com/javase/${cfgJavaVersion.majorVersion}/docs/api/")
}
}
}
tasks.named<Tar>("tar") {
archiveFileName.set(project.name + "-" + project.version + ".tgz")
dependsOn(distributionProjects.map { "${it.path}:build" })
distributionProjects.forEach {
println("project: "
+ it.path)
}
dependsOn(tasks.named("javadocAll"))
compression = Compression.GZIP
destinationDirectory.set(File("build/distributions/"))
}

@ -0,0 +1,110 @@
project.ext {
cfgVersion = "1.8.0"
cfgGroup = "com.beanit"
cfgCopyDependencies = true
cfgCopyToRoot = false
cfgSignPom = true
cfgJavaVersion = "1.7"
cfgRepository = project.properties.sonatypeRepository
cfgSnapshotRepository = project.properties.sonatypeSnapshotRepository
cfgRepositoryUser = project.properties.sonatypeUser
cfgRepositoryPass = project.properties.sonatypePass
cfgStagingProfileId = project.properties.sonatypeStagingProfileId
javaProjects = allprojects
distributionProjects = javaProjects
docProjects = javaProjects
repositoryProjects = javaProjects
}
tasks.withType(Tar) {
into(project.name) {
from("./") {
include "build.gradle"
include "configuration.gradle"
include "settings.gradle"
include "LICENSE.txt"
include "doc/**"
include "bin/**"
include "gradle/wrapper/**"
include "gradlew"
include "gradlew.bat"
include "build/libs-all/**"
include "src/**"
include "asn1/**"
}
}
into(project.name + "/doc/") {
from("./build/docs/") {
include "javadoc/**"
}
}
}
//------------------project specific configurations--------------------
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "signing"
def projectName = "OpenIEC61850"
dependencies {
compile group: "org.slf4j", name: "slf4j-api", version: "1.7.25"
compile group: "com.beanit", name: "jasn1", version: "1.11.0"
compile group: "ch.qos.logback", name: "logback-classic", version: "1.2.3"
compile group: "com.toedter", name: "jcalendar", version: "1.4"
}
jar {
bnd("Bundle-Name": "OpenIEC61850",
"Bundle-SymbolicName": "com.beanit.openiec61850",
"-exportcontents": "!*.internal.*,*",
"Import-Package": "com.beanit.jasn1.*,javax.net,*;resolution:=optional")
}
sourceSets {
main {
java.srcDirs = ["src/main/java", "src/main/java-gen"]
}
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name "OpenIEC61850"
description "OpenIEC61850 is a Java library implementing the IEC 61850 MMS communication standard for clients and servers."
licenses {
license {
name "Apache License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0"
distribution "repo"
}
}
}
}
}
}

@ -1,16 +1,3 @@
v1.9.0 30-Jun-2020
--------------------
- renamed OpenIEC61850 to IEC61850bean
- moved from Java 7 to 8
- run scripts support white space in paths
- BdaTimestamp's getters and setters take Instant instead of Date now
- significant code clean up
v1.8.0 22-Mar-2019
--------------------

@ -1,26 +1,27 @@
# IEC61850bean User Guide
# OpenIEC61850 User Guide
* unnumbered toc
{:toc}
## Intro
IEC61850bean (previously known as OpenIEC61850) is a library implementing the IEC 61850 standard based on the MMS mapping for client and server communication. It is licensed under the Apache 2.0 license. IEC61850bean includes a console client and server as well as a GUI client.
OpenIEC61850 is a library implementing the IEC 61850 standard based on the MMS mapping for client and server communication. It is licensed under the Apache 2.0 license. OpenIEC61850 includes a console client and server as well as a GUI client.
### Distribution
After extracting the distribution tar file, the IEC61850bean library can be found in the folder *build/libs-all*.
After extracting the distribution tar file, the OpenIEC61850 library can be found in the folder *build/libs-all*.
#### Dependencies
Besides the IEC61850bean library the folder *build/libs-all/* contains the following external libraries:
Besides the OpenIEC61850 library the folder *build/libs-all/* contains the following external libraries:
* *asn1bean* - the ASN.1 BER encoding/decoding library by beanit, license: Apache 2.0, https://www.beanit.com
* *jasn1* - the ASN.1 BER encoding/decoding library by beanit, license: Apache 2.0, https://www.beanit.com
* *slf4j-api* - a popular logging API. It is only needed if iec61850bean is used to implement a server. The client part does not log anything. License: MIT, http://www.slf4j.org
* *slf4j-api* - a popular logging API. It is only needed if openiec61850 is used to implement a server. The client part does not log anything. License: MIT, http://www.slf4j.org
* *logback-core/logback-classic* - an actual logger implementation of the slf4-api. It is used by the console server application to output log information. It can be replaced by a logger of your choice that supports the slf4j API. Like slf4j it is only needed for server implementations. License: EPLv1.0 and LGPLv2.1, http://logback.qos.ch
* *jcalendar* - a calendar library needed by the client GUI. You don't need this dependency if you don't use the client gui. (C)1999-2011 Kai Toedter, License: LGPLv3, http://toedter.com/jcalendar/
### Console & GUI Applications
@ -29,16 +30,16 @@ You can execute the console client and server through the scripts found in the *
### OSI Stack
The IEC61850bean library includes an OSI stack implementation as it is needed by the IEC 61850 MMS mapping. The API of the OSI stack and the OSI transport layers are made public so that they can be used by other projects.
The OpenIEC61850 library includes an OSI stack implementation as it is needed by the IEC 61850 MMS mapping. The API of the OSI stack and the OSI transport layers are made public so that they can be used by other projects.
* *josistack* - implements the Application Control Service Element (ACSE) protocol as defined by ISO 8650 or ITU X.217/X.227, the lower ISO Presentation Layer as defined by ISO 8823/ITU X226, and the ISO Session Layer as defined by 8327/ITU X.225.
* *jositransport* - implements RFC 1006 and the OSI Transport Service Layer.
## Using IEC61850bean
## Using OpenIEC61850
The easiest way to learn how IEC61850bean works is by running and analyzing the console client and server applications. You might want to look at the source code of the console applications to get an understanding of how they work. They can be used as a basis for you to code your individual client or server applications. An IEC 61850 device that is to be controlled or monitored is called an IEC 61850 server. An IEC 61850 server normally listens on port 102 for incoming connection requests by IEC 61850 clients.
The easiest way to learn how OpenIEC61850 works is by running and analyzing the console client and server applications. You might want to look at the source code of the console applications to get an understanding of how they work. They can be used as a basis for you to code your individual client or server applications. An IEC 61850 device that is to be controlled or monitored is called an IEC 61850 server. An IEC 61850 server normally listens on port 102 for incoming connection requests by IEC 61850 clients.
### Client
@ -52,9 +53,9 @@ First get a List of ServerSaps using the method ServerSap.getSapsFromSclFile().
An IEC 61850 server contains a treelike data model that contains at its leafs the data (integers, boolean, strings etc) that can be accessed by clients. Clients can also retrieve the whole data model from the server.
The upper most model node is called "server". In IEC61850bean it is an object of type ServerModel. The server node contains 1..n logical devices (LD). A logical device may contain 1..n logical nodes (LN). A logical node may contain 1..n data objects. In IEC61850bean the logical nodes do not contain complete data objects but instead contain so called functionally constraint data objects (FCDO). An FCDO is a data object that is split up by functional constraint. An FCDO can contain a combination of other FCDOs, arrays, constructed data attributes and/or basic data attributes.
The upper most model node is called "server". In OpenIEC61850 it is an object of type ServerModel. The server node contains 1..n logical devices (LD). A logical device may contain 1..n logical nodes (LN). A logical node may contain 1..n data objects. In OpenIEC61850 the logical nodes do not contain complete data objects but instead contain so called functionally constraint data objects (FCDO). An FCDO is a data object that is split up by functional constraint. An FCDO can contain a combination of other FCDOs, arrays, constructed data attributes and/or basic data attributes.
All nodes of the server model in IEC61850bean are of one of the following seven types:
All nodes of the server model in OpenIEC61850 are of one of the following seven types:
* ServerModel
* LogicalDevice
@ -66,7 +67,7 @@ All nodes of the server model in IEC61850bean are of one of the following seven
They all implement the ModelNode interface. The nodes FcDataObject, Array, ConstructedDataAttribute and BasicDataAttribute also implement the interface called FcModelNode because they are considered functionally constraint data in the standard. Many of the services of IEC 61850 can only be applied to functionally constraint data (e.g. GetDataValues and SetDataValues).
When programming a client you get a copy of the server model either through ClientAssociation.retrieveModel from the server device or through SclParser.parse from an SCL file. When using the second approach, the model has to be set in the client association using ClientAssociation.setServerModel. When programming a server you get a copy of the server model through the ServerSap.getModelCopy() function.
When programming a client you get a copy of the server model either through ClientAssociation.retrieveModel() or ClientAssociation.getModelFromSclFile(). When programming a server you get a copy of the server model through the ServerSap.getModelCopy() function.
You can then navigate through the model using several functions:
@ -78,6 +79,6 @@ You can then navigate through the model using several functions:
## Modifying and Compiling IEC61850bean
## Modifying and Compiling OpenIEC61850
We use the Gradle build automation tool. The distribution contains a fully functional gradle build file (*build.gradle*). Thus if you changed code and want to rebuild a library you can do it easily with Gradle.

Binary file not shown.

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

53
gradlew vendored

@ -1,21 +1,5 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
@ -44,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@ -82,7 +66,6 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -126,11 +109,10 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@ -156,19 +138,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
i=$((i+1))
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@ -177,9 +159,14 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

22
gradlew.bat vendored

@ -1,19 +1,3 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@ -29,11 +13,8 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@ -84,7 +65,6 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

@ -1,5 +0,0 @@
#Tue Jun 30 15:11:36 CEST 2020
tselLocal=0,0
serverAddress=127.0.0.1
tselRemote=0,1
serverPort=10002

@ -1,18 +0,0 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.string.BerVisibleString;
public class Identifier extends BerVisibleString {
private static final long serialVersionUID = 1L;
public Identifier() {}
public Identifier(byte[] value) {
super(value);
}
}

@ -1,18 +0,0 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.string.BerVisibleString;
public class MMSString extends BerVisibleString {
private static final long serialVersionUID = 1L;
public MMSString() {}
public MMSString(byte[] value) {
super(value);
}
}

@ -1,18 +0,0 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.BerOctetString;
public class TimeOfDay extends BerOctetString {
private static final long serialVersionUID = 1L;
public TimeOfDay() {}
public TimeOfDay(byte[] value) {
super(value);
}
}

@ -1,18 +0,0 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.BerOctetString;
public class UtcTime extends BerOctetString {
private static final long serialVersionUID = 1L;
public UtcTime() {}
public UtcTime(byte[] value) {
super(value);
}
}

@ -1,15 +1,12 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -19,7 +16,7 @@ public class AAREApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerBitString protocolVersion = null;
private BerObjectIdentifier applicationContextName = null;
private AssociateResult result = null;
@ -155,7 +152,6 @@ public class AAREApdu implements BerType, Serializable {
this.userInformation = userInformation;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -163,7 +159,9 @@ public class AAREApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -290,174 +288,160 @@ public class AAREApdu implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new BerBitString();
vByteCount += protocolVersion.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += protocolVersion.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
applicationContextName = new BerObjectIdentifier();
vByteCount += applicationContextName.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
vByteCount += berTag.decode(is);
subCodeLength += applicationContextName.decode(is, true);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
result = new AssociateResult();
vByteCount += result.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
vByteCount += berTag.decode(is);
subCodeLength += result.decode(is, true);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
resultSourceDiagnostic = new AssociateSourceDiagnostic();
vByteCount += resultSourceDiagnostic.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += resultSourceDiagnostic.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
respondingAPTitle = new APTitle();
vByteCount += respondingAPTitle.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingAPTitle.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
respondingAEQualifier = new AEQualifier();
vByteCount += respondingAEQualifier.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingAEQualifier.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
respondingAPInvocationIdentifier = new APInvocationIdentifier();
vByteCount += respondingAPInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
respondingAEInvocationIdentifier = new AEInvocationIdentifier();
vByteCount += respondingAEInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
responderAcseRequirements = new ACSERequirements();
vByteCount += responderAcseRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += responderAcseRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
mechanismName = new MechanismName();
vByteCount += mechanismName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += mechanismName.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 10)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
respondingAuthenticationValue = new AuthenticationValue();
vByteCount += respondingAuthenticationValue.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingAuthenticationValue.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
applicationContextNameList = new ApplicationContextNameList();
vByteCount += applicationContextNameList.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += applicationContextNameList.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) {
implementationInformation = new ImplementationData();
vByteCount += implementationInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += implementationInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation();
vByteCount += userInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -466,7 +450,6 @@ public class AAREApdu implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,15 +1,12 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -19,7 +16,7 @@ public class AARQApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 0);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerBitString protocolVersion = null;
private BerObjectIdentifier applicationContextName = null;
private APTitle calledAPTitle = null;
@ -173,7 +170,6 @@ public class AARQApdu implements BerType, Serializable {
this.userInformation = userInformation;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -181,7 +177,9 @@ public class AARQApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -330,198 +328,182 @@ public class AARQApdu implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new BerBitString();
vByteCount += protocolVersion.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += protocolVersion.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
applicationContextName = new BerObjectIdentifier();
vByteCount += applicationContextName.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += applicationContextName.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
calledAPTitle = new APTitle();
vByteCount += calledAPTitle.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += calledAPTitle.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
calledAEQualifier = new AEQualifier();
vByteCount += calledAEQualifier.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += calledAEQualifier.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
calledAPInvocationIdentifier = new APInvocationIdentifier();
vByteCount += calledAPInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += calledAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
calledAEInvocationIdentifier = new AEInvocationIdentifier();
vByteCount += calledAEInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += calledAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
callingAPTitle = new APTitle();
vByteCount += callingAPTitle.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingAPTitle.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 7)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
callingAEQualifier = new AEQualifier();
vByteCount += callingAEQualifier.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingAEQualifier.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 8)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
callingAPInvocationIdentifier = new APInvocationIdentifier();
vByteCount += callingAPInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingAPInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 9)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
callingAEInvocationIdentifier = new AEInvocationIdentifier();
vByteCount += callingAEInvocationIdentifier.decode(is, true);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingAEInvocationIdentifier.decode(is, true);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
senderAcseRequirements = new ACSERequirements();
vByteCount += senderAcseRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += senderAcseRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
mechanismName = new MechanismName();
vByteCount += mechanismName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += mechanismName.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
vByteCount += length.decode(is);
subCodeLength += length.decode(is);
callingAuthenticationValue = new AuthenticationValue();
vByteCount += callingAuthenticationValue.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingAuthenticationValue.decode(is, null);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
applicationContextNameList = new ApplicationContextNameList();
vByteCount += applicationContextNameList.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += applicationContextNameList.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 29)) {
implementationInformation = new ImplementationData();
vByteCount += implementationInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += implementationInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation();
vByteCount += userInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -530,7 +512,6 @@ public class AARQApdu implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class ACSEApdu implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AARQApdu aarq = null;
private AAREApdu aare = null;
private RLRQApdu rlrq = null;
@ -60,11 +57,12 @@ public class ACSEApdu implements BerType, Serializable {
this.rlre = rlre;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -92,46 +90,45 @@ public class ACSEApdu implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(AARQApdu.tag)) {
aarq = new AARQApdu();
tlvByteCount += aarq.decode(is, false);
return tlvByteCount;
codeLength += aarq.decode(is, false);
return codeLength;
}
if (berTag.equals(AAREApdu.tag)) {
aare = new AAREApdu();
tlvByteCount += aare.decode(is, false);
return tlvByteCount;
codeLength += aare.decode(is, false);
return codeLength;
}
if (berTag.equals(RLRQApdu.tag)) {
rlrq = new RLRQApdu();
tlvByteCount += rlrq.decode(is, false);
return tlvByteCount;
codeLength += rlrq.decode(is, false);
return codeLength;
}
if (berTag.equals(RLREApdu.tag)) {
rlre = new RLREApdu();
tlvByteCount += rlre.decode(is, false);
return tlvByteCount;
codeLength += rlre.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -144,7 +141,6 @@ public class ACSEApdu implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerBitString;
public class ACSERequirements extends BerBitString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class AEInvocationIdentifier extends BerInteger {

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class AEQualifier implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AEQualifierForm2 aeQualifierForm2 = null;
public AEQualifier() {}
@ -33,11 +30,12 @@ public class AEQualifier implements BerType, Serializable {
this.aeQualifierForm2 = aeQualifierForm2;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -50,28 +48,27 @@ public class AEQualifier implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(AEQualifierForm2.tag)) {
aeQualifierForm2 = new AEQualifierForm2();
tlvByteCount += aeQualifierForm2.decode(is, false);
return tlvByteCount;
codeLength += aeQualifierForm2.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -84,7 +81,6 @@ public class AEQualifier implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class AEQualifierForm2 extends BerInteger {

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class AETitle implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AETitleForm2 aeTitleForm2 = null;
public AETitle() {}
@ -33,11 +30,12 @@ public class AETitle implements BerType, Serializable {
this.aeTitleForm2 = aeTitleForm2;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -50,28 +48,27 @@ public class AETitle implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(AETitleForm2.tag)) {
aeTitleForm2 = new AETitleForm2();
tlvByteCount += aeTitleForm2.decode(is, false);
return tlvByteCount;
codeLength += aeTitleForm2.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -84,7 +81,6 @@ public class AETitle implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class AETitleForm2 extends BerObjectIdentifier {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class APInvocationIdentifier extends BerInteger {

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class APTitle implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private APTitleForm2 apTitleForm2 = null;
public APTitle() {}
@ -33,11 +30,12 @@ public class APTitle implements BerType, Serializable {
this.apTitleForm2 = apTitleForm2;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -50,28 +48,27 @@ public class APTitle implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(APTitleForm2.tag)) {
apTitleForm2 = new APTitleForm2();
tlvByteCount += apTitleForm2.decode(is, false);
return tlvByteCount;
codeLength += apTitleForm2.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -84,7 +81,6 @@ public class APTitle implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class APTitleForm2 extends BerObjectIdentifier {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class ApplicationContextName extends BerObjectIdentifier {

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class ApplicationContextNameList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<ApplicationContextName> seqOf = null;
public ApplicationContextNameList() {
@ -38,7 +35,6 @@ public class ApplicationContextNameList implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -46,7 +42,9 @@ public class ApplicationContextNameList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -67,46 +65,36 @@ public class ApplicationContextNameList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
int totalLength = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(ApplicationContextName.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
ApplicationContextName element = new ApplicationContextName();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -115,7 +103,6 @@ public class ApplicationContextNameList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class AssociateResult extends BerInteger {

@ -1,14 +1,11 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -18,7 +15,7 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerInteger acseServiceUser = null;
private BerInteger acseServiceProvider = null;
@ -44,11 +41,12 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
this.acseServiceProvider = acseServiceProvider;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -78,40 +76,35 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
acseServiceUser = new BerInteger();
tlvByteCount += acseServiceUser.decode(is, true);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += acseServiceUser.decode(is, true);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
acseServiceProvider = new BerInteger();
tlvByteCount += acseServiceProvider.decode(is, true);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += acseServiceProvider.decode(is, true);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -124,7 +117,6 @@ public class AssociateSourceDiagnostic implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class AssociationInformation implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<Myexternal> seqOf = null;
public AssociationInformation() {
@ -38,7 +35,6 @@ public class AssociationInformation implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -46,7 +42,9 @@ public class AssociationInformation implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -67,46 +65,36 @@ public class AssociationInformation implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
int totalLength = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(Myexternal.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
Myexternal element = new Myexternal();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -115,7 +103,6 @@ public class AssociationInformation implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,14 +1,11 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.asn1bean.ber.types.string.BerGraphicString;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerType;
import com.beanit.jasn1.ber.types.string.BerGraphicString;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -18,7 +15,7 @@ public class AuthenticationValue implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerGraphicString charstring = null;
private BerBitString bitstring = null;
private Myexternal2 external = null;
@ -53,11 +50,12 @@ public class AuthenticationValue implements BerType, Serializable {
this.external = external;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -89,40 +87,39 @@ public class AuthenticationValue implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
charstring = new BerGraphicString();
tlvByteCount += charstring.decode(is, false);
return tlvByteCount;
codeLength += charstring.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
bitstring = new BerBitString();
tlvByteCount += bitstring.decode(is, false);
return tlvByteCount;
codeLength += bitstring.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
external = new Myexternal2();
tlvByteCount += external.decode(is, false);
return tlvByteCount;
codeLength += external.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -135,7 +132,6 @@ public class AuthenticationValue implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.string.BerGraphicString;
import com.beanit.jasn1.ber.types.string.BerGraphicString;
public class ImplementationData extends BerGraphicString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class MechanismName extends BerObjectIdentifier {

@ -1,18 +1,15 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -22,7 +19,7 @@ public class Myexternal implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerObjectIdentifier directReference = null;
private BerInteger indirectReference = null;
private Encoding encoding = null;
@ -57,7 +54,6 @@ public class Myexternal implements BerType, Serializable {
this.encoding = encoding;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -65,7 +61,9 @@ public class Myexternal implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -92,59 +90,48 @@ public class Myexternal implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) {
directReference = new BerObjectIdentifier();
vByteCount += directReference.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += directReference.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerInteger.tag)) {
indirectReference = new BerInteger();
vByteCount += indirectReference.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += indirectReference.decode(is, false);
subCodeLength += berTag.decode(is);
}
encoding = new Encoding();
numDecodedBytes = encoding.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
subCodeLength += encoding.decode(is, berTag);
if (subCodeLength == totalLength) {
return codeLength;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -153,7 +140,6 @@ public class Myexternal implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -208,7 +194,7 @@ public class Myexternal implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null;
private BerBitString arbitrary = null;
@ -243,11 +229,12 @@ public class Myexternal implements BerType, Serializable {
this.arbitrary = arbitrary;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -283,43 +270,40 @@ public class Myexternal implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
singleASN1Type = new BerAny();
tlvByteCount += singleASN1Type.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += singleASN1Type.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString();
tlvByteCount += octetAligned.decode(is, false);
return tlvByteCount;
codeLength += octetAligned.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString();
tlvByteCount += arbitrary.decode(is, false);
return tlvByteCount;
codeLength += arbitrary.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -332,7 +316,6 @@ public class Myexternal implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,18 +1,15 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -22,7 +19,7 @@ public class Myexternal2 implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 8);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerObjectIdentifier directReference = null;
private BerInteger indirectReference = null;
private Encoding encoding = null;
@ -57,7 +54,6 @@ public class Myexternal2 implements BerType, Serializable {
this.encoding = encoding;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -65,7 +61,9 @@ public class Myexternal2 implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -92,59 +90,48 @@ public class Myexternal2 implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) {
directReference = new BerObjectIdentifier();
vByteCount += directReference.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += directReference.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerInteger.tag)) {
indirectReference = new BerInteger();
vByteCount += indirectReference.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += indirectReference.decode(is, false);
subCodeLength += berTag.decode(is);
}
encoding = new Encoding();
numDecodedBytes = encoding.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
subCodeLength += encoding.decode(is, berTag);
if (subCodeLength == totalLength) {
return codeLength;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -153,7 +140,6 @@ public class Myexternal2 implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -208,7 +194,7 @@ public class Myexternal2 implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null;
private BerBitString arbitrary = null;
@ -243,11 +229,12 @@ public class Myexternal2 implements BerType, Serializable {
this.arbitrary = arbitrary;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -283,43 +270,40 @@ public class Myexternal2 implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
singleASN1Type = new BerAny();
tlvByteCount += singleASN1Type.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += singleASN1Type.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString();
tlvByteCount += octetAligned.decode(is, false);
return tlvByteCount;
codeLength += octetAligned.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString();
tlvByteCount += arbitrary.decode(is, false);
return tlvByteCount;
codeLength += arbitrary.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -332,7 +316,6 @@ public class Myexternal2 implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public final class OidValues {
public static final BerObjectIdentifier aCSEId =

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class RLREApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 3);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ReleaseResponseReason reason = null;
private AssociationInformation userInformation = null;
@ -43,7 +40,6 @@ public class RLREApdu implements BerType, Serializable {
this.userInformation = userInformation;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class RLREApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -82,56 +80,50 @@ public class RLREApdu implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
if (lengthVal == 0) {
return tlByteCount;
}
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
if (totalLength == 0) {
return codeLength;
}
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
reason = new ReleaseResponseReason();
vByteCount += reason.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += reason.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation();
vByteCount += userInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -140,7 +132,6 @@ public class RLREApdu implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class RLRQApdu implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 2);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ReleaseRequestReason reason = null;
private AssociationInformation userInformation = null;
@ -43,7 +40,6 @@ public class RLRQApdu implements BerType, Serializable {
this.userInformation = userInformation;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class RLRQApdu implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -82,56 +80,50 @@ public class RLRQApdu implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
if (lengthVal == 0) {
return tlByteCount;
}
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
if (totalLength == 0) {
return codeLength;
}
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
reason = new ReleaseRequestReason();
vByteCount += reason.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += reason.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 30)) {
userInformation = new AssociationInformation();
vByteCount += userInformation.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userInformation.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -140,7 +132,6 @@ public class RLRQApdu implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class ReleaseRequestReason extends BerInteger {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.acse.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class ReleaseResponseReason extends BerInteger {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class AbstractSyntaxName extends BerObjectIdentifier {

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class CPAPPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ModeSelector modeSelector = null;
private NormalModeParameters normalModeParameters = null;
@ -43,7 +40,6 @@ public class CPAPPDU implements BerType, Serializable {
this.normalModeParameters = normalModeParameters;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class CPAPPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -80,47 +78,43 @@ public class CPAPPDU implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
modeSelector = new ModeSelector();
vByteCount += modeSelector.decode(is, false);
subCodeLength += modeSelector.decode(is, false);
} else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
normalModeParameters = new NormalModeParameters();
vByteCount += normalModeParameters.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
subCodeLength += normalModeParameters.decode(is, false);
}
}
if (vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Length of set does not match length tag, length tag: "
+ lengthVal
+ totalLength
+ ", actual set length: "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -129,7 +123,6 @@ public class CPAPPDU implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -170,7 +163,7 @@ public class CPAPPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ProtocolVersion protocolVersion = null;
private RespondingPresentationSelector respondingPresentationSelector = null;
private PresentationContextDefinitionResultList presentationContextDefinitionResultList = null;
@ -234,7 +227,6 @@ public class CPAPPDU implements BerType, Serializable {
this.userData = userData;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -242,7 +234,9 @@ public class CPAPPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -298,98 +292,85 @@ public class CPAPPDU implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
if (lengthVal == 0) {
return tlByteCount;
}
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
if (totalLength == 0) {
return codeLength;
}
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new ProtocolVersion();
vByteCount += protocolVersion.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += protocolVersion.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
respondingPresentationSelector = new RespondingPresentationSelector();
vByteCount += respondingPresentationSelector.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += respondingPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
presentationContextDefinitionResultList = new PresentationContextDefinitionResultList();
vByteCount += presentationContextDefinitionResultList.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += presentationContextDefinitionResultList.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
presentationRequirements = new PresentationRequirements();
vByteCount += presentationRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += presentationRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
userSessionRequirements = new UserSessionRequirements();
vByteCount += userSessionRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userSessionRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
userData = new UserData();
numDecodedBytes = userData.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
userData = null;
int choiceDecodeLength = userData.decode(is, berTag);
subCodeLength += choiceDecodeLength;
if (subCodeLength == totalLength) {
return codeLength;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -398,7 +379,6 @@ public class CPAPPDU implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class CPType implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ModeSelector modeSelector = null;
private NormalModeParameters normalModeParameters = null;
@ -43,7 +40,6 @@ public class CPType implements BerType, Serializable {
this.normalModeParameters = normalModeParameters;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class CPType implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -80,47 +78,43 @@ public class CPType implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
modeSelector = new ModeSelector();
vByteCount += modeSelector.decode(is, false);
subCodeLength += modeSelector.decode(is, false);
} else if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
normalModeParameters = new NormalModeParameters();
vByteCount += normalModeParameters.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
subCodeLength += normalModeParameters.decode(is, false);
}
}
if (vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Length of set does not match length tag, length tag: "
+ lengthVal
+ totalLength
+ ", actual set length: "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -129,7 +123,6 @@ public class CPType implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -170,7 +163,7 @@ public class CPType implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private ProtocolVersion protocolVersion = null;
private CallingPresentationSelector callingPresentationSelector = null;
private CalledPresentationSelector calledPresentationSelector = null;
@ -253,7 +246,6 @@ public class CPType implements BerType, Serializable {
this.userData = userData;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -261,7 +253,9 @@ public class CPType implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -331,116 +325,103 @@ public class CPType implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
if (lengthVal == 0) {
return tlByteCount;
}
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
if (totalLength == 0) {
return codeLength;
}
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
protocolVersion = new ProtocolVersion();
vByteCount += protocolVersion.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += protocolVersion.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
callingPresentationSelector = new CallingPresentationSelector();
vByteCount += callingPresentationSelector.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += callingPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
calledPresentationSelector = new CalledPresentationSelector();
vByteCount += calledPresentationSelector.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += calledPresentationSelector.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
presentationContextDefinitionList = new PresentationContextDefinitionList();
vByteCount += presentationContextDefinitionList.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += presentationContextDefinitionList.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
defaultContextName = new DefaultContextName();
vByteCount += defaultContextName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += defaultContextName.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
presentationRequirements = new PresentationRequirements();
vByteCount += presentationRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += presentationRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
userSessionRequirements = new UserSessionRequirements();
vByteCount += userSessionRequirements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += userSessionRequirements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
userData = new UserData();
numDecodedBytes = userData.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
userData = null;
int choiceDecodeLength = userData.decode(is, berTag);
subCodeLength += choiceDecodeLength;
if (subCodeLength == totalLength) {
return codeLength;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -449,7 +430,6 @@ public class CPType implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,7 +1,4 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
public class CalledPresentationSelector extends PresentationSelector {

@ -1,7 +1,4 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
public class CallingPresentationSelector extends PresentationSelector {

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<SEQUENCE> seqOf = null;
public ContextList() {
@ -38,7 +35,6 @@ public class ContextList implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -46,7 +42,9 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -67,46 +65,36 @@ public class ContextList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(SEQUENCE.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
SEQUENCE element = new SEQUENCE();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -115,7 +103,6 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -155,7 +142,7 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private PresentationContextIdentifier presentationContextIdentifier = null;
private AbstractSyntaxName abstractSyntaxName = null;
private TransferSyntaxNameList transferSyntaxNameList = null;
@ -191,7 +178,6 @@ public class ContextList implements BerType, Serializable {
this.transferSyntaxNameList = transferSyntaxNameList;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -199,7 +185,9 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -222,65 +210,54 @@ public class ContextList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(PresentationContextIdentifier.tag)) {
presentationContextIdentifier = new PresentationContextIdentifier();
vByteCount += presentationContextIdentifier.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += presentationContextIdentifier.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(AbstractSyntaxName.tag)) {
abstractSyntaxName = new AbstractSyntaxName();
vByteCount += abstractSyntaxName.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += abstractSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(TransferSyntaxNameList.tag)) {
transferSyntaxNameList = new TransferSyntaxNameList();
vByteCount += transferSyntaxNameList.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += transferSyntaxNameList.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -289,7 +266,6 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -341,7 +317,7 @@ public class ContextList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<TransferSyntaxName> seqOf = null;
public TransferSyntaxNameList() {
@ -359,7 +335,6 @@ public class ContextList implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -367,7 +342,9 @@ public class ContextList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -388,46 +365,36 @@ public class ContextList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
int totalLength = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(TransferSyntaxName.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
TransferSyntaxName element = new TransferSyntaxName();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -437,7 +404,6 @@ public class ContextList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class DefaultContextName implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AbstractSyntaxName abstractSyntaxName = null;
private TransferSyntaxName transferSyntaxName = null;
@ -43,7 +40,6 @@ public class DefaultContextName implements BerType, Serializable {
this.transferSyntaxName = transferSyntaxName;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class DefaultContextName implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -78,54 +76,46 @@ public class DefaultContextName implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
abstractSyntaxName = new AbstractSyntaxName();
vByteCount += abstractSyntaxName.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += abstractSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
transferSyntaxName = new TransferSyntaxName();
vByteCount += transferSyntaxName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += transferSyntaxName.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -134,7 +124,6 @@ public class DefaultContextName implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class FullyEncodedData implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<PDVList> seqOf = null;
public FullyEncodedData() {
@ -38,7 +35,6 @@ public class FullyEncodedData implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -46,7 +42,9 @@ public class FullyEncodedData implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -67,46 +65,36 @@ public class FullyEncodedData implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
int totalLength = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(PDVList.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
PDVList element = new PDVList();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -115,7 +103,6 @@ public class FullyEncodedData implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,14 +1,11 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -18,7 +15,7 @@ public class ModeSelector implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerInteger modeValue = null;
public ModeSelector() {}
@ -35,7 +32,6 @@ public class ModeSelector implements BerType, Serializable {
this.modeValue = modeValue;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -43,7 +39,9 @@ public class ModeSelector implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -65,44 +63,40 @@ public class ModeSelector implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
codeLength += length.decode(is);
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
modeValue = new BerInteger();
vByteCount += modeValue.decode(is, false);
} else if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
} else {
throw new IOException("Tag does not match any set component: " + berTag);
subCodeLength += modeValue.decode(is, false);
}
}
if (vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Length of set does not match length tag, length tag: "
+ lengthVal
+ totalLength
+ ", actual set length: "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -111,7 +105,6 @@ public class ModeSelector implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,16 +1,13 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerAny;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerAny;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class PDVList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private TransferSyntaxName transferSyntaxName = null;
private PresentationContextIdentifier presentationContextIdentifier = null;
private PresentationDataValues presentationDataValues = null;
@ -56,7 +53,6 @@ public class PDVList implements BerType, Serializable {
this.presentationDataValues = presentationDataValues;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -64,7 +60,9 @@ public class PDVList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -89,61 +87,50 @@ public class PDVList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(TransferSyntaxName.tag)) {
transferSyntaxName = new TransferSyntaxName();
vByteCount += transferSyntaxName.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += transferSyntaxName.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(PresentationContextIdentifier.tag)) {
presentationContextIdentifier = new PresentationContextIdentifier();
vByteCount += presentationContextIdentifier.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += presentationContextIdentifier.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
presentationDataValues = new PresentationDataValues();
numDecodedBytes = presentationDataValues.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
subCodeLength += presentationDataValues.decode(is, berTag);
if (subCodeLength == totalLength) {
return codeLength;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -152,7 +139,6 @@ public class PDVList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -206,7 +192,7 @@ public class PDVList implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BerAny singleASN1Type = null;
private BerOctetString octetAligned = null;
private BerBitString arbitrary = null;
@ -241,11 +227,12 @@ public class PDVList implements BerType, Serializable {
this.arbitrary = arbitrary;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -281,43 +268,40 @@ public class PDVList implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
singleASN1Type = new BerAny();
tlvByteCount += singleASN1Type.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += singleASN1Type.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
octetAligned = new BerOctetString();
tlvByteCount += octetAligned.decode(is, false);
return tlvByteCount;
codeLength += octetAligned.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
arbitrary = new BerBitString();
tlvByteCount += arbitrary.decode(is, false);
return tlvByteCount;
codeLength += arbitrary.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -330,7 +314,6 @@ public class PDVList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,7 +1,4 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
public class PresentationContextDefinitionList extends ContextList {

@ -1,7 +1,4 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
public class PresentationContextDefinitionResultList extends ResultList {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class PresentationContextIdentifier extends BerInteger {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerBitString;
public class PresentationRequirements extends BerBitString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerOctetString;
public class PresentationSelector extends BerOctetString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerBitString;
public class ProtocolVersion extends BerBitString {

@ -1,7 +1,4 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
public class RespondingPresentationSelector extends PresentationSelector {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerInteger;
import java.math.BigInteger;
public class Result extends BerInteger {

@ -1,14 +1,11 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -21,7 +18,7 @@ public class ResultList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<SEQUENCE> seqOf = null;
public ResultList() {
@ -39,7 +36,6 @@ public class ResultList implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -47,7 +43,9 @@ public class ResultList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -68,46 +66,36 @@ public class ResultList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(SEQUENCE.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
while (subCodeLength < totalLength) {
SEQUENCE element = new SEQUENCE();
vByteCount += element.decode(is, false);
subCodeLength += element.decode(is, true);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -116,7 +104,6 @@ public class ResultList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -156,7 +143,7 @@ public class ResultList implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Result result = null;
private TransferSyntaxName transferSyntaxName = null;
private BerInteger providerReason = null;
@ -191,7 +178,6 @@ public class ResultList implements BerType, Serializable {
this.providerReason = providerReason;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -199,7 +185,9 @@ public class ResultList implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -235,67 +223,58 @@ public class ResultList implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
result = new Result();
vByteCount += result.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += result.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
transferSyntaxName = new TransferSyntaxName();
vByteCount += transferSyntaxName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += transferSyntaxName.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
providerReason = new BerInteger();
vByteCount += providerReason.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += providerReason.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -304,7 +283,6 @@ public class ResultList implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerOctetString;
public class SimplyEncodedData extends BerOctetString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerObjectIdentifier;
import com.beanit.jasn1.ber.types.BerObjectIdentifier;
public class TransferSyntaxName extends BerObjectIdentifier {

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class UserData implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private SimplyEncodedData simplyEncodedData = null;
private FullyEncodedData fullyEncodedData = null;
@ -42,11 +39,12 @@ public class UserData implements BerType, Serializable {
this.fullyEncodedData = fullyEncodedData;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -70,34 +68,33 @@ public class UserData implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.PRIMITIVE, 0)) {
simplyEncodedData = new SimplyEncodedData();
tlvByteCount += simplyEncodedData.decode(is, false);
return tlvByteCount;
codeLength += simplyEncodedData.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1)) {
fullyEncodedData = new FullyEncodedData();
tlvByteCount += fullyEncodedData.decode(is, false);
return tlvByteCount;
codeLength += fullyEncodedData.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -110,7 +107,6 @@ public class UserData implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.josistack.internal.presentation.asn1;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerBitString;
public class UserSessionRequirements extends BerBitString {

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class AccessResult implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private DataAccessError failure = null;
private Data success = null;
@ -42,11 +39,12 @@ public class AccessResult implements BerType, Serializable {
this.success = success;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -67,38 +65,35 @@ public class AccessResult implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
int numDecodedBytes;
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
failure = new DataAccessError();
tlvByteCount += failure.decode(is, false);
return tlvByteCount;
codeLength += failure.decode(is, false);
return codeLength;
}
success = new Data();
numDecodedBytes = success.decode(is, berTag);
if (numDecodedBytes != 0) {
return tlvByteCount + numDecodedBytes;
int choiceDecodeLength = success.decode(is, berTag);
if (choiceDecodeLength != 0) {
return codeLength + choiceDecodeLength;
} else {
success = null;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -111,7 +106,6 @@ public class AccessResult implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -20,7 +17,7 @@ public class AlternateAccess implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<CHOICE> seqOf = null;
public AlternateAccess() {
@ -38,7 +35,6 @@ public class AlternateAccess implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -46,7 +42,9 @@ public class AlternateAccess implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -67,48 +65,36 @@ public class AlternateAccess implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
codeLength += length.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
CHOICE element = new CHOICE();
numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
subCodeLength += element.decode(is, null);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -117,7 +103,6 @@ public class AlternateAccess implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -157,7 +142,7 @@ public class AlternateAccess implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AlternateAccessSelection unnamed = null;
public CHOICE() {}
@ -174,11 +159,12 @@ public class AlternateAccess implements BerType, Serializable {
this.unnamed = unnamed;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -191,32 +177,29 @@ public class AlternateAccess implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
int numDecodedBytes;
unnamed = new AlternateAccessSelection();
numDecodedBytes = unnamed.decode(is, berTag);
if (numDecodedBytes != 0) {
return tlvByteCount + numDecodedBytes;
int choiceDecodeLength = unnamed.decode(is, berTag);
if (choiceDecodeLength != 0) {
return codeLength + choiceDecodeLength;
} else {
unnamed = null;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -229,7 +212,6 @@ public class AlternateAccess implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,14 +1,11 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerNull;
import com.beanit.asn1bean.ber.types.BerType;
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerNull;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -18,7 +15,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private SelectAlternateAccess selectAlternateAccess = null;
private SelectAccess selectAccess = null;
@ -44,11 +41,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.selectAccess = selectAccess;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -69,38 +67,35 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
int numDecodedBytes;
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
selectAlternateAccess = new SelectAlternateAccess();
tlvByteCount += selectAlternateAccess.decode(is, false);
return tlvByteCount;
codeLength += selectAlternateAccess.decode(is, false);
return codeLength;
}
selectAccess = new SelectAccess();
numDecodedBytes = selectAccess.decode(is, berTag);
if (numDecodedBytes != 0) {
return tlvByteCount + numDecodedBytes;
int choiceDecodeLength = selectAccess.decode(is, berTag);
if (choiceDecodeLength != 0) {
return codeLength + choiceDecodeLength;
} else {
selectAccess = null;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -113,7 +108,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -141,7 +135,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private AccessSelection accessSelection = null;
private AlternateAccess alternateAccess = null;
@ -167,7 +161,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.alternateAccess = alternateAccess;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -175,7 +168,9 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -196,58 +191,42 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
accessSelection = new AccessSelection();
numDecodedBytes = accessSelection.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
subCodeLength += accessSelection.decode(is, berTag);
subCodeLength += berTag.decode(is);
if (berTag.equals(AlternateAccess.tag)) {
alternateAccess = new AlternateAccess();
vByteCount += alternateAccess.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
subCodeLength += alternateAccess.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -256,7 +235,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -299,7 +277,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Component component = null;
private Unsigned32 index = null;
private IndexRange indexRange = null;
@ -343,11 +321,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.allElements = allElements;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -391,49 +370,46 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
component = new Component();
tlvByteCount += component.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += component.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
index = new Unsigned32();
tlvByteCount += index.decode(is, false);
return tlvByteCount;
codeLength += index.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
indexRange = new IndexRange();
tlvByteCount += indexRange.decode(is, false);
return tlvByteCount;
codeLength += indexRange.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
allElements = new BerNull();
tlvByteCount += allElements.decode(is, false);
return tlvByteCount;
codeLength += allElements.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -447,7 +423,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -485,7 +460,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BasicIdentifier basic = null;
public Component() {}
@ -502,11 +477,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.basic = basic;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -519,28 +495,27 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BasicIdentifier.tag)) {
basic = new BasicIdentifier();
tlvByteCount += basic.decode(is, false);
return tlvByteCount;
codeLength += basic.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -554,7 +529,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -576,7 +550,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Unsigned32 lowIndex = null;
private Unsigned32 numberOfElements = null;
@ -602,7 +576,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.numberOfElements = numberOfElements;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -610,7 +583,9 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -637,57 +612,46 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
lowIndex = new Unsigned32();
vByteCount += lowIndex.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += lowIndex.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
numberOfElements = new Unsigned32();
vByteCount += numberOfElements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
subCodeLength += numberOfElements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -697,7 +661,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -741,7 +704,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Component component = null;
private Unsigned32 index = null;
private IndexRange indexRange = null;
@ -785,11 +748,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.allElements = allElements;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -833,49 +797,46 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
component = new Component();
tlvByteCount += component.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += component.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
index = new Unsigned32();
tlvByteCount += index.decode(is, false);
return tlvByteCount;
codeLength += index.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
indexRange = new IndexRange();
tlvByteCount += indexRange.decode(is, false);
return tlvByteCount;
codeLength += indexRange.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
allElements = new BerNull();
tlvByteCount += allElements.decode(is, false);
return tlvByteCount;
codeLength += allElements.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -888,7 +849,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -926,7 +886,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private BasicIdentifier basic = null;
public Component() {}
@ -943,11 +903,12 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.basic = basic;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -960,28 +921,27 @@ public class AlternateAccessSelection implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BasicIdentifier.tag)) {
basic = new BasicIdentifier();
tlvByteCount += basic.decode(is, false);
return tlvByteCount;
codeLength += basic.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -995,7 +955,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -1017,7 +976,7 @@ public class AlternateAccessSelection implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Unsigned32 lowIndex = null;
private Unsigned32 numberOfElements = null;
@ -1043,7 +1002,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
this.numberOfElements = numberOfElements;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -1051,7 +1009,9 @@ public class AlternateAccessSelection implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -1078,57 +1038,46 @@ public class AlternateAccessSelection implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
lowIndex = new Unsigned32();
vByteCount += lowIndex.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += lowIndex.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
numberOfElements = new Unsigned32();
vByteCount += numberOfElements.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
subCodeLength += numberOfElements.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: "
+ lengthVal
+ ", bytes decoded: "
+ vByteCount);
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -1138,7 +1087,6 @@ public class AlternateAccessSelection implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.string.BerVisibleString;
import com.beanit.jasn1.ber.types.string.BerVisibleString;
public class BasicIdentifier extends BerVisibleString {

@ -1,10 +1,7 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.types.BerNull;
import com.beanit.jasn1.ber.types.BerNull;
public class ConcludeRequestPDU extends BerNull {

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Unsigned32 invokeID = null;
private Unsigned32 modifierPosition = null;
private ServiceError serviceError = null;
@ -52,7 +49,6 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
this.serviceError = serviceError;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -60,7 +56,9 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -94,60 +92,52 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
invokeID = new Unsigned32();
vByteCount += invokeID.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += invokeID.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
modifierPosition = new Unsigned32();
vByteCount += modifierPosition.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += modifierPosition.decode(is, false);
subCodeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
serviceError = new ServiceError();
vByteCount += serviceError.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
subCodeLength += serviceError.decode(is, false);
if (subCodeLength == totalLength) {
return codeLength;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -156,7 +146,6 @@ public class ConfirmedErrorPDU implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Unsigned32 invokeID = null;
private ConfirmedServiceRequest service = null;
@ -43,7 +40,6 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
this.service = service;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -72,55 +70,44 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(Unsigned32.tag)) {
invokeID = new Unsigned32();
vByteCount += invokeID.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += invokeID.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
service = new ConfirmedServiceRequest();
numDecodedBytes = service.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
subCodeLength += service.decode(is, berTag);
if (subCodeLength == totalLength) {
return codeLength;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -129,7 +116,6 @@ public class ConfirmedRequestPDU implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Unsigned32 invokeID = null;
private ConfirmedServiceResponse service = null;
@ -43,7 +40,6 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
this.service = service;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -51,7 +47,9 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -72,55 +70,44 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
int codeLength = 0;
int subCodeLength = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
codeLength += length.decode(is);
int totalLength = length.val;
codeLength += totalLength;
subCodeLength += berTag.decode(is);
if (berTag.equals(Unsigned32.tag)) {
invokeID = new Unsigned32();
vByteCount += invokeID.decode(is, false);
vByteCount += berTag.decode(is);
subCodeLength += invokeID.decode(is, false);
subCodeLength += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
throw new IOException("Tag does not match the mandatory sequence element tag.");
}
service = new ConfirmedServiceResponse();
numDecodedBytes = service.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
} else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
subCodeLength += service.decode(is, berTag);
if (subCodeLength == totalLength) {
return codeLength;
}
throw new IOException(
"Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
"Unexpected end of sequence, length tag: "
+ totalLength
+ ", actual sequence length: "
+ subCodeLength);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -129,7 +116,6 @@ public class ConfirmedResponsePDU implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,13 +1,10 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -17,7 +14,7 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private GetNameListRequest getNameList = null;
private ReadRequest read = null;
private WriteRequest write = null;
@ -135,11 +132,12 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
this.fileDirectory = fileDirectory;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -254,100 +252,95 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
getNameList = new GetNameListRequest();
tlvByteCount += getNameList.decode(is, false);
return tlvByteCount;
codeLength += getNameList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
read = new ReadRequest();
tlvByteCount += read.decode(is, false);
return tlvByteCount;
codeLength += read.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
write = new WriteRequest();
tlvByteCount += write.decode(is, false);
return tlvByteCount;
codeLength += write.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
getVariableAccessAttributes = new GetVariableAccessAttributesRequest();
tlvByteCount += getVariableAccessAttributes.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += getVariableAccessAttributes.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 11)) {
defineNamedVariableList = new DefineNamedVariableListRequest();
tlvByteCount += defineNamedVariableList.decode(is, false);
return tlvByteCount;
codeLength += defineNamedVariableList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
BerLength length = new BerLength();
tlvByteCount += length.decode(is);
codeLength += BerLength.skip(is);
getNamedVariableListAttributes = new GetNamedVariableListAttributesRequest();
tlvByteCount += getNamedVariableListAttributes.decode(is, null);
tlvByteCount += length.readEocIfIndefinite(is);
return tlvByteCount;
codeLength += getNamedVariableListAttributes.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
deleteNamedVariableList = new DeleteNamedVariableListRequest();
tlvByteCount += deleteNamedVariableList.decode(is, false);
return tlvByteCount;
codeLength += deleteNamedVariableList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) {
fileOpen = new FileOpenRequest();
tlvByteCount += fileOpen.decode(is, false);
return tlvByteCount;
codeLength += fileOpen.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 73)) {
fileRead = new FileReadRequest();
tlvByteCount += fileRead.decode(is, false);
return tlvByteCount;
codeLength += fileRead.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) {
fileClose = new FileCloseRequest();
tlvByteCount += fileClose.decode(is, false);
return tlvByteCount;
codeLength += fileClose.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 76)) {
fileDelete = new FileDeleteRequest();
tlvByteCount += fileDelete.decode(is, false);
return tlvByteCount;
codeLength += fileDelete.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) {
fileDirectory = new FileDirectoryRequest();
tlvByteCount += fileDirectory.decode(is, false);
return tlvByteCount;
codeLength += fileDirectory.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -360,7 +353,6 @@ public class ConfirmedServiceRequest implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,12 +1,9 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerType;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -16,7 +13,7 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private GetNameListResponse getNameList = null;
private ReadResponse read = null;
private WriteResponse write = null;
@ -134,11 +131,12 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
this.fileDirectory = fileDirectory;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -247,94 +245,93 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
getNameList = new GetNameListResponse();
tlvByteCount += getNameList.decode(is, false);
return tlvByteCount;
codeLength += getNameList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
read = new ReadResponse();
tlvByteCount += read.decode(is, false);
return tlvByteCount;
codeLength += read.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
write = new WriteResponse();
tlvByteCount += write.decode(is, false);
return tlvByteCount;
codeLength += write.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
getVariableAccessAttributes = new GetVariableAccessAttributesResponse();
tlvByteCount += getVariableAccessAttributes.decode(is, false);
return tlvByteCount;
codeLength += getVariableAccessAttributes.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 11)) {
defineNamedVariableList = new DefineNamedVariableListResponse();
tlvByteCount += defineNamedVariableList.decode(is, false);
return tlvByteCount;
codeLength += defineNamedVariableList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 12)) {
getNamedVariableListAttributes = new GetNamedVariableListAttributesResponse();
tlvByteCount += getNamedVariableListAttributes.decode(is, false);
return tlvByteCount;
codeLength += getNamedVariableListAttributes.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 13)) {
deleteNamedVariableList = new DeleteNamedVariableListResponse();
tlvByteCount += deleteNamedVariableList.decode(is, false);
return tlvByteCount;
codeLength += deleteNamedVariableList.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 72)) {
fileOpen = new FileOpenResponse();
tlvByteCount += fileOpen.decode(is, false);
return tlvByteCount;
codeLength += fileOpen.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 73)) {
fileRead = new FileReadResponse();
tlvByteCount += fileRead.decode(is, false);
return tlvByteCount;
codeLength += fileRead.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 74)) {
fileClose = new FileCloseResponse();
tlvByteCount += fileClose.decode(is, false);
return tlvByteCount;
codeLength += fileClose.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 76)) {
fileDelete = new FileDeleteResponse();
tlvByteCount += fileDelete.decode(is, false);
return tlvByteCount;
codeLength += fileDelete.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 77)) {
fileDirectory = new FileDirectoryResponse();
tlvByteCount += fileDirectory.decode(is, false);
return tlvByteCount;
codeLength += fileDirectory.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -347,7 +344,6 @@ public class ConfirmedServiceResponse implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

@ -1,18 +1,15 @@
/*
* This class file was automatically generated by ASN1bean (http://www.beanit.com)
*/
package com.beanit.iec61850bean.internal.mms.asn1;
import com.beanit.asn1bean.ber.BerLength;
import com.beanit.asn1bean.ber.BerTag;
import com.beanit.asn1bean.ber.ReverseByteArrayOutputStream;
import com.beanit.asn1bean.ber.types.BerBitString;
import com.beanit.asn1bean.ber.types.BerInteger;
import com.beanit.asn1bean.ber.types.BerOctetString;
import com.beanit.asn1bean.ber.types.BerType;
import com.beanit.asn1bean.ber.types.string.BerVisibleString;
import com.beanit.iec61850bean.internal.BerBoolean;
/** This class file was automatically generated by jASN1 (http://www.beanit.com) */
package com.beanit.openiec61850.internal.mms.asn1;
import com.beanit.jasn1.ber.BerLength;
import com.beanit.jasn1.ber.BerTag;
import com.beanit.jasn1.ber.ReverseByteArrayOutputStream;
import com.beanit.jasn1.ber.types.BerBitString;
import com.beanit.jasn1.ber.types.BerInteger;
import com.beanit.jasn1.ber.types.BerOctetString;
import com.beanit.jasn1.ber.types.BerType;
import com.beanit.jasn1.ber.types.string.BerVisibleString;
import com.beanit.openiec61850.internal.BerBoolean;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -25,7 +22,7 @@ public class Data implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private Array array = null;
private Structure structure = null;
private BerBoolean bool = null;
@ -141,11 +138,12 @@ public class Data implements BerType, Serializable {
this.utcTime = utcTime;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
return code.length;
}
@ -249,94 +247,93 @@ public class Data implements BerType, Serializable {
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
array = new Array();
tlvByteCount += array.decode(is, false);
return tlvByteCount;
codeLength += array.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
structure = new Structure();
tlvByteCount += structure.decode(is, false);
return tlvByteCount;
codeLength += structure.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
bool = new BerBoolean();
tlvByteCount += bool.decode(is, false);
return tlvByteCount;
codeLength += bool.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
bitString = new BerBitString();
tlvByteCount += bitString.decode(is, false);
return tlvByteCount;
codeLength += bitString.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 5)) {
integer = new BerInteger();
tlvByteCount += integer.decode(is, false);
return tlvByteCount;
codeLength += integer.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
unsigned = new BerInteger();
tlvByteCount += unsigned.decode(is, false);
return tlvByteCount;
codeLength += unsigned.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
floatingPoint = new FloatingPoint();
tlvByteCount += floatingPoint.decode(is, false);
return tlvByteCount;
codeLength += floatingPoint.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 9)) {
octetString = new BerOctetString();
tlvByteCount += octetString.decode(is, false);
return tlvByteCount;
codeLength += octetString.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 10)) {
visibleString = new BerVisibleString();
tlvByteCount += visibleString.decode(is, false);
return tlvByteCount;
codeLength += visibleString.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 12)) {
binaryTime = new TimeOfDay();
tlvByteCount += binaryTime.decode(is, false);
return tlvByteCount;
codeLength += binaryTime.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 16)) {
mMSString = new MMSString();
tlvByteCount += mMSString.decode(is, false);
return tlvByteCount;
codeLength += mMSString.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 17)) {
utcTime = new UtcTime();
tlvByteCount += utcTime.decode(is, false);
return tlvByteCount;
codeLength += utcTime.decode(is, false);
return codeLength;
}
if (tagWasPassed) {
if (passedTag != null) {
return 0;
}
@ -349,7 +346,6 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -427,7 +423,7 @@ public class Data implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<Data> seqOf = null;
public Array() {
@ -445,7 +441,6 @@ public class Data implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -453,7 +448,9 @@ public class Data implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -474,48 +471,36 @@ public class Data implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
codeLength += length.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
Data element = new Data();
numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
subCodeLength += element.decode(is, null);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -524,7 +509,6 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
@ -565,7 +549,7 @@ public class Data implements BerType, Serializable {
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private static final long serialVersionUID = 1L;
private byte[] code = null;
public byte[] code = null;
private List<Data> seqOf = null;
public Structure() {
@ -583,7 +567,6 @@ public class Data implements BerType, Serializable {
return seqOf;
}
@Override
public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
@ -591,7 +574,9 @@ public class Data implements BerType, Serializable {
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
for (int i = code.length - 1; i >= 0; i--) {
reverseOS.write(code[i]);
}
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
@ -612,48 +597,36 @@ public class Data implements BerType, Serializable {
return codeLength;
}
@Override
public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
int codeLength = 0;
int subCodeLength = 0;
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
codeLength += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
codeLength += length.decode(is);
int totalLength = length.val;
while (subCodeLength < totalLength) {
Data element = new Data();
numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
subCodeLength += element.decode(is, null);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
if (subCodeLength != totalLength) {
throw new IOException(
"Decoded SequenceOf or SetOf has wrong length. Expected "
+ lengthVal
+ totalLength
+ " but has "
+ vByteCount);
+ subCodeLength);
}
return tlByteCount + vByteCount;
codeLength += subCodeLength;
return codeLength;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
@ -662,7 +635,6 @@ public class Data implements BerType, Serializable {
code = reverseOS.getArray();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save