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;
}
Aggregations