本文整理汇总了Java中org.globus.gsi.gssapi.GlobusGSSCredentialImpl类的典型用法代码示例。如果您正苦于以下问题:Java GlobusGSSCredentialImpl类的具体用法?Java GlobusGSSCredentialImpl怎么用?Java GlobusGSSCredentialImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GlobusGSSCredentialImpl类属于org.globus.gsi.gssapi包,在下文中一共展示了GlobusGSSCredentialImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImportExportOpaque
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void testImportExportOpaque() throws Exception {
GlobusGSSCredentialImpl cred =
(GlobusGSSCredentialImpl)manager.createCredential(GSSCredential.ACCEPT_ONLY);
assertTrue(cred != null);
byte [] data = cred.export(ExtendedGSSCredential.IMPEXP_OPAQUE);
assertTrue(data != null);
System.out.println(new String(data));
GlobusGSSCredentialImpl cred2 =
(GlobusGSSCredentialImpl)manager.createCredential(data,
ExtendedGSSCredential.IMPEXP_OPAQUE,
GSSCredential.DEFAULT_LIFETIME,
null,
GSSCredential.ACCEPT_ONLY);
assertTrue(cred2 != null);
assertEquals(cred.getPrivateKey(), cred2.getPrivateKey());
}
示例2: testImportExportMechSpecific
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void testImportExportMechSpecific() throws Exception {
GlobusGSSCredentialImpl cred =
(GlobusGSSCredentialImpl)manager.createCredential(GSSCredential.ACCEPT_ONLY);
assertTrue(cred != null);
byte [] data = cred.export(ExtendedGSSCredential.IMPEXP_MECH_SPECIFIC);
assertTrue(data != null);
String handle = new String(data);
System.out.println(handle);
GlobusGSSCredentialImpl cred2 =
(GlobusGSSCredentialImpl)manager.createCredential(data,
ExtendedGSSCredential.IMPEXP_MECH_SPECIFIC,
GSSCredential.DEFAULT_LIFETIME,
null,
GSSCredential.ACCEPT_ONLY);
assertTrue(cred2 != null);
assertEquals(cred.getPrivateKey(), cred2.getPrivateKey());
handle = handle.substring(handle.indexOf('=')+1);
assertTrue((new File(handle)).delete());
}
示例3: testPutGet2
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void testPutGet2() throws Exception {
myProxy.put(cred,
username,
password,
lifetime);
GSSCredential mCred = myProxy.get(cred,
username,
password,
lifetime);
assertTrue(mCred != null);
GlobusCredential gCred =
((GlobusGSSCredentialImpl)mCred).getGlobusCredential();
assertTrue(gCred != null);
gCred.verify();
}
示例4: testStore
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void testStore() throws Exception {
String credName = "foobar";
String credDesc = "foobar description";
StoreParams storeRequest = new StoreParams();
storeRequest.setUserName(username);
storeRequest.setCredentialName(credName);
storeRequest.setCredentialDescription(credDesc);
GlobusCredential globusCred =
((GlobusGSSCredentialImpl)cred).getGlobusCredential();
myProxy.store(cred,
globusCred.getCertificateChain(),
new BouncyCastleOpenSSLKey(globusCred.getPrivateKey()),
storeRequest);
}
示例5: getData
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
/**
* Returns a handle to the input stream of the socket which is returning the
* data referred to by the descriptor. This method can make an https
* connection if desired using the credentials passed in. If you wish to use
* this method to connect to http it will not use the Crediential whether
* you pass them in or they are null,
*
* @param desc
* data transfer descriptor received from
* TransferServiceContextClient
* @param creds
* creator of the transfer resource credentials
* @return
* @throws Exception
*/
public static InputStream getData(DataTransferDescriptor desc, GlobusCredential creds) throws Exception {
InputStream dataStream = null;
URL url = new URL(desc.getUrl());
if (url.getProtocol().equals("http")) {
URLConnection conn = url.openConnection();
conn.connect();
dataStream = conn.getInputStream();
} else if (url.getProtocol().equals("https")) {
if (creds != null) {
GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(creds, GSSCredential.INITIATE_AND_ACCEPT);
GSIHttpURLConnection connection = new GSIHttpURLConnection(url);
connection.setGSSMode(GSIConstants.MODE_SSL);
connection.setCredentials(cred);
dataStream = connection.getInputStream();
} else {
throw new Exception(
"To use the https protocol to retrieve data from the Transfer Service you must have credentials");
}
} else {
throw new Exception("Protocol " + url.getProtocol() + " not supported.");
}
return dataStream;
}
示例6: initializeCredentials
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public static GSSCredential initializeCredentials(boolean personal, String hostcert,
String hostkey) throws GlobusCredentialException, GSSException {
if (!personal) {
return new GlobusGSSCredentialImpl(new GlobusCredential(hostcert != null ? hostcert
: "/etc/grid-security/hostcert.pem", hostkey != null ? hostkey
: "/etc/grid-security/hostkey.pem"), GSSCredential.INITIATE_AND_ACCEPT);
}
else {
return new GlobusGSSCredentialImpl(GlobusCredential.getDefaultCredential(),
GSSCredential.INITIATE_AND_ACCEPT);
}
}
示例7: loadProxyFromFile
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
private static GSSCredential loadProxyFromFile(String proxyPath) {
try {
GlobusCredential cred = new GlobusCredential(proxyPath);
return new GlobusGSSCredentialImpl(cred, GSSCredential.INITIATE_AND_ACCEPT);
}
catch (Exception e) {
throw new SecurityException(e);
}
}
示例8: load
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
private static GSSCredential load(String file) {
try {
GlobusCredential cred = new GlobusCredential(file);
return new GlobusGSSCredentialImpl(cred, GSSCredential.INITIATE_AND_ACCEPT);
} catch(Exception e) {
System.err.println("Failed to load proxy: " + e.getMessage());
System.exit(-1);
}
return null;
}
示例9: testPutGet3
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void testPutGet3() throws Exception {
myProxy.put(cred,
username,
password,
lifetime);
GSSCredential mCred = myProxy.get(username,
password,
lifetime);
assertTrue(mCred != null);
GlobusCredential gCred =
((GlobusGSSCredentialImpl)mCred).getGlobusCredential();
assertTrue(gCred != null);
gCred.verify();
}
示例10: createGSSCredential
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public static GSSCredential createGSSCredential(GridProxy proxy) throws Exception
{
VGridCredential sourceCred = proxy.getCredential();
if (sourceCred instanceof GlobusCredentialWrapper)
{
GlobusGSSCredentialImpl gssCred = createGSSCredential(((GlobusCredentialWrapper) sourceCred).getGlobusCredential());
return gssCred;
}
else
{
throw new Exception("Cannot convert non GlobusCredentials to GSS Credentials:" + sourceCred.getClass());
}
}
示例11: convertCredential
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
@Override
public VGridCredential convertCredential(VGridCredential sourceCred, String type) throws Exception
{
if (sourceCred instanceof GlobusCredentialWrapper)
{
if (StringUtil.equals(GridProxy.GSS_CREDENTIAL_TYPE,type))
{
GlobusGSSCredentialImpl gssCred = createGSSCredential( ((GlobusCredentialWrapper)sourceCred).getGlobusCredential());
return new GSSCredentialWrapper(this,gssCred);
}
}
return null;
}
示例12: getValidGSSCredential
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
private static GSSCredential getValidGSSCredential(
VRSContext context) throws GlobusCredentialException,
GSSException, AuthenticationException
{
// debug("getGlobusCredentials");
GridProxy proxy = context.getGridProxy();
if (proxy == null)
{
throw new nl.esciencecenter.vlet.exception.AuthenticationException(
"NULL grid credential (Not set for this context)");
}
if (proxy.isValid() == false)
{
throw new nl.esciencecenter.vlet.exception.AuthenticationException(
"No valid grid credential found");
}
GlobusCredential globusCred = GlobusUtil.getGlobusCredential(proxy);
if (globusCred != null)
{
GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(
globusCred, GSSCredential.DEFAULT_LIFETIME);
return cred;
}
throw new AuthenticationException(
"Couldn't find proper GSI credentials (no proxy?)");
// return null;
}
示例13: putData
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
/**
* Reads from the input stream to put the data to the server. Be sure to
* close the stream when done writing the data. This method can use http and
* https if the credentials are provided. This is a blocking call. Will
* return with the entire data has been transmitted.
*
* @param is
* input stream providing the data
* @param contentLength
* number of bytes in the input stream to be read
* @param desc
* data transfer descriptor received from
* TransferServiceContextClient
* @param creds
* creator of the transfer resource credentials
* @return
* @throws Exception
*/
public static void putData(InputStream is, long contentLength, DataTransferDescriptor desc, GlobusCredential creds)
throws Exception {
URL url = new URL(desc.getUrl());
if (url.getProtocol().equals("http")) {
PostMethod post = new PostMethod(desc.getUrl());
InputStreamRequestEntity re = new InputStreamRequestEntity(is, contentLength);
post.setRequestEntity(re);
HttpClient client = new HttpClient();
int status = client.executeMethod(post);
} else if (url.getProtocol().equals("https")) {
if (creds != null) {
GlobusGSSCredentialImpl cred = new GlobusGSSCredentialImpl(creds, GSSCredential.INITIATE_AND_ACCEPT);
GSIHttpURLConnection connection = new GSIHttpURLConnection(url);
connection.setGSSMode(GSIConstants.MODE_SSL);
connection.setCredentials(cred);
try {
int l = -1;
byte[] buffer = new byte[1024];
while ((l = is.read(buffer)) != -1) {
connection.getOutputStream().write(buffer, 0, l);
}
} finally {
is.close();
}
connection.getOutputStream().close();
connection.getInputStream().close();
} else {
throw new Exception(
"To use the https protocol to stage data to the Transfer Service you must have credentials");
}
} else {
throw new Exception("Protocol " + url.getProtocol() + " not supported.");
}
}
示例14: configure
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的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());
}
}
示例15: configure
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl; //导入依赖的package包/类
public void configure(Stub stub) throws CommunicationStyleException{
try{
Util.registerTransport();
stub._setProperty(GSIConstants.GSI_TRANSPORT, 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());
}
}