当前位置: 首页>>代码示例>>Java>>正文


Java GlobusCredential.getTimeLeft方法代码示例

本文整理汇总了Java中org.globus.gsi.GlobusCredential.getTimeLeft方法的典型用法代码示例。如果您正苦于以下问题:Java GlobusCredential.getTimeLeft方法的具体用法?Java GlobusCredential.getTimeLeft怎么用?Java GlobusCredential.getTimeLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.globus.gsi.GlobusCredential的用法示例。


在下文中一共展示了GlobusCredential.getTimeLeft方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeGlobusProxy

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
/**
 * Change the type of the Globus Proxy Credential with optional new
 * ExtensionSet. Older implementations and for example VOMS enabled proxies
 * must be of of GSI_2_PROXY type.
 * 
 * @param proxy
 *            - original Globus Proxy
 * @param proxyType
 *            - new Proxy Type, for example 'legacy' type:
 *            <code>GSIConstants.GSI_2_PROXY</code>
 * @param extensions
 *            - X509ExtensionSet, if null extensions will be removed.
 * @return new changed GlobusCredential.
 * @throws GeneralSecurityException
 * @see GSIConstants
 */
public static GlobusCredential changeGlobusProxy(GlobusCredential proxy, int proxyType, X509ExtensionSet extensions)
        throws GeneralSecurityException
{
    BouncyCastleCertProcessingFactory factory = BouncyCastleCertProcessingFactory.getDefault();

    if (proxyType <= 0)
    {
        proxyType = GSIConstants.GSI_2_PROXY;
    }

    int timeLeft = (int) proxy.getTimeLeft();
    int numBits = proxy.getStrength();
    GlobusCredential newProxy = factory.createCredential(proxy.getCertificateChain(),
            proxy.getPrivateKey(),
            numBits,
            timeLeft,
            proxyType,
            extensions,
            null);

    return newProxy;
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:39,代码来源:GlobusUtil.java

示例2: checkCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
private void checkCertificate(String expectedIdentity, CertificateLifetime lifetime, PrivateKey key,
    X509Certificate cert) throws Exception {
    assertNotNull(cert);

    GlobusCredential cred = new GlobusCredential(key, new X509Certificate[]{cert});
    assertNotNull(cred);
    long max = FederationUtils.getTimeInSeconds(lifetime);
    long min = max - 3;
    long timeLeft = cred.getTimeLeft();
    if ((min > timeLeft) || (timeLeft > max)) {
        assertTrue(false);
    }
    assertEquals(cert.getSubjectDN().toString(), identityToSubject(cred.getIdentity()));
    assertEquals(expectedIdentity, cred.getIdentity());
    assertEquals(getCA().getCACertificate().getSubjectDN(), cert.getIssuerDN());
    cred.verify();
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:18,代码来源:TestDorian.java

示例3: checkCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
private void checkCertificate(String expectedIdentity, CertificateLifetime lifetime, PrivateKey key,
    X509Certificate cert) throws Exception {
    assertNotNull(cert);
    GlobusCredential cred = new GlobusCredential(key, new X509Certificate[]{cert});
    assertNotNull(cred);
    long max = FederationUtils.getTimeInSeconds(lifetime);
    // what is this 3 for?
    long min = max - 3;
    long timeLeft = cred.getTimeLeft();
    assertTrue(min <= timeLeft);
    assertTrue(timeLeft <= max);
    assertEquals(expectedIdentity, cred.getIdentity());
    assertEquals(cert.getSubjectDN().toString(), identityToSubject(cred.getIdentity()));
    assertEquals(cred.getIssuer(), ca.getCACertificate().getSubjectDN().getName());
    cred.verify();
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:17,代码来源:TestIdentityFederationManager.java

示例4: getProxyIdentity

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public String getProxyIdentity() {
    if (getProxy() != null) {
        return getProxy().getIdentity();
    } else if (!isAnonymousPrefered()) {
        try {
            GlobusCredential cred = ProxyUtil.getDefaultProxy();
            if (cred.getTimeLeft() > 0) {
                return cred.getIdentity();
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
        return null;
    } else {
        return null;
    }
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:18,代码来源:GridGrouperClient.java

示例5: handleCredentialSelection

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void handleCredentialSelection() {
    int maxPathLength = 0;
    long lifetimeSeconds = 0;
    try {
        GlobusCredential cred = getProxy().getSelectedCredential().getCredential();
        X509Certificate[] certs = cred.getCertificateChain();
        maxPathLength = getDelegationPathLength(certs[0]);
        lifetimeSeconds = cred.getTimeLeft() - SECONDS_OFFSET;
    } catch (Exception e) {
        FaultUtil.logFault(log, e);
    }
    if (maxPathLength < 0) {
        maxPathLength = 0;
    }
    delegatedCredentialPathLength.removeAllItems();
    for (int i = 0; i <= maxPathLength; i++) {
        delegatedCredentialPathLength.addItem(new Integer(i));
    }
    if (maxPathLength >= 1) {
        delegatedCredentialPathLength.setSelectedIndex(1);
    }

    getDelegationLifetime().setLifetime(lifetimeSeconds);
    getIssuedCredentialLifetime().setLifetime(lifetimeSeconds - SECONDS_OFFSET);
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:26,代码来源:DelegateProxyWindowStep1.java

示例6: GridGrouperExpressionEditor

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public GridGrouperExpressionEditor(List gridGrouperURIs,
		boolean loadOnStartup, MembershipExpression expression) {
	super();
	this.gridGrouperURIs = gridGrouperURIs;
	this.expression = expression;
	initialize();
	if ((loadOnStartup) && (gridGrouperURIs != null)
			&& (gridGrouperURIs.size() > 0)) {
		GlobusCredential cred = null;
		try {
			cred = ProxyUtil.getDefaultProxy();
			if (cred.getTimeLeft() <= 0) {
				cred = null;
			}
		} catch (Exception e) {

		}
		this.getGrouperTree().addGridGrouper(
				(String) gridGrouperURIs.get(0), cred);
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:22,代码来源:GridGrouperExpressionEditor.java

示例7: checkCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
private void checkCertificate(String expectedIdentity, CertificateLifetime lifetime, PrivateKey key, X509Certificate cert) throws Exception {
	assertNotNull(cert);

	GlobusCredential cred = new GlobusCredential(key, new X509Certificate[] { cert });
	assertNotNull(cred);
	long max = FederationUtils.getTimeInSeconds(lifetime);
	long min = max - 3;
	long timeLeft = cred.getTimeLeft();
	if ((min > timeLeft) || (timeLeft > max)) {
		assertTrue(false);
	}
	assertEquals(cert.getSubjectDN().toString(), identityToSubject(cred.getIdentity()));
	assertEquals(expectedIdentity, cred.getIdentity());
	assertEquals(getCA().getCACertificate().getSubjectDN(), cert.getIssuerDN());
	cred.verify();
}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:17,代码来源:TestDorian.java

示例8: checkCreateProxy

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void checkCreateProxy(int length) {
	try {
		CA ca = new CA();
		Credential gridCred = ca.createIdentityCertificate("User X");
		int hours = 2;
		int minutes = 0;
		int seconds = 0;
		PrivateKey key = gridCred.getPrivateKey();
		assertNotNull(key);
		KeyPair pair = KeyUtil.generateRSAKeyPair512("BC");
		assertNotNull(pair);
		PublicKey proxyPublicKey = pair.getPublic();
		assertNotNull(proxyPublicKey);
		X509Certificate cert = gridCred.getCertificate();
		assertNotNull(cert);
		X509Certificate[] certs = ProxyCreator.createImpersonationProxyCertificate(CA.PROVIDER.getName(), cert,
			key, proxyPublicKey, hours, minutes, seconds, length, CA.SIGNATURE_ALGORITHM);
		assertNotNull(certs);
		assertEquals(2, certs.length);
		GlobusCredential cred = new GlobusCredential(pair.getPrivate(), certs);
		assertNotNull(cred);
		long timeLeft = cred.getTimeLeft();
		assertEquals(cert.getSubjectDN().toString(), identityToSubject(cred.getIdentity()));
		assertEquals(cred.getIssuer(), identityToSubject(cred.getIdentity()));
		assertEquals(length, CertificateExtensionsUtil.getDelegationPathLength(certs[0]));

		long okMax = hours * 60 * 60;
		// Allow some Buffer
		long okMin = okMax - 3;

		if ((okMin > timeLeft) || (timeLeft > okMax)) {
			assertTrue(false);
		}

	} catch (Exception e) {
		FaultUtil.printFault(e);
		assertTrue(false);
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:40,代码来源:TestProxyCreator.java

示例9: loadCredentials

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public synchronized void loadCredentials() {
    this.credentials.clear();
    this.credentialFiles.clear();
    String dir = Utils.getCaGridUserHome() + File.separator + File.separator + "credentials";
    credentialDir = new File(dir);
    credentialDir.mkdirs();
    FileFilter ff = new CredentialFilter();
    File list[] = credentialDir.listFiles(ff);
    for (int i = 0; i < list.length; i++) {
        try {
            long fileId = getFileId(list[i]);
            if (fileId > lastId) {
                lastId = fileId;
            }

            X509CredentialDescriptor des = EncodingUtil.deserialize(list[i]);
            X509CredentialEntry entry = CredentialEntryFactory.getEntry(des);
            GlobusCredential cred = entry.getCredential();
            if (cred.getTimeLeft() == 0) {
                list[i].delete();
            } else {
                credentials.put(entry.getIdentity(), entry);
                credentialFiles.put(entry.getIdentity(), list[i]);
            }

        } catch (Exception e) {
            list[i].delete();
            FaultUtil.logFault(log, e);
        }
    }
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:32,代码来源:CredentialManager.java

示例10: getCredentials

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public synchronized List<X509CredentialEntry> getCredentials() {
    // loadCredentials();
    List<X509CredentialEntry> l = new ArrayList<X509CredentialEntry>();
    Iterator<X509CredentialEntry> itr = this.credentials.values().iterator();
    while (itr.hasNext()) {
        X509CredentialEntry credential = itr.next();
        GlobusCredential cred = credential.getCredential();
        if (cred.getTimeLeft() == 0) {
            deleteCredential(credential);
        } else {
            l.add(credential);
        }
    }
    return l;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:16,代码来源:CredentialManager.java

示例11: showCredential

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void showCredential(GlobusCredential cred) {
	clearCredential();
	subjectField.setText(cred.getSubject());
	issuer.setText(cred.getIssuer());
	identity.setText(cred.getIdentity());
	strength.setText(cred.getStrength() + " bits");
	cred.getTimeLeft();
	GregorianCalendar c = new GregorianCalendar();
	c.add(Calendar.SECOND, (int) cred.getTimeLeft());
	timeLeft.setText(c.getTime().toString());
	X509Certificate[] certs = cred.getCertificateChain();
	for (int i = 0; i < certs.length; i++) {
		certificates.addCertificate(certs[i]);
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:16,代码来源:CredentialPanel.java

示例12: checkCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
private void checkCertificate(String expectedIdentity, CertificateLifetime lifetime, PrivateKey key, X509Certificate cert) throws Exception {
	assertNotNull(cert);
	GlobusCredential cred = new GlobusCredential(key, new X509Certificate[] { cert });
	assertNotNull(cred);
	long max = FederationUtils.getTimeInSeconds(lifetime);
	// what is this 3 for?
	long min = max - 3;
	long timeLeft = cred.getTimeLeft();
	assertTrue(min <= timeLeft);
	assertTrue(timeLeft <= max);
	assertEquals(expectedIdentity, cred.getIdentity());
	assertEquals(cert.getSubjectDN().toString(), identityToSubject(cred.getIdentity()));
	assertEquals(cred.getIssuer(), ca.getDefaultCertificateAuthority().getCACertificate().getSubjectDN().getName());
	cred.verify();
}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:16,代码来源:TestIdentityFederationManager.java

示例13: testCreateCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void testCreateCertificate() {

        CertificateAuthority ca = null;
        try {
            int hours = 12;
            CertificateAuthorityProperties conf = this.getDorianCAConfAutoCreateAutoRenewalLong();
            String user = SUBJECT_PREFIX + "User";
            ca = getCertificateAuthority(conf);
            ca.clearCertificateAuthority();
            Calendar c = new GregorianCalendar();
            Date start = c.getTime();
            c.add(Calendar.HOUR, hours);

            KeyPair pair = KeyUtil.generateRSAKeyPair1024();
            assertNotNull(pair);
            PublicKey proxyPublicKey = pair.getPublic();
            assertNotNull(proxyPublicKey);

            X509Certificate cert = ca.signCertificate(user, pair.getPublic(), start, c.getTime());
            assertNotNull(cert);
            GlobusCredential cred = new GlobusCredential(pair.getPrivate(), new X509Certificate[]{cert});
            assertNotNull(cred);
            long timeLeft = cred.getTimeLeft();
            assertEquals(user, cert.getSubjectDN().getName());
            assertEquals(user, identityToSubject(cred.getIdentity()));
            assertEquals(cert.getIssuerDN(), ca.getCACertificate().getSubjectDN());

            long okMax = hours * 60 * 60;
            // Allow some Buffer
            long okMin = okMax - 300;

            // must have less time left than the maximum
            assertTrue(timeLeft <= okMax);
            // must have more time left than the minimum
            assertTrue(timeLeft >= okMin);

        } catch (Exception e) {
            FaultUtil.printFault(e);
            assertTrue(false);
        }
    }
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:42,代码来源:TestCertificateAuthority.java

示例14: testCreateCertificate

import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void testCreateCertificate() {

		CertificateAuthority ca = null;
		try {
			int hours = 12;
			CertificateAuthorityProperties conf = this.getDorianCAConfAutoCreateAutoRenewalLong();
			String user = SUBJECT_PREFIX + "User";
			ca = getCertificateAuthority(conf);
			ca.clearCertificateAuthority();
			Calendar c = new GregorianCalendar();
			Date start = c.getTime();
			c.add(Calendar.HOUR, hours);

			KeyPair pair = KeyUtil.generateRSAKeyPair1024();
			assertNotNull(pair);
			PublicKey proxyPublicKey = pair.getPublic();
			assertNotNull(proxyPublicKey);

			X509Certificate cert = ca.signCertificate(user, pair.getPublic(), start, c.getTime(), CertificateSignatureAlgorithm.SHA2);
			assertNotNull(cert);
			GlobusCredential cred = new GlobusCredential(pair.getPrivate(), new X509Certificate[] { cert });
			assertNotNull(cred);
			long timeLeft = cred.getTimeLeft();
			assertEquals(user, cert.getSubjectDN().getName());
			assertEquals(user, identityToSubject(cred.getIdentity()));
			assertEquals(cert.getIssuerDN(), ca.getCACertificate().getSubjectDN());

			long okMax = hours * 60 * 60;
			// Allow some Buffer
			long okMin = okMax - 300;

			// must have less time left than the maximum
			assertTrue(timeLeft <= okMax);
			// must have more time left than the minimum
			assertTrue(timeLeft >= okMin);

		} catch (Exception e) {
			e.printStackTrace();
			assertTrue(false);
		}
	}
 
开发者ID:NCIP,项目名称:cagrid2,代码行数:42,代码来源:TestCertificateAuthority.java


注:本文中的org.globus.gsi.GlobusCredential.getTimeLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。