1 17 package org.apache.geronimo.security.deploy; 18 19 import java.beans.PropertyEditorManager ; 20 import java.io.Serializable ; 21 22 import org.apache.geronimo.common.propertyeditor.PropertyEditorException; 23 import org.apache.geronimo.common.propertyeditor.TextPropertyEditorSupport; 24 25 26 29 public class Principal implements Serializable { 30 31 static { 32 PropertyEditorManager.registerEditor(Principal.class, PrincipalEditor.class); 33 } 34 35 private String className; 36 private String principalName; 37 private boolean designatedRunAs; 38 39 public String getClassName() { 40 return className; 41 } 42 43 public void setClassName(String className) { 44 this.className = className; 45 } 46 47 public String getPrincipalName() { 48 return principalName; 49 } 50 51 public void setPrincipalName(String principalName) { 52 this.principalName = principalName; 53 } 54 55 public boolean isDesignatedRunAs() { 56 return designatedRunAs; 57 } 58 59 public void setDesignatedRunAs(boolean designatedRunAs) { 60 this.designatedRunAs = designatedRunAs; 61 } 62 63 public static class PrincipalEditor extends TextPropertyEditorSupport { 64 65 public void setAsText(String text) { 66 if (text != null) { 67 String [] parts = text.split("="); 68 if (parts.length != 2) { 69 throw new PropertyEditorException("Principal should have the form 'name=class'"); 70 } 71 Principal principal = new Principal(); 72 principal.setPrincipalName(parts[0]); 73 principal.setClassName(parts[1]); 74 setValue(principal); 75 } else { 76 setValue(null); 77 } 78 } 79 80 public String getAsText() { 81 Principal principal = (Principal) getValue(); 82 if (principal == null) { 83 return null; 84 } 85 return new StringBuffer (principal.getPrincipalName()).append("=").append(principal.getClassName()).toString(); 86 } 87 } 88 } 89 | Popular Tags |