Exemple #1
0
  /**
   * Should not be called from an import. This really expects that the client is created from the
   * admin console.
   *
   * @param session
   * @param realm
   * @param rep
   * @param addDefaultRoles
   * @return
   */
  public static ClientModel createClient(
      KeycloakSession session,
      RealmModel realm,
      ClientRepresentation rep,
      boolean addDefaultRoles) {
    ClientModel client = RepresentationToModel.createClient(session, realm, rep, addDefaultRoles);

    if (rep.getProtocol() != null) {
      LoginProtocolFactory providerFactory =
          (LoginProtocolFactory)
              session
                  .getKeycloakSessionFactory()
                  .getProviderFactory(LoginProtocol.class, rep.getProtocol());
      providerFactory.setupClientDefaults(rep, client);
    }

    // remove default mappers if there is a template
    if (rep.getProtocolMappers() == null && rep.getClientTemplate() != null) {
      Set<ProtocolMapperModel> mappers = client.getProtocolMappers();
      for (ProtocolMapperModel mapper : mappers) client.removeProtocolMapper(mapper);
    }
    return client;
  }
Exemple #2
0
 @Override
 public void removeProtocolMapper(ProtocolMapperModel mapping) {
   getDelegateForUpdate();
   updated.removeProtocolMapper(mapping);
 }