⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 visitorauthenticator.java

📁 Java p2p程序设计2002年版
💻 JAVA
字号:
/* * VisitorAuthenticator.java * * Created on September 23, 2001, 11:16 PM */package com.sams.jxta.groups;import net.jxta.membership.*;import net.jxta.credential.AuthenticationCredential;import net.jxta.peergroup.*;import net.jxta.protocol.*;import net.jxta.service.*;import net.jxta.exception.*;import net.jxta.peer.*;import net.jxta.document.*;import net.jxta.credential.*;//import net.jxta.id.IDFactory;/** * This class is used to authenticate the user into the group.  * We only allow the user into the group * if they give us a user name and are * in a compatible debug mode. * * @author  Daniel Brookshier * @version */public class VisitorAuthenticator implements Authenticator {   protected String visitorName = "";   private String password = "";   protected boolean debug = false;   protected boolean allowDebug = true;     MembershipService source;   AuthenticationCredential application;            VisitorAuthenticator( MembershipService source, AuthenticationCredential application ) {      this.source = source;      this.application = application;      System.out.println(this.getClass().getName()+" **** VisitorAuthenticator()");   }         /**    * Return the Authentication Credential associated with this authenticator if any.    */   public AuthenticationCredential getAuthenticationCredential(){      return application;   }      /**    *Returns the name of this authentication method.    **/   public String getMethodName(){      return "VisitorAuthenticator";   }   public void setVisitorName(String visitorName ){      this.visitorName = visitorName;   }   public String getVisitorName(){      return visitorName;   }   /**    * Returns the service which generated this authenticator.    */   public MembershipService getSourceService() {      return source;   }   /**    * Returns true if this Authenticator has been satisfied and is ready for the join operation.    * We are only worried about the user name and if we are allowing debug users.     */   public boolean isReadyForJoin() {      System.out.println(this.getClass().getName()+" **** isReadyForJoin()");      if (!getAllowDebugMode() && getDebugMode()){         return false;      }else if(getVisitorName() == null || getVisitorName().length() == 0){         return false;      }else{         return true;      }   }   public void setPassword(String password){      this.password = password;   }   public void setDebugMode(boolean debug){      this.debug = debug;   }   public boolean getDebugMode(){      return debug;   }   /**    * Set to false to prevent debug users.    */   protected void setAllowDebugMode(boolean allowDebug){      this.allowDebug = allowDebug;   }   /**    * The state of the group to allow debug users.    */   protected boolean getAllowDebugMode(){      return allowDebug;   }   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -