1 23 24 package com.sun.enterprise.deployment.runtime.common; 25 26 import com.sun.enterprise.deployment.Descriptor; 27 import java.lang.reflect.Constructor ; 28 import java.security.Principal ; 29 30 35 public class PrincipalNameDescriptor extends Descriptor { 36 37 private static final String defaultClassName = 38 "com.sun.enterprise.deployment.PrincipalImpl"; 39 private String principalName = null; 40 private String className = null; 41 42 public PrincipalNameDescriptor() {} 43 44 public String getName() { 45 return principalName; 46 } 47 48 public String getClassName() { 49 if (className == null) { 50 return defaultClassName; 51 } 52 return className; 53 } 54 55 public void setName(String name) { 56 principalName = name; 57 } 58 59 public void setClassName(String name) { 60 className = name; 61 } 62 63 public Principal getPrincipal() { 64 try { 65 Class clazz = Class.forName(getClassName()); 66 Constructor constructor = 67 clazz.getConstructor(new Class []{String .class}); 68 Object o = constructor.newInstance(new Object []{principalName}); 69 return (Principal ) o; 70 } catch(Exception ex) { 71 RuntimeException e = new RuntimeException (); 72 e.initCause(ex); 73 throw e; 74 } 75 } 76 77 public String toString() { 78 return "principal-name " + principalName + "; className " + getClassName(); 79 } 80 } 81 | Popular Tags |