📄 baseauthmodule.java
字号:
package org.gridsphere.services.core.security.auth.modules.impl;import org.gridsphere.portlet.service.spi.impl.descriptor.ConfigParam;import org.gridsphere.portlet.service.spi.impl.descriptor.Description;import org.gridsphere.services.core.security.auth.modules.LoginAuthModule;import org.gridsphere.services.core.security.auth.modules.impl.descriptor.AuthModuleDefinition;import javax.servlet.http.HttpServletRequest;import java.util.*;/** * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a> * @version $Id: BaseAuthModule.java 5032 2006-08-17 18:15:06Z novotny $ */public abstract class BaseAuthModule implements LoginAuthModule, Comparable { protected Map attributes = new HashMap(); protected AuthModuleDefinition moduleDef = null; protected HttpServletRequest request = null; public BaseAuthModule(AuthModuleDefinition moduleDef) { this.moduleDef = moduleDef; List configList = moduleDef.getConfigParamList(); Iterator it = configList.iterator(); while (it.hasNext()) { ConfigParam param = (ConfigParam)it.next(); attributes.put(param.getParamName(), param.getParamValue()); } } public void setHttpServletRequest(HttpServletRequest request) { this.request = request; } public String getAttribute(String name) { return (String) attributes.get(name); } public Map getAttributes() { return attributes; } public void setAttributes(Map attributes) { this.attributes = attributes; } public String getModuleName() { return moduleDef.getModuleName(); } public String getModuleError(String key, Locale locale) { List modErrs = moduleDef.getModuleErrors(); if (locale == null) throw new IllegalArgumentException("locale is NULL"); Iterator it = modErrs.iterator(); String defTitle = null; while (it.hasNext()) { Description t = (Description) it.next(); if (t.getKey().equals(key)) { if (t.getLang() == null) t.setLang(Locale.ENGLISH.getLanguage()); if (locale.getLanguage().equals(new Locale(t.getLang(), "", "").getLanguage())) return t.getText(); if (t.getLang().equals(Locale.ENGLISH.getLanguage())) defTitle = t.getText(); } } return defTitle; } public String getModuleDescription(Locale locale) { List modDescs = moduleDef.getModuleDescriptions(); if (locale == null) throw new IllegalArgumentException("locale is NULL"); Iterator it = modDescs.iterator(); String defTitle = ""; while (it.hasNext()) { Description t = (Description) it.next(); if (t.getLang() == null) t.setLang(Locale.ENGLISH.getLanguage()); if (locale.getLanguage().equals(new Locale(t.getLang(), "", "").getLanguage())) return t.getText(); if (t.getLang().equals(Locale.ENGLISH.getLanguage())) defTitle = t.getText(); } return defTitle; } public int getModulePriority() { return moduleDef.getModulePriority(); } public void setModulePriority(int priority) { moduleDef.setModulePriority(priority); } public boolean isModuleActive() { return moduleDef.getModuleActive(); } public void setModuleActive(boolean active) { moduleDef.setModuleActive(active); } public int compareTo(Object obj) { if ((obj != null) && (obj instanceof LoginAuthModule)) { LoginAuthModule l = (LoginAuthModule) obj; if (this.moduleDef.getModulePriority() < l.getModulePriority()) { return -1; } else if (this.moduleDef.getModulePriority() > l.getModulePriority()) { return 1; } else { return 0; } } throw new ClassCastException("Unable to compare supplied object to this module"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -