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


Java UnauthorizedServiceException类代码示例

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


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

示例1: getRegisteredServiceJwtSecret

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
/**
 * Gets registered service jwt secret.
 *
 * @param service  the service
 * @param propName the prop name
 * @return the registered service jwt secret
 */
protected String getRegisteredServiceJwtSecret(final RegisteredService service, final String propName) {
    if (service == null || !service.getAccessStrategy().isServiceAccessAllowed()) {
        logger.debug("Service is not defined/found or its access is disabled in the registry");
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
    }
    if (service.getProperties().containsKey(propName)) {
        final RegisteredServiceProperty propSigning = service.getProperties().get(propName);
        final String tokenSigningSecret = propSigning.getValue();
        if (StringUtils.isNotBlank(tokenSigningSecret)) {
            logger.debug("Found the secret value {} for service [{}]", propName, service.getServiceId());
            return tokenSigningSecret;
        }
    }
    logger.warn("Service [{}] does not define a property [{}] in the registry",
            service.getServiceId(), propName);
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:25,代码来源:TokenAuthenticationHandler.java

示例2: verifyValidateServiceTicketWithInvalidService

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected = UnauthorizedServiceException.class)
public void verifyValidateServiceTicketWithInvalidService() throws Exception {
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), getService("test2"));

    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService()
        .createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService()
        .grantServiceTicket(ticketGrantingTicket.getId(), getService(), ctx);

    getCentralAuthenticationService().validateServiceTicket(
        serviceTicket.getId(), getService("test2"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:CentralAuthenticationServiceImplTests.java

示例3: unauthorizedServiceProvided

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void unauthorizedServiceProvided() throws Exception {
    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.getFlowScope().put("service", this.unauthorizedService);

    this.serviceAuthorizationCheck.doExecute(mockRequestContext);
    fail("Should have thrown UnauthorizedServiceException");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:ServiceAuthorizationCheckTests.java

示例4: serviceThatIsNotRegisteredProvided

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void serviceThatIsNotRegisteredProvided() throws Exception {
    final MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.getFlowScope().put("service", this.undefinedService);
    this.serviceAuthorizationCheck.doExecute(mockRequestContext);
    fail("Should have thrown UnauthorizedServiceException");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:ServiceAuthorizationCheckTests.java

示例5: verifyValidateServiceTicketWithInvalidService

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void verifyValidateServiceTicketWithInvalidService() throws Exception {
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService()
        .createTicketGrantingTicket(
            TestUtils.getCredentialsWithSameUsernameAndPassword());
    final ServiceTicket serviceTicket = getCentralAuthenticationService()
        .grantServiceTicket(ticketGrantingTicket.getId(), TestUtils.getService());

    getCentralAuthenticationService().validateServiceTicket(
        serviceTicket.getId(), TestUtils.getService("test2"));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:CentralAuthenticationServiceImplTests.java

示例6: doExecute

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext context) throws Exception {
    final Service service = WebUtils.getService(context);

    final boolean match = this.servicesManager.matchesExistingService(service);

    if (match) {
        return success();
    }

    final String msg = String.format("ServiceManagement: Unauthorized Service Access. "
            + "Service [%s] does not match entries in service registry.", service.getId());
    logger.warn(msg);
    throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, msg);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:GatewayServicesManagementCheck.java

示例7: doExecute

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext context) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    if (!this.pathPopulated) {
        final String contextPath = context.getExternalContext().getContextPath();
        final String cookiePath = StringUtils.hasText(contextPath) ? contextPath + '/' : "/";
        logger.info("Setting path for cookies to: {} ", cookiePath);
        this.warnCookieGenerator.setCookiePath(cookiePath);
        this.ticketGrantingTicketCookieGenerator.setCookiePath(cookiePath);
        this.pathPopulated = true;
    }

    WebUtils.putTicketGrantingTicketInScopes(context,
            this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request));

    WebUtils.putWarningCookie(context,
            Boolean.valueOf(this.warnCookieGenerator.retrieveCookieValue(request)));

    final Service service = WebUtils.getService(this.argumentExtractors, context);


    if (service != null) {
        logger.debug("Placing service in context scope: [{}]", service.getId());

        final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService != null && registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            logger.debug("Placing registered service [{}] with id [{}] in context scope",
                    registeredService.getServiceId(),
                    registeredService.getId());
            WebUtils.putRegisteredService(context, registeredService);
        }
    } else if (!this.enableFlowOnAbsentServiceRequest) {
        logger.warn("No service authentication request is available at [{}]. CAS is configured to disable the flow.",
                WebUtils.getHttpServletRequest(context).getRequestURL());
        throw new NoSuchFlowExecutionException(context.getFlowExecutionContext().getKey(),
                new UnauthorizedServiceException("screen.service.required.message", "Service is required"));
    }
    WebUtils.putService(context, service);
    return result("success");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:41,代码来源:InitialFlowSetupAction.java

示例8: testValidateServiceTicketWithInvalidService

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void testValidateServiceTicketWithInvalidService() throws Exception {
    final String ticketGrantingTicket = getCentralAuthenticationService()
        .createTicketGrantingTicket(
            TestUtils.getCredentialsWithSameUsernameAndPassword());
    final String serviceTicket = getCentralAuthenticationService()
        .grantServiceTicket(ticketGrantingTicket, TestUtils.getService());

    getCentralAuthenticationService().validateServiceTicket(
        serviceTicket, TestUtils.getService("test2"));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:12,代码来源:CentralAuthenticationServiceImplTests.java

示例9: unauthorizedServiceProvided

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void unauthorizedServiceProvided() throws Exception {
    MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.getFlowScope().put("service", this.unauthorizedService);

    this.serviceAuthorizationCheck.doExecute(mockRequestContext);
    fail("Should have thrown UnauthorizedServiceException");
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:9,代码来源:ServiceAuthorizationCheckTests.java

示例10: serviceThatIsNotRegisteredProvided

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void serviceThatIsNotRegisteredProvided() throws Exception {
    MockRequestContext mockRequestContext = new MockRequestContext();
    mockRequestContext.getFlowScope().put("service", this.undefinedService);
    this.serviceAuthorizationCheck.doExecute(mockRequestContext);
    fail("Should have thrown UnauthorizedServiceException");
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:8,代码来源:ServiceAuthorizationCheckTests.java

示例11: newCookieGeneratorInstance

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
protected LocalCookieGenerator newCookieGeneratorInstance(
    final HttpServletRequest request) {
    String appName = CasShibUtil.getAppNameFromRequestURI(request,
        shibServiceRegistrar);
    if (appName == null) {
        throw new UnauthorizedServiceException(
            "Can't issue cookies because application name could not be determined.");
    }

    LocalCookieGenerator cookieGenerator = new LocalCookieGenerator();
    if (cookieSecure != null)
        cookieGenerator.setCookieSecure(cookieSecure.booleanValue());
    if (cookieMaxAge != null)
        cookieGenerator.setCookieMaxAge(cookieMaxAge.intValue());

    // cookie name is cookieNamePrefix + "-" + escaped(appName)
    cookieGenerator.setCookieName(getFullCookieName(appName));

    // determine the cookie path based on the requestURI
    String cookiePath = (request.getContextPath() != null ? request
        .getContextPath() : "")
        + "/shib/" + appName;

    cookieGenerator.setCookiePath(cookiePath);

    return (cookieGenerator);
}
 
开发者ID:UniconLabs,项目名称:casshib,代码行数:28,代码来源:CasShibCookieRetrievingCookieGenerator.java

示例12: extractServiceInternal

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
public WebApplicationService extractServiceInternal(
    final HttpServletRequest request) {
    CasShibWebApplicationServiceImpl service = (CasShibWebApplicationServiceImpl) super
        .extractServiceInternal(request);

    boolean authorizedService = isAuthorized(service, false);
    if (!authorizedService) {
        // fortunately this is a RuntimeException
        throw new UnauthorizedServiceException(
            "The passcode provided is invalid.");
    }

    return (service);
}
 
开发者ID:UniconLabs,项目名称:casshib,代码行数:16,代码来源:CasShibRegistrationProtectedArgumentExtractor.java

示例13: extractServiceInternal

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
public WebApplicationService extractServiceInternal(
    final HttpServletRequest request) {
    CasShibWebApplicationServiceImpl service = (CasShibWebApplicationServiceImpl) super
        .extractServiceInternal(request);

    boolean authorizedService = isAuthorized(service, true);
    if (!authorizedService) {
        // fortunately this is a RuntimeException
        throw new UnauthorizedServiceException(
            "The passcode provided is invalid.");
    }

    return (service);
}
 
开发者ID:UniconLabs,项目名称:casshib,代码行数:16,代码来源:CasShibPasscodeProtectedArgumentExtractor.java

示例14: extractServiceInternal

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
public WebApplicationService extractServiceInternal(
    final HttpServletRequest request) {
    CasShibSamlService service = (CasShibSamlService) super
        .extractServiceInternal(request);

    boolean authorizedService = isAuthorized(service, false);
    if (!authorizedService) {
        // fortunately this is a RuntimeException
        throw new UnauthorizedServiceException(
            "The passcode provided is invalid.");
    }

    return (service);
}
 
开发者ID:UniconLabs,项目名称:casshib,代码行数:16,代码来源:CasShibSamlRegistrationProtectedArgumentExtractor.java

示例15: extractServiceInternal

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
public WebApplicationService extractServiceInternal(
    final HttpServletRequest request) {
    CasShibSamlService service = (CasShibSamlService) super
        .extractServiceInternal(request);

    boolean authorizedService = isAuthorized(service, true);
    if (!authorizedService) {
        // fortunately this is a RuntimeException
        throw new UnauthorizedServiceException(
            "The passcode provided is invalid.");
    }

    return (service);
}
 
开发者ID:UniconLabs,项目名称:casshib,代码行数:16,代码来源:CasShibSamlPasscodeProtectedArgumentExtractor.java


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