Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@Accessors(chain = true)
public class CertificateAuthority {
private Integer id;
private Integer certificationServiceId;
private CertificateDetails caCertificate;
private List<OcspResponder> ocspResponders;
private Instant createdAt;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* The MIT License
*
* Copyright (c) 2019- Nordic Institute for Interoperability Solutions (NIIS)
* Copyright (c) 2018 Estonian Information System Authority (RIA),
* Nordic Institute for Interoperability Solutions (NIIS), Population Register Centre (VRK)
* Copyright (c) 2015-2017 Estonian Information System Authority (RIA), Population Register Centre (VRK)
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.niis.xroad.cs.admin.api.dto;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class OcspResponderCertificateDetails extends CertificateDetails {

private Integer certificationServiceId;
private Integer intermediateCaId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
*/
package org.niis.xroad.cs.admin.api.service;

import org.niis.xroad.cs.admin.api.dto.CertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponder;
import org.niis.xroad.cs.admin.api.dto.OcspResponderCertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponderRequest;

public interface OcspRespondersService {
CertificateDetails getOcspResponderCertificateDetails(Integer id);
OcspResponderCertificateDetails getOcspResponderCertificateDetails(Integer id);

OcspResponder update(OcspResponderRequest updateRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class CaInfoConverter {
public CertificateAuthority toCertificateAuthority(CaInfoEntity caInfo) {
return new CertificateAuthority()
.setId(caInfo.getId())
.setCertificationServiceId(caInfo.getApprovedCa() == null ? null : caInfo.getApprovedCa().getId())
.setCaCertificate(certConverter.toCertificateDetails(caInfo.getCert()))
.setOcspResponders(caInfo.getOcspInfos().stream()
.map(ocspResponderConverter::toModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
import lombok.RequiredArgsConstructor;
import org.niis.xroad.common.core.exception.XrdRuntimeException;
import org.niis.xroad.cs.admin.api.dto.CertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponderCertificateDetails;
import org.niis.xroad.cs.admin.api.dto.SecurityServerAuthenticationCertificateDetails;
import org.niis.xroad.cs.admin.core.entity.AuthCertEntity;
import org.niis.xroad.cs.admin.core.entity.OcspInfoEntity;
import org.springframework.stereotype.Component;

import java.io.IOException;
Expand Down Expand Up @@ -70,6 +72,19 @@ public CertificateDetails toCertificateDetails(final byte[] cert) {
}
}

public OcspResponderCertificateDetails toCertificateDetails(final OcspInfoEntity ocspInfo) {
if (ocspInfo.getCert() == null) {
return null;
}
try {
OcspResponderCertificateDetails certificateDetails = new OcspResponderCertificateDetails();
populateCertificateDetails(certificateDetails, ocspInfo.getCert());
return certificateDetails;
} catch (Exception e) {
throw XrdRuntimeException.systemException(e);
}
}

public CertificateDetails toCertificateDetails(final X509Certificate certificate) {
try {
var certificateDetails = new CertificateDetails();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
package org.niis.xroad.cs.admin.core.repository;

import org.niis.xroad.cs.admin.core.entity.ApprovedCaEntity;
import org.niis.xroad.cs.admin.core.entity.CaInfoEntity;

public interface ApprovedCaRepository extends GenericRepository<ApprovedCaEntity, Integer> {
import java.util.Optional;

public interface ApprovedCaRepository extends GenericRepository<ApprovedCaEntity, Integer> {
Optional<Integer> findApprovedCaIdByCaId(CaInfoEntity caInfoEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public CertificateAuthority addIntermediateCa(Integer certificationServiceId, by
final CaInfoEntity caInfo = caInfoConverter.toCaInfo(cert);
caInfo.setApprovedCa(getById(certificationServiceId));

caInfoRepository.save(caInfo);
var saved = caInfoRepository.save(caInfo);

auditDataHelper.put(CA_ID, certificationServiceId);
auditDataHelper.put(INTERMEDIATE_CA_ID, caInfo.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import org.niis.xroad.common.exception.NotFoundException;
import org.niis.xroad.cs.admin.api.dto.CertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponder;
import org.niis.xroad.cs.admin.api.dto.OcspResponderCertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponderRequest;
import org.niis.xroad.cs.admin.api.service.OcspRespondersService;
import org.niis.xroad.cs.admin.core.converter.CertificateConverter;
import org.niis.xroad.cs.admin.core.converter.OcspResponderConverter;
import org.niis.xroad.cs.admin.core.entity.OcspInfoEntity;
import org.niis.xroad.cs.admin.core.repository.ApprovedCaRepository;
import org.niis.xroad.cs.admin.core.repository.OcspInfoRepository;
import org.niis.xroad.cs.admin.core.validation.UrlValidator;
import org.niis.xroad.restapi.config.audit.AuditDataHelper;
Expand All @@ -55,20 +56,35 @@
@RequiredArgsConstructor
public class OcspRespondersServiceImpl implements OcspRespondersService {
private final OcspInfoRepository ocspInfoRepository;
private final ApprovedCaRepository approvedCaRepository;
private final CertificateConverter certConverter;
private final OcspResponderConverter ocspResponderConverter;

private final AuditDataHelper auditDataHelper;
private final UrlValidator urlValidator;

@Override
public CertificateDetails getOcspResponderCertificateDetails(Integer id) {
public OcspResponderCertificateDetails getOcspResponderCertificateDetails(Integer id) {
return ocspInfoRepository.findById(id)
.map(OcspInfoEntity::getCert)
.map(certConverter::toCertificateDetails)
.filter(ocsp -> ocsp.getCert() != null)
.map(ocsp -> attachCaIds(ocsp, certConverter.toCertificateDetails(ocsp)))
.orElseThrow(() -> new NotFoundException(OCSP_RESPONDER_NOT_FOUND.build()));
}

private OcspResponderCertificateDetails attachCaIds(final OcspInfoEntity ocspInfo,
final OcspResponderCertificateDetails certificateDetails) {
if (ocspInfo.getCaInfo().getApprovedCa() == null) {
certificateDetails.setCertificationServiceId(
approvedCaRepository.findApprovedCaIdByCaId(ocspInfo.getCaInfo()).orElse(null)
);
} else {
certificateDetails.setIntermediateCaId(ocspInfo.getCaInfo().getId());
certificateDetails.setCertificationServiceId(ocspInfo.getCaInfo().getApprovedCa().getId());
}

return certificateDetails;
}

private OcspInfoEntity get(Integer id) {
return ocspInfoRepository.findById(id)
.orElseThrow(() -> new NotFoundException(OCSP_RESPONDER_NOT_FOUND.build()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.niis.xroad.cs.admin.core.converter.CertificateConverter;
import org.niis.xroad.cs.admin.core.converter.KeyUsageConverter;
import org.niis.xroad.cs.admin.core.entity.ApprovedTsaEntity;
import org.niis.xroad.cs.admin.core.repository.ApprovedCaRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -51,7 +52,7 @@
import static org.niis.xroad.cs.admin.api.dto.KeyUsageEnum.NON_REPUDIATION;

@ActiveProfiles("test")
@SpringBootTest(classes = {ApprovedTsaMapperImpl.class, CertificateConverter.class, KeyUsageConverter.class})
@SpringBootTest(classes = {ApprovedTsaMapperImpl.class, CertificateConverter.class, KeyUsageConverter.class, ApprovedCaRepository.class})
class ApprovedTsaMapperTest {

private static final int ID = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class OcspRespondersServiceImplTest {
@Mock
private OcspInfoRepository ocspInfoRepository;
@Mock
private ApprovedCaRepository approvedCaRepository;
@Mock
private AuditDataHelper auditDataHelper;
@Mock
private UrlValidator urlValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@
import org.mapstruct.MappingConstants;
import org.niis.xroad.cs.admin.api.converter.GenericMapper;
import org.niis.xroad.cs.admin.api.dto.CertificateDetails;
import org.niis.xroad.cs.admin.api.dto.OcspResponderCertificateDetails;
import org.niis.xroad.cs.admin.api.dto.SecurityServerAuthenticationCertificateDetails;
import org.niis.xroad.cs.openapi.model.CertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.OcspResponderCertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.SecurityServerAuthenticationCertificateDetailsDto;

@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface CertificateDetailsDtoConverter extends GenericMapper {

CertificateDetailsDto convert(CertificateDetails certificateDetails);

OcspResponderCertificateDetailsDto convert(OcspResponderCertificateDetails certificateDetails);

SecurityServerAuthenticationCertificateDetailsDto convert(SecurityServerAuthenticationCertificateDetails certificateDetails);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.niis.xroad.cs.admin.rest.api.converter.CertificateDetailsDtoConverter;
import org.niis.xroad.cs.admin.rest.api.converter.OcspResponderDtoConverter;
import org.niis.xroad.cs.openapi.OcspRespondersApi;
import org.niis.xroad.cs.openapi.model.CertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.OcspResponderCertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.OcspResponderDto;
import org.niis.xroad.restapi.config.audit.AuditEventMethod;
import org.niis.xroad.restapi.config.audit.RestApiAuditEvent;
Expand Down Expand Up @@ -91,7 +91,7 @@ public ResponseEntity<OcspResponderDto> updateOcspResponder(Integer id, String u

@Override
@PreAuthorize("hasAuthority('VIEW_APPROVED_CA_DETAILS')")
public ResponseEntity<CertificateDetailsDto> getOcspRespondersCertificate(Integer id) {
public ResponseEntity<OcspResponderCertificateDetailsDto> getOcspRespondersCertificate(Integer id) {
return ok(certificateDetailsDtoConverter.convert(ocspRespondersService.getOcspResponderCertificateDetails(id)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@
package org.niis.xroad.cs.admin.jpa.repository;

import org.niis.xroad.cs.admin.core.entity.ApprovedCaEntity;
import org.niis.xroad.cs.admin.core.entity.CaInfoEntity;
import org.niis.xroad.cs.admin.core.repository.ApprovedCaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface JpaApprovedCaRepository extends JpaRepository<ApprovedCaEntity, Integer>, ApprovedCaRepository {

@Query("select aca.id FROM ApprovedCaEntity aca WHERE aca.caInfo = :caInfoEntity")
Optional<Integer> findApprovedCaIdByCaId(CaInfoEntity caInfoEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.nortal.test.asserts.Assertion;
import com.nortal.test.asserts.AssertionOperation;
import io.cucumber.java.en.Step;
import org.niis.xroad.cs.openapi.model.CertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.OcspResponderCertificateDetailsDto;
import org.niis.xroad.cs.openapi.model.OcspResponderDto;
import org.niis.xroad.cs.test.api.FeignOcspRespondersApi;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void updateOcspResponderUrl() {
public void ocspResponderUrlAndCertificateIsUpdated() throws Exception {
Integer ocspResponderId = getRequiredStepData(OCSP_RESPONDER_ID);

final ResponseEntity<CertificateDetailsDto> certificateResponse = ocspRespondersApi
final ResponseEntity<OcspResponderCertificateDetailsDto> certificateResponse = ocspRespondersApi
.getOcspRespondersCertificate(ocspResponderId);

getKeyOldOcspResponderCertHash = certificateResponse.getBody().getHash();
Expand All @@ -100,7 +100,7 @@ public void ocspResponderUrlAndCertificateIsUpdated() throws Exception {
public void theOCSPResponderCertificateWasUpdated() {
Integer ocspResponderId = getRequiredStepData(OCSP_RESPONDER_ID);

final ResponseEntity<CertificateDetailsDto> certificateResponse = ocspRespondersApi
final ResponseEntity<OcspResponderCertificateDetailsDto> certificateResponse = ocspRespondersApi
.getOcspRespondersCertificate(ocspResponderId);

validate(certificateResponse)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/central-server/admin-service/ui/public/favicon.ico
Binary file not shown.
57 changes: 9 additions & 48 deletions src/central-server/admin-service/ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,24 @@
THE SOFTWARE.
-->
<template>
<v-app class="xrd-app">
<!-- Dont show toolbar or footer in login view -->
<app-toolbar v-if="loginView" />
<v-main app>
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</v-main>
<XrdSnackBar
:success-notifications="notificationStore.successNotifications"
@close="notificationStore.deleteSuccessNotification($event.timeAdded)"
/>
<XrdAppFooter v-if="loginView" />
</v-app>
<XrdApp :login-view="loginView">
<router-view />
</XrdApp>
</template>

<script lang="ts" setup>
// The root component of the Vue app
import { computed } from 'vue';
import { XrdAppFooter, XrdSnackBar } from '@niis/shared-ui';
import AppToolbar from '@/layouts/AppToolbar.vue';
import { RouteName } from '@/global';

import { useRoute } from 'vue-router';
import { useNotifications } from '@/store/modules/notifications';

import { XrdApp } from '@niis/shared-ui';

import { RouteName } from '@/global';

const route = useRoute();
const notificationStore = useNotifications();

const loginView = computed(() => {
return route.name !== RouteName.Login;
return route.name === RouteName.Login;
});
</script>

<!-- eslint-disable-next-line vue-scoped-css/enforce-style-type -->
<style lang="scss">
@use '@niis/shared-ui/src/assets/global-style.scss';
</style>

<style lang="scss" scoped>
@use '@niis/shared-ui/src/assets/colors';

.fade-enter-active,
.fade-leave-active {
transition-duration: 0.2s;
transition-property: opacity;
transition-timing-function: ease;
}

.fade-enter,
.fade-leave-active {
opacity: 0;
}

// Set the app background color
.v-theme--light.v-application.xrd-app {
background: colors.$WarmGrey30;
}
</style>
11 changes: 9 additions & 2 deletions src/central-server/admin-service/ui/src/assets/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@use '@niis/shared-ui/src/assets/colors';

@use 'vuetify/settings' with (
$layers: false,

$table-row-height: 56px,
$button-text-transform: none,
$field-outline-opacity: .4,
$ripple-animation-visible-opacity: .24,
$body-font-family: ('Open Sans', sans-serif),
$overlay-opacity: 0.6,
$overlay-scrim-background: #0B283E,
$field-control-padding-bottom: 8px,
);

Loading