01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.client;
17:
18: import java.io.IOException;
19: import java.io.ObjectInput;
20: import java.io.ObjectOutput;
21:
22: public class AuthenticationRequest implements Request {
23:
24: private transient String realm;
25: private transient String username;
26: private transient String credentials;
27:
28: public AuthenticationRequest() {
29: }
30:
31: public AuthenticationRequest(String principal, String credentials) {
32: this (null, principal, credentials);
33: }
34:
35: public AuthenticationRequest(String realm, String principal,
36: String credentials) {
37: this .realm = realm;
38: this .username = principal;
39: this .credentials = credentials;
40: }
41:
42: public byte getRequestType() {
43: return RequestMethodConstants.AUTH_REQUEST;
44: }
45:
46: public String getRealm() {
47: return realm;
48: }
49:
50: public String getUsername() {
51: return username;
52: }
53:
54: public String getCredentials() {
55: return credentials;
56: }
57:
58: public void readExternal(ObjectInput in) throws IOException,
59: ClassNotFoundException {
60: byte version = in.readByte(); // future use
61:
62: realm = (String) in.readObject();
63: username = (String) in.readObject();
64: credentials = (String) in.readObject();
65: }
66:
67: public void writeExternal(ObjectOutput out) throws IOException {
68: // write out the version of the serialized data for future use
69: out.writeByte(1);
70:
71: out.writeObject(realm);
72: out.writeObject(username);
73: out.writeObject(credentials);
74: }
75:
76: public String toString() {
77: StringBuilder sb = new StringBuilder(50);
78: sb.append(realm).append(':');
79: sb.append(username);
80: return sb.toString();
81: }
82: }
|