Package org.restlet.data

Examples of org.restlet.data.ChallengeResponse


   public Entry createEntry(String xml)
      throws StatusException,IOException,XMLException
   {
      Request request = new Request(Method.POST,editURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      if (cookie!=null) {
         request.getCookies().add(cookie);
      }
      request.setEntity(new StringRepresentation(xml,MediaType.APPLICATION_ATOM_XML));
      Response response = new Response(request);
      editClient.handle(request,response);
      Status status = response.getStatus();
      if (response.isEntityAvailable()) {
         response.getEntity().release();
      }
      if (!status.isSuccess()) {
         throw new StatusException("Cannot create entry due to status "+status.getCode(),status);
      }
      Reference location = response.getLocationRef();
     
      request = new Request(Method.GET,location);
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      Response entryResponse = locClient.handle(request);
      if (!entryResponse.getStatus().isSuccess()) {
         if (entryResponse.isEntityAvailable()) {
            entryResponse.getEntity().release();
View Full Code Here


   public Status updateEntry(UUID entryId,String xml)
   {
      URI entryURI = getEntryLocation(entryId);
      Request request = new Request(Method.PUT,entryURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      if (cookie!=null) {
         request.getCookies().add(cookie);
      }
      request.setEntity(new StringRepresentation(xml,MediaType.APPLICATION_ATOM_XML));
View Full Code Here

   public Entry createMedia(UUID id,String filePath,Representation rep)
      throws StatusException,IOException,XMLException
   {
      Request request = new Request(Method.POST,editURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      if (cookie!=null) {
         request.getCookies().add(cookie);
      }
      Form headers = (Form)request.getAttributes().get("org.restlet.http.headers");
View Full Code Here

   public Status updateMedia(String filePath,Representation rep)
   {
      URI mediaURI = location.resolve("./"+filePath);
      Request request = new Request(Method.PUT,mediaURI.toString());
      if (identity!=null) {
         request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,identity.getName(),identity.getPassword()));
      }
      if (cookie!=null) {
         request.getCookies().add(cookie);
      }
      request.setEntity(rep);
View Full Code Here

      this.db = db;
      this.permission = null;
      this.group = null;
      setVerifier(new Verifier() {
         public int verify(Request request, Response response) {
            ChallengeResponse cr = request.getChallengeResponse();
            if (cr==null) {
               return Verifier.RESULT_MISSING;
            }
            try {
               String identifier = cr.getIdentifier();
               char [] secret = cr.getSecret();
               getContext().getLogger().info("Finding user "+identifier);
               User user = AuthResource.findUser(UserGuard.this.db,identifier);
               if (user==null) {
                  getContext().getLogger().info("No such user.");
                  return Verifier.RESULT_INVALID;
View Full Code Here

      this.requiredGroups = new ArrayList<String>();
      this.authService = authService;
      setVerifier(new Verifier() {
         public int verify(Request request, Response response) {
            request.getAttributes().put(App.AUTH_SERVICE_ATTR,UserGuard.this.authService);
            ChallengeResponse cr = request.getChallengeResponse();
            Cookie cookie = request.getCookies().getFirst("I");

            // We must have one of these to check
            if (cr==null && cookie==null) {
               return Verifier.RESULT_MISSING;
View Full Code Here

      this.permissions = null;
      this.group = null;
      this.adminPermission = adminPermission;
      setVerifier(new Verifier() {
         public int verify(Request request,Response response) {
            ChallengeResponse cr = request.getChallengeResponse();
            if (cr==null) {
               return Verifier.RESULT_MISSING;
            }
            String identifier = request.getChallengeResponse().getIdentifier();
            char[] secret = request.getChallengeResponse().getSecret();
View Full Code Here

   public boolean createGroup(AuthCredentials cred,String name)
      throws AuthException
   {
      String groupsURL = serviceBase.resolve("./groups").toString();
      Request request = new Request(Method.POST,groupsURL);
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
      request.setEntity(new StringRepresentation("<group xmlns='"+NAMESPACE+"' alias='"+name+"'/>",MediaType.APPLICATION_XML));
      Response response = client.handle(request);
      return response.getStatus().isSuccess();
   }
View Full Code Here

   public boolean deleteGroup(AuthCredentials cred,String name)
      throws AuthException
   {
      String groupURL = serviceBase.resolve("./groups/a/"+name).toString();
      Request request = new Request(Method.DELETE,groupURL);
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
      Response response = client.handle(request);
      return response.getStatus().isSuccess();
   }
View Full Code Here

   public boolean addUserToGroup(AuthCredentials cred,String alias,String name)
      throws AuthException
   {
      String groupURL = serviceBase.resolve("./groups/a/"+name+"/users").toString();
      Request request = new Request(Method.POST,groupURL);
      request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,cred.getName(),cred.getPassword()));
      request.setEntity(new StringRepresentation("<user xmlns='"+NAMESPACE+"' alias='"+alias+"'/>",MediaType.APPLICATION_XML));
      Response response = client.handle(request);
      boolean success = response.getStatus().isSuccess();
      if (!success && response.getStatus().getCode()!=404) {
         throw new AuthException("Failed to add "+alias+" to group "+name+", status="+response.getStatus().getCode());
View Full Code Here

TOP

Related Classes of org.restlet.data.ChallengeResponse

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.