/** * * @param username user name * @param password password */ public BasicAuthentication(final String username, final String password) { authHeader = BasicAuthHelper.createHeader(username, password); }
protected GenericPrincipal basicAuth(Request request, Response response) throws IOException { String authHeader = request.getHeader(HttpHeaders.AUTHORIZATION); if (authHeader == null) { basicAuthError(response); return null; } String[] creds = BasicAuthHelper.parseHeader(authHeader); if (creds == null) { basicAuthError(response); return null; } String username = creds[0]; String password = creds[1]; GenericPrincipal gp = (GenericPrincipal) context.getRealm().authenticate(username, password); if (gp == null) { basicAuthError(response); return null; } return gp; }
/** * * @param username user name * @param password password */ public BasicAuthentication(String username, String password) { authHeader = BasicAuthHelper.createHeader(username, password); }
/** * * @param username * @param password */ public BasicAuthentication(String username, String password) { authHeader = BasicAuthHelper.createHeader(username, password); }
public ConditionalBasicAuthentication(String username, String password) { this.authHeader = BasicAuthHelper.createHeader(username, password); }
public String resolveBearerToken(String redirectUri, String code) { redirectUri = stripOauthParametersFromRedirect(redirectUri); String authHeader = BasicAuthHelper.createHeader(clientId, password); Form codeForm = new Form() .param("grant_type", "authorization_code") .param("code", code) .param("redirect_uri", redirectUri); Response res = client.target(codeUrl).request().header(HttpHeaders.AUTHORIZATION, authHeader).post(Entity.form(codeForm)); try { if (res.getStatus() == 400) { throw new BadRequestException(); } else if (res.getStatus() != 200) { throw new InternalServerErrorException(new Exception(Messages.MESSAGES.unknownErrorGettingAccessToken())); } AccessTokenResponse tokenResponse = res.readEntity(AccessTokenResponse.class); return tokenResponse.getToken(); } finally { res.close(); } }
String authHeader = BasicAuthHelper.createHeader(client_id, password); String redirectUri = stripOauthParametersFromRedirect(); Form form = new Form();