Here you can find the source of getDirectiveValue( HashMap
Parameter | Description |
---|---|
directivesMap | the directive's map |
directive | the name of the directive we want to retrieve |
mandatory | is the directive mandatory |
Parameter | Description |
---|---|
AuthenticationException | if mandatory is true and if directivesMap.get(directive) == null |
public static String getDirectiveValue( HashMap<String, String> directivesMap, String directive, boolean mandatory) throws AuthenticationException
//package com.java2s; /**/*from w w w. ja v a 2 s . c o m*/ * Copyright 2007-2016, Kaazing Corporation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.HashMap; import javax.security.sasl.AuthenticationException; public class Main { /** * A directive is a parameter of the digest authentication process. * Returns the value of a directive from the map. If mandatory is true and the * value is null, then it throws an {@link AuthenticationException}. * * @param directivesMap the directive's map * @param directive the name of the directive we want to retrieve * @param mandatory is the directive mandatory * @return the mandatory value as a String * @throws AuthenticationException if mandatory is true and if * directivesMap.get(directive) == null */ public static String getDirectiveValue( HashMap<String, String> directivesMap, String directive, boolean mandatory) throws AuthenticationException { String value = directivesMap.get(directive); if (value == null) { if (mandatory) { throw new AuthenticationException("\"" + directive + "\" mandatory directive is missing"); } return ""; } return value; } }