當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthenticationException類代碼示例

本文整理匯總了Java中org.apache.http.auth.AuthenticationException的典型用法代碼示例。如果您正苦於以下問題:Java AuthenticationException類的具體用法?Java AuthenticationException怎麽用?Java AuthenticationException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AuthenticationException類屬於org.apache.http.auth包,在下文中一共展示了AuthenticationException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
public void execute() throws IOException, URISyntaxException, AuthenticationException {
    String pa = restRequest.getParameterValue("project-area");
    Map<String, JsonElement> typeMap = new TreeMap<String, JsonElement>();
    try {
        IProjectAreaHandle targetArea = ProjectAreaHelpers.getProjectArea(pa, parentService);
        if(targetArea == null) {
            response.setStatus(400);
            return;
        }
        IWorkItemServer serverService = parentService.getService(IWorkItemServer.class);
        List<IWorkItemType> types = WorkItemTypeHelpers.getWorkItemTypes(targetArea, serverService, new NullProgressMonitor());
        for(IWorkItemType type : types) {
            JsonObject typeObject = new JsonObject();
            typeObject.addProperty("id", type.getIdentifier());
            typeObject.addProperty("name", type.getDisplayName());
            typeMap.put(type.getDisplayName(), typeObject);
        }
    } catch (TeamRepositoryException e) {
        response.setStatus(500);
    }
    response.getWriter().write(new Gson().toJson(typeMap.values()));
}
 
開發者ID:jazz-community,項目名稱:rtc-workitem-bulk-mover-service,代碼行數:23,代碼來源:ProjectAreaTypeService.java

示例2: execute

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
public void execute() throws IOException, URISyntaxException, AuthenticationException {
    Gson googleJson = new Gson();
    try {
        IProcessServerService processServerService = parentService.getService(IProcessServerService.class);
        IContributorHandle contribHandle = processServerService.getAuthenticatedContributor();
        IRepositoryItemService itemService = parentService.getService(IRepositoryItemService.class);
        IContributor contributor = (IContributor) itemService.fetchItem(contribHandle, null);
        Map<String, ProjectArea> projectAreas = new TreeMap<String, ProjectArea>();
        IProcessArea[] areas = processServerService.findProcessAreas(contributor, null, null);
        for(IProcessArea a : areas) {
            IProjectArea pa = (IProjectArea) itemService.fetchItem(a.getProjectArea(), null);
            String paId = pa.getItemId().toString();
            projectAreas.put(pa.getName(), new ProjectArea(paId, pa.getName()));
        }
        String projectAreasJson = googleJson.toJson(projectAreas);
        response.getWriter().write(projectAreasJson);
    } catch (Exception e) {
        response.setStatus(500);
    }
}
 
開發者ID:jazz-community,項目名稱:rtc-workitem-bulk-mover-service,代碼行數:21,代碼來源:ProjectAreaService.java

示例3: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
public Token authenticate() throws AuthenticationException {
    Token bьььь044Cь = Token.bьььь044Cь(Type.SHORT_TERM);
    bьььь044Cь.loadToken(this.b04140414Д0414ДД);
    b0439ййййй(bьььь044Cь);
    if (bьььь044Cь.isTokenExpired()) {
        Log.d(bДД04140414ДД, "Credentials expired or do not exist. Requesting new token.");
        rrcrcc login = new cccrrr(this.b04140414Д0414ДД, this.bД041404140414ДД, ccccrr.getAppName(), ccccrr.useSSL()).login(this.bД0414Д0414ДД.getUserName(), this.bД0414Д0414ДД.getPassword());
        if (login.requestUnauthorized()) {
            b0449щ0449044904490449();
            throw new AuthenticationException();
        } else if (login.requestTimedOut()) {
            bщ04490449044904490449();
            if (((bХ0425Х042504250425 + b04250425Х042504250425) * bХ0425Х042504250425) % bХХ0425042504250425 != bХ04250425042504250425) {
                bХ0425Х042504250425 = 30;
                bХ04250425042504250425 = 78;
            }
            return bьььь044Cь;
        }
    }
    bщщ0449044904490449(bьььь044Cь);
    return bьььь044Cь;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:23,代碼來源:TVMAuthenticator.java

示例4: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Produces basic authorization header for the given set of {@link Credentials}.
 *
 * @param credentials The set of credentials to be used for authentication
 * @param request The request being authenticated
 * @throws InvalidCredentialsException if authentication credentials are not
 *   valid or not applicable for this authentication scheme
 * @throws AuthenticationException if authorization string cannot
 *   be generated due to an authentication failure
 *
 * @return a basic authorization string
 */
@Override
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {

    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }

    String charset = AuthParams.getCredentialCharset(request.getParams());
    return authenticate(credentials, charset, isProxy());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:BasicScheme.java

示例5: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Produces Diadoc authorization header for the given set of {@link org.apache.http.auth.Credentials}.
 *
 * @param credentials The set of credentials to be used for authentication; must be of type DiadocCredentials
 * @param request     The request being authenticated
 * @return a Diadoc authorization string
 * @throws org.apache.http.auth.AuthenticationException
 *                                     if authorization string cannot
 *                                     be generated due to an authentication failure
 */
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request) throws AuthenticationException {

    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }
    if (!(credentials instanceof DiadocCredentials)) {
        throw new IllegalArgumentException("Credentials must be of type DiadocCredentials");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }

    return authenticate((DiadocCredentials) credentials);
}
 
開發者ID:diadoc,項目名稱:diadocsdk-java,代碼行數:27,代碼來源:DiadocAuthScheme.java

示例6: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Produces a digest authorization string for the given set of
 * {@link Credentials}, method name and URI.
 *
 * @param credentials A set of credentials to be used for athentication
 * @param request    The request being authenticated
 *
 * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
 *         are not valid or not applicable for this authentication scheme
 * @throws AuthenticationException if authorization string cannot
 *   be generated due to an authentication failure
 *
 * @return a digest authorization string
 */
@Override
public Header authenticate(
        final Credentials credentials,
        final HttpRequest request,
        final HttpContext context) throws AuthenticationException {

    Args.notNull(credentials, "Credentials");
    Args.notNull(request, "HTTP request");
    if (getParameter("realm") == null) {
        throw new AuthenticationException("missing realm in challenge");
    }
    if (getParameter("nonce") == null) {
        throw new AuthenticationException("missing nonce in challenge");
    }
    // Add method name and request-URI to the parameter map
    getParameters().put("methodname", request.getRequestLine().getMethod());
    getParameters().put("uri", request.getRequestLine().getUri());
    final String charset = getParameter("charset");
    if (charset == null) {
        getParameters().put("charset", getCredentialsCharset(request));
    }
    return createDigestHeader(credentials, request);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:38,代碼來源:DigestSchemeHC4.java

示例7: performImport

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Performs an import of the impex file
 *
 * @param file
 *            file to be imported
 * @return message with import result
 */
public String performImport(final IFile impexFile) {
	updateLoginVariables();
	String resultMessage;
	try {
		fetchCsrfTokenFromHac();
		loginToHac();
		// continues only if logged in successfully
		try {
			fetchCsrfTokenFromHac();
			resultMessage = postImpex(impexFile);
		} finally {
			logoutFromHac();
		}
	} catch (final IOException | AuthenticationException e) {
		resultMessage = e.getMessage();
	}
	return resultMessage;
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:26,代碼來源:ImportManager.java

示例8: fetchCsrfTokenFromHac

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Send HTTP GET request to {@link #endpointUrl}, updates {@link #csrfToken}
 * token
 *
 * @return true if {@link #endpointUrl} is accessible
 * @throws IOException
 * @throws ClientProtocolException
 * @throws AuthenticationException 
 */
protected void fetchCsrfTokenFromHac() throws ClientProtocolException, IOException, AuthenticationException {
	final HttpGet getRequest = new HttpGet(getEndpointUrl());

	try {
		final HttpResponse response = httpClient.execute(getRequest, getContext());
		final String responseString = new BasicResponseHandler().handleResponse(response);
		csrfToken = getCsrfToken(responseString);
		
		if( StringUtil.isBlank(csrfToken) ) {
			throw new AuthenticationException(ErrorMessage.CSRF_TOKEN_CANNOT_BE_OBTAINED);
		}
	} catch (UnknownHostException error) {
		final String errorMessage = error.getMessage();
		final Matcher matcher = HACPreferenceConstants.HOST_REGEXP_PATTERN.matcher(getEndpointUrl());

		if (matcher.find() && matcher.group(1).equals(errorMessage)) {
			throw new UnknownHostException(
					String.format(ErrorMessage.UNKNOWN_HOST_EXCEPTION_MESSAGE_FORMAT, matcher.group(1)));
		}
		throw error;
	}
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:32,代碼來源:AbstractHACCommunicationManager.java

示例9: performScriptImport

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Performs script import.
 * 
 * @param scriptFile
 *            script file to import
 * @param commit
 *            flat to determinate whether script will be committed or not.
 */
protected void performScriptImport(final IFile scriptFile, final Boolean commit) {
	updateLoginVariables();

	try {
		fetchCsrfTokenFromHac();
		loginToHac();
		try {
			fetchCsrfTokenFromHac();
			postScriptExecution(scriptFile, commit);
		} finally {
			logoutFromHac();
		}

	} catch (final IOException | AuthenticationException e) {
		ConsoleUtils.printError(e.getMessage());
	}
}
 
開發者ID:SAP,項目名稱:hybris-commerce-eclipse-plugin,代碼行數:26,代碼來源:ScriptExecutorManager.java

示例10: redeemBusiness

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Perform entire 4 steps process of Redeem OneDrive for Business API according to documentation {@link https://dev.onedrive.com/auth/aad_oauth.htm}
 * 
 * Step 1: Redeem the authorization code for tokens
 * Step 2: Discover the OneDrive for Business resource URI
 * Step 3: Redeem refresh token for an access token to call OneDrive API
 * Step 4: It is not documented but retriever Email address for user access token.
 *
 * @param redeemRequest the redeem request
 * @return the one drive business object which encapsulate credential info, such as access and refresh token and sharepoint URL for further OneDrive for Business API calls
 * @throws AuthenticationException the authentication exception
 */
public static BusinessCredential redeemBusiness(RedeemRequest redeemRequest) throws AuthenticationException{
	try {
		Map<String, Object> redeemBusinessApiResource = redeemBusinessApiResource(ApiEnviroment.graphApiUrl.getValue(), redeemRequest.getClientId(), redeemRequest.getClientSecret(), redeemRequest.getRedirectUri(), redeemRequest.getCode());
		Map<String, Object> redeemBusinessApi = redeemBusinessApiResource(redeemRequest.getSharepointResourceId(), redeemRequest.getClientId(), redeemRequest.getClientSecret(), redeemRequest.getRedirectUri(), redeemRequest.getCode());
		String userEmail = businessEmail((String)redeemBusinessApiResource.get("access_token"));
		logger.debug("Redeem for OneDrive Business API sharepoint specific URL {}", redeemBusinessApi);
		return BusinessCredential.builder()
				.sharepointEndpointUri(redeemRequest.getSharepointEndpointUri())
				.sharepointResourceId(redeemRequest.getSharepointResourceId())
				.accessToken((String)redeemBusinessApi.get("access_token"))
				.refreshToken((String)redeemBusinessApi.get("refresh_token"))
				.tokenType((String)redeemBusinessApi.get("token_type"))
				.user(userEmail)
				.build();
	} catch (Exception e) {
		throw new AuthenticationException("Could not redeem code "+redeemRequest.getCode()+" for OneDrive Business API");			
	}
}
 
開發者ID:mxhero,項目名稱:onedrive-api,代碼行數:31,代碼來源:OneDrive.java

示例11: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
@Override
public Header authenticate(Credentials credentials, HttpRequest request, HttpContext context)
        throws AuthenticationException {
    Args.notNull(credentials, "Credentials");
    Args.notNull(request, "HTTP request");

    // the bearer token is stored in the password field, not credentials.getUserPrincipal().getName()
    String bearerToken = credentials.getPassword();

    CharArrayBuffer buffer = new CharArrayBuffer(64);
    if (isProxy()) {
        buffer.append("Proxy-Authorization");
    } else {
        buffer.append("Authorization");
    }
    buffer.append(": Bearer ");
    buffer.append(bearerToken);

    return new BufferedHeader(buffer);
}
 
開發者ID:hawkular,項目名稱:hawkular-agent,代碼行數:21,代碼來源:JolokiaClientFactory.java

示例12: signRequestHeader

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Signs an {@link HttpRequest} and returns a header with the signed
 * authorization value.
 *
 * @param credentials Credentials containing a username
 * @param request The {@link HttpRequest} to sign.
 * @return header with signed authorization value
 * @throws AuthenticationException If unable to sign the request.
 */
protected Header signRequestHeader(final Credentials credentials,
                                   final HttpRequest request)
        throws AuthenticationException {
    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Signing request: %s", request));
    }

    final Header date = request.getFirstHeader(HttpHeaders.DATE);
    final String stringDate;

    if (date != null) {
        stringDate = date.getValue();
    } else {
        stringDate = signer.get().defaultSignDateAsString();
        request.setHeader(HttpHeaders.DATE, stringDate);
    }

    // Assure that a cache object is always present for each credential
    signatureCacheMap.computeIfAbsent(credentials, NEW_CACHE_FUNCTION);

    final String authz = signatureCacheMap.get(credentials)
            .updateAndGetSignature(stringDate, signer.get(), keyPair);
    return new BasicHeader(HttpHeaders.AUTHORIZATION, authz);
}
 
開發者ID:joyent,項目名稱:java-http-signature,代碼行數:34,代碼來源:HttpSignatureAuthScheme.java

示例13: processChallenges

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
private void processChallenges(
    final Map<String, Header> challenges,
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response,
    final HttpContext context)
      throws MalformedChallengeException, AuthenticationException {

  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();

  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id +
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:25,代碼來源:DefaultRequestDirector.java

示例14: retryAuthentification

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
private static String retryAuthentification(int retryCount,
		AccountManager accountManager, String authtoken,
		String accountName, HttpResponse response)
		throws AuthenticationException, OperationCanceledException,
		NetworkErrorException, ServerException {
	accountManager.invalidateAuthToken(Constants.ACCOUNT_TYPE, authtoken);
	String newToken = null;
	if (retryCount == 0) {
		newToken = blockingGetAuthToken(accountManager, new Account(
				accountName, Constants.ACCOUNT_TYPE), null);
	}
	if (newToken == null) {
		throw new AuthenticationException(response.getStatusLine()
				.toString());
	}
	return newToken;
}
 
開發者ID:mgrieder,項目名稱:ntsync-android,代碼行數:18,代碼來源:NetworkUtilities.java

示例15: authenticate

import org.apache.http.auth.AuthenticationException; //導入依賴的package包/類
/**
 * Produces a digest authorization string for the given set of 
 * {@link Credentials}, method name and URI.
 * 
 * @param credentials A set of credentials to be used for athentication
 * @param request    The request being authenticated
 * 
 * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
 *         are not valid or not applicable for this authentication scheme
 * @throws AuthenticationException if authorization string cannot 
 *   be generated due to an authentication failure
 * 
 * @return a digest authorization string
 */
public Header authenticate(
        final Credentials credentials, 
        final HttpRequest request) throws AuthenticationException {

    if (credentials == null) {
        throw new IllegalArgumentException("Credentials may not be null");
    }
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    
    // Add method name and request-URI to the parameter map
    getParameters().put("methodname", request.getRequestLine().getMethod());
    getParameters().put("uri", request.getRequestLine().getUri());
    String charset = getParameter("charset");
    if (charset == null) {
        charset = AuthParams.getCredentialCharset(request.getParams());
        getParameters().put("charset", charset);
    }
    String digest = createDigest(credentials);
    return createDigestHeader(credentials, digest);
}
 
開發者ID:tdopires,項目名稱:cJUnit-mc626,代碼行數:37,代碼來源:DigestScheme.java


注:本文中的org.apache.http.auth.AuthenticationException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。