Messaging is a method of communication between software components or
applications.
A messaging system:peer to peer (P2P)点对点
Messaging enables distributed communication that is loosely coupled
消息传递支持松散耦合的分布式通信
Sender和receiver不需要知道对方的任何信息,除了要使用什么消息格式和目的地之外
不同于 tightly coupled 紧密耦合的通信技术 比如 Remote Method Invocation (RMI)(远程方法调用):要求应用程序知道远程应用程序的方法。
也不同于e-mail:是人与人或人与应用程序间的通信。
Messaging is used for communication between software applications or software components 消息用于应用程序之间或软件组成之间的通信
A message service : **software component functionality **软件组件的功能
一种**peer to peer(P2P)**通信
每个组件既是client也是server
sender只需要知道要发送的数据格式和receiver的目的地
loosely coupled cimmunication 松散耦合
Google Cloud Messaging (GCM) Service;Google Cloud Messaging (GCM) Service;Java Messaging Service (JMS);Xiaomi MIUI Cloud Messaging Service
Message-oriented Middleware (MOM) is a software or hardware that provides a communication channel between **heterogeneous **applications, platforms and systems by passing messages across between the communicating systems.
面向消息的中间件(MOM)是一种软件或硬件,它通过在通信系统之间传递消息,在异构应用程序、平台和系统之间提供一个通信通道。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eTBFTeWV-1640226990834)(/Users/mac/Library/Application Support/typora-user-images/image-20211217130749774.png)]
Microsoft’s Message Queuing (MSMQ)
Oracle’s Java Messaging Service (JMS)
IBM’s WebSphere Message Queuing (WebSphere MQ)
Sonic Message Queuing (Sonic MQ)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SeRNjS9A-1640226990835)(/Users/mac/Library/Application Support/typora-user-images/image-20211217144536609.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PEKCFGcv-1640226990836)(/Users/mac/Library/Application Support/typora-user-images/image-20211217151504749.png)]
JMS Provider
JMS Clients
Messages
Administered Objects
JNDI Namespace
通常,message product是异步的
基本组件:Administered objects, connections, sessions, JMSContext objects, Message producers, Message consumers, Messages.
is the object a client uses to create a connection with a provider
每个CF都是QueueConnectionFactory接口 或 TopicConnectionFactory接口
在J2EE SDK,可以使用默认CF objects:QueueConnectionFactory接口或TopicConnectionFactory接口来创建连接
也可以使用新连接:
j2eeadmin –addJmsFactory jndi_name queue
j2eeadmin –addJmsFactory jndi_name topic
在JMS client程序开头,使用JNDI API查找连接
Context ctx = new InitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory)
ctx.lookup(“QueueConnectionFactory”);
TopicConnectionFactory topicConnectionFactory = (TopicConnectionFactory)
ctx.lookup(“TopicConnectionFactory”);
调用 InitialContext 方法 with no arguments results in a search of the current classpath for vendor-specific file named jndi.properties
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
TopicConnection topicConnection = topicConnectionFactory.createTopicConnection();
client用来指定消息目标:specify the target of messages
j2eeadmin –addJmsFactory jndi_name queue
j2eeadmin –addJmsFactory jndi_name topic
除了查找connection factory,还要查找destination
Topic:Topic myTopic = (Topic) ctx.lookup(“MyTopic”);
Queue:Quene myQuene = (Quene) ctx.lookup(“MyQuene”);
A session is a single threaded context for producing and consuming messages
创建message producers, message consumers and messages
两种形式:使用QueueSession接口或TopicSession接口
例如:创建TopicSession:
TopicSession topicSession = topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
第一个参数是boolean类型。
是由session创建的对象:It is an object created by a session and is used for sending messages to a destination
PTP(P2P)message producer:QueueSender接口
Pub/Sub message producer:TopicPublisher接口
例如:使用QueueSession创建sender和TopicSession创建publisher
QueueSender queueSender = queueSession.createSender(myQueue);
TopicPublisher topicPublisher = queueSession.createPublisher(myTopic);
创建了message producers之后,就可以使用它发送消息,注意,您必须首先创建消息来完成此操作
queueSender.send(message);
topicPublisher.publish(message);
是由session创建的对象,用于接收发送到目的地的消息:A message consumer is an object created by a session and is used for receiving messages sent to a destination
P2P message consumer:QueueReceiver接口
Pub/Sub message consumer:TopicSubscriber接口
例如:使用QueueSession创建sender和TopicSession创建publisher
QueueReceiver queueReceiver = queueSession.createReceiver(myQueue);
TopicSubscriber TopicSubscriber = topicSession.createSubscriber(myTopic);
使用receive方法同步P2P和Pub/Sub消息。调用start方法即可使用receive方法
//start method
queueConnection.start();
Message m = queueReceiver.receive();
topicConnection.start(0);
Message m = topicSubscriber.receive(1000); // timeout after a second
为了异步使用消息,使用message listener
TopicListener topicListener = new TopicListener();
topicSubscriber.setMessageListener(topicListener);
JMS应用程序的目标是生成能够使用的消息,然后由其他软件应用程序使用
JMS messages包含:
• Header (needed)
• Properties (optional)
• A body (optional)
JMS API定义了message body formats,也叫message types。
创建任何类型的消息,例如,TextMessage:
TextMessage message = queueSession.createTextMessage();
Message.setText(msg.text);
queueSender.send(message);
在consume最后,消息作为通用的Message对象,必须转换为适当的消息类型。可以使用一个或多个getter方法提取消息内容。
例如:getText方法:
Message m = queueReceiver.receive();
if (m instanceof TextMessage) {
TextMessage message = (TextMexxafe)m;
Systems.out.println(“Reading message: “ + message.getText();
} else {
// Handle error
}
方法:JMSException,处理异常的通用方法。
The JMSException class includes the following subclasses:
• IllegalStateException
• InvalidClientException
• InvalidDestinationException
• InvalidSelectorException
• JMSSecurityException
• MessageEDFException
• MessageFormatException
• MessageNotReadableException
• MessageNotWritableException
• ResourceAllocationException
• TransactionInProgressException
• TransactionRolledBackException
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2O6MrMsf-1640226990836)(/Users/mac/Library/Application Support/typora-user-images/image-20211218130700255.png)]
Loosely coupled connectivity 松散耦合连接
确保安全web services的方法
-**Authentication **身份验证
– Authorisation 授权
– Confidentiality 保密
– Integrity 完整
下面细说这4个方法
1.Authentication
确认是同一个人,一个强大的authentication过程至少由两个步骤组成(sth one has, knows, is)
2.Authorisation
Access control访问控制
由一个或多个属性定义,属性是一个用户的特征
3.Confidentiality
Privacy, keeping information secretive
实现confidentiality和privacy
4.Integrity
信息不应被更改
1.Transport-layer
Secure Socket Layer (SSL), 也叫Transport Layer Security (TLS)
2.Application layer
补充Transport layer,基于XML frameworks
Data confidentiality通过 XML Encryption实现,Data integrity and authenticity 通过 XML Signature实现.
3.Middleware layer
Middleware layer确保communicating layer是安全的
Single Sign-On(SSO) systems 单点登录系统
1.是黑客入侵的区域
2.injection flaws
3.prevention(For injection flaws)
4.Broken Authentication 无效的身份验证
5.Cross Site Scripting 跨站脚本
6.Insecure Direct Object Reference 不安全的直接对象引用
7.Security Misconfigurations
8.Sensitive data exposure 暴露敏感数据
9.Problem with access control level 访问控制级别的问题
10.Cross Site Request Forgery (CSRF) 跨站点请求伪造
11.Unvalidated Redirects and Forwards 未验证跳转
Use Web Security Vulnerability Scanners:自动的应用程序,扫描整个网站的漏洞
Globus的安全特性被称为:Grid Security Infrastructure(GSI)
Globus使用proxy delegations, PKI, CAs, SSL/TLS
program名: grid-cert-request
//used to create a public/private key pair and unsigned certificate in ~/.globus/
对应的文件名:
//usercert_request.pem: Unsigned certificate file
//userkey.pem: Encrypted private key file(一定是只读的)
Mail usercert_request.pem to [email protected]
收到Globus-signed certificate:放在***~/.globus/usercert.pem***
运行程序需要Globus身份验证:%grid-proxy-init
Enter PEM pass phrase**(密码) //输入pass phrase:used to decrypt private key
grid-proxy-init里的选项:
hours
bits
help
作用:
1.grid-proxy-init:create the local proxy file.
2.private key:used to sign a proxy certificate with its own, new public/private key pair.
3.Proxy放在***/tmp***中,read-only by user. No network traffic.
4.gird-proxy-info显示proxy详细信息
为了destroy gird-proxy-init创建的local proxy:%grid-proxy-destroy
不会destroy任何从这个proxy委托的proxy:无法撤销远程proxy,通常create短寿命的proxy
Gird-mapfile maps individual users to their proxy and certificates for authentication and authorisation.
Group-mapfile maps individuals belonging to particular groups for authentication and authorisation
IEEE 802 把OSI link layer分成两个子layer从Data link layer:
这张图要考
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-joZsuNYy-1640226990837)(/Users/mac/Library/Application Support/typora-user-images/image-20211222162549027.png)]
Set of computer networking communication protocols
用于internet communication和其他网络通信
an **end-to-end communication protocol **端到端
consists of “Linked Layers”
Internet layer
将数据包从源网络发送到单个或 多个目的地网络,使用“IP地址”(如10.20.40.8)作为主机地址来识别,发送数据包被称为“packet routing”
Transport layer
It is a connection-oriented end-to-end message transmission **layer **面向连接的端到端传输层
Application layer
This consists of other application specific protocols that allow exchange of data or provides some services
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1NFObOOl-1640226990837)(/Users/mac/Library/Application Support/typora-user-images/image-20211222172154044.png)]
smart Grid, Home appliances automation, car hiring services, Food collection/delivery services(外卖)
a “scripting” language
a dynamic programming language 用于web应用开发,移动应用开发,non-web应用
用于client side(web browsers)和server side application
JavaScript和Java
JavaScript is NOT Java
– They have different semantics
– JavaScript来源于C语言
Or
Arithmetic +, -, *, /, %, ++, –
Comparison <, >, ==, <=, >=, !=
Logical &, |, ~, &&, ||, !
var student = {surName:”Wang”, firstName:”Liu”, age:20};
创建objetcs用“new”,new后面必须紧跟一个函数调用,以这种方式使用的函数称为构造函数
有些内置构造函数
• var obj = new Object(); // creates an empty object similar to
using {}
• var arr = new Array(); // creates an empty array similar to
using []
• var dt= new date(); // creates a Date object with the current
date
Boolean: 只有2种,True 和False
var myBooleanValue1 = true;
var myBooleanValue2 = false;
"typeof"知道数据类型
typeof 23; // returns a number
typeof “Wang”; // returns a string
typeof false; // returns a boolean
if (condition) {
//execute the code here if the condition is true
}
Examples:
if (myAge < 16) {
driving = “I cannot drive!";
}
if (myAge < 16) {
driving = “I cannot drive!";
} else {
driving = “I can drive!";
}
switch(expression) {
case 1:
code block
break;
case 2:
code block
break;
default:
default code block
}
Create a function:
function functionName(para1, para2, …….) {
return returnValue;
}
var mySum = myAddFunction(4, 3); // Function is called,
return value will end up in mySum
function myAddFunction(a, b) {
return a + b; // Function returns the sum of a and b
}
还有几个例子
HTML元素被称为nodes
创建node
This is a paragraph.
This is another paragraph.
remove existing elements
This is a paragraph.
This is another paragraph.
◆ Use the “length” property to get define the number of nodes in a node list
var myNodeList = document.getElementsByTagName("p");
document.getElementById(“myNodes").innerHTML = myNodeList.length;
Classes
例1
My First Web Page
My first paragraph.
例2
Use of Expressions for Computation
输入:Prompt, stdIn
输出:alert, stdOut
Example:
var strInput = WScript.StdIn.ReadAll();
WScript.StdOut.Write(strInput)
Cookies are functionalities in web-browsers that enable data and information about web activities to be saved for future reference
Session cookies, First cookies, Third cookies
jQuery consists of the following
– DOM element selections
– DOM manipulation
– Events
– AJAX (Asynchronous JavaScript and XML)
– JSON parsing
Basic syntax is: $(selector).action()
JSON -JavaScript Object Notation