本文整理汇总了Java中net.shibboleth.idp.authn.context.AuthenticationContext类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationContext类的具体用法?Java AuthenticationContext怎么用?Java AuthenticationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationContext类属于net.shibboleth.idp.authn.context包,在下文中一共展示了AuthenticationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extAuthnHandlerSetsErrorAttributeWhenIdentificationFails
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
@Test
public void extAuthnHandlerSetsErrorAttributeWhenIdentificationFails() throws Exception {
when(mockAuthenticationHandlerService.buildSession(any()))
.thenReturn(null);
when(mockAuthenticationHandlerService.purgeSession(any()))
.thenReturn(mock(MultivaluedMap.class));
ProfileRequestContext profileRequestContext = new ProfileRequestContext();
profileRequestContext.addSubcontext(new AuthenticationContext());
MockHttpServletRequest request = getQueryParamRequest(getValidTupasResponseParams());
MockHttpServletResponse response = new MockHttpServletResponse();
when(ExternalAuthentication.getProfileRequestContext("e1s1", request)).thenReturn(profileRequestContext);
extAuthnHandler.doGet(request, response);
AuthenticationContext authenticationContext = profileRequestContext.getSubcontext(AuthenticationContext.class);
assertNotNull(authenticationContext);
TupasContext tupasContext = authenticationContext.getSubcontext(TupasContext.class);
assertNull(tupasContext);
assertNotNull(response.getRedirectedUrl());
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:23,代码来源:ShibbolethExtAuthnHandlerTest.java
示例2: doExecute
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
log.debug("{} Initializing authentication context", getLogPrefix());
final AuthenticationContext authnCtx = new AuthenticationContext();
if (getAuthenticationRequest().getPrompt() != null) {
authnCtx.setIsPassive(getAuthenticationRequest().getPrompt().contains(Prompt.Type.NONE));
authnCtx.setForceAuthn(getAuthenticationRequest().getPrompt().contains(Prompt.Type.LOGIN));
}
if (getAuthenticationRequest().getLoginHint() != null) {
authnCtx.setHintedName(getAuthenticationRequest().getLoginHint());
}
final AuthenticationContext initialAuthnContext =
profileRequestContext.getSubcontext(AuthenticationContext.class);
if (initialAuthnContext != null) {
authnCtx.setInitialAuthenticationResult(initialAuthnContext.getAuthenticationResult());
}
profileRequestContext.addSubcontext(authnCtx, true);
log.debug("{} Created authentication context: {}", getLogPrefix(), authnCtx);
}
示例3: getUnattemptedInactiveFlow
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
/**
* Return the first inactive potential flow not found in the intermediate
* flows collection that applies to the request.
*
* @param profileRequestContext
* the current profile request context
* @param authenticationContext
* the current authentication context
* @return an eligible flow, or null
*/
@Nullable
private AuthenticationFlowDescriptor getUnattemptedInactiveFlow(
@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull final AuthenticationContext authenticationContext) {
for (final AuthenticationFlowDescriptor flow : authenticationContext.getPotentialFlows().values()) {
if (!authenticationContext.getIntermediateFlows().containsKey(flow.getId())) {
if (!authenticationContext.isPassive() || flow.isPassiveAuthenticationSupported()) {
if (flow.apply(profileRequestContext)) {
return flow;
}
}
}
}
return null;
}
示例4: doSelectRequestedPrincipals
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
/**
* Executes the selection process in the presence of specific requested
* Principals, requiring evaluation of potential flows and results for
* Principal-compatibility with request.
*
* @param profileRequestContext
* the current IdP profile request context
* @param authenticationContext
* the current authentication context
*/
private boolean doSelectRequestedPrincipals(@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull final AuthenticationContext authenticationContext) {
log.debug("{} Specific principals requested with '{}' operator: {}", getLogPrefix(),
requestedPrincipalCtx.getOperator(), requestedPrincipalCtx.getRequestedPrincipals());
if (authenticationContext.getInitialAuthenticationResult() != null
&& authenticationContext.getPotentialFlows().containsKey(
authenticationContext.getInitialAuthenticationResult().getAuthenticationFlowId())) {
// Invoke possible SSO but with the initial result as the only
// possible reuse option.
return selectRequestedFlow(profileRequestContext, authenticationContext, Collections.singletonMap(
authenticationContext.getInitialAuthenticationResult().getAuthenticationFlowId(),
authenticationContext.getInitialAuthenticationResult()));
} else if (authenticationContext.isForceAuthn()) {
log.debug("{} Forced authentication requested, selecting an inactive flow", getLogPrefix());
return selectRequestedInactiveFlow(profileRequestContext, authenticationContext);
} else if (authenticationContext.getActiveResults().isEmpty()) {
log.debug("{} No active results available, selecting an inactive flow", getLogPrefix());
return selectRequestedInactiveFlow(profileRequestContext, authenticationContext);
} else {
return selectRequestedFlow(profileRequestContext, authenticationContext,
authenticationContext.getActiveResults());
}
}
示例5: testOIDCAuthnRequestNoFlags
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
/**
* Test that the action functions properly if the inbound message is a oidc
* authentication request.
*/
@Test
public void testOIDCAuthnRequestNoFlags() throws Exception {
AuthenticationRequest req = AuthenticationRequest
.parse("response_type=code&client_id=s6BhdRkqt3&login_hint=foo&redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb&scope=openid%20profile&state=af0ifjsldkj&nonce=n-0S6_WzA2Mj");
final RequestContext requestCtx = new RequestContextBuilder().setInboundMessage(req).buildRequestContext();
@SuppressWarnings("rawtypes")
final ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
final InitializeAuthenticationContext action = new InitializeAuthenticationContext();
action.initialize();
final Event event = action.execute(requestCtx);
ActionTestingSupport.assertProceedEvent(event);
AuthenticationContext authnCtx = prc.getSubcontext(AuthenticationContext.class);
Assert.assertFalse(authnCtx.isForceAuthn());
Assert.assertFalse(authnCtx.isPassive());
Assert.assertEquals(authnCtx.getHintedName(), "foo");
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:InitializeAuthenticationContextTest.java
示例6: init
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private void init(String request) throws ParseException, ComponentInitializationException {
AuthenticationRequest req = AuthenticationRequest.parse(request);
requestCtx = new RequestContextBuilder().setInboundMessage(req).buildRequestContext();
ProfileRequestContext prc = new WebflowRequestContextProfileRequestContextLookup().apply(requestCtx);
authnCtx = prc.getSubcontext(AuthenticationContext.class, true);
List<AuthenticationResult> results = new ArrayList<AuthenticationResult>();
Subject subject1 = new Subject();
AuthenticationResult result1 = new AuthenticationResult("id1", subject1);
// 10 seconds ago
result1.setAuthenticationInstant(new Date().getTime() - 10000);
Subject subject2 = new Subject();
AuthenticationResult result2 = new AuthenticationResult("id2", subject2);
// 5 seconds ago
result2.setAuthenticationInstant(new Date().getTime() - 5000);
results.add(result1);
results.add(result2);
authnCtx.setActiveResults(results);
action = new FilterActiveAuthenticationResultsByMaxAge();
action.initialize();
}
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:22,代码来源:FilterActiveAuthenticationResultsByMaxAgeTest.java
示例7: 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");
}
示例8: 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");
}
示例9: 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"));
}
示例10: 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"));
}
示例11: 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());
}
示例12: 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());
}
示例13: 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());
}
示例14: apply
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
@Nullable
public Long apply(@Nullable final ProfileRequestContext input) {
if (input == null) {
return null;
}
AuthenticationContext authCtx = input.getSubcontext(AuthenticationContext.class, false);
if (authCtx == null) {
return null;
}
AuthenticationResult authResult = authCtx.getAuthenticationResult();
if (authResult == null) {
return null;
}
return authResult.getAuthenticationInstant();
}
示例15: ShibbolethExtAuthnHandlerBuildsSessionOnPost
import net.shibboleth.idp.authn.context.AuthenticationContext; //导入依赖的package包/类
@Test
public void ShibbolethExtAuthnHandlerBuildsSessionOnPost() throws Exception {
when(mockAuthenticationHandlerService.buildSession(any()))
.thenReturn(new TupasIdentification("210281-9988", "TESTAA PORTAALIA", "e1s1"));
ProfileRequestContext profileRequestContext = new ProfileRequestContext();
profileRequestContext.addSubcontext(new AuthenticationContext());
MockHttpServletRequest request = getQueryParamRequest(getValidTupasResponseParams());
request.setParameter("token", "NOT_NULL_ILLOGICAL_MOCK");
MockHttpServletResponse response = new MockHttpServletResponse();
when(ExternalAuthentication.getProfileRequestContext("e1s1", request)).thenReturn(profileRequestContext);
extAuthnHandler.doPost(request, response);
AuthenticationContext authenticationContext = profileRequestContext.getSubcontext(AuthenticationContext.class);
assertNotNull(authenticationContext);
TupasContext tupasContext = authenticationContext.getSubcontext(TupasContext.class);
assertNotNull(tupasContext);
assertEquals("TESTAA PORTAALIA", tupasContext.getCn());
assertEquals("210281-9988", tupasContext.getHetu());
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:23,代码来源:ShibbolethExtAuthnHandlerTest.java