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.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2019-2021] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://github.com/payara/Payara/blob/master/LICENSE.txt
* See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* The Payara Foundation designates this particular file as subject to the "Classpath"
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package fish.payara.ejb.http.client;
import fish.payara.ejb.http.client.adapter.ClientAdapter;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Configuration;
import java.net.URI;
import java.net.URL;
import java.security.KeyStore;
import java.util.Hashtable;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Logger;
import static fish.payara.ejb.http.client.RemoteEJBContextFactory.*;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import java.util.logging.Level;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.client.ClientResponseFilter;
import jakarta.ws.rs.core.Form;
import static jakarta.ws.rs.core.SecurityContext.BASIC_AUTH;
import static jakarta.ws.rs.core.SecurityContext.DIGEST_AUTH;
import static jakarta.ws.rs.core.SecurityContext.FORM_AUTH;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
/**
* This is the context used for looking up and invoking remote EJBs via
* REST in Payara 5.191+.
*
*
* Note that at the moment only the lookup methods are implemented.
*
*
* This context supports the following Payara specific properties in its environment:
*
*
*
fish.payara.connectTimeout
*
fish.payara.executorService
*
fish.payara.hostnameVerifier
*
fish.payara.keyStore
*
fish.payara.readTimeout
*
fish.payara.hostnameVerifier
*
fish.payara.scheduledExecutorService"
*
fish.payara.sslContext
*
fish.payara.trustStore
*
fish.payara.withConfig
*
*
* All properties corresponds to the similarly named settings on the JAX-RS {@link ClientBuilder}.
* Times are in microseconds, and values can either be given as Strings, number values or object instances.
*
* @author Arjan Tijms
* @since Payara 5.191
*
*/
class RemoteEJBContext implements Context {
private static final Logger logger = Logger.getLogger(LookupV0.class.getName());
private ClientAdapter clientAdapter;
private Hashtable environment;
private Lookup lookup;
public RemoteEJBContext(Hashtable environment) {
this.environment = environment;
if (environment.containsKey(RemoteEJBContextFactory.CLIENT_ADAPTER)) {
Object adapter = environment.get(RemoteEJBContextFactory.CLIENT_ADAPTER);
if (adapter instanceof ClientAdapter) {
this.clientAdapter = (ClientAdapter)adapter;
}
}
}
@Override
public Object lookup(Name name) throws NamingException {
return lookup(name.toString());
}
@Override
public Object lookup(String name) throws NamingException {
if (name == null) {
throw new NullPointerException("Lookup name cannot be null");
}
String url = (String) environment.get(PROVIDER_URL);
try {
if (clientAdapter != null) {
Optional