Package javax.security.auth.callback

Examples of javax.security.auth.callback.CallbackHandler


    protected CallbackHandler getCallback(RequestData reqData, int doAction) throws WSSecurityException {
        /*
         * To check a UsernameToken or to decrypt an encrypted message we need a
         * password.
         */
        CallbackHandler cbHandler = null;
        if ((doAction & (WSConstants.ENCR | WSConstants.UT)) != 0) {
            Object o = ((SoapMessage)reqData.getMsgContext())
                .getContextualProperty(SecurityConstants.CALLBACK_HANDLER);
            if (o instanceof String) {
                try {
View Full Code Here


            String password = options.getPassword();
           
            if(password == null || password.length() == 0) {
               
                //Then try to get the password from the given callback handler
                CallbackHandler handler = RampartUtil.getPasswordCB(rmd);
           
                if(handler == null) {
                    //If the callback handler is missing
                    throw new RampartException("cbHandlerMissing");
                }
               
                WSPasswordCallback[] cb = { new WSPasswordCallback(user,
                        WSPasswordCallback.USERNAME_TOKEN) };
                try {
                    handler.handle(cb);
                } catch (Exception e) {
                    throw new RampartException("errorInGettingPasswordForUser",
                            new String[]{user}, e);
                }
               
View Full Code Here

        if(user != null && !"".equals(user)) {
            log.debug("User : " + user);
           
            //Get the password
            CallbackHandler handler = RampartUtil.getPasswordCB(rmd);
           
            if(handler == null) {
                //If the callback handler is missing
                throw new RampartException("cbHandlerMissing");
            }
           
            WSPasswordCallback[] cb = { new WSPasswordCallback(user,
                    WSPasswordCallback.SIGNATURE) };
           
            try {
                handler.handle(cb);
                if(cb[0].getPassword() != null && !"".equals(cb[0].getPassword())) {
                    password = cb[0].getPassword();
                    log.debug("Password : " + password);
                } else {
                    //If there's no password then throw an exception
View Full Code Here

     * @return The <code>CallbackHandler</code> instance
     * @throws RampartException
     */
    public static CallbackHandler getPasswordCB(MessageContext msgContext, RampartPolicyData rpd) throws RampartException {
       
        CallbackHandler cbHandler;

        if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getPwCbClass() != null) {
           
            String cbHandlerClass = rpd.getRampartConfig().getPwCbClass();
            ClassLoader classLoader = msgContext.getAxisService().getClassLoader();
View Full Code Here

                client.setRstTemplate(rstTemplate);
       
                // Set crypto information
                Crypto crypto = RampartUtil.getSignatureCrypto(rmd.getPolicyData().getRampartConfig(),
                        rmd.getMsgContext().getAxisService().getClassLoader());
                CallbackHandler cbh = RampartUtil.getPasswordCB(rmd);
                client.setCryptoInfo(crypto, cbh);
       
                // Get service policy
                Policy servicePolicy = rmd.getServicePolicy();
       
View Full Code Here

        @Override
        public void validate(TimestampValidationCallback.Request request)
                throws TimestampValidationCallback.TimestampValidationException {
            for (int i = 0; i < getCallbackHandlers().length; i++) {
                CallbackHandler callbackHandler = getCallbackHandlers()[i];
                try {
                    callbackHandler.handle(new Callback[]{callback});
                    callback.getResult();
                }
                catch (IOException e) {
                    throw new TimestampValidationCallback.TimestampValidationException(e);
                }
View Full Code Here

        @Override
        public boolean validate(PasswordValidationCallback.Request request)
                throws PasswordValidationCallback.PasswordValidationException {
            boolean allUnsupported = true;
            for (int i = 0; i < getCallbackHandlers().length; i++) {
                CallbackHandler callbackHandler = getCallbackHandlers()[i];
                try {
                    callbackHandler.handle(new Callback[]{callback});
                    allUnsupported = false;
                    if (!callback.getResult()) {
                        return false;
                    }
                }
View Full Code Here

        @Override
        public boolean validate(X509Certificate certificate)
                throws CertificateValidationCallback.CertificateValidationException {
            boolean allUnsupported = true;
            for (int i = 0; i < getCallbackHandlers().length; i++) {
                CallbackHandler callbackHandler = getCallbackHandlers()[i];
                try {
                    callbackHandler.handle(new Callback[]{callback});
                    allUnsupported = false;
                    if (!callback.getResult()) {
                        return false;
                    }
                }
View Full Code Here

        // 1. Felix JAAS LoginContextFactory is used.
        //In that case client code does not have to
        //manage Thread Context Classloader or provide explicit configuration

        PrintWriter pw = resp.getWriter();
        CallbackHandler handler = new ServletRequestCallbackHandler(req);
        Subject subject = new Subject();
        try
        {
            LoginContext lc = loginContextFactory.createLoginContext("sample",subject,handler);
            lc.login();
View Full Code Here

        //
        //This needs to be enabled via configuration of 'Apache Felix JAAS Configuration SPI'
        //In that case client code does not have to provide explicit configuration

        PrintWriter pw = resp.getWriter();
        CallbackHandler handler = new ServletRequestCallbackHandler(req);

        Subject subject = new Subject();
        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try
        {
View Full Code Here

TOP

Related Classes of javax.security.auth.callback.CallbackHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.