[精讚] [會員登入]
378

keycloak 透過java client lib新增user

使用keycloak-admin-client lib maven <dependency> <gro

分享此文連結 //n.sfs.tw/15093

分享連結 keycloak 透過java client lib新增user@igogo
(文章歡迎轉載,務必尊重版權註明連結來源)
最後編修
2021-05-10 08:48:34 By igogo
 

 

 

使用keycloak-admin-client lib

 

maven

	<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-admin-client</artifactId>
			<version>12.0.4</version>
	</dependency>

 

 

 

    Keycloak keycloak = Keycloak.getInstance(keycloakserverurl, "master", "admin", "PASSWORD", "demoapp");
        RealmRepresentation realm = keycloak.realm("master").toRepresentation() ;
//          create a user
        UserRepresentation userRepresentation = new UserRepresentation();
        userRepresentation.setUsername("ccc");
        userRepresentation.setFirstName("first name");
        userRepresentation.setEmail("ddd@ccc");
//        userRepresentation.setRequiredActions(Collections.emptyList());
        userRepresentation.setEnabled(true);

        CredentialRepresentation credentialRepresentation = new CredentialRepresentation();
        credentialRepresentation.setType(CredentialRepresentation.PASSWORD);
        credentialRepresentation.setValue("1234");

        userRepresentation.setCredentials(Collections.singletonList(credentialRepresentation));

        Response response = keycloak.realm("master").users().create(userRepresentation);
        System.out.println("response status: " + response.getStatus());

 

參考

https://www.keycloak.org/docs/latest/server_development/

END

你可能感興趣的文章

java lambda files filter java, files filter, lambda

使用poi 解析 docx 原先是想解析出在docx 中的文字跟圖片, 但是, 有些我們認為是圖片, 其實是用方程式表示, 實在是太麻煩了 就記錄一

spring boot 使用jdbc連接mariadb spring boot, mariadb, jdbc, rowmapper

spring boot jpa 使用多個欄位排序 我有一entity 叫 team 資料欄下如下 @Id @GeneratedValue(strategy = Gener

刪除資料夾內的檔案 lambda 一行文 Arrays.stream(new File("/folder/path").

利用maven建立一個可執行的jar檔 利用maven建立一個可執行的jar檔

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[vue.js] 設定 content type 今天在wickt 端怎麼就是收不到vue.js 以post 傳過來的資料 找了好久才發現 application/jso

[vue.js] input event Form-Input-Components-using-Custom-Events

windows ad 如何得知 dn 值 如何得知 windows ad 上的使用者dn 值 https://support.symantec.com/en_US

臺中市雲端校務系統與Windows AD帳號整合(3) LDAP的基本概念

[scratch2] 分數排名 在清單中隨机產生5名學生的考試分數, 再利用另一個清單排名 想法, 分數愈高者排名愈好, 例如名次是第5名, 那分數是最