admin 管理员组

文章数量: 887021


2024年2月7日发(作者:哪里找免费网站)

public class CasRealm extends AuthorizingRealm{ public CasRealm() { validationProtocol = "CAS"; rememberMeAttributeName = "longTermAuthenticationRequestTokenUsed"; setAuthenticationTokenClass(org/apache/shiro/cas/CasToken); } protected void onInit() { (); ensureTicketValidator(); } protected TicketValidator ensureTicketValidator() { if(ticketValidator == null) ticketValidator = createTicketValidator(); return ticketValidator; } protected TicketValidator createTicketValidator() { String urlPrefix = getCasServerUrlPrefix(); if("saml".equalsIgnoreCase(getValidationProtocol())) return new Saml11TicketValidator(urlPrefix); else return new Cas20ServiceTicketValidator(urlPrefix); } protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { CasToken casToken = (CasToken)token; if(token == null) return null; String ticket = (String)dentials(); if(!t(ticket)) return null; TicketValidator ticketValidator = ensureTicketValidator(); try { Assertion casAssertion = te(ticket, getCasService()); AttributePrincipal casPrincipal = ncipal(); String userId = e(); ("Validate ticket : {} in CAS server : {} to retrieve user : {}", new Object[] { ticket, getCasServerUrlPrefix(), userId }); Map attributes = ributes(); rId(userId); String rememberMeAttributeName = getRememberMeAttributeName(); String rememberMeStringValue = (String)(rememberMeAttributeName); boolean isRemembered = rememberMeStringValue != null && oolean(rememberMeStringValue); if(isRemembered) emberMe(true); List principals = (new Object[] { userId, attributes }); PrincipalCollection principalCollection = new SimplePrincipalCollection(principals, getName()); return new SimpleAuthenticationInfo(principalCollection, ticket); } catch(TicketValidationException e) { throw new CasAuthenticationException((new StringBuilder()).append("Unable to validate ticket [").append(ticket).append("]").toString(), e);

throw new CasAuthenticationException((new StringBuilder()).append("Unable to validate ticket [").append(ticket).append("]").toString(), e); } } protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { SimplePrincipalCollection principalCollection = (SimplePrincipalCollection)principals; List listPrincipals = (); Map attributes = (Map)(1); SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(); addRoles(simpleAuthorizationInfo, split(defaultRoles)); addPermissions(simpleAuthorizationInfo, split(defaultPermissions)); List attributeNames = split(roleAttributeNames); String value; for(Iterator i$ = or(); i$.hasNext(); addRoles(simpleAuthorizationInfo, split(value))) { String attributeName = (String)i$.next(); value = (String)(attributeName); } attributeNames = split(permissionAttributeNames); String value; for(Iterator i$ = or(); i$.hasNext(); addPermissions(simpleAuthorizationInfo, split(value))) { String attributeName = (String)i$.next(); value = (String)(attributeName); } return simpleAuthorizationInfo; } private List split(String s) { List list = new ArrayList(); String elements[] = (s, ','); if(elements != null && > 0) { String arr$[] = elements; int len$ = arr$.length; for(int i$ = 0; i$ < len$; i$++) { String element = arr$[i$]; if(t(element)) (()); } } return list; } private void addRoles(SimpleAuthorizationInfo simpleAuthorizationInfo, List roles) { String role; for(Iterator i$ = or(); i$.hasNext(); e(role)) role = (String)i$.next(); } private void addPermissions(SimpleAuthorizationInfo simpleAuthorizationInfo, List permissions) { String permission; for(Iterator i$ = or(); i$.hasNext(); ingPermission(permission)) permission = (String)i$.next(); }

public String getCasServerUrlPrefix() { return casServerUrlPrefix; } public void setCasServerUrlPrefix(String casServerUrlPrefix) { verUrlPrefix = casServerUrlPrefix; } public String getCasService() { return casService; } public void setCasService(String casService) { vice = casService; } public String getValidationProtocol() { return validationProtocol; } public void setValidationProtocol(String validationProtocol) { tionProtocol = validationProtocol; } public String getRememberMeAttributeName() { return rememberMeAttributeName; } public void setRememberMeAttributeName(String rememberMeAttributeName) { erMeAttributeName = rememberMeAttributeName; } public String getDefaultRoles() { return defaultRoles; } public void setDefaultRoles(String defaultRoles) { tRoles = defaultRoles; } public String getDefaultPermissions() { return defaultPermissions; } public void setDefaultPermissions(String defaultPermissions) { tPermissions = defaultPermissions; } public String getRoleAttributeNames() { return roleAttributeNames; }


本文标签: 网站 免费 作者