⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client_gsisecmsg_encrypt.java

📁 globus toolkit Math例子
💻 JAVA
字号:
/* * This file is licensed under the terms of the Globus Toolkit Public License * v3, found at http://www.globus.org/toolkit/legal/4.0/license-v3.html. *  * This notice must appear in redistributions of this file, with or without * modification. */package org.globus.examples.clients.MathService_instance_4op;import java.security.cert.X509Certificate;import javax.security.auth.Subject;import javax.xml.rpc.Stub;import org.apache.axis.message.addressing.Address;import org.apache.axis.message.addressing.EndpointReferenceType;import org.globus.examples.services.security.first.impl.MathConstants;import org.globus.examples.stubs.MathService_instance_4op.MathPortType;import org.globus.examples.stubs.MathService_instance_4op.service.MathServiceAddressingLocator;import org.globus.gsi.CertUtil;import org.globus.wsrf.impl.security.authentication.Constants;import org.globus.wsrf.impl.security.authentication.encryption.EncryptionCredentials;import org.globus.wsrf.impl.security.authorization.NoAuthorization;import org.oasis.wsrf.properties.GetResourcePropertyResponse;public class Client_GSISecMsg_Encrypt {	public static void main(String[] args) {		MathServiceAddressingLocator locator = new MathServiceAddressingLocator();		GetResourcePropertyResponse valueRP;		String value;		try {			String serviceURI = args[0];			// Create endpoint reference to service			EndpointReferenceType endpoint = new EndpointReferenceType();			endpoint.setAddress(new Address(serviceURI));			MathPortType math = locator.getMathPortTypePort(endpoint);			// Get PortType			math = locator.getMathPortTypePort(endpoint);			/* Setup security options */			// Specify server's public key			String pkFile = "/etc/grid-security/containercert.pem";			Subject subject = new Subject();			X509Certificate serverCert = CertUtil.loadCertificate(pkFile);			EncryptionCredentials encryptionCreds = new EncryptionCredentials(					new X509Certificate[] { serverCert });			subject.getPublicCredentials().add(encryptionCreds);			// Set stub options			((Stub) math)._setProperty(Constants.GSI_SEC_MSG,					Constants.ENCRYPTION);			((Stub) math)._setProperty(Constants.PEER_SUBJECT, subject);			((Stub) math)._setProperty(Constants.AUTHORIZATION, NoAuthorization					.getInstance());			// Perform an addition			try {				math.add(60);				System.out.println("Addition was successful");			} catch (Exception e) {				System.out.println("[add]      ERROR: " + e.getMessage());				e.printStackTrace();			}			// Perform a subtraction			try {				math.subtract(50);				System.out.println("Subtraction was successful");			} catch (Exception e) {				System.out.println("[subtract] ERROR: " + e.getMessage());			}			// Perform a multiplication			try {				math.multiply(4);				System.out.println("Multiplication was successful");			} catch (Exception e) {				System.out.println("[multiply] ERROR: " + e.getMessage());			}			// Perform a division			try {				math.divide(2);				System.out.println("Division was successful");			} catch (Exception e) {				System.out.println("[divide]   ERROR: " + e.getMessage());			}			// Access value			try {				valueRP = math.getResourceProperty(MathConstants.RP_VALUE);				value = valueRP.get_any()[0].getValue();				System.out.println("Current value: " + value);			} catch (Exception e) {				System.out.println("[getRP]    ERROR: " + e.getMessage());			}		} catch (Exception e) {			e.printStackTrace();		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -