|
43 | 43 | import javax.xml.stream.XMLStreamReader; |
44 | 44 | import javax.xml.transform.TransformerException; |
45 | 45 |
|
| 46 | +import org.apache.http.HttpEntity; |
| 47 | +import org.apache.http.HttpResponse; |
| 48 | +import org.apache.http.auth.AuthScope; |
| 49 | +import org.apache.http.auth.UsernamePasswordCredentials; |
| 50 | +import org.apache.http.client.methods.HttpPut; |
| 51 | +import org.apache.http.entity.StringEntity; |
| 52 | +import org.apache.http.impl.client.DefaultHttpClient; |
| 53 | +import org.apache.http.util.EntityUtils; |
46 | 54 | import org.custommonkey.xmlunit.exceptions.XpathException; |
47 | 55 | import org.junit.After; |
48 | 56 | import org.junit.AfterClass; |
@@ -155,8 +163,8 @@ public static void setUpBeforeClass() throws Exception { |
155 | 163 | setupAppServicesConstraint(dbName); |
156 | 164 | // Create the External Security setting. |
157 | 165 | createExternalSecurityForKerberos(appServerName, extSecurityName); |
158 | | - // Associate the external security with the App Server. |
159 | | - // Do not attach external security to REST Server - associateRESTServerWithKerberosExtSecurity(appServerName, extSecurityName); |
| 166 | + // Set authentication to kerberos-ticket, internal security to true and external securities to be none on App Server. |
| 167 | + setAuthToKerberosAndInternalSecurityToTrue(appServerName, "none"); |
160 | 168 | createUserRolesWithPrevilages("test-evalKer", "xdbc:eval", "xdbc:eval-in", "xdmp:eval-in", "any-uri", "xdbc:invoke"); |
161 | 169 | //createRESTKerberosUser("builder", "Welcome123", kdcPrincipalUser, "rest-reader", "rest-writer", "rest-admin", "rest-extension-user", "test-evalKer"); |
162 | 170 |
|
@@ -243,6 +251,31 @@ public static void createAutomaticGeoIndex() throws KeyManagementException, NoSu |
243 | 251 | } |
244 | 252 | } |
245 | 253 | } |
| 254 | + |
| 255 | + // Method sets REST server's "authentication" to "Kerberos-ticket" and "internal security" to true |
| 256 | + // external security to be "none" |
| 257 | + public static void setAuthToKerberosAndInternalSecurityToTrue(String restServerName, String extSecurityrName) |
| 258 | + throws Exception { |
| 259 | + DefaultHttpClient client = new DefaultHttpClient(); |
| 260 | + |
| 261 | + client.getCredentialsProvider().setCredentials(new AuthScope(appServerHostName, getAdminPort()), |
| 262 | + new UsernamePasswordCredentials("admin", "admin")); |
| 263 | + String body = "{\"group-name\": \"Default\", \"authentication\":\"kerberos-ticket\",\"internal-security\": \"true\",\"external-security\": \"" |
| 264 | + + extSecurityrName + "\"}"; |
| 265 | + |
| 266 | + HttpPut put = new HttpPut("http://" + appServerHostName + ":" + getAdminPort() + "/manage/v2/servers/" + restServerName |
| 267 | + + "/properties?server-type=http"); |
| 268 | + put.addHeader("Content-type", "application/json"); |
| 269 | + put.setEntity(new StringEntity(body)); |
| 270 | + |
| 271 | + HttpResponse response2 = client.execute(put); |
| 272 | + HttpEntity respEntity = response2.getEntity(); |
| 273 | + if (respEntity != null) { |
| 274 | + String content = EntityUtils.toString(respEntity); |
| 275 | + System.out.println(content); |
| 276 | + } |
| 277 | + client.getConnectionManager().shutdown(); |
| 278 | + } |
246 | 279 |
|
247 | 280 | public GeoSpecialArtifact getGeoArtifact(int counter) { |
248 | 281 |
|
|
0 commit comments