Search in sources :

Example 1 with NTUserPrincipal

use of com.sun.security.auth.NTUserPrincipal 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)

Example 2 with NTUserPrincipal

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

the class MoreThenOnePrincipals method Provider1.

@DataProvider
public Object[][] Provider1() {
    Subject s1 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
    s1.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-2"));
    Subject s2 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
    s2.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
    return new Object[][] { { s1 }, { s2 } };
}
Also used : NTUserPrincipal(com.sun.security.auth.NTUserPrincipal) Subject(javax.security.auth.Subject) DataProvider(org.testng.annotations.DataProvider)

Example 3 with NTUserPrincipal

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

the class MoreThenOnePrincipals method Provider2.

@DataProvider
public Object[][] Provider2() {
    Subject s3 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
    s3.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
    s3.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
    Subject s4 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
    s4.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
    s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
    s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-2"));
    return new Object[][] { { s3 }, { s4 } };
}
Also used : NTUserPrincipal(com.sun.security.auth.NTUserPrincipal) UnixPrincipal(com.sun.security.auth.UnixPrincipal) Subject(javax.security.auth.Subject) DataProvider(org.testng.annotations.DataProvider)

Aggregations

NTUserPrincipal (com.sun.security.auth.NTUserPrincipal)3 Subject (javax.security.auth.Subject)2 DataProvider (org.testng.annotations.DataProvider)2 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 UnixPrincipal (com.sun.security.auth.UnixPrincipal)1