Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZNTA-1841 convert some java class to kotlin
- Loading branch information
Patrick Huang
committed
Oct 3, 2017
1 parent
fe398cf
commit e02faa6
Showing
4 changed files
with
193 additions
and
232 deletions.
There are no files selected for viewing
95 changes: 0 additions & 95 deletions
95
server/services/src/main/java/org/zanata/security/SamlIdentity.java
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
server/services/src/main/java/org/zanata/security/SamlIdentity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
R * Copyright 2010, Red Hat, Inc. and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.zanata.security | ||
|
||
import java.io.Serializable | ||
import java.security.Principal | ||
|
||
import javax.enterprise.context.SessionScoped | ||
import javax.enterprise.event.Event | ||
import javax.inject.Inject | ||
|
||
import org.zanata.events.AlreadyLoggedInEvent | ||
import org.zanata.util.ServiceLocator | ||
import org.zanata.util.Synchronized | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings | ||
|
||
@SessionScoped | ||
@Synchronized | ||
class SamlIdentity : Serializable { | ||
|
||
@Inject | ||
lateinit private var identity: ZanataIdentity | ||
|
||
@SuppressFBWarnings("SE_BAD_FIELD") | ||
@Inject | ||
lateinit private var alreadyLoggedInEvent: Event<AlreadyLoggedInEvent> | ||
lateinit var uniqueNameId: String | ||
lateinit var email: String | ||
lateinit var name: String | ||
|
||
fun authenticate(uniqueNameId: String, username: String?, | ||
email: String?, name: String?) { | ||
this.uniqueNameId = uniqueNameId | ||
this.email = email ?: "" | ||
this.name = name ?: "" | ||
|
||
if (identity.isLoggedIn) { | ||
alreadyLoggedInEvent.fire(AlreadyLoggedInEvent()) | ||
return | ||
} | ||
|
||
with (identity) { | ||
credentials.username = username | ||
credentials.password = "" | ||
credentials.authType = AuthenticationType.SSO | ||
credentials.isInitialized = true | ||
isPreAuthenticated = true | ||
} | ||
} | ||
|
||
fun login(principal: Principal) { | ||
if (identity.isLoggedIn) { | ||
alreadyLoggedInEvent.fire(AlreadyLoggedInEvent()) | ||
return | ||
} | ||
|
||
identity.acceptExternallyAuthenticatedPrincipal(principal) | ||
} | ||
|
||
companion object { | ||
private const val serialVersionUID = 5341594999046279309L | ||
} | ||
} |
137 changes: 0 additions & 137 deletions
137
server/services/src/main/java/org/zanata/servlet/SAMLFilter.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.