Created
April 9, 2014 05:46
-
-
Save DemkaAge/10229499 to your computer and use it in GitHub Desktop.
Просто тест (кривонький) с JAAS аутентификацией для сферы.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testBaseCalls() throws Exception { | |
LoginContext lc = null; | |
try { | |
lc = new LoginContext("WSLogin", new WSCallbackHandlerImpl("gcd_admin", "o9p0[-]=")); | |
} catch (LoginException le) { | |
Assert.fail("Cannot create LoginContext. " + le.getMessage()); | |
} catch (SecurityException se) { | |
Assert.fail("Cannot create LoginContext." + se.getMessage()); | |
} | |
try { | |
lc.login(); | |
Subject subject = lc.getSubject(); | |
WSSubject.setRunAsSubject(subject); | |
InitialContext context = new InitialContext(); | |
complexServiceLocal = (ComplexServiceLocal) context.lookup("ejblocal:test_complexService/test.jar/ComplexServiceImpl#ru.brbpm.lecm.server.samples.ComplexServiceLocal"); | |
String actual = complexServiceLocal.helloService(); | |
Assert.assertEquals("ComplexServiceImpl", actual); | |
Assert.assertEquals("InnerServiceImpl", complexServiceLocal.helloInnerService()); | |
String userPrincipal = complexServiceLocal.getUserPrincipal(); | |
Assert.assertNotSame("null", userPrincipal); | |
String innerServiceUserPrincipal = complexServiceLocal.getInnerServiceUserPrincipal(); | |
Assert.assertNotSame("null", innerServiceUserPrincipal); | |
String ceUserPrincipal = complexServiceLocal.getInnerServiceCeUserPrincipal(); | |
Assert.assertNotSame("null", ceUserPrincipal); | |
complexServiceLocal.runInnerServiceStuffMethod(); | |
} catch (LoginException le) { | |
Assert.fail("Fails to create Subject. " + le.getMessage()); | |
} finally { | |
lc.logout(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment