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


Java GSIConstants类代码示例

本文整理汇总了Java中org.globus.gsi.GSIConstants的典型用法代码示例。如果您正苦于以下问题:Java GSIConstants类的具体用法?Java GSIConstants怎么用?Java GSIConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test2

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void test2() throws Exception {
    URL u = new URL("httpg://pitcairn.mcs.anl.gov:2119/jobmanager");
    
    URLConnection con = u.openConnection();
    
    assertTrue(con instanceof GSIURLConnection);
    
    ((GSIURLConnection)con).setDelegationType(GSIConstants.DELEGATION_FULL);
    
    try {
        InputStream in = con.getInputStream();
        fail("did not throw exception");
    } catch (IOException e) {
        // everything is cool
    } finally {
        ((GSIURLConnection)con).disconnect();
    }
    
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:20,代码来源:GSIHttpURLConnectionTest.java

示例2: setGssMode

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
protected void setGssMode(Object value) 
    throws GSSException {
    if (!(value instanceof Integer)) {
        throw new GlobusGSSException(GSSException.FAILURE,
                                     GlobusGSSException.BAD_OPTION_TYPE,
                                     "badType",
                                     new Object [] {"GSS mode", Integer.class});
    }
    Integer v = (Integer)value;
    if (v == GSIConstants.MODE_GSI || 
        v == GSIConstants.MODE_SSL) {
        this.gssMode = v;
    } else {
        throw new GlobusGSSException(GSSException.FAILURE,
                                     GlobusGSSException.BAD_OPTION,
                                     "badGssMode");
    }
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:19,代码来源:GlobusGSSContextImpl.java

示例3: setDelegationType

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
protected void setDelegationType(Object value) 
    throws GSSException {
    if (!(value instanceof Integer)) {
        throw new GlobusGSSException(GSSException.FAILURE,
                                     GlobusGSSException.BAD_OPTION_TYPE,
                                     "badType",
                                     new Object[] {"delegation type",  Integer.class});
    }
    Integer v = (Integer)value;
    if (v == GSIConstants.DELEGATION_TYPE_FULL ||
        v == GSIConstants.DELEGATION_TYPE_LIMITED) {
        this.delegationType = v;
    } else {
        throw new GlobusGSSException(GSSException.FAILURE,
                                     GlobusGSSException.BAD_OPTION,
                                     "badDelegType");
    }
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:19,代码来源:GlobusGSSContextImpl.java

示例4: checkProxyName

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
/**
    * Returns proxy name. 
    *
    * @deprecated Only works for Globus legacy proxies.
    */
   public static int checkProxyName(X509Cert cert) {
int rs = -1;
DistinguishedName subject = dupName(cert.getSubjectName());
Vector subjectDN = subject.getName();
Vector lastAva = (Vector)subjectDN.elementAt(subjectDN.size()-1);
String [] ava = (String[])lastAva.elementAt(0);

if (ava[0].equalsIgnoreCase("CN")) {
    if (ava[1].equalsIgnoreCase("proxy")) {
	rs = GSIConstants.GSI_2_PROXY;
    } else if (ava[1].equalsIgnoreCase("limited proxy")) {
	rs = GSIConstants.GSI_2_LIMITED_PROXY;
    }
	
    if (rs != -1) {
	Vector nameDN = dupName(cert.getIssuerName()).getName();
	nameDN.addElement(lastAva);
	X509Name newName = new X509Name(nameDN);

	return (Arrays.equals(subject.getNameDER(), newName.getNameDER())) ? rs : -1;
    }
}

return rs;
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:31,代码来源:PureTLSUtil.java

示例5: testResctrictedNoProxyCertInfoExt

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void testResctrictedNoProxyCertInfoExt() throws Exception {

GlobusCredential cred = GlobusCredential.getDefaultCredential();

try {
    factory.createCredential(cred.getCertificateChain(),
			     cred.getPrivateKey(),
			     512,
			     60 * 60,
			     GSIConstants.GSI_3_RESTRICTED_PROXY,
			     (X509ExtensionSet)null,
			     null);
    fail("Expected to fail");
} catch (IllegalArgumentException e) {
    // that's what we expected
}
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:18,代码来源:BouncyCastleCertProcessingFactoryTest.java

示例6: changeGlobusProxy

import org.globus.gsi.GSIConstants; //导入依赖的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

示例7: makeProxy

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
private GlobusCredential makeProxy(KeyPair kp, X509Certificate issuerCert) throws GeneralSecurityException {
    BouncyCastleCertProcessingFactory factory = BouncyCastleCertProcessingFactory.getDefault();
    KeyPair newKeyPair = CertUtil.generateKeyPair(CA_CERT_ALGORITHM, CA_CERT_BITS);
    
    return factory.createCredential(new X509Certificate[] { issuerCert },
            kp.getPrivate(), CA_CERT_BITS, (int) (CA_CERT_LIFETIME / 1000), GSIConstants.DELEGATION_FULL,
            (X509ExtensionSet) null);
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:9,代码来源:AutoCA.java

示例8: generateNewCredential

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
private GlobusCredential generateNewCredential(Key key) throws GlobusCredentialException,
        InvalidSecurityContextException, GeneralSecurityException {
    GlobusCredential src = GlobusCredential.getDefaultCredential();
    if (src == null) {
        throw new InvalidSecurityContextException("No default credential found");
    }

    // If only the security stuff in [email protected] would be
    // separable from the WS crap
    BouncyCastleCertProcessingFactory factory =
                BouncyCastleCertProcessingFactory.getDefault();
    int delegType = (key.delegationType == Delegation.FULL_DELEGATION ?
                GSIConstants.DELEGATION_FULL : GSIConstants.DELEGATION_LIMITED);

    KeyPair newKeyPair = CertUtil.generateKeyPair("RSA", src.getStrength());

    X509Certificate[] srcChain = src.getCertificateChain();
    X509Certificate newCert = null;

    try {
        newCert = factory.createProxyCertificate(srcChain[0],
                                    src.getPrivateKey(),
                                    newKeyPair.getPublic(), -1,
                                    key.delegationType == Delegation.FULL_DELEGATION ?
                                            GSIConstants.DELEGATION_FULL
                                            : GSIConstants.DELEGATION_LIMITED,
                                    (X509ExtensionSet) null, null);
    }
    catch (GeneralSecurityException e) {
        throw new InvalidSecurityContextException("Delegation failed", e);
    }

    X509Certificate[] newChain = new X509Certificate[srcChain.length + 1];
    newChain[0] = newCert;
    System.arraycopy(srcChain, 0, newChain, 1, srcChain.length);

    return new GlobusCredential(newKeyPair.getPrivate(), newChain);
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:39,代码来源:ProxyForwardingManager.java

示例9: createProxy

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public GlobusCredential createProxy(String pwd)
throws Exception {   

getProperties();

userCert = CertUtil.loadCertificate(props.getUserCertFile());

OpenSSLKey key = 
    new BouncyCastleOpenSSLKey(props.getUserKeyFile());

if (key.isEncrypted()) {
    try {
	key.decrypt(pwd);
    } catch(GeneralSecurityException e) {
	throw new Exception("Wrong password or other security error");
    }
}

PrivateKey userKey = key.getPrivateKey();

BouncyCastleCertProcessingFactory factory =
    BouncyCastleCertProcessingFactory.getDefault();

int proxyType = (getLimited()) ? 
    GSIConstants.DELEGATION_LIMITED :
    GSIConstants.DELEGATION_FULL;

return factory.createCredential(new X509Certificate[] {userCert},
				userKey,
				props.getProxyStrength(), 
				props.getProxyLifeTime() * 3600,
				proxyType,
				(X509ExtensionSet)null);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:35,代码来源:DefaultGridProxyModel.java

示例10: setRequestProperty

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void setRequestProperty(String key, String value) {
    if (key.equals(GSS_MODE_PROPERTY)) {
        if (value.equals("ssl")) {
            setGSSMode(GSIConstants.MODE_SSL);
        } else if (value.equals("gsi")) {
            setGSSMode(GSIConstants.MODE_GSI);
        } else {
            setGSSMode(null);
        }
    } else {
        super.setRequestProperty(key, value);
    }
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:14,代码来源:GSIURLConnection.java

示例11: testGetCertificateType3

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void testGetCertificateType3() throws Exception {
X509Certificate cert = getCertificate(1);
int type = Integer.parseInt(ProxyPathValidatorTest.certs[1][0]);
assertEquals(GSIConstants.EEC, BouncyCastleUtil.getCertificateType(cert));

TrustedCertificates trustedCerts =
    new TrustedCertificates(new X509Certificate[] {cert});

assertEquals(GSIConstants.CA, BouncyCastleUtil.getCertificateType(cert, trustedCerts));
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:11,代码来源:BouncyCastleUtilTest.java

示例12: testExtensions

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void testExtensions() throws Exception {

GlobusCredential cred = GlobusCredential.getDefaultCredential();
X509Extension ext = null;

String oid1 = "1.2.3.4";
String expectedValue1 = "foo";
boolean critical1 = false;

String oid2 = "5.6.7.8";
String expectedValue2 = "bar";
boolean critical2 = true;

X509ExtensionSet extSet = new X509ExtensionSet();
ext = new X509Extension(oid1, critical1, expectedValue1.getBytes());
extSet.add(ext);
ext = new X509Extension(oid2, critical2, expectedValue2.getBytes());
extSet.add(ext);

GlobusCredential newCred = 
    factory.createCredential(cred.getCertificateChain(),
			     cred.getPrivateKey(),
			     512,
			     60 * 60,
			     GSIConstants.GSI_3_IMPERSONATION_PROXY,
			     extSet,
			     null);

X509Certificate newCert = newCred.getCertificateChain()[0];

System.out.println(newCert);

verifyExtension(newCert, oid1, expectedValue1, critical1);
verifyExtension(newCert, oid2, expectedValue2, critical2);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:36,代码来源:BouncyCastleCertProcessingFactoryTest.java

示例13: GassOutputStream

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
/**
    * Opens Gass output stream in secure mode with specified
    * user credentials.
    *
    * @param cred user credentials to use. If null,
    *             default user credentials will be used.
    * @param host host name of the gass server.
    * @param port port number of the gass server.
    * @param file name of the file on the remote side.
    * @param length total size of the data to be transfered.
    *               Use -1 if unknown. The data then will be 
    *               transfered in chunks.
    * @param append if true, append data to existing file.
    *               Otherwise, the file will be overwritten.
    */
   public GassOutputStream(GSSCredential cred,
		    Authorization auth,
		    String host,
		    int port,
		    String file,
		    long length,
		    boolean append) 
throws GassException, GSSException, IOException {
super();

this.size = length;
this.append = append;

GSSManager manager = ExtendedGSSManager.getInstance();

ExtendedGSSContext context = 
    (ExtendedGSSContext)manager.createContext(null, 
					      GSSConstants.MECH_OID,
					      cred,
					      GSSContext.DEFAULT_LIFETIME);

context.setOption(GSSConstants.GSS_MODE, GSIConstants.MODE_SSL);

GssSocketFactory factory = GssSocketFactory.getDefault();

socket = factory.createSocket(host, port, context);

((GssSocket)socket).setAuthorization(auth);

put(host, file, length, -1);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:47,代码来源:GassOutputStream.java

示例14: createImpersonationProxyCertificate

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public static X509Certificate[] createImpersonationProxyCertificate(String provider, X509Certificate[] certs,
	PrivateKey privateKey, PublicKey proxyPublicKey, int lifetimeHours, int lifetimeMinutes, int lifetimeSeconds,
	int delegationPathLength, String signatureAlgorithm) throws GeneralSecurityException {
	ProxyPolicy policy = new ProxyPolicy(ProxyPolicy.IMPERSONATION);
	ProxyCertInfo proxyCertInfo = new ProxyCertInfo(delegationPathLength, policy);
	org.globus.gsi.X509Extension x509Ext = new ProxyCertInfoExtension(proxyCertInfo);
	X509ExtensionSet extSet = new X509ExtensionSet();
	extSet.add(x509Ext);
	return createProxyCertificate(provider, certs, privateKey, proxyPublicKey, lifetimeHours, lifetimeMinutes,
		lifetimeSeconds, GSIConstants.GSI_4_IMPERSONATION_PROXY, extSet, signatureAlgorithm);
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:12,代码来源:ProxyCreator.java

示例15: configure

import org.globus.gsi.GSIConstants; //导入依赖的package包/类
public void configure(Stub stub) throws CommunicationStyleException{
	try{
	stub._setProperty(Constants.GSI_SEC_CONV, GSIConstants.ENCRYPTION);
	if (credential != null) {
		GSSCredential gss = new GlobusGSSCredentialImpl(credential, GSSCredential.INITIATE_AND_ACCEPT);
		stub._setProperty(org.globus.axis.gsi.GSIConstants.GSI_CREDENTIALS, gss);
	}
	}catch(Exception e){
		e.printStackTrace();
		throw new CommunicationStyleException(e.getMessage());
	}
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:13,代码来源:SecureConversationWithEncryption.java


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