• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ProfileManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ProfileManager类属于org.pac4j.core.profile包,在下文中一共展示了ProfileManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAuthenticatedUsername

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Return the username of the authenticated user (based on pac4j security).
 *
 * @return the authenticated username.
 */
public static String getAuthenticatedUsername() {
    final HttpServletRequest request = getHttpServletRequest();
    final HttpServletResponse response = getHttpServletResponse();
    if (request != null && response != null) {
        final J2EContext context = new J2EContext(request, response);
        final ProfileManager manager = new ProfileManager(context);
        final UserProfile profile = manager.get(true);
        if (profile != null) {
            final String id = profile.getId();
            if (id != null) {
                return id;
            }
        }
    }
    return UNKNOWN_USER;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:WebUtils.java


示例2: login

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * app rest 登录获取token
 * eg:http://localhost:8081/user/login?cilent_name=rest&username=hsjhsj&password=hsjhsj
 * 然后获取资源:http://localhost:8081/user/1?token=eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..7usGh1GK3jl5_wPH.QJdYqNp81zRyAs6OHmN4573l67z_UgxQ7WXJ7OUsDw50Dato2X9Tyh5kXBAJF5l9LmmKe8y-kHrhyx9gcEIa6PC97mo5fPbCw9WoOypyTqdWkE1Q9mM44Zn8CZZVH9PTml7_0jwln0W_bzDWjN3f-0Pk2etxU6lXwz5insFVz4nGt5SEmykhvOdKlscLsYbHGQVqze4nlXuAtVXQ08CuphRsZ2FmSaK-LFR8Ivs.DkqbT-PgEjE0ZS6pgNVqGA
 * @Description:TODO
 * @author:hsj qq:2356899074
 * @time:2017年12月11日 下午2:36:30
 * @param request
 * @param response
 * @return
 */
@RequestMapping("/user/login")
public Object login(HttpServletRequest request, HttpServletResponse response) {
    Map<String, Object> model = new HashMap<>();
    J2EContext context = new J2EContext(request, response);
    final ProfileManager<CasRestProfile> manager = new ProfileManager(context);
    final Optional<CasRestProfile> profile = manager.get(true);
    //获取ticket
    TokenCredentials tokenCredentials = casRestFormClient.requestServiceTicket(serviceUrl, profile.get(), context);
    //根据ticket获取用户信息
    final CasProfile casProfile = casRestFormClient.validateServiceTicket(serviceUrl, tokenCredentials, context);
    //生成jwt token
    String token = generator.generate(casProfile);
    model.put("token", token);
    return new HttpEntity<>(model);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:IndexController.java


示例3: generate

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Generate string.
 *
 * @param request           the request
 * @param response          the response
 * @param accessTokenId     the access token id
 * @param timeout           the timeout
 * @param responseType      the response type
 * @param registeredService the registered service
 * @return the string
 * @throws Exception the exception
 */
public String generate(final HttpServletRequest request,
                       final HttpServletResponse response,
                       final AccessToken accessTokenId,
                       final long timeout,
                       final OAuth20ResponseTypes responseType,
                       final OAuthRegisteredService registeredService) throws Exception {

    final OidcRegisteredService oidcRegisteredService = (OidcRegisteredService) registeredService;

    final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    final Optional<UserProfile> profile = manager.get(true);

    LOGGER.debug("Attempting to produce claims for the id token [{}]", accessTokenId);
    final JwtClaims claims = produceIdTokenClaims(request, accessTokenId, timeout,
            oidcRegisteredService, profile.get(), context, responseType);
    LOGGER.debug("Produce claims for the id token [{}] as [{}]", accessTokenId, claims);

    return this.signingService.encode(oidcRegisteredService, claims);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:33,代码来源:OidcIdTokenGeneratorService.java


示例4: extract

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
public AccessTokenRequestDataHolder extract() {
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    final String grantType = request.getParameter(OAuth20Constants.GRANT_TYPE);
    LOGGER.debug("OAuth grant type is [{}]", grantType);

    final Optional<UserProfile> profile = manager.get(true);
    final String clientId = profile.get().getId();
    final OAuthRegisteredService registeredService = OAuth20Utils.getRegisteredOAuthService(this.servicesManager, clientId);
    LOGGER.debug("Located OAuth registered service [{}]", registeredService);

    // we generate a refresh token if requested by the service but not from a refresh token
    final boolean generateRefreshToken = isAllowedToGenerateRefreshToken(registeredService);
    final OAuthToken token = getOAuthTokenFromRequest();
    if (token == null) {
        throw new InvalidTicketException(getOAuthParameter());
    }
    return new AccessTokenRequestDataHolder(token, generateRefreshToken, registeredService);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:AccessTokenAuthorizationCodeGrantRequestExtractor.java


示例5: getAuthenticatedUsername

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Return the username of the authenticated user (based on pac4j security).
 *
 * @return the authenticated username.
 */
public static String getAuthenticatedUsername() {
    final HttpServletRequest request = getHttpServletRequestFromRequestAttributes();
    final HttpServletResponse response = getHttpServletResponseFromRequestAttributes();
    if (request != null && response != null) {
        final ProfileManager manager = getPac4jProfileManager(request, response);
        final Optional<UserProfile> profile = manager.get(true);
        if (profile != null && profile.isPresent()) {
            final String id = profile.get().getId();
            if (id != null) {
                return id;
            }
        }
    }
    return PrincipalResolver.UNKNOWN_USER;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:WebUtils.java


示例6: generate

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Generate string.
 *
 * @param request           the request
 * @param response          the response
 * @param accessTokenId     the access token id
 * @param timeout           the timeout
 * @param responseType      the response type
 * @param registeredService the registered service
 * @return the string
 * @throws Exception the exception
 */
public String generate(final HttpServletRequest request,
                       final HttpServletResponse response,
                       final AccessToken accessTokenId,
                       final long timeout,
                       final OAuth20ResponseTypes responseType,
                       final OAuthRegisteredService registeredService) throws Exception {

    final OidcRegisteredService oidcRegisteredService = (OidcRegisteredService) registeredService;

    final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    final Optional<UserProfile> profile = manager.get(true);

    LOGGER.debug("Attempting to produce claims for the id token [{}]", accessTokenId);
    final JwtClaims claims = produceIdTokenClaims(request, accessTokenId, timeout,
        oidcRegisteredService, profile.get(), context, responseType);
    LOGGER.debug("Produce claims for the id token [{}] as [{}]", accessTokenId, claims);

    return this.signingService.encode(oidcRegisteredService, claims);
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:33,代码来源:OidcIdTokenGeneratorService.java


示例7: handleRequest

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@GetMapping(
		path = {"/oauth2.0/authorize"}
)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
	J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
	ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
	if(this.verifyAuthorizeRequest(request) && isRequestAuthenticated(manager, context)) {
		String clientId = context.getRequestParameter("client_id");
		OAuthRegisteredService registeredService = this.getRegisteredServiceByClientId(clientId);
		try {
			RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(clientId, registeredService);
		} catch (Exception var8) {
			LOGGER.error(var8.getMessage(), var8);
			return OAuth20Utils.produceUnauthorizedErrorView();
		}
		ModelAndView mv = this.consentApprovalViewResolver.resolve(context, registeredService);
		return !mv.isEmpty() && mv.hasView()?mv:this.redirectToCallbackRedirectUrl(manager, registeredService, context, clientId);
	} else {
		LOGGER.error("Authorize request verification failed");
		return OAuth20Utils.produceUnauthorizedErrorView();
	}
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:23,代码来源:OAuth20AuthorizeEndpointController.java


示例8: login

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@RequestMapping("/user/login")
public Object login(HttpServletRequest request, HttpServletResponse response) {
    Map<String, Object> model = new HashMap<>();
    J2EContext context = new J2EContext(request, response);
    final ProfileManager<CasRestProfile> manager = new ProfileManager(context);
    final Optional<CasRestProfile> profile = manager.get(true);
    //获取ticket
    TokenCredentials tokenCredentials = casRestFormClient.requestServiceTicket(serviceUrl, profile.get(), context);
    //根据ticket获取用户信息
    final CasProfile casProfile = casRestFormClient.validateServiceTicket(serviceUrl, tokenCredentials, context);
    //生成jwt token
    String token = generator.generate(casProfile);
    model.put("token", token);
    return new HttpEntity<>(model);
}
 
开发者ID:kawhii,项目名称:wolf,代码行数:16,代码来源:IndexController.java


示例9: shouldAllowAccess

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Test
public void shouldAllowAccess() throws Exception {
  new MockUnit(Request.class, Response.class, Route.Chain.class, ProfileManager.class,
      WebContext.class, Session.class, CommonProfile.class)
      .expect(unit -> {
        CommonProfile profile = unit.get(CommonProfile.class);

        ProfileManager pm = unit.get(ProfileManager.class);
        expect(pm.getAll(true)).andReturn(ImmutableList.of(profile));

        Request req = unit.get(Request.class);
        expect(req.require(ProfileManager.class)).andReturn(pm);
        expect(req.ifSession()).andReturn(Optional.of(unit.get(Session.class)));

        Pac4jClientType.profileTypes(profile.getClass(),
            type -> expect(req.set(type, profile)).andReturn(req));

        Response rsp = unit.get(Response.class);
        unit.get(Route.Chain.class).next(req, rsp);
      })
      .run(unit -> {
        new Pac4jGrantAccessAdapter(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class))
            .adapt(unit.get(WebContext.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:27,代码来源:Pac4jGrantAccessAdapterTest.java


示例10: shouldCreateProfileManager

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Test
public void shouldCreateProfileManager() throws Exception {
  new MockUnit(WebContext.class, Config.class, ProfileManager.class)
      .expect(unit -> {
        Function<WebContext, ProfileManager> pmf = unit.mock(Function.class);
        expect(pmf.apply(unit.get(WebContext.class))).andReturn(unit.get(ProfileManager.class));

        Config config = unit.get(Config.class);
        expect(config.getProfileManagerFactory()).andReturn(pmf);
      })
      .run(unit -> {
        Pac4jProfileManager pmp = new Pac4jProfileManager(unit.get(Config.class),
            unit.get(WebContext.class));
        assertEquals(unit.get(ProfileManager.class), pmp.get());
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:17,代码来源:Pac4jProfileManagerTest.java


示例11: resolve

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
public ModelAndView resolve(final J2EContext ctx, final ProfileManager manager, final String url) {
    final Set<String> prompt = authorizationRequestSupport.getOidcPromptFromAuthorizationRequest(url);
    if (prompt.contains(OidcConstants.PROMPT_NONE)) {
        if (manager.get(true) != null) {
            return new ModelAndView(url);
        }
        final Map<String, String> model = new HashMap<>();
        model.put(OAuth20Constants.ERROR, OidcConstants.LOGIN_REQUIRED);
        return new ModelAndView(new MappingJackson2JsonView(), model);
    }
    return new ModelAndView(new RedirectView(url));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:OidcCallbackAuthorizeViewResolver.java


示例12: preHandle

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
public boolean preHandle(final HttpServletRequest request,
                         final HttpServletResponse response,
                         final Object handler) throws Exception {
    final J2EContext ctx = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);


    boolean clearCreds = false;
    final Optional<UserProfile> auth = authorizationRequestSupport.isAuthenticationProfileAvailable(ctx);

    if (auth.isPresent()) {
        final Optional<Long> maxAge = authorizationRequestSupport.getOidcMaxAgeFromAuthorizationRequest(ctx);
        if (maxAge.isPresent()) {
            clearCreds = authorizationRequestSupport.isCasAuthenticationOldForMaxAgeAuthorizationRequest(ctx, auth.get());
        }
    }

    final Set<String> prompts = authorizationRequestSupport.getOidcPromptFromAuthorizationRequest(ctx);
    if (!clearCreds) {
        clearCreds = prompts.contains(OidcConstants.PROMPT_LOGIN);
    }

    if (clearCreds) {
        clearCreds = !prompts.contains(OidcConstants.PROMPT_NONE);
    }

    if (clearCreds) {
        manager.remove(true);
    }
    return super.preHandle(request, response, handler);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:33,代码来源:OidcSecurityInterceptor.java


示例13: destroyApplicationSession

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Destroy application session.
 * Also kills all delegated authn profiles via pac4j.
 *
 * @param request  the request
 * @param response the response
 */
protected void destroyApplicationSession(final HttpServletRequest request, final HttpServletResponse response) {
    LOGGER.debug("Destroying application session");
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    manager.logout();

    final HttpSession session = request.getSession();
    if (session != null) {
        session.invalidate();
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:TerminateSessionAction.java


示例14: extract

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
public AccessTokenRequestDataHolder extract() {
    final String clientId = request.getParameter(OAuth20Constants.CLIENT_ID);
    LOGGER.debug("Locating OAuth registered service by client id [{}]", clientId);

    final OAuthRegisteredService registeredService = OAuth20Utils.getRegisteredOAuthService(this.servicesManager, clientId);
    LOGGER.debug("Located OAuth registered service [{}]", registeredService);

    final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    final Optional<OAuthUserProfile> profile = manager.get(true);
    if (!profile.isPresent()) {
        throw new UnauthorizedServiceException("OAuth user profile cannot be determined");
    }
    LOGGER.debug("Creating matching service request based on [{}]", registeredService);
    final boolean requireServiceHeader = oAuthProperties.getGrants().getResourceOwner().isRequireServiceHeader();
    if (requireServiceHeader) {
        LOGGER.debug("Using request headers to identify and build the target service url");
    }
    final Service service = this.authenticationBuilder.buildService(registeredService, context, requireServiceHeader);

    LOGGER.debug("Authenticating the OAuth request indicated by [{}]", service);
    final Authentication authentication = this.authenticationBuilder.build(profile.get(), registeredService, context, service);
    RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);

    final AuthenticationResult result = new DefaultAuthenticationResult(authentication, requireServiceHeader ? service : null);
    final TicketGrantingTicket ticketGrantingTicket = this.centralAuthenticationService.createTicketGrantingTicket(result);
    return new AccessTokenRequestDataHolder(service, authentication, registeredService, ticketGrantingTicket);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:30,代码来源:AccessTokenPasswordGrantRequestExtractor.java


示例15: handleRequest

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Handle request internal model and view.
 *
 * @param request  the request
 * @param response the response
 * @return the model and view
 * @throws Exception the exception
 */
@GetMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.AUTHORIZE_URL)
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);

    if (!verifyAuthorizeRequest(request) || !isRequestAuthenticated(manager, context)) {
        LOGGER.error("Authorize request verification failed");
        return OAuth20Utils.produceUnauthorizedErrorView();
    }

    final String clientId = context.getRequestParameter(OAuth20Constants.CLIENT_ID);
    final OAuthRegisteredService registeredService = getRegisteredServiceByClientId(clientId);
    try {
        RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(clientId, registeredService);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        return OAuth20Utils.produceUnauthorizedErrorView();
    }

    final ModelAndView mv = this.consentApprovalViewResolver.resolve(context, registeredService);
    if (!mv.isEmpty() && mv.hasView()) {
        return mv;
    }

    return redirectToCallbackRedirectUrl(manager, registeredService, context, clientId);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:OAuth20AuthorizeEndpointController.java


示例16: handleRequest

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
/**
 * Handle request.
 *
 * @param request  the request
 * @param response the response
 * @return the model and view
 * @throws Exception the exception
 */
@GetMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.CALLBACK_AUTHORIZE_URL)
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    this.callbackController.callback(request, response);
    final String url = StringUtils.remove(response.getHeader("Location"), "redirect:");
    final J2EContext ctx = WebUtils.getPac4jJ2EContext(request, response);
    final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
    return oAuth20CallbackAuthorizeViewResolver.resolve(ctx, manager, url);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:17,代码来源:OAuth20CallbackAuthorizeEndpointController.java


示例17: redirectToCallbackRedirectUrl

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
protected ModelAndView redirectToCallbackRedirectUrl(ProfileManager manager, OAuthRegisteredService registeredService, J2EContext context, String clientId) throws Exception {
	Optional profile = manager.get(true);
	if(profile != null && profile.isPresent()) {
		Service service = this.authenticationBuilder.buildService(registeredService, context, false);
		LOGGER.debug("Created service [{}] based on registered service [{}]", service, registeredService);
		Authentication authentication = this.authenticationBuilder.build((UserProfile)profile.get(), registeredService, context, service);
		LOGGER.debug("Created OAuth authentication [{}] for service [{}]", service, authentication);

		try {
			RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);
		} catch (PrincipalException | UnauthorizedServiceException var13) {
			LOGGER.error(var13.getMessage(), var13);
			return OAuth20Utils.produceUnauthorizedErrorView();
		}

		String redirectUri = context.getRequestParameter("redirect_uri");
		LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);
		String responseType = context.getRequestParameter("response_type");
		TicketGrantingTicket ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest(this.ticketGrantingTicketCookieGenerator, this.ticketRegistry, context.getRequest());
		String callbackUrl;
		if(OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.CODE)) {
			callbackUrl = this.buildCallbackUrlForAuthorizationCodeResponseType(authentication, service, redirectUri, ticketGrantingTicket);
		} else if(OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.TOKEN)) {
			AccessTokenRequestDataHolder holder = new AccessTokenRequestDataHolder(service, authentication, registeredService, ticketGrantingTicket);
			callbackUrl = this.buildCallbackUrlForImplicitTokenResponseType(holder, redirectUri);
		} else {
			callbackUrl = this.buildCallbackUrlForTokenResponseType(context, authentication, service, redirectUri, responseType, clientId);
		}

		LOGGER.debug("Callback URL to redirect: [{}]", callbackUrl);
		context.getRequest().getSession().invalidate();
		removeCookie(context);
		return StringUtils.isBlank(callbackUrl)?OAuth20Utils.produceUnauthorizedErrorView():OAuth20Utils.redirectTo(callbackUrl);
	} else {
		LOGGER.error("Unexpected null profile from profile manager. Request is not fully authenticated.");
		return OAuth20Utils.produceUnauthorizedErrorView();
	}
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:39,代码来源:OAuth20AuthorizeEndpointController.java


示例18: saveUserProfile

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
protected void saveUserProfile(final C context, final CommonProfile profile,
                               final boolean multiProfile, final boolean renewSession) {
    final ProfileManager manager = getProfileManager(context);
    if (profile != null) {
        manager.save(true, profile, multiProfile);
        if (renewSession) {
            renewSession(context);
        }
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:DefaultCallbackLogic.java


示例19: perform

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
public R perform(final C context, final Config config, final HttpActionAdapter<R, C> httpActionAdapter,
                   final String defaultUrl, final String inputLogoutUrlPattern) {

    logger.debug("=== APP LOGOUT ===");

    // default value
    final String logoutUrlPattern;
    if (inputLogoutUrlPattern == null) {
        logoutUrlPattern = Pac4jConstants.DEFAULT_LOGOUT_URL_PATTERN_VALUE;
    } else {
        logoutUrlPattern = inputLogoutUrlPattern;
    }

    // checks
    assertNotNull("context", context);
    assertNotNull("config", config);
    assertNotNull("httpActionAdapter", httpActionAdapter);
    assertNotBlank(Pac4jConstants.LOGOUT_URL_PATTERN, logoutUrlPattern);

    // logic
    final ProfileManager manager = getProfileManager(context);
    manager.logout();
    postLogout(context);

    final String url = context.getRequestParameter(Pac4jConstants.URL);
    String redirectUrl = defaultUrl;
    if (url != null && Pattern.matches(logoutUrlPattern, url)) {
        redirectUrl = url;
    }
    logger.debug("redirectUrl: {}", redirectUrl);
    final HttpAction action;
    if (redirectUrl != null) {
        action = HttpAction.redirect("redirect", context, redirectUrl);
    } else {
        action = HttpAction.ok("ok", context);
    }

    return httpActionAdapter.adapt(action.getCode(), context);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:41,代码来源:DefaultApplicationLogoutLogic.java


示例20: createValueFactory

import org.pac4j.core.profile.ProfileManager; //导入依赖的package包/类
@Override
protected Factory<?> createValueFactory(Parameter parameter) {
    if (parameter.isAnnotationPresent(Pac4JProfileManager.class)) {
        if (ProfileManager.class.isAssignableFrom(parameter.getRawType())) {
            return manager.get();
        }

        throw new IllegalStateException("Cannot inject a Pac4J profile manager into a parameter of type "
                + parameter.getRawType().getName());
    }

    if (parameter.isAnnotationPresent(Pac4JProfile.class)) {
        if (CommonProfile.class.isAssignableFrom(parameter.getRawType())) {
            return profile.get();
        }

        if (Optional.class.isAssignableFrom(parameter.getRawType())) {
            List<ClassTypePair> ctps = ReflectionHelper.getTypeArgumentAndClass(parameter.getRawType());
            ClassTypePair ctp = (ctps.size() == 1) ? ctps.get(0) : null;
            if (ctp == null || CommonProfile.class.isAssignableFrom(ctp.rawClass())) {
                return optProfile.get();
            }
        }

        throw new IllegalStateException(
                "Cannot inject a Pac4J profile into a parameter of type " + parameter.getRawType().getName());
    }

    return null;
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:31,代码来源:Pac4JValueFactoryProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DERBoolean类代码示例发布时间:2022-05-22
下一篇:
Java NoBracketingException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap