Search in sources :

Example 1 with MapIdentityManager

use of com.iota.iri.utils.MapIdentityManager in project iri by iotaledger.

the class API method addSecurity.

private HttpHandler addSecurity(final HttpHandler toWrap) {
    String credentials = instance.configuration.string(DefaultConfSettings.REMOTE_AUTH);
    if (credentials == null || credentials.isEmpty()) {
        return toWrap;
    }
    final Map<String, char[]> users = new HashMap<>(2);
    users.put(credentials.split(":")[0], credentials.split(":")[1].toCharArray());
    IdentityManager identityManager = new MapIdentityManager(users);
    HttpHandler handler = toWrap;
    handler = new AuthenticationCallHandler(handler);
    handler = new AuthenticationConstraintHandler(handler);
    final List<AuthenticationMechanism> mechanisms = Collections.singletonList(new BasicAuthenticationMechanism("Iota Realm"));
    handler = new AuthenticationMechanismsHandler(handler, mechanisms);
    handler = new SecurityInitialHandler(AuthenticationMode.PRO_ACTIVE, identityManager, handler);
    return handler;
}
Also used : HttpHandler(io.undertow.server.HttpHandler) AuthenticationConstraintHandler(io.undertow.security.handlers.AuthenticationConstraintHandler) IdentityManager(io.undertow.security.idm.IdentityManager) MapIdentityManager(com.iota.iri.utils.MapIdentityManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) BasicAuthenticationMechanism(io.undertow.security.impl.BasicAuthenticationMechanism) AuthenticationMechanism(io.undertow.security.api.AuthenticationMechanism) HttpString(io.undertow.util.HttpString) MapIdentityManager(com.iota.iri.utils.MapIdentityManager) SecurityInitialHandler(io.undertow.security.handlers.SecurityInitialHandler) AuthenticationMechanismsHandler(io.undertow.security.handlers.AuthenticationMechanismsHandler) AuthenticationCallHandler(io.undertow.security.handlers.AuthenticationCallHandler) BasicAuthenticationMechanism(io.undertow.security.impl.BasicAuthenticationMechanism)

Aggregations

MapIdentityManager (com.iota.iri.utils.MapIdentityManager)1 AuthenticationMechanism (io.undertow.security.api.AuthenticationMechanism)1 AuthenticationCallHandler (io.undertow.security.handlers.AuthenticationCallHandler)1 AuthenticationConstraintHandler (io.undertow.security.handlers.AuthenticationConstraintHandler)1 AuthenticationMechanismsHandler (io.undertow.security.handlers.AuthenticationMechanismsHandler)1 SecurityInitialHandler (io.undertow.security.handlers.SecurityInitialHandler)1 IdentityManager (io.undertow.security.idm.IdentityManager)1 BasicAuthenticationMechanism (io.undertow.security.impl.BasicAuthenticationMechanism)1 HttpHandler (io.undertow.server.HttpHandler)1 HttpString (io.undertow.util.HttpString)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1