registeredservicevalidator.java
来自「CAS在Tomcat中实现单点登录项目,单点登录(Single Sign On 」· Java 代码 · 共 76 行
JAVA
76 行
/* * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license * distributed with this file and available online at * http://www.uportal.org/license.html */package org.jasig.cas.services.web.support;import org.jasig.cas.services.RegisteredService;import org.jasig.cas.services.RegisteredServiceImpl;import org.jasig.cas.services.ServicesManager;import org.jasig.cas.util.annotation.GreaterThan;import org.jasig.cas.util.annotation.NotNull;import org.springframework.validation.Errors;import org.springframework.validation.Validator;/** * RegisteredServiceValidator ensures that a new RegisteredService does not have * a conflicting Service Id with another service already in the registry. * * @author Scott Battaglia * @version $Revision: 42053 $ $Date: 2007-06-10 09:17:55 -0400 (Sun, 10 Jun 2007) $ * @since 3.1 */public final class RegisteredServiceValidator implements Validator { /** Default length, which matches what is in the view. */ private static final int DEFAULT_MAX_DESCRIPTION_LENGTH = 300; /** ServiceRegistry to look up services. */ @NotNull private ServicesManager servicesManager; /** The maximum length of the description we will accept. */ @GreaterThan(0) private int maxDescriptionLength = DEFAULT_MAX_DESCRIPTION_LENGTH; /** * Supports the RegisteredServiceImpl. * * @see org.springframework.validation.Validator#supports(java.lang.Class) */ public boolean supports(final Class clazz) { return RegisteredServiceImpl.class.equals(clazz); } public void validate(final Object o, final Errors errors) { final RegisteredService r = (RegisteredService) o; if (r.getServiceId() != null) { for (final RegisteredService service : this.servicesManager .getAllServices()) { if (r.getServiceId().equals(service.getServiceId()) && r.getId() != service.getId()) { errors.rejectValue("serviceId", "registeredService.serviceId.exists", null); break; } } } if (r.getDescription() != null && r.getDescription().length() > this.maxDescriptionLength) { errors.rejectValue("description", "registeredService.description.length", null); } } public void setServicesManager(final ServicesManager serviceRegistry) { this.servicesManager = serviceRegistry; } public void setMaxDescriptionLength(final int maxLength) { this.maxDescriptionLength = maxLength; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?