RuleNode<SecurityFactory<SSLContext>> sslRuleMatching(URI uri, String abstractType, String abstractTypeAuthority) { RuleNode<SecurityFactory<SSLContext>> node = this.sslRules; while (node != null) { if (node.getRule().matches(uri, abstractType, abstractTypeAuthority)) return node; node = node.getNext(); } return null; }
/** * Create a new rule which is the same as this rule, but also matches the given URI user info. * * @param userSpec the user info to match * @return the new rule */ public final MatchRule matchUser(String userSpec) { return userSpec == null ? matchNoUser() : new MatchUserRule(this, userSpec); }
/** * Create a new rule which is the same as this rule, but also matches the given URN name. * * @param name the URN name to match * @return the new rule */ public final MatchRule matchUrnName(String name) { return name == null ? without(MatchSchemeSpecificPartRule.class) : new MatchSchemeSpecificPartRule(this, name); }
/** * Construct a new instance. * * @param delegate the delegate SASL client */ public AuthenticationContextSaslClient(final SaslClient delegate) { super(delegate); context = AuthenticationContext.captureCurrent(); }
/** * Get a new authentication context which is the same as this one, but which includes the given rule and SSL context at * the end of its SSL context list. * * @param rule the rule to match * @param sslContext the SSL context to select when the rule matches * @return the combined authentication context */ public AuthenticationContext withSsl(MatchRule rule, SecurityFactory<SSLContext> sslContext) { if (sslContext == null || rule == null) return this; return new AuthenticationContext(authRules, with(sslRules, rule, sslContext)); }
@Override boolean halfEqual(final MatchRule other) { return other.getMatchUser() == null && parentHalfEqual(other); }
@Override boolean halfEqual(final MatchRule other) { return other.getMatchPort() == port && parentHalfEqual(other); }
/** * Create a new rule which is the same as this rule, but also matches the given Internet network address. * * @param cidrAddress the network to match * @return the new rule */ public final MatchRule matchNetwork(CidrAddress cidrAddress) { if (cidrAddress == null) { return without(MatchHostRule.class).without(MatchNetworkRule.class); } else { return new MatchNetworkRule(this, cidrAddress); } }
private SaslClientFactory getSaslClientFactory() { if (saslClientFactory == null) { synchronized (this) { if (saslClientFactory == null) { saslClientFactory = getSaslClientFactory(getProviderSupplier()); } } } return saslClientFactory; }
/** * Run a privileged action with this authentication context associated for the duration of the task. * * @param parameter the parameter to pass to the action * @param action the action to run under association * @param <T> the action return type * @param <P> the action parameter type * @return the action return value */ public <T, P> T run(P parameter, ParametricPrivilegedAction<T, P> action) { return runFunction(action, parameter); }
/** * Run a privileged action with this authentication context associated for the duration of the task. * * @param parameter1 the first parameter to pass to the action * @param parameter2 the second parameter to pass to the action * @param action the action to run * @param <T> the action first parameter type */ public <T> void runAsObjIntConsumer(ObjIntConsumer<T> action, T parameter1, int parameter2) { runBiConsumer(action::accept, parameter1, parameter2); }
/** * Get the protocol (scheme) that this rule matches, or {@code null} if this rule does not match by protocol. * * @return the protocol, or {@code null} if there is none */ public String getMatchProtocol() { return parent.getMatchProtocol(); }
/** * Determine whether this rule matches based on abstract type. * * @return {@code true} if the rule matches based on type, {@code false} otherwise */ public boolean isTypeMatched() { return parent.isTypeMatched(); }
/** * Get the abstract type that this rule matches, or {@code null} if this rule does not match by abstract type. * * @return the abstract type, or {@code null} if there is none */ public String getMatchAbstractType() { return parent.getMatchAbstractType(); }
/** * Get the abstract type authority that this rule matches, or {@code null} if this rule does not match by abstract type authority. * * @return the abstract type, or {@code null} if there is none */ public String getMatchAbstractTypeAuthority() { return parent.getMatchAbstractTypeAuthority(); }
/** * Create a new configuration which is the same as this configuration, but which uses the given identity * credentials to acquire the credential required for authentication. * * @param credentials the credentials to use * @return the new configuration */ public AuthenticationConfiguration useCredentials(CredentialSource credentials) { return new AuthenticationConfiguration(this, SET_CRED_SOURCE, credentials == null ? CredentialSource.NONE : credentials); }
/** * Use the default provider discovery behaviour of combining service loader discovered providers with the system default * security providers when locating security implementations. * * @return the new configuration */ public AuthenticationConfiguration useDefaultProviders() { return useProviders(DEFAULT_PROVIDER_SUPPLIER); }
RuleNode<AuthenticationConfiguration> authRuleMatching(URI uri, String abstractType, String abstractTypeAuthority) { RuleNode<AuthenticationConfiguration> node = this.authRules; while (node != null) { if (node.getRule().matches(uri, abstractType, abstractTypeAuthority)) return node; node = node.getNext(); } return null; }
/** * Run a privileged action with this authentication context associated for the duration of the task. * * @param action the action to run * @param <T> the action return type * @return the action result (may be {@code null}) */ public <T> T runAsSupplier(Supplier<T> action) { return runFunction(Supplier::get, action); }