Check array size before accessing

This commit is contained in:
Maksymilian Pawlak 2017-09-19 10:10:24 +01:00
parent 2c5aa4eead
commit 72c6577b23
2 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,4 @@
gradlePluginsVersion=0.16.4
gradlePluginsVersion=0.16.5
kotlinVersion=1.1.4
guavaVersion=21.0
bouncycastleVersion=1.57

View File

@ -3,6 +3,7 @@ package net.corda.plugins
import com.typesafe.config.*
import net.corda.cordform.CordformNode
import org.bouncycastle.asn1.x500.X500Name
import org.bouncycastle.asn1.x500.RDN
import org.bouncycastle.asn1.x500.style.BCStyle
import org.gradle.api.Project
import java.nio.charset.StandardCharsets
@ -87,10 +88,13 @@ class Node extends CordformNode {
}
protected void rootDir(Path rootDir) {
def dirName
def dirName = name
try {
X500Name x500Name = new X500Name(name)
dirName = x500Name.getRDNs(BCStyle.O).getAt(0).getFirst().getValue().toString()
RDN[] o = x500Name.getRDNs(BCStyle.O)
if (o.length > 0) {
dirName = o.getAt(0).getFirst().getValue().toString()
}
} catch(IllegalArgumentException ignore) {
// Can't parse as an X500 name, use the full string
dirName = name