1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 /******************************************************************************* 27 * Product of NIST/ITL Advanced Networking Technologies Division (ANTD). * 28 *******************************************************************************/ 29 package gov.nist.javax.sip.header; 30 import gov.nist.core.*; 31 32 /** 33 * Credentials that are used in authentication and authorization headers. 34 * @author M. Ranganathan 35 * @version 1.2 $Revision: 1.7 $ $Date: 2009/07/17 18:57:30 $ 36 * @since 1.1 37 */ 38 public class Credentials extends SIPObject { 39 40 /** 41 * Comment for <code>serialVersionUID</code> 42 */ 43 private static final long serialVersionUID = -6335592791505451524L; 44 45 private static String DOMAIN = ParameterNames.DOMAIN; 46 private static String REALM = ParameterNames.REALM; 47 private static String OPAQUE = ParameterNames.OPAQUE; 48 private static String RESPONSE = ParameterNames.RESPONSE; 49 private static String URI = ParameterNames.URI; 50 private static String NONCE = ParameterNames.NONCE; 51 private static String CNONCE = ParameterNames.CNONCE; 52 private static String USERNAME = ParameterNames.USERNAME; 53 54 protected String scheme; 55 56 /** 57 * parameters list. 58 */ 59 protected NameValueList parameters; 60 61 /** 62 * Default constructor 63 */ Credentials()64 public Credentials() { 65 parameters = new NameValueList(); 66 parameters.setSeparator(COMMA); 67 } 68 69 /** 70 * get the parameters list. 71 * @return NameValueList 72 */ getCredentials()73 public NameValueList getCredentials() { 74 return parameters; 75 } 76 77 /** 78 * get the scheme field. 79 * @return String. 80 */ getScheme()81 public String getScheme() { 82 return scheme; 83 } 84 85 /** 86 * Set the scheme member 87 * @param s String to set 88 */ setScheme(String s)89 public void setScheme(String s) { 90 scheme = s; 91 } 92 93 /** 94 * Set the parameters member 95 * @param c NameValueList to set. 96 */ setCredentials(NameValueList c)97 public void setCredentials(NameValueList c) { 98 parameters = c; 99 } 100 encode()101 public String encode() { 102 String retval = scheme; 103 if (!parameters.isEmpty()) { 104 retval += SP + parameters.encode(); 105 } 106 return retval; 107 } 108 109 /*public void setCredential(NameValue nameValue) { 110 if (nameValue.getName().compareToIgnoreCase(URI) == 0) 111 nameValue.setQuotedValue(); 112 else if (nameValue.getName().compareToIgnoreCase(NONCE) == 0) 113 nameValue.setQuotedValue(); 114 else if (nameValue.getName().compareToIgnoreCase(REALM) == 0) 115 nameValue.setQuotedValue(); 116 else if (nameValue.getName().compareToIgnoreCase(CNONCE) == 0) 117 nameValue.setQuotedValue(); 118 else if (nameValue.getName().compareToIgnoreCase(RESPONSE) == 0) 119 nameValue.setQuotedValue(); 120 else if (nameValue.getName().compareToIgnoreCase(OPAQUE) == 0) 121 nameValue.setQuotedValue(); 122 else if (nameValue.getName().compareToIgnoreCase(USERNAME) == 0) 123 nameValue.setQuotedValue(); 124 else if (nameValue.getName().compareToIgnoreCase(DOMAIN) == 0) 125 nameValue.setQuotedValue(); 126 parameters.set(nameValue); 127 }*/ 128 clone()129 public Object clone() { 130 Credentials retval = (Credentials) super.clone(); 131 if (this.parameters != null) 132 retval.parameters = (NameValueList) this.parameters.clone(); 133 return retval; 134 } 135 } 136