protected static AuthToken readAuthToken(DataInput in) throws Exception { if(in.readByte() == 0) return null; short id=in.readShort(); AuthToken retval=null; if(id >= 0) retval=ClassConfigurator.create(id); else { String classname=in.readUTF(); Class<?> clazz=Class.forName(classname); retval=(AuthToken)clazz.newInstance(); } retval.readFrom(in); return retval; }
protected static void writeAuthToken(DataOutput out, AuthToken tok) throws Exception { out.writeByte(tok == null? 0 : 1); if(tok == null) return; short id=ClassConfigurator.getMagicNumber(tok.getClass()); out.writeShort(id); if(id < 0) { String classname=tok.getClass().getName(); out.writeUTF(classname); } tok.writeTo(out); }
public void destroy() { if(auth_token != null) auth_token.destroy(); super.destroy(); }
/** * Handles a GMS header * @param gms_hdr * @param msg * @return true if the message should be passed up, or else false */ protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg) { if(needsAuthentication(gms_hdr)) { if(this.auth_token.authenticate(auth_hdr.getToken(), msg)) return true; // authentication passed, send message up the stack else { log.warn("%s: failed to validate AuthHeader (token: %s) from %s; dropping message and sending " + "rejection message", local_addr, auth_token.getClass().getSimpleName(), msg.src()); sendRejectionMessage(gms_hdr.getType(), msg.getSrc(), "authentication failed"); return false; } } return true; }
public void init() throws Exception { super.init(); if(!match_ip_address && !match_logical_name) throw new IllegalArgumentException("either match_ip_address or match_logical_address has to be true"); if(match_string == null) throw new IllegalArgumentException("match_string cannot be null"); pattern=Pattern.compile(match_string); }
public void stop() { if(auth_token != null) auth_token.stop(); super.stop(); }
public void start() throws Exception { super.start(); if(auth_token != null) auth_token.start(); }
@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); }
protected static int sizeOf(AuthToken tok) { int retval=Global.BYTE_SIZE; // null token ? if(tok == null) return retval; retval+=Global.SHORT_SIZE; short id=ClassConfigurator.getMagicNumber(tok.getClass()); if(id < 0) { String classname=tok.getClass().getName(); retval+=classname.length() +2; } retval+=tok.size(); return retval; }
/** * Handles a GMS header * @param gms_hdr * @param msg * @return true if the message should be passed up, or else false */ protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg) { if(needsAuthentication(gms_hdr)) { if(this.auth_token.authenticate(auth_hdr.getToken(), msg)) return true; // authentication passed, send message up the stack else { log.warn("%s: failed to validate AuthHeader (token: %s) from %s; dropping message and sending " + "rejection message", local_addr, auth_token.getClass().getSimpleName(), msg.src()); sendRejectionMessage(gms_hdr.getType(), msg.getSrc(), "authentication failed"); return false; } } return true; }
public void init() throws Exception { super.init(); if(auth_token == null) throw new IllegalStateException("no authentication mechanism configured"); if(auth_token instanceof X509Token) { X509Token tmp=(X509Token)auth_token; tmp.setCertificate(); } auth_token.init(); }
public void stop() { if(auth_token != null) auth_token.stop(); super.stop(); }
public void start() throws Exception { super.start(); if(auth_token != null) auth_token.start(); }
@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); }
protected static int sizeOf(AuthToken tok) { int retval=Global.BYTE_SIZE; // null token ? if(tok == null) return retval; retval+=Global.SHORT_SIZE; short id=ClassConfigurator.getMagicNumber(tok.getClass()); if(id < 0) { String classname=tok.getClass().getName(); retval+=classname.length() +2; } retval+=tok.size(); return retval; }
if(this.serverSideToken.authenticate(authHeader.getToken(), msg)){
public void init() throws Exception { super.init(); if(!match_ip_address && !match_logical_name) throw new IllegalArgumentException("either match_ip_address or match_logical_address has to be true"); if(match_string == null) throw new IllegalArgumentException("match_string cannot be null"); pattern=Pattern.compile(match_string); }
public void destroy() { super.destroy(); unregisterBypasser(auth); }
public static AuthToken readAuthToken(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException { try{ String type = Util.readString(in); Object obj = Class.forName(type).newInstance(); AuthToken token = (AuthToken) obj; token.readFrom(in); return token; } catch(ClassNotFoundException cnfe){ return null; } }