Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including
all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and
JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.remoting3;
import static java.security.AccessController.doPrivileged;
import static org.jboss.remoting3._private.Messages.log;
import java.io.IOException;
import java.security.Principal;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.UnaryOperator;
import javax.net.ssl.SSLSession;
import javax.security.sasl.SaslClient;
import javax.security.sasl.SaslClientFactory;
import javax.security.sasl.SaslException;
import org.jboss.remoting3._private.IntIndexHashMap;
import org.jboss.remoting3.spi.ConnectionHandler;
import org.wildfly.common.Assert;
import org.wildfly.security.auth.AuthenticationException;
import org.wildfly.security.auth.client.AuthenticationConfiguration;
import org.wildfly.security.auth.client.AuthenticationContextConfigurationClient;
import org.wildfly.security.auth.client.PeerIdentityContext;
import org.wildfly.security.auth.principal.AnonymousPrincipal;
import org.wildfly.security.sasl.WildFlySasl;
import org.wildfly.security.sasl.util.ProtocolSaslClientFactory;
import org.wildfly.security.sasl.util.ServerNameSaslClientFactory;
import org.xnio.Cancellable;
import org.xnio.FinishedIoFuture;
import org.xnio.FutureResult;
import org.xnio.IoFuture;
/**
* A peer identity context for a connection which supports remote authentication-based identity multiplexing.
*
* @author David M. Lloyd
*/
public final class ConnectionPeerIdentityContext extends PeerIdentityContext {
private static final byte[] NO_BYTES = new byte[0];
private final ConnectionImpl connection;
private final Collection offeredMechanisms;
private final ConnectionPeerIdentity anonymousIdentity;
private final ConnectionPeerIdentity connectionIdentity;
private final FinishedIoFuture connectionIdentityFuture;
private final FinishedIoFuture anonymousIdentityFuture;
private final IntIndexHashMap authMap = new IntIndexHashMap(Authentication::getId);
private final ConcurrentHashMap> futureAuths = new ConcurrentHashMap<>();
private final UnaryOperator factoryOperator;
private static final AuthenticationContextConfigurationClient CLIENT = doPrivileged((PrivilegedAction) AuthenticationContextConfigurationClient::new);
ConnectionPeerIdentityContext(final ConnectionImpl connection, final Collection offeredMechanisms, final String peerSaslServer, final String saslProtocol) {
this.connection = connection;
this.offeredMechanisms = offeredMechanisms == null ? Collections.emptySet() : offeredMechanisms;
connectionIdentity = constructIdentity(conf -> new ConnectionPeerIdentity(conf, connection.getPrincipal(), 0, connection));
connectionIdentityFuture = new FinishedIoFuture<>(connectionIdentity);
anonymousIdentity = constructIdentity(conf -> new ConnectionPeerIdentity(conf, AnonymousPrincipal.getInstance(), 1, connection));
anonymousIdentityFuture = new FinishedIoFuture<>(anonymousIdentity);
this.factoryOperator = d -> new ServerNameSaslClientFactory(new ProtocolSaslClientFactory(d, saslProtocol), peerSaslServer);
}
private static final Object PENDING = new Object();
private static final Object CANCELLED = new Object();
public IoFuture authenticateAsync(final AuthenticationConfiguration configuration) {
Assert.checkNotNullParam("configuration", configuration);
if (configuration.equals(connection.getAuthenticationConfiguration())) {
return connectionIdentityFuture;
} else if (CLIENT.getAuthorizationPrincipal(configuration) instanceof AnonymousPrincipal) {
return anonymousIdentityFuture;
}
IoFuture ioFuture = futureAuths.get(configuration);
if (ioFuture != null) {
return ioFuture;
}
final FutureResult futureResult = new FutureResult<>(connection.getEndpoint().getExecutor());
ioFuture = futureAuths.putIfAbsent(configuration, futureResult.getIoFuture());
if (ioFuture != null) {
return ioFuture;
}
final AtomicReference