Examples of HttpAuthenticator


Examples of com.maverick.http.HttpAuthenticator

  private void connectAgent() throws IOException, HttpException,
      UnsupportedAuthenticationException,
      AuthenticationCancelledException {

    HttpResponse response = null;
    HttpAuthenticator authenticator = null;
    String ticketToSend = ticket;
   
    boolean doPreemptive = ticketIsPassword;

    try {
           
      for (int i = 0; i < 3; i++) {

              HttpClient client = getHttpClient();
              if (doPreemptive) {
                  client.setCredentials(new PasswordCredentials(username,
                          ticket));
                  client.setPreferredAuthentication("Basic");
              }
              else {
                  client.setCredentials(null);
              }

        // #ifdef DEBUG
        log.info("Registering with the server"); //$NON-NLS-1$
        log.info("Server is " + (isSecure ? "https://" : "http://") + getAditoHost() //$NON-NLS-1$
            + ":" + getAditoPort()); //$NON-NLS-1$
        // #endif
        GetMethod post = new GetMethod("/agent"); //$NON-NLS-1$

              client.setPreemtiveAuthentication(doPreemptive);
        if (!doPreemptive && ticket != null) {
          post.setParameter("ticket", ticket); //$NON-NLS-1$
        }

        post.setParameter(
            "agentType", getConfiguration().getAgentType()); //$NON-NLS-1$ //$NON-NLS-2$
        post.setParameter("locale", Locale.getDefault().toString()); //$NON-NLS-1$

        response = client.execute(post);

        if (response.getStatus() == 302) {
          // Reset the client
          this.client = null;

          URL url = new URL(response.getHeaderField("Location")); //$NON-NLS-1$
          aditoHostname = url.getHost();
          if (url.getPort() > 0)
            aditoPort = url.getPort();
          continue;
        } else if (response.getStatus() == 200) {
          con.addListener(this);
          httpConnection = response.getConnection(); // Preserve the
          // connection
          con.registerRequestHandler(MESSAGE_REQUEST, this);
          con.registerRequestHandler(SHUTDOWN_REQUEST, this);
          con.registerRequestHandler(OPEN_URL_REQUEST, this);
          con.registerRequestHandler(UPDATE_RESOURCES_REQUEST, this);

          // Start the protocol

          con.startProtocol(
              response.getConnection().getInputStream(), response
                  .getConnection().getOutputStream(), true);

          // Synchronize and read back server information
          Request syncRequest = new Request(SYNCHRONIZED_REQUEST);
          con.sendRequest(syncRequest, true);
          if (syncRequest.getRequestData() == null)
            throw new IOException(
                "Server failed to return version data");

          ByteArrayReader reader = new ByteArrayReader(syncRequest
              .getRequestData());
          serverVersion = reader.readString();

          /**
           * Initialize the managers. Tunnels are no longer recorded
           * here unless they are active. This simplifies the agent by
           * making it respond to start and stop requests from the new
           * persistent connection with Adito.
           */
          tunnelManager = new TunnelManager(this);
          applicationManager = new ApplicationManager(this);
          webForwardManager = new WebForwardManager(this);
          networkPlaceManager = new NetworkPlaceManager(this);
          updateResources(-1);
          return;
        } else if (response.getStatus() == 401) {
          authenticator = HttpAuthenticatorFactory
              .createAuthenticator(
                  response.getConnection(),
                  response
                      .getHeaderFields("WWW-Authenticate"),
                  "WWW-Authenticate", "Authorization",
                  HttpAuthenticatorFactory.BASIC, post
                      .getURI());
          if (authenticator.wantsPrompt()) {
            if ( !( defaultAuthenticationPrompt != null ? defaultAuthenticationPrompt.promptForCredentials(false, authenticator) :
                getGUI().promptForCredentials(false, authenticator) ) ) {
              throw new AuthenticationCancelledException();
            }
          }
View Full Code Here

Examples of com.sun.enterprise.appclient.HttpAuthenticator

                System.exit(1);
            }
            // Set the authenticator which is called back when a
            // protected web resource is requested and authentication data is
            // needed.
            Authenticator.setDefault(new HttpAuthenticator(container));

            // log a machine name, port number per Jagadesh's request
      _logger.log(Level.INFO, "acc.orb_host_name", host);
            _logger.log(Level.INFO, "acc.orb_port_number", port);
                     
View Full Code Here

Examples of com.sun.enterprise.appclient.HttpAuthenticator

            Cleanup cleanup = prepareShutdownCleanup(container, appClientInfo);

            // Set the authenticator which is called back when a
            // protected web resource is requested and authentication data is
            // needed.
            Authenticator.setDefault(new HttpAuthenticator(container));

            /*
             *The container needs to use the new classloader to locate any
             *user-specified security callback handler.
             */
 
View Full Code Here

Examples of org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator

        resourceFactory = wac.getBean( "davResourceFactory#archiva", DavResourceFactory.class );
        locatorFactory = new ArchivaDavLocatorFactory();

        ServletAuthenticator servletAuth = wac.getBean( ServletAuthenticator.class );
        HttpAuthenticator httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class );

        sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );

        long end = System.currentTimeMillis();
View Full Code Here

Examples of org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator

        resourceFactory = wac.getBean( "davResourceFactory#archiva", DavResourceFactory.class );
        locatorFactory = new ArchivaDavLocatorFactory();

        ServletAuthenticator servletAuth = wac.getBean( ServletAuthenticator.class );
        HttpAuthenticator httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class );

        sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );

        long end = System.currentTimeMillis();
View Full Code Here

Examples of org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator

        resourceFactory = wac.getBean( "davResourceFactory#archiva", DavResourceFactory.class );
        locatorFactory = new ArchivaDavLocatorFactory();

        ServletAuthenticator servletAuth = wac.getBean( ServletAuthenticator.class );
        HttpAuthenticator httpAuth = wac.getBean( "httpAuthenticator#basic", HttpAuthenticator.class );

        sessionProvider = new ArchivaDavSessionProvider( servletAuth, httpAuth );

        log.info( "initServers done" );
    }
View Full Code Here

Examples of org.apache.axis2.transport.http.HTTPAuthenticator

     * or Basic Authentication. Apart from that user can change the priory or
     * add a custom authentication scheme.
     */
    protected void setAuthenticationInfo(HttpClient agent, MessageContext msgCtx,
            HostConfiguration config) throws AxisFault {
        HTTPAuthenticator authenticator;
        Object obj = msgCtx.getProperty(HTTPConstants.AUTHENTICATE);
        if (obj != null) {
            if (obj instanceof HTTPAuthenticator) {
                authenticator = (HTTPAuthenticator) obj;

                String username = authenticator.getUsername();
                String password = authenticator.getPassword();
                String host = authenticator.getHost();
                String domain = authenticator.getDomain();

                int port = authenticator.getPort();
                String realm = authenticator.getRealm();

                /* If retrying is available set it first */
                isAllowedRetry = authenticator.isAllowedRetry();

                Credentials creds;

                HttpState tmpHttpState = null;
                HttpState httpState = (HttpState) msgCtx
                        .getProperty(HTTPConstants.CACHED_HTTP_STATE);
                if (httpState != null) {
                    tmpHttpState = httpState;
                } else {
                    tmpHttpState = agent.getState();
                }

                agent.getParams().setAuthenticationPreemptive(
                        authenticator.getPreemptiveAuthentication());

                if (host != null) {
                    if (domain != null) {
                        /* Credentials for NTLM Authentication */
                        creds = new NTCredentials(username, password, host, domain);
                    } else {
                        /* Credentials for Digest and Basic Authentication */
                        creds = new UsernamePasswordCredentials(username, password);
                    }
                    tmpHttpState.setCredentials(new AuthScope(host, port, realm), creds);
                } else {
                    if (domain != null) {
                        /*
                         * Credentials for NTLM Authentication when host is
                         * ANY_HOST
                         */
                        creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
                        tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
                                creds);
                    } else {
                        /* Credentials only for Digest and Basic Authentication */
                        creds = new UsernamePasswordCredentials(username, password);
                        tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY), creds);
                    }
                }
                /* Customizing the priority Order */
                List schemes = authenticator.getAuthSchemes();
                if (schemes != null && schemes.size() > 0) {
                    List authPrefs = new ArrayList(3);
                    for (int i = 0; i < schemes.size(); i++) {
                        if (schemes.get(i) instanceof AuthPolicy) {
                            authPrefs.add(schemes.get(i));
                            continue;
                        }
                        String scheme = (String) schemes.get(i);
                        authPrefs.add(authenticator.getAuthPolicyPref(scheme));

                    }
                    agent.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
                }

View Full Code Here

Examples of org.apache.axis2.transport.http.HTTPAuthenticator

     * or Basic Authentication. Apart from that user can change the priory or
     * add a custom authentication scheme.
     */
    protected void setAuthenticationInfo(AbstractHttpClient agent, MessageContext msgCtx)
            throws AxisFault {
        HTTPAuthenticator authenticator;
        Object obj = msgCtx.getProperty(HTTPConstants.AUTHENTICATE);
        if (obj != null) {
            if (obj instanceof HTTPAuthenticator) {
                authenticator = (HTTPAuthenticator) obj;

                String username = authenticator.getUsername();
                String password = authenticator.getPassword();
                String host = authenticator.getHost();
                String domain = authenticator.getDomain();

                int port = authenticator.getPort();
                String realm = authenticator.getRealm();

                /* If retrying is available set it first */
                isAllowedRetry = authenticator.isAllowedRetry();

                Credentials creds;

                // TODO : Set preemptive authentication, but its not recommended in HC 4

                if (host != null) {
                    if (domain != null) {
                        /* Credentials for NTLM Authentication */
                        agent.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
                        creds = new NTCredentials(username, password, host, domain);
                    } else {
                        /* Credentials for Digest and Basic Authentication */
                        creds = new UsernamePasswordCredentials(username, password);
                    }
                    agent.getCredentialsProvider().
                            setCredentials(new AuthScope(host, port, realm), creds);
                } else {
                    if (domain != null) {
                        /*
                         * Credentials for NTLM Authentication when host is
                         * ANY_HOST
                         */
                        agent.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
                        creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
                        agent.getCredentialsProvider().
                                setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
                                               creds);
                    } else {
                        /* Credentials only for Digest and Basic Authentication */
                        creds = new UsernamePasswordCredentials(username, password);
                        agent.getCredentialsProvider().
                                setCredentials(new AuthScope(AuthScope.ANY), creds);
                    }
                }
                /* Customizing the priority Order */
                List schemes = authenticator.getAuthSchemes();
                if (schemes != null && schemes.size() > 0) {
                    List authPrefs = new ArrayList(3);
                    for (int i = 0; i < schemes.size(); i++) {
                        if (schemes.get(i) instanceof AuthPolicy) {
                            authPrefs.add(schemes.get(i));
                            continue;
                        }
                        String scheme = (String) schemes.get(i);
                        authPrefs.add(authenticator.getAuthPolicyPref(scheme));

                    }
                    agent.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPrefs);
                }

View Full Code Here

Examples of org.apache.http.impl.auth.HttpAuthenticator

        this.redirectStrategy = redirectStrategy;
        this.targetAuthStrategy = targetAuthStrategy;
        this.proxyAuthStrategy = proxyAuthStrategy;
        this.userTokenHandler = userTokenHandler;
        this.routeDirector = new BasicRouteDirector();
        this.authenticator = new HttpAuthenticator(log);
    }
View Full Code Here

Examples of org.apache.http.impl.auth.HttpAuthenticator

        Args.notNull(reuseStrategy, "Connection reuse strategy");
        Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
        Args.notNull(targetAuthStrategy, "Target authentication strategy");
        Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
        Args.notNull(userTokenHandler, "User token handler");
        this.authenticator      = new HttpAuthenticator();
        this.proxyHttpProcessor = new ImmutableHttpProcessor(
                new RequestTargetHost(), new RequestClientConnControl());
        this.routeDirector      = new BasicRouteDirector();
        this.requestExecutor    = requestExecutor;
        this.connManager        = connManager;
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.