Search in sources :

Example 11 with PasswordCredential

use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.

the class SetupNewGateway method setUpGateway.

public static void setUpGateway() {
    Gateway testGateway = new Gateway();
    testGateway.setGatewayId("maven.test.gateway");
    testGateway.setGatewayName("maven test gateway");
    testGateway.setIdentityServerUserName("mavenTest");
    testGateway.setGatewayAdminFirstName("Maven");
    testGateway.setGatewayAdminLastName("Test");
    testGateway.setGatewayAdminEmail("some.man@gmail.com");
    PasswordCredential superAdminCreds = new PasswordCredential();
    superAdminCreds.setGatewayId(testGateway.getGatewayId());
    superAdminCreds.setDescription("test credentials for IS admin creation");
    superAdminCreds.setLoginUserName("airavataAdmin");
    superAdminCreds.setPassword("Airavata@123");
    superAdminCreds.setPortalUserName("superAdmin");
    TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
    try {
        client.addTenant(superAdminCreds, testGateway);
        if (!client.createTenantAdminAccount(superAdminCreds, testGateway, "Test@123")) {
            logger.error("Admin account creation failed !!, please refer error logs for reason");
        }
        Gateway gatewayWithIdAndSecret = client.configureClient(superAdminCreds, testGateway);
        System.out.println(gatewayWithIdAndSecret.getOauthClientId());
        System.out.println(gatewayWithIdAndSecret.getOauthClientSecret());
    } catch (IamAdminServicesException ex) {
        logger.error("Gateway Setup Failed, reason: " + ex.getCause(), ex);
    }
}
Also used : TenantManagementKeycloakImpl(org.apache.airavata.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) Gateway(org.apache.airavata.model.workspace.Gateway) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential)

Example 12 with PasswordCredential

use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.

the class IamAdminServicesHandler method getUsersWithRole.

@Override
@SecurityCheck
public List<UserProfile> getUsersWithRole(AuthzToken authzToken, 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.getUsersWithRole(isRealmAdminCredentials, gatewayId, roleName);
    } catch (Exception ex) {
        String msg = "Error while retrieving users with role, 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) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) PasswordCredential(org.apache.airavata.model.credential.store.PasswordCredential) TException(org.apache.thrift.TException) AuthorizationException(org.apache.airavata.model.error.AuthorizationException) RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) CredentialStoreException(org.apache.airavata.credential.store.exception.CredentialStoreException) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) IamAdminServicesException(org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException) SecurityCheck(org.apache.airavata.service.security.interceptor.SecurityCheck)

Example 13 with PasswordCredential

use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.

the class IamAdminServicesHandler method enableUser.

@Override
@SecurityCheck
public boolean enableUser(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException {
    TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
    String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
    try {
        PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
        if (keycloakclient.enableUserAccount(isRealmAdminCredentials, gatewayId, username))
            return true;
        else
            return false;
    } catch (TException | ApplicationSettingsException ex) {
        String msg = "Error while enabling user account, 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 14 with PasswordCredential

use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.

the class IamAdminServicesHandler method addRoleToUser.

@Override
@SecurityCheck
public boolean addRoleToUser(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.addRoleToUser(isRealmAdminCredentials, gatewayId, username, roleName);
    } catch (TException | ApplicationSettingsException ex) {
        String msg = "Error while adding role to 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 15 with PasswordCredential

use of org.apache.airavata.model.credential.store.PasswordCredential in project airavata by apache.

the class IamAdminServicesHandler method resetUserPassword.

@Override
@SecurityCheck
public boolean resetUserPassword(AuthzToken authzToken, String username, String newPassword) throws IamAdminServicesException, AuthorizationException, TException {
    TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
    String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
    try {
        PasswordCredential isRealmAdminCredentials = getTenantAdminPasswordCredential(gatewayId);
        if (keycloakclient.resetUserPassword(isRealmAdminCredentials, gatewayId, username, newPassword))
            return true;
        else
            return false;
    } catch (TException | ApplicationSettingsException ex) {
        String msg = "Error while resetting user password in 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)

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