use of io.gravitee.am.service.model.openid.PatchOIDCSettings in project gravitee-access-management by gravitee-io.
the class PatchDomain method patch.
public Domain patch(Domain _toPatch) {
// create new object for audit purpose (patch json result)
Domain toPatch = new Domain(_toPatch);
SetterUtils.safeSet(toPatch::setName, this.getName());
SetterUtils.safeSet(toPatch::setDescription, this.getDescription());
SetterUtils.safeSet(toPatch::setEnabled, this.getEnabled(), boolean.class);
SetterUtils.safeSet(toPatch::setAlertEnabled, this.getAlertEnabled(), boolean.class);
SetterUtils.safeSet(toPatch::setPath, this.getPath());
SetterUtils.safeSet(toPatch::setVhostMode, this.getVhostMode());
SetterUtils.safeSet(toPatch::setVhosts, this.getVhosts());
SetterUtils.safeSet(toPatch::setUma, this.getUma());
SetterUtils.safeSet(toPatch::setScim, this.getScim());
SetterUtils.safeSet(toPatch::setLoginSettings, this.getLoginSettings());
SetterUtils.safeSet(toPatch::setWebAuthnSettings, this.getWebAuthnSettings());
SetterUtils.safeSet(toPatch::setAccountSettings, this.getAccountSettings());
SetterUtils.safeSet(toPatch::setSelfServiceAccountManagementSettings, this.getSelfServiceAccountManagementSettings());
SetterUtils.safeSet(toPatch::setTags, this.getTags());
SetterUtils.safeSet(toPatch::setMaster, this.getMaster(), boolean.class);
if (this.getOidc() != null) {
if (this.getOidc().isPresent()) {
PatchOIDCSettings patcher = this.getOidc().get();
toPatch.setOidc(patcher.patch(toPatch.getOidc()));
} else {
toPatch.setOidc(OIDCSettings.defaultSettings());
}
}
if (this.passwordSettings != null) {
this.passwordSettings.ifPresent(ps -> toPatch.setPasswordSettings(ps.patch(toPatch.getPasswordSettings())));
}
return toPatch;
}
use of io.gravitee.am.service.model.openid.PatchOIDCSettings in project gravitee-access-management by gravitee-io.
the class PatchDomainTest method testGetRequiredPermissions.
@Test
public void testGetRequiredPermissions() {
PatchDomain patchDomain = new PatchDomain();
assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
patchDomain.setName(Optional.of("patchName"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setDescription(Optional.of("patchDescription"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setEnabled(Optional.of(true));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setPath(Optional.of("patchPath"));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setLoginSettings(Optional.of(new LoginSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setAccountSettings(Optional.of(new AccountSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setTags(Optional.of(Collections.singleton("patchTag")));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
PatchOIDCSettings oidcSettings = new PatchOIDCSettings();
patchDomain.setOidc(Optional.of(oidcSettings));
assertEquals(Collections.emptySet(), patchDomain.getRequiredPermissions());
oidcSettings.setClientRegistrationSettings(Optional.of(new PatchClientRegistrationSettings()));
oidcSettings.setRedirectUriStrictMatching(Optional.of(true));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_OPENID)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setScim(Optional.of(new SCIMSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
patchDomain = new PatchDomain();
patchDomain.setUma(Optional.of(new UMASettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_UMA)), patchDomain.getRequiredPermissions());
// Check multiple permissions.
patchDomain = new PatchDomain();
patchDomain.setPath(Optional.of("patchPath"));
patchDomain.setOidc(Optional.of(oidcSettings));
patchDomain.setScim(Optional.of(new SCIMSettings()));
assertEquals(new HashSet<>(Arrays.asList(Permission.DOMAIN_SETTINGS, Permission.DOMAIN_OPENID, Permission.DOMAIN_SCIM)), patchDomain.getRequiredPermissions());
}
use of io.gravitee.am.service.model.openid.PatchOIDCSettings in project gravitee-access-management by gravitee-io.
the class PatchDomainTest method testPatchWithEnabledOidc.
@Test
public void testPatchWithEnabledOidc() {
// Build patcher
PatchClientRegistrationSettings dcrPatcher = new PatchClientRegistrationSettings();
dcrPatcher.setDynamicClientRegistrationEnabled(Optional.of(true));
PatchOIDCSettings oidcPatcher = new PatchOIDCSettings();
oidcPatcher.setClientRegistrationSettings(Optional.of(dcrPatcher));
PatchDomain patch = new PatchDomain();
patch.setOidc(Optional.of(oidcPatcher));
// Build object to patch with DCR enabled
Domain toPatch = new Domain();
toPatch.setOidc(OIDCSettings.defaultSettings());
// apply patch
Domain result = patch.patch(toPatch);
// check.
assertNotNull("was expecting a domain", result);
assertNotNull(result.getOidc());
assertNotNull(result.getOidc().getClientRegistrationSettings());
assertTrue("should have been enabled", result.getOidc().getClientRegistrationSettings().isDynamicClientRegistrationEnabled());
}
use of io.gravitee.am.service.model.openid.PatchOIDCSettings in project gravitee-access-management by gravitee-io.
the class DomainUpgrader method upgradeDomain.
private Single<Domain> upgradeDomain(Domain domain) {
if (domain.getOidc() != null) {
return Single.just(domain);
}
PatchClientRegistrationSettings clientRegistrationPatch = new PatchClientRegistrationSettings();
clientRegistrationPatch.setDynamicClientRegistrationEnabled(Optional.of(false));
clientRegistrationPatch.setOpenDynamicClientRegistrationEnabled(Optional.of(false));
clientRegistrationPatch.setAllowHttpSchemeRedirectUri(Optional.of(true));
clientRegistrationPatch.setAllowLocalhostRedirectUri(Optional.of(true));
clientRegistrationPatch.setAllowWildCardRedirectUri(Optional.of(true));
PatchOIDCSettings oidcPatch = new PatchOIDCSettings();
oidcPatch.setClientRegistrationSettings(Optional.of(clientRegistrationPatch));
PatchDomain patchDomain = new PatchDomain();
patchDomain.setOidc(Optional.of(oidcPatch));
return domainService.patch(domain.getId(), patchDomain);
}
Aggregations