Package org.apache.ws.security

Examples of org.apache.ws.security.KerberosTokenPrincipal


      WSSConfig wsc) throws WSSecurityException {
    X509Certificate returnCert[];
    Set returnElements;
    Set protectedElements;
    byte signatureValue[][];
    KerberosTokenPrincipal lastPrincipalFound;

    WSDocInfoStore.store(wsDocInfo);
    returnCert = new X509Certificate[1];
    returnElements = new HashSet();
    protectedElements = new TreeSet();
View Full Code Here


      X509Certificate returnCert[], Set returnElements,
      Set protectedElements, byte signatureValue[][],
      CallbackHandler handler) throws WSSecurityException {

    SecretKey secretKey = null;
    KerberosTokenPrincipal principal = null;

    try {
      authenticate(handler);
      KerberosSecurity ks = createSecurityToken(elem);
      GSSContext context = acceptSecurityContext(ks);
      secretKey = getSessionKey(ks.getToken());

      if (log.isDebugEnabled()) {
        log.debug((new StringBuilder())
            .append("security context accepted with ")
            .append(context.getSrcName().toString())
            .append(",")
            .append(context.getSrcName().getStringNameType()
                .toString()).toString());
      }

      principal = new KerberosTokenPrincipal(context.getSrcName()
          .toString());
      principal.setTokenElement(elem);

      if (secretKey != null) {
        principal.setSessionKey(secretKey.getEncoded());
      } else {
        log.error("null secret key");
        throw new WSSecurityException(3, "nullSecretKey",
            new Object[] { "null secret key" });
      }

      principal.setSecretKey(secretKey);

      KrbSession kerberosSession = new KrbSession(ks.getSHA1(), secretKey);
      kerberosSession.setClientPrincipalName(context.getSrcName()
          .toString());
      kerberosSession.setServerPrincipalName(context.getTargName()
          .toString());
      KrbSessionCache.getInstance().addSession(kerberosSession);

      principal.setClientPrincipalName(kerberosSession
          .getClientPrincipalName());
      principal.setServicePrincipalName(kerberosSession
          .getServerPrincipalName());

    } catch (RuntimeException e) {
      log.error(e.getMessage(), e);
      throw new WSSecurityException(3, "kerberosAcceptCtxFailed",
View Full Code Here

    sig.addResourceResolver(EnvelopeIdResolver.getInstance());
    KeyInfo info = sig.getKeyInfo();
    SecretKey secretKey = null;

    KerberosTokenPrincipal principal = null;

    if (info != null) {
      org.w3c.dom.Node node = WSSecurityUtil.getDirectChild(
          info.getElement(), "SecurityTokenReference",
          WSConstants.WSSE_NS);

      if (node == null) {
        throw new WSSecurityException(3, "unsupportedKeyInfo");
      }

      SecurityTokenReference secRef = new SecurityTokenReference(
          (Element) node);
      WSDocInfo wsDocInfo = WSDocInfoStore
          .lookup(elem.getOwnerDocument());

      if (secRef.containsReference()) {
        Element token = secRef.getTokenElement(elem.getOwnerDocument(),
            wsDocInfo, cb);
        QName el = new QName(token.getNamespaceURI(),
            token.getLocalName());
        if (el.equals(WSSecurityEngine.binaryToken))
          try {
            if (lastPrincipalFound == null) {
              authenticate(cb);
              KerberosSecurity ks = createSecurityToken(token);
              GSSContext context = acceptSecurityContext(ks);
              secretKey = getSessionKey(ks.getToken());
              if (log.isDebugEnabled()) {
                log.debug("security context accepted with "
                    + context.getSrcName().toString()
                    + ","
                    + context.getSrcName()
                        .getStringNameType());
              }
              principal = new KerberosTokenPrincipal(context
                  .getSrcName().toString());
              principal.setTokenElement(token);
              principal.setSessionKey(secretKey.getEncoded());
              principal.setSecretKey(secretKey);
              KrbSession kerberosSession = new KrbSession(
                  ks.getSHA1(), secretKey);
              kerberosSession.setClientPrincipalName(context
                  .getSrcName().toString());
              kerberosSession.setServerPrincipalName(context
                  .getTargName().toString());
              KrbSessionCache.getInstance().addSession(
                  kerberosSession);
              principal.setClientPrincipalName(kerberosSession
                  .getClientPrincipalName());
              principal.setServicePrincipalName(kerberosSession
                  .getServerPrincipalName());
            } else {
              secretKey = lastPrincipalFound.getSecretKey();
            }
          } catch (RuntimeException e) {
View Full Code Here

            Vector wsSecEngineResults = rResult.getResults();
            for (int j = 0; j < wsSecEngineResults.size(); j++) {
                WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults.get(j);
                Integer actInt = (Integer) wser.get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt.intValue() == org.apache.ws.security.WSConstants.KERBEROS_SIGN) {
                    KerberosTokenPrincipal principal = (KerberosTokenPrincipal) wser
                            .get(WSSecurityEngineResult.TAG_PRINCIPAL);
                    BinarySecurity token;
                    try {
                        token = new BinarySecurity(principal.getTokenElement());
                        krbToken.setBSTToken(token);
                    } catch (WSSecurityException e) {
                        throw new RampartException("errorExtractingKereberosToken");
                    }
                }
View Full Code Here

            } else if (WSConstants.SIGN == actInt.intValue()) {
                X509Certificate cert = (X509Certificate) wser
                        .get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
                msgCtx.setProperty(RampartMessageData.X509_CERT, cert);
            } else if (WSConstants.KERBEROS == actInt.intValue()) {
                KerberosTokenPrincipal principal = null;
                principal = ((KerberosTokenPrincipal) wser
                        .get(WSSecurityEngineResult.TAG_PRINCIPAL));
                if (principal != null) {
                    String clientPricipalName = principal.getClientPrincipalName();
                    String servicePricipalName = principal.getServicePrincipalName();
                    if (clientPricipalName != null) {
                        msgCtx.getOptions().setProperty(KerberosConfig.CLIENT_PRINCIPLE_NAME,
                                clientPricipalName);
                    }
                    if (servicePricipalName != null) {
                        msgCtx.getOptions().setProperty(KerberosConfig.SERVICE_PRINCIPLE_NAME,
                                servicePricipalName);
                    }
                }
            } else if (WSConstants.KERBEROS_ENCR == actInt.intValue()) {
                KerberosTokenPrincipal principal = null;
                principal = ((KerberosTokenPrincipal) wser
                        .get(WSSecurityEngineResult.TAG_PRINCIPAL));
                if (principal != null) {
                    String clientPricipalName = principal.getClientPrincipalName();
                    String servicePricipalName = principal.getServicePrincipalName();
                    if (clientPricipalName != null) {
                        msgCtx.getOptions().setProperty(KerberosConfig.CLIENT_PRINCIPLE_NAME,
                                clientPricipalName);
                    }
                    if (servicePricipalName != null) {
                        msgCtx.getOptions().setProperty(KerberosConfig.SERVICE_PRINCIPLE_NAME,
                                servicePricipalName);
                    }
                }
            } else if (WSConstants.KERBEROS_SIGN == actInt.intValue()) {
                KerberosTokenPrincipal principal = null;
                principal = ((KerberosTokenPrincipal) wser
                        .get(WSSecurityEngineResult.TAG_PRINCIPAL));
                if (principal != null) {
                    String clientPricipalName = principal.getClientPrincipalName();
                    String servicePricipalName = principal.getServicePrincipalName();
                    if (clientPricipalName != null) {
                        msgCtx.getOptions().setProperty(KerberosConfig.CLIENT_PRINCIPLE_NAME,
                                clientPricipalName);
                    }
                    if (servicePricipalName != null) {
View Full Code Here

TOP

Related Classes of org.apache.ws.security.KerberosTokenPrincipal

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.