Examples of Credentials


Examples of org.apache.http.auth.Credentials

        assertEquals(got, expected);
    }
   
    public void testRealmCredentials() throws Exception {
        BasicCredentialsProvider state = new BasicCredentialsProvider();
        Credentials expected = new UsernamePasswordCredentials("name", "pass");
        state.setCredentials(DEFSCOPE, expected);
        Credentials got = state.getCredentials(DEFSCOPE);
        assertEquals(expected, got);
    }
View Full Code Here

Examples of org.apache.http.auth.Credentials

        assertEquals(expected, got);
    }
   
    public void testHostCredentials() throws Exception {
        BasicCredentialsProvider state = new BasicCredentialsProvider();
        Credentials expected = new UsernamePasswordCredentials("name", "pass");
        state.setCredentials(
            new AuthScope("host", AuthScope.ANY_PORT, AuthScope.ANY_REALM), expected);
        Credentials got = state.getCredentials(DEFSCOPE);
        assertEquals(expected, got);
    }
View Full Code Here

Examples of org.apache.http.auth.Credentials

        assertEquals(expected, got);
    }
   
    public void testWrongHostCredentials() throws Exception {
        BasicCredentialsProvider state = new BasicCredentialsProvider();
        Credentials expected = new UsernamePasswordCredentials("name", "pass");
        state.setCredentials(
            new AuthScope("host1", AuthScope.ANY_PORT, "realm"), expected);
        Credentials got = state.getCredentials(
            new AuthScope("host2", AuthScope.ANY_PORT, "realm"));
        assertNotSame(expected, got);
    }
View Full Code Here

Examples of org.apache.http.auth.Credentials

        assertNotSame(expected, got);
    }
   
    public void testWrongRealmCredentials() throws Exception {
        BasicCredentialsProvider state = new BasicCredentialsProvider();
        Credentials cred = new UsernamePasswordCredentials("name", "pass");
        state.setCredentials(
            new AuthScope("host", AuthScope.ANY_PORT, "realm1"), cred);
        Credentials got = state.getCredentials(
            new AuthScope("host", AuthScope.ANY_PORT, "realm2"));
        assertNotSame(cred, got);
    }
View Full Code Here

Examples of org.apache.http.auth.Credentials

            new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, "somescheme"));
        assertTrue(m2 > m1);
    }
   
    public void testCredentialsMatching() {
        Credentials creds1 = new UsernamePasswordCredentials("name1", "pass1");
        Credentials creds2 = new UsernamePasswordCredentials("name2", "pass2");
        Credentials creds3 = new UsernamePasswordCredentials("name3", "pass3");
       
        AuthScope scope1 = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);
        AuthScope scope2 = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "somerealm");
        AuthScope scope3 = new AuthScope("somehost", AuthScope.ANY_PORT, AuthScope.ANY_REALM);
       
        BasicCredentialsProvider state = new BasicCredentialsProvider();
        state.setCredentials(scope1, creds1);
        state.setCredentials(scope2, creds2);
        state.setCredentials(scope3, creds3);

        Credentials got = state.getCredentials(
            new AuthScope("someotherhost", 80, "someotherrealm", "basic"));
        Credentials expected = creds1;
        assertEquals(expected, got);

        got = state.getCredentials(
            new AuthScope("someotherhost", 80, "somerealm", "basic"));
        expected = creds2;
View Full Code Here

Examples of org.apache.http.auth.Credentials

    }

    private static Principal getAuthPrincipal(final AuthState authState) {
        AuthScheme scheme = authState.getAuthScheme();
        if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
            Credentials creds = authState.getCredentials();
            if (creds != null) {
                return creds.getUserPrincipal();
            }
        }
        return null;
    }
View Full Code Here

Examples of org.apache.http.auth.Credentials

     */
    private static Credentials matchCredentials(
            final HashMap<AuthScope, Credentials> map,
            final AuthScope authscope) {
        // see if we get a direct hit
        Credentials creds = map.get(authscope);
        if (creds == null) {
            // Nope.
            // Do a full scan
            int bestMatchFactor  = -1;
            AuthScope bestMatch  = null;
View Full Code Here

Examples of org.apache.http.auth.Credentials

                authScheme.getSchemeName())
       
        if (this.log.isDebugEnabled()) {
            this.log.debug("Authentication scope: " + authScope);
        }
        Credentials creds = authState.getCredentials();
        if (creds == null) {
            creds = credsProvider.getCredentials(authScope);
            if (this.log.isDebugEnabled()) {
                if (creds != null) {
                    this.log.debug("Found credentials");
View Full Code Here

Examples of org.apache.ivy.util.Credentials

            return true;
        }

        public String getPassword() {
            if (userPassword == null) {
                Credentials c = CredentialsUtil.promptCredentials(new Credentials(null, host,
                        userName, userPassword), passfile);
                if (c != null) {
                    userName = c.getUserName();
                    userPassword = c.getPasswd();
                }
            }
            return userPassword;
        }
View Full Code Here

Examples of org.apache.oozie.action.hadoop.Credentials

public class TestCredentials extends ActionExecutorTestCase {

    public void testHbaseCredentials() {
        CredentialsProperties prop = new CredentialsProperties("dummyName", "dummyType");
        prop.getProperties().put("hbase.zookeeper.quorum", "dummyHost");
        Credentials hb = new HbaseCredentials();
        WorkflowJobBean wfBean = new WorkflowJobBean();
        wfBean.setUser("dummyUser");
        JobConf jc = new JobConf(false);
        try {
            hb.addtoJobConf(jc, prop, new Context(wfBean, new WorkflowActionBean()));
        }
        catch (Exception e) {
            // Change this when security related classes are available from
            // hbase maven repo
            if (!(e.getCause() instanceof ClassNotFoundException)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.