Package org.apache.airavata.gfac.ssh.security

Examples of org.apache.airavata.gfac.ssh.security.SSHSecurityContext


        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();
            }

            // 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.
            authenticationInfo = authInfo;
View Full Code Here


        HostDescription registeredHost = jobExecutionContext.getApplicationContext().getHostDescription();
        if (registeredHost.getType() instanceof GlobusHostType || registeredHost.getType() instanceof UnicoreHostType
                || registeredHost.getType() instanceof GsisshHostType) {
            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 SSHHostType) {
            SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
            String credentialStoreToken = jobExecutionContext.getCredentialStoreToken(); // this is set by the framework
            RequestData requestData = new RequestData(ServerSettings.getDefaultUserGateway());
            requestData.setTokenId(credentialStoreToken);

            ServerInfo serverInfo = new ServerInfo(null, registeredHost.getType().getHostAddress());

            Cluster pbsCluster = null;
            try {
                TokenizedSSHAuthInfo tokenizedSSHAuthInfo = new TokenizedSSHAuthInfo(requestData);
                String installedParentPath = "/";
                if (((SSHHostType) registeredHost.getType()).getHpcResource()) {
                    installedParentPath = ((HpcApplicationDeploymentType)
                            jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
                }
                SSHCredential credentials = tokenizedSSHAuthInfo.getCredentials();// this is just a call to get and set credentials in to this object,data will be used
                serverInfo.setUserName(credentials.getPortalUserName());

                // inside the pbsCluser object
                pbsCluster = new PBSCluster(serverInfo, tokenizedSSHAuthInfo,
                        CommonUtils.getPBSJobManager(installedParentPath));
            } catch (Exception e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            sshSecurityContext.setPbsCluster(pbsCluster);
            jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, sshSecurityContext);
        }
    }
View Full Code Here

        }
        // Server info
        ServerInfo serverInfo = new ServerInfo(this.userName, this.hostName);

        Cluster pbsCluster = null;
        SSHSecurityContext sshSecurityContext = null;

            JobManagerConfiguration pbsJobManager = CommonUtils.getPBSJobManager(app.getInstalledParentPath());
            pbsCluster = new PBSCluster(serverInfo, authenticationInfo, pbsJobManager);


            sshSecurityContext = new SSHSecurityContext();
            sshSecurityContext.setPbsCluster(pbsCluster);
            sshSecurityContext.setUsername(userName);
            sshSecurityContext.setKeyPass(passPhrase);
            sshSecurityContext.setPrivateKeyLoc(privateKeyPath);
             return sshSecurityContext;
        } catch (SSHApiException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
        return null;
View Full Code Here

        jobExecutionContext.setOutMessageContext(outMessage);

    }

  private SSHSecurityContext getSecurityContext() {
    SSHSecurityContext context = new SSHSecurityContext();
        context.setUsername("lginnali");
        context.setPrivateKeyLoc("~/.ssh/id_dsa");
        context.setKeyPass("i want to be free");
    return context;
  }
View Full Code Here

            String sshUserName = configurationProperties.getProperty(Constants.SSH_USER_NAME);
            String sshPrivateKey = configurationProperties.getProperty(Constants.SSH_PRIVATE_KEY);
            String sshPrivateKeyPass = configurationProperties.getProperty(Constants.SSH_PRIVATE_KEY_PASS);
            String sshPassword = configurationProperties.getProperty(Constants.SSH_PASSWORD);
            String sshPublicKey = configurationProperties.getProperty(Constants.SSH_PUBLIC_KEY);
            SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
            AuthenticationInfo authenticationInfo = null;
            // we give higher preference to the password over keypair ssh authentication
            if (sshPassword != null) {
                authenticationInfo = new DefaultPasswordAuthenticationInfo(sshPassword);
            } else {
                authenticationInfo = new DefaultPublicKeyFileAuthentication(sshPublicKey, sshPrivateKey, sshPrivateKeyPass);
            }
            ServerInfo serverInfo = new ServerInfo(sshUserName, registeredHost.getType().getHostAddress());

            Cluster pbsCluster = null;
            try {
                String installedParentPath = "/";
                if (((SSHHostType) registeredHost.getType()).getHpcResource()) {
                    installedParentPath = ((HpcApplicationDeploymentType)
                            jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
                }
                pbsCluster = new PBSCluster(serverInfo, authenticationInfo,
                        CommonUtils.getPBSJobManager(installedParentPath));
            } catch (SSHApiException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
            }
            sshSecurityContext.setPbsCluster(pbsCluster);
            sshSecurityContext.setUsername(sshUserName);
            jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, sshSecurityContext);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.ssh.security.SSHSecurityContext

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.