Package org.keycloak.representations.idm

Examples of org.keycloak.representations.idm.ApplicationRepresentation


        // Applications
        List<ApplicationModel> applications = realm.getApplications();
        List<ApplicationRepresentation> appReps = new ArrayList<ApplicationRepresentation>();
        for (ApplicationModel app : applications) {
            ApplicationRepresentation appRep = exportApplication(app);
            appReps.add(appRep);
        }
        rep.setApplications(appReps);

        // OAuth clients
View Full Code Here


     * Full export of application including claims and secret
     * @param app
     * @return full ApplicationRepresentation
     */
    public static ApplicationRepresentation exportApplication(ApplicationModel app) {
        ApplicationRepresentation appRep = ModelToRepresentation.toRepresentation(app);

        appRep.setSecret(app.getSecret());
        ClaimRepresentation claimRep = ModelToRepresentation.toRepresentation((ClientModel)app);
        appRep.setClaims(claimRep);
        return appRep;
    }
View Full Code Here

        assertEquals(application, actual);
    }

    @Test
    public void json() {
        ApplicationRepresentation representation = ModelToRepresentation.toRepresentation(application);
        representation.setId(null);

        RealmModel realm = realmManager.createRealm("copy");
        ApplicationModel copy = RepresentationToModel.createApplication(realm, representation, true);

        assertEquals(application, copy);
View Full Code Here

        }
        return rep;
    }

    public static ApplicationRepresentation toRepresentation(ApplicationModel applicationModel) {
        ApplicationRepresentation rep = new ApplicationRepresentation();
        rep.setId(applicationModel.getId());
        rep.setName(applicationModel.getName());
        rep.setEnabled(applicationModel.isEnabled());
        rep.setAdminUrl(applicationModel.getManagementUrl());
        rep.setPublicClient(applicationModel.isPublicClient());
        rep.setProtocol(applicationModel.getProtocol());
        rep.setAttributes(applicationModel.getAttributes());
        rep.setFullScopeAllowed(applicationModel.isFullScopeAllowed());
        rep.setBearerOnly(applicationModel.isBearerOnly());
        rep.setSurrogateAuthRequired(applicationModel.isSurrogateAuthRequired());
        rep.setBaseUrl(applicationModel.getBaseUrl());
        rep.setNotBefore(applicationModel.getNotBefore());
        rep.setNodeReRegistrationTimeout(applicationModel.getNodeReRegistrationTimeout());

        Set<String> redirectUris = applicationModel.getRedirectUris();
        if (redirectUris != null) {
            rep.setRedirectUris(new LinkedList<String>(redirectUris));
        }

        Set<String> webOrigins = applicationModel.getWebOrigins();
        if (webOrigins != null) {
            rep.setWebOrigins(new LinkedList<String>(webOrigins));
        }

        if (!applicationModel.getDefaultRoles().isEmpty()) {
            rep.setDefaultRoles(applicationModel.getDefaultRoles().toArray(new String[0]));
        }

        if (!applicationModel.getRegisteredNodes().isEmpty()) {
            rep.setRegisteredNodes(new HashMap<String, Integer>(applicationModel.getRegisteredNodes()));
        }

        return rep;
    }
View Full Code Here

        boolean view = auth.hasView();
        for (ApplicationModel applicationModel : applicationModels) {
            if (view) {
                rep.add(ModelToRepresentation.toRepresentation(applicationModel));
            } else {
                ApplicationRepresentation app = new ApplicationRepresentation();
                app.setName(applicationModel.getName());
                rep.add(app);
            }
        }
        return rep;
    }
View Full Code Here

        assertNames(realm.applications().findAll(), "account", "realm-management", "security-admin-console");
    }

    @Test
    public void createApplication() {
        ApplicationRepresentation rep = new ApplicationRepresentation();
        rep.setName("my-app");
        rep.setEnabled(true);
        realm.applications().create(rep);

        assertNames(realm.applications().findAll(), "account", "realm-management", "security-admin-console", "my-app");
    }
View Full Code Here

    @Test
    public void getApplicationRepresentation() {
        createApplication();

        ApplicationRepresentation rep = realm.applications().get("my-app").toRepresentation();
        assertEquals("my-app", rep.getName());
        assertTrue(rep.isEnabled());
    }
View Full Code Here

        checkRealmRep(rep, storedRealm);

        if (rep.getApplications() != null) {
            WebTarget applicationsTarget = realmTarget.path("applications");
            for (ApplicationRepresentation appRep : rep.getApplications()) {
                ApplicationRepresentation newApp = new ApplicationRepresentation();
                if (appRep.getId() != null) newApp.setId(appRep.getId());
                newApp.setName(appRep.getName());
                if (appRep.getSecret() != null) {
                    newApp.setSecret(appRep.getSecret());
                }
                Response appCreateResponse = applicationsTarget.request().post(Entity.json(newApp));
                Assert.assertEquals(201, appCreateResponse.getStatus());
                appCreateResponse.close();
                WebTarget appTarget = applicationsTarget.path(appRep.getName());
                CredentialRepresentation cred = appTarget.path("client-secret").request().get(CredentialRepresentation.class);
                if (appRep.getSecret() != null) Assert.assertEquals(appRep.getSecret(), cred.getValue());
                CredentialRepresentation newCred = appTarget.path("client-secret").request().post(null, CredentialRepresentation.class);
                Assert.assertNotEquals(newCred.getValue(), cred.getValue());

                Response appUpdateResponse = appTarget.request().put(Entity.json(appRep));
                Assert.assertEquals(204, appUpdateResponse.getStatus());
                appUpdateResponse.close();


                ApplicationRepresentation storedApp = appTarget.request().get(ApplicationRepresentation.class);

                checkAppUpdate(appRep, storedApp);

            }
        }
View Full Code Here

TOP

Related Classes of org.keycloak.representations.idm.ApplicationRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.