Search in sources :

Example 1 with NTSidGroupPrincipal

use of com.sun.security.auth.NTSidGroupPrincipal in project jdk8u_jdk by JetBrains.

the class NTLoginModule method login.

/**
     * Import underlying NT system identity information.
     *
     * <p>
     *
     * @return true in all cases since this <code>LoginModule</code>
     *          should not be ignored.
     *
     * @exception FailedLoginException if the authentication fails. <p>
     *
     * @exception LoginException if this <code>LoginModule</code>
     *          is unable to perform the authentication.
     */
public boolean login() throws LoginException {
    // Indicate not yet successful
    succeeded = false;
    ntSystem = new NTSystem(debugNative);
    if (ntSystem == null) {
        if (debug) {
            System.out.println("\t\t[NTLoginModule] " + "Failed in NT login");
        }
        throw new FailedLoginException("Failed in attempt to import the " + "underlying NT system identity information");
    }
    if (ntSystem.getName() == null) {
        throw new FailedLoginException("Failed in attempt to import the " + "underlying NT system identity information");
    }
    userPrincipal = new NTUserPrincipal(ntSystem.getName());
    if (debug) {
        System.out.println("\t\t[NTLoginModule] " + "succeeded importing info: ");
        System.out.println("\t\t\tuser name = " + userPrincipal.getName());
    }
    if (ntSystem.getUserSID() != null) {
        userSID = new NTSidUserPrincipal(ntSystem.getUserSID());
        if (debug) {
            System.out.println("\t\t\tuser SID = " + userSID.getName());
        }
    }
    if (ntSystem.getDomain() != null) {
        userDomain = new NTDomainPrincipal(ntSystem.getDomain());
        if (debug) {
            System.out.println("\t\t\tuser domain = " + userDomain.getName());
        }
    }
    if (ntSystem.getDomainSID() != null) {
        domainSID = new NTSidDomainPrincipal(ntSystem.getDomainSID());
        if (debug) {
            System.out.println("\t\t\tuser domain SID = " + domainSID.getName());
        }
    }
    if (ntSystem.getPrimaryGroupID() != null) {
        primaryGroup = new NTSidPrimaryGroupPrincipal(ntSystem.getPrimaryGroupID());
        if (debug) {
            System.out.println("\t\t\tuser primary group = " + primaryGroup.getName());
        }
    }
    if (ntSystem.getGroupIDs() != null && ntSystem.getGroupIDs().length > 0) {
        String[] groupSIDs = ntSystem.getGroupIDs();
        groups = new NTSidGroupPrincipal[groupSIDs.length];
        for (int i = 0; i < groupSIDs.length; i++) {
            groups[i] = new NTSidGroupPrincipal(groupSIDs[i]);
            if (debug) {
                System.out.println("\t\t\tuser group = " + groups[i].getName());
            }
        }
    }
    if (ntSystem.getImpersonationToken() != 0) {
        iToken = new NTNumericCredential(ntSystem.getImpersonationToken());
        if (debug) {
            System.out.println("\t\t\timpersonation token = " + ntSystem.getImpersonationToken());
        }
    }
    succeeded = true;
    return succeeded;
}
Also used : NTSidDomainPrincipal(com.sun.security.auth.NTSidDomainPrincipal) NTSidUserPrincipal(com.sun.security.auth.NTSidUserPrincipal) NTUserPrincipal(com.sun.security.auth.NTUserPrincipal) NTDomainPrincipal(com.sun.security.auth.NTDomainPrincipal) NTNumericCredential(com.sun.security.auth.NTNumericCredential) NTSidGroupPrincipal(com.sun.security.auth.NTSidGroupPrincipal) NTSidPrimaryGroupPrincipal(com.sun.security.auth.NTSidPrimaryGroupPrincipal)

Aggregations

NTDomainPrincipal (com.sun.security.auth.NTDomainPrincipal)1 NTNumericCredential (com.sun.security.auth.NTNumericCredential)1 NTSidDomainPrincipal (com.sun.security.auth.NTSidDomainPrincipal)1 NTSidGroupPrincipal (com.sun.security.auth.NTSidGroupPrincipal)1 NTSidPrimaryGroupPrincipal (com.sun.security.auth.NTSidPrimaryGroupPrincipal)1 NTSidUserPrincipal (com.sun.security.auth.NTSidUserPrincipal)1 NTUserPrincipal (com.sun.security.auth.NTUserPrincipal)1