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;
}
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 } };
}
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 } };
}
Aggregations