/*******************************************************************************
* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0 which accompany this distribution.
*
* The Apache License is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
*******************************************************************************/

package org.openscore.content.httpclient.build.auth;

import com.sun.security.auth.module.Krb5LoginModule;

import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: davidmih
 * Date: 9/23/14
 */
public class KrbHttpLoginModule extends Krb5LoginModule {
    static String USR = "javax.security.auth.login.name";
    static String PAS = "javax.security.auth.login.password";
    @Override
    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
        super.initialize(subject, callbackHandler, sharedState, options);    //To change body of overridden methods use File | Settings | File Templates.
        Map<String, Object> myss = (Map<String, Object>) sharedState;
        myss.put(USR, System.getProperty(USR));
        myss.put(PAS, System.getProperty(PAS).toCharArray());
    }
}

@@ -659,23 +659,189 @@
 Callback
-Handler
+;%0Aimport javax.security.auth.callback.CallbackHandler;%0Aimport javax.security.auth.callback.UnsupportedCallbackException;%0Aimport java.io.IOException;%0Aimport java.util.HashMap
 ;%0Aimport
@@ -1584,20 +1584,90 @@
 arArray());%0A
+        System.clearProperty(USR);%0A        System.clearProperty(PAS);%0A
     %7D%0A%7D%0A

Fix security issue (Kerberos auth): clear saved username & password from System Property after using them. Signed-off-by: Mihail Cristian Tusa mihail-cristian.tusa@hp.com