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


Java Service类代码示例

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


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

示例1: verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithDifferentEncodingAndIgnoringCase() throws Exception {
    final String origSvc = "http://www.jasig.org?param=hello+world";
    final Service svc = org.jasig.cas.authentication.TestUtils.getService(origSvc);
    final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils
            .getAuthenticationContext(getAuthenticationSystemSupport(), svc);

    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(ctx);
    

    final ServiceTicket sId = getCentralAuthenticationService()
            .grantServiceTicket(tId.getId(), svc, ctx);

    final String reqSvc = "http://WWW.JASIG.ORG?PARAM=hello%20world";
    
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", org.jasig.cas.authentication.TestUtils.getService(reqSvc).getId());
    request.addParameter("ticket", sId.getId());
    
    assertEquals(AbstractServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:26,代码来源:AbstractServiceValidateControllerTests.java

示例2: create

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Override
public <T extends Ticket> T create(final ProxyGrantingTicket proxyGrantingTicket,
                                   final Service service) {
    final String uniqueTicketIdGenKey = service.getClass().getName();
    logger.debug("Looking up service ticket id generator for [{}]", uniqueTicketIdGenKey);
    UniqueTicketIdGenerator serviceTicketUniqueTicketIdGenerator =
            this.uniqueTicketIdGeneratorsForService.get(uniqueTicketIdGenKey);
    if (serviceTicketUniqueTicketIdGenerator == null) {
        serviceTicketUniqueTicketIdGenerator = this.defaultServiceTicketIdGenerator;
        logger.debug("Service ticket id generator not found for [{}]. Using the default generator...",
                uniqueTicketIdGenKey);
    }

    final String ticketId = serviceTicketUniqueTicketIdGenerator.getNewTicketId(ProxyTicket.PROXY_TICKET_PREFIX);
    final ProxyTicket serviceTicket = proxyGrantingTicket.grantProxyTicket(
            ticketId,
            service,
            this.serviceTicketExpirationPolicy,
            this.onlyTrackMostRecentSession);
    return (T) serviceTicket;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:DefaultProxyTicketFactory.java

示例3: evaluateProxiedServiceIfNeeded

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
/**
 * Evaluate proxied service if needed.
 *
 * @param service the service
 * @param ticketGrantingTicket the ticket granting ticket
 * @param registeredService the registered service
 */
protected final void evaluateProxiedServiceIfNeeded(final Service service, final TicketGrantingTicket ticketGrantingTicket,
                                            final RegisteredService registeredService) {
    final Service proxiedBy = ticketGrantingTicket.getProxiedBy();
    if (proxiedBy != null) {
        logger.debug("TGT is proxied by [{}]. Locating proxy service in registry...", proxiedBy.getId());
        final RegisteredService proxyingService = servicesManager.findServiceBy(proxiedBy);

        if (proxyingService != null) {
            logger.debug("Located proxying service [{}] in the service registry", proxyingService);
            if (!proxyingService.getProxyPolicy().isAllowedToProxy()) {
                logger.warn("Found proxying service {}, but it is not authorized to fulfill the proxy attempt made by {}",
                        proxyingService.getId(), service.getId());
                throw new UnauthorizedProxyingException("Proxying is not allowed for registered service "
                        + registeredService.getId());
            }
        } else {
            logger.warn("No proxying service found. Proxy attempt by service [{}] (registered service [{}]) is not allowed.",
                    service.getId(), registeredService.getId());
            throw new UnauthorizedProxyingException("Proxying is not allowed for registered service "
                    + registeredService.getId());
        }
    } else {
        logger.trace("TGT is not proxied by another service");
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:33,代码来源:AbstractCentralAuthenticationService.java

示例4: testAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void testAllowsAccessToHighSecurityServiceWithPasswordAndOTPViaRenew() throws Exception {
    // Note the original credential used to start SSO session does not satisfy security policy
    final String tgt = cas.createTicketGrantingTicket(newUserPassCredentials("alice", "alice"));
    assertNotNull(tgt);
    final Service service = newService("https://example.com/high/");
    final String st = cas.grantServiceTicket(
            tgt,
            service,
            newUserPassCredentials("alice", "alice"),
            new OneTimePasswordCredential("alice", "31415"));
    assertNotNull(st);
    // Confirm the authentication in the assertion is the one that satisfies security policy
    final Assertion assertion = cas.validateServiceTicket(st, service);
    assertEquals(2, assertion.getPrimaryAuthentication().getSuccesses().size());
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("passwordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getSuccesses().containsKey("oneTimePasswordHandler"));
    assertTrue(assertion.getPrimaryAuthentication().getAttributes().containsKey(
            SuccessfulHandlerMetaDataPopulator.SUCCESSFUL_AUTHENTICATION_HANDLERS));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:MultifactorAuthenticationTests.java

示例5: testMatchesExistingService

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void testMatchesExistingService() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setId(1000);
    r.setName("test");
    r.setServiceId("test");

    final Service service = new SimpleService("test");
    final Service service2 = new SimpleService("fdfa");

    this.defaultServicesManagerImpl.save(r);

    assertTrue(this.defaultServicesManagerImpl.matchesExistingService(service));
    assertEquals(r, this.defaultServicesManagerImpl.findServiceBy(service));
    assertNull(this.defaultServicesManagerImpl.findServiceBy(service2));
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:17,代码来源:DefaultServicesManagerImplTests.java

示例6: verifyValidateServiceTicketReturnOnlyAllowedAttribute

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyValidateServiceTicketReturnOnlyAllowedAttribute() throws Exception {
    final Service service = getService("eduPersonTestInvalid");
    final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword();
    final AuthenticationContext ctx = TestUtils.getAuthenticationContext(getAuthenticationSystemSupport(), service);
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(),
        service, ctx);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(),
        service);
    final Authentication auth = assertion.getPrimaryAuthentication();
    final Map<String, Object> attributes = auth.getPrincipal().getAttributes();
    assertEquals(1, attributes.size());
    assertEquals("adopters", attributes.get("groupMembership"));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:17,代码来源:CentralAuthenticationServiceImplTests.java

示例7: verifyRenewWithServiceAndBadCredentials

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyRenewWithServiceAndBadCredentials() throws Exception {
    final Credential c = org.jasig.cas.authentication.TestUtils.getCredentialsWithSameUsernameAndPassword();
    final Service service = TestUtils.getService("test");
    final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils.getAuthenticationContext(
            getAuthenticationSystemSupport(), service, c);

    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockRequestContext context = new MockRequestContext();

    WebUtils.putTicketGrantingTicketInScopes(context, ticketGrantingTicket);
    request.addParameter("renew", "true");
    request.addParameter("service", service.getId());

    final Credential c2 = org.jasig.cas.authentication.TestUtils.getCredentialsWithDifferentUsernameAndPassword();
    context.setExternalContext(new ServletExternalContext(
        new MockServletContext(), request, new MockHttpServletResponse()));
    putCredentialInRequestScope(context, c2);
    context.getRequestScope().put(
        "org.springframework.validation.BindException.credentials",
        new BindException(c2, "credentials"));

    final MessageContext messageContext = mock(MessageContext.class);
    assertEquals("error", this.action.submit(context, c2, messageContext).getId());
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:27,代码来源:AuthenticationViaFormActionTests.java

示例8: isAuthenticationRenewed

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
/**
 * Tries to determine if authentication was created as part of a "renew" event.
 * Renewed authentications can occur if the service is not allowed to participate
 * in SSO or if a "renew" request parameter is specified.
 *
 * @param ctx the request context
 * @return true if renewed
 */
private boolean isAuthenticationRenewed(final RequestContext ctx) {
    if (ctx.getRequestParameters().contains(CasProtocolConstants.PARAMETER_RENEW)) {
        LOGGER.debug("[{}] is specified for the request. The authentication session will be considered renewed.",
                CasProtocolConstants.PARAMETER_RENEW);
        return true;
    }

    final Service service = WebUtils.getService(ctx);
    if (service != null) {
        final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
        if (registeredService != null) {
            final boolean isAllowedForSso = registeredService.getAccessStrategy().isServiceAccessAllowedForSso();
            LOGGER.debug("Located [{}] in registry. Service access to participate in SSO is set to [{}]",
                    registeredService.getServiceId(), isAllowedForSso);
            return !isAllowedForSso;
        }
    }

    return false;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:SendTicketGrantingTicketAction.java

示例9: prepareMergedOutputModel

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Override
protected void prepareMergedOutputModel(final Map<String, Object> model, final HttpServletRequest request,
                                        final HttpServletResponse response) throws Exception {

    super.prepareMergedOutputModel(model, request, response);

    final Service service = super.getServiceFrom(model);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final Map<String, Object> attributes = new HashMap<>(getPrincipalAttributesAsMultiValuedAttributes(model));
    attributes.put(CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_AUTHENTICATION_DATE,
            Collections.singleton(getAuthenticationDate(model)));
    attributes.put(CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_FROM_NEW_LOGIN,
            Collections.singleton(isAssertionBackedByNewLogin(model)));
    attributes.put(CasProtocolConstants.VALIDATION_REMEMBER_ME_ATTRIBUTE_NAME,
            Collections.singleton(isRememberMeAuthentication(model)));

    decideIfCredentialPasswordShouldBeReleasedAsAttribute(attributes, model, registeredService);
    decideIfProxyGrantingTicketShouldBeReleasedAsAttribute(attributes, model, registeredService);

    super.putIntoModel(model,
            CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_ATTRIBUTES,
            this.casAttributeEncoder.encodeAttributes(attributes, getServiceFrom(model)));
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:25,代码来源:Cas30ResponseView.java

示例10: verifyValidServiceTicketWithDifferentEncoding

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyValidServiceTicketWithDifferentEncoding() throws Exception {
    final Service svc = org.jasig.cas.authentication.TestUtils.getService("http://www.jasig.org?param=hello+world");
    final AuthenticationContext ctx = org.jasig.cas.authentication.TestUtils
            .getAuthenticationContext(getAuthenticationSystemSupport(), svc);

    this.serviceValidateController.setProxyHandler(new Cas10ProxyHandler());
    final TicketGrantingTicket tId = getCentralAuthenticationService()
            .createTicketGrantingTicket(ctx);

    final ServiceTicket sId = getCentralAuthenticationService()
            .grantServiceTicket(tId.getId(), svc, ctx);

    final String reqSvc = "http://www.jasig.org?param=hello%20world";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("service", org.jasig.cas.authentication.TestUtils.getService(reqSvc).getId());
    request.addParameter("ticket", sId.getId());
    
    assertEquals(AbstractServiceValidateController.DEFAULT_SERVICE_SUCCESS_VIEW_NAME,
            this.serviceValidateController.handleRequestInternal(request,
                    new MockHttpServletResponse()).getViewName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:AbstractServiceValidateControllerTests.java

示例11: resolveUsername

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Override
public String resolveUsername(final Principal principal, final Service service) {
    String principalId = principal.getId();
    
    if (principal.getAttributes().containsKey(this.usernameAttribute)) {
        principalId = principal.getAttributes().get(this.usernameAttribute).toString();
    } else {
        logger.warn("Principal [{}] did not have attribute [{}] among attributes [{}] so CAS cannot "
                + "provide the user attribute the service expects. "
                + "CAS will instead return the default principal id [{}]",
                principalId,
                this.usernameAttribute,
                principal.getAttributes(),
                principalId);
    }
    
    logger.debug("Principal id to return is [{}]. The default principal id is [{}].",
            principalId, principal.getId());
    return principalId;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:PrincipalAttributeRegisteredServiceUsernameProvider.java

示例12: verifyMatchesExistingService

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyMatchesExistingService() {
    final RegisteredServiceImpl r = new RegisteredServiceImpl();
    r.setId(1000);
    r.setName("test");
    r.setServiceId("test");

    final Service service = new SimpleService("test");
    final Service service2 = new SimpleService("fdfa");

    this.defaultServicesManagerImpl.save(r);

    assertTrue(this.defaultServicesManagerImpl.matchesExistingService(service));
    assertEquals(r, this.defaultServicesManagerImpl.findServiceBy(service));
    assertNull(this.defaultServicesManagerImpl.findServiceBy(service2));
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:DefaultServicesManagerImplTests.java

示例13: encodeAttributes

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Override
public final Map<String, Object> encodeAttributes(final Map<String, Object> attributes,
                                                  final Service service) {
    logger.debug("Starting to encode attributes for release to service [{}]", service);
    final Map<String, Object> newEncodedAttributes = new HashMap<>(attributes);
    final Map<String, String> cachedAttributesToEncode = initialize(newEncodedAttributes);

    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    if (registeredService != null && registeredService.getAccessStrategy().isServiceAccessAllowed()) {
        encodeAttributesInternal(newEncodedAttributes, cachedAttributesToEncode,
                this.cipherExecutor, registeredService);
        logger.debug("[{}] Encoded attributes are available for release to [{}]",
                newEncodedAttributes.size(), service);
    } else {
        logger.debug("Service [{}] is not found and/or enabled in the service registry. "
                + "No encoding has taken place.", service);
    }

    return newEncodedAttributes;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:AbstractCasAttributeEncoder.java

示例14: ImmutableAssertion

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
/**
 * Creates a new instance with required parameters.
 *
 * @param primary Primary authentication.
 * @param chained Chained authentitications.
 * @param service The service we are asserting this ticket for.
 * @param fromNewLogin True if the ticket was issued as a result of authentication, false otherwise.
 *
 * @throws IllegalArgumentException If any of the given arguments do not meet requirements.
 */
public ImmutableAssertion(
        final Authentication primary,
        final List<Authentication> chained,
        final Service service,
        final boolean fromNewLogin) {

    Assert.notNull(primary, "primary authentication cannot be null");
    Assert.notNull(chained, "chained authentications cannot be null");
    Assert.notNull(service, "service cannot be null");
    Assert.notEmpty(chained, "chained authentications cannot be empty");

    this.primaryAuthentication = primary;
    this.chainedAuthentications = chained;
    this.service = service;
    this.fromNewLogin = fromNewLogin;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:27,代码来源:ImmutableAssertion.java

示例15: verifyValidateServiceTicketWithUsernameAttribute

import org.jasig.cas.authentication.principal.Service; //导入依赖的package包/类
@Test
public void verifyValidateServiceTicketWithUsernameAttribute() throws Exception {
    final UsernamePasswordCredential cred =  TestUtils.getCredentialsWithSameUsernameAndPassword();
    final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred);

    final Service svc = TestUtils.getService("eduPersonTest");
    final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc);

    final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc);
    assertEquals("developer", assertion.getPrimaryAuthentication().getPrincipal().getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:CentralAuthenticationServiceImplTests.java


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