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.geronimo.security.deploy;
17:
18: import java.beans.PropertyEditorManager;
19:
20: import org.apache.geronimo.common.propertyeditor.PropertyEditorException;
21: import org.apache.geronimo.common.propertyeditor.TextPropertyEditorSupport;
22:
23: /**
24: * @version $Rev: 545781 $ $Date: 2007-06-09 10:44:02 -0700 (Sat, 09 Jun 2007) $
25: */
26: public class LoginDomainPrincipalInfo extends PrincipalInfo {
27:
28: static {
29: PropertyEditorManager.registerEditor(
30: LoginDomainPrincipalInfo.class,
31: LoginDomainPrincipalEditor.class);
32: }
33:
34: public LoginDomainPrincipalInfo(String domainName,
35: String className, String principalName) {
36: super (className, principalName);
37: this .domainName = domainName;
38: }
39:
40: private final String domainName;
41:
42: public String getDomain() {
43: return domainName;
44: }
45:
46: public static class LoginDomainPrincipalEditor extends
47: TextPropertyEditorSupport {
48:
49: public void setAsText(String text) {
50: if (text != null) {
51: String[] parts = text.split(",");
52: if (parts.length != 3) {
53: throw new PropertyEditorException(
54: "Principal should have the form 'domain,class,name'");
55: }
56: LoginDomainPrincipalInfo principal = new LoginDomainPrincipalInfo(
57: parts[0], parts[1], parts[2]);
58: setValue(principal);
59: } else {
60: setValue(null);
61: }
62: }
63:
64: public String getAsText() {
65: LoginDomainPrincipalInfo principal = (LoginDomainPrincipalInfo) getValue();
66: if (principal == null) {
67: return null;
68: }
69: return principal.getPrincipalName() + ","
70: + principal.getClassName() + ","
71: + principal.getDomain();
72: }
73: }
74: }
|