001/**
002 *
003 * Copyright the original author or authors
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smack.sasl.javax;
018
019import java.util.Map;
020
021import javax.security.sasl.Sasl;
022
023/**
024 * Implementation of the SASL GSSAPI mechanism.
025 *
026 * @author Jay Kline
027 */
028public class SASLGSSAPIMechanism extends SASLJavaXMechanism {
029
030    public static final String NAME = GSSAPI;
031
032    @Override
033    public boolean authzidSupported() {
034      return true;
035    }
036
037    @Override
038    public String getName() {
039        return NAME;
040    }
041
042    @Override
043    protected Map<String, String> getSaslProps() {
044        Map<String, String> props = super.getSaslProps();
045        props.put(Sasl.SERVER_AUTH, "TRUE");
046        return props;
047    }
048
049    /**
050     * GSSAPI differs from all other SASL mechanism such that it required the FQDN host name as
051     * server name and not the serviceName (At least that is what old code comments of Smack tell
052     * us).
053     */
054    @Override
055    protected String getServerName() {
056        return host;
057    }
058
059    @Override
060    public int getPriority() {
061        return 100;
062    }
063
064    @Override
065    public SASLGSSAPIMechanism newInstance() {
066        return new SASLGSSAPIMechanism();
067    }
068
069    @Override
070    public boolean requiresPassword() {
071        return false;
072    }
073}