Examples of Signature


Examples of com.sun.xml.ws.security.opt.crypto.dsig.Signature

     */
    public XMLSignature newXMLSignature(SignedInfo signedInfo, KeyInfo keyInfo) {
        if ( signedInfo == null ) {
            throw new NullPointerException("SignedInfo can not be null");
        }
        Signature signature = new Signature();
        signature.setKeyInfo((com.sun.xml.ws.security.opt.crypto.dsig.keyinfo.KeyInfo) keyInfo);
        signature.setSignedInfo((com.sun.xml.ws.security.opt.crypto.dsig.SignedInfo) signedInfo);
        return signature;
    }
View Full Code Here

Examples of com.sun.xml.ws.security.opt.impl.incoming.Signature

                        SecurityContextToken sct = new SecurityContextToken(message, context, (HashMap) currentParentNS);
                        context.getSecurityContext().getProcessedSecurityHeaders().add(sct);
                        return sct;
                    }
                    case SIGNATURE_ELEMENT:{
                        Signature sig = new Signature(context,currentParentNS,creator,true);
                        sig.process(message);
                        if (sig.getReferences().size() == 0){
                            context.getSecurityContext().getProcessedSecurityHeaders().add(sig);
                        }
                        context.getInferredSecurityPolicy().append(sig.getPolicy());
                        return sig;
                    }
                    case SAML_ASSERTION_ELEMEMENT :{
                        SAMLAssertion samlAssertion = new SAMLAssertion(message,context,null,(HashMap) currentParentNS);
                        context.getSecurityContext().getProcessedSecurityHeaders().add(samlAssertion);
View Full Code Here

Examples of edu.harvard.hul.ois.jhove.Signature

    doc.setDate ("2003-11-10");
    doc.setIdentifier (new Identifier ("http://www.w3.org/Graphics/GIF/spec-gif87.txt",
                       IdentifierType.URL));
    _specification.add (doc);

    Signature sig = new InternalSignature ("PNG", SignatureType.MAGIC,
                         SignatureUseType.MANDATORY, 0);
    _signature.add (sig);

    sig = new ExternalSignature (".png", SignatureType.EXTENSION,
                   SignatureUseType.OPTIONAL);
View Full Code Here

Examples of fiftyone.mobile.detection.entities.Signature

    }

    @Override
    public Signature create(Dataset dataSet, int index,
            BinaryReader reader) {
        return new Signature(dataSet, index, reader);
    }
View Full Code Here

Examples of ivory.lsh.data.Signature

        OutputCollector<IntWritable, PairOfFloatInt> output,
        Reporter reporter) throws IOException {
      Long time = System.currentTimeMillis();
      for(int i=0;i<signatures.size();i++){
        IntWritable sampleDocno = (IntWritable)signatures.get(i).getLeftElement();
        Signature fromSample = (Signature)signatures.get(i).getRightElement();
        int dist = signature.hammingDistance(fromSample, maxDist);
 
        if(dist <= maxDist){
          output.collect(new IntWritable(sampleDocno.get()), new PairOfFloatInt(-dist,docno.get()));
        }
View Full Code Here

Examples of java.security.Signature

  }

  private boolean validate(PublicKey publickey, JonasIdentity identity) throws Exception {

    // Build signature with data to validate (principal name + roles)
    Signature signature = null;
    try {
      signature = Signature.getInstance("SHA1withDSA");
    } catch (NoSuchAlgorithmException e) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "EXCEPTION:: validate", e);
      throw new Exception("Error while getting the algorithm 'SHA1withDSA' :" + e.getMessage());
    }

    try {
      signature.initVerify(publickey);
    } catch (InvalidKeyException e) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "EXCEPTION:: validate", e);
      throw new Exception("Cannot initialize the signature with the given public key:" + e.getMessage());
    }

    // Add principal name
    String principal = null;
    try {
      //signature.update(principal.getBytes());
      principal = identity.getPrincipal();
      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "validate principal = " + principal);

      if (principal == null) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "EXCEPTION:: validate principal == null");
        throw new Exception("Cannot add the bytes for the principal name '" + principal + "'");     
      }

      signature.update(principal.getBytes());

    } catch (SignatureException e) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "EXCEPTION:: validate", e);
      throw new Exception("Cannot add the bytes for the principal name '" + principal + "' :" + e.getMessage());
    }

    // Add roles
    Object[] roles = identity.getRoles();
    if (!Configuration.getBoolean(UNSORT_ROLES)) {
      // Sort roles before adding it to the signature to preserve the order
      Arrays.sort(roles);
    }
    for (int r = 0; r < roles.length; r++) {
      try {
        signature.update(((String)roles[r]).getBytes());
      } catch (SignatureException e) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "EXCEPTION:: validate", e);
        throw new Exception("Cannot add the bytes for the role '" + roles[r] + "' : " + e.getMessage());
      }
    }

    // Check signature
    boolean trusted = false;
    try {
      trusted = signature.verify(identity.getSignature());
    } catch (SignatureException e) {
      if (logger.isLoggable(BasicLevel.ERROR))
        logger.log(BasicLevel.ERROR, "EXCEPTION:: validate", e);
      throw new Exception("The signature found in the identity '" + this + "' is invalid:" + e.getMessage());
    }
View Full Code Here

Examples of java.security.Signature

      zis = new ZipInputStream(
          new BufferedInputStream( new FileInputStream( file ) ));
       
      byte[]    signature  = null;
     
      Signature  sig = Signature.getInstance("MD5withRSA" );

      sig.initVerify( key );
     
      while( true ){
       
        ZipEntry  entry = zis.getNextEntry();
         
        if ( entry == null ){
         
          break;
        }
     
        if ( entry.isDirectory()){
         
          continue;
        }
       
        String  name = entry.getName();
     
        ByteArrayOutputStream  output = null;
       
        if ( name.equalsIgnoreCase("azureus.sig")){
         
          output  = new ByteArrayOutputStream();
        }
                       
        byte[]  buffer = new byte[65536];
       
        while( true ){
       
          int  len = zis.read( buffer );
         
          if ( len <= 0 ){
           
            break;
          }
         
          if ( output == null ){
           
            sig.update( buffer, 0, len );
           
          }else{
           
            output.write( buffer, 0, len );
          }
        }
       
        if ( output != null ){
         
          signature = output.toByteArray();
        }
      }
           
      if ( signature == null ){
               
        throw( new AEVerifierException( AEVerifierException.FT_SIGNATURE_MISSING, "Signature missing from file" ));
      }
     
      if ( !sig.verify( signature )){
       
        throw( new AEVerifierException( AEVerifierException.FT_SIGNATURE_BAD, "Signature doesn't match data" ));
      }
    }finally{
     
View Full Code Here

Examples of java.security.Signature

    RSAPublicKeySpec   public_key_spec =
      new RSAPublicKeySpec( new BigInteger(modulus,16), new BigInteger(pub_exp,16));

    RSAPublicKey public_key   = (RSAPublicKey)key_factory.generatePublic( public_key_spec );
   
    Signature  sig = Signature.getInstance("MD5withRSA" );

    sig.initVerify( public_key );
   
    sig.update( data.getBytes( "UTF-8" ));
     
    if ( !sig.verify( signature )){
     
      throw( new AEVerifierException( AEVerifierException.FT_SIGNATURE_BAD, "Data verification failed, signature doesn't match data" ));
    }
  }
View Full Code Here

Examples of java.security.Signature

        PrivateKey      key,
        String          provider,
        SecureRandom    random)
        throws NoSuchProviderException, SecurityException, SignatureException, InvalidKeyException
    {
        Signature sig = null;

        if (sigOID == null)
        {
            throw new IllegalStateException("no signature algorithm specified");
        }

        try
        {
            sig = Signature.getInstance(sigOID.getId(), provider);
        }
        catch (NoSuchAlgorithmException ex)
        {
            try
            {
                sig = Signature.getInstance(signatureAlgorithm, provider);
            }
            catch (NoSuchAlgorithmException e)
            {
                throw new SecurityException("exception creating signature: " + e.toString());
            }
        }

        if (random != null)
        {
            sig.initSign(key, random);
        }
        else
        {
            sig.initSign(key);
        }

        if (extensions != null)
        {
            tbsGen.setExtensions(new X509Extensions(extOrdering, extensions));
        }

        TBSCertificateStructure tbsCert = tbsGen.generateTBSCertificate();

        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            DEROutputStream         dOut = new DEROutputStream(bOut);

            dOut.writeObject(tbsCert);

            sig.update(bOut.toByteArray());
        }
        catch (Exception e)
        {
            throw new SecurityException("exception encoding TBS cert - " + e);
        }

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(tbsCert);
        v.add(sigAlgId);
        v.add(new DERBitString(sig.sign()));

        return new X509CertificateObject(new X509CertificateStructure(new DERSequence(v)));
    }
View Full Code Here

Examples of java.security.Signature

    if ( !c.getSignatureAlgorithm().equals(c.getTBSCertList().getSignature()) )
    {
      throw new CRLException("Signature algorithm on CertifcateList does not match TBSCertList.");
    }

    Signature sig = Signature.getInstance(getSigAlgName(), sigProvider);

    sig.initVerify(key);
    sig.update(this.getTBSCertList());
    if ( !sig.verify(this.getSignature()) )
    {
      throw new SignatureException("CRL does not verify with supplied public key.");
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.