}
Exception detailedException = null;
if (usePrincipalInSubject) {
if (serverSubject == null) {
detailedException = new UnsupportedConstraintException(
"Forgot JAAS login? Using default " +
"serverSubject but no subject is associated " +
"with the current access control context.");
} else {
try {
serverPrincipal = findServerPrincipal(serverSubject);
} catch (Exception e) {
detailedException = e;
}
}
} else if (useCurrentSubject) {
try {
/* caller provided principal, but want to use the
current subject, should only proceed if caller has
the listen AuthenticationPermission */
KerberosUtil.checkAuthPermission(
serverPrincipal, null, "listen");
if (serverSubject == null) {
detailedException = new UnsupportedConstraintException(
"Forgot JAAS login? Using default " +
"serverSubject but no subject is associated " +
"with the current access control context.");
}
} catch (SecurityException e) {
serverSubject = null;
// will throw a SecurityException in enumerateListenEndpoints
}
}
if (detailedException != null) {
if (logger.isLoggable(Levels.FAILED)) {
KerberosUtil.logThrow(
logger, Levels.FAILED, this.getClass(),
"constructor", "construction failed", null,
detailedException);
}
KerberosUtil.secureThrow(
detailedException, new UnsupportedConstraintException(
"Either the caller has not been granted the right " +
"AuthenticationPermission, or there is no default " +
"server subject (<code>Subject.getSubject(" +
"AccessController.getContext())</code> returns " +
"<code>null</code>), or no appropriate Kerberos " +