/* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. */

import com.sun.net.httpserver.BasicAuthenticator;

public class DICOMAuthenticator extends BasicAuthenticator {
	private static String username = "oracle";
	private static String password =  "welcome";
	
	/**
	 * Construct a authenticator for any request on the realm. 
	 */
	public DICOMAuthenticator(String realm) {
		super(realm);
	}
	
	/**
	 * Check if user and password is the same as predefined ones. 
	 */
	@Override
	public boolean checkCredentials(String usr, String pwd) {
		if (usr.equals(username) && pwd.equals(password)) {
			System.out.println(
			    "[LOG] Authorized user \"" + usr + "\"");
			return true;
		} else {
			System.out.println(
			    "[LOG] Unauthorized user \"" + usr + "\"");
			return false;
		}
	}
}
