Search in sources :

Example 16 with PasswordCredential

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);
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 17 with PasswordCredential

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);
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) TException(org.apache.thrift.TException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 18 with PasswordCredential

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();
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) UserProfile(org.apache.airavata.model.user.UserProfile) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) ArrayList(java.util.ArrayList) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential)

Example 19 with PasswordCredential

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();
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) UserProfile(org.apache.airavata.model.user.UserProfile) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) ArrayList(java.util.ArrayList) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential)

Aggregations

PasswordCredential (org.apache.airavata.model.credential.store.PasswordCredential)19 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)12 TenantManagementKeycloakImpl (org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl)12 IamAdminServicesException (org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException)12 TException (org.apache.thrift.TException)11 SecurityCheck (org.apache.airavata.service.security.interceptor.SecurityCheck)9 CredentialStoreService (org.apache.airavata.credential.store.cpi.CredentialStoreService)6 GatewayResourceProfile (org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile)3 RegistryServiceException (org.apache.airavata.registry.api.exception.RegistryServiceException)3 ArrayList (java.util.ArrayList)2 UserProfile (org.apache.airavata.model.user.UserProfile)2 Gateway (org.apache.airavata.model.workspace.Gateway)2 AiravataSecurityException (org.apache.airavata.security.AiravataSecurityException)2 TrustStoreManager (org.apache.airavata.security.util.TrustStoreManager)2 AxisFault (org.apache.axis2.AxisFault)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1