Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
  * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
  */
 package com.hp.autonomy.frontend.configuration.authentication;
 
    private final String roleDefault;
    private final ConfigService<? extends AuthenticationConfig<?>> configService;
    public DefaultLoginAuthenticationProvider(final ConfigService<? extends AuthenticationConfig<?>> configServicefinal String roleDefault) {
        this. = roleDefault;
        this. = configService;
    }
    @Override
    public Authentication authenticate(final Authentication authenticationthrows AuthenticationException {
        final com.hp.autonomy.frontend.configuration.Authentication<?> authenticationConfig = .getConfig().getAuthentication();
        if(!..equalsIgnoreCase(authenticationConfig.getMethod())) {
            return null;
        }
        final UsernameAndPassword defaultLogin = authenticationConfig.getDefaultLogin();
        final String username = authentication.getName();
        final String password = authentication.getCredentials().toString();
        if(defaultLogin.getUsername().equals(username) && defaultLogin.getPassword().equals(password)) {
            return new UsernamePasswordAuthenticationToken(usernamepassword, Arrays.asList(new SimpleGrantedAuthority()));
        }
        else {
            throw new BadCredentialsException("Access is denied");
        }
    }
    @Override
    public boolean supports(final Class<?> authentication) {
        return UsernamePasswordAuthenticationToken.class == authentication;
    }
New to GrepCode? Check out our FAQ X