@Override public Object run(SecurityService ss) throws PropertyVetoException, TransactionFailure { AuthRealm oldAdminRealm = getAdminRealm(ss); ss.getAuthRealm().remove(oldAdminRealm); appendNL(sb,"..."); //AuthRealm ldapr = createLDAPRealm(ss); //ss.getAuthRealm().add(ldapr); //appendNL(sb,lsm.getString("ldap.realm.setup", FIXED_ADMIN_REALM_NAME)); return true; } };
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { param.getAuthRealm().remove(authRealm); return null; } }, securityService);
private AuthRealm findRealm() { for (AuthRealm realm : securityService.getAuthRealm()) { if (realm.getName().equals(authRealmName)) { return realm; } } return null; } }
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { param.getAuthRealm().remove(authRealm); //temporary fix - since the SecurityConfigListener is not being called on an realm delete. SecurityConfigListener.authRealmDeleted(authRealm); return null; } }, securityService);
@Override public Object run(SecurityService ss) throws PropertyVetoException, TransactionFailure { AuthRealm ldapr = createLDAPRealm(ss); ss.getAuthRealm().add(ldapr); appendNL(sb,lsm.getString("ldap.realm.setup", FIXED_ADMIN_REALM_NAME)); return true; } };
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { AuthRealm newAuthRealm = ConfigSupport.createChildOf( param, AuthRealm.class); populateAuthRealmElement(newAuthRealm); param.getAuthRealm().add(newAuthRealm); return newAuthRealm; } }, securityService);
private List<AuthRealm> getAuthRealms() { return getSecurityService().getAuthRealm(); }
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { param.getAuthRealm().remove(authRealm); //temporary fix - since the SecurityConfigListener is not being called on an realm delete. SecurityConfigListener.authRealmDeleted(authRealm); return null; } }, securityService);
static boolean isRealmNew(final SecurityService securityService, final String authRealmName) { // check if there exists an auth realm byt he specified name // if so return failure. List<AuthRealm> authrealms = securityService.getAuthRealm(); for (AuthRealm authrealm : authrealms) { if (authrealm.getName().equals(authRealmName)) { return false; } } return true; }
private AuthRealm getAdminRealm(SecurityService ss) { List<AuthRealm> realms = ss.getAuthRealm(); for (AuthRealm realm : realms) { if (FIXED_ADMIN_REALM_NAME.equals(realm.getName())) return realm; } return null; //unlikely - represents an assertion }
private String getNewRealmName(SecurityService ss) { List<AuthRealm> realms = ss.getAuthRealm(); String pref = ORIG_ADMIN_REALM_NAME + "-"; int index = 0; //last one for (AuthRealm realm : realms) { if (realm.getName().indexOf(pref) >= 0) { index = Integer.parseInt(realm.getName().substring(pref.length())); } } return pref + (index+1); }
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { AuthRealm newAuthRealm = param.createChild(AuthRealm.class); populateAuthRealmElement(newAuthRealm); param.getAuthRealm().add(newAuthRealm); //In case of cluster instances, this is required to //avoid issues with the listener's callback method SecurityConfigListener.authRealmCreated(config, newAuthRealm); return newAuthRealm; } }, securityService);
public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { AuthRealm newAuthRealm = param.createChild(AuthRealm.class); populateAuthRealmElement(newAuthRealm); param.getAuthRealm().add(newAuthRealm); //In case of cluster instances, this is required to //avoid issues with the listener's callback method SecurityConfigListener.authRealmCreated(config, newAuthRealm); return newAuthRealm; } }, securityService);
static AuthRealm findRealm(final SecurityService securityService, String authRealmName) { // ensure we have the file authrealm if (authRealmName == null) { authRealmName = securityService.getDefaultRealm(); } for (AuthRealm authRealm : securityService.getAuthRealm()) { if (authRealm.getName().equals(authRealmName)) { return authRealm; } } return null; }
public List<String> getKeyFileNames(SecurityService securityService) { List<String> keyFileNames = new ArrayList<String>(); List<AuthRealm> authRealms = securityService.getAuthRealm(); for (AuthRealm authRealm : authRealms) { String className = authRealm.getClassname(); if ("com.sun.enterprise.security.auth.realm.file.FileRealm".equals(className)) { List<Property> props = authRealm.getProperty(); for (Property prop : props) { if ("file".equals(prop.getName())) { keyFileNames.add(prop.getValue()); } } } } return keyFileNames; }
public List<String> getKeyFileNames(SecurityService securityService) { List<String> keyFileNames = new ArrayList<String>(); List<AuthRealm> authRealms = securityService.getAuthRealm(); for (AuthRealm authRealm : authRealms) { String className = authRealm.getClassname(); if ("com.sun.enterprise.security.auth.realm.file.FileRealm".equals(className)) { List<Property> props = authRealm.getProperty(); for (Property prop : props) { if ("file".equals(prop.getName())) { keyFileNames.add(prop.getValue()); } } } } return keyFileNames; }
/** This is the place where the iteration for the {@link AuthRealm} for administration should be carried out * in server. A convenience method for the same. * * @param as AdminService implemented by those who implement the interface (outer interface). * @return AuthRealm instance for which the name is same as as.getAuthRealmName(), null otherwise. */ public static AuthRealm getAssociatedAuthRealm(AdminService as) { String rn = as.getAuthRealmName(); //this is the name of admin-service@auth-realm-name Config cfg = as.getParent(Config.class); //assumes the structure where <admin-service> resides directly under <config> SecurityService ss = cfg.getSecurityService(); List<AuthRealm> realms = ss.getAuthRealm(); for (AuthRealm realm : realms) { if (rn.equals(realm.getName())) return realm; } return null; }
/** This is the place where the iteration for the {@link AuthRealm} for administration should be carried out * in server. A convenience method for the same. * * @param as AdminService implemented by those who implement the interface (outer interface). * @return AuthRealm instance for which the name is same as as.getAuthRealmName(), null otherwise. */ public static AuthRealm getAssociatedAuthRealm(AdminService as) { String rn = as.getAuthRealmName(); //this is the name of admin-service@auth-realm-name Config cfg = as.getParent(Config.class); //assumes the structure where <admin-service> resides directly under <config> SecurityService ss = cfg.getSecurityService(); List<AuthRealm> realms = ss.getAuthRealm(); for (AuthRealm realm : realms) { if (rn.equals(realm.getName())) return realm; } return null; }
/** * Executes the command with the command parameters passed as Properties * where the keys are the paramter names and the values the parameter values * * @param context information */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); List <Config> configList = configs.getConfig(); Config config = configList.get(0); SecurityService securityService = config.getSecurityService(); for (AuthRealm realm : securityService.getAuthRealm()) { ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(realm.getName()); } } }
/** * Executes the command with the command parameters passed as Properties * where the keys are the paramter names and the values the parameter values * * @param context information */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); // Enumeration realms = Realm.getRealmNames(); // // if ( realms == null || !realms.hasMoreElements()) { // //Create realms // realmsManager.createRealms(securityService); // } for (AuthRealm authRealm : securityService.getAuthRealm()) { ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(authRealm.getName()); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } }