01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.client;
22
23 import org.apache.qpid.test.utils.QpidTestCase;
24 import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
25 import org.apache.qpid.server.registry.ApplicationRegistry;
26 import org.apache.qpid.client.transport.TransportConnection;
27
28 import java.io.File;
29 import java.security.Provider;
30 import java.security.Security;
31 import java.util.List;
32 import java.util.LinkedList;
33
34 /**
35 * QPID-1394 : Test to ensure that the client can register their custom JCAProviders after the broker to ensure that
36 * the Qpid custom authentication SASL plugins are used.
37 */
38 public class MultipleJCAProviderRegistrationTest extends QpidTestCase
39 {
40
41 public void setUp() throws Exception
42 {
43 super.setUp();
44
45 stopBroker();
46
47 _broker = VM;
48
49 final String QpidHome = System.getProperty("QPID_HOME");
50
51 assertNotNull("QPID_HOME not set",QpidHome);
52
53 final File defaultaclConfigFile = new File(QpidHome, "etc/config.xml");
54
55 if (!defaultaclConfigFile.exists())
56 {
57 System.err.println("Configuration file not found:" + defaultaclConfigFile);
58 fail("Configuration file not found:" + defaultaclConfigFile);
59 }
60
61 ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(defaultaclConfigFile);
62 startBroker();
63 }
64
65 public void test() throws Exception
66 {
67 // Get the providers before connection
68 Provider[] providers = Security.getProviders();
69
70 // Force the client to load the providers
71 getConnection();
72
73 Provider[] afterConnectionCreation = Security.getProviders();
74
75 // Find the additions
76 List additions = new LinkedList();
77 for (Provider afterCreation : afterConnectionCreation)
78 {
79 boolean found = false;
80 for (Provider provider : providers)
81 {
82 if (provider == afterCreation)
83 {
84 found=true;
85 break;
86 }
87 }
88
89 // Record added registies
90 if (!found)
91 {
92 additions.add(afterCreation);
93 }
94 }
95
96 assertTrue("Client did not register any providers", additions.size() > 0);
97 }
98
99 }
|