Package org.jasig.cas.authentication.principal

Examples of org.jasig.cas.authentication.principal.Principal


        assertTrue(credentials.toString().contains("unknown"));
    }
   
    public void testToStringWithPrincipal() {
        final SpnegoCredentials credentials = new SpnegoCredentials(new byte[] {});
        final Principal principal = new SimplePrincipal("test");
        credentials.setPrincipal(principal);
        assertEquals("test", credentials.toString());
    }
View Full Code Here


    public final Authentication authenticate(final Credentials credentials) throws AuthenticationException {

        final Pair<AuthenticationHandler, Principal> pair = authenticateAndObtainPrincipal(credentials);

        // we can only get here if the above method doesn't throw an exception. And if it doesn't, then the pair must not be null.
        final Principal p = pair.getSecond();
        log.info(String.format("Principal found: %s", p.getId()));

        if (log.isDebugEnabled()) {
            log.debug(String.format("Attribute map for %s: %s", p.getId(), p.getAttributes()));
        }

        Authentication authentication = new MutableAuthentication(p);

        if (pair.getFirst()instanceof NamedAuthenticationHandler) {
View Full Code Here

                continue;
            }

            foundOneThatWorks = true;
            if (authenticationHandler.authenticate(credentials)) {
                final Principal p = this.linkedHandlers.get(authenticationHandler).resolvePrincipal(credentials);
                return new Pair<AuthenticationHandler,Principal>(authenticationHandler, p);
            }
        }

        if (foundOneThatWorks) {
View Full Code Here

            final int authenticationChainSize = serviceTicket
                .getGrantingTicket().getChainedAuthentications().size();
            final Authentication authentication = serviceTicket
                .getGrantingTicket().getChainedAuthentications().get(
                    authenticationChainSize - 1);
            final Principal principal = authentication.getPrincipal();
            final String principalId = registeredService.isAnonymousAccess()
                ? this.persistentIdGenerator.generate(principal, serviceTicket
                    .getService()) : principal.getId();
               
            final Authentication authToUse;
           
            if (!registeredService.isIgnoreAttributes()) {
                final Map<String, Object> attributes = new HashMap<String, Object>();
   
                for (final String attribute : registeredService
                    .getAllowedAttributes()) {
                    final Object value = principal.getAttributes().get(
                        attribute);
   
                    if (value != null) {
                        attributes.put(attribute, value);
                    }
                }

                final Principal modifiedPrincipal = new SimplePrincipal(
                    principalId, attributes);
                final MutableAuthentication mutableAuthentication = new MutableAuthentication(
                    modifiedPrincipal, authentication.getAuthenticatedDate());
                mutableAuthentication.getAttributes().putAll(
                    authentication.getAttributes());
View Full Code Here

        if (!d.getAuthenticationHandler().authenticate(credentials)) {
            throw new BadCredentialsAuthenticationException();
        }

        final Principal p = d.getCredentialsToPrincipalResolver().resolvePrincipal(credentials);

        return new Pair<AuthenticationHandler,Principal>(d.getAuthenticationHandler(), p);
    }
View Full Code Here

        foundSupported = false;

        for (final CredentialsToPrincipalResolver credentialsToPrincipalResolver : this.credentialsToPrincipalResolvers) {
            if (credentialsToPrincipalResolver.supports(credentials)) {
                final Principal principal = credentialsToPrincipalResolver.resolvePrincipal(credentials);
                log.info("Resolved principal " + principal);
                foundSupported = true;
                if (principal != null) {
                    return new Pair<AuthenticationHandler,Principal>(authenticatedClass, principal);
                }
View Full Code Here

                jsonGenerator.writeStringField("error", OAuthConstants.EXPIRED_ACCESS_TOKEN);
                jsonGenerator.writeEndObject();
                return null;
            }
            // generate profile : identifier + attributes
            final Principal principal = ticketGrantingTicket.getAuthentication().getPrincipal();
            jsonGenerator.writeStartObject();
            jsonGenerator.writeStringField(ID, principal.getId());
            jsonGenerator.writeArrayFieldStart(ATTRIBUTES);
            final Map<String, Object> attributes = principal.getAttributes();
            for (final String key : attributes.keySet()) {
                jsonGenerator.writeStartObject();
                jsonGenerator.writeObjectField(key, attributes.get(key));
                jsonGenerator.writeEndObject();
            }
View Full Code Here

    private static final Logger logger = LoggerFactory.getLogger(LogPublishingCasServiceTicketValidatedEventListener.class);

    @Override
    public void onApplicationEvent(CasServiceTicketValidatedEvent event) {
        final Principal principal = Assertions.getAuthenticatedPrincipalFrom(event.getAssertion());
        logger.info("==================== RELEASED SERVICE ATTRIBUTES =============================");
        logger.info("Request is received from the following IP address: [{}]", ClientInfoHolder.getClientInfo().getClientIpAddress());
        logger.info("Service [{}] will receive the following attributes [{}] for the authenticated principal [{}]", event.getService().getId(), principal.getAttributes(), principal.getId());
        logger.info("==================== RELEASED SERVICE ATTRIBUTES (END) =============================");
    }
View Full Code Here

TOP

Related Classes of org.jasig.cas.authentication.principal.Principal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.