Package org.restlet.data

Examples of org.restlet.data.AuthenticationInfo


                    List<ChallengeRequest> crs = org.restlet.engine.security.AuthenticatorUtils
                            .parseRequest(response, header.getValue(), headers);
                    response.getProxyChallengeRequests().addAll(crs);
                } else if (header.getName().equalsIgnoreCase(
                        HeaderConstants.HEADER_AUTHENTICATION_INFO)) {
                    AuthenticationInfo authenticationInfo = org.restlet.engine.security.AuthenticatorUtils
                            .parseAuthenticationInfo(header.getValue());
                    response.setAuthenticationInfo(authenticationInfo);
                } else if (header.getName().equalsIgnoreCase(
                        HeaderConstants.HEADER_SERVER)) {
                    response.getServerInfo().setAgent(header.getValue());
View Full Code Here


     *            The header value to parse.
     * @return The equivalent {@link AuthenticationInfo} instance.
     * @throws IOException
     */
    public static AuthenticationInfo parseAuthenticationInfo(String header) {
        AuthenticationInfo result = null;
        ParameterReader hr = new ParameterReader(header);

        try {
            String nextNonce = null;
            String qop = null;
            String responseAuth = null;
            String cnonce = null;
            int nonceCount = 0;
            Parameter param = hr.readValue();

            while (param != null) {
                try {
                    if ("nextnonce".equals(param.getName())) {
                        nextNonce = param.getValue();
                    } else if ("qop".equals(param.getName())) {
                        qop = param.getValue();
                    } else if ("rspauth".equals(param.getName())) {
                        responseAuth = param.getValue();
                    } else if ("cnonce".equals(param.getName())) {
                        cnonce = param.getValue();
                    } else if ("nc".equals(param.getName())) {
                        nonceCount = Integer.parseInt(param.getValue(), 16);
                    }

                    if (hr.skipValueSeparator()) {
                        param = hr.readValue();
                    } else {
                        param = null;
                    }
                } catch (Exception e) {
                    Context.getCurrentLogger()
                            .log(Level.WARNING,
                                    "Unable to parse the authentication info header parameter",
                                    e);
                }
            }

            result = new AuthenticationInfo(nextNonce, nonceCount, cnonce, qop,
                    responseAuth);
        } catch (IOException e) {
            Context.getCurrentLogger()
                    .log(Level.WARNING,
                            "Unable to parse the authentication info header: "
View Full Code Here

public class AuthenticationInfoTestCase extends RestletTestCase {
    /**
     * Test parsing an Authorization-Info header string.
     */
    public void testAuthenticaitonInfoHeaderParse() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("00000002", 1,
                "MDAzMTAw1", "auth", null);
        String authInfoHeader = new String(
                "nc=00000001, qop=auth, cnonce=\"MDAzMTAw1\", nextnonce=00000002");
        AuthenticationInfo parsedAuthInfo = AuthenticatorUtils
                .parseAuthenticationInfo(authInfoHeader);
        assertTrue(authInfo.equals(parsedAuthInfo));
        assertTrue(parsedAuthInfo.equals(authInfo));
    }
View Full Code Here

    /**
     * Test cnonce getting/setting.
     */
    public void testCnonce() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("testnonce",
                1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo.getClientNonce(), "testcnonce");
        String newCnonce = new String("newcnonce");
        authInfo.setClientNonce(newCnonce);
        assertEquals(authInfo.getClientNonce(), "newcnonce");
    }
View Full Code Here

    /**
     * Equality tests.
     */
    public void testEquals() throws Exception {
        final AuthenticationInfo authInfo1 = new AuthenticationInfo(
                "testnonce", 1111111, "testcnonce", "auth", "FFFFFF");
        final AuthenticationInfo authInfo2 = new AuthenticationInfo(
                "testnonce", 1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo1, authInfo2);
        assertTrue(authInfo1.equals(authInfo2));
    }
View Full Code Here

    /**
     * Test nextnonce getting/setting.
     */
    public void testNextNonce() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("testnonce",
                1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo.getNextServerNonce(), "testnonce");
        String newNonce = new String("newnonce");
        authInfo.setNextServerNonce(newNonce);
        assertEquals(authInfo.getNextServerNonce(), "newnonce");
    }
View Full Code Here

    /**
     * Test nonce-count getting/setting.
     */
    public void testNonceCount() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("testnonce",
                1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo.getNonceCount(), 1111111);
        int newNonceCount = 2222222;
        authInfo.setNonceCount(newNonceCount);
        assertEquals(authInfo.getNonceCount(), 2222222);
    }
View Full Code Here

    /**
     * Test message-qop getting/setting.
     */
    public void testQop() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("testnonce",
                1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo.getQuality(), "auth");
        String newQop = new String("auth-int");
        authInfo.setQuality(newQop);
        assertEquals(authInfo.getQuality(), "auth-int");
    }
View Full Code Here

    /**
     * Test response-auth getting/setting.
     */
    public void testResponseAuth() throws Exception {
        AuthenticationInfo authInfo = new AuthenticationInfo("testnonce",
                1111111, "testcnonce", "auth", "FFFFFF");
        assertEquals(authInfo.getResponseDigest(), "FFFFFF");
        String newResponseAuth = new String("000000");
        authInfo.setResponseDigest(newResponseAuth);
        assertEquals(authInfo.getResponseDigest(), "000000");
    }
View Full Code Here

        authInfo.setResponseDigest(newResponseAuth);
        assertEquals(authInfo.getResponseDigest(), "000000");
    }

    public void testUnEquals() throws Exception {
        final AuthenticationInfo authInfo1 = new AuthenticationInfo(
                "testnonce1", 1111111, "testcnonce1", "auth", "FFFFFF");
        final AuthenticationInfo authInfo2 = new AuthenticationInfo(
                "testnonce2", 1111111, "testcnonce2", "auth", "FFFFFF");
        assertFalse(authInfo1.equals(authInfo2));
        assertFalse(authInfo1.equals(null));
        assertFalse(authInfo2.equals(null));
        assertFalse(authInfo1.getNextServerNonce().equals(
                authInfo2.getNextServerNonce()));
        assertFalse(authInfo1.getClientNonce().equals(
                authInfo2.getClientNonce()));
    }
View Full Code Here

TOP

Related Classes of org.restlet.data.AuthenticationInfo

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.