001/* 002 * acme4j - Java ACME client 003 * 004 * Copyright (C) 2015 Richard "Shred" Körber 005 * http://acme4j.shredzone.org 006 * 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 013 */ 014package org.shredzone.acme4j.challenge; 015 016import org.shredzone.acme4j.Session; 017 018/** 019 * Implements the {@value TYPE} challenge. 020 */ 021public class Http01Challenge extends TokenChallenge { 022 private static final long serialVersionUID = 3322211185872544605L; 023 024 /** 025 * Challenge type name: {@value} 026 */ 027 public static final String TYPE = "http-01"; 028 029 /** 030 * Creates a new generic {@link Http01Challenge} object. 031 * 032 * @param session 033 * {@link Session} to bind to. 034 */ 035 public Http01Challenge(Session session) { 036 super(session); 037 } 038 039 /** 040 * Returns the token to be used for this challenge. 041 */ 042 @Override 043 public String getToken() { 044 return super.getToken(); 045 } 046 047 /** 048 * Returns the authorization string to be used for the response. 049 * <p> 050 * <em>NOTE:</em> The response file must only contain the returned String (UTF-8 051 * or ASCII encoded). There must not be any other leading or trailing characters 052 * (like white-spaces or line breaks). Otherwise the challenge will fail. 053 */ 054 @Override 055 public String getAuthorization() { 056 return super.getAuthorization(); 057 } 058 059 @Override 060 protected boolean acceptable(String type) { 061 return TYPE.equals(type); 062 } 063 064}