Package org.apache.airavata.gfac.gsissh.security

Examples of org.apache.airavata.gfac.gsissh.security.GSISecurityContext


        } else if (registeredHost.getType() instanceof GsisshHostType) {
            String credentialStoreToken = jobExecutionContext.getCredentialStoreToken(); // this is set by the framework
            RequestData requestData = new RequestData(ServerSettings.getDefaultUserGateway());
            requestData.setTokenId(credentialStoreToken);
            PBSCluster pbsCluster = null;
            GSISecurityContext context = null;
            try {
                TokenizedMyProxyAuthInfo tokenizedMyProxyAuthInfo = new TokenizedMyProxyAuthInfo(requestData);
                GsisshHostType gsisshHostType = (GsisshHostType) registeredHost.getType();
                ServerInfo serverInfo = new ServerInfo(requestData.getMyProxyUserName(), registeredHost.getType().getHostAddress(),
                        gsisshHostType.getPort());

                JobManagerConfiguration jConfig = null;
                String installedParentPath = ((HpcApplicationDeploymentType)
                        jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
                String jobManager = ((GsisshHostType) registeredHost.getType()).getJobManager();
                if (jobManager == null) {
                    logger.error("No Job Manager is configured, so we are picking pbs as the default job manager");
                    jConfig = CommonUtils.getPBSJobManager(installedParentPath);
                } else {
                    if (PBS_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getPBSJobManager(installedParentPath);
                    } else if (SLURM_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getSLURMJobManager(installedParentPath);
                    } else if (SUN_GRID_ENGINE_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getSGEJobManager(installedParentPath);
                    }
                }
                pbsCluster = new PBSCluster(serverInfo, tokenizedMyProxyAuthInfo, jConfig);
                context = new GSISecurityContext(tokenizedMyProxyAuthInfo.getCredentialReader(), requestData,pbsCluster);
            } catch (Exception e) {
                throw new GFacException("An error occurred while creating GSI security context", e);
            }
            jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT, context);
        }
View Full Code Here



    public ResourceConnection(HostMonitorData hostMonitorData,AuthenticationInfo authInfo) throws SSHApiException {
        MonitorID monitorID = hostMonitorData.getMonitorIDs().get(0);
        try {
            GSISecurityContext securityContext = (GSISecurityContext) monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
            if(securityContext != null) {
                cluster = (PBSCluster) securityContext.getPbsCluster();
            }else {
                SSHSecurityContext sshSecurityContext = (SSHSecurityContext) monitorID.getJobExecutionContext().getSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT);
                cluster = (PBSCluster)sshSecurityContext.getPbsCluster();
            }
View Full Code Here

    }

    public ResourceConnection(HostMonitorData hostMonitorData) throws SSHApiException {
        MonitorID monitorID = hostMonitorData.getMonitorIDs().get(0);
        try {
            GSISecurityContext securityContext = (GSISecurityContext) monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
            cluster = (PBSCluster) securityContext.getPbsCluster();

            // we just use cluster configuration from the incoming request and construct a new cluster because for monitoring
            // we are using our own credentials and not using one users account to do everything.
            cluster = new PBSCluster(cluster.getServerInfo(), authenticationInfo, cluster.getJobManagerConfiguration());
        } catch (GFacException e) {
View Full Code Here


    public ResourceConnection(HostMonitorData hostMonitorData) throws SSHApiException {
        MonitorID monitorID = hostMonitorData.getMonitorIDs().get(0);
        try {
            GSISecurityContext securityContext = (GSISecurityContext)monitorID.getJobExecutionContext().getSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT);
            cluster = (PBSCluster)securityContext.getPbsCluster();
        } catch (GFacException e) {
            log.error("Error reading data from job ExecutionContext");
        }
    }
View Full Code Here

        try {
            pbsCluster = new PBSCluster(serverInfo, authenticationInfo, CommonUtils.getPBSJobManager(app.getInstalledParentPath()));
        } catch (SSHApiException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
        GSISecurityContext sshSecurityContext = new GSISecurityContext(pbsCluster);
        return sshSecurityContext;
    }
View Full Code Here

        DerbyUtil.stopDerbyServer();
    }

    private GSSCredential getGSSCredentials() throws Exception {

        GSISecurityContext gsiSecurityContext = getGSISecurityContext();

        return gsiSecurityContext.getGssCredentials();
    }
View Full Code Here

        requestData.setMyProxyPassword(password);
        requestData.setMyProxyServerUrl(ServerSettings.getMyProxyServer());
        requestData.setMyProxyLifeTime(ServerSettings.getMyProxyLifetime());
        CredentialReader credentialReader = CredentialReaderFactory.createCredentialStoreReader(getDbUtil());

        return new GSISecurityContext(credentialReader, requestData);
    }
View Full Code Here

    } */

    @Test
    public void testGetDefaultCredentials() throws Exception {
        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
        Assert.assertNotNull(gsiSecurityContext.getDefaultCredentials());

    }
View Full Code Here

    }

    @Test
    public void testGetProxyCredentials() throws Exception {
        GSISecurityContext gsiSecurityContext = getGSISecurityContext();
        Assert.assertNotNull(gsiSecurityContext.getProxyCredentials());

    }
View Full Code Here

    public static final String SLURM_JOB_MANAGER = "slurm";
    public static final String SUN_GRID_ENGINE_JOB_MANAGER = "sge";

    public static void addSecurityContext(JobExecutionContext jobExecutionContext) throws GFacException, ApplicationSettingsException {
        RequestData requestData = new RequestData("default");
        GSISecurityContext context = null;
        try {
            //todo fix this
            context = new GSISecurityContext(null, requestData);
        } catch (Exception e) {
            throw new GFacException("An error occurred while creating GSI security context", e);
        }
        HostDescription registeredHost = jobExecutionContext.getApplicationContext().getHostDescription();
        if (registeredHost.getType() instanceof GlobusHostType || registeredHost.getType() instanceof UnicoreHostType
                || registeredHost.getType() instanceof SSHHostType) {
            logger.error("This is a wrong method to invoke to non ssh host types,please check your gfac-config.xml");
        } else if (registeredHost.getType() instanceof GsisshHostType) {
            GSIAuthenticationInfo authenticationInfo
                    = new MyProxyAuthenticationInfo(requestData.getMyProxyUserName(), requestData.getMyProxyPassword(), requestData.getMyProxyServerUrl(),
                    requestData.getMyProxyPort(), requestData.getMyProxyLifeTime(), System.getProperty(Constants.TRUSTED_CERTIFICATE_SYSTEM_PROPERTY));
            GsisshHostType gsisshHostType = (GsisshHostType) registeredHost.getType();
            ServerInfo serverInfo = new ServerInfo(requestData.getMyProxyUserName(), registeredHost.getType().getHostAddress(),
                    gsisshHostType.getPort());

            Cluster pbsCluster = null;
            try {
                JobManagerConfiguration jConfig = null;
                String installedParentPath = ((HpcApplicationDeploymentType)
                        jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
                String jobManager = ((GsisshHostType) registeredHost.getType()).getJobManager();
                if (jobManager == null) {
                    logger.error("No Job Manager is configured, so we are picking pbs as the default job manager");
                    jConfig = CommonUtils.getPBSJobManager(installedParentPath);
                } else {
                    if (PBS_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getPBSJobManager(installedParentPath);
                    } else if (SLURM_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getSLURMJobManager(installedParentPath);
                    } else if (SUN_GRID_ENGINE_JOB_MANAGER.equalsIgnoreCase(jobManager)) {
                        jConfig = CommonUtils.getSGEJobManager(installedParentPath);
                    }
                }
                pbsCluster = new PBSCluster(serverInfo, authenticationInfo, jConfig);
            } catch (SSHApiException e) {
               throw new GFacException("An error occurred while creating GSI security context", e);
            }

            context.setPbsCluster(pbsCluster);
        }
        jobExecutionContext.addSecurityContext(GSISecurityContext.GSI_SECURITY_CONTEXT,context);
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.gsissh.security.GSISecurityContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.