Examples of AuthService


Examples of org.apache.cxf.authservice.AuthService

        AegisDatabinding aegisBinding = new AegisDatabinding();
        JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
        proxyFactory.setDataBinding(aegisBinding);
        proxyFactory.setServiceClass(AuthService.class);
        proxyFactory.setAddress("http://localhost:9002/jaxwsAndAegis");
        AuthService service = (AuthService) proxyFactory.create();
        assertTrue(service.authenticate("Joe", "Joe", "123"));
        assertFalse(service.authenticate("Joe1", "Joe", "fang"));     
        List<String> list = service.getRoles("Joe");
        assertEquals(1, list.size());
        assertEquals("Joe", list.get(0));
        assertEquals("get Joe", service.getAuthentication("Joe"));
        Authenticate au = new Authenticate();
        au.setSid("ffang");
        au.setUid("ffang");
        assertTrue(service.authenticate(au));
        au.setUid("ffang1");
        assertFalse(service.authenticate(au));
    }
View Full Code Here

Examples of org.apache.cxf.authservice.AuthService

        AegisDatabinding aegisBinding = new AegisDatabinding();
        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
        proxyFactory.setDataBinding(aegisBinding);
        proxyFactory.setServiceClass(AuthService.class);
        proxyFactory.setAddress("http://localhost:9002/service");
        AuthService service = (AuthService) proxyFactory.create();
        assertTrue(service.authenticate("Joe", "Joe", "123"));
        assertFalse(service.authenticate("Joe1", "Joe", "fang"));     
        assertTrue(service.authenticate("Joe", null, "123"));
        List<String> list = service.getRoles("Joe");
        assertEquals(3, list.size());
        assertEquals("Joe", list.get(0));
        assertEquals("Joe-1", list.get(1));
        assertEquals("Joe-2", list.get(2));
        String roles[] = service.getRolesAsArray("Joe");
        assertEquals(2, roles.length);
        assertEquals("Joe", roles[0]);
        assertEquals("Joe-1", roles[1]);
       
        assertEquals("get Joe", service.getAuthentication("Joe"));
        Authenticate au = new Authenticate();
        au.setSid("ffang");
        au.setUid("ffang");
        assertTrue(service.authenticate(au));
        au.setUid("ffang1");
        assertFalse(service.authenticate(au));
    }
View Full Code Here

Examples of org.apache.cxf.authservice.AuthService

        AegisDatabinding aegisBinding = new AegisDatabinding();
        JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
        proxyFactory.setDataBinding(aegisBinding);
        proxyFactory.setServiceClass(AuthService.class);
        proxyFactory.setAddress("http://localhost:9002/jaxwsAndAegis");
        AuthService service = (AuthService) proxyFactory.create();
        assertTrue(service.authenticate("Joe", "Joe", "123"));
        assertFalse(service.authenticate("Joe1", "Joe", "fang"));     
        assertTrue(service.authenticate("Joe", null, "123"));
        List<String> list = service.getRoles("Joe");
        assertEquals(3, list.size());
        assertEquals("Joe", list.get(0));
        assertEquals("Joe-1", list.get(1));
        assertEquals("Joe-2", list.get(2));
        String roles[] = service.getRolesAsArray("Joe");
        assertEquals(2, roles.length);
        assertEquals("Joe", roles[0]);
        assertEquals("Joe-1", roles[1]);
       
        roles = service.getRolesAsArray("null");
        assertNull(roles);
       
        roles = service.getRolesAsArray("0");
        assertEquals(0, roles.length);
       
        assertEquals("get Joe", service.getAuthentication("Joe"));
        Authenticate au = new Authenticate();
        au.setSid("ffang");
        au.setUid("ffang");
        assertTrue(service.authenticate(au));
        au.setUid("ffang1");
        assertFalse(service.authenticate(au));
    }
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

               }
               if (authName==null) {
                  getLogger().warning("Ignoring db entry where auth term "+DB_NAME_TERM+" does not have a value.");
                  return;
               }
               AuthService auth = services.get(authName);
               if (auth==null) {
                  auth = autoServices.get(authName);
               }
               if (auth==null) {
                  getLogger().warning("Cannot configure db entry for "+dbName+" as auth service "+authName+" does not exist.");
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

   }
  
   public void toXML(ItemDestination dest)
      throws AuthException,XMLException
   {
      AuthService auth = (AuthService)getRequest().getAttributes().get(App.AUTH_SERVICE_ATTR);
      AuthCredentials cred = new AuthCredentials(getRequest().getChallengeResponse());
      final Iterator<User> users = auth.getUsers(cred);

      ItemConstructor constructor = InfosetFactory.getDefaultInfoset().createItemConstructor();
      dest.send(constructor.createDocument());
      dest.send(constructor.createElement(NM_USERS));
      dest.send(constructor.createCharacters("\n"));
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

      dest.send(constructor.createDocumentEnd());
   }
  
   public Representation post(Representation entity)
   {
      AuthService auth = (AuthService)getRequest().getAttributes().get(App.AUTH_SERVICE_ATTR);
      if (!XMLRepresentationParser.isXML(entity.getMediaType())) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Non-XML media type for entity body: "+entity.getMediaType().getName());
      }
      Document doc = null;
      try {
         doc = parser.load(entity);
      } catch (Exception ex) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("XML parse error: "+ex.getMessage());
      }
     
      Element top = doc.getDocumentElement();
      if (!top.getName().equals(NM_USER)) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Unknown document element: "+top.getName());
      }
      String alias = top.getAttributeValue("alias");
      String password = top.getAttributeValue("password");
      if (password==null) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("The password is missing.");
      }
     
      alias = alias.trim();
      password = password.trim();
      if (alias.length()==0 || password.length()==0) {
         getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
         return new StringRepresentation("Empty alias or password.");
      }
     
      Element nameE = top.getFirstElementNamed(NM_NAME);
      String name = null;
      if (nameE!=null) {
         name = nameE.getText();
      } else {
         name = alias;
      }
      Element emailE = top.getFirstElementNamed(NM_EMAIL);
      String email = null;
      if (emailE!=null) {
         email = emailE.getText();
      }
      try {
         AuthCredentials cred = new AuthCredentials(getRequest().getChallengeResponse());
         if (auth.getUser(cred,alias)!=null) {
            getResponse().setStatus(Status.CLIENT_ERROR_CONFLICT);
            return new StringRepresentation("User "+alias+" already exists.");
         } else {
            UUID id = UUID.randomUUID();
            try {
               auth.createUser(cred,alias,name,email,password);
               getResponse().setStatus(Status.SUCCESS_CREATED);
               Reference ref = new Reference(getRequest().getResourceRef().toString()+"/"+alias);
               getResponse().setLocationRef(ref);
               return null;
            } catch (AuthException ex) {
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

     
      public AuthService newInstance()
         throws AuthException
      {
         try {
            AuthService service = serviceClass.newInstance();
            service.init(props);
            return service;
         } catch (InstantiationException ex) {
            throw new AuthException("Cannot instantiate service "+serviceClass.getName(),ex);
         } catch (IllegalAccessException ex) {
            throw new AuthException("Cannot instantiate service "+serviceClass.getName(),ex);
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

      services = new HashMap<String,AuthService>();
      autoServices = new HashMap<String,AuthService>();
     
      for (ServerConfiguration.Auth auth : serverConf.getAuthServices().values()) {
         try {
            AuthService service = auth.newInstance();
            services.put(auth.getName(),service);
         } catch (AuthException ex) {
            getLogger().log(Level.SEVERE,"Cannot instantiate auth service "+auth.getName(),ex);
         }
      }
      ServerAdminApplication admin = new ServerAdminApplication(childContext,dbConfList,autodbList,storageFactory);
      for (ServerConfiguration.AdminHost adminHost : serverConf.getAdminHosts().values()) {
        
         VirtualHost vhost =  createVirtualHost(adminHost);
         getHosts().add(vhost);
         adminRouters.add(vhost);
         String authName = adminHost.getAuthName();
         if (authName==null) {
            getLogger().severe("The admin interface is missing a named auth service.");
            continue;
         }
         AuthService service = services.get(authName);
         if (service==null) {
            getLogger().severe("Cannot find auth service "+authName+" for admin interface.");
            continue;
         }
         UserGuard adminGuard = new UserGuard(childContext,ChallengeScheme.HTTP_BASIC,"Atom Administrator",service);
         adminGuard.getRequiredGroups().add(AuthService.ADMIN_GROUP);
         adminGuard.setNext(admin);
        
         vhost.attach("/admin",adminGuard);
        
      }
     
      admins = new HashMap<String,Restlet>();
      Restlet lastAdmin = null;
      for (final DB adminDB : dbList.values()) {
         getLogger().info("Configuring database "+adminDB.getName()+" for administration");
         ServerConfiguration.Database databaseConf = serverConf.getDatabases().get(adminDB.getName());
         AuthService service = null;
         if (databaseConf==null || databaseConf.getAuthName()==null) {
            service = new DBAuthService();
            Properties props = new Properties();
            props.setProperty("database",adminDB.getName());
            props.setProperty("dir", adminDB.getDatabaseDir().getAbsolutePath());
            try {
               service.init(props);
            } catch (AuthException ex) {
               getLogger().log(Level.SEVERE,"Cannot instantiate auth service for database "+adminDB.getName(),ex);
               continue;
            }
         } else {
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

         atomDB = autodbList.get(host.getDatabaseName());
      }
      if (atomDB==null) {
         throw new RuntimeException("Database "+host.getDatabaseName()+" does not exist.");
      }
      AuthService auth = atomDB.getAuthService();
      if (auth==null) {
         throw new RuntimeException("The auth service for database "+host.getDatabaseName()+" does not exist.");
      }
     
      Storage storage = storageFactory.getStorage(atomDB.getDB());
View Full Code Here

Examples of org.atomojo.app.auth.AuthService

      if (facet!=null) {
         getResponse().setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
         return null;
      }
        
      AuthService auth = (AuthService)getRequest().getAttributes().get(App.AUTH_SERVICE_ATTR);

      User user = null;
      try {
         ChallengeResponse transCred = getRequest().getChallengeResponse();
         AuthCredentials cred = new AuthCredentials(transCred.getScheme().toString(),transCred.getIdentifier(),new String(transCred.getSecret()));
         user = auth.getUser(cred,alias);
         if (user==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
            return new StringRepresentation("User "+alias+" does not exist.");
         }
      } catch (AuthException ex) {
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.