Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1.   public synchronized void authenticate() throws PortalSecurityException {
  2.     this.isauth = false;
  3.     if (this.myPrincipal.UID != null && this.myOpaqueCredentials.credentialstring != null) {
  4.       String first_name = null, last_name = null;
  5.       try {
  6.         String acct[] = AccountStoreFactory.getAccountStoreImpl().getUserAccountInformation(this.myPrincipal.UID);
  7.         if (acct[0] != null) {
  8.           first_name = acct[1];
  9.           last_name = acct[2];
  10.           this.myPrincipal.FullName = first_name + " " + last_name;
  11.           if (log.isInfoEnabled())
  12.               log.info( "User " + this.myPrincipal.UID + " is authenticated");
  13.  
  14.           // Encrypt our credentials using the spring-configured password
  15.           // encryption service
  16.           IStringEncryptionService encryptionService = PasswordEncryptionServiceLocator.getPasswordEncryptionService();
  17.           String encryptedPassword = encryptionService.encrypt(new String(this.myOpaqueCredentials.credentialstring));
  18.           byte[] encryptedPasswordBytes = encryptedPassword.getBytes();
  19.          
  20.           // Save our encrypted credentials so the parent's authenticate()
  21.           // method doesn't blow them away.
  22.           this.cachedcredentials = new byte[encryptedPasswordBytes.length];
  23.           System.arraycopy(encryptedPasswordBytes, 0, this.cachedcredentials, 0, encryptedPasswordBytes.length);
  24.           this.isauth = true;
  25.         }
  26.         else
  27.             if (log.isInfoEnabled())
  28.                 log.info( "No such user: " + this.myPrincipal.UID);
  29.       } catch (Exception e) {
  30.         PortalSecurityException ep = new PortalSecurityException("SQL Database Error");
  31.         log.error( "SQL database error", e);
  32.         throw  (ep);
  33.       }
  34.     }
  35.     else {
  36.         if (this.myPrincipal.UID == null) {
  37.             log.error( "Principal not initialized prior to authenticate");
  38.         }
  39.         if (this.myOpaqueCredentials.credentialstring == null) {
  40.             log.error( "OpaqueCredentials not initialized prior to authenticate");
  41.         }
  42.     }
  43.     // Ok...we are now ready to authenticate all of our subcontexts.
  44.     super.authenticate();
  45.     return;
  46.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement