/**
         * Authenticate given username and password through JAAS (instead of Java EE
         * Security).
         * 
         * @param user,
         *            or null
         * @param password
         *            cleartext password. After authentication will be cleared.
         * @param realm
         *            JAAS realm name
         * @return
         */
public LoginContext authenticate(String user, char[] password, String realm) {
		// consider modules: Krb5LoginModule, LdapLoginModule, NTLoginModule,
		// JndiLoginModule
		// ...sun...
		PassiveCallbackHandler cbh = new PassiveCallbackHandler(user, password);
		LoginContext lc;
		try {
			lc = new LoginContext(realm, cbh); // referenced in jaas.conf
		} catch (LoginException e) {
			LOG.error("Exception during new LoginContext()", e);
			return null;
		}
		try {
			// call callback to retrieve credentials, and checks that
			// Authentication fails
			lc.login();
		} catch (LoginException e) {
			// FIXME. LoginException may happen either because authentication
			// failed, or for many other reasons.
			// We should ignore the first, and LOG the latter.
			LOG.error("Exception while loggin-in", e);
			return null;
		} finally {
			Arrays.fill(password, '\u0000');
		}
		return lc;
	}
public LoginContext authenticate(String user, char[] password, String realm) {
// consider modules: Krb5LoginModule, LdapLoginModule, NTLoginModule,
// JndiLoginModule
// ...sun...
PassiveCallbackHandler cbh = new PassiveCallbackHandler(user, password);
LoginContext lc;
try {
lc = new LoginContext(realm, cbh); // referenced in jaas.conf
} catch (LoginException e) {
LOG.error("Exception during new LoginContext()", e);
return null;
}
try {
// call callback to retrieve credentials, and checks that
// Authentication fails
lc.login();
} catch (LoginException e) {
// FIXME. LoginException may happen either because authentication
// failed, or for many other reasons.
// We should ignore the first, and LOG the latter.
LOG.error("Exception while loggin-in", e);
return null;
} finally {
Arrays.fill(password, '\u0000');
}
return lc;
}
public LoginContext authenticate(String user, char[] password, String realm) {
// consider modules: Krb5LoginModule, LdapLoginModule, NTLoginModule,
// JndiLoginModule
// ...sun...
PassiveCallbackHandler cbh = new PassiveCallbackHandler(user, password);
LoginContext lc;
try {
lc = new LoginContext(realm, cbh); // referenced in jaas.conf
} catch (LoginException e) {
LOG.error("Exception during new LoginContext()", e);
return null;
}
try {
// call callback to retrieve credentials, and checks that
// Authentication fails
lc.login();
} catch (LoginException e) {
// FIXME. LoginException may happen either because authentication
// failed, or for many other reasons.
// We should ignore the first, and LOG the latter.
LOG.error("Exception while loggin-in", e);
return null;
} finally {
Arrays.fill(password, '\u0000');
}
return lc;
}
public LoginContext authenticate(String user, char[] password, String realm) {
// consider modules: Krb5LoginModule, LdapLoginModule, NTLoginModule,
// JndiLoginModule
// ...sun...
PassiveCallbackHandler cbh = new PassiveCallbackHandler(user, password);
LoginContext lc;
try {
lc = new LoginContext(realm, cbh); // referenced in jaas.conf
} catch (LoginException e) {
LOG.error("Exception during new LoginContext()", e);
return null;
}
try {
// call callback to retrieve credentials, and checks that
// Authentication fails
lc.login();
} catch (LoginException e) {
// FIXME. LoginException may happen either because authentication
// failed, or for many other reasons.
// We should ignore the first, and LOG the latter.
LOG.error("Exception while loggin-in", e);
return null;
} finally {
Arrays.fill(password, '\u0000');
}
return lc;
}