Skip to content

Commit 855a72a

Browse files
authored
Merge pull request #8453 from DigitalPebble/port/clojure-tests-phase7
Port nimbus_test.clj from Clojure to Java (Phase 7)
2 parents 1a4fe08 + 4f7e540 commit 855a72a

3 files changed

Lines changed: 2395 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with
3+
* this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version
4+
* 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
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
10+
* and limitations under the License.
11+
*/
12+
13+
package org.apache.storm;
14+
15+
import java.util.Map;
16+
import javax.security.auth.Subject;
17+
import org.apache.storm.security.INimbusCredentialPlugin;
18+
import org.apache.storm.security.auth.IAutoCredentials;
19+
import org.apache.storm.security.auth.ICredentialsRenewer;
20+
21+
/**
22+
* Mock implementation of INimbusCredentialPlugin, IAutoCredentials and ICredentialsRenewer for testing only.
23+
* Duplicated from storm-core test sources since storm-server cannot depend on storm-core test classes.
24+
*/
25+
public class MockAutoCred implements INimbusCredentialPlugin, IAutoCredentials, ICredentialsRenewer {
26+
public static final String NIMBUS_CRED_KEY = "nimbusCredTestKey";
27+
public static final String NIMBUS_CRED_VAL = "nimbusTestCred";
28+
public static final String NIMBUS_CRED_RENEW_VAL = "renewedNimbusTestCred";
29+
public static final String GATEWAY_CRED_KEY = "gatewayCredTestKey";
30+
public static final String GATEWAY_CRED_VAL = "gatewayTestCred";
31+
public static final String GATEWAY_CRED_RENEW_VAL = "renewedGatewayTestCred";
32+
33+
@Override
34+
public void populateCredentials(Map<String, String> credentials) {
35+
credentials.put(GATEWAY_CRED_KEY, GATEWAY_CRED_VAL);
36+
}
37+
38+
@Override
39+
public void populateCredentials(Map<String, String> credentials, Map<String, Object> topoConf) {
40+
credentials.put(NIMBUS_CRED_KEY, NIMBUS_CRED_VAL);
41+
}
42+
43+
@Override
44+
public void populateSubject(Subject subject, Map<String, String> credentials) {
45+
subject.getPublicCredentials().add(credentials.get(NIMBUS_CRED_KEY));
46+
subject.getPublicCredentials().add(credentials.get(GATEWAY_CRED_KEY));
47+
}
48+
49+
@Override
50+
public void updateSubject(Subject subject, Map<String, String> credentials) {
51+
populateSubject(subject, credentials);
52+
}
53+
54+
@Override
55+
public void renew(Map<String, String> credentials, Map<String, Object> topologyConf, String ownerPrincipal) {
56+
credentials.put(NIMBUS_CRED_KEY, NIMBUS_CRED_RENEW_VAL);
57+
credentials.put(GATEWAY_CRED_KEY, GATEWAY_CRED_RENEW_VAL);
58+
}
59+
60+
@Override
61+
public void prepare(Map<String, Object> conf) {
62+
63+
}
64+
65+
@Override
66+
public void shutdown() {
67+
68+
}
69+
}

0 commit comments

Comments
 (0)