1 18 19 20 package sync4j.framework.core; 21 22 30 public final class Cred 31 implements java.io.Serializable { 32 33 public static final String AUTH_TYPE_MD5 = "syncml:auth-md5" ; 35 public static final String AUTH_TYPE_BASIC = "syncml:auth-basic"; 36 public static final String AUTH_TYPE_HMAC = "syncml:auth-MAC" ; 37 public static final String AUTH_NONE = "none" ; 38 public static final String AUTH_SUPPORTED_TYPES = AUTH_TYPE_BASIC 39 + ',' 40 + AUTH_TYPE_MD5 41 + ',' 42 + AUTH_TYPE_HMAC; 43 44 private Authentication authentication; 46 47 49 protected Cred() {} 50 51 59 public Cred(final Authentication authentication) { 60 if (authentication == null) { 61 throw new IllegalArgumentException ("authentication cannot be null"); 62 } 63 this.authentication = authentication; 64 } 65 66 68 73 public String getType() { 74 return authentication.getType(); 75 } 76 77 82 public String getFormat() { 83 return authentication.getFormat(); 84 } 85 86 91 public String getData() { 92 return authentication.getData(); 93 } 94 95 100 public String getUsername() { 101 return authentication.getUsername(); 102 } 103 104 105 114 public static Authentication createAuthentication(String data, 115 String type) { 116 return new Authentication(type,data); 117 } 118 119 124 public Authentication getAuthentication() { 125 return authentication; 126 } 127 128 134 public void setAuthentication(Authentication auth) { 135 this.authentication = auth; 136 } 137 public String toString() { 138 StringBuffer res = new StringBuffer (); 139 res.append(getUsername()).append(" with ").append(getType()); 140 res.append(" from ").append(getData()); 141 return res.toString(); 142 } 143 } 144 | Popular Tags |