Exemplo n.º 1
0
  private void createObjects(RealmModel realm) {
    ClientModel app1 = realm.addClient("app1");
    realm.addClient("app2");

    realmManager.getSession().users().addUser(realm, "user1");
    realmManager.getSession().users().addUser(realm, "user2");

    realm.addRole("role1");
    realm.addRole("role2");

    app1.addRole("app1Role1");
    app1.addScopeMapping(realm.getRole("role1"));

    realm.addClient("cl1");
  }
Exemplo n.º 2
0
            @Override
            public void config(
                RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
              ClientModel app = appRealm.addClient("service-account-cl");
              app.setSecret("secret1");
              new ClientManager(manager).enableServiceAccount(app);

              ClientModel disabledApp = appRealm.addClient("service-account-disabled");
              disabledApp.setSecret("secret1");

              UserModel serviceAccountUser =
                  session
                      .users()
                      .getUserByUsername(
                          ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX
                              + "service-account-cl",
                          appRealm);
              userId = serviceAccountUser.getId();
            }
            @Override
            public void config(
                RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
              ClientModel app = appRealm.addClient("resource-owner");
              app.setSecret("secret");

              UserModel user = session.users().addUser(appRealm, "direct-login");
              user.setEmail("direct-login@localhost");
              user.setEnabled(true);

              userId = user.getId();

              session
                  .users()
                  .updateCredential(appRealm, user, UserCredentialModel.password("password"));
            }