220 credentials.add(cred);
221 } else {
222 // Ignore non-KerberosTicket and non-KerberosKey elements
223 debug("Skipped cred element: " + cred);
224 }
225 }
226 }
227
228 /**
229 * Authenticate using the login module from the specified
230 * configuration entry.
231 *
232 * @param caller the caller of JAAS Login
233 * @param mech the mech to be used
234 * @return the authenticated subject
235 */
236 public static Subject login(GSSCaller caller, Oid mech) throws LoginException {
237
238 CallbackHandler cb = null;
239 if (caller instanceof HttpCaller) {
240 cb = new sun.net.www.protocol.http.NegotiateCallbackHandler(
241 ((HttpCaller)caller).info());
242 } else {
243 String defaultHandler =
244 java.security.Security.getProperty(DEFAULT_HANDLER);
245 // get the default callback handler
246 if ((defaultHandler != null) && (defaultHandler.length() != 0)) {
247 cb = null;
248 } else {
249 cb = new TextCallbackHandler();
250 }
251 }
252
253 // New instance of LoginConfigImpl must be created for each login,
254 // since the entry name is not passed as the first argument, but
255 // generated with caller and mech inside LoginConfigImpl
256 LoginContext lc = new LoginContext("", null, cb,
257 new LoginConfigImpl(caller, mech));
258 lc.login();
259 return lc.getSubject();
260 }
|
220 credentials.add(cred);
221 } else {
222 // Ignore non-KerberosTicket and non-KerberosKey elements
223 debug("Skipped cred element: " + cred);
224 }
225 }
226 }
227
228 /**
229 * Authenticate using the login module from the specified
230 * configuration entry.
231 *
232 * @param caller the caller of JAAS Login
233 * @param mech the mech to be used
234 * @return the authenticated subject
235 */
236 public static Subject login(GSSCaller caller, Oid mech) throws LoginException {
237
238 CallbackHandler cb = null;
239 if (caller instanceof HttpCaller) {
240 cb = new sun.net.www.protocol.http.spnego.NegotiateCallbackHandler(
241 ((HttpCaller)caller).info());
242 } else {
243 String defaultHandler =
244 java.security.Security.getProperty(DEFAULT_HANDLER);
245 // get the default callback handler
246 if ((defaultHandler != null) && (defaultHandler.length() != 0)) {
247 cb = null;
248 } else {
249 cb = new TextCallbackHandler();
250 }
251 }
252
253 // New instance of LoginConfigImpl must be created for each login,
254 // since the entry name is not passed as the first argument, but
255 // generated with caller and mech inside LoginConfigImpl
256 LoginContext lc = new LoginContext("", null, cb,
257 new LoginConfigImpl(caller, mech));
258 lc.login();
259 return lc.getSubject();
260 }
|