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


Java AuthenticatedUser类代码示例

本文整理汇总了Java中org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser的典型用法代码示例。如果您正苦于以下问题:Java AuthenticatedUser类的具体用法?Java AuthenticatedUser怎么用?Java AuthenticatedUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticatedUser类属于org.wso2.carbon.identity.application.authentication.framework.model包,在下文中一共展示了AuthenticatedUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addSessionContextToCache

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
/**
 * @param key
 * @param sessionContext
 */
public static void addSessionContextToCache(String key, SessionContext sessionContext) {
    SessionContextCacheKey cacheKey = new SessionContextCacheKey(key);
    SessionContextCacheEntry cacheEntry = new SessionContextCacheEntry();

    Map<String, SequenceConfig> seqData = sessionContext.getAuthenticatedSequences();
    if (seqData != null) {
        for (Entry<String, SequenceConfig> entry : seqData.entrySet()) {
            if (entry.getValue() != null) {
                entry.getValue().getAuthenticatedUser().setUserAttributes(null);
            }
        }
    }
    Object authenticatedUserObj = sessionContext.getProperty(FrameworkConstants.AUTHENTICATED_USER);
    if (authenticatedUserObj != null && authenticatedUserObj instanceof AuthenticatedUser) {
        AuthenticatedUser authenticatedUser = (AuthenticatedUser) authenticatedUserObj;
        cacheEntry.setLoggedInUser(authenticatedUser.getAuthenticatedSubjectIdentifier());
    }
    cacheEntry.setContext(sessionContext);
    SessionContextCache.getInstance().addToCache(cacheKey, cacheEntry);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:FrameworkUtils.java

示例2: publishSessionEvent

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
public static void publishSessionEvent(String sessionId, HttpServletRequest request, AuthenticationContext
        context, SessionContext sessionContext, AuthenticatedUser user, String status) {
    AuthenticationDataPublisher authnDataPublisherProxy = FrameworkServiceDataHolder.getInstance()
            .getAuthnDataPublisherProxy();
    if (authnDataPublisherProxy != null && authnDataPublisherProxy.isEnabled(context)) {
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put(FrameworkConstants.AnalyticsAttributes.USER, user);
        paramMap.put(FrameworkConstants.AnalyticsAttributes.SESSION_ID, sessionId);
        Map<String, Object> unmodifiableParamMap = Collections.unmodifiableMap(paramMap);
        if (FrameworkConstants.AnalyticsAttributes.SESSION_CREATE.equalsIgnoreCase(status)) {
            authnDataPublisherProxy.publishSessionCreation(request, context, sessionContext,
                    unmodifiableParamMap);
        } else if (FrameworkConstants.AnalyticsAttributes.SESSION_UPDATE.equalsIgnoreCase(status)) {
            authnDataPublisherProxy.publishSessionUpdate(request, context, sessionContext,
                    unmodifiableParamMap);
        } else if (FrameworkConstants.AnalyticsAttributes.SESSION_TERMINATE.equalsIgnoreCase(status)) {
            authnDataPublisherProxy.publishSessionTermination(request, context, sessionContext,
                    unmodifiableParamMap);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:FrameworkUtils.java

示例3: testResetAuthenticationContext

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test
public void testResetAuthenticationContext() throws Exception {

    AuthenticationContext context = new AuthenticationContext();
    context.setSubject(new AuthenticatedUser());
    context.setStateInfo(mock(AuthenticatorStateInfo.class));
    context.setExternalIdP(mock(ExternalIdPConfig.class));

    Map<String, String> authenticatorProperties = new HashMap<>();
    authenticatorProperties.put("Prop1", "Value1");

    context.setAuthenticatorProperties(authenticatorProperties);
    context.setRetryCount(3);
    context.setRetrying(true);
    context.setCurrentAuthenticator("OIDCAuthenticator");

    stepBasedSequenceHandler.resetAuthenticationContext(context);

    assertResetContext(context);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultStepBasedSequenceHandlerTest.java

示例4: processFirstStepOnly

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
/**
 * In SMSOTP optional case proceed with first step only.It can be basic or federated.
 *
 * @param authenticatedUser the name of authenticatedUser
 * @param context           the AuthenticationContext
 */
private void processFirstStepOnly(AuthenticatedUser authenticatedUser, AuthenticationContext context) {
    if (log.isDebugEnabled()) {
        log.debug("Processing First step only. Skipping SMSOTP");
    }
    //the authentication flow happens with basic authentication.
    StepConfig stepConfig = context.getSequenceConfig().getStepMap().get(context.getCurrentStep() - 1);
    if (stepConfig.getAuthenticatedAutenticator().getApplicationAuthenticator() instanceof
            LocalApplicationAuthenticator) {
        if (log.isDebugEnabled()) {
            log.debug("Found local authenticator in previous step. Hence setting a local user");
        }
        FederatedAuthenticatorUtil.updateLocalAuthenticatedUserInStepConfig(context, authenticatedUser);
        context.setProperty(SMSOTPConstants.AUTHENTICATION, SMSOTPConstants.BASIC);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Found federated authenticator in previous step. Hence setting a local user");
        }
        FederatedAuthenticatorUtil.updateAuthenticatedUserInStepConfig(context, authenticatedUser);
        context.setProperty(SMSOTPConstants.AUTHENTICATION, SMSOTPConstants.FEDERETOR);
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:28,代码来源:SMSOTPAuthenticator.java

示例5: processAuthenticationResponse

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
/**
 * Process the response of the SMSOTP end-point.
 *
 * @param request  the HttpServletRequest
 * @param response the HttpServletResponse
 * @param context  the AuthenticationContext
 * @throws AuthenticationFailedException
 */
@Override
protected void processAuthenticationResponse(HttpServletRequest request, HttpServletResponse response,
                                             AuthenticationContext context) throws AuthenticationFailedException {
    String userToken = request.getParameter(SMSOTPConstants.CODE);
    String contextToken = (String) context.getProperty(SMSOTPConstants.OTP_TOKEN);
    AuthenticatedUser authenticatedUser = (AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER);
    if (StringUtils.isEmpty(request.getParameter(SMSOTPConstants.CODE))) {
        throw new InvalidCredentialsException("Code cannot not be null");
    }
    if (Boolean.parseBoolean(request.getParameter(SMSOTPConstants.RESEND))) {
        if (log.isDebugEnabled()) {
            log.debug("Retrying to resend the OTP");
        }
        throw new InvalidCredentialsException("Retrying to resend the OTP");
    }
    if (userToken.equals(contextToken)) {
        context.setSubject(authenticatedUser);
    } else if (SMSOTPUtils.getBackupCode(context, getName()).equals("true")) {
        checkWithBackUpCodes(context, userToken, authenticatedUser);
    } else {
        context.setProperty(SMSOTPConstants.CODE_MISMATCH, true);
        throw new AuthenticationFailedException("Code mismatch");
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:33,代码来源:SMSOTPAuthenticator.java

示例6: testProcessWithLogout

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test
public void testProcessWithLogout() throws AuthenticationFailedException, LogoutFailedException {
    mockStatic(FederatedAuthenticatorUtil.class);
    mockStatic(SMSOTPUtils.class);
    mockStatic(FrameworkUtils.class);
    when(context.isLogoutRequest()).thenReturn(false);
    when(httpServletRequest.getParameter(SMSOTPConstants.CODE)).thenReturn("");
    context.setTenantDomain("carbon.super");
    when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
            thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
    FederatedAuthenticatorUtil.setUsernameFromFirstStep(context);
    when(SMSOTPUtils.isSMSOTPMandatory(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
    when(SMSOTPUtils.getErrorPageFromXMLFile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn
            (SMSOTPConstants.ERROR_PAGE);
    when(SMSOTPUtils.isSendOTPDirectlyToMobile(context, SMSOTPConstants.AUTHENTICATOR_NAME))
            .thenReturn(false);
    when(FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(),
            context.getCallerSessionKey(), context.getContextIdentifier())).thenReturn(null);
    when(SMSOTPUtils.getBackupCode(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("false");
    AuthenticatorFlowStatus status = spy.process(httpServletRequest, httpServletResponse, context);
    Assert.assertEquals(status, AuthenticatorFlowStatus.INCOMPLETE);
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:23,代码来源:SMSOTPAuthenticatorTest.java

示例7: testInitiateAuthenticationRequestWithSMSOTPMandatory

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test
public void testInitiateAuthenticationRequestWithSMSOTPMandatory() throws Exception {
    mockStatic(FederatedAuthenticatorUtil.class);
    mockStatic(SMSOTPUtils.class);
    mockStatic(FrameworkUtils.class);
    context.setTenantDomain("carbon.super");
    when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
            thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
    FederatedAuthenticatorUtil.setUsernameFromFirstStep(context);
    when(SMSOTPUtils.isSMSOTPMandatory(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn(true);
    when(SMSOTPUtils.getErrorPageFromXMLFile(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn
            (SMSOTPConstants.ERROR_PAGE);
    when(SMSOTPUtils.isSendOTPDirectlyToMobile(context, SMSOTPConstants.AUTHENTICATOR_NAME))
            .thenReturn(false);
    when(SMSOTPUtils.getErrorPageFromXMLFile(any(AuthenticationContext.class), anyString())).
            thenReturn(SMSOTPConstants.ERROR_PAGE);
    when(FrameworkUtils.getQueryStringWithFrameworkContextId(context.getQueryParams(),
            context.getCallerSessionKey(), context.getContextIdentifier())).thenReturn(null);
    when(SMSOTPUtils.getBackupCode(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("false");
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    Whitebox.invokeMethod(smsotpAuthenticator, "initiateAuthenticationRequest",
            httpServletRequest, httpServletResponse, context);
    verify(httpServletResponse).sendRedirect(captor.capture());
    Assert.assertTrue(captor.getValue().contains(SMSOTPConstants.SEND_OTP_DIRECTLY_DISABLE));
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:26,代码来源:SMSOTPAuthenticatorTest.java

示例8: testProcessAuthenticationResponseWithBackupCode

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test(expectedExceptions = {AuthenticationFailedException.class})
public void testProcessAuthenticationResponseWithBackupCode() throws Exception {
    mockStatic(IdentityTenantUtil.class);
    mockStatic(SMSOTPUtils.class);
    when(httpServletRequest.getParameter(SMSOTPConstants.CODE)).thenReturn("123456");
    context.setProperty(SMSOTPConstants.OTP_TOKEN,"123");
    context.setProperty(SMSOTPConstants.USER_NAME,"admin");
    when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
            thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
    when(SMSOTPUtils.getBackupCode(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("true");

    when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
    when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
    when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    Whitebox.invokeMethod(smsotpAuthenticator, "processAuthenticationResponse",
            httpServletRequest, httpServletResponse, context);
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:19,代码来源:SMSOTPAuthenticatorTest.java

示例9: testCheckWithBackUpCodes

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test
public void testCheckWithBackUpCodes() throws Exception {
    mockStatic(IdentityTenantUtil.class);
    context.setProperty(SMSOTPConstants.USER_NAME,"admin");
    when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
    when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
    when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
            thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
    when(userRealm.getUserStoreManager()
            .getUserClaimValue(MultitenantUtils.getTenantAwareUsername("admin"),
                    SMSOTPConstants.SAVED_OTP_LIST, null)).thenReturn("12345,4568,1234,7896");
    AuthenticatedUser user = (AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER);
    Whitebox.invokeMethod(smsotpAuthenticator, "checkWithBackUpCodes",
            context,"1234",user);
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:18,代码来源:SMSOTPAuthenticatorTest.java

示例10: testCheckWithInvalidBackUpCodes

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Test(expectedExceptions = {AuthenticationFailedException.class})
public void testCheckWithInvalidBackUpCodes() throws Exception {
    mockStatic(IdentityTenantUtil.class);
    context.setProperty(SMSOTPConstants.USER_NAME,"admin");
    when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
    when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
    when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when((AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER)).
            thenReturn(AuthenticatedUser.createLocalAuthenticatedUserFromSubjectIdentifier("admin"));
    when(userRealm.getUserStoreManager()
            .getUserClaimValue(MultitenantUtils.getTenantAwareUsername("admin"),
                    SMSOTPConstants.SAVED_OTP_LIST, null)).thenReturn("12345,4568,1234,7896");
    AuthenticatedUser user = (AuthenticatedUser) context.getProperty(SMSOTPConstants.AUTHENTICATED_USER);
    Whitebox.invokeMethod(smsotpAuthenticator, "checkWithBackUpCodes",
            context,"45698789",user);
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:18,代码来源:SMSOTPAuthenticatorTest.java

示例11: processAuthenticationResponse

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
@Override
protected void processAuthenticationResponse(HttpServletRequest request,
                                             HttpServletResponse response,
                                             AuthenticationContext context)
        throws AuthenticationFailedException {

    String tokenResponse = request.getParameter("tokenResponse");
    if (tokenResponse != null && !tokenResponse.contains("errorCode")) {
        String appID = FIDOUtil.getOrigin(request);
        AuthenticatedUser user = getUsername(context);

        U2FService u2FService = U2FService.getInstance();
        FIDOUser fidoUser = new FIDOUser(user.getUserName(), user.getTenantDomain(),
                                         user.getUserStoreDomain(), AuthenticateResponse.fromJson(tokenResponse));
        fidoUser.setAppID(appID);
        u2FService.finishAuthentication(fidoUser);
        context.setSubject(user);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("FIDO authentication filed : " + tokenResponse);
        }

        throw new InvalidCredentialsException("FIDO device authentication failed ");
    }

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:27,代码来源:FIDOAuthenticator.java

示例12: getUsername

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
private AuthenticatedUser getUsername(AuthenticationContext context) throws AuthenticationFailedException {
    //username from authentication context.
    AuthenticatedUser authenticatedUser = null;
    for (int i = 1; i <= context.getSequenceConfig().getStepMap().size(); i++) {
        StepConfig stepConfig = context.getSequenceConfig().getStepMap().get(i);
        if (stepConfig.getAuthenticatedUser() != null && stepConfig.getAuthenticatedAutenticator()
                .getApplicationAuthenticator() instanceof LocalApplicationAuthenticator) {
            authenticatedUser = stepConfig.getAuthenticatedUser();
            if (authenticatedUser.getUserStoreDomain() == null) {
                authenticatedUser.setUserStoreDomain(UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME);
            }


            if (log.isDebugEnabled()) {
                log.debug("username :" + authenticatedUser.toString());
            }
            break;
        }
    }
    if(authenticatedUser == null){
        throw new AuthenticationFailedException("Could not locate an authenticated username from previous steps " +
                "of the sequence. Hence cannot continue with FIDO authentication.");
    }
    return authenticatedUser;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:26,代码来源:FIDOAuthenticator.java

示例13: putUserRPToStore

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
/**
 * @param user
 * @param appName
 * @throws OAuthSystemException
 */
public void putUserRPToStore(AuthenticatedUser user, String appName, boolean trustedAlways, String clientId) throws
        OAuthSystemException {
    OpenIDUserRPDO repDO = new OpenIDUserRPDO();
    repDO.setDefaultProfileName(DEFAULT_PROFILE_NAME);
    repDO.setRpUrl(appName);
    repDO.setUserName(user.getAuthenticatedSubjectIdentifier());
    repDO.setTrustedAlways(trustedAlways);
    int tenantId = -1;
    if (user.getUserName() != null) {
        tenantId = IdentityTenantUtil.getTenantId(user.getTenantDomain());
    } else {
        OAuthAppDAO oAuthAppDAO = new OAuthAppDAO();
        OAuthAppDO appDO;
        try {
            appDO = oAuthAppDAO.getAppInformation(clientId);
            tenantId = IdentityTenantUtil.getTenantId(appDO.getUser().getTenantDomain());
        } catch (IdentityOAuth2Exception | InvalidOAuthClientException e) {
            throw new OAuthSystemException("Error while retrieving app");
        }
    }

    OpenIDUserRPDAO dao = new OpenIDUserRPDAO();
    dao.createOrUpdate(repDO, tenantId);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:OpenIDConnectUserRPStore.java

示例14: hasUserApproved

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
/**
 * @param user
 * @param appName
 * @return
 * @throws OAuthSystemException
 */
public synchronized boolean hasUserApproved(AuthenticatedUser user, String appName, String clientId) throws
        OAuthSystemException {
    OpenIDUserRPDAO dao = new OpenIDUserRPDAO();
    OpenIDUserRPDO rpDO;
    int tenantId = -1;
    if (user.getUserName() != null) {
        tenantId = IdentityTenantUtil.getTenantId(user.getTenantDomain());
    } else {
        OAuthAppDAO oAuthAppDAO = new OAuthAppDAO();
        OAuthAppDO appDO;
        try {
            appDO = oAuthAppDAO.getAppInformation(clientId);
            tenantId = IdentityTenantUtil.getTenantId(appDO.getUser().getTenantDomain());
        } catch (IdentityOAuth2Exception | InvalidOAuthClientException e) {
            throw new OAuthSystemException("Error while retrieving app");
        }
    }

    rpDO = dao.getOpenIDUserRP(user.getAuthenticatedSubjectIdentifier(), appName, tenantId);
    if (rpDO != null && rpDO.isTrustedAlways()) {
        return true;
    }

    return false;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:OpenIDConnectUserRPStore.java

示例15: publishAuthenticationSuccess

import org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser; //导入依赖的package包/类
private void publishAuthenticationSuccess(HttpServletRequest request, AuthenticationContext context,
                                          AuthenticatedUser user) {

    AuthenticationDataPublisher authnDataPublisherProxy = FrameworkServiceDataHolder.getInstance()
            .getAuthnDataPublisherProxy();
    if (authnDataPublisherProxy != null && authnDataPublisherProxy.isEnabled(context)) {
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put(FrameworkConstants.AnalyticsAttributes.USER, user);
        Map<String, Object> unmodifiableParamMap = Collections.unmodifiableMap(paramMap);
        authnDataPublisherProxy.publishAuthenticationSuccess(request, context,
                unmodifiableParamMap);

    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:15,代码来源:DefaultAuthenticationRequestHandler.java


注:本文中的org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。