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 * and others. 7 * Pursuant to title 15 Untied States Code Section 105, works of NIST 8 * employees are not subject to copyright protection in the United States 9 * and are considered to be in the public domain. As a result, a formal 10 * license is not needed to use the software. 11 * 12 * This software is provided by NIST as a service and is expressly 13 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 14 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 16 * AND DATA ACCURACY. NIST does not warrant or make any representations 17 * regarding the use of the software or the results thereof, including but 18 * not limited to the correctness, accuracy, reliability or usefulness of 19 * the software. 20 * 21 * Permission to use this software is contingent upon your acceptance 22 * of the terms of this agreement 23 * 24 * . 25 * 26 */ 27 /***************************************************************************** 28 * PRODUCT OF PT INOVACAO - EST DEPARTMENT and Aveiro University - Portugal) * 29 *****************************************************************************/ 30 31 32 package gov.nist.javax.sip.header.ims; 33 34 35 import java.text.ParseException; 36 37 import gov.nist.javax.sip.header.SIPHeader; 38 39 import javax.sip.InvalidArgumentException; 40 import javax.sip.header.ExtensionHeader; 41 import javax.sip.header.HeaderAddress; 42 import javax.sip.header.Parameters; 43 44 45 /** 46 * P-Media-Authorization SIP Private Header - RFC 3313. 47 * 48 * <p>Sintax:</p> 49 * <pre> 50 * P-Media-Authorization = "P-Media-Authorization" HCOLON 51 * P-Media-Authorization-Token 52 * *(COMMA P-Media-Authorization-Token) 53 * P-Media-Authorization-Token = 1*HEXDIG 54 * </pre> 55 * @author Miguel Freitas (IT) PT-Inovacao 56 */ 57 58 public class PMediaAuthorization 59 extends SIPHeader 60 implements PMediaAuthorizationHeader, SIPHeaderNamesIms, ExtensionHeader 61 { 62 63 /** 64 * Comment for <code>serialVersionUID</code> 65 */ 66 private static final long serialVersionUID = -6463630258703731133L; 67 68 69 /** 70 * P-Media-Authorization Token 71 */ 72 private String token; 73 74 75 /** 76 * Constructor 77 */ 78 public PMediaAuthorization() 79 { 80 super(P_MEDIA_AUTHORIZATION); 81 } 82 83 84 /** 85 * Get the media authorization token. 86 * 87 * @return token 88 */ 89 public String getToken() 90 { 91 return token; 92 } 93 94 95 /** 96 * Set the media authorization token. 97 * 98 * @param token - media authorization token to set 99 * @throws InvalidArgumentException - if token is null or empty 100 */ 101 public void setMediaAuthorizationToken(String token) throws InvalidArgumentException 102 { 103 if (token == null || token.length() == 0) 104 throw new InvalidArgumentException(" the Media-Authorization-Token parameter is null or empty"); 105 106 this.token = token; 107 } 108 109 /** 110 * Encode header 111 * @return the header content 112 */ 113 protected String encodeBody() 114 { 115 return token; 116 } 117 118 119 public void setValue(String value) throws ParseException { 120 throw new ParseException (value,0); 121 122 } 123 124 125 public boolean equals(Object other) 126 { 127 if (other instanceof PMediaAuthorizationHeader) 128 { 129 final PMediaAuthorizationHeader o = (PMediaAuthorizationHeader) other; 130 return this.getToken().equals(o.getToken()); 131 } 132 return false; 133 134 } 135 136 137 public Object clone() { 138 PMediaAuthorization retval = (PMediaAuthorization) super.clone(); 139 if (this.token != null) 140 retval.token = this.token; 141 return retval; 142 } 143 144 } 145