Package org.atomojo.auth.service.db

Examples of org.atomojo.auth.service.db.Realm


      getContext().getLogger().fine("Finding realm...");
      boolean found = false;
      String realmName = AuthApplication.getStringAttribute(request,"realm-name",null);
      if (realmName!=null) {
         try {
            Realm realm = db.getRealm(realmName);
            if (realm!=null) {
               if (getContext().getLogger().isLoggable(Level.FINE)) {
                  getContext().getLogger().fine("Found realm by name "+realmName);
               }
               found = true;
               request.getAttributes().put(AuthApplication.REALM_ATTR,realm);
            }
         } catch (SQLException ex) {
            getContext().getLogger().log(Level.SEVERE,"Cannot retrieve realm.",ex);
         }
      }
      String realmId = AuthApplication.getStringAttribute(request,"realm-id",null);
      if (realmId!=null && !found) {
         try {
            Realm realm = db.getRealm(UUID.fromString(realmId));
            if (realm!=null) {
               if (getContext().getLogger().isLoggable(Level.FINE)) {
                  getContext().getLogger().fine("Found realm by id "+realmId);
               }
               found = true;
View Full Code Here


            String identifier = request.getChallengeResponse().getIdentifier();
            char[] secret = request.getChallengeResponse().getSecret();
            if ((identifier != null) && (secret != null)) {
               getContext().getLogger().info("Authenticating " + identifier);
               try {
                  Realm currentRealm = RealmUserGuard.this.realm == null ? (Realm) request.getAttributes().get(AuthApplication.REALM_ATTR) : RealmUserGuard.this.realm;
                  if (currentRealm != null) {
                     RealmUser user = AuthResource.findRealmUser(RealmUserGuard.this.db, currentRealm, identifier);
                     if (user != null && user.getUser().checkPassword(new String(secret))) {
                        getContext().getLogger().info("Authenticated: " + user.getAlias() + ", checking roles and groups");
                        if (permissions != null) {
View Full Code Here

   }
  
   public Representation get()
   {
      try {
         Realm realm = fetch();
         if (realm!=null) {
            Representation entity = new DBObjectRepresentation(MediaType.APPLICATION_XML,realm);
            entity.setCharacterSet(CharacterSet.UTF_8);
            return entity;
         }
View Full Code Here

      return (Realm)getRequest().getAttributes().get(AuthApplication.REALM_ATTR);
   }
  
   public Representation delete() {
      try {
         Realm realm = fetch();
         if (realm!=null) {
            realm.delete();
            getResponse().setStatus(Status.SUCCESS_NO_CONTENT);
         } else {
            getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
         }
         return null;
View Full Code Here

   }
  
   public Representation get()
   {
      try {
         Realm realm = fetchRealm();
         if (realm==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return new StringRepresentation("The realm does not exist.");
         } else {
            Representation entity = new DBIteratorRepresentation(MediaType.APPLICATION_XML,XML.GROUPS_NAME,db.getGroups(realm),false);
View Full Code Here

         String sid = top.getAttributeValue("id");
         UUID id = sid==null ? UUID.randomUUID() : UUID.fromString(sid);
         String alias = top.getAttributeValue("alias");

         try {
            Realm realm = fetchRealm();
            if (realm==null) {
               getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
               return new StringRepresentation("The realm does not exist.");
            } else {
               Group group = db.createGroup(realm,id,alias);
View Full Code Here

   }
  
   protected Realm fetchRealm()
      throws SQLException
   {
      Realm realm = (Realm)getRequest().getAttributes().get(AuthApplication.REALM_ATTR);
      /*
      Realm realm = null;
      if (realmName!=null) {
         realm = db.getRealm(realmName);
      }
View Full Code Here

         if (role==null) {
            getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
            return new StringRepresentation("Role not found.");
         }
         if (realmId!=null || realmName!=null) {
            Realm realm = fetchRealm();
            if (realm==null) {
               getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
               return new StringRepresentation("Realm not found.");
            }
            RealmUser user = fetchRealmUser(realm);
View Full Code Here

   }
  
   protected Realm fetchRealm()
      throws SQLException,IllegalArgumentException
   {
      Realm realm = null;
      if (realmName!=null) {
         realm = db.getRealm(realmName);
      }
      if (realmId!=null) {
         UUID id = UUID.fromString(realmId);
View Full Code Here

   }
  
   public Representation get()
   {
      try {
         Realm realm  = fetch();
         if (realm!=null) {
            Representation entity = new DBIteratorRepresentation(MediaType.APPLICATION_XML,XML.USERS_NAME,db.getRealmUsers(realm));
            entity.setCharacterSet(CharacterSet.UTF_8);
            return entity;
         } else {
View Full Code Here

TOP

Related Classes of org.atomojo.auth.service.db.Realm

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.