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


Java RegisteredService类代码示例

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


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

示例1: decideAttributeReleaseBasedOnServiceAttributePolicy

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Decide attribute release based on service attribute policy.
 *
 * @param attributes the attributes
 * @param attributeValue the attribute value
 * @param attributeName the attribute name
 * @param service the service
 * @param doesAttributePolicyAllow does attribute policy allow release of this attribute?
 */
protected void decideAttributeReleaseBasedOnServiceAttributePolicy(final Map<String, Object> attributes,
                                                                   final String attributeValue,
                                                                   final String attributeName,
                                                                   final RegisteredService service,
                                                                   final boolean doesAttributePolicyAllow) {
    if (StringUtils.isNotBlank(attributeValue)) {
        logger.debug("Obtained [{}] as an authentication attribute", attributeName);

        if (doesAttributePolicyAllow) {
            logger.debug("Obtained [{}] is passed to the CAS validation payload", attributeName);
            attributes.put(attributeName, Collections.singleton(attributeValue));
        } else {
            logger.debug("Attribute release policy for [{}] does not authorize the release of [{}]",
                    service.getServiceId(), attributeName);
            attributes.remove(attributeName);
        }
    } else {
        logger.trace("[{}] is not available and will not be released to the validation response.", attributeName);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:AbstractCasView.java

示例2: checkSaveMethod

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Test
public void checkSaveMethod() {
    final OAuthRegisteredService r = new OAuthRegisteredService();
    r.setName("checkSaveMethod");
    r.setServiceId("testId");
    r.setTheme("theme");
    r.setDescription("description");
    r.setClientId("clientid");
    r.setServiceId("secret");
    r.setBypassApprovalPrompt(true);
    final RegisteredService r2 = this.dao.save(r);
    assertTrue(r2 instanceof OAuthRegisteredService);
    this.dao.load();
    final RegisteredService r3 = this.dao.findServiceById(r2.getId());
    assertTrue(r3 instanceof OAuthRegisteredService);
    assertEquals(r, r2);
    assertEquals(r2, r3);
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:19,代码来源:OAuthRegisteredServiceTests.java

示例3: encodeAttributes

import org.jasig.cas.services.RegisteredService; //导入依赖的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

示例4: encryptAndEncodeAndPutIntoAttributesMap

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Encrypt, encode and put the attribute into attributes map.
 *
 * @param attributes the attributes
 * @param cachedAttributesToEncode the cached attributes to encode
 * @param cachedAttributeName the cached attribute name
 * @param cipher the cipher
 * @param registeredService the registered service
 */
protected final void encryptAndEncodeAndPutIntoAttributesMap(final Map<String, Object> attributes,
                                                       final Map<String, String> cachedAttributesToEncode,
                                                       final String cachedAttributeName,
                                                       final RegisteredServiceCipherExecutor cipher,
                                                       final RegisteredService registeredService) {
    final String cachedAttribute = cachedAttributesToEncode.remove(cachedAttributeName);
    if (StringUtils.isNotBlank(cachedAttribute)) {
        logger.debug("Retrieved [{}] as a cached model attribute...", cachedAttributeName);
        final String encodedValue = cipher.encode(cachedAttribute, registeredService);
        if (StringUtils.isNotBlank(encodedValue)) {
            attributes.put(cachedAttributeName, encodedValue);
            logger.debug("Encrypted and encoded [{}] as an attribute to [{}].",
                    cachedAttributeName, encodedValue);
        }
    } else {
        logger.debug("[{}] is not available as a cached model attribute to encrypt...", cachedAttributeName);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:28,代码来源:DefaultCasAttributeEncoder.java

示例5: setUpMocks

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Before
public void setUpMocks() {
    final RegisteredServiceImpl authorizedRegisteredService = new RegisteredServiceImpl();
    final RegisteredServiceImpl unauthorizedRegisteredService = new RegisteredServiceImpl();
    unauthorizedRegisteredService.setAccessStrategy(
            new DefaultRegisteredServiceAccessStrategy(false, false));

    final List<RegisteredService> list = new ArrayList<>();
    list.add(authorizedRegisteredService);
    list.add(unauthorizedRegisteredService);
    
    when(this.servicesManager.findServiceBy(this.authorizedService)).thenReturn(authorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.unauthorizedService)).thenReturn(unauthorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.undefinedService)).thenReturn(null);
    
    when(this.servicesManager.getAllServices()).thenReturn(list);
    
    this.serviceAuthorizationCheck = new ServiceAuthorizationCheck(this.servicesManager);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:20,代码来源:ServiceAuthorizationCheckTests.java

示例6: isAuthenticationRenewed

import org.jasig.cas.services.RegisteredService; //导入依赖的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

示例7: setUpMocks

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Before
public void setUpMocks() {
    RegisteredServiceImpl authorizedRegisteredService = new RegisteredServiceImpl();
    RegisteredServiceImpl unauthorizedRegisteredService = new RegisteredServiceImpl();
    unauthorizedRegisteredService.setEnabled(false);

    List<RegisteredService> list = new ArrayList<RegisteredService>();
    list.add(authorizedRegisteredService);
    list.add(unauthorizedRegisteredService);
    
    when(this.servicesManager.findServiceBy(this.authorizedService)).thenReturn(authorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.unauthorizedService)).thenReturn(unauthorizedRegisteredService);
    when(this.servicesManager.findServiceBy(this.undefinedService)).thenReturn(null);
    
    when(this.servicesManager.getAllServices()).thenReturn(list);
    
    this.serviceAuthorizationCheck = new ServiceAuthorizationCheck(this.servicesManager);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:19,代码来源:ServiceAuthorizationCheckTests.java

示例8: verifyAddMockRegisteredService

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Test
public void verifyAddMockRegisteredService() throws Exception {
    registeredServiceFactory.setRegisteredServiceMapper(new MockRegisteredServiceMapper());

    final MockRegisteredService svc = new MockRegisteredService();
    svc.setDescription("description");
    svc.setServiceId("^serviceId");
    svc.setName("name");
    svc.setId(1000);
    svc.setEvaluationOrder(1000);

    final RegisteredServiceEditBean.ServiceData data = registeredServiceFactory.createServiceData(svc);
    this.controller.saveService(new MockHttpServletRequest(),
            new MockHttpServletResponse(),
            data, mock(BindingResult.class));

    final Collection<RegisteredService> services = this.manager.getAllServices();
    assertEquals(1, services.size());
    for (final  RegisteredService rs : this.manager.getAllServices()) {
        assertTrue(rs instanceof MockRegisteredService);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:23,代码来源:RegisteredServiceSimpleFormControllerTests.java

示例9: save

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Override
public RegisteredService save(final RegisteredService rs) {
    if (this.ldapServiceMapper != null) {
        if (rs.getId() != RegisteredService.INITIAL_IDENTIFIER_VALUE) {
            return update(rs);
        }

        try {
            final LdapEntry entry = this.ldapServiceMapper.mapFromRegisteredService(this.baseDn, rs);
            LdapUtils.executeAddOperation(this.connectionFactory, entry);
        } catch (final LdapException e) {
            logger.error(e.getMessage(), e);
        }
        return rs;
    }
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:LdapServiceRegistryDao.java

示例10: verifyLogoutUrlForServiceIsUsed

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
@Test
public void verifyLogoutUrlForServiceIsUsed() throws Exception {
    final RegisteredService svc = getRegisteredService();
    when(this.servicesManager.findServiceBy(any(SingleLogoutService.class))).thenReturn(svc);

    final SingleLogoutService service = mock(SingleLogoutService.class);
    when(service.getId()).thenReturn(svc.getServiceId());
    when(service.getOriginalUrl()).thenReturn(svc.getServiceId());

    final MockTicketGrantingTicket tgt = new MockTicketGrantingTicket("test");
    tgt.getServices().put("service", service);
    final Event event = getLogoutEvent(this.logoutManager.performLogout(tgt));
    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(svc.getLogoutUrl().toExternalForm()));

}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:20,代码来源:FrontChannelLogoutActionTests.java

示例11: initializeCipherBasedOnServicePublicKey

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Initialize cipher based on service public key.
 *
 * @param publicKey the public key
 * @param registeredService the registered service
 * @return the false if no public key is found
 * or if cipher cannot be initialized, etc.
 */
private Cipher initializeCipherBasedOnServicePublicKey(final PublicKey publicKey,
                                                       final RegisteredService registeredService) {
    try {
        logger.debug("Using public key [{}] to initialize the cipher",
                registeredService.getPublicKey());

        final Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm());
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        logger.debug("Initialized cipher in encrypt-mode via the public key algorithm [{}]",
                publicKey.getAlgorithm());
        return cipher;
    } catch (final Exception e) {
        logger.warn("Cipher could not be initialized for service [{}]. Error [{}]",
                registeredService, e.getMessage());
    }
    return null;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:26,代码来源:DefaultRegisteredServiceCipherExecutor.java

示例12: updateRegisteredServiceEvaluationOrder

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Updates the {@link RegisteredService#getEvaluationOrder()}.
 *
 * @param response the response
 * @param id the service ids, whose order also determines the service evaluation order
 */
@RequestMapping(value="updateRegisteredServiceEvaluationOrder.html", method={RequestMethod.POST})
public void updateRegisteredServiceEvaluationOrder(final HttpServletResponse response,
                                                   @RequestParam("id") final long... id) {
    if (id == null || id.length == 0) {
        throw new IllegalArgumentException("No service id was received. Re-examine the request");
    }
    for (int i = 0; i < id.length; i++) {
        final long svcId = id[i];
        final RegisteredService svc = this.servicesManager.findServiceBy(svcId);
        if (svc == null) {
            throw new IllegalArgumentException("Service id " + svcId + " cannot be found.");
        }
        svc.setEvaluationOrder(i);
        this.servicesManager.save(svc);
    }
    final Map<String, Object> model = new HashMap<>();
    model.put("status", HttpServletResponse.SC_OK);
    JsonViewUtils.render(model, response);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:26,代码来源:ManageRegisteredServicesMultiActionController.java

示例13: getRegexRegisteredService

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
private static RegisteredService getRegexRegisteredService() {
    final AbstractRegisteredService rs  = new RegexRegisteredService();
    rs.setName("Service Name Regex");
    rs.setProxyPolicy(new RefuseRegisteredServiceProxyPolicy());
    rs.setUsernameAttributeProvider(new AnonymousRegisteredServiceUsernameAttributeProvider(
            new ShibbolethCompatiblePersistentIdGenerator("hello")
    ));
    rs.setDescription("Service description");
    rs.setServiceId("^http?://.+");
    rs.setTheme("the theme name");
    rs.setEvaluationOrder(123);
    rs.setDescription("Here is another description");
    rs.setRequiredHandlers(new HashSet<>(Arrays.asList("handler1", "handler2")));

    final Map<String, RegisteredServiceProperty> propertyMap = new HashMap();
    final DefaultRegisteredServiceProperty property = new DefaultRegisteredServiceProperty();

    final Set<String> values = new HashSet<>();
    values.add("value1");
    values.add("value2");
    property.setValues(values);
    propertyMap.put("field1", property);
    rs.setProperties(propertyMap);

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

示例14: getServiceById

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Gets service by id.
 *
 * @param id       the id
 * @param request  the request
 * @param response the response
 */
@RequestMapping(method = RequestMethod.GET, value = {"getService.html"})
public void getServiceById(@RequestParam(value = "id", required = false) final Long id,
                           final HttpServletRequest request, final HttpServletResponse response) {

    try {
        final RegisteredServiceEditBean bean = new RegisteredServiceEditBean();
        if (id == -1) {
            bean.setServiceData(null);
        } else {
            final RegisteredService service = this.servicesManager.findServiceBy(id);

            if (service == null) {
                logger.warn("Invalid service id specified [{}]. Cannot find service in the registry", id);
                throw new IllegalArgumentException("Service id " + id + " cannot be found");
            }
            bean.setServiceData(registeredServiceFactory.createServiceData(service));
        }
        bean.setFormData(registeredServiceFactory.createFormData());

        bean.setStatus(HttpServletResponse.SC_OK);
        JsonViewUtils.render(bean, response);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:RegisteredServiceSimpleFormController.java

示例15: determineLogoutUrl

import org.jasig.cas.services.RegisteredService; //导入依赖的package包/类
/**
 * Determine logout url.
 *
 * @param registeredService the registered service
 * @param singleLogoutService the single logout service
 * @return the uRL
 */
private URL determineLogoutUrl(final RegisteredService registeredService, final SingleLogoutService singleLogoutService) {
    try {
        URL logoutUrl = new URL(singleLogoutService.getOriginalUrl());
        final URL serviceLogoutUrl = registeredService.getLogoutUrl();

        if (serviceLogoutUrl != null) {
            LOGGER.debug("Logout request will be sent to [{}] for service [{}]",
                    serviceLogoutUrl, singleLogoutService);
            logoutUrl = serviceLogoutUrl;
        }
        return logoutUrl;
    } catch (final Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:23,代码来源:LogoutManagerImpl.java


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