Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/client/opers/JDAPExtendedRequest.java

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 package org.ietf.ldap.client.opers;
39
40 import org.ietf.ldap.ber.stream.BERElement;
41 import org.ietf.ldap.ber.stream.BEROctetString;
42 import org.ietf.ldap.ber.stream.BERSequence;
43 import org.ietf.ldap.ber.stream.BERTag;
44
45 /**
46 * This class implements the ExtendedRequest request. This object
47 * is sent to the ldap server and is a v3 request.
48 * <P>See RFC 1777.
49 *
50 * <pre>
51 * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
52 * requestName [0] LDAPOID,
53 * requestValue [1] OCTET STRING OPTIONAL
54 * }
55 * </pre>
56 *
57 * @version 1.0
58 */
59 public class JDAPExtendedRequest implements JDAPProtocolOp {
60 /**
61 * Internal variables
62 */
63 protected String m_oid = null;
64 protected byte m_value[] = null;
65
66 /**
67 * Constructs extended request.
68 * @param oid object identifier
69 * @param value request value
70 */
71 public JDAPExtendedRequest(String oid, byte value[]) {
72 m_oid = oid;
73 m_value = value;
74 }
75
76 /**
77 * Retrieves protocol operation type.
78 * @return protcol type
79 */
80 public int getType() {
81 return JDAPProtocolOp.EXTENDED_REQUEST;
82 }
83
84 /**
85 * Gets the ber representation of extended request.
86 * @return ber representation of request
87 */
88 public BERElement getBERElement() {
89 BERSequence seq = new BERSequence();
90 seq.addElement(new BERTag(BERTag.CONTEXT|0,
91 new BEROctetString (m_oid), true));
92 if (m_value != null) {
93 seq.addElement(new BERTag(BERTag.CONTEXT|1,
94 new BEROctetString (m_value, 0, m_value.length), true));
95 }
96 BERTag element = new BERTag(BERTag.APPLICATION|BERTag.CONSTRUCTED|23,
97 seq, true);
98 return element;
99 }
100
101 /**
102 * Retrieves the string representation of add request parameters.
103 * @return string representation of add request parameters
104 */
105 public String getParamString() {
106 String s = "";
107 if (m_value != null) {
108 try{
109 s = new String(m_value, "UTF8");
110 } catch(Throwable x) {}
111 }
112 return "{OID='" + m_oid + "', value='" + s + "'}";
113 }
114
115 /**
116 * Retrieves the string representation of add request.
117 * @return string representation of add request
118 */
119 public String toString() {
120 return "ExtendedRequest " + getParamString();
121 }
122 }