Added other methods
This commit is contained in:
parent
d18a598540
commit
bc554b4d70
@ -21,7 +21,10 @@ public class App
|
|||||||
try{
|
try{
|
||||||
//awsCognitoIDPClient = new AWSCognitoIdentityProviderClient(new BasicAWSCredentials("AKIAWZE5RV2A25L5XZHW", "4VDMBOAjfcM4IDMuVh8p9YOMqI3zu/JrvF7Nsm4b")).withRegion(Regions.US_EAST_2);
|
//awsCognitoIDPClient = new AWSCognitoIdentityProviderClient(new BasicAWSCredentials("AKIAWZE5RV2A25L5XZHW", "4VDMBOAjfcM4IDMuVh8p9YOMqI3zu/JrvF7Nsm4b")).withRegion(Regions.US_EAST_2);
|
||||||
|
|
||||||
_addUser();
|
// _addUser();
|
||||||
|
|
||||||
|
_listGroupsForUser();
|
||||||
|
_removeGroupForUser();
|
||||||
|
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@ -103,4 +106,54 @@ public class App
|
|||||||
System.out.println(user.getUsername());
|
System.out.println(user.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void _addUserToGroup(){
|
||||||
|
AWSCognitoIdentityProvider cognitoClient = getAmazonCognitoIdentityClient();
|
||||||
|
AdminAddUserToGroupRequest request = new AdminAddUserToGroupRequest();
|
||||||
|
request.setUserPoolId("us-east-1_lPr8YBxKX");
|
||||||
|
request.setUsername("shafaat");
|
||||||
|
request.setGroupName("Maker");
|
||||||
|
|
||||||
|
try{
|
||||||
|
cognitoClient.adminAddUserToGroup(request);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _listGroupsForUser(){
|
||||||
|
AWSCognitoIdentityProvider cognitoClient = getAmazonCognitoIdentityClient();
|
||||||
|
|
||||||
|
AdminListGroupsForUserRequest request = new AdminListGroupsForUserRequest();
|
||||||
|
request.setUsername("shafaat");
|
||||||
|
request.setUserPoolId("us-east-1_lPr8YBxKX");
|
||||||
|
|
||||||
|
|
||||||
|
try{
|
||||||
|
AdminListGroupsForUserResult result = cognitoClient.adminListGroupsForUser(request);
|
||||||
|
result.getGroups().stream()
|
||||||
|
.map( a -> a.getGroupName())
|
||||||
|
.forEach( System.out:: println );
|
||||||
|
;
|
||||||
|
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _removeGroupForUser(){
|
||||||
|
AWSCognitoIdentityProvider cognitoClient = getAmazonCognitoIdentityClient();
|
||||||
|
|
||||||
|
AdminRemoveUserFromGroupRequest request = new AdminRemoveUserFromGroupRequest();
|
||||||
|
request.setUsername("shafaat");
|
||||||
|
request.setUserPoolId("us-east-1_lPr8YBxKX");
|
||||||
|
request.setGroupName("Maker");
|
||||||
|
|
||||||
|
try{
|
||||||
|
cognitoClient.adminRemoveUserFromGroup(request);
|
||||||
|
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user