use of com.helger.phoss.smp.domain.sml.ISMLInfoManager in project phoss-smp by phax.
the class PageSecureSMLConfiguration method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMLInfoManager aSMLInfoMgr = SMPMetaManager.getSMLInfoMgr();
aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMLInfo aCurObject : aSMLInfoMgr.getAllSMLInfos()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
aRow.addCell(aCurObject.getDNSZone());
aRow.addCell(aCurObject.getManagementServiceURL());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), aDisplayLocale));
aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getDisplayName()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.phoss.smp.domain.sml.ISMLInfoManager in project phoss-smp by phax.
the class PageSecureSMLConfiguration method validateAndSaveInputParameters.
@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMLInfo aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
final boolean bEdit = eFormAction.isEdit();
final ISMLInfoManager aSMLInfoMgr = SMPMetaManager.getSMLInfoMgr();
final String sDisplayName = aWPEC.params().getAsString(FIELD_DISPLAY_NAME);
final String sDNSZone = aWPEC.params().getAsString(FIELD_DNS_ZONE);
final String sManagementAddressURL = aWPEC.params().getAsString(FIELD_MANAGEMENT_ADDRESS_URL);
final boolean bClientCertificateRequired = aWPEC.params().isCheckBoxChecked(FIELD_CLIENT_CERTIFICATE_REQUIRED, DEFAULT_CLIENT_CERTIFICATE_REQUIRED);
// validations
if (StringHelper.hasNoText(sDisplayName))
aFormErrors.addFieldError(FIELD_DISPLAY_NAME, "The SML configuration name must not be empty!");
if (StringHelper.hasNoText(sDNSZone))
aFormErrors.addFieldError(FIELD_DNS_ZONE, "The DNS Zone must not be empty!");
if (StringHelper.hasNoText(sManagementAddressURL))
aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL must not be empty!");
else {
final URL aURL = URLHelper.getAsURL(sManagementAddressURL);
if (aURL == null)
aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL is not a valid URL!");
else if (!"https".equals(aURL.getProtocol()) && !"http".equals(aURL.getProtocol()))
aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL should only be use the 'http' or the 'https' protocol!");
}
if (aFormErrors.isEmpty()) {
// Lowercase with the US locale - not display locale specific
final String sDNSZoneLC = sDNSZone.toLowerCase(Locale.US);
if (bEdit) {
aSMLInfoMgr.updateSMLInfo(aSelectedObject.getID(), sDisplayName, sDNSZoneLC, sManagementAddressURL, bClientCertificateRequired);
aWPEC.postRedirectGetInternal(success("The SML configuration '" + sDisplayName + "' was successfully edited."));
} else {
aSMLInfoMgr.createSMLInfo(sDisplayName, sDNSZoneLC, sManagementAddressURL, bClientCertificateRequired);
aWPEC.postRedirectGetInternal(success("The new SML configuration '" + sDisplayName + "' was successfully created."));
}
}
}
use of com.helger.phoss.smp.domain.sml.ISMLInfoManager in project phoss-smp by phax.
the class SMPSettingsManagerMongoDBTest method testBasic.
@Test
public void testBasic() {
final ISMLInfoManager aSMLInfoMgr = SMPMetaManager.getSMLInfoMgr();
final ISMLInfo aSMLInfo = aSMLInfoMgr.createSMLInfo("bla", "foo", "http://bar", true);
assertNotNull(aSMLInfo);
try (final SMPSettingsManagerMongoDB aMgr = new SMPSettingsManagerMongoDB()) {
final ISMPSettings aSettings = aMgr.getSettings();
assertNotNull(aSettings);
aMgr.updateSettings(true, true, true, true, "v1", true, true, aSMLInfo.getID());
assertTrue(aSettings.isRESTWritableAPIDisabled());
assertTrue(aSettings.isDirectoryIntegrationRequired());
assertTrue(aSettings.isDirectoryIntegrationEnabled());
assertTrue(aSettings.isDirectoryIntegrationAutoUpdate());
assertEquals("v1", aSettings.getDirectoryHostName());
assertTrue(aSettings.isSMLRequired());
assertTrue(aSettings.isSMLEnabled());
assertEquals(aSMLInfo, aSettings.getSMLInfo());
aMgr.updateSettings(false, false, false, false, "v2", false, false, aSMLInfo.getID());
assertFalse(aSettings.isRESTWritableAPIDisabled());
assertFalse(aSettings.isDirectoryIntegrationRequired());
assertFalse(aSettings.isDirectoryIntegrationEnabled());
assertFalse(aSettings.isDirectoryIntegrationAutoUpdate());
assertEquals("v2", aSettings.getDirectoryHostName());
assertFalse(aSettings.isSMLRequired());
assertFalse(aSettings.isSMLEnabled());
assertEquals(aSMLInfo, aSettings.getSMLInfo());
} finally {
aSMLInfoMgr.deleteSMLInfo(aSMLInfo.getID());
}
}
Aggregations