Package org.pac4j.http.credentials

Examples of org.pac4j.http.credentials.UsernamePasswordCredentials


    @Override
    protected UsernamePasswordCredentials retrieveCredentials(final WebContext context) throws RequiresHttpAction {
        final String username = context.getRequestParameter(this.usernameParameter);
        final String password = context.getRequestParameter(this.passwordParameter);
        if (CommonHelper.isNotBlank(username) && CommonHelper.isNotBlank(password)) {
            final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password,
                                                                                            getName());
            logger.debug("usernamePasswordCredentials : {}", credentials);
            try {
                // validate credentials
                this.usernamePasswordAuthenticator.validate(credentials);
View Full Code Here


        final int delim = token.indexOf(":");
        if (delim < 0) {
            throw new CredentialsException("Bad format of the basic auth header");
        }
        final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(token.substring(0, delim),
                token.substring(delim + 1), getName());
        logger.debug("usernamePasswordCredentials : {}", credentials);
        try {
            // validate credentials
            this.usernamePasswordAuthenticator.validate(credentials);
View Full Code Here

    }
   
    public void testGetCredentialsGoodCredentials() throws RequiresHttpAction {
        final BasicAuthClient basicAuthClient = getBasicAuthClient();
        final String header = USERNAME + ":" + USERNAME;
        final UsernamePasswordCredentials credentials = basicAuthClient.getCredentials(MockWebContext.create()
            .addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
                              "Basic " + Base64.encodeBase64String(header.getBytes())));
        assertEquals(USERNAME, credentials.getUsername());
        assertEquals(USERNAME, credentials.getPassword());
    }
View Full Code Here

        }
    }
   
    public void testGetRightCredentials() throws RequiresHttpAction {
        final FormClient formClient = getFormClient();
        final UsernamePasswordCredentials credentials = formClient.getCredentials(MockWebContext.create()
            .addRequestParameter(formClient.getUsernameParameter(), USERNAME)
            .addRequestParameter(formClient.getPasswordParameter(), USERNAME));
        assertEquals(USERNAME, credentials.getUsername());
        assertEquals(USERNAME, credentials.getPassword());
    }
View Full Code Here

    }
   
    public void testGetUserProfile() {
        final FormClient formClient = getFormClient();
        final MockWebContext context = MockWebContext.create();
        final HttpProfile profile = formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, USERNAME,
                                                                                              formClient.getName()),
                                                              context);
        assertEquals(USERNAME, profile.getId());
        assertEquals(HttpProfile.class.getSimpleName() + UserProfile.SEPARATOR + USERNAME, profile.getTypedId());
        assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), HttpProfile.class));
View Full Code Here

TOP

Related Classes of org.pac4j.http.credentials.UsernamePasswordCredentials

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.