1 23 24 29 package com.sun.enterprise.management.config; 30 31 import java.util.Map ; 32 import java.util.Properties ; 33 34 import javax.management.ObjectName ; 35 36 import javax.management.Attribute ; 37 import javax.management.AttributeList ; 38 39 import com.sun.appserv.management.config.PropertiesAccess; 40 import com.sun.appserv.management.config.AuthRealmConfig; 41 import static com.sun.appserv.management.config.AuthRealmConfig.*; 42 43 import com.sun.appserv.management.util.misc.StringUtil; 44 45 import com.sun.enterprise.management.support.oldconfig.OldSecurityServiceMBean; 46 import com.sun.enterprise.management.support.oldconfig.OldConfigsMBean; 47 48 import com.sun.enterprise.security.auth.realm.file.FileRealm; 49 50 52 public final class AuthRealmConfigFactory extends ConfigFactory 53 { 54 public 55 AuthRealmConfigFactory(final ConfigFactoryCallback callbacks) 56 { 57 super( callbacks ); 58 59 assert( FileRealm.JAAS_CONTEXT_PARAM.equals( 60 StringUtil.stripPrefix( JAAS_CONTEXT_PROPERTY_KEY, 61 PropertiesAccess.PROPERTY_PREFIX ) ) ); 62 63 assert( FileRealm.PARAM_KEYFILE.equals( 64 StringUtil.stripPrefix( KEY_FILE_PROPERTY_KEY, 65 PropertiesAccess.PROPERTY_PREFIX ) ) ); 66 } 67 68 private final OldSecurityServiceMBean 69 getOldSecurityServiceMBean( ) 70 { 71 final OldSecurityServiceMBean oldSecurityService = 72 getOldConfigProxies().getOldSecurityServiceMBean( getConfigName() ); 73 return( oldSecurityService ); 74 } 75 76 private final OldConfigsMBean 77 getOldConfigsMBean( ) 78 { 79 final OldConfigsMBean oldConfigs = 80 getOldConfigProxies().getOldConfigsMBean(); 81 return( oldConfigs ); 82 } 83 84 85 static final String CLASSNAME_KEY = "Classname"; 86 87 private void 88 checkDefaultProps( final Map <String ,String > optional ) 89 { 90 final String keyFile = optional == null ? 91 null : (String )optional.get( KEY_FILE_PROPERTY_KEY ); 92 if ( keyFile == null ) 93 { 94 throw new IllegalArgumentException ( 95 "Must specify a key file using KEY_FILE_PROPERTY_KEY in options Map" ); 96 } 97 98 final String jaasContext = optional == null ? 99 null : (String )optional.get( JAAS_CONTEXT_PROPERTY_KEY ); 100 if ( jaasContext == null ) 101 { 102 throw new IllegalArgumentException ( 103 "Must specify a JAAS context file using JAAS_CONTEXT_PROPERTY_KEY in options Map" ); 104 } 105 } 106 107 public ObjectName 108 create( 109 final String name, 110 final String className, 111 final Map <String ,String > optional ) 112 { 113 if ( className.equals( DEFAULT_REALM_CLASSNAME ) ) 114 { 115 checkDefaultProps( optional ); 116 } 117 118 final String [] requiredParams = { CLASSNAME_KEY, className, }; 119 120 final Map <String ,String > params = 121 initParams( name, requiredParams, optional ); 122 123 final ObjectName amxName = createNamedChild( name, params ); 124 125 return amxName; 126 } 127 128 129 130 protected final void 131 removeByName( final String authLayer ) 132 { 133 getOldSecurityServiceMBean().removeAuthRealmByName( authLayer ); 134 } 135 136 139 protected ObjectName 140 createOldChildConfig( 141 final AttributeList translatedAttrs, 142 final Properties props ) 143 { 144 final String target = getConfigName(); 145 146 final ObjectName objectName = 147 getOldConfigsMBean().createAuthRealm( 148 translatedAttrs, props, target); 149 150 return( objectName ); 151 } 152 } 153 154 155 156 157 158 159 160 | Popular Tags |