Package org.mitre.jose.keystore

Examples of org.mitre.jose.keystore.JWKSetKeyStore


    public JwtSigningAndValidationService load(String key) throws Exception {

      String jsonString = restTemplate.getForObject(key, String.class);
      JWKSet jwkSet = JWKSet.parse(jsonString);

      JWKSetKeyStore keyStore = new JWKSetKeyStore(jwkSet);

      JwtSigningAndValidationService service = new DefaultJwtSigningAndValidationService(keyStore);

      return service;
View Full Code Here


    @Override
    public JwtEncryptionAndDecryptionService load(String key) throws Exception {
      String jsonString = restTemplate.getForObject(key, String.class);
      JWKSet jwkSet = JWKSet.parse(jsonString);

      JWKSetKeyStore keyStore = new JWKSetKeyStore(jwkSet);

      JwtEncryptionAndDecryptionService service = new DefaultJwtEncryptionAndDecryptionService(keyStore);

      return service;
    }
View Full Code Here

    // Key Store
   
    keys_list.add(RSAjwk);
    keys_list.add(AESjwk);
    JWKSet jwkSet = new JWKSet(keys_list);
    JWKSetKeyStore keyStore = new JWKSetKeyStore(jwkSet);
   
    service_ks = new DefaultJwtEncryptionAndDecryptionService(keyStore);
  }
View Full Code Here

 
  /* Constructors with no valid Resource setup */
  @Test
  public void ksConstructorTest() {

    JWKSetKeyStore ks = new JWKSetKeyStore(jwkSet);
    assertEquals(ks.getJwkSet(), jwkSet);
   
    JWKSetKeyStore ks_empty= new JWKSetKeyStore();
    assertEquals(ks_empty.getJwkSet(), null)
   
    boolean thrown = false;
    try {
      JWKSetKeyStore ks_null = new JWKSetKeyStore(null);
    } catch (IllegalArgumentException e) {
      thrown = true;
    }
    assertTrue(thrown);
  }
View Full Code Here

    byte jwtbyte[] = RSAjwk.toString().getBytes();
    FileOutputStream out = new FileOutputStream(ks_file_badJWK);
    out.write(jwtbyte);
    out.close();
   
    JWKSetKeyStore ks_badJWK = new JWKSetKeyStore();
    Resource loc = new FileSystemResource(ks_file_badJWK);
    assertTrue(loc.exists());
   
    ks_badJWK.setLocation(loc);
    assertEquals(loc.getFilename(), ks_file_badJWK);
   
    ks_badJWK = new JWKSetKeyStore(null);
  }
View Full Code Here

 
  /* Empty constructor with valid Resource */
  @Test
  public void ksEmptyConstructorkLoc() {

    JWKSetKeyStore ks = new JWKSetKeyStore();
   
    File file = new File(ks_file);
   
    /* First, test with file without "read" permission */

        boolean set = false;

        if (file.exists()) {
                set = file.setReadable(false);
        }
       
        // skip this part of the test on systems that don't allow the settable function, like Windows
        if (set) {
         
          Resource loc_noread = new FileSystemResource(file);
          assertTrue(loc_noread.exists());
          // assertTrue(!loc_noread.isReadable());
 
          boolean thrown = false;
          try {
                  ks.setLocation(loc_noread);
          } catch (IllegalArgumentException e) {
                  thrown = true;
          }
          assertTrue(thrown);
 
          /* Now, make cache file readable */
 
          if (file.exists()) {
                  file.setReadable(true);
          }

        }
   
        Resource loc = new FileSystemResource(file);
    assertTrue(loc.exists());
    assertTrue(loc.isReadable());

    ks.setLocation(loc);
   
    assertEquals(loc.getFilename(),ks.getLocation().getFilename());   
  }
View Full Code Here

 
  @Test
  public void ksSetJwkSet() throws IllegalArgumentException {
    
    JWKSetKeyStore ks = new JWKSetKeyStore();
    boolean thrown = false;
    try {
      ks.setJwkSet(null);
    } catch (IllegalArgumentException e) {
      thrown = true;
    }
    assertTrue(thrown);

    ks.setJwkSet(jwkSet);;
    assertEquals(ks.getJwkSet(), jwkSet);
  }
View Full Code Here

TOP

Related Classes of org.mitre.jose.keystore.JWKSetKeyStore

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.