Search in sources :

Example 6 with Security

use of org.jboss.jca.common.api.metadata.common.Security in project wildfly by wildfly.

the class IronJacamarResourceCreator method addConnectionDefinition.

private void addConnectionDefinition(final Resource parent, ConnectionDefinition connDef) {
    final Resource connDefResource = new IronJacamarResource.IronJacamarRuntimeResource();
    final ModelNode model = connDefResource.getModel();
    setAttribute(model, Constants.JNDINAME, connDef.getJndiName());
    if (connDef.getConfigProperties() != null) {
        for (Map.Entry<String, String> config : connDef.getConfigProperties().entrySet()) {
            addConfigProperties(connDefResource, config.getKey(), config.getValue());
        }
    }
    setAttribute(model, CLASS_NAME, connDef.getClassName());
    setAttribute(model, JNDINAME, connDef.getJndiName());
    setAttribute(model, USE_JAVA_CONTEXT, connDef.isUseJavaContext());
    setAttribute(model, ENABLED, connDef.isEnabled());
    setAttribute(model, CONNECTABLE, connDef.isConnectable());
    if (connDef.isTracking() != null) {
        setAttribute(model, TRACKING, connDef.isTracking());
    }
    setAttribute(model, USE_CCM, connDef.isUseCcm());
    setAttribute(model, SHARABLE, connDef.isSharable());
    setAttribute(model, ENLISTMENT, connDef.isEnlistment());
    final Pool pool = connDef.getPool();
    if (pool != null) {
        setAttribute(model, MAX_POOL_SIZE, pool.getMaxPoolSize());
        setAttribute(model, MIN_POOL_SIZE, pool.getMinPoolSize());
        setAttribute(model, INITIAL_POOL_SIZE, pool.getInitialPoolSize());
        if (pool.getCapacity() != null) {
            if (pool.getCapacity().getIncrementer() != null) {
                setAttribute(model, CAPACITY_INCREMENTER_CLASS, pool.getCapacity().getIncrementer().getClassName());
                if (pool.getCapacity().getIncrementer().getConfigPropertiesMap() != null) {
                    for (Map.Entry<String, String> config : pool.getCapacity().getIncrementer().getConfigPropertiesMap().entrySet()) {
                        model.get(CAPACITY_INCREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                    }
                }
            }
            if (pool.getCapacity().getDecrementer() != null) {
                setAttribute(model, CAPACITY_DECREMENTER_CLASS, pool.getCapacity().getDecrementer().getClassName());
                if (pool.getCapacity().getDecrementer().getConfigPropertiesMap() != null) {
                    for (Map.Entry<String, String> config : pool.getCapacity().getDecrementer().getConfigPropertiesMap().entrySet()) {
                        model.get(CAPACITY_DECREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                    }
                }
            }
        }
        setAttribute(model, POOL_USE_STRICT_MIN, pool.isUseStrictMin());
        if (pool.getFlushStrategy() != null)
            setAttribute(model, POOL_FLUSH_STRATEGY, pool.getFlushStrategy().name());
        setAttribute(model, POOL_PREFILL, pool.isPrefill());
        setAttribute(model, POOL_FAIR, pool.isFair());
        if (connDef.isXa()) {
            assert connDef.getPool() instanceof XaPool;
            XaPool xaPool = (XaPool) connDef.getPool();
            setAttribute(model, WRAP_XA_RESOURCE, xaPool.isWrapXaResource());
            setAttribute(model, SAME_RM_OVERRIDE, xaPool.isSameRmOverride());
            setAttribute(model, PAD_XID, xaPool.isPadXid());
            setAttribute(model, INTERLEAVING, xaPool.isInterleaving());
            setAttribute(model, NOTXSEPARATEPOOL, xaPool.isNoTxSeparatePool());
        }
    }
    final Security security = connDef.getSecurity();
    if (security != null) {
        setAttribute(model, APPLICATION, security.isApplication());
        if (security instanceof org.jboss.as.connector.metadata.api.common.Security && ((org.jboss.as.connector.metadata.api.common.Security) security).isElytronEnabled()) {
            setAttribute(model, ELYTRON_ENABLED, true);
            setAttribute(model, AUTHENTICATION_CONTEXT, security.getSecurityDomain());
            setAttribute(model, AUTHENTICATION_CONTEXT_AND_APPLICATION, security.getSecurityDomainAndApplication());
        } else {
            setAttribute(model, SECURITY_DOMAIN, security.getSecurityDomain());
            setAttribute(model, SECURITY_DOMAIN_AND_APPLICATION, security.getSecurityDomainAndApplication());
        }
    }
    final TimeOut timeOut = connDef.getTimeOut();
    if (timeOut != null) {
        setAttribute(model, ALLOCATION_RETRY, timeOut.getAllocationRetry());
        setAttribute(model, ALLOCATION_RETRY_WAIT_MILLIS, timeOut.getAllocationRetryWaitMillis());
        setAttribute(model, BLOCKING_TIMEOUT_WAIT_MILLIS, timeOut.getBlockingTimeoutMillis());
        setAttribute(model, IDLETIMEOUTMINUTES, timeOut.getIdleTimeoutMinutes());
        setAttribute(model, XA_RESOURCE_TIMEOUT, timeOut.getXaResourceTimeout());
    }
    final Validation validation = connDef.getValidation();
    if (validation != null) {
        setAttribute(model, BACKGROUNDVALIDATIONMILLIS, validation.getBackgroundValidationMillis());
        setAttribute(model, BACKGROUNDVALIDATION, validation.isBackgroundValidation());
        setAttribute(model, USE_FAST_FAIL, validation.isUseFastFail());
        setAttribute(model, VALIDATE_ON_MATCH, validation.isValidateOnMatch());
    }
    final Recovery recovery = connDef.getRecovery();
    if (recovery != null) {
        setAttribute(model, NO_RECOVERY, recovery.getNoRecovery());
        final Extension recoverPlugin = recovery.getRecoverPlugin();
        if (recoverPlugin != null) {
            setAttribute(model, RECOVERLUGIN_CLASSNAME, recoverPlugin.getClassName());
            if (recoverPlugin.getConfigPropertiesMap() != null) {
                for (Map.Entry<String, String> config : recoverPlugin.getConfigPropertiesMap().entrySet()) {
                    model.get(RECOVERLUGIN_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                }
            }
        }
        final Credential recoveryCredential = recovery.getCredential();
        if (recoveryCredential != null) {
            setAttribute(model, RECOVERY_PASSWORD, recoveryCredential.getPassword());
            if (recoveryCredential instanceof org.jboss.as.connector.metadata.api.common.Credential && ((org.jboss.as.connector.metadata.api.common.Credential) recoveryCredential).isElytronEnabled()) {
                setAttribute(model, RECOVERY_ELYTRON_ENABLED, true);
                setAttribute(model, RECOVERY_AUTHENTICATION_CONTEXT, recoveryCredential.getSecurityDomain());
            } else {
                setAttribute(model, RECOVERY_SECURITY_DOMAIN, recoveryCredential.getSecurityDomain());
            }
            setAttribute(model, RECOVERY_USERNAME, recoveryCredential.getUserName());
        }
    }
    final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
    connDefResource.registerChild(PathElement.pathElement(Constants.STATISTICS_NAME, "local"), statsResource);
    final PathElement element = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, connDef.getJndiName());
    parent.registerChild(element, connDefResource);
}
Also used : Validation(org.jboss.jca.common.api.metadata.common.Validation) XaPool(org.jboss.jca.common.api.metadata.common.XaPool) Credential(org.jboss.jca.common.api.metadata.common.Credential) TimeOut(org.jboss.jca.common.api.metadata.common.TimeOut) Resource(org.jboss.as.controller.registry.Resource) WorkManagerSecurity(org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity) Security(org.jboss.jca.common.api.metadata.common.Security) Recovery(org.jboss.jca.common.api.metadata.common.Recovery) Extension(org.jboss.jca.common.api.metadata.common.Extension) PathElement(org.jboss.as.controller.PathElement) XaPool(org.jboss.jca.common.api.metadata.common.XaPool) Pool(org.jboss.jca.common.api.metadata.common.Pool) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map)

Example 7 with Security

use of org.jboss.jca.common.api.metadata.common.Security in project wildfly by wildfly.

the class PooledConnectionFactoryService method createConnDef.

private static ConnectionDefinition createConnDef(TransactionSupportEnum transactionSupport, String jndiName, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace) throws ValidateException {
    Integer minSize = (minPoolSize == -1) ? null : minPoolSize;
    Integer maxSize = (maxPoolSize == -1) ? null : maxPoolSize;
    boolean prefill = false;
    boolean useStrictMin = false;
    FlushStrategy flushStrategy = FlushStrategy.FAILING_CONNECTION_ONLY;
    Boolean isXA = Boolean.FALSE;
    final Pool pool;
    if (transactionSupport == TransactionSupportEnum.XATransaction) {
        pool = new XaPoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
        isXA = Boolean.TRUE;
    } else {
        pool = new PoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR);
    }
    TimeOut timeOut = new TimeOutImpl(null, null, null, null, null) {
    };
    // <security>
    // <application />
    // </security>
    // => PoolStrategy.POOL_BY_CRI
    Security security = new SecurityImpl(null, null, true, false);
    // register the XA Connection *without* recovery. ActiveMQ already takes care of the registration with the correct credentials
    // when its ResourceAdapter is started
    Recovery recovery = new Recovery(new CredentialImpl(null, null, null, false, null), null, Boolean.TRUE);
    Validation validation = new ValidationImpl(Defaults.VALIDATE_ON_MATCH, null, null, false);
    // do no track
    return new ConnectionDefinitionImpl(Collections.<String, String>emptyMap(), RAMANAGED_CONN_FACTORY, jndiName, ACTIVEMQ_CONN_DEF, true, true, true, Defaults.SHARABLE, Defaults.ENLISTMENT, Defaults.CONNECTABLE, false, managedConnectionPoolClassName, enlistmentTrace, pool, timeOut, validation, security, recovery, isXA);
}
Also used : Validation(org.jboss.jca.common.api.metadata.common.Validation) TimeOut(org.jboss.jca.common.api.metadata.common.TimeOut) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) PoolImpl(org.jboss.jca.common.metadata.common.PoolImpl) Security(org.jboss.jca.common.api.metadata.common.Security) Recovery(org.jboss.jca.common.api.metadata.common.Recovery) ValidationImpl(org.jboss.jca.common.metadata.common.ValidationImpl) SecurityImpl(org.jboss.as.connector.metadata.common.SecurityImpl) CredentialImpl(org.jboss.as.connector.metadata.common.CredentialImpl) FlushStrategy(org.jboss.jca.common.api.metadata.common.FlushStrategy) ConnectionDefinitionImpl(org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) Pool(org.jboss.jca.common.api.metadata.common.Pool) TimeOutImpl(org.jboss.jca.common.metadata.common.TimeOutImpl)

Aggregations

Security (org.jboss.jca.common.api.metadata.common.Security)7 Pool (org.jboss.jca.common.api.metadata.common.Pool)4 Recovery (org.jboss.jca.common.api.metadata.common.Recovery)4 TimeOut (org.jboss.jca.common.api.metadata.common.TimeOut)4 Validation (org.jboss.jca.common.api.metadata.common.Validation)4 CredentialImpl (org.jboss.as.connector.metadata.common.CredentialImpl)3 SecurityImpl (org.jboss.as.connector.metadata.common.SecurityImpl)3 FlushStrategy (org.jboss.jca.common.api.metadata.common.FlushStrategy)3 PoolImpl (org.jboss.jca.common.metadata.common.PoolImpl)3 TimeOutImpl (org.jboss.jca.common.metadata.common.TimeOutImpl)3 ValidationImpl (org.jboss.jca.common.metadata.common.ValidationImpl)3 XaPoolImpl (org.jboss.jca.common.metadata.common.XaPoolImpl)3 Credential (org.jboss.jca.common.api.metadata.common.Credential)2 Extension (org.jboss.jca.common.api.metadata.common.Extension)2 ConnectionDefinition (org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition)2 WorkManagerSecurity (org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity)2 ConnectionDefinitionImpl (org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Credential (org.jboss.as.connector.metadata.api.common.Credential)1