Examples of SkeletonKeyToken


Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      String encoded = new JWSBuilder()
              .content(tokenBytes)
              .rsa256(idpPair.getPrivate());

      SkeletonKeyToken v = null;
      try
      {
         v = RSATokenVerifier.verifyToken(encoded, metadata);
      }
      catch (VerificationException ignored)
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      String encoded = new JWSBuilder()
              .content(tokenBytes)
              .rsa256(idpPair.getPrivate());

      SkeletonKeyToken v = null;
      try
      {
         v = RSATokenVerifier.verifyToken(encoded, metadata);
         Assert.fail();
      }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

   }

   @Test
   public void testTokenAuth() throws Exception
   {
      token = new SkeletonKeyToken();
      token.principal("CN=Client")
              .audience("domain")
              .addAccess("service").addRole("admin").verifyCaller(true);
      byte[] tokenBytes = JsonSerialization.toByteArray(token, false);

      String encoded = new JWSBuilder()
              .content(tokenBytes)
              .rsa256(idpPair.getPrivate());

      SkeletonKeyToken v = null;
      try
      {
         v = RSATokenVerifier.verifyToken(encoded, metadata);
      }
      catch (VerificationException ignored)
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

   protected void logoutResources(String username, String admin)
   {
      if (skeletonKeyConfig.getResources().size() != 0)
      {
         SkeletonKeyToken token = new SkeletonKeyToken();
         token.id(generateId());
         token.principal(admin);
         token.audience(skeletonKeyConfig.getRealm());
         SkeletonKeyToken.Access realmAccess = new SkeletonKeyToken.Access();
         realmAccess.addRole(skeletonKeyConfig.getAdminRole());
         token.setRealmAccess(realmAccess);
         String tokenString = buildTokenString(realmPrivateKey, token);
         ResteasyClient client = new ResteasyClientBuilder()
                 .providerFactory(providers)
                 .hostnameVerification(ResteasyClientBuilder.HostnameVerificationPolicy.ANY)
                 .trustStore(resourceMetadata.getTruststore())
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      if (!skeletonKeyConfig.isCancelPropagation())
      {
         GenericPrincipal gp = (GenericPrincipal) request.getPrincipal();
         if (gp != null)
         {
            SkeletonKeyToken token = buildToken(gp);
            String stringToken = buildTokenString(realmPrivateKey, token);
            SkeletonKeySession skSession = new SkeletonKeySession(stringToken, resourceMetadata);
            request.setAttribute(SkeletonKeySession.class.getName(), skSession);
            ResteasyProviderFactory.pushContext(SkeletonKeySession.class, skSession);
            request.getSessionInternal(true).setNote(SkeletonKeySession.class.getName(), skSession);
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

         response.sendError(400);
         return;
      }
      GenericPrincipal gp = basicAuth(request, response);
      if (gp == null) return;
      SkeletonKeyToken token = buildToken(gp);
      AccessTokenResponse res = accessTokenResponse(realmPrivateKey, token);
      response.setStatus(200);
      response.setContentType("application/json");
      accessTokenResponseWriter.writeValue(response.getOutputStream(), res);
      response.getOutputStream().flush();
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      response.sendError(401);
   }

   protected void redirectAccessCode(boolean sso, Response response, String redirect_uri, String client_id, String state, GenericPrincipal gp) throws IOException
   {
      SkeletonKeyToken token = buildToken(gp);
      AccessCode code = new AccessCode();
      code.setToken(token);
      code.setClient(client_id);
      code.setSso(sso);
      code.setRedirect(redirect_uri);
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      log.debug("<--- end oauthAuthenticate");
   }

   protected SkeletonKeyToken buildToken(GenericPrincipal gp)
   {
      SkeletonKeyToken token = new SkeletonKeyToken();
      token.id(generateId());
      token.principal(gp.getName());
      token.audience(skeletonKeyConfig.getRealm());
      int expiration = skeletonKeyConfig.getAccessCodeLifetime() == 0 ? 3600 : skeletonKeyConfig.getAccessCodeLifetime();
      if (skeletonKeyConfig.getTokenLifetime() > 0)
      {
         token.expiration((System.currentTimeMillis() / 1000) + expiration);
      }
      SkeletonKeyToken.Access realmAccess = new SkeletonKeyToken.Access();
      for (String role : gp.getRoles())
      {
         realmAccess.addRole(role);
      }
      token.setRealmAccess(realmAccess);
      return token;
   }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

   }

   protected SkeletonKeyToken createAccessToken(User user, Realm realm)
   {
      List<Resource> resources = identityManager.getResources(realm);
      SkeletonKeyToken token = new SkeletonKeyToken();
      token.id(generateId());
      token.principal(user.getUsername());
      token.audience(realm.getName());
      if (realm.getTokenLifespan() > 0)
      {
         token.expiration((System.currentTimeMillis() / 1000) + realm.getTokenLifespan());
      }
      RoleMapping realmMapping = identityManager.getRoleMapping(realm, user);
      if (realmMapping != null && realmMapping.getRoles().size() > 0)
      {
         SkeletonKeyToken.Access access = new SkeletonKeyToken.Access();
         for (String role : realmMapping.getRoles())
         {
            access.addRole(role);
         }
         token.setRealmAccess(access);
      }
      for (Resource resource : resources)
      {
         RoleMapping mapping = identityManager.getRoleMapping(realm, resource, user);
         if (mapping == null) continue;
         SkeletonKeyToken.Access access = token.addAccess(resource.getName())
                                               .verifyCaller(resource.isSurrogateAuthRequired());
         for (String role : mapping.getRoles())
         {
            access.addRole(role);
         }
      }
      if (token.getResourceAccess() == null || token.getResourceAccess().size() == 0) return null;
      return token;
   }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.SkeletonKeyToken

      }
      boolean authenticated = authenticate(realm, user, formData);
      if (!authenticated) return loginForm("Unable to authenticate, try again", redirect, clientId, scopeParam, state, realm, client);

      SkeletonKeyToken token = createToken(scopeParam, realm, client, user);
      AccessCode code = new AccessCode();
      code.setExpiration((System.currentTimeMillis() / 1000) + realm.getAccessCodeLifespan());
      code.setToken(token);
      code.setClient(client);
      synchronized (accessCodeMap)
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.