Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including
all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and
Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
package org.jgroups.protocols;
import org.jgroups.*;
import org.jgroups.annotations.MBean;
import org.jgroups.annotations.Property;
import org.jgroups.annotations.XmlAttribute;
import org.jgroups.auth.AuthToken;
import org.jgroups.auth.X509Token;
import org.jgroups.conf.ClassConfigurator;
import org.jgroups.protocols.pbcast.GMS;
import org.jgroups.protocols.pbcast.JoinRsp;
import org.jgroups.stack.Protocol;
import org.jgroups.util.MessageBatch;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* The AUTH protocol adds a layer of authentication to JGroups
* @author Chris Mills
* @author Bela Ban
*/
@XmlAttribute(attrs={
"auth_value", // SimpleToken, MD5Token, X509Token
"fixed_members_value", "fixed_members_seperator", // FixedMembershipToken
"block_time", // DemoToken
"client_principal_name", "client_password", "service_principal_name", // Krb5Token
"token_hash", // MD5Token
"match_string", "match_ip_address", "match_logical_name", // RegexMembership
"keystore_type", "cert_alias", "keystore_path", "cipher_type",
"cert_password", "keystore_password" // X509Token
})
@MBean(description="Provides authentication of joiners, to prevent un-authorized joining of a cluster")
public class AUTH extends Protocol {
/** Interface to provide callbacks for handling up events */
public interface UpHandler {
/**
* Called when an up event has been received
* @param evt the event
* @return true if the event should be pass up, else false
*/
boolean handleUpEvent(Event evt);
}
/** Used on the coordinator to authentication joining member requests against */
protected AuthToken auth_token=null;
protected static final short gms_id=ClassConfigurator.getProtocolId(GMS.class);
/** List of UpHandler which are called when an up event has been received. Usually used by AuthToken impls */
protected final List up_handlers=new ArrayList<>();
protected Address local_addr;
public AUTH() {name="AUTH";}
private volatile boolean authenticateCoord = false;
@Property(name="authenticate_coord")
public void setAuthCoord( boolean authenticateCoord) {
this.authenticateCoord = authenticateCoord;
}
@Property(name="auth_class")
public void setAuthClass(String class_name) throws Exception {
Object obj=Class.forName(class_name).newInstance();
auth_token=(AuthToken)obj;
auth_token.setAuth(this);
}
public String getAuthClass() {return auth_token != null? auth_token.getClass().getName() : null;}
public AuthToken getAuthToken() {return auth_token;}
public void setAuthToken(AuthToken token) {this.auth_token=token;}
public void register(UpHandler handler) {up_handlers.add(handler);}
public void unregister(UpHandler handler) {up_handlers.remove(handler);}
public Address getAddress() {return local_addr;}
public PhysicalAddress getPhysicalAddress() {return getTransport().getPhysicalAddress();}
protected List