1 23 package com.sun.enterprise.management.offline; 24 25 import com.sun.enterprise.admin.config.MBeanConfigException; 26 27 import com.sun.appserv.management.util.misc.StringUtil; 28 29 32 final class AuthRealmSupport 33 { 34 private final AuthRealmMBeanX mAuthRealmMBean; 35 private final AuthRealmConfigBeanHelper mHelper; 36 37 public final String PREFIX = "${com.sun.aas.instanceRoot}"; 38 39 public 40 AuthRealmSupport( final AuthRealmConfigBeanHelper helper ) 41 { 42 mHelper = helper; 43 44 String file = helper.getFile(); 45 46 if ( file.startsWith( PREFIX ) ) 47 { 48 throw new IllegalArgumentException ( 49 "AuthRealm does not yet support ${...} values for the filename" ); 50 } 51 52 mAuthRealmMBean = new AuthRealmMBeanX( file ); 53 } 54 protected void 55 sdebug( Object o ) 56 { 57 System.out.println( "" + o ); 58 } 59 60 private String 61 getRealmName() 62 { 63 try 64 { 65 return (String )mHelper.getAttribute( "Name" ); 66 } 67 catch( Exception e ) 68 { 69 return null; 70 } 71 } 72 73 public String [] 74 getGroupNames() 75 { 76 try 77 { 78 return mAuthRealmMBean.getGroupNames(); 79 } 80 catch( MBeanConfigException e ) 81 { 82 throw new RuntimeException ( "" + e ); 83 } 84 } 85 86 public String [] 87 getUserNames() 88 { 89 91 try 92 { 93 final String [] userNames = mAuthRealmMBean.getUserNames(); 94 95 return userNames; 98 } 99 catch( MBeanConfigException e ) 100 { 101 throw new RuntimeException ( "" + e ); 104 } 105 } 106 107 public String [] 108 getUserGroupNames( final String user ) 109 { 110 try 111 { 112 return mAuthRealmMBean.getUserGroupNames( user ); 113 } 114 catch( MBeanConfigException e ) 115 { 116 throw new RuntimeException ( "" + e ); 117 } 118 } 119 120 public void 121 addUser( 122 final String user, 123 final String password, 124 final String [] groupList) 125 { 126 try 127 { 128 mAuthRealmMBean.addUser( user, password, groupList ); 129 } 130 catch( MBeanConfigException e ) 131 { 132 throw new RuntimeException ( "" + e ); 133 } 134 } 135 136 public void 137 updateUser( 138 final String user, 139 final String password, 140 final String [] groupList) 141 { 142 try 143 { 144 mAuthRealmMBean.updateUser( user, password, groupList ); 145 } 146 catch( MBeanConfigException e ) 147 { 148 throw new RuntimeException ( "" + e ); 149 } 150 } 151 152 public void 153 removeUser( final String user) 154 { 155 try 156 { 157 mAuthRealmMBean.removeUser( user ); 158 } 159 catch( MBeanConfigException e ) 160 { 161 throw new RuntimeException ( "" + e ); 162 } 163 } 164 } 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | Popular Tags |