List of usage examples for org.springframework.security.cas.authentication CasAuthenticationToken getName
public String getName()
From source file:com.vnomicscorp.spring.security.cas.authentication.redis.DefaultCasAuthenticationTokenSerializerTest.java
private void assertTokenEquals(CasAuthenticationToken expected, CasAuthenticationToken got) { assertEquals(expected.getName(), got.getName()); assertEquals(expected.isAuthenticated(), got.isAuthenticated()); assertEquals(expected.getAuthorities(), got.getAuthorities()); assertEquals(expected.getCredentials(), got.getCredentials()); assertEquals(expected.getDetails(), got.getDetails()); assertEquals(expected.getKeyHash(), got.getKeyHash()); assertEquals(expected.getPrincipal(), got.getPrincipal()); assertEquals(expected.getUserDetails(), got.getUserDetails()); }
From source file:eu.trentorise.smartcampus.permissionprovider.authority.CASAuthorityHandler.java
@SuppressWarnings("unchecked") @Override/*from w w w. ja v a2 s . c o m*/ public Map<String, String> extractAttributes(HttpServletRequest request, Map<String, String> map, AuthorityMapping mapping) { Map<String, String> attrs = new HashMap<String, String>(); CasAuthenticationToken token = (CasAuthenticationToken) SecurityContextHolder.getContext() .getAuthentication(); String username = token.getName(); Map<String, Object> tokenAttrs = token.getAssertion().getAttributes(); if (tokenAttrs == null) { tokenAttrs = new HashMap<String, Object>(); } tokenAttrs.put(USERNAME, username); for (String key : mapping.getIdentifyingAttributes()) { Object value = readAttribute(key, tokenAttrs); if (value != null) { attrs.put(key, value.toString()); } } for (Attributes attribute : mapping.getAttributes()) { // used alias if present to set attribute in map String key = (attribute.getAlias() != null && !attribute.getAlias().isEmpty()) ? attribute.getAlias() : attribute.getValue(); Object value = readAttribute(attribute.getValue(), tokenAttrs); if (value != null) { attrs.put(key, value.toString()); } } return attrs; }
From source file:org.jasig.cas.support.pac4j.web.flow.ClientLogoutAction.java
private void logAuthentication(Authentication authentication) { org.jasig.cas.authentication.principal.SimplePrincipal principal = (SimplePrincipal) authentication .getPrincipal();/* w w w . j av a2 s . c om*/ Map<String, Object> attributes = authentication.getAttributes(); Map<String, Object> pattributes = principal.getAttributes(); for (Map.Entry<String, Object> entry : pattributes.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); System.out.println("p attributes" + key + " a value " + value.getClass()); //CasAuthenticationToken } logger.debug("=========================================="); logger.debug("ClientLogoutAction CAS Authentication: "); logger.debug("principal.getId(): " + principal.getId()); for (Map.Entry<String, Object> entry : attributes.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); logger.debug("authentication.attributes key: " + key + " value: " + value); } for (Map.Entry<String, Object> entry : pattributes.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); logger.debug("principal.attributes key: " + key); if (value instanceof CasAuthenticationToken) { CasAuthenticationToken casAuthenticationToken = (CasAuthenticationToken) value; logger.debug("principal.casAuthenticationToken.getName: " + casAuthenticationToken.getName()); logger.debug("principal.casAuthenticationToken.getName: " + casAuthenticationToken.getCredentials().getClass()); } } logger.debug("=========================================="); }