Skip to content

Commit

Permalink
Merge pull request #38 from 3KeyCompany/release/1.4.1
Browse files Browse the repository at this point in the history
Update release version to 1.4.1
  • Loading branch information
3keyroman authored Nov 23, 2023
2 parents 318db77 + f06b75f commit a88b3f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<parent>
<groupId>com.czertainly</groupId>
<artifactId>dependencies</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>

<groupId>com.czertainly</groupId>
<artifactId>keystore-entity-provider</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<name>CZERTAINLY-Keystore-Entity-Provider</name>

<properties>
Expand All @@ -24,18 +24,18 @@
<dependency>
<groupId>com.czertainly</groupId>
<artifactId>interfaces</artifactId>
<version>2.8.0</version>
<version>2.10.0</version>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>2.7.0</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-scp</artifactId>
<version>2.5.1</version>
<version>2.11.0</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<id>ossrh-releases</id>
<url>https://s01.oss.sonatype.org/content/repositories/releases</url>
</repository>
<repository>
<id>github</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.czertainly.api.exception.NotFoundException;
import com.czertainly.api.model.client.attribute.RequestAttributeDto;
import com.czertainly.api.model.common.attribute.v2.AttributeType;
import com.czertainly.api.model.common.attribute.v2.BaseAttribute;
import com.czertainly.api.model.common.attribute.v2.DataAttribute;
import com.czertainly.api.model.common.attribute.v2.MetadataAttribute;
import com.czertainly.api.model.common.attribute.v2.content.AttributeContentType;
Expand Down Expand Up @@ -94,6 +95,8 @@ public LocationDetailResponseDto getLocationDetail(String entityUuid, LocationDe
List<CertificateLocationDto> certificates = new ArrayList<>();
// parse the response and get certificates
List<KeystoreCertificate> certs = KeystoreResponseUtil.getAllKeystoreCertificates(response);
List<BaseAttribute> csrAttributesDefinitions = locationAttributeService.listGenerateCsrAttributes(entity);
List<BaseAttribute> pushAttributesDefinitions = locationAttributeService.listPushCertificateAttributes(entity);
for (KeystoreCertificate cert : certs) {
CertificateLocationDto certificateLocationDto = new CertificateLocationDto();
certificateLocationDto.setCertificateData(CertificateUtil.getBase64Certificate(cert.getCertificate()));
Expand All @@ -104,33 +107,29 @@ public LocationDetailResponseDto getLocationDetail(String entityUuid, LocationDe

certificateLocationDto.setMetadata(certificateMeta);

List<DataAttribute> pushAttributes = new ArrayList<>();
DataAttribute aliasAttribute = new DataAttribute();
List<RequestAttributeDto> pushAttributes = new ArrayList<>();
RequestAttributeDto aliasAttribute = new RequestAttributeDto();
aliasAttribute.setName(AttributeConstants.ATTRIBUTE_ALIAS_NAME);
aliasAttribute.setContent(List.of(new StringAttributeContent(cert.getAlias())));
aliasAttribute.setContentType(AttributeContentType.STRING);
pushAttributes.add(aliasAttribute);

certificateLocationDto.setPushAttributes(pushAttributes);
certificateLocationDto.setPushAttributes(AttributeDefinitionUtils.mergeAttributes(pushAttributesDefinitions, pushAttributes));

List<DataAttribute> csrAttributes = new ArrayList<>();
List<RequestAttributeDto> csrAttributes = new ArrayList<>();
if (cert.isKeyEntry()) {
DataAttribute subjectDnAttribute = new DataAttribute();
RequestAttributeDto subjectDnAttribute = new RequestAttributeDto();
subjectDnAttribute.setName(AttributeConstants.ATTRIBUTE_DN_NAME);
subjectDnAttribute.setContent(List.of(new StringAttributeContent(cert.getCertificate().getSubjectDN().toString())));
subjectDnAttribute.setContentType(AttributeContentType.STRING);
csrAttributes.add(subjectDnAttribute);

PublicKey pubk = cert.getCertificate().getPublicKey();
DataAttribute keyAlgorithmAttribute = new DataAttribute();
RequestAttributeDto keyAlgorithmAttribute = new RequestAttributeDto();
keyAlgorithmAttribute.setName(AttributeConstants.ATTRIBUTE_KEY_ALG_NAME);
keyAlgorithmAttribute.setContent(List.of(new StringAttributeContent(pubk.getAlgorithm())));
keyAlgorithmAttribute.setContentType(AttributeContentType.STRING);
csrAttributes.add(keyAlgorithmAttribute);

DataAttribute keyLengthAttribute = new DataAttribute();
RequestAttributeDto keyLengthAttribute = new RequestAttributeDto();
keyLengthAttribute.setName(AttributeConstants.ATTRIBUTE_KEY_SIZE_NAME);
keyLengthAttribute.setContentType(AttributeContentType.STRING);
if (pubk instanceof RSAPublicKey) {
RSAPublicKey rsaPubk = (RSAPublicKey) pubk;
keyLengthAttribute.setContent(List.of(new StringAttributeContent(String.valueOf(rsaPubk.getModulus().bitLength()))));
Expand All @@ -145,17 +144,16 @@ public LocationDetailResponseDto getLocationDetail(String entityUuid, LocationDe
}
csrAttributes.add(keyLengthAttribute);

DataAttribute signatureAlgorithmAttribute = new DataAttribute();
RequestAttributeDto signatureAlgorithmAttribute = new RequestAttributeDto();
signatureAlgorithmAttribute.setName(AttributeConstants.ATTRIBUTE_SIG_ALG_NAME);
signatureAlgorithmAttribute.setContent(List.of(new StringAttributeContent(cert.getCertificate().getSigAlgName())));
signatureAlgorithmAttribute.setContentType(AttributeContentType.STRING);
csrAttributes.add(signatureAlgorithmAttribute);

// alias include
csrAttributes.add(aliasAttribute);
}

certificateLocationDto.setCsrAttributes(csrAttributes);
certificateLocationDto.setCsrAttributes(AttributeDefinitionUtils.mergeAttributes(csrAttributesDefinitions, csrAttributes));

certificates.add(certificateLocationDto);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.scp.ScpClient;
import org.apache.sshd.client.scp.ScpClientCreator;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.scp.client.ScpClient;
import org.apache.sshd.scp.client.ScpClientCreator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down

0 comments on commit a88b3f3

Please sign in to comment.