@@ -0,0 +1,2028 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.hadoop.security;%0A%0Aimport javax.security.auth.Subject;%0Aimport javax.security.auth.kerberos.KerberosPrincipal;%0A%0Aimport java.util.Set;%0A%0Aimport static java.util.Objects.requireNonNull;%0Aimport static org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;%0A%0Apublic final class UserGroupInformationShim%0A%7B%0A    private UserGroupInformationShim() %7B%7D%0A%0A    public static Subject getSubject(UserGroupInformation userGroupInformation)%0A    %7B%0A        return userGroupInformation.getSubject();%0A    %7D%0A%0A    public static UserGroupInformation createUserGroupInformationForSubject(Subject subject)%0A    %7B%0A        requireNonNull(subject, %22subject is null%22);%0A        Set%3CKerberosPrincipal%3E kerberosPrincipals = subject.getPrincipals(KerberosPrincipal.class);%0A        if (kerberosPrincipals.isEmpty()) %7B%0A            throw new IllegalArgumentException(%22subject must contain a KerberosPrincipal%22);%0A        %7D%0A        if (kerberosPrincipals.size() != 1) %7B%0A            throw new IllegalArgumentException(%22subject must contain only a single KerberosPrincipal%22);%0A        %7D%0A%0A        KerberosPrincipal principal = kerberosPrincipals.iterator().next();%0A        User user = new User(principal.getName(), KERBEROS, null);%0A        subject.getPrincipals().add(user);%0A        UserGroupInformation userGroupInformation = new UserGroupInformation(subject);%0A        userGroupInformation.setAuthenticationMethod(KERBEROS);%0A        return userGroupInformation;%0A    %7D%0A%7D%0A

Add UserGroupInformationShim