[精讚] [會員登入]
612

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

你可能感興趣的文章

ArrayList 與 HashMap 範例 public static void main(String[] args) { String titleIds = &

Thread java thread

讀取特定資料夾下的xls檔 讀取特定資料夾下的xls檔

停止多執行緒 利用主程式呼叫多執行緒時, 要怎麼停止正在執行的多執行緒

java.time 時間 instant java.time

keycloak 透過java client lib新增user 使用keycloak-admin-client lib maven <dependency> <gro

隨機好文

java-身份証字號驗証 FormatCheck.java public class FormatCheck { private volatile

tmux 將終端機切割成多個視 窗 tmux, multiple terminal

vue.js components 多個組件的呈現 vue.js 組件 component

台中市網路應用競賽試場安排(一) 排試場就跟排班或是排課表一樣, 找不到一個都能讓所有人滿意的結果

管理Google共用雲端硬碟 管理Google共用雲端硬碟