Package org.ietf.jgss

Examples of org.ietf.jgss.GSSException


      return GSSCredential.INITIATE_ONLY;
    }
    if (isAccept) {
      return GSSCredential.ACCEPT_ONLY;
    }
    throw new GSSException(GSSException.BAD_MECH,
        GSSUtils.DEFAULT_GSSEXCEPTION_MINOR_CODE,
        "no credential for mech " + mech);
  }
View Full Code Here


        "no credential for mech " + mech);
  }

  private void checkDisposed() throws GSSException {
    if (disposed) {
      throw new GSSException(GSSUtils.DEFAULT_GSSEXCEPTION_MAJOR_CODE,
          GSSUtils.DEFAULT_GSSEXCEPTION_MINOR_CODE,
          "credential disposed");
    }
  }
View Full Code Here

          serverSubject, serverPrincipal,
          gssManager, GSSCredential.ACCEPT_ONLY);
        }
          });
    } catch (PrivilegedActionException pe) {
        GSSException ge = (GSSException) pe.getException();
        throw new UnsupportedConstraintException(
      "Failed to get GSSCredential for server principal: " +
      serverPrincipal, ge);
    }
      } catch (UnsupportedConstraintException uce) {
View Full Code Here

     */
    public static void obtainServiceTickets( Subject subject, String userName, String serviceName, String hostName )
        throws GSSException
    {
        ObtainServiceTicketAction action = new ObtainServiceTicketAction( userName, serviceName, hostName );
        GSSException exception = Subject.doAs( subject, action );
        if ( exception != null )
        {
            throw exception;
        }
    }
View Full Code Here

               initSASLServer();
           } catch (SaslException ex) {
               if (debugEnabled())
                   TRACER.debugCaught(DebugLogLevel.ERROR, ex);
               Message msg;
               GSSException gex = (GSSException) ex.getCause();
               if(gex != null)
                 msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
                     GSSAPISASLMechanismHandler.getGSSExceptionMessage(gex));
               else
                  msg = ERR_SASL_CONTEXT_CREATE_ERROR.get(SASL_MECHANISM_GSSAPI,
View Full Code Here

            int lifetime) throws GSSException {
       
        if (peer != null) {
            this.targetName = (GSSNameImpl)peer;
        } else {
            throw new GSSException(GSSException.BAD_NAME);
        }

        if (mech == null) {
            /* default native mech = gss_mech_krb5 */
            this.mech = new OidImpl("1.2.840.113554.1.2.2");
View Full Code Here

                }
            }

        } catch (IOException e) {
            /* I/O Error occurred when reading InputStream */
            throw new GSSException(GSSException.FAILURE);
        }
      
        /* read token -> byte array -> gss_buffer_desc for native gssapi */
        inputTokArray = outTok.toByteArray();
        if (inputTokArray != null && inputTokArray.length > 0) {
            gsswrapper.setDescArray(inputToken, inputTokArray);
            inputToken.setLength(inputTokArray.length);
        }

        /* get requested flags */
        long requestedFlags = getRequestedFlags();

        maj_status = gsswrapper.gss_init_sec_context(min_status,
                credential.getInternGSSCred(),
                context_tmp,
                targetName.getInternGSSName(),
                mech.getNativeOid(),
                requestedFlags,
                lifetime,
                channelBinding.getNativeChannelBindings(),
                inputToken,
                actual_mech_type,
                outputToken,
                actual_flags,
                time_rec);

        if (maj_status == gsswrapper.GSS_S_CONTINUE_NEEDED) {
            /* gss_init_sec_context needs to be called again with output
               token from gss_accept_sec_context. */
            ctxState = State.INPROG;
        } else if (maj_status != gsswrapper.GSS_S_COMPLETE) {
            throw new GSSExceptionImpl((int) maj_status, (int) min_status[0]);
        } else {
            ctxState = State.DONE;
        }

        /* save native context */
        internGSSCtx = context_tmp;

        /* set some context variables */
        this.lifetime = (int) time_rec[0];
        mech = new OidImpl(actual_mech_type.toDotString());
        setReturnedFlags(actual_flags[0]);

        /* set our context as an initiator */
        this.initiator = true;

        /* place output token into OutputStream */
        if (outputToken.getLength() > 0) {
            temp_token = new byte[(int) outputToken.getLength()];
            temp_token = gsswrapper.getDescArray(outputToken);
            try {
                outStream.write(temp_token);
            } catch (IOException e) {
                throw new GSSException(GSSException.FAILURE);
            }
            ret = temp_token.length;
        } else {
            ret = 0;
        }
View Full Code Here

                }
            }

        } catch (IOException e) {
            /* I/O Error occurred when reading InputStream */
            throw new GSSException(GSSException.FAILURE);
        }

        /* read token into byte array, gss_buffer_desc for native gssapi */
        inputTokArray = outTok.toByteArray();
        if (inputTokArray != null && inputTokArray.length > 0) {
            gsswrapper.setDescArray(inputToken, inputTokArray);
            inputToken.setLength(inputTokArray.length);
        }

        requestedFlags = getRequestedFlags();

        maj_status = gsswrapper.gss_accept_sec_context(min_status,
                context_tmp,
                credential.getInternGSSCred(),
                inputToken,
                channelBinding.getNativeChannelBindings(),
                srcName.getInternGSSName(),
                actual_mech_type,
                outputToken,
                actual_flags,
                time_rec,
                delegatedCred);

        if (maj_status == gsswrapper.GSS_S_CONTINUE_NEEDED) {
            ctxState = State.INPROG;
        } else if (maj_status != gsswrapper.GSS_S_COMPLETE) {
            throw new GSSExceptionImpl((int)maj_status, (int)min_status[0]);
        } else {
            ctxState = State.DONE;
        }

        /* set context */
        internGSSCtx = context_tmp;

        /* save some context variables */
        this.lifetime = time_rec[0];
        mech = new OidImpl(actual_mech_type.toDotString());
        setReturnedFlags(actual_flags[0]);

        if (delegCredential == null)
            delegCredential = new GSSCredentialImpl();
        delegCredential.setInternGSSCred(delegatedCred);
       
        /* set our context as an acceptor */
        this.initiator = false;

        /* place output token into OutputStream */
        if (outputToken.getLength() > 0) {
            byte[] temp_token = new byte[(int) outputToken.getLength()];
            temp_token = gsswrapper.getDescArray(outputToken);
            try {
                outStream.write(temp_token);
            } catch (IOException e) {
                throw new GSSException(GSSException.FAILURE);
            }
        }

        /* release native structures */
        gsswrapper.gss_release_buffer(min_status, outputToken);
View Full Code Here

            for (int i = 0; i < numBytes; i++) {
                inMsgTmp.write(inStream.read());
            }

        } catch (IOException e) {
            throw new GSSException(GSSException.FAILURE);
        }
        inMsg = inMsgTmp.toByteArray();

        /* copy input message to gss_buffer_desc for native wrap() */
        if (inMsg != null) {
            gsswrapper.setDescArray(inputMsg, inMsg);
            inputMsg.setLength(inMsg.length);
        }

        /* determine requested level of confidentiality and integrity */
        if (msgProp.getPrivacy())
            conf_req = 1;

        maj_status = gsswrapper.gss_wrap(min_status, this.internGSSCtx,
                conf_req, msgProp.getQOP(), inputMsg, state, outputMsg);

        if (maj_status != gsswrapper.GSS_S_COMPLETE) {
            throw new GSSExceptionImpl((int) maj_status, (int) min_status[0]);
        }
       
        /* set the actual privacy state applied for caller to use */
        if (state[0] == 0) {
            msgProp.setPrivacy(false);
        } else {
            msgProp.setPrivacy(true);
        }

        /* get the byte[] from our outputMsg, copy back to OutputStream */
        if (outputMsg.getLength() > 0) {
            temp_msg = new byte[(int) outputMsg.getLength()];
            temp_msg = gsswrapper.getDescArray(outputMsg);
            try {
                outStream.write(temp_msg);
            } catch (IOException e) {
                throw new GSSException(GSSException.FAILURE);
            }
        }

        /* release native structures */
        gsswrapper.gss_release_buffer(min_status, outputMsg);
View Full Code Here

            for (int i = 0; i < numBytes; i++) {
                inMsgTmp.write(inStream.read());
            }

        } catch (IOException e) {
            throw new GSSException(GSSException.FAILURE);
        }
        inMsg = inMsgTmp.toByteArray();

        /* copy input message to gss_buffer_desc for native unwrap() */
        if (inMsg != null) {
            gsswrapper.setDescArray(inputMsg, inMsg);
            inputMsg.setLength(inMsg.length);
        }

        maj_status = gsswrapper.gss_unwrap(min_status, this.internGSSCtx,
                inputMsg, outputMsg, conf_state, qop_state);

        if (maj_status != gsswrapper.GSS_S_COMPLETE) {
            throw new GSSExceptionImpl((int) maj_status, (int) min_status[0]);
        } else {

            /* set supplementary info */
            if ((maj_status & gsswrapper.GSS_S_DUPLICATE_TOKEN) != 0)
                tokDup =  true;
            if ((maj_status & gsswrapper.GSS_S_OLD_TOKEN) != 0)
                tokOld =  true;
            if ((maj_status & gsswrapper.GSS_S_UNSEQ_TOKEN) != 0)
                tokUnseq =  true;
            if ((maj_status & gsswrapper.GSS_S_GAP_TOKEN) != 0)
                tokGap =  true;

            msgProp.setSupplementaryStates(tokDup, tokOld, tokUnseq, tokGap,
                    (int)min_status[0], "");
        }

        /* set the actual privacy and conf state applied for caller to use */
        if (conf_state[0] == 0) {
            msgProp.setPrivacy(false);
        } else {
            msgProp.setPrivacy(true);
        }

        msgProp.setQOP((int) qop_state[0]);

        /* get the byte[] from our outputMsg, copy back to OutputStream */
        if (outputMsg.getLength() > 0) {
            byte[] temp_msg = new byte[(int) outputMsg.getLength()];
            temp_msg = gsswrapper.getDescArray(outputMsg);
            gsswrapper.gss_release_buffer(min_status, outputMsg);
            try {
                outStream.write(temp_msg);
            } catch (IOException e) {
                throw new GSSException(GSSException.FAILURE);
            }
        }

        /* release native structures */
        gsswrapper.gss_release_buffer(min_status, outputMsg);
View Full Code Here

TOP

Related Classes of org.ietf.jgss.GSSException

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.