use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.
the class IamAdminServicesHandler method findUsers.
@Override
@SecurityCheck
public List<UserProfile> findUsers(AuthzToken authzToken, String email, String userId) throws IamAdminServicesException, AuthorizationException, TException {
TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
try {
PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
return keycloakclient.findUser(isRealmAdminCredentials, gatewayId, email, userId);
} catch (TException | ApplicationSettingsException ex) {
String msg = "Error while retrieving users from Identity Server, reason: " + ex.getMessage();
logger.error(msg, ex);
throw new IamAdminServicesException(msg);
}
}
use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.
the class IamAdminServicesHandler method removeRoleFromUser.
@Override
@SecurityCheck
public boolean removeRoleFromUser(AuthzToken authzToken, String username, String roleName) throws IamAdminServicesException, AuthorizationException, TException {
TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
try {
PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
return keycloakclient.removeRoleFromUser(isRealmAdminCredentials, gatewayId, username, roleName);
} catch (TException | ApplicationSettingsException ex) {
String msg = "Error while removing role from user, reason: " + ex.getMessage();
logger.error(msg, ex);
throw new IamAdminServicesException(msg);
}
}
use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.
the class SetupNewGateway method findUser.
// public static void resetPassword(){
// UserProfile user = new UserProfile();
// user.setUserId("testuser");
// List<String> emails = new ArrayList<>();
// emails.add("some.man@outlook.com");
// user.setGatewayId("maven.test.gateway");
// user.setEmails(emails);
// TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
// try {
// PasswordCredential tenantAdminCreds = new PasswordCredential();
// tenantAdminCreds.setGatewayId(user.getGatewayId());
// tenantAdminCreds.setDescription("test credentials for tenant admin creation");
// tenantAdminCreds.setLoginUserName("mavenTest");
// tenantAdminCreds.setPassword("Test@1234");
// tenantAdminCreds.setPortalUserName("TenantAdmin");
// client.resetUserPassword(tenantAdminCreds,user,"test@123");
// } catch (IamAdminServicesException e) {
// e.printStackTrace();
// }
// }
public static void findUser() {
UserProfile user = new UserProfile();
List<String> emails = new ArrayList<>();
emails.add("some.man@outlook.com");
user.setGatewayId("maven.test.gateway");
user.setEmails(emails);
TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
try {
PasswordCredential tenantAdminCreds = new PasswordCredential();
tenantAdminCreds.setGatewayId(user.getGatewayId());
tenantAdminCreds.setDescription("test credentials for tenant admin creation");
tenantAdminCreds.setLoginUserName("mavenTest");
tenantAdminCreds.setPassword("Test@1234");
tenantAdminCreds.setPortalUserName("TenantAdmin");
List<UserProfile> list = client.findUser(tenantAdminCreds, "maven.test.gateway", "some.man@outlook.com", null);
System.out.println(list.get(0).getUserId());
} catch (IamAdminServicesException e) {
e.printStackTrace();
}
}
use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.
the class SetupNewGateway method UserRegistration.
public static void UserRegistration() {
UserProfile user = new UserProfile();
user.setUserId("testuser");
user.setFirstName("test-firstname");
user.setLastName("test-lastname");
List<String> emails = new ArrayList<>();
emails.add("some.man@outlook.com");
user.setGatewayId("maven.test.gateway");
user.setEmails(emails);
PasswordCredential tenantAdminCreds = new PasswordCredential();
tenantAdminCreds.setGatewayId(user.getGatewayId());
tenantAdminCreds.setDescription("test credentials for tenant admin creation");
tenantAdminCreds.setLoginUserName("mavenTest");
tenantAdminCreds.setPassword("Test@1234");
tenantAdminCreds.setPortalUserName("TenantAdmin");
TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
try {
client.createUser(tenantAdminCreds, user.getGatewayId(), user.getUserId(), user.getEmails().get(0), user.getFirstName(), user.getLastName(), "test@123");
client.enableUserAccount(tenantAdminCreds, user.getGatewayId(), user.getUserId());
} catch (IamAdminServicesException e) {
e.printStackTrace();
}
}
Aggregations