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


Java OpenIdService类代码示例

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


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

示例1: verifyBadUsername

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void verifyBadUsername() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "fablah");
    request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");

    final OpenIdServiceFactory factory = new OpenIdServiceFactory();
    final OpenIdService service = factory.createService(request);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", "tgtId");

    context.setExternalContext(new ServletExternalContext(
            new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("error", this.action.execute(context).getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:OpenIdSingleSignOnActionTests.java

示例2: verifySuccessfulServiceTicket

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void verifySuccessfulServiceTicket() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final Authentication authentication = org.jasig.cas.authentication.TestUtils.getAuthentication("scootman28");
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication,
            new NeverExpiresExpirationPolicy());

    this.ticketRegistry.addTicket(t);

    request.setParameter(OpenIdProtocolConstants.OPENID_IDENTITY, "http://openid.aol.com/scootman28");
    request.setParameter(OpenIdProtocolConstants.OPENID_RETURNTO, "http://www.cnn.com");

    final OpenIdService service = new OpenIdServiceFactory().createService(request);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", t.getId());

    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("success", this.action.execute(context).getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:OpenIdSingleSignOnActionTests.java

示例3: setUp

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.ticketRegistry = new DefaultTicketRegistry();
    final OpenIdCredentialsAuthenticationHandler handler = new OpenIdCredentialsAuthenticationHandler();
    handler.setTicketRegistry(this.ticketRegistry);
    this.authenticationManager = new PolicyBasedAuthenticationManager(
            Collections.<AuthenticationHandler, PrincipalResolver>singletonMap(
                    handler,
                    new OpenIdPrincipalResolver()));

    final Map<String, UniqueTicketIdGenerator> generator = new HashMap<>();
    generator.put(OpenIdService.class.getName(), new DefaultUniqueTicketIdGenerator());

    impl = new CentralAuthenticationServiceImpl(this.ticketRegistry, null, this.authenticationManager,
            new DefaultUniqueTicketIdGenerator(), generator, new NeverExpiresExpirationPolicy(),
            new NeverExpiresExpirationPolicy(),
            new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()), mock(LogoutManager.class));

    this.action = new OpenIdSingleSignOnAction();
    this.action.setCentralAuthenticationService(this.impl);
    this.action.setExtractor(new DefaultOpenIdUserNameExtractor());
    this.action.afterPropertiesSet();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:24,代码来源:OpenIdSingleSignOnActionTests.java

示例4: verifyBadUsername

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void verifyBadUsername() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter(OpenIdConstants.OPENID_IDENTITY, "fablah");
    request.setParameter(OpenIdConstants.OPENID_RETURNTO, "http://www.cnn.com");

    final OpenIdService service = OpenIdService.createServiceFrom(request, null);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", "tgtId");

    context.setExternalContext(new ServletExternalContext(
            new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("error", this.action.execute(context).getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:OpenIdSingleSignOnActionTests.java

示例5: verifySuccessfulServiceTicket

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void verifySuccessfulServiceTicket() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final Authentication authentication = TestUtils.getAuthentication("scootman28");
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication,
            new NeverExpiresExpirationPolicy());

    this.ticketRegistry.addTicket(t);

    request.setParameter(OpenIdConstants.OPENID_IDENTITY, "http://openid.aol.com/scootman28");
    request.setParameter(OpenIdConstants.OPENID_RETURNTO, "http://www.cnn.com");

    final OpenIdService service = OpenIdService.createServiceFrom(request, null);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", t.getId());

    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("success", this.action.execute(context).getId());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:OpenIdSingleSignOnActionTests.java

示例6: constructCredentialsFromRequest

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    final String userName = this.extractor
            .extractLocalUsernameFromUri(context.getRequestParameters()
                    .get("openid.identity"));
    final Service service = WebUtils.getService(context);

    context.getExternalContext().getSessionMap().put("openIdLocalId", userName);

    // clear the service because otherwise we can fake the username
    if (service instanceof OpenIdService && userName == null) {
        context.getFlowScope().remove("service");
    }

    if (ticketGrantingTicketId == null || userName == null) {
        return null;
    }

    return new OpenIdCredential(
            ticketGrantingTicketId, userName);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:23,代码来源:OpenIdSingleSignOnAction.java

示例7: setUp

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.ticketRegistry = new DefaultTicketRegistry();
    final OpenIdCredentialsAuthenticationHandler handler = new OpenIdCredentialsAuthenticationHandler();
    handler.setTicketRegistry(this.ticketRegistry);
    this.authenticationManager = new PolicyBasedAuthenticationManager(
            Collections.<AuthenticationHandler, PrincipalResolver>singletonMap(
                    handler,
                    new OpenIdPrincipalResolver()));

    final Map<String, UniqueTicketIdGenerator> generator = new HashMap<String, UniqueTicketIdGenerator>();
    generator.put(OpenIdService.class.getName(), new DefaultUniqueTicketIdGenerator());

    impl = new CentralAuthenticationServiceImpl(this.ticketRegistry, null, this.authenticationManager,
            new DefaultUniqueTicketIdGenerator(), generator, new NeverExpiresExpirationPolicy(),
            new NeverExpiresExpirationPolicy(),
            new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()), mock(LogoutManager.class));

    this.action = new OpenIdSingleSignOnAction();
    this.action.setCentralAuthenticationService(this.impl);
    this.action.setExtractor(new DefaultOpenIdUserNameExtractor());
    this.action.afterPropertiesSet();
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:24,代码来源:OpenIdSingleSignOnActionTests.java

示例8: testBadUsername

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void testBadUsername() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("openid.identity", "fablah");
    request.setParameter("openid.return_to", "http://www.cnn.com");

    final OpenIdService service = OpenIdService.createServiceFrom(request);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", "tgtId");

    context.setExternalContext(new ServletExternalContext(
            new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("error", this.action.execute(context).getId());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:17,代码来源:OpenIdSingleSignOnActionTests.java

示例9: testSuccessfulServiceTicket

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Test
public void testSuccessfulServiceTicket() throws Exception {
    final MockRequestContext context = new MockRequestContext();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final Authentication authentication = TestUtils.getAuthentication("scootman28");
    final TicketGrantingTicket t = new TicketGrantingTicketImpl("TGT-11", authentication,
            new NeverExpiresExpirationPolicy());

    this.ticketRegistry.addTicket(t);

    request.setParameter("openid.identity", "http://openid.aol.com/scootman28");
    request.setParameter("openid.return_to", "http://www.cnn.com");

    final OpenIdService service = OpenIdService.createServiceFrom(request);
    context.getFlowScope().put("service", service);
    context.getFlowScope().put("ticketGrantingTicketId", t.getId());

    context.setExternalContext(new ServletExternalContext(new MockServletContext(), request,
            new MockHttpServletResponse()));
    assertEquals("success", this.action.execute(context).getId());
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:22,代码来源:OpenIdSingleSignOnActionTests.java

示例10: setUp

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.ticketRegistry = new DefaultTicketRegistry();
    final OpenIdCredentialsAuthenticationHandler handler = new OpenIdCredentialsAuthenticationHandler();
    handler.setTicketRegistry(this.ticketRegistry);
    this.authenticationManager = new PolicyBasedAuthenticationManager(
            Collections.<AuthenticationHandler, PrincipalResolver>singletonMap(
                    handler,
                    new OpenIdPrincipalResolver()));

    final Map<String, UniqueTicketIdGenerator> generator = new HashMap<>();
    generator.put(OpenIdService.class.getName(), new DefaultUniqueTicketIdGenerator());

    impl = new CentralAuthenticationServiceImpl(this.ticketRegistry, this.authenticationManager,
            new DefaultUniqueTicketIdGenerator(), generator, new NeverExpiresExpirationPolicy(),
            new NeverExpiresExpirationPolicy(),
            new DefaultServicesManagerImpl(new InMemoryServiceRegistryDaoImpl()), mock(LogoutManager.class));

    this.action = new OpenIdSingleSignOnAction();
    this.action.setCentralAuthenticationService(this.impl);
    this.action.setExtractor(new DefaultOpenIdUserNameExtractor());
    this.action.afterPropertiesSet();
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:24,代码来源:OpenIdSingleSignOnActionTests.java

示例11: constructCredentialsFromRequest

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    final String openidIdentityParameter = context.getRequestParameters().get(OpenIdProtocolConstants.OPENID_IDENTITY);
    String userName = null;
    if (OpenIdProtocolConstants.OPENID_IDENTIFIERSELECT.equals(openidIdentityParameter)) {
        userName = OpenIdProtocolConstants.OPENID_IDENTIFIERSELECT;
        context.getExternalContext().getSessionMap().remove(OpenIdProtocolConstants.OPENID_LOCALID);
        // already authenticated: retrieve the username from the authentication
        if (ticketGrantingTicketId != null) {
            try {
                final TicketGrantingTicket tgt = getCentralAuthenticationService()
                        .getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
                userName = tgt.getAuthentication().getPrincipal().getId();
            } catch (final InvalidTicketException e) {
                logger.error("Cannot get TGT", e);
            }
        }
    } else {
        userName = this.extractor.extractLocalUsernameFromUri(openidIdentityParameter);
        context.getExternalContext().getSessionMap().put(OpenIdProtocolConstants.OPENID_LOCALID, userName);
    }
    final Service service = WebUtils.getService(context);

    // clear the service because otherwise we can fake the username
    if (service instanceof OpenIdService && userName == null) {
        context.getFlowScope().remove("service");
    }

    if (ticketGrantingTicketId == null || userName == null) {
        return null;
    }

    return new OpenIdCredential(
            ticketGrantingTicketId, userName);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:37,代码来源:OpenIdSingleSignOnAction.java

示例12: constructCredentialsFromRequest

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final String ticketGrantingTicketId = WebUtils.getTicketGrantingTicketId(context);
    final String openidIdentityParameter = context.getRequestParameters().get(OpenIdConstants.OPENID_IDENTITY);
    String userName = null;
    if (OpenIdConstants.OPENID_IDENTIFIERSELECT.equals(openidIdentityParameter)) {
        userName = OpenIdConstants.OPENID_IDENTIFIERSELECT;
        context.getExternalContext().getSessionMap().remove(OpenIdConstants.OPENID_LOCALID);
        // already authenticated: retrieve the username from the authentication
        if (ticketGrantingTicketId != null) {
            try {
                final TicketGrantingTicket tgt = getCentralAuthenticationService()
                        .getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
                userName = tgt.getAuthentication().getPrincipal().getId();
            } catch (final InvalidTicketException e) {
                logger.error("Cannot get TGT", e);
            }
        }
    } else {
        userName = this.extractor.extractLocalUsernameFromUri(openidIdentityParameter);
        context.getExternalContext().getSessionMap().put(OpenIdConstants.OPENID_LOCALID, userName);
    }
    final Service service = WebUtils.getService(context);

    // clear the service because otherwise we can fake the username
    if (service instanceof OpenIdService && userName == null) {
        context.getFlowScope().remove("service");
    }

    if (ticketGrantingTicketId == null || userName == null) {
        return null;
    }

    return new OpenIdCredential(
            ticketGrantingTicketId, userName);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:37,代码来源:OpenIdSingleSignOnAction.java

示例13: initializeServletApplicationContext

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
protected void initializeServletApplicationContext() {
    addControllerToCasServletHandlerMapping(OpenIdProtocolConstants.ENDPOINT_OPENID, "openIdProviderController");
    addServiceTicketUniqueIdGenerator(OpenIdService.class.getCanonicalName(), this.serviceTicketUniqueIdGenerator);
    addServiceFactory(openIdServiceFactory);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:7,代码来源:OpenIdServletContextListener.java

示例14: extractServiceInternal

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
protected WebApplicationService extractServiceInternal(final HttpServletRequest request) {
    return OpenIdService.createServiceFrom(request, openIdPrefixUrl);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:5,代码来源:OpenIdArgumentExtractor.java

示例15: extractService

import org.jasig.cas.support.openid.authentication.principal.OpenIdService; //导入依赖的package包/类
@Override
public WebApplicationService extractService(final HttpServletRequest request) {
    return OpenIdService.createServiceFrom(request);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:5,代码来源:OpenIdArgumentExtractor.java


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