001/*
002 * Copyright 2015 Aroma Tech.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 
018package tech.aroma.banana.authentication.service.operations;
019
020
021import com.google.inject.AbstractModule;
022import com.google.inject.Provides;
023import com.google.inject.TypeLiteral;
024import java.time.Duration;
025import java.util.function.Function;
026import org.slf4j.Logger;
027import org.slf4j.LoggerFactory;
028import tech.aroma.banana.thrift.LengthOfTime;
029import tech.aroma.banana.thrift.authentication.service.CreateTokenRequest;
030import tech.aroma.banana.thrift.authentication.service.CreateTokenResponse;
031import tech.aroma.banana.thrift.authentication.service.GetTokenInfoRequest;
032import tech.aroma.banana.thrift.authentication.service.GetTokenInfoResponse;
033import tech.aroma.banana.thrift.authentication.service.InvalidateTokenRequest;
034import tech.aroma.banana.thrift.authentication.service.InvalidateTokenResponse;
035import tech.aroma.banana.thrift.authentication.service.VerifyTokenRequest;
036import tech.aroma.banana.thrift.authentication.service.VerifyTokenResponse;
037import tech.aroma.banana.thrift.functions.TimeFunctions;
038import tech.sirwellington.alchemy.thrift.operations.ThriftOperation;
039
040/**
041 *
042 * @author SirWellington
043 */
044public final class AuthenticationOperationsModule extends AbstractModule
045{
046    private final static Logger LOG = LoggerFactory.getLogger(AuthenticationOperationsModule.class);
047
048    @Override
049    protected void configure()
050    {
051        bind(new TypeLiteral<ThriftOperation<CreateTokenRequest, CreateTokenResponse>>() {})
052            .to(CreateTokenOperation.class);
053        
054        bind(new TypeLiteral<ThriftOperation<GetTokenInfoRequest, GetTokenInfoResponse>>() {})
055            .to(GetTokenInfoOperation.class);
056        
057        
058        bind(new TypeLiteral<ThriftOperation<InvalidateTokenRequest, InvalidateTokenResponse>>() {})
059            .to(InvalidateTokenOperation.class);
060        
061        bind(new TypeLiteral<ThriftOperation<VerifyTokenRequest, VerifyTokenResponse>>() {})
062            .to(VerifyTokenOperation.class);
063        
064    }
065    
066    @Provides
067    Function<LengthOfTime, Duration> provideLengthOfTimeConverter()
068    {
069        return TimeFunctions.LENGTH_OF_TIME_TO_DURATION;
070    }
071    
072}