Search in sources :

Example 1 with Result

use of org.dcache.gplazma.monitor.LoginMonitor.Result in project dcache by dCache.

the class LoginResultPrinter method printPluginHeader.

private void printPluginHeader(PAMPluginResult plugin) {
    ConfigurationItemControl control = plugin.getControl();
    Result result = plugin.getResult();
    String resultLabel = stringFor(result);
    String name = plugin.getName();
    String error;
    if (result == SUCCESS) {
        error = "";
    } else {
        error = " (" + plugin.getError() + ")";
    }
    _sb.append(String.format(" |   +--%s %s:%s%s => %s", name, plugin.getControl().name(), resultLabel, error, ALWAYS_OK.contains(control) ? "OK" : resultLabel));
    if ((result == SUCCESS && control == SUFFICIENT) || (result == FAIL && control == REQUISITE)) {
        _sb.append(" (ends the phase)");
    }
    _sb.append('\n');
}
Also used : ConfigurationItemControl(org.dcache.gplazma.configuration.ConfigurationItemControl) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) AccountPhaseResult(org.dcache.gplazma.monitor.LoginResult.AccountPhaseResult) AuthPhaseResult(org.dcache.gplazma.monitor.LoginResult.AuthPhaseResult) PAMPluginResult(org.dcache.gplazma.monitor.LoginResult.PAMPluginResult) SessionPluginResult(org.dcache.gplazma.monitor.LoginResult.SessionPluginResult) MapPhaseResult(org.dcache.gplazma.monitor.LoginResult.MapPhaseResult) AccountPluginResult(org.dcache.gplazma.monitor.LoginResult.AccountPluginResult) SessionPhaseResult(org.dcache.gplazma.monitor.LoginResult.SessionPhaseResult) PhaseResult(org.dcache.gplazma.monitor.LoginResult.PhaseResult) MapPluginResult(org.dcache.gplazma.monitor.LoginResult.MapPluginResult) Result(org.dcache.gplazma.monitor.LoginMonitor.Result) AuthPluginResult(org.dcache.gplazma.monitor.LoginResult.AuthPluginResult)

Example 2 with Result

use of org.dcache.gplazma.monitor.LoginMonitor.Result in project dcache by dCache.

the class DefaultMappingStrategy method map.

/**
 * Delegates execution of the {@link GPlazmaMappingPlugin#map(Set<Principal>)
 * GPlazmaMappingPlugin.map} methods of the plugins supplied by {@link
 * GPlazmaStrategy#setPlugins(List< GPlazmaPluginService <T>>) GPlazmaStrategy.setPlugins} to
 * {@link  PAMStyleStrategy#callPlugins(PluginCaller<T>) PAMStyleStrategy.callPlugins(PluginCaller<T>)}
 * by providing anonymous implementation of the {@link PluginCaller#call(GPlazmaPlugin)
 * PluginCaller} interface.
 *
 * @param monitor
 * @param principals
 * @throws AuthenticationException
 * @see PAMStyleStrategy
 * @see PluginCaller
 */
@Override
public void map(final LoginMonitor monitor, final Set<Principal> principals) throws AuthenticationException {
    pamStyleMappingStrategy.callPlugins(service -> {
        monitor.mapPluginBegins(service.getName(), service.getControl(), principals);
        GPlazmaMappingPlugin plugin = service.getPlugin();
        Result result = Result.FAIL;
        String error = null;
        try {
            plugin.map(principals);
            result = Result.SUCCESS;
        } catch (AuthenticationException e) {
            error = e.getMessage();
            throw e;
        } finally {
            monitor.mapPluginEnds(service.getName(), service.getControl(), result, error, principals);
        }
    });
}
Also used : AuthenticationException(org.dcache.gplazma.AuthenticationException) GPlazmaMappingPlugin(org.dcache.gplazma.plugins.GPlazmaMappingPlugin) Result(org.dcache.gplazma.monitor.LoginMonitor.Result)

Example 3 with Result

use of org.dcache.gplazma.monitor.LoginMonitor.Result in project dcache by dCache.

the class LoginResultPrinter method printValidation.

private void printValidation() {
    if (_result.hasValidationHappened()) {
        Result result = _result.getValidationResult();
        String label = stringFor(_result.getValidationResult());
        _sb.append(" +--VALIDATION ").append(label);
        if (result == Result.FAIL) {
            _sb.append(" (").append(_result.getValidationError()).append(")");
        }
        _sb.append('\n');
    } else {
        _sb.append(" +--(VALIDATION) skipped\n");
    }
}
Also used : ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) AccountPhaseResult(org.dcache.gplazma.monitor.LoginResult.AccountPhaseResult) AuthPhaseResult(org.dcache.gplazma.monitor.LoginResult.AuthPhaseResult) PAMPluginResult(org.dcache.gplazma.monitor.LoginResult.PAMPluginResult) SessionPluginResult(org.dcache.gplazma.monitor.LoginResult.SessionPluginResult) MapPhaseResult(org.dcache.gplazma.monitor.LoginResult.MapPhaseResult) AccountPluginResult(org.dcache.gplazma.monitor.LoginResult.AccountPluginResult) SessionPhaseResult(org.dcache.gplazma.monitor.LoginResult.SessionPhaseResult) PhaseResult(org.dcache.gplazma.monitor.LoginResult.PhaseResult) MapPluginResult(org.dcache.gplazma.monitor.LoginResult.MapPluginResult) Result(org.dcache.gplazma.monitor.LoginMonitor.Result) AuthPluginResult(org.dcache.gplazma.monitor.LoginResult.AuthPluginResult)

Example 4 with Result

use of org.dcache.gplazma.monitor.LoginMonitor.Result in project dcache by dCache.

the class LoginResultPrinter method printInitialPart.

private void printInitialPart() {
    Result result = getOverallResult();
    _sb.append("LOGIN ").append(stringFor(result)).append("\n");
    printLines(" in", buildInLines());
    printLines("out", buildOutItems());
    _sb.append(" |\n");
}
Also used : AccountPhaseResult(org.dcache.gplazma.monitor.LoginResult.AccountPhaseResult) AuthPhaseResult(org.dcache.gplazma.monitor.LoginResult.AuthPhaseResult) PAMPluginResult(org.dcache.gplazma.monitor.LoginResult.PAMPluginResult) SessionPluginResult(org.dcache.gplazma.monitor.LoginResult.SessionPluginResult) MapPhaseResult(org.dcache.gplazma.monitor.LoginResult.MapPhaseResult) AccountPluginResult(org.dcache.gplazma.monitor.LoginResult.AccountPluginResult) SessionPhaseResult(org.dcache.gplazma.monitor.LoginResult.SessionPhaseResult) PhaseResult(org.dcache.gplazma.monitor.LoginResult.PhaseResult) MapPluginResult(org.dcache.gplazma.monitor.LoginResult.MapPluginResult) Result(org.dcache.gplazma.monitor.LoginMonitor.Result) AuthPluginResult(org.dcache.gplazma.monitor.LoginResult.AuthPluginResult)

Example 5 with Result

use of org.dcache.gplazma.monitor.LoginMonitor.Result in project dcache by dCache.

the class DefaultAccountStrategy method account.

/**
 * Devegates execution of the {@link GPlazmaAccountPlugin#account(SessionID, Set<Principal>)
 * GPlazmaAccountPlugin.account} methods of the plugins supplied by {@link
 * GPlazmaStrategy#setPlugins(List< GPlazmaPluginService <T>>) GPlazmaStrategy.setPlugins} to
 * {@link  PAMStyleStrategy#callPlugins(PluginCaller<T>) PAMStyleStrategy.callPlugins(PluginCaller<T>)}
 * by providing anonymous implementation of the {@link PluginCaller#call(GPlazmaPlugin)
 * PluginCaller} interface.
 *
 * @param sessionID
 * @param authorizedPrincipals
 * @throws AuthenticationException
 * @see PAMStyleStrategy
 * @see PluginCaller
 */
@Override
public void account(final LoginMonitor monitor, final Set<Principal> authorizedPrincipals) throws AuthenticationException {
    pamStyleAccountStrategy.callPlugins(service -> {
        monitor.accountPluginBegins(service.getName(), service.getControl(), authorizedPrincipals);
        GPlazmaAccountPlugin plugin = service.getPlugin();
        Result result = Result.FAIL;
        String error = null;
        try {
            plugin.account(authorizedPrincipals);
            result = Result.SUCCESS;
        } catch (AuthenticationException e) {
            error = e.getMessage();
            throw e;
        } finally {
            monitor.accountPluginEnds(service.getName(), service.getControl(), result, error, authorizedPrincipals);
        }
    });
}
Also used : AuthenticationException(org.dcache.gplazma.AuthenticationException) GPlazmaAccountPlugin(org.dcache.gplazma.plugins.GPlazmaAccountPlugin) Result(org.dcache.gplazma.monitor.LoginMonitor.Result)

Aggregations

Result (org.dcache.gplazma.monitor.LoginMonitor.Result)8 AuthenticationException (org.dcache.gplazma.AuthenticationException)4 AccountPhaseResult (org.dcache.gplazma.monitor.LoginResult.AccountPhaseResult)3 AccountPluginResult (org.dcache.gplazma.monitor.LoginResult.AccountPluginResult)3 AuthPhaseResult (org.dcache.gplazma.monitor.LoginResult.AuthPhaseResult)3 AuthPluginResult (org.dcache.gplazma.monitor.LoginResult.AuthPluginResult)3 MapPhaseResult (org.dcache.gplazma.monitor.LoginResult.MapPhaseResult)3 MapPluginResult (org.dcache.gplazma.monitor.LoginResult.MapPluginResult)3 PAMPluginResult (org.dcache.gplazma.monitor.LoginResult.PAMPluginResult)3 PhaseResult (org.dcache.gplazma.monitor.LoginResult.PhaseResult)3 SessionPhaseResult (org.dcache.gplazma.monitor.LoginResult.SessionPhaseResult)3 SessionPluginResult (org.dcache.gplazma.monitor.LoginResult.SessionPluginResult)3 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 Subject (javax.security.auth.Subject)1 ConfigurationItemControl (org.dcache.gplazma.configuration.ConfigurationItemControl)1 LoginResult (org.dcache.gplazma.monitor.LoginResult)1 GPlazmaAccountPlugin (org.dcache.gplazma.plugins.GPlazmaAccountPlugin)1 GPlazmaAuthenticationPlugin (org.dcache.gplazma.plugins.GPlazmaAuthenticationPlugin)1 GPlazmaMappingPlugin (org.dcache.gplazma.plugins.GPlazmaMappingPlugin)1 GPlazmaSessionPlugin (org.dcache.gplazma.plugins.GPlazmaSessionPlugin)1