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

Java UnauthorizedServiceException类代码示例

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

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



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


示例16: doExecute

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
    final String entityId = request.getParameter(this.entityIdParameterName);
    if (StringUtils.isBlank(entityId)) {
        logger.debug("No entity id found for parameter [{}]", this.entityIdParameterName);
        return success();
    }

    final WebApplicationService service = serviceFactory.createService(entityId);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        logger.debug("Entity id [{}] is not recognized/allowed by the CAS service registry", entityId);

        if (registeredService != null) {
            WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(requestContext,
                    registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
        }

        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE,
                "Entity " + entityId + " not recognized");
    }

    final EntityDescriptor entityDescriptor = this.metadataAdapter.getEntityDescriptorForEntityId(entityId);
    if (entityDescriptor == null) {
        logger.debug("Entity descriptor not found for [{}]", entityId);
        return success();
    }

    final SPSSODescriptor spssoDescriptor = getSPSsoDescriptor(entityDescriptor);
    if (spssoDescriptor == null) {
        logger.debug("SP SSO descriptor not found for [{}]", entityId);
        return success();
    }

    final Extensions extensions = spssoDescriptor.getExtensions();
    if (extensions == null) {
        logger.debug("No extensions are found for [{}]", UIInfo.DEFAULT_ELEMENT_NAME.getNamespaceURI());
        return success();
    }

    final List<XMLObject> spExtensions = extensions.getUnknownXMLObjects(UIInfo.DEFAULT_ELEMENT_NAME);
    if (spExtensions.isEmpty()) {
        logger.debug("No extensions are found for [{}]", UIInfo.DEFAULT_ELEMENT_NAME.getNamespaceURI());
        return success();
    }

    final SimpleMetadataUIInfo mdui = new SimpleMetadataUIInfo(registeredService);

    for (final XMLObject obj : spExtensions) {
        if (obj instanceof UIInfo) {
            final UIInfo uiInfo = (UIInfo) obj;
            logger.debug("Found UI info for [{}] and added to flow context", entityId);
            mdui.setUIInfo(uiInfo);
        }
    }

    requestContext.getFlowScope().put(MDUI_FLOW_PARAMETER_NAME, mdui);
    return success();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:61,代码来源:SamlMetadataUIParserAction.java


示例17: constructSamlResponse

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
/**
 * Construct SAML response.
 * <a href="http://bit.ly/1uI8Ggu">See this reference for more info.</a>
 * @param service the service
 * @return the SAML response
 */
protected String constructSamlResponse(final GoogleAccountsService service) {
    final DateTime currentDateTime = new DateTime();
    final DateTime notBeforeIssueInstant = DateTime.parse("2003-04-17T00:46:02Z");

    /*
     * Must be looked up directly from the context
     * because the services manager is not serializable
     * and cannot be class field.
     */
    final ApplicationContext context = ApplicationContextProvider.getApplicationContext();
    final ServicesManager servicesManager = context.getBean("servicesManager", ServicesManager.class);
    final RegisteredService registeredService = servicesManager.findServiceBy(service);
    if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE);
    }
    final String userId = registeredService.getUsernameAttributeProvider()
                .resolveUsername(service.getPrincipal(), service);

    final org.opensaml.saml.saml2.core.Response response = samlObjectBuilder.newResponse(
        samlObjectBuilder.generateSecureRandomId(), currentDateTime, service.getId(), service);
    response.setStatus(samlObjectBuilder.newStatus(StatusCode.SUCCESS, null));

    final AuthnStatement authnStatement = samlObjectBuilder.newAuthnStatement(
        AuthnContext.PASSWORD_AUTHN_CTX, currentDateTime);
    final Assertion assertion = samlObjectBuilder.newAssertion(authnStatement,
        "https://www.opensaml.org/IDP",
        notBeforeIssueInstant, samlObjectBuilder.generateSecureRandomId());

    final Conditions conditions = samlObjectBuilder.newConditions(notBeforeIssueInstant,
            currentDateTime.plusSeconds(this.skewAllowance), service.getId());
    assertion.setConditions(conditions);

    final Subject subject = samlObjectBuilder.newSubject(NameID.EMAIL, userId,
        service.getId(), currentDateTime.plusSeconds(this.skewAllowance), service.getRequestId());
    assertion.setSubject(subject);

    response.getAssertions().add(assertion);

    final StringWriter writer = new StringWriter();
    samlObjectBuilder.marshalSamlXmlObject(response, writer);

    final String result = writer.toString();
    LOGGER.debug("Generated Google SAML response: {}", result);
    return result;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:52,代码来源:GoogleAccountsServiceResponseBuilder.java


示例18: verifyInvalidServiceWhenDelegatingTicketGrantingTicket

import org.jasig.cas.services.UnauthorizedServiceException; //导入依赖的package包/类
@Test(expected=UnauthorizedServiceException.class)
public void verifyInvalidServiceWhenDelegatingTicketGrantingTicket() throws Exception {
    this.cas.createProxyGrantingTicket(ST_ID, getAuthenticationContext());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:CentralAuthenticationServiceImplWithMockitoTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ResourceRequestProtoOrBuilder类代码示例发布时间:2022-05-22
下一篇:
Java Builder类代码示例发布时间: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