Package org.globus.gsi

Examples of org.globus.gsi.GlobusCredential


  public GSSCredential getGssCredential() throws Exception {
        try {
          if(hostcertsKeyFile != null && !user){
               FileInputStream fis = new FileInputStream(hostcertsKeyFile);
                      GlobusCredential globusCred = new GlobusCredential(fis);
                      this.gssCredential = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
                  
          }else{
          this.gssCredential = getDefaultProxy();
          }
View Full Code Here


      MyProxy myproxy = new MyProxy(myproxyHostname, myproxyPortNumber);
      int lifeHours = myproxyLifeTime * SECS_PER_HOUR;
      GSSCredential proxy = myproxy.get(myproxyUserName, myproxyPassword,
          lifeHours);

      GlobusCredential globusCred = null;
      if (proxy instanceof GlobusGSSCredentialImpl) {
        globusCred = ((GlobusGSSCredentialImpl) proxy)
            .getGlobusCredential();
        System.out.println("got proxy from myproxy for "
            + myproxyUserName + " with " + myproxyLifeTime
            + " lifetime.");
        String uid = myproxyUserName;
        if (proxyloc == null) {
          System.out.println("uid: " + uid);
          proxyloc = "/tmp/x509up_u" + uid;
        }
        File proxyfile = new File(proxyloc);
        System.out.println("proxy location: " + proxyfile.getAbsolutePath());
        if (proxyfile.exists() == false) {
          String dirpath = proxyloc.substring(0, proxyloc
              .lastIndexOf('/'));
          File dir = new File(dirpath);
          if (dir.exists() == false) {
            dir.mkdirs();
            System.out.println("new directory " + dirpath
                + " is created.");
          }
          proxyfile.createNewFile();
          System.out.println("new proxy file " + proxyloc
              + " is created.");
        }
        FileOutputStream fout = new FileOutputStream(proxyfile);
        globusCred.save(fout);
        fout.close();
        String osName = System.getProperty("os.name");
        if (!osName.contains("Windows")) {
        Runtime.getRuntime().exec("/bin/chmod 600 " + proxyloc);
        }
View Full Code Here

    public static GSSCredential createCredentials() throws XregistryException {
        try {
            // load the x509 proxy. if not found, quit.
            String proxyPath = System.getProperty("X509_USER_PROXY");
            System.out.println("Proxy location = " + proxyPath);
            GlobusCredential globusCred;
            GSSCredential gssCred;

            // if delegated proxy is used, then the proxy path is denoted by the
            // env variable X509_USER_PROXY
            if (proxyPath != null && !"".equals(proxyPath)) {
                globusCred = new GlobusCredential(proxyPath);
            } else {
                globusCred = GlobusCredential.getDefaultCredential();
            }
            globusCred.verify();
            gssCred = getGSSCredential(globusCred);

            return gssCred;
        } catch (GlobusCredentialException e) {
            throw new XregistryException(e);
View Full Code Here

            MyProxy myproxy = new MyProxy( hostname, port );
            GSSCredential proxy =
                myproxy.get(username, password, lifetime);


            GlobusCredential globusCred = null;
            if(proxy instanceof GlobusGSSCredentialImpl) {
                globusCred =
                    ((GlobusGSSCredentialImpl)proxy).getGlobusCredential();
                log.info("got proxy from myproxy for " + username
                              + " with " + lifetime + " lifetime.");
//                InputStream is = Runtime.getRuntime().exec( "/bin/env").getInputStream();
//                BufferedReader in
//                    = new BufferedReader(new InputStreamReader(is));
//                String str;
//                while((str = in.readLine()) != null) {
//                    if(str.startsWith("X509_USER_PROXY=")) {
//                        proxyloc = str.substring("X509_USER_PROXY=".length());
//                    }
//                }
//                //                proxyloc = XpolaUtil.getSysEnv("X509_USER_PROXY");
//                log.info("proxy location0: " + proxyloc);
                if(proxyloc == null) {
                    String uid = XpolaUtil.getSysUserid();
                    log.info("uid: " + uid);
                    proxyloc = "/tmp/x509up_u" + uid;
                }
                log.info("proxy location: " + proxyloc);
                File proxyfile = new File(proxyloc);
                if(proxyfile.exists() == false) {
                    String dirpath = proxyloc.substring(0, proxyloc.lastIndexOf('/'));
                    File dir = new File(dirpath);
                    if(dir.exists() == false) {
                        dir.mkdirs();
                        log.info("new directory " + dirpath + " is created.");
                    }
                    proxyfile.createNewFile();
                    log.info("new proxy file " + proxyloc + " is created.");
                }
                FileOutputStream fout = new FileOutputStream(proxyfile);
                globusCred.save(fout);
                fout.close();
                Runtime.getRuntime().exec( "/bin/chmod 600 " + proxyloc );
                log.info("proxy file renewed");

                System.out.println("Proxy file renewed to "+ proxyloc + " for the user "+ username
View Full Code Here

                    //Use Globous crednatials if it is there
                    try {
                        ctx = new PureTLSContext();
                        GSSCredential gssCredntial = globalContext.getCredential();
                        if(gssCredntial instanceof GlobusGSSCredentialImpl){
                            GlobusCredential globusCred = ((GlobusGSSCredentialImpl)gssCredntial).getGlobusCredential();
                            TrustedCertificates tc = TrustedCertificates.getDefaultTrustedCertificates();
                            if (tc == null)
                            {
                                throw new XregistryException("Trusted certificates is null");
                            }
View Full Code Here

        this.myproxyClient = new MyProxy(hostname, port);
    }

    public void loadCertificate(String certFile, String keyFile)
        throws Exception {
        GlobusCredential clientCred =
            new GlobusCredential(certFile, keyFile);
        this.credential =
            new GlobusGSSCredentialImpl(clientCred,
                GSSCredential.INITIATE_AND_ACCEPT);
    }
View Full Code Here

        this.certificateValidity = validity;
    }

    public GSSCredential getVOMSProxy(GSSCredential myproxyCred)
        throws Exception {
        GlobusCredential globusCred = null;
        if (myproxyCred instanceof GlobusGSSCredentialImpl) {
            globusCred =
                ((GlobusGSSCredentialImpl)myproxyCred).getGlobusCredential();
        }
        if (globusCred == null) {
            return null;
        }

        GlobusCredential tmpCred = getVOMSProxy(globusCred);
        GSSCredential vomsCredential = null;
        vomsCredential = new GlobusGSSCredentialImpl(tmpCred,
            GSSCredential.INITIATE_AND_ACCEPT);
        return vomsCredential;
    }
View Full Code Here

            GSSCredential.INITIATE_AND_ACCEPT);
        return vomsCredential;
    }

    public String getVOMSProxy(String pemCredential) throws Exception {
        GlobusCredential globusCred =
            new GlobusCredential(
                new ByteArrayInputStream(pemCredential.getBytes()));

        GlobusCredential tmpCred = getVOMSProxy(globusCred);

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        tmpCred.save(output);
        String vomsCredential = output.toString();
        return vomsCredential;
    }
View Full Code Here

        VOMSProxyInit proxyInit = VOMSProxyInit.instance( globusCred );
        proxyInit.setProxyType(vomsProxyType);
        proxyInit.setProxyOutputFile(null);
        proxyInit.setProxyLifetime( this.certificateValidity );
        proxyInit.addVomsServer( info );
        GlobusCredential tmpCred = null;
        try {
            List<VOMSRequestOptions> options = getVOMSRequestOptions();
            tmpCred = proxyInit.getVomsProxy( options );
        } catch (VOMSException e) {
            throw new Exception(e.getMessage(), e);
View Full Code Here

    @Before
    protected void setUp() throws IOException
    {
        try
        {
            GlobusCredential gCert = GlobusCredential.getDefaultCredential();
            GSSCredential cert = new GlobusGSSCredentialImpl(gCert, GSSCredential.INITIATE_AND_ACCEPT);
            acc = new SRBAccount(SRBHOST, 5544, cert);
            acc.setDefaultStorageResource(DEFAULT_RESOURCE);

            System.out.println(cert.getName());
View Full Code Here

TOP

Related Classes of org.globus.gsi.GlobusCredential

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.