当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationContext.getSubcontext方法代码示例

本文整理汇总了Java中net.shibboleth.idp.authn.context.AuthenticationContext.getSubcontext方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationContext.getSubcontext方法的具体用法?Java AuthenticationContext.getSubcontext怎么用?Java AuthenticationContext.getSubcontext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.shibboleth.idp.authn.context.AuthenticationContext的用法示例。


在下文中一共展示了AuthenticationContext.getSubcontext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: doExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Override
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) {
    this.usernamePasswordContext = authenticationContext.getSubcontext(UsernamePasswordContext.class);
    if (usernamePasswordContext == null) {
        logger.info(getLogPrefix() + "No UsernamePasswordContext available within authentication context");
        handleError(profileRequestContext, authenticationContext, "NoCredentials", AuthnEventIds.NO_CREDENTIALS);
    } else if (usernamePasswordContext.getUsername() == null || usernamePasswordContext.getUsername().equals("")) {
        logger.info(getLogPrefix() + "No username available within UsernamePasswordContext");
        handleError(profileRequestContext, authenticationContext, "NoCredentials", AuthnEventIds.NO_CREDENTIALS);
    } else if (usernamePasswordContext.getPassword() == null || usernamePasswordContext.getPassword().equals("")) {
        logger.info(getLogPrefix() + "No password available witin UsernamePasswordContext");
        handleError(profileRequestContext, authenticationContext, "InvalidCredentials", AuthnEventIds.INVALID_CREDENTIALS);
    } else if (!usernamePasswordContext.getUsername().equals(usernamePasswordContext.getPassword())) {
        logger.info(getLogPrefix() + "Login by " + usernamePasswordContext.getUsername() + " failed");
        handleError(profileRequestContext, authenticationContext, "InvalidCredentials", AuthnEventIds.INVALID_CREDENTIALS);
    } else {
        logger.info(getLogPrefix() + "Login by " + usernamePasswordContext.getUsername() + " succeeded");
        buildAuthenticationResult(profileRequestContext, authenticationContext);
    }
}
 
开发者ID:UniconLabs,项目名称:shibboleth-hazelcast-storage-service,代码行数:21,代码来源:ValidateUsernamePasswordAgainstMagic.java

示例4: doPreExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) {

    AuthenticationContext authCtx = profileRequestContext.getSubcontext(AuthenticationContext.class, false);
    if (authCtx == null) {
        log.error("{} No authentication context", getLogPrefix());
        ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX);
        return false;
    }
    requestedPrincipalContext = authCtx.getSubcontext(RequestedPrincipalContext.class);
    return super.doPreExecute(profileRequestContext);
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:14,代码来源:SetAuthenticationContextClassReferenceToResponseContext.java

示例5: doPreExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final AuthenticationContext authenticationContext) {

    if (!super.doPreExecute(profileRequestContext, authenticationContext)) {
        return false;
    }

    requestedPrincipalCtx = authenticationContext.getSubcontext(RequestedPrincipalContext.class);
    if (requestedPrincipalCtx != null) {
        if (requestedPrincipalCtx.getOperator() == null || requestedPrincipalCtx.getRequestedPrincipals().isEmpty()) {
            requestedPrincipalCtx = null;
        }
    }

    // Detect a previous attempted flow, and move it to the intermediate
    // collection.
    // This will prevent re-selecting the same (probably failed) flow again
    // as part of
    // general flow selection. A flow might signal to explicitly re-run
    // another flow anyway.
    if (authenticationContext.getAttemptedFlow() != null) {
        log.info("{} Moving incomplete flow {} to intermediate set", getLogPrefix(), authenticationContext
                .getAttemptedFlow().getId());
        authenticationContext.getIntermediateFlows().put(authenticationContext.getAttemptedFlow().getId(),
                authenticationContext.getAttemptedFlow());
    }

    return true;
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:33,代码来源:SelectAuthenticationFlow.java

示例6: doExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
        @Nonnull final AuthenticationContext authenticationContext) {

    if (authenticationContext.getSignaledFlowId() != null) {
        doSelectSignaledFlow(profileRequestContext, authenticationContext);
    } else if (requestedPrincipalCtx == null) {
        doSelectNoRequestedPrincipals(profileRequestContext, authenticationContext);
    } else {
        if (!doSelectRequestedPrincipals(profileRequestContext, authenticationContext)) {
            final OIDCRequestedPrincipalContext oidcRPCtx = authenticationContext.getSubcontext(
                    OIDCRequestedPrincipalContext.class, false);
            if (oidcRPCtx != null && !oidcRPCtx.isEssential()) {
                log.debug("{} mismatch for voluntary acr, retry with any", getLogPrefix());
                // We hide requested principal ctx from rest of the actions,
                // namely finalizeauthentication
                oidcRPCtx.addSubcontext(requestedPrincipalCtx);
                authenticationContext.removeSubcontext(requestedPrincipalCtx);
                doSelectNoRequestedPrincipals(profileRequestContext, authenticationContext);
                return;

            }
            ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.REQUEST_UNSUPPORTED);
        }
    }
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:28,代码来源:SelectAuthenticationFlow.java

示例7: 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");
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:16,代码来源:SelectAuthenticationFlowTest.java

示例8: resolveDeclarationRef

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
/**
 * Resolves authentication context declaration ref from ProfileRequestContext.
 *
 * @param profileRequestContext
 * @return authentication context declaration ref
 */
private String resolveDeclarationRef(ProfileRequestContext profileRequestContext) throws ExternalAuthenticationException {
    AuthenticationContext ac = profileRequestContext.getSubcontext(AuthenticationContext.class);
    RequestedPrincipalContext rpc = ac.getSubcontext(RequestedPrincipalContext.class);
    List<Principal> principalList = rpc.getRequestedPrincipals();
    if (principalList.size() != 1 || !(principalList.get(0) instanceof AuthnContextDeclRefPrincipal)) {
        throw new ExternalAuthenticationException("Exactly one authentication context declaration ref must be requested");
    } else {
        AuthnContextDeclRefPrincipal declRefPrincipal = (AuthnContextDeclRefPrincipal)principalList.get(0);
        logger.debug("Requested declaration ref: {}", declRefPrincipal.getAuthnContextDeclRef().getAuthnContextDeclRef());
        return declRefPrincipal.getAuthnContextDeclRef().getAuthnContextDeclRef();
    }
}
 
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:19,代码来源:ShibbolethExtAuthnHandler.java

示例9: extAuthnHandlerBuildsSessionOnGet

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Test
public void extAuthnHandlerBuildsSessionOnGet() throws Exception {
    when(mockAuthenticationHandlerService.buildSession(any()))
            .thenReturn(new TupasIdentification("210281-9988", "TESTAA PORTAALIA", "e1s1"));
    ProfileRequestContext profileRequestContext = new ProfileRequestContext();
    profileRequestContext.addSubcontext(new AuthenticationContext());

    MockHttpServletRequest request = new MockHttpServletRequest();
    Map<String,String> queryParams = getValidTupasResponseParams();
    String queryString = queryParams.entrySet().stream()
            .map(pair -> pair.getKey() + "=" + pair.getValue())
            .collect(Collectors.joining("&", "?", ""));
    request.setQueryString(queryString);
    request.setParameter("token", "NOT_NULL_ILLOGICAL_MOCK");
    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);
    assertNotNull(tupasContext);
    assertEquals("TESTAA PORTAALIA", tupasContext.getCn());
    assertEquals("210281-9988", tupasContext.getHetu());
}
 
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:28,代码来源:ShibbolethExtAuthnHandlerTest.java

示例10: doExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
		@Nonnull final AuthenticationContext authenticationContext) {
	logger.debug("{} Entering TokenValidator", getLogPrefix());		

	TokenContext tokenCtx = authenticationContext.getSubcontext(TokenContext.class, true);

	logger.debug("{} TokenValidator is called with token {} for user {}", getLogPrefix(), tokenCtx.getToken(), username);

	try {
		LinotpConnection connection = new LinotpConnection(host, serviceUsername, servicePassword, checkCert);
		boolean login = connection.validateToken(tokenCtx);
		
		if (login == true) {
			buildAuthenticationResult(profileRequestContext, authenticationContext);
			return;
		}
			
		handleError(profileRequestContext, authenticationContext, "TokenWrong",
					AuthnEventIds.INVALID_CREDENTIALS);

	}		
	catch (Exception e) {
		logger.warn("{} Exception while validating token: {}", getLogPrefix(), e.getMessage());
		handleError(profileRequestContext, authenticationContext, e,
				AuthnEventIds.AUTHN_EXCEPTION);
	}
}
 
开发者ID:cyber-simon,项目名称:idp-auth-linotp,代码行数:29,代码来源:TokenValidator.java

示例11: doExecute

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
@Override
protected void doExecute(@Nonnull final ProfileRequestContext<SAMLObject, SAMLObject> profileRequestContext,
		@Nonnull final AuthenticationContext authenticationContext) {
	
	final HttpServletRequest request = getHttpServletRequest();

	if (request == null) {
		logger.debug("{} Empty HttpServletRequest", getLogPrefix());
		ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_CREDENTIALS);
		return;
	}

	try {

		TokenContext tokenCtx = authenticationContext.getSubcontext(TokenContext.class, true);

		/** get tokencode from request **/
		String value = StringSupport.trimOrNull(request.getParameter(tokenCodeField));

		if (Strings.isNullOrEmpty(value)) {
			logger.debug("{} Empty tokenCode", getLogPrefix());
			ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.INVALID_CREDENTIALS);
			return;
		} else {
			logger.debug("{} TokenCode: {}", getLogPrefix(), value);

			/** set tokencode to TokenCodeContext **/
			tokenCtx.setToken(value);
			logger.debug("Put Token code to the TokenCodeCtx");
			return;
		}

	} catch (Exception e) {
		logger.warn("{} Login by {} produced exception", getLogPrefix(),  e);
	}		
}
 
开发者ID:cyber-simon,项目名称:idp-auth-linotp,代码行数:37,代码来源:ExtractTokenFromForm.java

示例12: getAuthenticationTokenCredentials

import net.shibboleth.idp.authn.context.AuthenticationContext; //导入方法依赖的package包/类
private static Object getAuthenticationTokenCredentials(final ProfileRequestContext profileRequestContext) {
    final AuthenticationContext ctx = profileRequestContext.getSubcontext(AuthenticationContext.class);
    if (ctx != null && ctx.containsSubcontext(UsernamePasswordContext.class)) {
        final UsernamePasswordContext subcontext = ctx.getSubcontext(UsernamePasswordContext.class);
        return subcontext.getUsername();
    }
    final SubjectContext sub = profileRequestContext.getSubcontext(SubjectContext.class);
    if (sub == null) {
        throw new OIDCException("Could not locate SubjectContext in the ProfileRequestContext");
    }
    return sub.getPrincipalName();
}
 
开发者ID:uchicago,项目名称:shibboleth-oidc,代码行数:13,代码来源:SpringSecurityAuthenticationTokenFactory.java


注:本文中的net.shibboleth.idp.authn.context.AuthenticationContext.getSubcontext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。