/** * Import a realm * * <p>Imports a realm from a full representation of that realm. Realm name must be unique. * * @param uriInfo * @param rep JSON representation of the realm * @return */ @POST @Consumes(MediaType.APPLICATION_JSON) public Response importRealm(@Context final UriInfo uriInfo, final RealmRepresentation rep) { RealmManager realmManager = new RealmManager(session); realmManager.setContextPath(keycloak.getContextPath()); if (!auth.getRealm().equals(realmManager.getKeycloakAdminstrationRealm())) { throw new ForbiddenException(); } if (!auth.hasRealmRole(AdminRoles.CREATE_REALM)) { throw new ForbiddenException(); } logger.debugv("importRealm: {0}", rep.getRealm()); try { RealmModel realm = realmManager.importRealm(rep); grantPermissionsToRealmCreator(realm); URI location = AdminRoot.realmsUrl(uriInfo).path(realm.getName()).build(); logger.debugv("imported realm success, sending back: {0}", location.toString()); return Response.created(location).build(); } catch (ModelDuplicateException e) { return ErrorResponse.exists("Realm with same name exists"); } }
@GET @NoCache @Path("installation/providers/{providerId}") public Response getInstallationProvider(@PathParam("providerId") String providerId) { auth.requireView(); if (client == null) { throw new NotFoundException("Could not find client"); } ClientInstallationProvider provider = session.getProvider(ClientInstallationProvider.class, providerId); if (provider == null) throw new NotFoundException("Unknown Provider"); return provider.generateInstallation(session, realm, client, keycloak.getBaseUri(uriInfo)); }