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.
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. It intercepts join and merge requests and rejects them
* if the joiner or merger is not permitted to join a or merge into a cluster. AUTH should be placed right below
* {@link GMS} in the configuration.
* @author Chris Mills
* @author Bela Ban
*/
@XmlAttribute(attrs={
"auth_value", // SimpleToken, MD5Token, X509Token
"fixed_members_value", "fixed_members_seperator", // FixedMembershipToken
"block_time", "challenge_size", // ChallengeResponseToken
"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 a message has been received
* @param msg the message
* @return true if the message should be passed up, else false
*/
boolean handleUpMessage(Message msg);
}
/** Used on the coordinator to authentication joining member requests against */
protected AuthToken auth_token;
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() {}
protected volatile boolean authenticate_coord=true;
@Property(description="Do join or merge responses from the coordinator also need to be authenticated")
public AUTH setAuthCoord( boolean authenticateCoord) {
this.authenticate_coord= authenticateCoord; return this;
}
@Property(name="auth_class",description="The fully qualified name of the class implementing the AuthToken interface")
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 AUTH setAuthToken(AuthToken token) {this.auth_token=token; return this;}
public AUTH register(UpHandler handler) {up_handlers.add(handler); return this;}
public AUTH unregister(UpHandler handler) {up_handlers.remove(handler);return this;}
public Address getAddress() {return local_addr;}
public PhysicalAddress getPhysicalAddress() {return getTransport().getPhysicalAddress();}
protected List