Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public synchronized void authenticate() throws PortalSecurityException {
- this.isauth = false;
- if (this.myPrincipal.UID != null && this.myOpaqueCredentials.credentialstring != null) {
- String first_name = null, last_name = null;
- try {
- String acct[] = AccountStoreFactory.getAccountStoreImpl().getUserAccountInformation(this.myPrincipal.UID);
- if (acct[0] != null) {
- first_name = acct[1];
- last_name = acct[2];
- this.myPrincipal.FullName = first_name + " " + last_name;
- if (log.isInfoEnabled())
- log.info( "User " + this.myPrincipal.UID + " is authenticated");
- // Encrypt our credentials using the spring-configured password
- // encryption service
- IStringEncryptionService encryptionService = PasswordEncryptionServiceLocator.getPasswordEncryptionService();
- String encryptedPassword = encryptionService.encrypt(new String(this.myOpaqueCredentials.credentialstring));
- byte[] encryptedPasswordBytes = encryptedPassword.getBytes();
- // Save our encrypted credentials so the parent's authenticate()
- // method doesn't blow them away.
- this.cachedcredentials = new byte[encryptedPasswordBytes.length];
- System.arraycopy(encryptedPasswordBytes, 0, this.cachedcredentials, 0, encryptedPasswordBytes.length);
- this.isauth = true;
- }
- else
- if (log.isInfoEnabled())
- log.info( "No such user: " + this.myPrincipal.UID);
- } catch (Exception e) {
- PortalSecurityException ep = new PortalSecurityException("SQL Database Error");
- log.error( "SQL database error", e);
- throw (ep);
- }
- }
- else {
- if (this.myPrincipal.UID == null) {
- log.error( "Principal not initialized prior to authenticate");
- }
- if (this.myOpaqueCredentials.credentialstring == null) {
- log.error( "OpaqueCredentials not initialized prior to authenticate");
- }
- }
- // Ok...we are now ready to authenticate all of our subcontexts.
- super.authenticate();
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement