Search in sources :

Example 1 with SecurityMapConfig

use of com.sun.appserv.management.config.SecurityMapConfig in project Payara by payara.

the class SecurityMapConfigTest method ensureDefaultInstance.

public static SecurityMapConfig ensureDefaultInstance(final DomainConfig domainConfig) {
    final ConnectorConnectionPoolConfig ccpc = ConnectorConnectionPoolConfigTest.ensureDefaultInstance(domainConfig);
    SecurityMapConfig result = ccpc.getSecurityMapConfigMap().get(getDefaultInstanceName());
    if (result == null) {
        result = createInstance(ccpc, getDefaultInstanceName(), DEFAULT_BACKEND_PRINCIPAL, DEFAULT_BACKEND_PASSWORD, DEFAULT_PRINCIPALS, DEFAULT_USERGROUPS);
    }
    return result;
}
Also used : ConnectorConnectionPoolConfig(com.sun.appserv.management.config.ConnectorConnectionPoolConfig) SecurityMapConfig(com.sun.appserv.management.config.SecurityMapConfig)

Example 2 with SecurityMapConfig

use of com.sun.appserv.management.config.SecurityMapConfig in project Payara by payara.

the class SecurityMapConfigTest method testCreateRemove.

public void testCreateRemove() {
    if (!checkNotOffline("testDeleteLBConfig")) {
        return;
    }
    final String TEST_NAME = "SecurityMapConfigTest.testCreateRemove";
    final ResourceAdapterConfig rac = ResourceAdapterConfigTest.createInstance(getDomainConfig(), TEST_NAME);
    try {
        final ConnectorConnectionPoolConfig ccpc = ConnectorConnectionPoolConfigTest.createInstance(getDomainConfig(), TEST_NAME, CONNECTOR_DEF_NAME, rac.getName(), null);
        try {
            final String smcName = "SecurityMapConfigTest.testCreateRemove";
            final String[] principals = new String[] { "SecurityMapConfigTest.testCreateRemove" };
            final String[] userGroups = new String[0];
            final SecurityMapConfig smc = createInstance(ccpc, smcName, DEFAULT_BACKEND_PRINCIPAL, DEFAULT_BACKEND_PASSWORD, principals, null);
            try {
                assert (smcName.equals(smc.getName()));
                assert (smc == ccpc.getSecurityMapConfigMap().get(smc.getName()));
                testGetters(smc);
                final Set<String> principalsBefore = GSetUtil.newSet(smc.getPrincipalNames());
                final String PRINCIPAL1 = "testCreateRemove.test1";
                smc.createPrincipal(PRINCIPAL1);
                final Set<String> principalsAfter = GSetUtil.newSet(smc.getPrincipalNames());
                assert (principalsAfter.contains(PRINCIPAL1));
                smc.removePrincipal(PRINCIPAL1);
                assert (principalsBefore.equals(GSetUtil.newSet(smc.getPrincipalNames())));
            } finally {
                ccpc.removeSecurityMapConfig(smc.getName());
            }
        } finally {
            getDomainConfig().getResourcesConfig().removeConnectorConnectionPoolConfig(ccpc.getName());
        }
    } finally {
        getDomainConfig().getResourcesConfig().removeResourceAdapterConfig(rac.getName());
    }
}
Also used : ConnectorConnectionPoolConfig(com.sun.appserv.management.config.ConnectorConnectionPoolConfig) SecurityMapConfig(com.sun.appserv.management.config.SecurityMapConfig) ResourceAdapterConfig(com.sun.appserv.management.config.ResourceAdapterConfig)

Example 3 with SecurityMapConfig

use of com.sun.appserv.management.config.SecurityMapConfig in project Payara by payara.

the class SecurityServiceConfigTest method testCreateRemove.

public void testCreateRemove() {
    if (!checkNotOffline("testDeleteLBConfig")) {
        return;
    }
    final String TEST_NAME = "SecurityMapConfigTest.testCreateRemove";
    final ResourceAdapterConfig rac = ResourceAdapterConfigTest.createInstance(getDomainConfig(), TEST_NAME);
    try {
        final ConnectorConnectionPoolConfig ccpc = ConnectorConnectionPoolConfigTest.createInstance(getDomainConfig(), TEST_NAME, CONNECTOR_DEF_NAME, rac.getName(), null);
        try {
            final String smcName = TEST_NAME;
            final String[] principals = new String[] { TEST_NAME };
            final String[] userGroups = new String[0];
            final SecurityMapConfig smc = createInstance(ccpc, smcName, DEFAULT_BACKEND_PRINCIPAL, DEFAULT_BACKEND_PASSWORD, principals, null);
            try {
                assert (smcName.equals(smc.getName()));
                assert (smc == ccpc.getSecurityMapConfigMap().get(smc.getName()));
                testGetters(smc);
                final Set<String> principalsBefore = GSetUtil.newSet(smc.getPrincipalNames());
                final String PRINCIPAL1 = "testCreateRemove.test1";
                smc.createPrincipal(PRINCIPAL1);
                final Set<String> principalsAfter = GSetUtil.newSet(smc.getPrincipalNames());
                assert (principalsAfter.contains(PRINCIPAL1));
                smc.removePrincipal(PRINCIPAL1);
                assert (principalsBefore.equals(GSetUtil.newSet(smc.getPrincipalNames())));
            } finally {
                ccpc.removeSecurityMapConfig(smc.getName());
            }
        } finally {
            getDomainConfig().getResourcesConfig().removeConnectorConnectionPoolConfig(ccpc.getName());
        }
    } finally {
        getDomainConfig().getResourcesConfig().removeResourceAdapterConfig(rac.getName());
    }
}
Also used : ConnectorConnectionPoolConfig(com.sun.appserv.management.config.ConnectorConnectionPoolConfig) SecurityMapConfig(com.sun.appserv.management.config.SecurityMapConfig) ResourceAdapterConfig(com.sun.appserv.management.config.ResourceAdapterConfig)

Example 4 with SecurityMapConfig

use of com.sun.appserv.management.config.SecurityMapConfig in project Payara by payara.

the class SecurityServiceConfigTest method ensureDefaultInstance.

public static SecurityMapConfig ensureDefaultInstance(final DomainConfig domainConfig) {
    final ConnectorConnectionPoolConfig ccpc = ConnectorConnectionPoolConfigTest.ensureDefaultInstance(domainConfig);
    SecurityMapConfig result = ccpc.getSecurityMapConfigMap().get(getDefaultInstanceName());
    if (result == null) {
        result = createInstance(ccpc, getDefaultInstanceName(), DEFAULT_BACKEND_PRINCIPAL, DEFAULT_BACKEND_PASSWORD, DEFAULT_PRINCIPALS, DEFAULT_USERGROUPS);
    }
    return result;
}
Also used : ConnectorConnectionPoolConfig(com.sun.appserv.management.config.ConnectorConnectionPoolConfig) SecurityMapConfig(com.sun.appserv.management.config.SecurityMapConfig)

Example 5 with SecurityMapConfig

use of com.sun.appserv.management.config.SecurityMapConfig in project Payara by payara.

the class AMXTest method checkCreateRemoveGet.

/**
 *     Verify:
 *     <ul>
 *     <li>each create() or createAbc() method ends in "Config" if it returns an AMXConfig subclass</li>
 *     <li>each remove() or removeAbc() method ends in "Config"</li>
 *     </ul>
 */
public void checkCreateRemoveGet(final ObjectName objectName) throws Exception {
    final AMX proxy = getProxyFactory().getProxy(objectName, AMX.class);
    if (proxy instanceof Container) {
        final Method[] methods = getInterfaceClass(proxy).getMethods();
        final MBeanInfo mbeanInfo = Util.getExtra(proxy).getMBeanInfo();
        final MBeanOperationInfo[] operations = mbeanInfo.getOperations();
        for (int methodIdx = 0; methodIdx < methods.length; ++methodIdx) {
            final Method method = methods[methodIdx];
            final String methodName = method.getName();
            if (methodName.startsWith("create") && !methodName.endsWith("Config")) {
                if (AMXConfig.class.isAssignableFrom(method.getReturnType()) && (!(proxy instanceof SecurityMapConfig))) {
                    trace("WARNING: method " + methodName + " does not end in 'Config': " + objectName);
                }
            } else if (methodName.startsWith("remove") && !methodName.endsWith("Config") && proxy instanceof AMXConfig) {
                if (// method.getReturnType() == Void.class &&
                method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == String.class && !method.getName().equals("removeProperty") && !method.getName().equals("removeSystemProperty") && (!(proxy instanceof SecurityMapConfig))) {
                    trace("WARNING: method " + methodName + " does not end in 'Config': " + methodName);
                }
            }
        }
    }
}
Also used : Container(com.sun.appserv.management.base.Container) MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) SecurityMapConfig(com.sun.appserv.management.config.SecurityMapConfig) Method(java.lang.reflect.Method) AMX(com.sun.appserv.management.base.AMX) AMXConfig(com.sun.appserv.management.config.AMXConfig)

Aggregations

SecurityMapConfig (com.sun.appserv.management.config.SecurityMapConfig)5 ConnectorConnectionPoolConfig (com.sun.appserv.management.config.ConnectorConnectionPoolConfig)4 ResourceAdapterConfig (com.sun.appserv.management.config.ResourceAdapterConfig)2 AMX (com.sun.appserv.management.base.AMX)1 Container (com.sun.appserv.management.base.Container)1 AMXConfig (com.sun.appserv.management.config.AMXConfig)1 Method (java.lang.reflect.Method)1 MBeanInfo (javax.management.MBeanInfo)1 MBeanOperationInfo (javax.management.MBeanOperationInfo)1