/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4378100
* @summary LoginContext doesn't reinit modules with new Subject
* if authentication fails
*
* @build ModuleSubject ModuleSubjectModule
* @run main/othervm -Djava.security.auth.login.config=file:${test.src}/ModuleSubject.config ModuleSubject
*/
public class ModuleSubject {
try {
} catch (LoginException le) {
("ModuleSubject test failed - login construction failed");
}
// first attempt must fail
try {
throw new SecurityException
("ModuleSubject test failed: 1st login attempt did not fail!");
} catch (LoginException le) {
// good!
("Good: first attempt failed");
}
throw new SecurityException
("ModuleSubject test failed - " +
"Subject after failed attempt not null: " +
}
// second attempt succeeds, and the correct subject comes back
try {
throw new SecurityException("ModuleSubject test failed: " +
"corrupted subject");
}
while (i.hasNext()) {
p.toString());
}
} catch (LoginException le) {
("ModuleSubject test failed - 2nd login attempt failed");
}
}
}