SASLGSSAPIMechanism.java

  1. /**
  2.  *
  3.  * Copyright the original author or authors
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smack.sasl.javax;

  18. import java.util.Map;

  19. import javax.security.sasl.Sasl;

  20. /**
  21.  * Implementation of the SASL GSSAPI mechanism.
  22.  *
  23.  * @author Jay Kline
  24.  */
  25. public class SASLGSSAPIMechanism extends SASLJavaXMechanism {

  26.     public static final String NAME = GSSAPI;

  27.     @Override
  28.     public boolean authzidSupported() {
  29.       return true;
  30.     }

  31.     @Override
  32.     public String getName() {
  33.         return NAME;
  34.     }

  35.     @Override
  36.     protected Map<String, String> getSaslProps() {
  37.         Map<String, String> props = super.getSaslProps();
  38.         props.put(Sasl.SERVER_AUTH, "TRUE");
  39.         return props;
  40.     }

  41.     /**
  42.      * GSSAPI differs from all other SASL mechanism such that it required the FQDN host name as
  43.      * server name and not the serviceName (At least that is what old code comments of Smack tell
  44.      * us).
  45.      */
  46.     @Override
  47.     protected String getServerName() {
  48.         return host;
  49.     }

  50.     @Override
  51.     public int getPriority() {
  52.         return 100;
  53.     }

  54.     @Override
  55.     public SASLGSSAPIMechanism newInstance() {
  56.         return new SASLGSSAPIMechanism();
  57.     }

  58.     @Override
  59.     public boolean requiresPassword() {
  60.         return false;
  61.     }
  62. }