public static String perRequestAuthorizationHeader(Request request, Realm realm) { String authorizationHeader = null; if (realm != null && realm.getUsePreemptiveAuth()) { switch (realm.getScheme()) { case BASIC: authorizationHeader = computeBasicAuthentication(realm); break; case DIGEST: if (isNonEmpty(realm.getNonce())) authorizationHeader = computeDigestAuthentication(realm); break; case NTLM: case KERBEROS: case SPNEGO: // NTLM, KERBEROS and SPNEGO are only set on the first request, // see firstRequestOnlyAuthorizationHeader case NONE: break; default: throw new IllegalStateException("Invalid Authentication " + realm); } } return authorizationHeader; } }
public void operationComplete(ChannelFuture cf) { if (!abortOnThrowable(cf.getCause(), cf.getChannel())) { future.touch(); /** * We need to make sure we aren't in the middle of an authorization process before publishing events as we will re-publish again the same event after the authorization, * causing unpredictable behavior. */ Realm realm = future.getRequest().getRealm() != null ? future.getRequest().getRealm() : config.getRealm(); boolean startPublishing = future.isInAuth() || realm == null || realm.getUsePreemptiveAuth(); if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) { if (notifyHeaders) { ProgressAsyncHandler.class.cast(asyncHandler).onHeadersWritten(); } else { ProgressAsyncHandler.class.cast(asyncHandler).onContentWritten(); } } } }
public void operationComplete(ChannelFuture cf) { if (!abortOnThrowable(cf.getCause(), cf.getChannel())) { future.touch(); /** * We need to make sure we aren't in the middle of an authorization process before publishing events as we will re-publish again the same event after the authorization, * causing unpredictable behavior. */ Realm realm = future.getRequest().getRealm() != null ? future.getRequest().getRealm() : config.getRealm(); boolean startPublishing = future.isInAuth() || realm == null || realm.getUsePreemptiveAuth(); if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) { if (notifyHeaders) { ProgressAsyncHandler.class.cast(asyncHandler).onHeaderWriteCompleted(); } else { ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteCompleted(); } } } }
public static String perRequestProxyAuthorizationHeader(Request request, ProxyServer proxyServer, Realm realm, boolean connect) { String proxyAuthorization = null; if (!connect && proxyServer != null && proxyServer.getScheme() == AuthScheme.BASIC) { proxyAuthorization = computeBasicAuthentication(proxyServer); } else if (realm != null && realm.getUsePreemptiveAuth() && realm.isTargetProxy()) { switch (realm.getScheme()) { case BASIC: proxyAuthorization = computeBasicAuthentication(realm); break; case DIGEST: if (isNonEmpty(realm.getNonce())) proxyAuthorization = computeDigestAuthentication(realm); break; case NTLM: case KERBEROS: case SPNEGO: // NTLM, KERBEROS and SPNEGO are only set on the first request, // see firstRequestOnlyAuthorizationHeader case NONE: break; default: throw new IllegalStateException("Invalid Authentication " + realm); } } return proxyAuthorization; }
public static String perConnectionAuthorizationHeader(Request request, ProxyServer proxyServer, Realm realm) { String authorizationHeader = null; if (realm != null && realm.getUsePreemptiveAuth()) { switch (realm.getScheme()) { case NTLM: String msg = NtlmEngine.INSTANCE.generateType1Msg(); authorizationHeader = "NTLM " + msg; break; case KERBEROS: case SPNEGO: String host; if (proxyServer != null) host = proxyServer.getHost(); else if (request.getVirtualHost() != null) host = request.getVirtualHost(); else host = request.getUri().getHost(); authorizationHeader = "Negotiate " + SpnegoEngine.instance().generateToken(host); break; default: break; } } return authorizationHeader; }
@Override public void operationComplete(ChannelProgressiveFuture cf) { // The write operation failed. If the channel was cached, it means it got asynchronously closed. // Let's retry a second time. if (!abortOnThrowable(cf.cause(), cf.channel())) { future.touch(); /** * We need to make sure we aren't in the middle of an authorization * process before publishing events as we will re-publish again the * same event after the authorization, causing unpredictable * behavior. */ Realm realm = future.getRequest().getRealm() != null ? future.getRequest().getRealm() : config.getRealm(); boolean startPublishing = future.isInAuth() || realm == null || realm.getUsePreemptiveAuth(); if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) { ProgressAsyncHandler<?> progressAsyncHandler = (ProgressAsyncHandler<?>) asyncHandler; if (notifyHeaders) { progressAsyncHandler.onHeaderWriteCompleted(); } else { progressAsyncHandler.onContentWriteCompleted(); } } } }
@Override public void operationComplete(ChannelProgressiveFuture cf) { // The write operation failed. If the channel was cached, it means it got asynchronously closed. // Let's retry a second time. if (!abortOnThrowable(cf.cause(), cf.channel())) { future.touch(); /** * We need to make sure we aren't in the middle of an authorization * process before publishing events as we will re-publish again the * same event after the authorization, causing unpredictable * behavior. */ Realm realm = future.getRequest().getRealm() != null ? future.getRequest().getRealm() : config.getRealm(); boolean startPublishing = future.isInAuth() || realm == null || realm.getUsePreemptiveAuth(); if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) { ProgressAsyncHandler<?> progressAsyncHandler = (ProgressAsyncHandler<?>) asyncHandler; if (notifyHeaders) { progressAsyncHandler.onHeadersWritten(); } else { progressAsyncHandler.onContentWritten(); } } } }
public RealmBuilder clone(Realm clone) { return setRealmName(clone.getRealmName())// .setAlgorithm(clone.getAlgorithm())// .setMethodName(clone.getMethodName())// .setNc(clone.getNc())// .setNonce(clone.getNonce())// .setPassword(clone.getPassword())// .setPrincipal(clone.getPrincipal())// .setCharset(clone.getCharset())// .setOpaque(clone.getOpaque())// .setQop(clone.getQop())// .setScheme(clone.getScheme())// .setUri(clone.getUri())// .setUsePreemptiveAuth(clone.getUsePreemptiveAuth())// .setNtlmDomain(clone.getNtlmDomain())// .setNtlmHost(clone.getNtlmHost())// .setUseAbsoluteURI(clone.isUseAbsoluteURI())// .setOmitQuery(clone.isOmitQuery())// .setTargetProxy(clone.isTargetProxy()); }