use of com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation in project phoss-smp by phax.
the class PageSecureTasksProblems method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final OffsetDateTime aNowDT = PDTFactory.getCurrentOffsetDateTime();
final OffsetDateTime aNowPlusDT = aNowDT.plusMonths(3);
aNodeList.addChild(info("This page tries to identify upcoming tasks and potential problems in the SMP configuration. It is meant to highlight immediate and upcoming action items as well as potential misconfiguration."));
final HCOL aOL = new HCOL();
// Check for default password
if (PhotonSecurityManager.getUserMgr().areUserIDAndPasswordValid(CSecurity.USER_ADMINISTRATOR_ID, CSecurity.USER_ADMINISTRATOR_PASSWORD)) {
aOL.addItem(_createError("Please change the password of the default user " + CSecurity.USER_ADMINISTRATOR_EMAIL + "!"), div("This is a severe security risk"));
}
_checkSettings(aOL);
// check keystore configuration
_checkKeyStore(aWPEC, aOL, aNowDT, aNowPlusDT);
// Check truststore configuration
_checkTrustStore(aWPEC, aOL, aNowDT, aNowPlusDT);
// Check SML configuration
_checkSMLConfiguration(aOL);
// Check Directory configuration
_checkDirectoryConfig(aWPEC, aOL, aNowDT, aNowPlusDT);
// check service groups and redirects
{
final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups();
if (aServiceGroups.isEmpty()) {
aOL.addItem(_createWarning("No service group is configured. This SMP is currently empty."));
} else {
// For all service groups
for (final ISMPServiceGroup aServiceGroup : CollectionHelper.getSorted(aServiceGroups, ISMPServiceGroup.comparator())) {
final HCUL aULPerSG = new HCUL();
final ICommonsList<ISMPServiceInformation> aServiceInfos = aServiceInfoMgr.getAllSMPServiceInformationOfServiceGroup(aServiceGroup);
if (aServiceInfos.isEmpty()) {
// This is merely a warning or an error
aULPerSG.addItem(_createInfo("No endpoint is configured for this service group."));
} else {
for (final ISMPServiceInformation aServiceInfo : aServiceInfos) {
final HCUL aULPerDocType = new HCUL();
final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses();
for (final ISMPProcess aProcess : aProcesses) {
final HCUL aULPerProcess = new HCUL();
final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints();
for (final ISMPEndpoint aEndpoint : aEndpoints) {
final HCUL aULPerEndpoint = new HCUL();
final ESMPTransportProfile eTransportProfile = ESMPTransportProfile.getFromIDOrNull(aEndpoint.getTransportProfile());
if (eTransportProfile == null)
aULPerEndpoint.addItem(_createWarning("The endpoint uses the non-standard transport profile '" + aEndpoint.getTransportProfile() + "'."));
if (aEndpoint.getServiceActivationDateTime() != null) {
if (aEndpoint.getServiceActivationDateTime().isAfter(XMLOffsetDateTime.of(aNowDT)))
aULPerEndpoint.addItem(_createWarning("The endpoint is not yet active."), div("It will be active from " + PDTToString.getAsString(aEndpoint.getServiceActivationDateTime(), aDisplayLocale) + "."));
}
if (aEndpoint.getServiceExpirationDateTime() != null) {
if (aEndpoint.getServiceExpirationDateTime().isBefore(XMLOffsetDateTime.of(aNowDT)))
aULPerEndpoint.addItem(_createError("The endpoint is no longer active."), div("It was valid until " + PDTToString.getAsString(aEndpoint.getServiceExpirationDateTime(), aDisplayLocale) + "."));
else if (aEndpoint.getServiceExpirationDateTime().isBefore(XMLOffsetDateTime.of(aNowPlusDT)))
aULPerEndpoint.addItem(_createWarning("The endpoint will be inactive soon."), div("It is only valid until " + PDTToString.getAsString(aEndpoint.getServiceExpirationDateTime(), aDisplayLocale) + "."));
}
X509Certificate aX509Cert = null;
try {
aX509Cert = CertificateHelper.convertStringToCertficate(aEndpoint.getCertificate());
} catch (final CertificateException ex) {
// Ignore
}
if (aX509Cert == null)
aULPerEndpoint.addItem(_createError("The X.509 certificate configured at the endpoint is invalid and could not be interpreted as a certificate."));
else {
final OffsetDateTime aNotBefore = PDTFactory.createOffsetDateTime(aX509Cert.getNotBefore());
if (aNowDT.isBefore(aNotBefore))
aULPerEndpoint.addItem(_createError("The endpoint certificate is not yet active."), div("It will be valid from " + PDTToString.getAsString(aNotBefore, aDisplayLocale) + "."));
final OffsetDateTime aNotAfter = PDTFactory.createOffsetDateTime(aX509Cert.getNotAfter());
if (aNowDT.isAfter(aNotAfter))
aULPerEndpoint.addItem(_createError("The endpoint certificate is already expired."), div("It was valid until " + PDTToString.getAsString(aNotAfter, aDisplayLocale) + "."));
else if (aNowPlusDT.isAfter(aNotAfter))
aULPerEndpoint.addItem(_createWarning("The endpoint certificate will expire soon."), div("It is only valid until " + PDTToString.getAsString(aNotAfter, aDisplayLocale) + "."));
}
// Show per endpoint errors
if (aULPerEndpoint.hasChildren())
aULPerProcess.addItem(div("Transport profile ").addChild(code(aEndpoint.getTransportProfile())), aULPerEndpoint);
}
// Show per process errors
if (aULPerProcess.hasChildren())
aULPerDocType.addItem(div("Process ").addChild(code(aProcess.getProcessIdentifier().getURIEncoded()).addClass(CUICoreCSS.CSS_CLASS_NOWRAP)), aULPerProcess);
}
// Show per document type errors
if (aULPerDocType.hasChildren())
aULPerSG.addItem(div("Document type ").addChild(code(aServiceInfo.getDocumentTypeIdentifier().getURIEncoded()).addClass(CUICoreCSS.CSS_CLASS_NOWRAP)), aULPerDocType);
}
}
// Show per service group errors
if (aULPerSG.hasChildren())
aOL.addItem(div("Service group ").addChild(code(aServiceGroup.getParticipantIdentifier().getURIEncoded())), aULPerSG);
}
}
}
// Show results
if (aOL.hasChildren()) {
aNodeList.addChild(warn("The following list of tasks and problems were identified:"));
aNodeList.addChild(aOL);
} else
aNodeList.addChild(success("Great job, no tasks or problems identified!"));
}
Aggregations