本文整理汇总了Java中net.shibboleth.idp.authn.context.AuthenticationContext.addSubcontext方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationContext.addSubcontext方法的具体用法?Java AuthenticationContext.addSubcontext怎么用?Java AuthenticationContext.addSubcontext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.shibboleth.idp.authn.context.AuthenticationContext
的用法示例。
在下文中一共展示了AuthenticationContext.addSubcontext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRequestNoneActive
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestNoneActive() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(principals);
action.execute(src);
Assert.assertNull(authCtx.getAuthenticationResult());
Assert.assertEquals(authCtx.getAttemptedFlow().getId(), "test3");
}
示例2: testRequestNoneActiveIntermediate
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestNoneActiveIntermediate() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
authCtx.getIntermediateFlows().put("test2", authCtx.getPotentialFlows().get("test2"));
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
authCtx.getPotentialFlows().get("test2").setSupportedPrincipals(principals);
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(principals);
action.execute(src);
Assert.assertNull(authCtx.getAuthenticationResult());
Assert.assertEquals(authCtx.getAttemptedFlow().getId(), "test3");
}
示例3: testRequestPickInactive
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestPickInactive() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
final AuthenticationResult active = new AuthenticationResult("test2", new Subject());
active.getSubject().getPrincipals().add(new TestPrincipal("test2"));
authCtx.setActiveResults(Arrays.asList(active));
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(ImmutableList.of(principals.get(0)));
action.execute(src);
Assert.assertNull(authCtx.getAuthenticationResult());
Assert.assertEquals(authCtx.getAttemptedFlow(), authCtx.getPotentialFlows().get("test3"));
}
示例4: testRequestPickInactiveInitial
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestPickInactiveInitial() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
final AuthenticationResult active = new AuthenticationResult("test2", new Subject());
active.getSubject().getPrincipals().add(new TestPrincipal("test2"));
authCtx.setActiveResults(Arrays.asList(active));
authCtx.setInitialAuthenticationResult(active);
authCtx.setForceAuthn(true);
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(ImmutableList.of(principals.get(0)));
action.execute(src);
Assert.assertNull(authCtx.getAuthenticationResult());
Assert.assertEquals(authCtx.getAttemptedFlow(), authCtx.getPotentialFlows().get("test3"));
}
示例5: testRequestPickActiveInitial
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestPickActiveInitial() throws ComponentInitializationException {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
final AuthenticationResult active = new AuthenticationResult("test2", new Subject());
active.getSubject().getPrincipals().add(new TestPrincipal("test2"));
authCtx.setActiveResults(Arrays.asList(active));
authCtx.setInitialAuthenticationResult(active);
authCtx.setForceAuthn(true);
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(ImmutableList.of(principals.get(0)));
action = new SelectAuthenticationFlow();
action.setFavorSSO(true);
action.initialize();
action.execute(src);
Assert.assertEquals(active, authCtx.getAuthenticationResult());
}
示例6: testRequestPickActive
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestPickActive() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
final AuthenticationResult active = new AuthenticationResult("test3", new Subject());
active.getSubject().getPrincipals().add(new TestPrincipal("test3"));
authCtx.setActiveResults(Arrays.asList(active));
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(ImmutableList.of(principals.get(0)));
final Event event = action.execute(src);
ActionTestingSupport.assertProceedEvent(event);
Assert.assertEquals(active, authCtx.getAuthenticationResult());
}
示例7: testRequestFavorSSO
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestFavorSSO() throws ComponentInitializationException {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final List<Principal> principals = Arrays.<Principal> asList(new TestPrincipal("test3"), new TestPrincipal(
"test2"));
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.getPrincipalEvalPredicateFactoryRegistry().register(TestPrincipal.class, "exact",
new ExactPrincipalEvalPredicateFactory());
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
authCtx.addSubcontext(rpc, true);
final AuthenticationResult active = new AuthenticationResult("test2", new Subject());
active.getSubject().getPrincipals().add(new TestPrincipal("test2"));
authCtx.setActiveResults(Arrays.asList(active));
authCtx.getPotentialFlows().get("test3").setSupportedPrincipals(ImmutableList.of(principals.get(0)));
action = new SelectAuthenticationFlow();
action.setFavorSSO(true);
action.initialize();
final Event event = action.execute(src);
ActionTestingSupport.assertProceedEvent(event);
Assert.assertEquals(active, authCtx.getAuthenticationResult());
}
示例8: testRequestNoMatch
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestNoMatch() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.setOperator("exact");
rpc.setRequestedPrincipals(Arrays.<Principal> asList(new TestPrincipal("foo")));
authCtx.addSubcontext(rpc, true);
final Event event = action.execute(src);
ActionTestingSupport.assertEvent(event, AuthnEventIds.REQUEST_UNSUPPORTED);
}
示例9: testRequestNoMatchNotEssential
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void testRequestNoMatchNotEssential() {
final AuthenticationContext authCtx = prc.getSubcontext(AuthenticationContext.class);
final OIDCRequestedPrincipalContext oidcRPCtx = authCtx
.getSubcontext(OIDCRequestedPrincipalContext.class, true);
oidcRPCtx.setEssential(false);
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.setOperator("exact");
rpc.setRequestedPrincipals(Arrays.<Principal> asList(new TestPrincipal("foo")));
authCtx.addSubcontext(rpc, true);
final Event event = action.execute(src);
Assert.assertNull(authCtx.getAuthenticationResult());
Assert.assertEquals(authCtx.getAttemptedFlow(), authCtx.getPotentialFlows().get(event.getId()));
Assert.assertEquals(authCtx.getAttemptedFlow().getId(), "test1");
}
示例10: verifyTupasIdentification
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
private void verifyTupasIdentification(HttpServletRequest request, HttpServletResponse response) throws ExternalAuthenticationException, IOException {
// Identification. Requests have encoding ISO-8859-1
String queryString = request.getQueryString();
queryString.replaceAll("%20", "+");
List<NameValuePair> queryParams = URLEncodedUtils.parse(queryString, Charset.forName("ISO-8859-1"));
MultivaluedMap<String, String> requestParams = convertToMap(queryParams);
String sessionId = request.getSession().getId();
requestParams.putSingle("sessionId", sessionId);
String token = requestParams.getFirst("token");
if (StringUtils.isBlank(token)) {
throw new ExternalAuthenticationException("Bad request, no token");
}
TupasIdentification identification = authenticationHandlerService.buildSession(requestParams);
if ( identification == null ) {
throw new ExternalAuthenticationException("Authentication verification failed");
}
AuthenticationContext ac = ExternalAuthentication.getProfileRequestContext(identification.getCkey(), request).getSubcontext(AuthenticationContext.class);
if ( ac == null ) {
logger.warn("Authentication context not valid");
request.setAttribute(ExternalAuthentication.AUTHENTICATION_ERROR_KEY, "Bad authentication");
ExternalAuthentication.finishExternalAuthentication(identification.getCkey(), request, response);
return;
}
TupasContext tupasContext = new TupasContext(identification.getName(), identification.getHetu());
ac.addSubcontext(tupasContext);
request.setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, token);
/** External authentication success. Give control back to Shibboleth IdP (4.) */
ExternalAuthentication.finishExternalAuthentication(identification.getCkey(), request, response);
return;
}
示例11: addRequestedPrincipalIntoContext
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
/**
* Add requested principal into context.
*
* @param ac the ac
* @param principals the principals
*/
private void addRequestedPrincipalIntoContext(final AuthenticationContext ac, final List<Principal> principals) {
final RequestedPrincipalContext rpc = new RequestedPrincipalContext();
rpc.setOperator("exact");
rpc.setRequestedPrincipals(principals);
ac.addSubcontext(rpc, true);
}