This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.atomicobject.misc; | |
| import com.google.common.base.Function; | |
| import com.google.common.base.Joiner; | |
| import com.google.common.base.Predicate; | |
| import com.google.common.base.Predicates; | |
| import com.google.common.collect.Collections2; | |
| import com.google.common.collect.ForwardingMap; | |
| import com.google.common.collect.ImmutableList; | |
| import com.google.common.collect.ImmutableMap; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Map<String, String> getData(final Integer id) { | |
| return new LazyImmutableMap<String, String>(new Callable<Map<String, String>() { | |
| public Map<String, String> call() throws Exception { | |
| return externalService.getSomeData(id); | |
| } | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LazyImmutableMap<K,V> extends ForwardingMap<K,V> { | |
| public static class AccessException extends RuntimeException { | |
| public AccessException(Throwable cause) { | |
| super(cause); | |
| } | |
| } | |
| private final FutureTask<Map<K, V>> task; | |
| public LazyImmutableMap(final Callable<Map<K,V>> eval) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ActiveDirectory | |
| include EnvironmentConfigurable | |
| configure_with "config/active_directory.yml" | |
| def self.valid_credentials?(login, password) | |
| ldap = Net::LDAP.new( | |
| :host => config.host, # active_directory.atomicobject.com | |
| :port => config.port, # 389 | |
| :base => config.base, # dc=atomicobject,dc=com | |
| :auth => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'ldap/server' | |
| module TestLdapServer | |
| def start_ldap_server | |
| logger = Logger.new(File.join(Rails.root, "log", "ldap.log")) | |
| logger.level = Logger::DEBUG | |
| logger.datetime_format = "%H:%M:%S" | |
| @ldap_credentials = {"cn=server,dc=atomicobject,dc=com" => "server password"} | |
| @ldap_server = LDAP::Server.new({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LdapOperation < LDAP::Server::Operation | |
| def initialize(connection, message_id, valid_credentials, logger) | |
| super(connection, message_id) | |
| @logger = logger | |
| @valid_credentials = valid_credentials | |
| end | |
| def simple_bind(version, dn, password) | |
| @logger.info "Got a simple_bind version: #{version.inspect}, dn: #{dn.inspect}, password #{password.inspect}" | |
| if version != 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Before('@active_directory') do | |
| start_ldap_server | |
| end | |
| After('@active_directory') do | |
| stop_ldap_server | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'happening' | |
| EM.run do | |
| EventMachine::add_periodic_timer(1) { print "." } | |
| item = Happening::S3::Item.new('my_bucket', | |
| "22mb_file", | |
| :aws_access_key_id => 'MY_ACCESS_KEY', | |
| :aws_secret_access_key => 'my_secret_key', | |
| :permissions => 'public-read') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| item = Happening::S3::Item.new('my_bucket', 'my_file', :protocol => "http", ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var addToTheList = function($elem, value) { | |
| var itemHtml = '<li>' + value + '</li>', | |
| selector = ".list"; | |
| $elem.find(selector).andSelf().filter(selector).append(itemHtml); | |
| }; |
OlderNewer