当前位置: 首页>>代码示例>>Java>>正文


Java InvalidCredentialsException类代码示例

本文整理汇总了Java中org.apache.http.auth.InvalidCredentialsException的典型用法代码示例。如果您正苦于以下问题:Java InvalidCredentialsException类的具体用法?Java InvalidCredentialsException怎么用?Java InvalidCredentialsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidCredentialsException类属于org.apache.http.auth包,在下文中一共展示了InvalidCredentialsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupDockerClient

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
private void setupDockerClient() throws
    InvalidCredentialsException {
  if (dockerClient != null) {
    return;
  }

  final DockerClientConfig config = createClientConfig();

  final DockerCmdExecFactory dockerCmdExecFactory = new JerseyDockerCmdExecFactory();
  dockerClient = DockerClientBuilder.getInstance(config)
      .withDockerCmdExecFactory(dockerCmdExecFactory)
      .build();

  // Check if client was successfully created
  final AuthResponse response = dockerClient.authCmd().exec();
  if (!response.getStatus().equalsIgnoreCase("Login Succeeded")) {
    throw new InvalidCredentialsException("Could not create DockerClient");
  }
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:20,代码来源:DockerClientManagerWithAuth.java

示例2: pushImage

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
/**
 * Push image to container registry.
 * @param imageName the name of the image.
 * @throws InvalidCredentialsException if authentication fails.
 */
public void pushImage(String imageName) throws
    InvalidCredentialsException {

  setupDockerClient();

  AuthConfig authConfig = new AuthConfig();
  authConfig.withUsername(registryUsername);
  authConfig.withPassword(registryPassword);
  authConfig.withRegistryAddress(registryUrl);
  authConfig.withEmail(registryEmail);

  dockerClient.pushImageCmd(imageName)
      .withAuthConfig(authConfig)
      .exec(new PushImageResultCallback())
      .awaitSuccess();
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:22,代码来源:DockerClientManagerWithAuth.java

示例3: getOutputProvider

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
public static OutputProvider getOutputProvider(URL url, String userName, String userPassword) throws MalformedURLException, InvalidCredentialsException{
	if(url == null || url.getProtocol() == null || url.getProtocol().trim().isEmpty()){
		throw new MalformedURLException("BAD URL. NO PROTOCOL.");
	}
	
	AuthenticationData ad = new AuthenticationData(userName, userPassword);
	
	String protocol = url.getProtocol();
	switch (protocol) {
	case "http":
		return new OutputHttpProvider(url, ad);
	case "file":
		return new OutputFileProvider(url, ad);
	case "ftp":
		return new OutputFtpProvider(url, ad, 30, true);
	}
	
	throw new MalformedURLException("NO PROTOCOL SUPPORT FOR : " + protocol);
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:20,代码来源:OutputProviderFactory.java

示例4: getInputProvider

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
public static InputProvider getInputProvider(URL url, String userName, String userPassword) throws MalformedURLException, InvalidCredentialsException{
	if(url == null || url.getProtocol() == null || url.getProtocol().trim().isEmpty()){
		throw new MalformedURLException("BAD URL. NO PROTOCOL.");
	}
	
	AuthenticationData ad = new AuthenticationData(userName, userPassword);
	
	String protocol = url.getProtocol();
	switch (protocol) {
	case "http":
		return new InputHttpProvider(url, ad);
	case "file":
		return new InputFileProvider(url, ad);
	case "ftp":
		return new InputFtpProvider(url, ad, 30, true);
	}
	
	throw new MalformedURLException("NO PROTOCOL SUPPORT FOR : " + protocol);
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:20,代码来源:InputProviderFactory.java

示例5: execute

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException {
  final Log log = getLog();

  if (skipPush) {
    log.info("skipPush is true. Skipping image push step.");
    return;
  }

  if (imageName == null || imageName.isEmpty()) {
    imageName = DockerImageUtil.getImageName(
        imageRepository,
        tagName
    );
  }
  try {
    DockerClientManagerWithAuth dockerClientManager =
        new DockerClientManagerWithAuth(region, customRegistry, authPush);

    if (authPush) {
      dockerClientManager.pushImage(imageName);
    } else {
      dockerClientManager.pushImageNoAuth(imageName);
    }
  } catch (InvalidCredentialsException | SdkClientException e) {
    throw new MojoExecutionException(
        "Could not create docker client. Invalid credentials.",
        e
    );
  }
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:32,代码来源:PushMojo.java

示例6: pushImageNoAuth

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
/**
 * Push image without authentication.
 * @param imageName the name of the image to be pushed.
 * @throws InvalidCredentialsException if authentication fails.
 */
public void pushImageNoAuth(String imageName) throws
    InvalidCredentialsException {
  setupDockerClient();

  dockerClient.pushImageCmd(imageName)
      .exec(new PushImageResultCallback())
      .awaitSuccess();
}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:14,代码来源:DockerClientManagerWithAuth.java

示例7: serveRunStart

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
private synchronized void serveRunStart(HttpServletRequest request,
		HttpServletResponse response, String path) throws IOException, CoreException, InvalidCredentialsException {
	JSONObject input = parseInput(request);
	verifyPassword(input);

	IContext context = Core.createSystemContext();
	if (!detectedUnitTests) {
		TestManager.instance().findAllTests(context);
		detectedUnitTests = true;
	}
	
	if (testSuiteRunner != null && !testSuiteRunner.isFinished()) {
		throw new IllegalArgumentException("Cannot start a test run while another test run is still running");
	}
	
	LOG.info("[remote api] starting new test run");
	testSuiteRunner = new TestSuiteRunner();
	
	Thread t = new Thread() {
		@Override
		public void run() {
			testSuiteRunner.run();
		}
	};
	
	t.start();
	response.setStatus(HttpServletResponse.SC_NO_CONTENT);		
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:29,代码来源:RemoteApiServlet.java

示例8: verifyPassword

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
private void verifyPassword(JSONObject input) throws InvalidCredentialsException {
	if (!input.has(PARAM_PASSWORD)) {
		LOG.warn("[remote api] Missing password");
		throw new IllegalArgumentException("No '" + PARAM_PASSWORD + "' attribute found in the JSON body. Please provide a password");
	}
	
	if (!password.equals(input.getString(PARAM_PASSWORD))) {
		LOG.warn("[remote api] Invalid password");
		throw new InvalidCredentialsException();
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:12,代码来源:RemoteApiServlet.java

示例9: OutputFtpProvider

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
protected OutputFtpProvider(
	URL url, AuthenticationData authenticationData, int timeOutSeconds, boolean connectWithPassiveMode
) throws MalformedURLException, InvalidCredentialsException {
	super(url, authenticationData);
	this.timeOutSeconds = timeOutSeconds;
	this.connectWithPassiveMode = connectWithPassiveMode;
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:8,代码来源:OutputFtpProvider.java

示例10: checkAuthenticationData

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
private void checkAuthenticationData(AuthenticationData authenticationData) throws InvalidCredentialsException{
	if(isAuthenticationRequired()){
		if(!StringValidator.validateString(authenticationData.getUserName()) 
		|| !StringValidator.validateString(authenticationData.getUserPassword())){
			throw new InvalidCredentialsException();
		}
	}
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:9,代码来源:ContentProvider.java

示例11: InputFtpProvider

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
protected InputFtpProvider(
	URL url, AuthenticationData authenticationData, int timeOutSeconds, boolean connectWithPassiveMode
) throws MalformedURLException, InvalidCredentialsException {
	super(url, authenticationData);
	this.timeOutSeconds = timeOutSeconds;
	this.connectWithPassiveMode = connectWithPassiveMode;
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:8,代码来源:InputFtpProvider.java

示例12: process

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
@Override
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException, InvalidCredentialsException {
  log.debug("Intercepted request [{}] with URI [{}] for context [{}].", request, request.getRequestLine().getUri(), context);

  final Boolean authenticated = authenticate(request, context);

  context.setAttribute(Authenticated, authenticated);
  Context.instance().getInvocationContext().set(Key.Authenticated, authenticated);

  if (request instanceof BasicHttpRequest) if (isDebugEnabled())
    getTracerService().examine(request);
}
 
开发者ID:Sabadios,项目名称:Cherry,代码行数:13,代码来源:RequestInterceptor.java

示例13: authenticate

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
@Override
public Header authenticate(
                            final Credentials credentials,
                            final HttpRequest request,
                            final HttpContext context ) throws AuthenticationException {

    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    switch (state) {
        case UNINITIATED:
            throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
        case FAILED:
            throw new AuthenticationException(getSchemeName() + " authentication has failed");
        case CHALLENGE_RECEIVED:
            try {
                token = generateToken(token);
                state = State.TOKEN_GENERATED;
            } catch (GSSException gsse) {
                state = State.FAILED;
                if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.NO_CRED)
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN)
                    throw new AuthenticationException(gsse.getMessage(), gsse);
                // other error
                throw new AuthenticationException(gsse.getMessage());
            }
            // continue to next case block
        case TOKEN_GENERATED:
            String tokenstr = new String(base64codec.encode(token));
            if (log.isDebugEnabled()) {
                log.debug("Sending response '" + tokenstr + "' back to the auth server");
            }
            return new BasicHeader("Authorization", "Negotiate " + tokenstr);
        default:
            throw new IllegalStateException("Illegal state: " + state);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:44,代码来源:GGSSchemeBase.java

示例14: authenticate

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
@Override
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    switch (state) {
    case UNINITIATED:
        throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
    case FAILED:
        throw new AuthenticationException(getSchemeName() + " authentication has failed");
    case CHALLENGE_RECEIVED:
        try {
            String key = null;
            if (isProxy()) {
                key = ExecutionContext.HTTP_PROXY_HOST;
            } else {
                key = ExecutionContext.HTTP_TARGET_HOST;
            }
            HttpHost host = (HttpHost) context.getAttribute(key);
            if (host == null) {
                throw new AuthenticationException("Authentication host is not set " +
                        "in the execution context");
            }
            String authServer;
            if (!this.stripPort && host.getPort() > 0) {
                authServer = host.toHostString();
            } else {
                authServer = host.getHostName();
            }

            if (log.isDebugEnabled()) {
                log.debug("init " + authServer);
            }
            token = generateToken(token, authServer);
            state = State.TOKEN_GENERATED;
        } catch (GSSException gsse) {
            state = State.FAILED;
            if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                    || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            if (gsse.getMajor() == GSSException.NO_CRED )
                throw new InvalidCredentialsException(gsse.getMessage(), gsse);
            if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                    || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                    || gsse.getMajor() == GSSException.OLD_TOKEN)
                throw new AuthenticationException(gsse.getMessage(), gsse);
            // other error
            throw new AuthenticationException(gsse.getMessage());
        }
    case TOKEN_GENERATED:
        String tokenstr = new String(base64codec.encode(token));
        if (log.isDebugEnabled()) {
            log.debug("Sending response '" + tokenstr + "' back to the auth server");
        }
        return new BasicHeader("Authorization", "Negotiate " + tokenstr);
    default:
        throw new IllegalStateException("Illegal state: " + state);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:63,代码来源:GGSSchemeBase.java

示例15: OutputProvider

import org.apache.http.auth.InvalidCredentialsException; //导入依赖的package包/类
public OutputProvider(URL url, AuthenticationData authenticationData) throws MalformedURLException, InvalidCredentialsException {
	super(url, authenticationData);
}
 
开发者ID:MatheusArleson,项目名称:PdfUtil,代码行数:4,代码来源:OutputProvider.java


注:本文中的org.apache.http.auth.InvalidCredentialsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。