DistributedSysSecurity_v04
DistributedSysSecurity_v04
JMS – Java Messages Service – Java Web Server Queues and Topics
Security:
Policies for RMI/CORBA/EJB
XML Security + WS-Security + JAAS for JBOSS
JCA – Java Crypto Architecture Programming in distributed applications
• RMI Overview
• Java RMI allows the programmers to invoke/call
procedures/methods from a class inside in a remote virtual
machine exactly as it is in the local virtual machine.
Local Machine (Client) Remote Machine (Server)
SampleServerInterface
remoteObject;
int s;
…
s = remoteObject.sum(1,2); 1,2
public int sum(int a,int b) {
return a + b;
}
System.out.println(s);
3
Section 4
RMI Architecture
• RMI Server must register its name and
address in the RMI Registry program –
bind
skeleton
Stub
RMI Client RMI Server
return
• The client invokes a remote method after obtaining the reference to the
server object through JRMI registry program from the server. The client
delegates the involved method invocation sockets and protocol to the JRMI
Stub class/instance-object.
• JRMI Stub is responsible for calling the method, using the parameter
marshalling technique in order to transfer them to the JRMI Skeleton
class/instance-object. The JRMI Skeleton class/instance-object from the
server side sends the returned response to the JRMI Stub, so the stub must
un-marshalling the result and must pass it to the client object.
• Technically, the JRMI Stub opens socket to the server, “marshaling” the
serializable objects parameters to the server and receive the result from the
JRMI Skeleton.
• JRMI Skeleton has a method that executes the remote calls from the stubs
and it use “un-marshaling” technique in order to extract the parameters of
the call and in order to instruct the JRMI server object to run the invoked
method with the received parameters
Section 4
Part I – JRMI – Java Remote Method Invocation
*in readme.txt:
Developing RMI System
DEVELOPMENT of the RMI SERVER:
1. Defining the remote interface
2. Developing the Java class for instantiation of the JRMI server
object – implementing the interface from the step 1.
3. Developing the Java main server program
4. Compiling the Java server classes source code and generating
the JRMI Skeleton & JRMI Stub classes using rmic utility
program
DEVELOPMENT of the RMI CLIENT:
5. Developing the Java client program
6. Copying the Java compiled byte-code files for JRMI Stub and
for the remote interface – from the server side to the client
side
7. Compiling the client Java source code file together with the
files from step 6.
RUNNING RMI SERVER:
8. Start the JRMI registry program.
9. Start the server program.
RUNNING RMI CLIENT:
10.Start the client program
Section 4
/* SampleServerInterface.java */
import java.rmi.*;
/* SampleServerImpl.java */
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class SampleServerImpl extends UnicastRemoteObject
implements SampleServerInterface {
SampleServerImpl() throws RemoteException
{ super(); }
Section 4
/* SampleServerImpl.java */
public int sum(int a,int b) throws RemoteException
{
return a + b;
}
}
Section 4
The main server program creates the JRMI server object from the
class created in step 2 and implements the interface from the step 1.
The JRMI server must register the object in JRMI registry utility
program – bind() or rebind().
Section 4
/* SampleServerProgMain.java */
public static void main(String args[])
{
try
{
System.setSecurityManager(new RMISecurityManager());
//set the security manager
• The client program should obtain the reference to the remote object in
order to invoke a remote method from the server object. The JRMI clients
receive the reference to the remote server object after interrogation of
the JRMI registry application – using the lookup() method from
java.rmi.Naming
• The JRMI server object name is like an URL:
rmi://server_registry_host:port/server_rmi_name
rmi://127.0.0.1:1099/SAMPLE-SERVER
• The default port used by the JRMI registry application is 1099.
• The name specified in URL, “server_rmi_name”, must be the same as the
one used by the JRMI server when registered – bind() into JRMI registry
application. For instance, here, the name is “SAMPLE-SERVER”
• The call of the remote object is, from the syntax point of view, the same
as calling a local method but using the a client object with the remote
interface as data type (SampleServerInterface remoteObject).
Step 5: The client program development
import java.rmi.*;
import java.rmi.server.*;
public class SampleClient
{
public static void main(String[] args)
{
// set the security manager for the client
System.setSecurityManager(new RMISecurityManager());
//get the remote object from the registry
try
{
System.out.println("Security Manager loaded");
String url = “rmi://localhost:1099/SAMPLE-SERVER";
SampleServerInterface remoteObject =
(SampleServer)Naming.lookup(url);
System.out.println("Got remote object");
System.out.println(" 1 + 2 = " + remoteObject.sum(1,2) );
}
catch (RemoteException exc) {
...
Java Security Policy File – java.policy
Section 4
Part I – JRMI – Java Remote Method Invocation
• In Java, an application actions take into account the privileges
required by Java Virtual Machine - JVM - java.exe to the OS-Operating
System. The JVM is instructed by a Java Policy file. Usually is in
%JAVA_HOME%/jre/lib/security folder or can be passed as parameter
to the JVM through -Dpolicy.file=… option:
grant {
permission java.security.AllPermission;
};
grant {
permission java.io.filePermission “d:/tmp”, “read”, “write”;
permission java.net.SocketPermission
“somehost.somedomain.com:999”,”connect”;
permission java.net.SocketPermission “*:1024-
65535”,”connect,request”;
permission java.net.SocketPermission “*:80”,”connect”;
};
Section 4
1. It permits the Java class to read and write files from the
“d:/tmp” folder and subfolders.
Part II – CORBA
Stub Skeleton
• Stub
– lives on client
– pretends to be remote object
• Skeleton
– lives on server
– receives requests from stub
– talks to true remote object
– delivers response to stub
Client Server
request response
ORB ORB
“Object Bus”
Section 4
Skeleton
Stub Server
“Gigel”
Copyright © 1997 Alex Chaffee
Name Server Virtual Machine
Section 4
Skeleton
Stub Server
“Gigel”
Copyright © 1997 Alex Chaffee
Name Server Virtual Machine
Section 4
Skeleton
Stub Server
3 4
“Gigel”
Copyright © 1997 Alex Chaffee
Name Server Virtual Machine
Section 4
6
Skeleton
Stub Server
FEATURES:
Object Request Broker - “Object Bus”
Handles all communication among objects
Each host (machine) has its own ORB
ORBs know how to talk to each other
ORB also provides basic services to client
RESPONSABILITIES:
Find the object implementation for the request
Prepare the object implementation to receive the request
Communicate the data making up the request
Retrieve results of request
Note:
There’s an ORB on the server too, and ORB receives request
ORB is good if Stub and Skeleton are written in different programming
language
Section 4
• Method invocations
– Static and Dynamic
– Remote objects or CORBA services
• High-level language bindings
– Use your favorite language; ORB
translates
• Self-describing
– Provides metadata for all objects and
services
Section 4
• Local or remote
– Same API wherever target object lives
• Preserves context
– Distributed security and transactions
• Coexistence with legacy code
– Just provide a wrapper object
Section 4
GIOP Messages:
IOR:000000000000001049444c3a466f7274756e653a312e300
000000001000000000000005e00010000000000186d617966
6c792e73642e6d6f6e6173682e6564752e617500070a00000
00000363a5c6d6179666c792e73642e6d6f6e6173682e6564
752e61753a666f7274756e653a466f7274756e65313a3a495
23a466f7274756e65
Section 4
Pseudo-objects
• The ORB is a pseudo-object
• It works just like a remote object, only it’s local
Object Adapters
Portable Object Adapter – POA
The POA:
• Allows the ORB and Objects to communicate
• Provides many services:
– Dispatches client calls to server objects
– Handles incoming client calls
– Handles registration of servers
– Instantiatiates objects at runtime and creates
and manages object references
• POA is a BOA – Basic Object Adapter
Section 4
Invocation
ORB
POA Manager
POA
POA
Architecture
Part II –
CORBA – ORB
Section 4
//IDL Sample:
module Calc {
interface Adder {
long add(in long x, in long y);
}
}
• Defines an class called Adder which
generates objects with a method
called “add”
Section 4
IDL Modules
IDL Operations
IDL Attributes
• Map to pair of functions – like C# do
• IDL
– string name;
• Java
– public void name(String val);
– public String name();
Section 4
CORBA Services
• Relationship
• Externalization
• Query
• Licensing
• Properties
• Time
• Trader
• Collection
• … and so on…
• See what means about CORBA will
be never being implemented?
Section 4
Remember!
• CORBA is a standard by OMG, not an implementation.
implements implements
extends
Remote Object
Client Stub Skeleton
(Server)
Section 4
Object Model
• ORB provides few services through ORB interface
• Operations to marshall and unmarshall object references
• Getting object reference to an object implementing a specific CORBA service
Section 4
WSDL Concept:
WSDL – Specifies the location of the service and the operations (or
methods) it exposes
Section 4
JiBX: JiBX is a complete databinding framework that actually provides not only
WSDL-to-Java conversion, but also Java-to-XML conversion. In some ways,
JiBX provides the best of both worlds. JiBX is extremely flexible, enabling you
to choose the classes that represent your entities, but it can be complicated
to set up. On the other hand, once it is set up, actually using the generated
code is as easy as using ADB.
Section 4
1. Generate client ADB from web service wsdl file using th command:
%AXIS2_HOME%/bin/WSDL2Java -uri ServiceName.wsdl -p clientpackage -d
adb –s
2. compile the stub
javac -cp .;%AXIS2_CLASSPATH% clientpackage/ClientStub.java
3. Compile and run the client
javac -cp .;%AXIS2_CLASSPATH% clientpackage/Client.java
java -cp .;%AXIS2_CLASSPATH% clientpackage/Client.java
Section 4
The Enterprise JavaBeans (EJB) 1.x, 2.x and 3.x specifications define
an architecture for the development and deployment of
transactional, distributed object applications-based, server-side
software components.
Java Web Servers with EJB Containers:
JBoss – RedHat Linux Division – Portlet + BPM/BPEL – Rules Engine
BEA Web Logic – purchased by Oracle
GlassFish – Sun Microsystems – purchased by Oracle / IBM lost - Portlet
Oracle 9iAS – Oracle
Apache GERONIMO – the only openSource compliant with JEE 5.0
IBM Web Sphere - Portlet
Section 4
The EJB container hosts and manages an enterprise bean in the same
manner that the Java Web Server hosts a servlet or an HTML browser
hosts a Java applet. An enterprise bean cannot function outside of an
EJB container.
JNDI ENC
Callback Methods
EJBContext
The remote and home interfaces are types of Java RMI Remote
interfaces. The java.rmi.Remote interface is used by distributed
objects to represent the bean in a different address space (process
or machine). An enterprise bean is a distributed object.
That means that the bean class is instantiated and lives in the
container but it can be accessed by applications that live in other
address spaces – in other JVMs and other computer machines.
Section 4
EJB Types:
1. Entity EJBs
1.1 CMP – Content Managed Persistence
1.2 BMP – Bean Managed Persistence
2. Session EJBs
2.1 Stateless
2.2 Stateful
3. Message Driven Beans – see JMS and JTA
Section 4
EJB Types:
1. Session EJBs
1.1 Stateless
1.2 Stateful
2. Message Driven Beans – see JMS and JTA
Sun: “Like a stateless session bean, a message-driven bean can have many
interchangeable instances running at the same time. The container can pool
these instances to allow streams of messages to be processed concurrently.
Concurrency can affect the order in which messages are delivered, so you
should write your application to handle messages that arrive out of sequence.”
Section 4
1. Entity EJBs
CustomerHome.java – Home
interface – EJB life-cycle methods.
Customer.java – Remote
Interface – business methods
– here get/set.
Section 4
1. Entity EJBs
1. Entity EJBs – The entity bean is used to represent data in the database. It
provides an object-oriented interface to data that would normally be
accessed by the JDBC or some other back-end API.
1.1 CMP – Container Managed Persistence – the container manages the
persistence of the entity bean. Vendor tools are used to map the entity
fields to the database and absolutely no database access code is written
in the bean class.
1.2 BMP – Bean Managed Persistence – the entity bean contains
database access code (usually JDBC) and is responsible for reading
and writing its own state to the database. BMP entities have a lot of help
with this since the container will alert the bean as to when it's necessary
to make an update or read its state from the database.
Section 4
2. Session EJBs
HotelClerkHome.java – Home
interface – EJB life-cycle methods.
HotelClerk.java – Remote
Interface – business methods
– here TASKS.
Section 4
In JEE:
Annotations-Reflection + (Taglibs + Generics + Servlet/JSP)
MVC + EJB + JMS + Rules Engine/BPM-BPEL = LOVE
Both the JBoss client-side interceptor (stub) and load balancer use load
balancing policies to determine which server node to send a new request to.
In this section, let's go over the load balancing policies available in JBoss AS.
Section 4
Beyond these enhancements, VMware is also working closely with both Intel and AMD
to ensure that new processor technology features are exploited by virtual infrastructure
to the fullest extent. In particular, the new virtualization hardware assist enhancements
(Intel’s “VT” and AMD’s “Pacifica”) will enable robust virtualization of the CPU
functionality. Such hardware virtualization support does not replace virtual infrastructure,
but allows it to run more efficiently.
Section 4
Amazon EC2’s simple web service interface allows you to obtain and
configure capacity with minimal friction. It provides you with complete
control of your computing resources and lets you run on Amazon’s
proven computing environment. Amazon EC2 reduces the time required
to obtain and boot new server instances to minutes, allowing you to
quickly scale capacity, both up and down, as your computing
requirements change.
Section 4
Amazon EC2 presents a true virtual computing environment, allowing you to use web service
interfaces to launch instances with a variety of operating systems, load them with your custom
application environment, manage your network’s access permissions, and run your image using as
many or few systems as you desire.
Standard Instances
Large Instance 7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2
EC2 Compute Units each), 850 GB of local instance storage, 64-bit platform
The National Institute of Standards and Technology (NIST – nist.org) provides a somewhat
more objective and specific definition: "Cloud computing is a model for enabling
convenient, on-demand network access to a shared pool of configurable computing
resources (e.g., networks, servers, storage, applications, and services) that can be rapidly
provisioned and released with minimal management effort or service provider interaction."
Section 4
Advantages:
Schimbul de informaţii. Creşterea masivă a cantităţii de informaţie şi
necesitatea de a schimba rapid informaţii între diferitele puncte aflate în locuri
geografic depărtate fac necesară conectarea între calculatoare autonome.
Partajarea resurselor. O organizaţie preferă să cumpere mai multe
calculatoare mai ieftine şi de puteri rezonabile decât să cumpere unul singur,
mult mai puternic dar mult mai scump. În acest mod devine necesară
interconectarea acestor calculatoare mai mici între ele, eventual cu un număr
redus de calculatoare mai puternice ale căror resurse (memorie, putere a
procesorului, periferice de capacităţi mari) să fie partajate între acestea.
Siguranţă mărită în funcţionare. Dacă un sistem de calcul este format dintr-un
singur calculator, defectarea acestuia face imposibilă utilizarea întregului
sistem, pe cand intr-un sistem distribuit, căderea unui nod nu perturbă
funcţionarea celorlalte, ci acestea preiau sarcinile celui căzut.
Section 4
Avantages:
• paralelism = un proces pentru a-şi soluţiona problema foloseşte în acelaşi timp diferite
resurse;
Section 4
JXTA
Conceived by Sun Microsystems by Bill Joy (the creator of ‘vi’):
• team identified a number of shortcomings in many existing peer-to-peer systems and set up
project JXTA in order to address these.
• their 3 main objectives of were to achieve interoperability, platform independence and ubiquity
JXTA
JXTA
JXTA Chat
(MIDP)
JXTA-C Shell
(C on Solaris)
Section 4
Interoperability
• software vendors tend to create specific code for their services e.g. file sharing,
instant messaging etc
• incompatible systems
• duplicate effort
• JXTA attempts give peers a common language to talk to each other
Platform independence
JXTA technology is designed to be independent of:
• programming languages e.g. C or Java
• system platforms e.g. Microsoft Windows and UNIX
• networking platforms (such as TCP/IP or Bluetooth)
Ubiquity
• implementable on every device with a digital heartbeat e.g. PDAs, phones,
sensors, consumer electronics appliances, network routers, desktop computers,
data-center servers, storage systems
• avoid specific binding to platforms (Wintel…)
• future proof e.g. such technologies should be extended to new platforms e.g.
mobile phones etc e.g. using JME, Google Android, Java BlackBerry, etc.
Section 4
JXTA - Implementations
Peer
JXTA Terms
Peer Peer
Peer Peer
Section 4
Peer Peer
Peer
Virtual Mapping
TCP/IP
Physical
Network
HTTP NAT
Firewall Physical Network
Section 4
Tcp/Ip
Tcp/Ip
Tcp/Ip
http http
NAT Firewall
SUN
JXTA
JXTA Community Applications JXTA
Applications
Applications
JXTA
Shell
SUN • Indexing Peer
JXTA JXTA Community JXTA • Searching
Services Services Commands
Services • File Sharing
JXTA Overview
Project JXTA defines a set of six protocols , which allow peers to:
• programming language
• operating system
• network transport
• Topology
• authentication
• Security
• encryption model.
The JXTA protocols therefore allow heterogeneous devices with completely different
software stacks to interoperate.
Section 4
JXTA Architecture
Platform Layer (JXTA Core)
– minimal and essential primitives that are common to P2P networking.
– building blocks to enable key mechanisms for P2P applications,
• including discovery,
• transport (including firewall handling),
• the creation of peers and peer groups,
• and associated security primitives.
Services Layer
– network services that may not be absolutely necessary for a P2P network to operate, but are
common or desirable in the P2P environment.
– Examples of network services include:
• searching and indexing,
• directory,
• storage systems,
• file sharing,
• distributed file systems,
• resource aggregation and renting,
• protocol translation,
• authentication,
• and PKI (Public Key Infrastructure) services.
JXTA Components
• JXTA peers use pipes to send messages to one another. Pipes are an
asynchronous and unidirectional message transfer mechanism used for
service communication. Messages are simple XML documents whose
envelope contains:
– routing,
– digest,
– and credential information.
• Pipes are bound to specific endpoints, such as a TCP port and associated
IP address.
Section 4
• Membership
– Peer Membership
Protocol
• Discovery
– Peer Discovery Protocol
– Peer Resolver Protocol
• Pipe
– Pipe Binding Protocol
– Peer Endpoint Protocol
• Monitoring
– Peer Information
Protocol
Section 4
JXTA
Section 4
Peer: any networked device that implements one or more of the JXTA protocols
Pipes: messages are send through virtual pipes – see next section …
Identifiers: each JXTA entity e.g. peer, advert etc has a UUID identifier
Relay Nodes: JXTA routers – help to route messages via firewalls, NAT systems
etc – i.e. they relay the message on
Section 4
JXTA Peers
• A peer
– Unique identifier (UUID)
– Addressable independently of its location
(firewalls, NAT)
– Multiple Peer “endpoint” address (TCP, HTTP, etc.)
• Peer types
– Minimal edge : send/receive
– Full edge : + cache
– Rendezvous : + fwd requests
– Relay : +routing cache +firewall support
Section 4
Pipe Advertisement:
<?xml version="1.0"?>
<!DOCTYPE jxta:PipeAdvertisement>
<jxta:PipeAdvertisement xml:space="preserve" xmlns:jxta="http://jxta.org">
<Id>urn:jxta:uuid-
59616261646162614E5047205032503301E704BC6C144BB28016FDF28A4580EF0
4</Id>
<Type>JxtaPropagate</Type>
<Name>mypipe</Name>
</jxta:PipeAdvertisement>
Section 4
JXTA Pipes
Output Pipe Input Pipe
• Virtual Communication Channels
Peer A JXTA Pipe Peer • Switchable e.g. TCP/IP, HTTP,
1 2 Bluetooth
• NOT point to point
Actual Route
• Two Types:
Pee • (End) Point to (End) Point
r • Propagate - multicast
Point to Point Propagate
Section 4
JXTA Pipes
<?xml version="1.0">
<ShellDoc>
<Item>
<Data>Hello, world!</Data>
</Item>
</ShellDoc>
2
JXTA Scenario 1
3
1.
RV
2. 4
3.
New
4.
Node .
5
5. 7
.
6
1. Rendezvous node (RV) accepts connection for nodes 1-7 and stores
advertisements locally
2. New node contacts Rendezvous using a discovery mechanism e.g.
Unicast/multicast (PDP)
3. RV authenticates New Node and adds the New Node to the group (RVP)
4. New Nodes performs a file search query by contacting the RV find a match
locally or propagates this query to all other members in the group. The file is
found on node 6 (PDP)
5. New Node and node 6 communicate directly through a JXTA pipe. This
connection is virtual and may actually traverse (route) through the RV node
and node 7.
JXTA Protocol Stack
Peer Discovery Peer Discovery
Via Peer Resolver Protocol
Protocol Protocol
Peer Information Peer Information
Via Peer Resolver Protocol
Protocol Protocol
Pipe Binding Pipe Binding
Via Peer Resolver Protocol
Protocol Protocol
Peer Discovery
Protocol • A peer uses the PDP to discover a JXTA resource
Pipe Binding •Note, that the first word, peer, is the subject and not necessarily
Protocol the object
•Using this protocol, peers can advertise their own resources, and
discover the resources from other peers
JXTA Protocols
Actual Route
Peer Peer
3 4
Firewall
Section 4
JXTA Protocols
‘The’ Resolver
Peer Endpoint
Protocol
Section 4
JXTA Protocols
Rendezvous
JXTA Protocols
Peer Resolver
Protocol • allows a peer to find information about the
available routes for sending a message to
destination peer
Rendezvous
Protocol • i.e. pipes are often not directly connected to
each other
• Discovery Service
• PeerInfo Service
• Pipe Service
• Resolver Service
• Membership Service
• Access Service
Section 4
JXTA SHELL & MyJXTA DEMO
Section 4
JXTA SHELL & MyJXTA DEMO
Section 4
JXTA Summary
• Features
– This system uses the pure P2P architecture rather than
else. It enables us to share information and
communicate with others, regardless of network
configuration and hierarchy. Finally, it helps us to
collaborate on the Internet.
• Potential applications
– E-education
– Tele-presentation/Conferences on the Internet
– Virtual meeting on the Internet
– Flexible information sharing
– Co-navigation on the Internet, Web Radio/TV, IP TV,
RTP/SIP Streaming and VoIP/VioIP Services
Section 4
• Short term
– Sharing files (text, image, pdf, mp3) – see MyJXTA
– Improving communication reliability
– Enhancing group management
– Effective memory usage
– Free drawing pad
• Long term
– Voice/video communication based on Java & JMF
– Record additional drawing on text & image file
– Network security
Section 4
Contact: