From b03ce0047c4893e22a4888066cae36700a05318e Mon Sep 17 00:00:00 2001 From: Stefan Guilhen Date: Mon, 21 Oct 2024 14:32:52 -0300 Subject: [PATCH] Add explicit getter method for organizations in RealmAdminResource - makes OrganizationsResource reachable to OpenAPI generator Closes #30832 Signed-off-by: Stefan Guilhen --- .../resource/OrganizationResourceFactory.java | 62 ------------------- .../OrganizationResourceProvider.java | 36 ----------- .../resources/admin/RealmAdminResource.java | 5 ++ ...dmin.ext.AdminRealmResourceProviderFactory | 17 ----- 4 files changed, 5 insertions(+), 115 deletions(-) delete mode 100644 services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceFactory.java delete mode 100644 services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceProvider.java delete mode 100644 services/src/main/resources/META-INF/services/org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory diff --git a/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceFactory.java b/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceFactory.java deleted file mode 100644 index 4d99e87ede..0000000000 --- a/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2024 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.organization.admin.resource; - -import org.keycloak.Config.Scope; -import org.keycloak.common.Profile; -import org.keycloak.common.Profile.Feature; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; -import org.keycloak.provider.EnvironmentDependentProviderFactory; -import org.keycloak.services.resources.admin.ext.AdminRealmResourceProvider; -import org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory; - -public class OrganizationResourceFactory implements AdminRealmResourceProviderFactory, EnvironmentDependentProviderFactory { - - private OrganizationResourceProvider PROVIDER_INSTANCE; - - @Override - public AdminRealmResourceProvider create(KeycloakSession session) { - return PROVIDER_INSTANCE; - } - - @Override - public void init(Scope config) { - - } - - @Override - public void postInit(KeycloakSessionFactory factory) { - PROVIDER_INSTANCE = new OrganizationResourceProvider(); - } - - @Override - public void close() { - - } - - @Override - public String getId() { - return "organizations"; - } - - @Override - public boolean isSupported(Scope config) { - return Profile.isFeatureEnabled(Feature.ORGANIZATION); - } -} diff --git a/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceProvider.java b/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceProvider.java deleted file mode 100644 index ff6433ff95..0000000000 --- a/services/src/main/java/org/keycloak/organization/admin/resource/OrganizationResourceProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2024 Red Hat, Inc. and/or its affiliates - * and other contributors as indicated by the @author tags. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.keycloak.organization.admin.resource; - -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.services.resources.admin.AdminEventBuilder; -import org.keycloak.services.resources.admin.ext.AdminRealmResourceProvider; -import org.keycloak.services.resources.admin.permissions.AdminPermissionEvaluator; - -public class OrganizationResourceProvider implements AdminRealmResourceProvider { - - @Override - public Object getResource(KeycloakSession session, RealmModel realm, AdminPermissionEvaluator auth, AdminEventBuilder adminEvent) { - return new OrganizationsResource(session, auth, adminEvent); - } - - @Override - public void close() { - } -} diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index 50797ff529..198f16e39d 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -92,6 +92,7 @@ import org.keycloak.models.UserSessionModel; import org.keycloak.models.utils.KeycloakModelUtils; import org.keycloak.models.utils.ModelToRepresentation; import org.keycloak.models.utils.RepresentationToModel; +import org.keycloak.organization.admin.resource.OrganizationsResource; import org.keycloak.partialimport.PartialImportResult; import org.keycloak.partialimport.PartialImportResults; import org.keycloak.representations.adapters.action.GlobalRequestResult; @@ -553,6 +554,10 @@ public class RealmAdminResource { return ref; } + @Path("organizations") + public OrganizationsResource organizations() { + return new OrganizationsResource(session, auth, adminEvent); + } @Path("{extension}") public Object extension(@PathParam("extension") String extension) { diff --git a/services/src/main/resources/META-INF/services/org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory b/services/src/main/resources/META-INF/services/org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory deleted file mode 100644 index 53bc20edf4..0000000000 --- a/services/src/main/resources/META-INF/services/org.keycloak.services.resources.admin.ext.AdminRealmResourceProviderFactory +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2024 Red Hat, Inc. and/or its affiliates -# and other contributors as indicated by the @author tags. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -org.keycloak.organization.admin.resource.OrganizationResourceFactory \ No newline at end of file